mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-04 08:55:40 +03:00
endpoint->hello is used to hold the 5 tuple etc. information about a new connection that has come in. Once the DTLS handshake has been completed a new coap_session_t is created for the ongoing encrypted work. However, if a second new DTLS request comes in before the first session has completed the DTLS handshakes, it will overwrite the endpoint->hello information causing the first request to stall / get lost. GnuTLS already has to check that the initial DTLS packet is a Client Hello before starting up a GnuTLS session, so moving this logic up a level to the initial DTLS packet makes sense to create a coap_session_t at this point and getting rid of the temporary endpoint->hello gets rid of this issue. Makefile.am: Replace coap_endpoint_new_dtls_session with coap_session_new_dtls_session include/coap2/coap_session.h: Remove coap_session_t hello; Replace coap_endpoint_new_dtls_session with coap_session_new_dtls_session src/coap_gnutls.c: Remove references to endpoint->hello Remove Client Hello check code (move it to coap_endpoint_get_session()) src/coap_io.c: Remove references to freeing off ep->hello src/coap_session.c: Remove endpoint->hello code. Check for Client Hello in coap_endpoint_get_session() if no session, is DTLS and don't build coap_session if not a Client Hello. Otherwise, always build a new coap_session. Timeout Client Hello session if inactive to prevent a DoS. Replace coap_endpoint_new_dtls_session with coap_session_new_dtls_session src/coap_net.c: Replace coap_endpoint_new_dtls_session with coap_session_new_dtls_session