sock_dtls_types.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
21 #include "dtls.h"
22 #include "net/sock/udp.h"
23 #include "net/credman.h"
24 #include "net/sock/dtls/creds.h"
25 #ifdef SOCK_HAS_ASYNC
26 #include "net/sock/async/types.h"
27 #endif
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #ifndef SOCK_DTLS_MBOX_SIZE
34 #define SOCK_DTLS_MBOX_SIZE (4)
35 #endif
36 
40 struct sock_dtls {
41  dtls_context_t *dtls_ctx;
43 #if defined(SOCK_HAS_ASYNC) || defined(DOXYGEN)
47  void *buf_ctx;
54  void *async_cb_arg;
55  session_t async_cb_session;
56 #if defined(SOCK_HAS_ASYNC_CTX) || defined(DOXYGEN)
63 #endif
64 #endif
72  struct {
73  uint8_t *data;
74  size_t datalen;
75  session_t *session;
76  } buffer;
79  unsigned tags_len;
80  dtls_peer_type role;
83 };
84 
89  session_t dtls_session;
90 };
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
(D)TLS credentials management module definitions
DTLS sock definitions.
uint16_t credman_tag_t
Tag of the credential.
Definition: credman.h:95
void(* sock_dtls_cb_t)(sock_dtls_t *sock, sock_async_flags_t flags, void *arg)
Event callback for sock_dtls_t.
Definition: types.h:68
#define CONFIG_DTLS_PSK_ID_HINT_MAX_SIZE
Default maximum size for the PSK Identity hint string.
Definition: creds.h:37
#define CONFIG_DTLS_CREDENTIALS_MAX
Default buffer size for TLS credential tags.
Definition: creds.h:44
credman_tag_t(* sock_dtls_client_psk_cb_t)(sock_dtls_t *sock, sock_udp_ep_t *ep, credman_tag_t tags[], unsigned tags_len, const char *hint, size_t hint_len)
Pre-Shared Key client callback.
Definition: creds.h:61
credman_tag_t(* sock_dtls_rpk_cb_t)(sock_dtls_t *sock, sock_udp_ep_t *ep, credman_tag_t tags[], unsigned tags_len)
Raw Public Key callback.
Definition: creds.h:76
UDP sock definitions.
#define SOCK_DTLS_MBOX_SIZE
Size of DTLS sock mailbox.
Mailbox struct definition.
Definition: mbox.h:40
Describes a message object which can be sent between threads.
Definition: msg.h:195
Asynchronous context for Asynchronous sock with event API.
Information about remote client connected to the server.
session_t dtls_session
TinyDTLS session.
Information about DTLS sock.
msg_t mbox_queue[SOCK_DTLS_MBOX_SIZE]
Queue for struct sock_dtls::mbox.
sock_dtls_cb_t async_cb
Asynchronous event callback.
session_t async_cb_session
asynchronous callback session
char psk_hint[CONFIG_DTLS_PSK_ID_HINT_MAX_SIZE]
PSK Identity hint.
mbox_t mbox
Mailbox for internal event handling.
dtls_context_t * dtls_ctx
TinyDTLS context for sock.
unsigned tags_len
Number of tags in the list 'tags'.
void * async_cb_arg
asynchronous callback arg
sock_async_ctx_t async_ctx
Asynchronous event context.
session_t * session
Session information.
sock_udp_t * udp_sock
Underlying UDP sock to use.
credman_tag_t tags[CONFIG_DTLS_CREDENTIALS_MAX]
Tags of the available credentials.
size_t datalen
data length
uint8_t * data
Pointer to the decrypted data.
dtls_peer_type role
DTLS role of the socket.
void * buf_ctx
Network stack internal buffer context.
struct sock_dtls::@325 buffer
Buffer used to pass decrypted data and its session information.
sock_dtls_rpk_cb_t rpk_cb
Callback to determine RPK credential for session.
sock_dtls_client_psk_cb_t client_psk_cb
Callback to determine PSK credential for session.
UDP sock type.
Definition: sock_types.h:128
Definitions for sock extension for asynchronous access.