Loading...
Searching...
No Matches

Use CoAP over DTLS, with optional reliability. More...

Detailed Description

Use CoAP over DTLS, with optional reliability.

Module. Specify USEMODULE += unicoap_driver_dtls in your application's Makefile.

Include these headers required for managing DTLS credentials.

#include "net/credman.h"
#include "net/dsm.h"
(D)TLS credentials management module definitions
DTLS sock definitions.
DTLS session management module definition.

Then, in your application, call sock_dtls_add_credential to add a DTLS credential. If you need to access the DTLS socket, call unicoap_transport_dtls_get_socket(). You must add DTLS credentials yourself. To change the UDP port unicoap is listening on, modify CONFIG_UNICOAP_DTLS_PORT. The CoAP over DTLS driver uses the same socket both for client and server functionality.

See also
UNICOAP_PROTO_DTLS
unicoap_rfc7252_message_type_t

This is the dependency graph of this driver:

unicoap_driver_dtls
├── unicoap_driver_rfc7252_common
│ ├── unicoap_driver_rfc7252_common_messaging
│ └── unicoap_driver_rfc7252_common_pdu
├── unicoap_sock_support
│ ├── sock_async
│ ├── sock_async_event
│ ├── sock_aux_local
│ └── sock_util
├── ... (operating system networking modules)
.

Data Structures

struct  unicoap_aux_t
 Auxiliary exchange information. More...
 

Sockets

sock_dtls_tunicoap_transport_dtls_get_socket (void)
 Returns the internal DTLS socket.
 
int unicoap_transport_dtls_add_socket (sock_dtls_t *socket, sock_udp_t *base_socket, sock_udp_ep_t *local)
 Adds DTLS socket for client and server functionality.
 
int unicoap_transport_dtls_remove_socket (sock_dtls_t *socket)
 Removes DTLS socket previously added manually.
 

Ports

#define CONFIG_UNICOAP_DTLS_PORT   UNICOAP_DEFAULT_COAPS_PORT
 DTLS port.
 

Session establishment

#define CONFIG_UNICOAP_DTLS_HANDSHAKE_TIMEOUT_MS   (3 * MS_PER_SEC)
 Timeout for the DTLS handshake process.
 
#define CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS   (1)
 Number of minimum available session slots.
 
#define CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS_TIMEOUT_MS   (15 * MS_PER_SEC)
 Timeout for freeing up a session when minimum number of available session slots is not available anymore.
 

Macro Definition Documentation

◆ CONFIG_UNICOAP_DTLS_HANDSHAKE_TIMEOUT_MS

#define CONFIG_UNICOAP_DTLS_HANDSHAKE_TIMEOUT_MS   (3 * MS_PER_SEC)

Timeout for the DTLS handshake process.

Set to 0 for infinite time

Default: 3 ms

Definition at line 392 of file config.h.

◆ CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS

#define CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS   (1)

Number of minimum available session slots.

If the count of available sessions falls below this threshold, the oldest used session will be closed after a timeout time. Set to 0 to deactivate this feature.

Default: 1

Definition at line 403 of file config.h.

◆ CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS_TIMEOUT_MS

#define CONFIG_UNICOAP_DTLS_MINIMUM_AVAILABLE_SESSION_SLOTS_TIMEOUT_MS   (15 * MS_PER_SEC)

Timeout for freeing up a session when minimum number of available session slots is not available anymore.

Default: 15 ms

Definition at line 413 of file config.h.

◆ CONFIG_UNICOAP_DTLS_PORT

#define CONFIG_UNICOAP_DTLS_PORT   UNICOAP_DEFAULT_COAPS_PORT

DTLS port.

Definition at line 105 of file config.h.

Function Documentation

◆ unicoap_transport_dtls_add_socket()

int unicoap_transport_dtls_add_socket ( sock_dtls_t * socket,
sock_udp_t * base_socket,
sock_udp_ep_t * local )

Adds DTLS socket for client and server functionality.

Precondition
Sockets must be pre-allocated and must remain allocated until the DTLS driver has been deinitialized or the socket is closed by you.
Parameters
[in,out]socketPre-allocated socket to use
[in,out]base_socketPre-allocated UDP base socket to use
[in]localInitialized endpoint, does not need to outlive this function call

You can call this function at any time after unicoap has been initialized.

Returns
0 on success or negative error value otherwise. The error value depends on the DTLS implementation.

◆ unicoap_transport_dtls_remove_socket()

int unicoap_transport_dtls_remove_socket ( sock_dtls_t * socket)

Removes DTLS socket previously added manually.

Parameters
[in,out]socketThe socket pointer you have previously passed to unicoap_transport_dtls_add_socket
Returns
0, indicating a success. Future versions of this API may return a negative error.