libcoap  4.2.0
coap_tinydtls.c
Go to the documentation of this file.
1 /*
2  * coap_tinydtls.c -- Datagram Transport Layer Support for libcoap with tinydtls
3  *
4  * Copyright (C) 2016 Olaf Bergmann <bergmann@tzi.org>
5  *
6  * This file is part of the CoAP library libcoap. Please see README for terms
7  * of use.
8  */
9 
10 #include "coap_config.h"
11 
12 #ifdef HAVE_LIBTINYDTLS
13 
14 #include "net.h"
15 #include "address.h"
16 #include "coap_debug.h"
17 #include "mem.h"
18 
19 /* We want TinyDTLS versions of these, not libcoap versions */
20 #undef PACKAGE_BUGREPORT
21 #undef PACKAGE_NAME
22 #undef PACKAGE_STRING
23 #undef PACKAGE_TARNAME
24 #undef PACKAGE_URL
25 #undef PACKAGE_VERSION
26 
27 #include <tinydtls.h>
28 #include <dtls.h>
29 #include <dtls_debug.h>
30 
31 static dtls_tick_t dtls_tick_0 = 0;
32 static coap_tick_t coap_tick_0 = 0;
33 
34 int
36  return 1;
37 }
38 
39 void coap_dtls_startup(void) {
40  dtls_init();
41  dtls_ticks(&dtls_tick_0);
42  coap_ticks(&coap_tick_0);
43 }
44 
45 void
46 coap_dtls_set_log_level(int level) {
47  dtls_set_log_level(level);
48 }
49 
50 int
52  return dtls_get_log_level();
53 }
54 
55 static void get_session_addr(const session_t *s, coap_address_t *a) {
56 #ifdef WITH_CONTIKI
57  a->addr = s->addr;
58  a->port = s->port;
59 #else
60  if (s->addr.sa.sa_family == AF_INET6) {
61  a->size = (socklen_t)sizeof(a->addr.sin6);
62  a->addr.sin6 = s->addr.sin6;
63  } else if (s->addr.sa.sa_family == AF_INET) {
64  a->size = (socklen_t)sizeof(a->addr.sin);
65  a->addr.sin = s->addr.sin;
66  } else {
67  a->size = (socklen_t)s->size;
68  a->addr.sa = s->addr.sa;
69  }
70 #endif
71 }
72 
73 static void put_session_addr(const coap_address_t *a, session_t *s) {
74 #ifdef WITH_CONTIKI
75  s->size = (unsigned char)sizeof(s->addr);
76  s->addr = a->addr;
77  s->port = a->port;
78 #else
79  if (a->addr.sa.sa_family == AF_INET6) {
80  s->size = (socklen_t)sizeof(s->addr.sin6);
81  s->addr.sin6 = a->addr.sin6;
82  } else if (a->addr.sa.sa_family == AF_INET) {
83  s->size = (socklen_t)sizeof(s->addr.sin);
84  s->addr.sin = a->addr.sin;
85  } else {
86  s->size = (socklen_t)a->size;
87  s->addr.sa = a->addr.sa;
88  }
89 #endif
90 }
91 
92 static int
93 dtls_send_to_peer(struct dtls_context_t *dtls_context,
94  session_t *dtls_session, uint8 *data, size_t len) {
95  coap_context_t *coap_context = (coap_context_t *)dtls_get_app_data(dtls_context);
96  coap_session_t *coap_session;
97  coap_address_t remote_addr;
98 
99  get_session_addr(dtls_session, &remote_addr);
100  coap_session = coap_session_get_by_peer(coap_context, &remote_addr, dtls_session->ifindex);
101  if (!coap_session) {
102  coap_log(LOG_WARNING, "dtls_send_to_peer: cannot find local interface\n");
103  return -3;
104  }
105  return (int)coap_session_send(coap_session, data, len);
106 }
107 
108 static int
109 dtls_application_data(struct dtls_context_t *dtls_context,
110  session_t *dtls_session, uint8 *data, size_t len) {
111  coap_context_t *coap_context = (coap_context_t *)dtls_get_app_data(dtls_context);
112  coap_session_t *coap_session;
113  coap_address_t remote_addr;
114 
115  get_session_addr(dtls_session, &remote_addr);
116  coap_session = coap_session_get_by_peer(coap_context, &remote_addr, dtls_session->ifindex);
117  if (!coap_session) {
119  "dropped message that was received on invalid interface\n");
120  return -1;
121  }
122 
123  return coap_handle_dgram(coap_context, coap_session, data, len);
124 }
125 
126 static int coap_event_dtls = 0;
127 
128 static int
129 dtls_event(struct dtls_context_t *dtls_context,
130  session_t *dtls_session,
131  dtls_alert_level_t level,
132  uint16_t code) {
133  (void)dtls_context;
134  (void)dtls_session;
135 
136  if (level == DTLS_ALERT_LEVEL_FATAL)
137  coap_event_dtls = COAP_EVENT_DTLS_ERROR;
138 
139  /* handle DTLS events */
140  switch (code) {
141  case DTLS_ALERT_CLOSE_NOTIFY:
142  {
143  coap_event_dtls = COAP_EVENT_DTLS_CLOSED;
144  break;
145  }
146  case DTLS_EVENT_CONNECTED:
147  {
148  coap_event_dtls = COAP_EVENT_DTLS_CONNECTED;
149  break;
150  }
151  case DTLS_EVENT_RENEGOTIATE:
152  {
153  coap_event_dtls = COAP_EVENT_DTLS_RENEGOTIATE;
154  break;
155  }
156  default:
157  ;
158  }
159 
160  return 0;
161 }
162 
163 /* This function is the "key store" for tinyDTLS. It is called to
164  * retrieve a key for the given identity within this particular
165  * session. */
166 static int
167 get_psk_info(struct dtls_context_t *dtls_context,
168  const session_t *dtls_session,
169  dtls_credentials_type_t type,
170  const uint8_t *id, size_t id_len,
171  unsigned char *result, size_t result_length) {
172  coap_context_t *coap_context;
173  coap_session_t *coap_session;
174  int fatal_error = DTLS_ALERT_INTERNAL_ERROR;
175  size_t identity_length;
176  static int client = 0;
177  static uint8_t psk[128];
178  static size_t psk_len = 0;
179  coap_address_t remote_addr;
180 
181 
182  if (type == DTLS_PSK_KEY && client) {
183  if (psk_len > result_length) {
184  coap_log(LOG_WARNING, "cannot set psk -- buffer too small\n");
185  goto error;
186  }
187  memcpy(result, psk, psk_len);
188  client = 0;
189  return (int)psk_len;
190  }
191 
192  client = 0;
193  coap_context = (coap_context_t *)dtls_get_app_data(dtls_context);
194  get_session_addr(dtls_session, &remote_addr);
195  coap_session = coap_session_get_by_peer(coap_context, &remote_addr, dtls_session->ifindex);
196  if (!coap_session) {
197  coap_log(LOG_DEBUG, "cannot get PSK, session not found\n");
198  goto error;
199  }
200 
201  switch (type) {
202  case DTLS_PSK_IDENTITY:
203 
204  if (id_len)
205  coap_log(LOG_DEBUG, "got psk_identity_hint: '%.*s'\n", (int)id_len, id);
206 
207  if (!coap_context || !coap_context->get_client_psk)
208  goto error;
209 
210  identity_length = 0;
211  psk_len = coap_context->get_client_psk(coap_session, (const uint8_t*)id, id_len, (uint8_t*)result, &identity_length, result_length, psk, sizeof(psk));
212  if (!psk_len) {
213  coap_log(LOG_WARNING, "no PSK identity for given realm\n");
214  fatal_error = DTLS_ALERT_CLOSE_NOTIFY;
215  goto error;
216  }
217  client = 1;
218  return (int)identity_length;
219 
220  case DTLS_PSK_KEY:
221  if (coap_context->get_server_psk)
222  return (int)coap_context->get_server_psk(coap_session, (const uint8_t*)id, id_len, (uint8_t*)result, result_length);
223  return 0;
224  break;
225 
226  case DTLS_PSK_HINT:
227  client = 0;
228  if (coap_context->get_server_hint)
229  return (int)coap_context->get_server_hint(coap_session, (uint8_t *)result, result_length);
230  return 0;
231 
232  default:
233  coap_log(LOG_WARNING, "unsupported request type: %d\n", type);
234  }
235 
236 error:
237  client = 0;
238  return dtls_alert_fatal_create(fatal_error);
239 }
240 
241 static dtls_handler_t cb = {
242  .write = dtls_send_to_peer,
243  .read = dtls_application_data,
244  .event = dtls_event,
245  .get_psk_info = get_psk_info,
246 #ifdef WITH_ECC
247  .get_ecdsa_key = NULL,
248  .verify_ecdsa_key = NULL
249 #endif
250 };
251 
252 void *
253 coap_dtls_new_context(struct coap_context_t *coap_context) {
254  struct dtls_context_t *dtls_context = dtls_new_context(coap_context);
255  if (!dtls_context)
256  goto error;
257  dtls_set_handler(dtls_context, &cb);
258  return dtls_context;
259 error:
260  coap_dtls_free_context(dtls_context);
261  return NULL;
262 }
263 
264 void
265 coap_dtls_free_context(void *handle) {
266  if (handle) {
267  struct dtls_context_t *dtls_context = (struct dtls_context_t *)handle;
268  dtls_free_context(dtls_context);
269  }
270 }
271 
272 static session_t *
274  session_t *dtls_session = coap_malloc_type(COAP_DTLS_SESSION, sizeof(session_t));
275 
276  if (dtls_session) {
277  /* create tinydtls session object from remote address and local
278  * endpoint handle */
279  dtls_session_init(dtls_session);
280  put_session_addr(&session->remote_addr, dtls_session);
281  dtls_session->ifindex = session->ifindex;
282  coap_log(LOG_DEBUG, "***new session %p\n", (void *)dtls_session);
283  }
284 
285  return dtls_session;
286 }
287 
289  return coap_dtls_new_session(session);
290 }
291 
293  dtls_peer_t *peer;
294  session_t *dtls_session = coap_dtls_new_session(session);
295  if (!dtls_session)
296  return NULL;
297  peer =
298  dtls_get_peer((struct dtls_context_t *)session->context->dtls_context,
299  dtls_session);
300 
301  if (!peer) {
302  /* The peer connection does not yet exist. */
303  /* dtls_connect() returns a value greater than zero if a new
304  * connection attempt is made, 0 for session reuse. */
305  if (dtls_connect((struct dtls_context_t *)session->context->dtls_context,
306  dtls_session) >= 0) {
307  peer =
308  dtls_get_peer((struct dtls_context_t *)session->context->dtls_context,
309  dtls_session);
310  }
311  }
312 
313  if (!peer) {
314  /* delete existing session because the peer object has been invalidated */
315  coap_free_type(COAP_DTLS_SESSION, dtls_session);
316  dtls_session = NULL;
317  }
318 
319  return dtls_session;
320 }
321 
322 void
324  (void)session;
325 }
326 
327 void
328 coap_dtls_free_session(coap_session_t *coap_session) {
329  struct dtls_context_t *ctx = (struct dtls_context_t *)coap_session->context->dtls_context;
330  if (coap_session->tls) {
331  dtls_peer_t *peer = dtls_get_peer(ctx, (session_t *)coap_session->tls);
332  if ( peer )
333  dtls_reset_peer(ctx, peer);
334  else
335  dtls_close(ctx, (session_t *)coap_session->tls);
336  coap_log(LOG_DEBUG, "***removed session %p\n", coap_session->tls);
337  coap_free_type(COAP_DTLS_SESSION, coap_session->tls);
338  coap_session->tls = NULL;
339  }
340 }
341 
342 int
344  const uint8_t *data,
345  size_t data_len
346 ) {
347  int res;
348  uint8_t *data_rw;
349 
350  coap_log(LOG_DEBUG, "call dtls_write\n");
351 
352  coap_event_dtls = -1;
353  /* Need to do this to not get a compiler warning about const parameters */
354  memcpy (&data_rw, &data, sizeof(data_rw));
355  res = dtls_write((struct dtls_context_t *)session->context->dtls_context,
356  (session_t *)session->tls, data_rw, data_len);
357 
358  if (res < 0)
359  coap_log(LOG_WARNING, "coap_dtls_send: cannot send PDU\n");
360 
361  if (coap_event_dtls >= 0) {
362  coap_handle_event(session->context, coap_event_dtls, session);
363  if (coap_event_dtls == COAP_EVENT_DTLS_CONNECTED)
364  coap_session_connected(session);
365  else if (coap_event_dtls == DTLS_ALERT_CLOSE_NOTIFY || coap_event_dtls == COAP_EVENT_DTLS_ERROR)
367  }
368 
369  return res;
370 }
371 
373  return 1;
374 }
375 
376 coap_tick_t coap_dtls_get_context_timeout(void *dtls_context) {
377  clock_time_t next = 0;
378  dtls_check_retransmit((struct dtls_context_t *)dtls_context, &next);
379  if (next > 0)
380  return ((coap_tick_t)(next - dtls_tick_0)) * COAP_TICKS_PER_SECOND / DTLS_TICKS_PER_SECOND + coap_tick_0;
381  return 0;
382 }
383 
385  (void)session;
386  return 0;
387 }
388 
390  (void)session;
391  return;
392 }
393 
394 int
396  const uint8_t *data,
397  size_t data_len
398 ) {
399  session_t *dtls_session = (session_t *)session->tls;
400  int err;
401  uint8_t *data_rw;
402 
403  coap_event_dtls = -1;
404  /* Need to do this to not get a compiler warning about const parameters */
405  memcpy (&data_rw, &data, sizeof(data_rw));
406  err = dtls_handle_message(
407  (struct dtls_context_t *)session->context->dtls_context,
408  dtls_session, data_rw, (int)data_len);
409 
410  if (err){
411  coap_event_dtls = COAP_EVENT_DTLS_ERROR;
412  }
413 
414  if (coap_event_dtls >= 0) {
415  coap_handle_event(session->context, coap_event_dtls, session);
416  if (coap_event_dtls == COAP_EVENT_DTLS_CONNECTED)
417  coap_session_connected(session);
418  else if (coap_event_dtls == DTLS_ALERT_CLOSE_NOTIFY || coap_event_dtls == COAP_EVENT_DTLS_ERROR)
420  }
421 
422  return err;
423 }
424 
425 int
427  const uint8_t *data,
428  size_t data_len
429 ) {
430  session_t dtls_session;
431  struct dtls_context_t *dtls_context =
432  (struct dtls_context_t *)session->context->dtls_context;
433  uint8_t *data_rw;
434 
435  dtls_session_init(&dtls_session);
436  put_session_addr(&session->remote_addr, &dtls_session);
437  dtls_session.ifindex = session->ifindex;
438  /* Need to do this to not get a compiler warning about const parameters */
439  memcpy (&data_rw, &data, sizeof(data_rw));
440  int res = dtls_handle_message(dtls_context, &dtls_session,
441  data_rw, (int)data_len);
442  if (res >= 0) {
443  if (dtls_get_peer(dtls_context, &dtls_session))
444  res = 1;
445  else
446  res = 0;
447  }
448  return res;
449 }
450 
451 unsigned int coap_dtls_get_overhead(coap_session_t *session) {
452  (void)session;
453  return 13 + 8 + 8;
454 }
455 
456 #ifdef __GNUC__
457 #define UNUSED __attribute__((unused))
458 #else /* __GNUC__ */
459 #define UNUSED
460 #endif /* __GNUC__ */
461 
462 int coap_tls_is_supported(void) {
463  return 0;
464 }
465 
468  static coap_tls_version_t version;
469  const char *vers = dtls_package_version();
470 
471  version.version = 0;
472  if (vers) {
473  long int p1, p2 = 0, p3 = 0;
474  char* endptr;
475 
476  p1 = strtol(vers, &endptr, 10);
477  if (*endptr == '.') {
478  p2 = strtol(endptr+1, &endptr, 10);
479  if (*endptr == '.') {
480  p3 = strtol(endptr+1, &endptr, 10);
481  }
482  }
483  version.version = (p1 << 16) | (p2 << 8) | p3;
484  }
485  version.built_version = version.version;
487  return &version;
488 }
489 
490 int
492  coap_dtls_pki_t* setup_data UNUSED,
493  coap_dtls_role_t role UNUSED
494 ) {
495  return 0;
496 }
497 
498 int
500  const char *ca_file UNUSED,
501  const char *ca_path UNUSED
502 ) {
503  return 0;
504 }
505 
506 int
508  const char *hint UNUSED,
509  coap_dtls_role_t role UNUSED
510 ) {
511  return 1;
512 }
513 
514 int
516 {
517  return 1;
518 }
519 
520 void *coap_tls_new_client_session(coap_session_t *session UNUSED, int *connected UNUSED) {
521  return NULL;
522 }
523 
524 void *coap_tls_new_server_session(coap_session_t *session UNUSED, int *connected UNUSED) {
525  return NULL;
526 }
527 
528 void coap_tls_free_session(coap_session_t *coap_session UNUSED) {
529 }
530 
531 ssize_t coap_tls_write(coap_session_t *session UNUSED,
532  const uint8_t *data UNUSED,
533  size_t data_len UNUSED
534 ) {
535  return -1;
536 }
537 
538 ssize_t coap_tls_read(coap_session_t *session UNUSED,
539  uint8_t *data UNUSED,
540  size_t data_len UNUSED
541 ) {
542  return -1;
543 }
544 
545 #undef UNUSED
546 
547 #else /* !HAVE_LIBTINYDTLS */
548 
549 #ifdef __clang__
550 /* Make compilers happy that do not like empty modules. As this function is
551  * never used, we ignore -Wunused-function at the end of compiling this file
552  */
553 #pragma GCC diagnostic ignored "-Wunused-function"
554 #endif
555 static inline void dummy(void) {
556 }
557 
558 #endif /* HAVE_LIBTINYDTLS */
void coap_dtls_set_log_level(int level)
Sets the log level to the specified value.
int coap_dtls_hello(coap_session_t *session UNUSED, const uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:140
void coap_tls_free_session(coap_session_t *coap_session UNUSED)
Definition: coap_notls.c:159
struct coap_context_t * context
session&#39;s context
Definition: coap_session.h:70
struct sockaddr_in6 sin6
Definition: address.h:67
struct sockaddr_in sin
Definition: address.h:66
void * tls
security parameters
Definition: coap_session.h:71
int coap_dtls_receive(coap_session_t *session UNUSED, const uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:132
multi-purpose address abstraction
Definition: address.h:62
int coap_dtls_context_check_keys_enabled(coap_context_t *ctx UNUSED)
Definition: coap_notls.c:65
#define COAP_EVENT_DTLS_RENEGOTIATE
Definition: coap_event.h:35
ssize_t coap_tls_read(coap_session_t *session UNUSED, uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:169
int coap_dtls_get_log_level(void)
Returns the current log level.
void * coap_dtls_new_client_session(coap_session_t *session UNUSED)
Definition: coap_notls.c:98
int coap_dtls_is_supported(void)
Check whether DTLS is available.
Definition: coap_dtls.c:891
int coap_dtls_context_set_pki(coap_context_t *ctx UNUSED, coap_dtls_pki_t *setup_data UNUSED, coap_dtls_role_t role UNUSED)
Definition: coap_notls.c:41
void * coap_tls_new_server_session(coap_session_t *session UNUSED, int *connected UNUSED)
Definition: coap_notls.c:155
ssize_t coap_tls_write(coap_session_t *session UNUSED, const uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:162
ssize_t coap_session_send(coap_session_t *session, const uint8_t *data, size_t datalen)
Function interface for datagram data transmission.
Definition: coap_session.c:218
coap_session_t * coap_session_get_by_peer(coap_context_t *ctx, const coap_address_t *remote_addr, int ifindex)
Definition: coap_session.c:923
Debug.
Definition: coap_debug.h:49
uint64_t version
(D)TLS runtime Library Version
Definition: coap_dtls.h:48
size_t(* get_client_psk)(const coap_session_t *session, const uint8_t *hint, size_t hint_len, uint8_t *identity, size_t *identity_len, size_t max_identity_len, uint8_t *psk, size_t max_psk_len)
Definition: net.h:203
void coap_dtls_free_session(coap_dtls_session_t *session UNUSED)
Definition: coap_dtls.c:925
void * coap_tls_new_client_session(coap_session_t *session UNUSED, int *connected UNUSED)
Definition: coap_notls.c:151
int coap_tls_is_supported(void)
Check whether TLS is available.
Definition: coap_notls.c:28
#define COAP_TICKS_PER_SECOND
Use ms resolution on POSIX systems.
Definition: coap_time.h:100
struct coap_dtls_session_t * coap_dtls_new_session(const coap_endpoint_t *local_interface UNUSED, const coap_address_t *remote UNUSED)
Definition: coap_dtls.c:919
coap_tls_version_t * coap_get_tls_library_version(void)
Determine the type and version of the underlying (D)TLS library.
Definition: coap_notls.c:33
coap_address_t remote_addr
remote address and port
Definition: coap_session.h:65
int type
Library type.
Definition: coap_dtls.h:49
static void dummy(void)
Warning.
Definition: coap_debug.h:46
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
Definition: coap_time.h:85
unsigned int coap_dtls_get_overhead(coap_session_t *session UNUSED)
Definition: coap_notls.c:147
#define COAP_TLS_LIBRARY_TINYDTLS
Using TinyDTLS library.
Definition: coap_dtls.h:39
Representation of network addresses.
#define UNUSED
Definition: coap_dtls.c:21
void coap_ticks(coap_tick_t *t)
Sets t to the internal time with COAP_TICKS_PER_SECOND resolution.
The structure used for returning the underlying (D)TLS library information.
Definition: coap_dtls.h:47
#define COAP_EVENT_DTLS_CLOSED
(D)TLS events for COAP_PROTO_DTLS and COAP_PROTO_TLS
Definition: coap_event.h:33
int coap_handle_dgram(coap_context_t *ctx, coap_session_t *session, uint8_t *msg, size_t msg_len)
Parses and interprets a CoAP datagram with context ctx.
Definition: net.c:1369
int coap_dtls_context_set_psk(coap_context_t *ctx UNUSED, const char *hint UNUSED, coap_dtls_role_t role UNUSED)
Definition: coap_notls.c:57
void * dtls_context
Definition: net.h:207
coap_dtls_role_t
Definition: coap_dtls.h:264
int ifindex
interface index
Definition: coap_session.h:67
size_t(* get_server_hint)(const coap_session_t *session, uint8_t *hint, size_t max_hint_len)
Definition: net.h:205
#define COAP_EVENT_DTLS_ERROR
Definition: coap_event.h:36
#define COAP_EVENT_DTLS_CONNECTED
Definition: coap_event.h:34
int coap_handle_event(coap_context_t *context, coap_event_t event, coap_session_t *session)
Invokes the event handler of context for the given event and data.
Definition: net.c:2310
static ssize_t dtls_send_to_peer(gnutls_transport_ptr_t context, const void *send_buffer, size_t send_buffer_length)
void * coap_dtls_new_server_session(coap_session_t *session UNUSED)
Definition: coap_notls.c:94
void coap_session_connected(coap_session_t *session)
Notify session that it has just connected or reconnected.
Definition: coap_session.c:326
void coap_dtls_free_context(struct coap_dtls_context_t *dtls_context)
Definition: coap_dtls.c:901
The structure used for defining the PKI setup data to be used.
Definition: coap_dtls.h:191
int coap_dtls_context_set_pki_root_cas(struct coap_context_t *ctx UNUSED, const char *ca_file UNUSED, const char *ca_path UNUSED)
Definition: coap_notls.c:49
struct coap_dtls_context_t * coap_dtls_new_context(struct coap_context_t *coap_context UNUSED)
Definition: coap_dtls.c:896
coap_tick_t coap_dtls_get_timeout(coap_session_t *session UNUSED)
Definition: coap_notls.c:124
size_t(* get_server_psk)(const coap_session_t *session, const uint8_t *identity, size_t identity_len, uint8_t *psk, size_t max_psk_len)
Definition: net.h:204
void * coap_malloc_type(coap_memory_tag_t type, size_t size)
Allocates a chunk of size bytes and returns a pointer to the newly allocated memory.
void coap_dtls_handle_timeout(coap_session_t *session UNUSED)
Definition: coap_notls.c:128
void coap_dtls_startup(void)
Initialize the underlying (D)TLS Library layer.
Definition: coap_notls.c:72
int coap_dtls_send(struct coap_context_t *coap_context UNUSED, struct coap_dtls_session_t *session UNUSED, const unsigned char *data UNUSED, size_t data_len UNUSED)
Definition: coap_dtls.c:912
void coap_session_disconnected(coap_session_t *session, coap_nack_reason_t reason)
Notify session that it has failed.
Definition: coap_session.c:383
#define coap_log(level,...)
Logging function.
Definition: coap_debug.h:122
union coap_address_t::@0 addr
socklen_t size
size of addr
Definition: address.h:63
void coap_free_type(coap_memory_tag_t type, void *p)
Releases the memory that was allocated by coap_malloc_type().
unsigned char uint8_t
Definition: uthash.h:79
coap_tick_t coap_dtls_get_context_timeout(void *dtls_context UNUSED)
Definition: coap_notls.c:120
uint64_t built_version
(D)TLS Built against Library Version
Definition: coap_dtls.h:50
void coap_dtls_session_update_mtu(coap_session_t *session UNUSED)
Definition: coap_notls.c:105
The CoAP stack&#39;s global state is stored in a coap_context_t object.
Definition: net.h:148
int coap_dtls_is_context_timeout(void)
Check if timeout is handled per CoAP session or per CoAP context.
Definition: coap_notls.c:116
struct sockaddr sa
Definition: address.h:65