Contiki-NG
Loading...
Searching...
No Matches
coap-uip.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016, SICS, Swedish ICT AB.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the Institute nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30/**
31 * \file
32 * CoAP transport implementation for uIPv6
33 * \author
34 * Niclas Finne <nfi@sics.se>
35 * Joakim Eriksson <joakime@sics.se>
36 */
37
38/**
39 * \addtogroup coap-transport
40 * @{
41 *
42 * \defgroup coap-uip CoAP transport implementation for uIP
43 * @{
44 *
45 * This is an implementation of CoAP transport and CoAP endpoint over uIP
46 * with DTLS support.
47 */
48
49#include "contiki.h"
51#include "net/ipv6/uiplib.h"
52#include "net/routing/routing.h"
53#include "coap.h"
54#include "coap-engine.h"
55#include "coap-endpoint.h"
56#include "coap-transport.h"
57#include "coap-transactions.h"
58#include "coap-constants.h"
59#include "coap-keystore.h"
61
62/* Log configuration */
63#include "coap-log.h"
64#define LOG_MODULE "coap-uip"
65#define LOG_LEVEL LOG_LEVEL_COAP
66
67#ifdef WITH_DTLS
69#endif /* WITH_DTLS */
70
71/* sanity check for configured values */
72#if COAP_MAX_PACKET_SIZE > (UIP_BUFSIZE - UIP_IPH_LEN - UIP_UDPH_LEN)
73#error "UIP_CONF_BUFFER_SIZE too small for COAP_MAX_CHUNK_SIZE"
74#endif
75
76#define SERVER_LISTEN_PORT UIP_HTONS(COAP_DEFAULT_PORT)
77#define SERVER_LISTEN_SECURE_PORT UIP_HTONS(COAP_DEFAULT_SECURE_PORT)
78
79#ifdef WITH_DTLS
80static struct uip_udp_conn *dtls_conn = NULL;
81static const coap_keystore_t *dtls_keystore = NULL;
82#ifdef COAP_DTLS_CONF_WITH_PSK
83static int coap_ep_get_dtls_psk_info(const coap_endpoint_t *ep,
85#endif /* COAP_DTLS_CONF_WITH_PSK */
86#ifdef COAP_DTLS_CONF_WITH_CERT
87static int coap_ep_get_dtls_cert_info(const coap_endpoint_t *ep,
89#endif /* COAP_DTLS_CONF_WITH_CERT */
90#endif /* WITH_DTLS */
91
92
93PROCESS(coap_engine, "CoAP Engine");
94
95static struct uip_udp_conn *udp_conn = NULL;
96
97/*---------------------------------------------------------------------------*/
98void
99coap_endpoint_log(const coap_endpoint_t *ep)
100{
101 if(ep == NULL) {
102 LOG_OUTPUT("(NULL EP)");
103 return;
104 }
105 if(ep->secure) {
106 LOG_OUTPUT("coaps://[");
107 } else {
108 LOG_OUTPUT("coap://[");
109 }
110 log_6addr(&ep->ipaddr);
111 LOG_OUTPUT("]:%u", uip_ntohs(ep->port));
112}
113/*---------------------------------------------------------------------------*/
114void
115coap_endpoint_print(const coap_endpoint_t *ep)
116{
117 if(ep == NULL) {
118 printf("(NULL EP)");
119 return;
120 }
121 if(ep->secure) {
122 printf("coaps://[");
123 } else {
124 printf("coap://[");
125 }
126 uiplib_ipaddr_print(&ep->ipaddr);
127 printf("]:%u", uip_ntohs(ep->port));
128}
129/*---------------------------------------------------------------------------*/
130int
131coap_endpoint_snprint(char *buf, size_t size, const coap_endpoint_t *ep)
132{
133 int n;
134 if(buf == NULL || size == 0) {
135 return 0;
136 }
137 if(ep == NULL) {
138 n = snprintf(buf, size - 1, "(NULL EP)");
139 } else {
140 if(ep->secure) {
141 n = snprintf(buf, size - 1, "coaps://[");
142 } else {
143 n = snprintf(buf, size - 1, "coap://[");
144 }
145 if(n < size - 1) {
146 n += uiplib_ipaddr_snprint(&buf[n], size - n - 1, &ep->ipaddr);
147 }
148 if(n < size - 1) {
149 n += snprintf(&buf[n], size -n - 1, "]:%u", uip_ntohs(ep->port));
150 }
151 }
152 if(n >= size - 1) {
153 buf[size - 1] = '\0';
154 }
155 return n;
156}
157/*---------------------------------------------------------------------------*/
158void
159coap_endpoint_copy(coap_endpoint_t *destination,
160 const coap_endpoint_t *from)
161{
162 uip_ipaddr_copy(&destination->ipaddr, &from->ipaddr);
163 destination->port = from->port;
164 destination->secure = from->secure;
165}
166/*---------------------------------------------------------------------------*/
167int
168coap_endpoint_cmp(const coap_endpoint_t *e1, const coap_endpoint_t *e2)
169{
170 if(!uip_ipaddr_cmp(&e1->ipaddr, &e2->ipaddr)) {
171 return 0;
172 }
173 return e1->port == e2->port && e1->secure == e2->secure;
174}
175/*---------------------------------------------------------------------------*/
176static int
177index_of(const char *data, int offset, int len, uint8_t c)
178{
179 if(offset < 0) {
180 return offset;
181 }
182 for(; offset < len; offset++) {
183 if(data[offset] == c) {
184 return offset;
185 }
186 }
187 return -1;
188}
189/*---------------------------------------------------------------------------*/
190static int
191get_port(const char *inbuf, size_t len, uint32_t *value)
192{
193 int i;
194 *value = 0;
195 for(i = 0; i < len; i++) {
196 if(inbuf[i] >= '0' && inbuf[i] <= '9') {
197 *value = *value * 10 + (inbuf[i] - '0');
198 } else {
199 break;
200 }
201 }
202 return i;
203}
204/*---------------------------------------------------------------------------*/
205int
206coap_endpoint_parse(const char *text, size_t size, coap_endpoint_t *ep)
207{
208 /* Only IPv6 supported */
209 int start = index_of(text, 0, size, '[');
210 int end = index_of(text, start, size, ']');
211 uint32_t port;
212
213 ep->secure = strncmp(text, "coaps:", 6) == 0;
214 if(start >= 0 && end > start &&
215 uiplib_ipaddrconv(&text[start], &ep->ipaddr)) {
216 if(text[end + 1] == ':' &&
217 get_port(text + end + 2, size - end - 2, &port)) {
218 ep->port = UIP_HTONS(port);
219 } else if(ep->secure) {
220 /* Use secure CoAP port by default for secure endpoints. */
221 ep->port = SERVER_LISTEN_SECURE_PORT;
222 } else {
223 ep->port = SERVER_LISTEN_PORT;
224 }
225 return 1;
226 } else if(size < UIPLIB_IPV6_MAX_STR_LEN) {
227 char buf[UIPLIB_IPV6_MAX_STR_LEN];
228 memcpy(buf, text, size);
229 buf[size] = '\0';
230 if(uiplib_ipaddrconv(buf, &ep->ipaddr)) {
231 ep->port = SERVER_LISTEN_PORT;
232 return 1;
233 }
234 }
235 return 0;
236}
237/*---------------------------------------------------------------------------*/
238static const coap_endpoint_t *
239get_src_endpoint(uint8_t secure)
240{
241 static coap_endpoint_t src;
242 uip_ipaddr_copy(&src.ipaddr, &UIP_IP_BUF->srcipaddr);
243 src.port = UIP_UDP_BUF->srcport;
244 src.secure = secure;
245 return &src;
246}
247/*---------------------------------------------------------------------------*/
248int
249coap_endpoint_is_secure(const coap_endpoint_t *ep)
250{
251 return ep->secure;
252}
253/*---------------------------------------------------------------------------*/
254int
255coap_endpoint_is_connected(const coap_endpoint_t *ep)
256{
257#ifndef CONTIKI_TARGET_NATIVE
258 if(!uip_is_addr_linklocal(&ep->ipaddr)
259 && NETSTACK_ROUTING.node_is_reachable() == 0) {
260 return false;
261 }
262#endif
263
264#ifdef WITH_DTLS
265 if(coap_ep_is_dtls_peer(ep)) {
266 /* only if handshake is done! */
267 LOG_DBG("DTLS peer state for ");
268 LOG_DBG_COAP_EP(ep);
269 LOG_DBG_(" is %sconnected\n", coap_ep_is_dtls_connected(ep) ? "" : "not ");
270 return coap_ep_is_dtls_connected(ep);
271 } else {
272 LOG_DBG("DTLS did not find peer ");
273 LOG_DBG_COAP_EP(ep);
274 LOG_DBG_("\n");
275 return false;
276 }
277#endif /* WITH_DTLS */
278
279 /* Assume connected */
280 return true;
281}
282/*---------------------------------------------------------------------------*/
283int
284coap_endpoint_connect(coap_endpoint_t *ep)
285{
286#ifdef WITH_DTLS
287#ifdef COAP_DTLS_CONF_WITH_CLIENT
288#ifdef COAP_DTLS_CONF_WITH_PSK
289 static coap_keystore_psk_entry_t psk_info;
290#endif /* COAP_DTLS_CONF_WITH_PSK */
291#ifdef COAP_DTLS_CONF_WITH_CERT
292 static coap_keystore_cert_entry_t cert_info;
293#endif /* COAP_DTLS_CONF_WITH_CERT */
294#endif /* COAP_DTLS_CONF_WITH_CLIENT */
295#endif /* WITH_DTLS */
296
297 if(!ep->secure) {
298 LOG_DBG("connect to ");
299 LOG_DBG_COAP_EP(ep);
300 LOG_DBG_("\n");
301 return 1;
302 }
303
304#ifdef WITH_DTLS
305 LOG_DBG("DTLS connect to ");
306 LOG_DBG_COAP_EP(ep);
307 LOG_DBG_("\n");
308
309#ifdef COAP_DTLS_CONF_WITH_CLIENT
310#ifdef COAP_DTLS_CONF_WITH_PSK
311 if(coap_ep_get_dtls_psk_info(ep, &psk_info) == 1) {
312 return coap_ep_dtls_connect(ep, COAP_DTLS_SEC_MODE_PSK, &psk_info);
313 }
314#endif /* COAP_DTLS_CONF_WITH_PSK */
315#ifdef COAP_DTLS_CONF_WITH_CERT
316 if(coap_ep_get_dtls_cert_info(ep, &cert_info) == 1) {
317 return coap_ep_dtls_connect(ep, COAP_DTLS_SEC_MODE_CERT, &cert_info);
318 }
319#endif /* COAP_DTLS_CONF_WITH_CERT */
320 LOG_ERR("Unable to retrieve DTLS authorization info for \n");
321 LOG_ERR_COAP_EP(ep);
322 LOG_ERR_("\n");
323#endif /* COAP_DTLS_CONF_WITH_CLIENT */
324#endif /* WITH_DTLS */
325
326 return 0;
327}
328/*---------------------------------------------------------------------------*/
329#ifdef WITH_DTLS
330#ifdef COAP_DTLS_CONF_WITH_SERVER
331int
333{
334 coap_endpoint_t ep;
335#ifdef COAP_DTLS_CONF_WITH_CERT
336 static coap_keystore_cert_entry_t cert_info;
337#endif /* COAP_DTLS_CONF_WITH_CERT */
338#ifdef COAP_DTLS_CONF_WITH_PSK
339 static coap_keystore_psk_entry_t psk_info;
340#endif /* COAP_DTLS_CONF_WITH_PSK */
341
342#ifdef COAP_DTLS_CONF_WITH_PSK
343 if(coap_ep_get_dtls_psk_info(&ep, &psk_info) == 1) {
344 return coap_dtls_server_setup(COAP_DTLS_SEC_MODE_PSK, &psk_info);
345 }
346#endif /* COAP_DTLS_CONF_WITH_PSK */
347
348#ifdef COAP_DTLS_CONF_WITH_CERT
349 if(coap_ep_get_dtls_cert_info(&ep, &cert_info) == 1) {
350 return coap_dtls_server_setup(COAP_DTLS_SEC_MODE_CERT, &cert_info);
351 }
352#endif /* COAP_DTLS_CONF_WITH_CERT */
353 return 0;
354}
355#endif /* COAP_DTLS_CONF_WITH_SERVER */
356#endif /* WITH_DTLS */
357/*---------------------------------------------------------------------------*/
358void
359coap_endpoint_disconnect(coap_endpoint_t *ep)
360{
361#ifdef WITH_DTLS
363#endif /* WITH_DTLS */
364}
365/*---------------------------------------------------------------------------*/
366uint8_t *
368{
369 return uip_appdata;
370}
371/*---------------------------------------------------------------------------*/
372void
374{
375 process_start(&coap_engine, NULL);
376#ifdef WITH_DTLS
378
379#if COAP_DTLS_KEYSTORE_CONF_WITH_SIMPLE
381#endif /* COAP_DTLS_KEYSTORE_CONF_WITH_SIMPLE */
382
383#endif /* WITH_DTLS */
384}
385/*---------------------------------------------------------------------------*/
386#ifdef WITH_DTLS
387static void
388process_secure_data(void)
389{
390 LOG_INFO("receiving secure UDP datagram from [");
391 LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
392 LOG_INFO_("]:%u\n", uip_ntohs(UIP_UDP_BUF->srcport));
393 LOG_INFO(" Length: %u\n", uip_datalen());
394
395 int ret;
396
398 (const coap_endpoint_t *) get_src_endpoint(1))) > 0) {
399 coap_receive(get_src_endpoint(1), uip_appdata, ret);
400 }
401}
402#endif /* WITH_DTLS */
403/*---------------------------------------------------------------------------*/
404static void
405process_data(void)
406{
407 LOG_INFO("receiving UDP datagram from [");
408 LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
409 LOG_INFO_("]:%u\n", uip_ntohs(UIP_UDP_BUF->srcport));
410 LOG_INFO(" Length: %u\n", uip_datalen());
411
412 coap_receive(get_src_endpoint(0), uip_appdata, uip_datalen());
413}
414/*---------------------------------------------------------------------------*/
415int
416coap_sendto(const coap_endpoint_t *ep, const uint8_t *data, uint16_t length)
417{
418 if(ep == NULL) {
419 LOG_WARN("failed to send - no endpoint\n");
420 return -1;
421 }
422
424 LOG_WARN("endpoint ");
425 LOG_WARN_COAP_EP(ep);
426 LOG_WARN_(" not connected - dropping packet\n");
427 return -1;
428 }
429
430#ifdef WITH_DTLS
432 int ret;
433 ret = coap_ep_dtls_write(ep, (unsigned char *) data, length);
434 LOG_INFO("sent DTLS to ");
435 LOG_INFO_COAP_EP(ep);
436 if(ret < 0) {
437 LOG_INFO_(" - error %d\n", ret);
438 } else {
439 LOG_INFO_(" %d/%u bytes\n", ret, length);
440 }
441 return ret;
442 }
443#endif /* WITH_DTLS */
444
445 uip_udp_packet_sendto(udp_conn, data, length, &ep->ipaddr, ep->port);
446 LOG_INFO("sent to ");
447 LOG_INFO_COAP_EP(ep);
448 LOG_INFO_(" %u bytes\n", length);
449 return length;
450}
451/*---------------------------------------------------------------------------*/
452PROCESS_THREAD(coap_engine, ev, data)
453{
455
456 /* new connection with remote host */
457 udp_conn = udp_new(NULL, 0, NULL);
458 if(udp_conn == NULL) {
459 LOG_ERR("No UDP connection available, exiting the process!\n");
460 PROCESS_EXIT();
461 }
462
463 udp_bind(udp_conn, SERVER_LISTEN_PORT);
464 LOG_INFO("Listening on port %u\n", uip_ntohs(udp_conn->lport));
465
466#ifdef WITH_DTLS
467 /* create new context with app-data */
468 dtls_conn = udp_new(NULL, 0, NULL);
469 if(dtls_conn != NULL) {
470 udp_bind(dtls_conn, SERVER_LISTEN_SECURE_PORT);
471 LOG_INFO("DTLS listening on port %u\n", uip_ntohs(dtls_conn->lport));
473 }
474#endif /* WITH_DTLS */
475
476 while(1) {
478#ifdef WITH_DTLS
479 if(ev == PROCESS_EVENT_POLL || ev == PROCESS_EVENT_TIMER) {
481 continue;
482 }
483#endif /* WITH_DTLS */
484 if(ev == tcpip_event) {
485 if(uip_newdata()) {
486#ifdef WITH_DTLS
487 if(uip_udp_conn == dtls_conn) {
488 process_secure_data();
489 continue;
490 }
491#endif /* WITH_DTLS */
492 process_data();
493 }
494 }
495 } /* while (1) */
496
497 PROCESS_END();
498}
499/*---------------------------------------------------------------------------*/
500
501/* DTLS */
502#ifdef WITH_DTLS
503/* This defines the key-store set API since we hookup DTLS here */
504void
505coap_set_keystore(const coap_keystore_t *keystore)
506{
507 dtls_keystore = keystore;
508}
509/*---------------------------------------------------------------------------*/
510#ifdef COAP_DTLS_CONF_WITH_PSK
511static int
512coap_ep_get_dtls_psk_info(const coap_endpoint_t *ep,
514{
515 if(NULL != dtls_keystore) {
516 if(dtls_keystore->coap_get_psk_info) {
517 /* Get identity first */
518 dtls_keystore->coap_get_psk_info(ep, info);
519 /* Get key */
520 dtls_keystore->coap_get_psk_info(ep, info);
521 return 1;
522 }
523 }
524 return 0;
525}
526#endif /* COAP_DTLS_CONF_WITH_PSK */
527/*---------------------------------------------------------------------------*/
528#ifdef COAP_DTLS_CONF_WITH_CERT
529static int
530coap_ep_get_dtls_cert_info(const coap_endpoint_t *ep,
532{
533 if(dtls_keystore != NULL && dtls_keystore->coap_get_cert_info != NULL) {
534 return dtls_keystore->coap_get_cert_info(ep, info);
535 }
536 return 0;
537}
538#endif /* COAP_DTLS_CONF_WITH_CERT */
539
540/*---------------------------------------------------------------------------*/
541#endif /* WITH_DTLS */
542/*---------------------------------------------------------------------------*/
543/** @} */
544/** @} */
Collection of constants specified in the CoAP standard.
API to address CoAP endpoints.
CoAP engine implementation.
A simple keystore with fixed credentials.
API for CoAP keystore.
Log support for CoAP.
CoAP module for reliable transport.
API for CoAP transport.
An implementation of the Constrained Application Protocol (RFC 7252).
void coap_keystore_simple_init(void)
Registers a simple CoAP DTLS keystore with fixed pre-shared key credentials.
void coap_set_keystore(const coap_keystore_t *keystore)
Set the CoAP keystore to use by CoAP.
int coap_secure_server_setup(void)
Setup a DTLS server session.
int coap_sendto(const coap_endpoint_t *ep, const uint8_t *data, uint16_t length)
Send a message to the specified CoAP endpoint.
Definition coap-uip.c:416
void coap_endpoint_disconnect(coap_endpoint_t *ep)
Request that any connection to a CoAP endpoint is discontinued.
Definition coap-uip.c:359
int coap_endpoint_cmp(const coap_endpoint_t *e1, const coap_endpoint_t *e2)
Compare two CoAP endpoints.
Definition coap-uip.c:168
int coap_endpoint_parse(const char *text, size_t size, coap_endpoint_t *ep)
Parse a CoAP endpoint.
Definition coap-uip.c:206
int coap_endpoint_connect(coap_endpoint_t *ep)
Request a connection to a CoAP endpoint.
Definition coap-uip.c:284
uint8_t * coap_databuf(void)
Returns a common data buffer that can be used when generating CoAP messages for transmission.
Definition coap-uip.c:367
void coap_endpoint_log(const coap_endpoint_t *ep)
Print a CoAP endpoint via the logging module.
Definition coap-uip.c:99
void coap_endpoint_print(const coap_endpoint_t *ep)
Print a CoAP endpoint.
Definition coap-uip.c:115
int coap_endpoint_snprint(char *buf, size_t size, const coap_endpoint_t *ep)
Print a CoAP endpoint to a string.
Definition coap-uip.c:131
int coap_endpoint_is_secure(const coap_endpoint_t *ep)
Check if a CoAP endpoint is secure (encrypted).
Definition coap-uip.c:249
void coap_transport_init(void)
Initialize the CoAP transport.
Definition coap-uip.c:373
void coap_endpoint_copy(coap_endpoint_t *destination, const coap_endpoint_t *from)
Copy a CoAP endpoint from one memory area to another.
Definition coap-uip.c:159
int coap_endpoint_is_connected(const coap_endpoint_t *ep)
Check if a CoAP endpoint is connected.
Definition coap-uip.c:255
void log_6addr(const uip_ipaddr_t *ipaddr)
Logs an IPv6 address.
Definition log.c:92
#define PROCESS(name, strname)
Declare a process.
Definition process.h:308
#define PROCESS_EXIT()
Exit the currently running process.
Definition process.h:201
#define PROCESS_CURRENT()
Get a pointer to the currently running process.
Definition process.h:404
#define PROCESS_BEGIN()
Define the beginning of a process.
Definition process.h:121
#define PROCESS_END()
Define the end of a process.
Definition process.h:132
void process_start(struct process *p, process_data_t data)
Start a process.
Definition process.c:121
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
Definition process.h:274
#define PROCESS_YIELD()
Yield the currently running process.
Definition process.h:165
static void start(void)
Start measurement.
process_event_t tcpip_event
The uIP event.
Definition tcpip.c:62
struct uip_udp_conn * udp_new(const uip_ipaddr_t *ripaddr, uint16_t port, void *appstate)
Create a new UDP connection.
Definition tcpip.c:264
#define udp_bind(conn, port)
Bind a UDP connection to a local port.
Definition tcpip.h:259
#define uiplib_ipaddrconv
Convert a textual representation of an IP address to a numerical representation.
Definition uiplib.h:71
void uiplib_ipaddr_print(const uip_ipaddr_t *addr)
Print an IP address using printf().
Definition uiplib.c:158
int uiplib_ipaddr_snprint(char *buf, size_t size, const uip_ipaddr_t *addr)
Write at most size - 1 characters of the IP address to the output string.
Definition uiplib.c:166
void * uip_appdata
Pointer to the application data in the packet buffer.
Definition uip6.c:148
#define uip_is_addr_linklocal(a)
is addr (a) a link local unicast address, see RFC 4291 i.e.
Definition uip.h:1766
#define UIP_IP_BUF
Direct access to IPv6 header.
Definition uip.h:71
#define uip_datalen()
The length of any incoming data that is currently available (if available) in the uip_appdata buffer.
Definition uip.h:593
#define uip_newdata()
Is new incoming data available?
Definition uip.h:680
#define UIP_HTONS(n)
Convert 16-bit quantity from host byte order to network byte order.
Definition uip.h:1157
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
Definition uip.h:969
void coap_dtls_conn_init(struct uip_udp_conn *udp_conn, struct process *host_process)
Registers, 1.
int coap_ep_dtls_write(const coap_endpoint_t *ep, const unsigned char *message, int len)
Encrypt app.
bool coap_ep_is_dtls_peer(const coap_endpoint_t *ep)
Check if a CoAP endpoint is a peer in the list of DTLS sessions.
bool coap_ep_is_dtls_connected(const coap_endpoint_t *ep)
Check if a peer has completed the handshake successfully.
void coap_dtls_init(void)
Initializes CoAP-MbedTLS global info.
void coap_ep_dtls_disconnect(const coap_endpoint_t *ep)
Disconnect a peer.
void coap_dtls_event_handler(void)
Handler for timer, and process-poll events.
int coap_ep_dtls_handle_message(const coap_endpoint_t *ep)
Handler for new DTLS messages.
DTLS (Mbed TLS implementation) support for CoAP.
Routing driver header file.
The structure of a CoAP PKI certificate info.
The structure of a CoAP pre-shared key info.
The structure of a CoAP keystore.
int(* node_is_reachable)(void)
Tells whether the node is currently reachable as part of the network.
Definition routing.h:114
Representation of a uIP UDP connection.
Definition uip.h:1309
uint16_t lport
The local port number in network byte order.
Definition uip.h:1311
Header file for module for sending UDP packets through uIP.
Header file for the IP address manipulation library.