Jon Shallow 3829cd6137 Fix DTLS session loss when multiple connections in a short time
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
2019-04-26 12:45:58 +01:00
2018-11-24 13:58:44 +01:00
2018-12-10 20:15:25 +00:00
2018-11-27 15:33:52 +00:00
2019-03-01 14:14:17 +01:00
2017-07-11 12:59:09 +02:00
2019-03-02 11:43:59 +01:00
2019-03-01 14:14:17 +01:00

libcoap: A C implementation of the Constrained Application Protocol (RFC 7252)

Build Status Static Analysis

Copyright (C) 2010—2019 by Olaf Bergmann bergmann@tzi.org and others

ABOUT LIBCOAP

libcoap is a C implementation of a lightweight application-protocol for devices that are constrained their resources such as computing power, RF range, memory, bandwidth, or network packet sizes. This protocol, CoAP, is standardized by the IETF as RFC 7252. For further information related to CoAP, see http://coap.technology.

You might want to check out libcoap-minimal for usage examples.

PACKAGE CONTENTS

This directory contains a protocol parser and basic networking functions for platform with support for malloc() and BSD-style sockets. The examples directory contains a client and a server to demonstrate the use of this library.

LICENSE INFORMATION

This library is published as open-source software without any warranty of any kind. Use is permitted under the terms of the simplified BSD license. It includes public domain software. libcoap binaries may also include open-source software with their respective licensing terms. Please refer to LICENSE for further details.

Languages
C 93.6%
M4 2.9%
CMake 1.8%
Shell 0.7%
Makefile 0.6%
Other 0.4%