• Home
  • Raw
  • Download

Lines Matching refs:c_session

218     coap_session_t *c_session =  in coap_gnutls_audit_log_func()  local
221 coap_session_str(c_session), text); in coap_gnutls_audit_log_func()
386 coap_dtls_get_tls(const coap_session_t *c_session, in coap_dtls_get_tls() argument
390 if (c_session && c_session->tls) { in coap_dtls_get_tls()
391 const coap_gnutls_env_t *g_env = (const coap_gnutls_env_t *)c_session->tls; in coap_dtls_get_tls()
511 coap_session_t *c_session = in psk_client_callback() local
530 if (c_session == NULL || c_session->context == NULL || in psk_client_callback()
531 c_session->context->get_client_psk == NULL) { in psk_client_callback()
535 g_context = (coap_gnutls_context_t *)c_session->context->dtls_context; in psk_client_callback()
539 setup_data = &c_session->cpsk_setup_data; in psk_client_callback()
554 c_session, in psk_client_callback()
577 psk_len = c_session->context->get_client_psk(c_session, in psk_client_callback()
711 coap_session_t *c_session) { in check_rpk_cert() argument
730 c_session, in check_rpk_cert()
751 coap_session_t *c_session = in cert_verify_gnutls() local
754 (coap_gnutls_context_t *)c_session->context->dtls_context; in cert_verify_gnutls()
755 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in cert_verify_gnutls()
765 if (!check_rpk_cert(g_context, &cert_info, c_session)) { in cert_verify_gnutls()
786 coap_session_str(c_session), in cert_verify_gnutls()
794 coap_session_str(c_session), in cert_verify_gnutls()
806 coap_session_str(c_session), in cert_verify_gnutls()
814 coap_session_str(c_session), in cert_verify_gnutls()
826 coap_session_str(c_session), in cert_verify_gnutls()
835 coap_session_str(c_session), in cert_verify_gnutls()
844 coap_session_str(c_session), in cert_verify_gnutls()
853 coap_session_str(c_session), in cert_verify_gnutls()
864 coap_session_str(c_session), in cert_verify_gnutls()
893 c_session, in cert_verify_gnutls()
924 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in cert_verify_gnutls()
1469 coap_session_t *c_session = in post_client_hello_gnutls_psk() local
1472 (coap_gnutls_context_t *)c_session->context->dtls_context; in post_client_hello_gnutls_psk()
1473 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in post_client_hello_gnutls_psk()
1477 if (c_session->context->spsk_setup_data.validate_sni_call_back) { in post_client_hello_gnutls_psk()
1529 c_session->context->spsk_setup_data.validate_sni_call_back(name, in post_client_hello_gnutls_psk()
1530 c_session, in post_client_hello_gnutls_psk()
1531 c_session->context->spsk_setup_data.sni_call_back_arg); in post_client_hello_gnutls_psk()
1545 sni_setup_data = c_session->context->spsk_setup_data; in post_client_hello_gnutls_psk()
1563 coap_session_refresh_psk_hint(c_session, in post_client_hello_gnutls_psk()
1565 coap_session_refresh_psk_key(c_session, in post_client_hello_gnutls_psk()
1584 coap_session_t *c_session = in post_client_hello_gnutls_pki() local
1587 (coap_gnutls_context_t *)c_session->context->dtls_context; in post_client_hello_gnutls_pki()
1588 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in post_client_hello_gnutls_pki()
1693 setup_client_ssl_session(coap_session_t *c_session, coap_gnutls_env_t *g_env) in setup_client_ssl_session() argument
1696 (coap_gnutls_context_t *)c_session->context->dtls_context; in setup_client_ssl_session()
1701 coap_dtls_cpsk_t *setup_data = &c_session->cpsk_setup_data; in setup_client_ssl_session()
1761 if (c_session->proto == COAP_PROTO_TLS) in setup_client_ssl_session()
1792 coap_session_t *c_session = in psk_server_callback() local
1800 if (c_session == NULL || c_session->context == NULL || in psk_server_callback()
1801 c_session->context->get_server_psk == NULL) in psk_server_callback()
1804 g_context = (coap_gnutls_context_t *)c_session->context->dtls_context; in psk_server_callback()
1807 setup_data = &c_session->context->spsk_setup_data; in psk_server_callback()
1815 if (c_session->psk_identity) in psk_server_callback()
1816 coap_delete_bin_const(c_session->psk_identity); in psk_server_callback()
1817 c_session->psk_identity = coap_new_bin_const((const uint8_t *)identity, in psk_server_callback()
1829 c_session, in psk_server_callback()
1839 coap_session_refresh_psk_key(c_session, psk_key); in psk_server_callback()
1843 psk_len = c_session->context->get_server_psk(c_session, in psk_server_callback()
1858 setup_server_ssl_session(coap_session_t *c_session, coap_gnutls_env_t *g_env) in setup_server_ssl_session() argument
1861 (coap_gnutls_context_t *)c_session->context->dtls_context; in setup_server_ssl_session()
1869 &c_session->context->spsk_setup_data), in setup_server_ssl_session()
1921 coap_session_t *c_session = (coap_session_t *)context; in coap_dgram_read() local
1924 if (!c_session->tls) { in coap_dgram_read()
1928 data = &((coap_gnutls_env_t *)c_session->tls)->coap_ssl_data; in coap_dgram_read()
1966 coap_session_t *c_session = (coap_session_t *)context; in coap_dgram_write() local
1968 if (c_session) { in coap_dgram_write()
1969 result = coap_session_send(c_session, send_buffer, send_buffer_length); in coap_dgram_write()
1987 coap_session_t *c_session = (coap_session_t *)context; in receive_timeout() local
1989 if (c_session) { in receive_timeout()
1992 int nfds = c_session->sock.fd +1; in receive_timeout()
1993 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in receive_timeout()
1996 if (c_session->proto == COAP_PROTO_DTLS && g_env && in receive_timeout()
2004 FD_SET (c_session->sock.fd, &readfds); in receive_timeout()
2006 FD_SET (c_session->sock.fd, &writefds); in receive_timeout()
2007 FD_SET (c_session->sock.fd, &exceptfds); in receive_timeout()
2019 coap_dtls_new_gnutls_env(coap_session_t *c_session, int type) in coap_dtls_new_gnutls_env() argument
2022 ((coap_gnutls_context_t *)c_session->context->dtls_context); in coap_dtls_new_gnutls_env()
2023 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_new_gnutls_env()
2046 gnutls_transport_set_ptr(g_env->g_session, c_session); in coap_dtls_new_gnutls_env()
2052 G_CHECK(setup_server_ssl_session(c_session, g_env), in coap_dtls_new_gnutls_env()
2056 G_CHECK(setup_client_ssl_session(c_session, g_env), in coap_dtls_new_gnutls_env()
2113 void *coap_dtls_new_server_session(coap_session_t *c_session) { in coap_dtls_new_server_session() argument
2115 (coap_gnutls_env_t *)c_session->tls; in coap_dtls_new_server_session()
2117 gnutls_transport_set_ptr(g_env->g_session, c_session); in coap_dtls_new_server_session()
2122 static void log_last_alert(coap_session_t *c_session, in log_last_alert() argument
2128 coap_session_str(c_session), in log_last_alert()
2132 coap_session_str(c_session), in log_last_alert()
2142 do_gnutls_handshake(coap_session_t *c_session, coap_gnutls_env_t *g_env) { in do_gnutls_handshake() argument
2150 coap_session_str(c_session)); in do_gnutls_handshake()
2169 log_last_alert(c_session, g_env->g_session); in do_gnutls_handshake()
2172 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in do_gnutls_handshake()
2176 log_last_alert(c_session, g_env->g_session); in do_gnutls_handshake()
2177 c_session->dtls_event = COAP_EVENT_DTLS_ERROR; in do_gnutls_handshake()
2190 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in do_gnutls_handshake()
2201 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in do_gnutls_handshake()
2206 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in do_gnutls_handshake()
2223 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in do_gnutls_handshake()
2230 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in do_gnutls_handshake()
2244 void *coap_dtls_new_client_session(coap_session_t *c_session) { in coap_dtls_new_client_session() argument
2245 coap_gnutls_env_t *g_env = coap_dtls_new_gnutls_env(c_session, GNUTLS_CLIENT); in coap_dtls_new_client_session()
2249 ret = do_gnutls_handshake(c_session, g_env); in coap_dtls_new_client_session()
2251 coap_dtls_free_gnutls_env(c_session->context->dtls_context, in coap_dtls_new_client_session()
2253 COAP_PROTO_NOT_RELIABLE(c_session->proto) ? in coap_dtls_new_client_session()
2261 void coap_dtls_free_session(coap_session_t *c_session) { in coap_dtls_free_session() argument
2262 if (c_session && c_session->context && c_session->tls) { in coap_dtls_free_session()
2263 coap_dtls_free_gnutls_env(c_session->context->dtls_context, in coap_dtls_free_session()
2264 c_session->tls, in coap_dtls_free_session()
2265 COAP_PROTO_NOT_RELIABLE(c_session->proto) ? in coap_dtls_free_session()
2267 c_session->tls = NULL; in coap_dtls_free_session()
2268 coap_handle_event(c_session->context, COAP_EVENT_DTLS_CLOSED, c_session); in coap_dtls_free_session()
2272 void coap_dtls_session_update_mtu(coap_session_t *c_session) { in coap_dtls_session_update_mtu() argument
2273 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_session_update_mtu()
2278 (unsigned int)c_session->mtu), in coap_dtls_session_update_mtu()
2289 int coap_dtls_send(coap_session_t *c_session, in coap_dtls_send() argument
2292 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_send()
2296 c_session->dtls_event = -1; in coap_dtls_send()
2308 log_last_alert(c_session, g_env->g_session); in coap_dtls_send()
2309 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in coap_dtls_send()
2326 ret = do_gnutls_handshake(c_session, g_env); in coap_dtls_send()
2329 return coap_dtls_send(c_session, data, data_len); in coap_dtls_send()
2334 if (c_session->dtls_event >= 0) { in coap_dtls_send()
2335 coap_handle_event(c_session->context, c_session->dtls_event, c_session); in coap_dtls_send()
2336 if (c_session->dtls_event == COAP_EVENT_DTLS_ERROR || in coap_dtls_send()
2337 c_session->dtls_event == COAP_EVENT_DTLS_CLOSED) { in coap_dtls_send()
2338 coap_session_disconnected(c_session, COAP_NACK_TLS_FAILED); in coap_dtls_send()
2354 coap_tick_t coap_dtls_get_timeout(coap_session_t *c_session, coap_tick_t now) { in coap_dtls_get_timeout() argument
2355 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_get_timeout()
2357 assert(c_session->state == COAP_SESSION_STATE_HANDSHAKE); in coap_dtls_get_timeout()
2379 void coap_dtls_handle_timeout(coap_session_t *c_session) { in coap_dtls_handle_timeout() argument
2380 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_handle_timeout()
2382 assert(g_env != NULL && c_session->state == COAP_SESSION_STATE_HANDSHAKE); in coap_dtls_handle_timeout()
2384 if ((++c_session->dtls_timeout_count > c_session->max_retransmit) || in coap_dtls_handle_timeout()
2385 (do_gnutls_handshake(c_session, g_env) < 0)) { in coap_dtls_handle_timeout()
2388 coap_session_disconnected(c_session, COAP_NACK_TLS_FAILED); in coap_dtls_handle_timeout()
2401 coap_dtls_receive(coap_session_t *c_session, in coap_dtls_receive() argument
2405 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_receive()
2415 coap_session_str(c_session), ssl_data->pdu_len); in coap_dtls_receive()
2419 c_session->dtls_event = -1; in coap_dtls_receive()
2421 if (c_session->state == COAP_SESSION_STATE_HANDSHAKE) { in coap_dtls_receive()
2422 coap_handle_event(c_session->context, COAP_EVENT_DTLS_CONNECTED, in coap_dtls_receive()
2423 c_session); in coap_dtls_receive()
2424 gnutls_transport_set_ptr(g_env->g_session, c_session); in coap_dtls_receive()
2425 coap_session_connected(c_session); in coap_dtls_receive()
2429 return coap_handle_dgram(c_session->context, c_session, pdu, (size_t)ret); in coap_dtls_receive()
2432 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in coap_dtls_receive()
2439 log_last_alert(c_session, g_env->g_session); in coap_dtls_receive()
2440 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in coap_dtls_receive()
2444 log_last_alert(c_session, g_env->g_session); in coap_dtls_receive()
2445 c_session->dtls_event = COAP_EVENT_DTLS_ERROR; in coap_dtls_receive()
2457 ret = do_gnutls_handshake(c_session, g_env); in coap_dtls_receive()
2459 coap_session_connected(c_session); in coap_dtls_receive()
2465 ret = do_gnutls_handshake(c_session, g_env); in coap_dtls_receive()
2468 coap_session_connected(c_session); in coap_dtls_receive()
2474 if (c_session->dtls_event >= 0) { in coap_dtls_receive()
2476 if (c_session->dtls_event != COAP_EVENT_DTLS_CLOSED) in coap_dtls_receive()
2477 coap_handle_event(c_session->context, c_session->dtls_event, c_session); in coap_dtls_receive()
2478 if (c_session->dtls_event == COAP_EVENT_DTLS_ERROR || in coap_dtls_receive()
2479 c_session->dtls_event == COAP_EVENT_DTLS_CLOSED) { in coap_dtls_receive()
2480 coap_session_disconnected(c_session, COAP_NACK_TLS_FAILED); in coap_dtls_receive()
2500 coap_dtls_hello(coap_session_t *c_session, in coap_dtls_hello() argument
2504 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_hello()
2509 g_env = coap_dtls_new_gnutls_env(c_session, GNUTLS_SERVER); in coap_dtls_hello()
2511 c_session->tls = g_env; in coap_dtls_hello()
2528 &c_session->addr_info, in coap_dtls_hello()
2529 sizeof(c_session->addr_info), in coap_dtls_hello()
2535 &c_session->addr_info, in coap_dtls_hello()
2536 sizeof(c_session->addr_info), in coap_dtls_hello()
2538 c_session, in coap_dtls_hello()
2549 ret = do_gnutls_handshake(c_session, g_env); in coap_dtls_hello()
2556 ((coap_gnutls_context_t *)c_session->context->dtls_context), in coap_dtls_hello()
2558 c_session->tls = NULL; in coap_dtls_hello()
2576 unsigned int coap_dtls_get_overhead(coap_session_t *c_session COAP_UNUSED) { in coap_dtls_get_overhead()
2589 coap_session_t *c_session = (coap_session_t *)context; in coap_sock_read() local
2593 ret = recv(c_session->sock.fd, (char *)out, (int)outl, 0); in coap_sock_read()
2595 ret = recv(c_session->sock.fd, out, outl, 0); in coap_sock_read()
2599 coap_session_str(c_session), ret); in coap_sock_read()
2602 coap_session_str(c_session), coap_socket_strerror()); in coap_sock_read()
2606 c_session->sock.flags &= ~COAP_SOCKET_CAN_READ; in coap_sock_read()
2609 c_session->sock.flags &= ~COAP_SOCKET_CAN_READ; in coap_sock_read()
2611 c_session->sock.flags &= ~COAP_SOCKET_CAN_READ; in coap_sock_read()
2625 coap_session_t *c_session = (coap_session_t *)context; in coap_sock_write() local
2627 ret = (int)coap_socket_write(&c_session->sock, in, inl); in coap_sock_write()
2630 coap_session_str(c_session), ret); in coap_sock_write()
2632 if ((c_session->state == COAP_SESSION_STATE_CSM || in coap_sock_write()
2633 c_session->state == COAP_SESSION_STATE_HANDSHAKE) && in coap_sock_write()
2650 coap_session_str(c_session), inl, coap_socket_strerror(), in coap_sock_write()
2651 c_session->state); in coap_sock_write()
2661 void *coap_tls_new_client_session(coap_session_t *c_session, int *connected) { in coap_tls_new_client_session() argument
2664 ((coap_gnutls_context_t *)c_session->context->dtls_context); in coap_tls_new_client_session()
2684 gnutls_transport_set_ptr(g_env->g_session, c_session); in coap_tls_new_client_session()
2687 setup_client_ssl_session(c_session, g_env); in coap_tls_new_client_session()
2691 c_session->tls = g_env; in coap_tls_new_client_session()
2692 ret = do_gnutls_handshake(c_session, g_env); in coap_tls_new_client_session()
2695 coap_handle_event(c_session->context, COAP_EVENT_DTLS_CONNECTED, c_session); in coap_tls_new_client_session()
2696 coap_session_send_csm(c_session); in coap_tls_new_client_session()
2706 void *coap_tls_new_server_session(coap_session_t *c_session, int *connected) { in coap_tls_new_server_session() argument
2709 ((coap_gnutls_context_t *)c_session->context->dtls_context); in coap_tls_new_server_session()
2728 gnutls_transport_set_ptr(g_env->g_session, c_session); in coap_tls_new_server_session()
2730 setup_server_ssl_session(c_session, g_env); in coap_tls_new_server_session()
2736 c_session->tls = g_env; in coap_tls_new_server_session()
2737 ret = do_gnutls_handshake(c_session, g_env); in coap_tls_new_server_session()
2747 void coap_tls_free_session(coap_session_t *c_session) { in coap_tls_free_session() argument
2748 coap_dtls_free_session(c_session); in coap_tls_free_session()
2757 ssize_t coap_tls_write(coap_session_t *c_session, in coap_tls_write() argument
2762 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_tls_write()
2766 c_session->dtls_event = -1; in coap_tls_write()
2778 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in coap_tls_write()
2784 log_last_alert(c_session, g_env->g_session); in coap_tls_write()
2785 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in coap_tls_write()
2802 ret = do_gnutls_handshake(c_session, g_env); in coap_tls_write()
2804 coap_handle_event(c_session->context, COAP_EVENT_DTLS_CONNECTED, in coap_tls_write()
2805 c_session); in coap_tls_write()
2806 coap_session_send_csm(c_session); in coap_tls_write()
2813 if (c_session->dtls_event >= 0) { in coap_tls_write()
2815 if (c_session->dtls_event != COAP_EVENT_DTLS_CLOSED) in coap_tls_write()
2816 coap_handle_event(c_session->context, c_session->dtls_event, c_session); in coap_tls_write()
2817 if (c_session->dtls_event == COAP_EVENT_DTLS_ERROR || in coap_tls_write()
2818 c_session->dtls_event == COAP_EVENT_DTLS_CLOSED) { in coap_tls_write()
2819 coap_session_disconnected(c_session, COAP_NACK_TLS_FAILED); in coap_tls_write()
2832 ssize_t coap_tls_read(coap_session_t *c_session, in coap_tls_read() argument
2836 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_tls_read()
2842 c_session->dtls_event = -1; in coap_tls_read()
2844 ret = do_gnutls_handshake(c_session, g_env); in coap_tls_read()
2846 coap_handle_event(c_session->context, COAP_EVENT_DTLS_CONNECTED, in coap_tls_read()
2847 c_session); in coap_tls_read()
2848 coap_session_send_csm(c_session); in coap_tls_read()
2851 if (c_session->state != COAP_SESSION_STATE_NONE && g_env->established) { in coap_tls_read()
2856 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in coap_tls_read()
2863 c_session->dtls_event = COAP_EVENT_DTLS_ERROR; in coap_tls_read()
2868 log_last_alert(c_session, g_env->g_session); in coap_tls_read()
2869 c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; in coap_tls_read()
2873 log_last_alert(c_session, g_env->g_session); in coap_tls_read()
2874 c_session->dtls_event = COAP_EVENT_DTLS_ERROR; in coap_tls_read()
2888 if (c_session->dtls_event >= 0) { in coap_tls_read()
2890 if (c_session->dtls_event != COAP_EVENT_DTLS_CLOSED) in coap_tls_read()
2891 coap_handle_event(c_session->context, c_session->dtls_event, c_session); in coap_tls_read()
2892 if (c_session->dtls_event == COAP_EVENT_DTLS_ERROR || in coap_tls_read()
2893 c_session->dtls_event == COAP_EVENT_DTLS_CLOSED) { in coap_tls_read()
2894 coap_session_disconnected(c_session, COAP_NACK_TLS_FAILED); in coap_tls_read()