Loading...
Searching...
No Matches
dtls.h File Reference

DTLS sock definitions. More...

Detailed Description

#include <assert.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include "net/sock.h"
#include "net/sock/udp.h"
#include "net/credman.h"
+ Include dependency graph for dtls.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CONFIG_DTLS_HANDSHAKE_BUFSIZE_EXP   8
 Default buffer size for DTLS handshake (as exponent of 2^n)
 
#define DTLS_HANDSHAKE_BUFSIZE   (1 << CONFIG_DTLS_HANDSHAKE_BUFSIZE_EXP)
 Size buffer used in handshake to hold credentials.
 
#define SOCK_DTLS_HANDSHAKE   (EXDEV)
 Return value for a successful handshake.
 
#define CONFIG_DTLS_FORCE_EXTENDED_MASTER_SECRET   1
 Force extended master secret extension.
 
#define CONFIG_DTLS_FORCE_RENEGOTIATION_INFO   1
 Force renegotiation info extension.
 

Typedefs

typedef struct sock_dtls sock_dtls_t
 Type for a DTLS sock object.
 
typedef struct sock_dtls_session sock_dtls_session_t
 Information about a created session.
 
typedef sock_udp_aux_rx_t sock_dtls_aux_rx_t
 Auxiliary data provided when receiving using an DTLS sock object.
 
typedef sock_udp_aux_tx_t sock_dtls_aux_tx_t
 Auxiliary data provided when sending using an DTLS sock object.
 

Functions

void sock_dtls_init (void)
 Called exactly once during auto_init.
 
int sock_dtls_create (sock_dtls_t *sock, sock_udp_t *udp_sock, credman_tag_t tag, unsigned version, unsigned role)
 Creates a new DTLS sock object.
 
sock_udp_tsock_dtls_get_udp_sock (sock_dtls_t *sock)
 Get underlying UDP sock.
 
int sock_dtls_session_init (sock_dtls_t *sock, const sock_udp_ep_t *ep, sock_dtls_session_t *remote)
 Initialize session handshake.
 
void sock_dtls_session_destroy (sock_dtls_t *sock, sock_dtls_session_t *remote)
 Destroys an existing DTLS session.
 
void sock_dtls_session_get_udp_ep (const sock_dtls_session_t *session, sock_udp_ep_t *ep)
 Get the remote UDP endpoint from a session.
 
void sock_dtls_session_set_udp_ep (sock_dtls_session_t *session, const sock_udp_ep_t *ep)
 Set the remote UDP endpoint from a session.
 
ssize_t sock_dtls_recv_aux (sock_dtls_t *sock, sock_dtls_session_t *remote, void *data, size_t maxlen, uint32_t timeout, sock_dtls_aux_rx_t *aux)
 Receive handshake messages and application data from remote peer.
 
static ssize_t sock_dtls_recv (sock_dtls_t *sock, sock_dtls_session_t *remote, void *data, size_t maxlen, uint32_t timeout)
 Receive handshake messages and application data from remote peer.
 
ssize_t sock_dtls_recv_buf_aux (sock_dtls_t *sock, sock_dtls_session_t *remote, void **data, void **buf_ctx, uint32_t timeout, sock_dtls_aux_rx_t *aux)
 Decrypts and provides stack-internal buffer space containing a message from a remote peer.
 
static ssize_t sock_dtls_recv_buf (sock_dtls_t *sock, sock_dtls_session_t *remote, void **data, void **buf_ctx, uint32_t timeout)
 Decrypts and provides stack-internal buffer space containing a message from a remote peer.
 
ssize_t sock_dtls_sendv_aux (sock_dtls_t *sock, sock_dtls_session_t *remote, const iolist_t *snips, uint32_t timeout, sock_dtls_aux_tx_t *aux)
 Encrypts and sends a message to a remote peer with non-continous payload.
 
static ssize_t sock_dtls_send_aux (sock_dtls_t *sock, sock_dtls_session_t *remote, const void *data, size_t len, uint32_t timeout, sock_dtls_aux_tx_t *aux)
 Encrypts and sends a message to a remote peer.
 
static ssize_t sock_dtls_send (sock_dtls_t *sock, sock_dtls_session_t *remote, const void *data, size_t len, uint32_t timeout)
 Encrypts and sends a message to a remote peer.
 
static ssize_t sock_dtls_sendv (sock_dtls_t *sock, sock_dtls_session_t *remote, const iolist_t *snips, uint32_t timeout)
 Encrypts and sends a message to a remote peer with non-continous payload.
 
void sock_dtls_close (sock_dtls_t *sock)
 Closes a DTLS sock.
 
enum  { SOCK_DTLS_1_0 = 1 , SOCK_DTLS_1_2 = 2 , SOCK_DTLS_1_3 = 3 }
 DTLS version number . More...
 
enum  { SOCK_DTLS_CLIENT = 1 , SOCK_DTLS_SERVER = 2 }
 DTLS role . More...