coap_server.h
Go to the documentation of this file.
1 /**
2  * @file coap_server.h
3  * @brief CoAP server
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2026 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.6.4
29  **/
30 
31 #ifndef _COAP_SERVER_H
32 #define _COAP_SERVER_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "coap/coap_common.h"
37 #include "coap/coap_message.h"
38 #include "coap/coap_option.h"
39 
40 //CoAP server support
41 #ifndef COAP_SERVER_SUPPORT
42  #define COAP_SERVER_SUPPORT ENABLED
43 #elif (COAP_SERVER_SUPPORT != ENABLED && COAP_SERVER_SUPPORT != DISABLED)
44  #error COAP_SERVER_SUPPORT parameter is not valid
45 #endif
46 
47 //DTLS-secured CoAP support
48 #ifndef COAP_SERVER_DTLS_SUPPORT
49  #define COAP_SERVER_DTLS_SUPPORT DISABLED
50 #elif (COAP_SERVER_DTLS_SUPPORT != ENABLED && COAP_SERVER_DTLS_SUPPORT != DISABLED)
51  #error COAP_SERVER_DTLS_SUPPORT parameter is not valid
52 #endif
53 
54 //Observable resource support
55 #ifndef COAP_SERVER_OBSERVE_SUPPORT
56  #define COAP_SERVER_OBSERVE_SUPPORT DISABLED
57 #elif (COAP_SERVER_OBSERVE_SUPPORT != ENABLED && COAP_SERVER_OBSERVE_SUPPORT != DISABLED)
58  #error COAP_SERVER_OBSERVE_SUPPORT parameter is not valid
59 #endif
60 
61 //Stack size required to run the CoAP server
62 #ifndef COAP_SERVER_STACK_SIZE
63  #define COAP_SERVER_STACK_SIZE 650
64 #elif (COAP_SERVER_STACK_SIZE < 1)
65  #error COAP_SERVER_STACK_SIZE parameter is not valid
66 #endif
67 
68 //DTLS server tick interval
69 #ifndef COAP_SERVER_TICK_INTERVAL
70  #define COAP_SERVER_TICK_INTERVAL 250
71 #elif (COAP_SERVER_TICK_INTERVAL < 100)
72  #error COAP_SERVER_TICK_INTERVAL parameter is not valid
73 #endif
74 
75 //DTLS session timeout
76 #ifndef COAP_SERVER_SESSION_TIMEOUT
77  #define COAP_SERVER_SESSION_TIMEOUT 120000
78 #elif (COAP_SERVER_SESSION_TIMEOUT < 0)
79  #error COAP_SERVER_SESSION_TIMEOUT parameter is not valid
80 #endif
81 
82 //Maximum number of retransmissions
83 #ifndef COAP_SERVER_MAX_RETRANSMIT
84  #define COAP_SERVER_MAX_RETRANSMIT 4
85 #elif (COAP_SERVER_MAX_RETRANSMIT < 1)
86  #error COAP_SERVER_MAX_RETRANSMIT parameter is not valid
87 #endif
88 
89 //Initial retransmission timeout (minimum)
90 #ifndef COAP_SERVER_ACK_TIMEOUT_MIN
91  #define COAP_SERVER_ACK_TIMEOUT_MIN 2000
92 #elif (COAP_SERVER_ACK_TIMEOUT_MIN < 1000)
93  #error COAP_SERVER_ACK_TIMEOUT_MIN
94 #endif
95 
96 //Initial retransmission timeout (maximum)
97 #ifndef COAP_SERVER_ACK_TIMEOUT_MAX
98  #define COAP_SERVER_ACK_TIMEOUT_MAX 3000
99 #elif (COAP_SERVER_ACK_TIMEOUT_MAX < COAP_SERVER_ACK_TIMEOUT_MIN)
100  #error COAP_SERVER_ACK_TIMEOUT_MAX
101 #endif
102 
103 //Minimum time interval between non-confirmable notifications
104 #ifndef COAP_SERVER_MIN_NON_CONFIRMABLE_NOTIF_INTERVAL
105  #define COAP_SERVER_MIN_NON_CONFIRMABLE_NOTIF_INTERVAL 3000
106 #elif (COAP_SERVER_MIN_NON_CONFIRMABLE_NOTIF_INTERVAL < 0)
107  #error COAP_SERVER_MIN_NON_CONFIRMABLE_NOTIF_INTERVAL
108 #endif
109 
110 //Maximum time interval between confirmable notifications
111 #ifndef COAP_SERVER_MAX_CONFIRMABLE_NOTIF_INTERVAL
112  #define COAP_SERVER_MAX_CONFIRMABLE_NOTIF_INTERVAL 60000
113 #elif (COAP_SERVER_MAX_CONFIRMABLE_NOTIF_INTERVAL < 1000)
114  #error COAP_SERVER_MAX_CONFIRMABLE_NOTIF_INTERVAL
115 #endif
116 
117 //Size of buffer used for input/output operations
118 #ifndef COAP_SERVER_BUFFER_SIZE
119  #define COAP_SERVER_BUFFER_SIZE 2048
120 #elif (COAP_SERVER_BUFFER_SIZE < 1)
121  #error COAP_SERVER_BUFFER_SIZE parameter is not valid
122 #endif
123 
124 //Maximum size of observable recources
125 #ifndef COAP_SERVER_MAX_OBS_RESOURCE_SIZE
126  #define COAP_SERVER_MAX_OBS_RESOURCE_SIZE 512
127 #elif (COAP_SERVER_MAX_OBS_RESOURCE_SIZE < 1)
128  #error COAP_SERVER_MAX_OBS_RESOURCE_SIZE parameter is not valid
129 #endif
130 
131 //Maximum size of the cookie secret
132 #ifndef COAP_SERVER_MAX_COOKIE_SECRET_SIZE
133  #define COAP_SERVER_MAX_COOKIE_SECRET_SIZE 32
134 #elif (COAP_SERVER_MAX_COOKIE_SECRET_SIZE < 1)
135  #error COAP_SERVER_MAX_COOKIE_SECRET_SIZE parameter is not valid
136 #endif
137 
138 //Maximum length of URI
139 #ifndef COAP_SERVER_MAX_URI_LEN
140  #define COAP_SERVER_MAX_URI_LEN 128
141 #elif (COAP_SERVER_MAX_URI_LEN < 1)
142  #error COAP_SERVER_MAX_URI_LEN parameter is not valid
143 #endif
144 
145 //Priority at which the CoAP server should run
146 #ifndef COAP_SERVER_PRIORITY
147  #define COAP_SERVER_PRIORITY OS_TASK_PRIORITY_NORMAL
148 #endif
149 
150 //Application specific context
151 #ifndef COAP_SERVER_PRIVATE_CONTEXT
152  #define COAP_SERVER_PRIVATE_CONTEXT
153 #endif
154 
155 //DTLS supported?
156 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
157  #include "core/crypto.h"
158  #include "tls/tls.h"
159  #include "tls/tls_ticket.h"
160 #endif
161 
162 //Forward declaration of CoapServerContext structure
163 struct _CoapServerContext;
164 #define CoapServerContext struct _CoapServerContext
165 
166 //Forward declaration of CoapDtlsSession structure
167 struct _CoapDtlsSession;
168 #define CoapDtlsSession struct _CoapDtlsSession
169 
170 //Forward declaration of CoapResource structure
171 struct _CoapResource;
172 #define CoapResource struct _CoapResource
173 
174 //Forward declaration of CoapObserver structure
175 struct _CoapObserver;
176 #define CoapObserver struct _CoapObserver
177 
178 //C++ guard
179 #ifdef __cplusplus
180 extern "C" {
181 #endif
182 
183 
184 /**
185  * @brief Observer states
186  **/
187 
188 typedef enum
189 {
194 
195 
196 /**
197  * @brief UDP initialization callback function
198  **/
199 
201  Socket *socket);
202 
203 
204 //DTLS supported?
205 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
206 
207 /**
208  * @brief DTLS initialization callback
209  **/
210 
212  TlsContext *dtlsContext);
213 
214 #endif
215 
216 
217 /**
218  * @brief CoAP request callback function
219  **/
220 
222  CoapCode method, const char_t *uri);
223 
224 
225 /**
226  * @brief Observe callback function
227  **/
228 
230  CoapObserver *observer, CoapResource *resource);
231 
232 
233 /**
234  * @brief CoAP server settings
235  **/
236 
237 typedef struct
238 {
239  OsTaskParameters task; ///<Task parameters
240  NetContext *netContext; ///<TCP/IP stack context
241  NetInterface *interface; ///<Underlying network interface
242  uint16_t port; ///<CoAP port number
243 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
244  uint_t numSessions; ///<Maximum number of DTLS sessions
245  CoapDtlsSession *sessions; ///<DTLS sessions
246 #endif
247 #if (COAP_SERVER_OBSERVE_SUPPORT == ENABLED)
248  uint_t numResources; ///<Maximum number of observable resources
249  CoapResource *resources; ///<Observable resources
250  uint_t numObservers; ///<Maximum number of observers
251  CoapObserver *observers; ///<Observers
252 #endif
253  CoapServerUdpInitCallback udpInitCallback; ///<UDP initialization callback
254 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
255  CoapServerDtlsInitCallback dtlsInitCallback; ///<DTLS initialization callback
256 #endif
257  CoapServerRequestCallback requestCallback; ///<CoAP request callback
258 #if (COAP_SERVER_OBSERVE_SUPPORT == ENABLED)
260 #endif
262 
263 
264 /**
265  * @brief CoAP server context
266  **/
267 
269 {
270  NetContext *netContext; ///<TCP/IP stack context
271  NetInterface *interface; ///<Underlying network interface
272  uint16_t port; ///<CoAP port number
273 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
274  uint_t numSessions; ///<Maximum number of DTLS sessions
275  CoapDtlsSession *sessions; ///<DTLS sessions
276 #endif
277 #if (COAP_SERVER_OBSERVE_SUPPORT == ENABLED)
278  uint_t numResources; ///<Maximum number of observable resources
279  CoapResource *resources; ///<List of observable resources
280  uint_t numObservers; ///<Maximum number of observers
281  CoapObserver *observers; ///<List of registered observers
282 #endif
283  CoapServerUdpInitCallback udpInitCallback; ///<UDP initialization callback
284 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
285  CoapServerDtlsInitCallback dtlsInitCallback; ///<DTLS initialization callback
286 #endif
287  CoapServerRequestCallback requestCallback; ///<CoAP request callback
288 #if (COAP_SERVER_OBSERVE_SUPPORT == ENABLED)
290 #endif
291  bool_t running; ///<Operational state of the CoAP server
292  bool_t stop; ///<Stop request
293  OsMutex mutex; ///<Mutex preventing simultaneous access to the context
294  OsEvent event; ///<Event object used to poll the underlying socket
295  OsTaskParameters taskParams; ///<Task parameters
296  OsTaskId taskId; ///<Task identifier
297  Socket *socket; ///<Underlying socket
298  NetInterface *localInterface; ///<Network interface the CoAP request was received on
299  IpAddr localIpAddr; ///<Destination IP address of the received CoAP request
300  IpAddr remoteIpAddr; ///<Source IP address of the received CoAP request
301  uint16_t remotePort; ///<Source port of the received CoAP request
302  uint8_t buffer[COAP_SERVER_BUFFER_SIZE]; ///<Memory buffer for input/output operations
303  size_t bufferLen; ///<Length of the buffer, in bytes
304  char_t uri[COAP_SERVER_MAX_URI_LEN + 1]; ///<Resource identifier
305  CoapMessage request; ///<CoAP request message
306  CoapMessage response; ///<CoAP response message
307 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
309  size_t cookieSecretLen; ///<Length of the cookie secret, in bytes
310 #endif
311 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED && TLS_TICKET_SUPPORT == ENABLED)
312  TlsTicketContext dtlsTicketContext; ///<DTLS ticket encryption context
313 #endif
314 #if (COAP_SERVER_OBSERVE_SUPPORT == ENABLED)
315  uint16_t mid; ///<Message identifier
316 #endif
317  COAP_SERVER_PRIVATE_CONTEXT ///<Application specific context
318 };
319 
320 
321 /**
322  * @brief DTLS session
323  **/
324 
326 {
327  CoapServerContext *context; ///<Pointer to the CoAP server context
328  NetInterface *interface; ///<Underlying network interface
329  IpAddr serverIpAddr; ///<Server's IP address
330  IpAddr clientIpAddr; ///<Client's IP address
331  uint16_t clientPort; ///<Client's port
332 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
333  TlsContext *dtlsContext; ///<DTLS context
334 #endif
335  systime_t timestamp; ///<Timestamp to manage timeout
336 };
337 
338 
339 /**
340  * @brief Observable resource
341  **/
342 
344 {
345  char_t uri[COAP_SERVER_MAX_URI_LEN + 1]; ///<Resource identifier
346  uint8_t data[COAP_SERVER_MAX_OBS_RESOURCE_SIZE]; ///<Resource state
347  size_t dataLen; ///<Length of the resource state
348  uint32_t seqNum; ///<Sequence number
349 };
350 
351 
352 /**
353  * @brief Observer
354  **/
355 
357 {
358  CoapObserverState state; ///Observer state
359  CoapResource *resource; ///<Registered resource
360  NetInterface *interface; ///<Underlying network interface
361  IpAddr serverIpAddr; ///<Server's IP address
362  IpAddr clientIpAddr; ///<Client's IP address
363  uint16_t clientPort; ///<Client's port
364  CoapMessageType type; ///<Message type
365  uint16_t mid; ///<Message identifier
366  uint8_t token[COAP_MAX_TOKEN_LEN]; ///<Token
367  size_t tokenLen; ///<Length of the token
368  uint_t retransmitCount; ///<Retransmission counter
369  systime_t retransmitTimestamp; ///<Time at which the last message was sent
370  systime_t retransmitTimeout; ///<Retransmission timeout
371  systime_t ackTimestamp; ///<Time at which the last acknowledgement was received
372  bool_t changed; ///<The resource state has changed
373 };
374 
375 
376 //CoAP server related functions
378 
380  const CoapServerSettings *settings);
381 
383  const uint8_t *cookieSecret, size_t cookieSecretLen);
384 
387 
389 
391  const void *data, size_t length);
392 
394 
395 void coapServerTask(CoapServerContext *context);
396 
397 void coapServerDeinit(CoapServerContext *context);
398 
399 //C++ guard
400 #ifdef __cplusplus
401 }
402 #endif
403 
404 #endif
CoapServerRequestCallback requestCallback
CoAP request callback.
Definition: coap_server.h:287
IpAddr remoteIpAddr
Source IP address of the received CoAP request.
Definition: coap_server.h:300
OsTaskParameters taskParams
Task parameters.
Definition: coap_server.h:295
NetInterface * interface
Underlying network interface.
Definition: coap_server.h:241
error_t(* CoapServerUdpInitCallback)(CoapServerContext *context, Socket *socket)
UDP initialization callback function.
Definition: coap_server.h:200
size_t tokenLen
Length of the token.
Definition: coap_server.h:367
uint_t numResources
Maximum number of observable resources.
Definition: coap_server.h:278
#define NetContext
Definition: net.h:36
OsMutex mutex
Mutex preventing simultaneous access to the context.
Definition: coap_server.h:293
int bool_t
Definition: compiler_port.h:63
uint16_t mid
Message identifier.
Definition: coap_server.h:315
NetInterface * interface
Underlying network interface.
Definition: coap_server.h:271
IP network address.
Definition: ip.h:90
NetInterface * interface
Underlying network interface.
Definition: coap_server.h:360
IpAddr serverIpAddr
Server's IP address.
Definition: coap_server.h:329
CoapResource * resources
List of observable resources.
Definition: coap_server.h:279
CoapObserver * observers
List of registered observers.
Definition: coap_server.h:281
uint8_t data[]
Definition: ethernet.h:224
Event object.
uint_t numSessions
Maximum number of DTLS sessions.
Definition: coap_server.h:244
CoapServerObserveCallback observeCallback
Observe callback.
Definition: coap_server.h:289
NetInterface * interface
Underlying network interface.
Definition: coap_server.h:328
CoapServerUdpInitCallback udpInitCallback
UDP initialization callback.
Definition: coap_server.h:253
CoapMessageType type
Message type.
Definition: coap_server.h:364
#define CoapObserver
Definition: coap_server.h:176
CoapResource * resource
Observer state.
Definition: coap_server.h:359
uint16_t clientPort
Client's port.
Definition: coap_server.h:363
uint_t numObservers
Maximum number of observers.
Definition: coap_server.h:280
CoAP server context.
Definition: coap_server.h:269
IpAddr clientIpAddr
Client's IP address.
Definition: coap_server.h:330
#define CoapResource
Definition: coap_server.h:172
char_t uri[COAP_SERVER_MAX_URI_LEN+1]
Resource identifier.
Definition: coap_server.h:345
CoAP message formatting and parsing.
uint16_t clientPort
Client's port.
Definition: coap_server.h:331
OsTaskId taskId
Task identifier.
Definition: coap_server.h:296
uint16_t port
CoAP port number.
Definition: coap_server.h:242
OsTaskParameters task
Task parameters.
Definition: coap_server.h:239
@ COAP_OBSERVER_STATE_UNREGISTERED
Definition: coap_server.h:190
Session ticket encryption context.
Definition: tls_ticket.h:91
@ COAP_OBSERVER_STATE_UPDATING
Definition: coap_server.h:192
CoapServerUdpInitCallback udpInitCallback
UDP initialization callback.
Definition: coap_server.h:283
uint_t numObservers
Maximum number of observers.
Definition: coap_server.h:250
CoapServerObserveCallback observeCallback
Observe callback.
Definition: coap_server.h:259
#define TlsContext
Definition: tls.h:36
error_t
Error codes.
Definition: error.h:43
NetContext * netContext
TCP/IP stack context.
Definition: coap_server.h:270
uint_t numSessions
Maximum number of DTLS sessions.
Definition: coap_server.h:274
OsEvent event
Event object used to poll the underlying socket.
Definition: coap_server.h:294
int_t socket(int_t family, int_t type, int_t protocol)
Create a socket that is bound to a specific transport service provider.
Definition: bsd_socket.c:65
CoapObserver * observers
Observers.
Definition: coap_server.h:251
char_t uri[COAP_SERVER_MAX_URI_LEN+1]
Resource identifier.
Definition: coap_server.h:304
NetInterface * localInterface
Network interface the CoAP request was received on.
Definition: coap_server.h:298
CoapServerDtlsInitCallback dtlsInitCallback
DTLS initialization callback.
Definition: coap_server.h:285
CoAP message.
Definition: coap_message.h:56
error_t coapServerDeleteResource(CoapServerContext *context, const char_t *uri)
Delete an observable resource.
Definition: coap_server.c:607
#define NetInterface
Definition: net.h:40
size_t dataLen
Length of the resource state.
Definition: coap_server.h:347
bool_t stop
Stop request.
Definition: coap_server.h:292
uint8_t data[COAP_SERVER_MAX_OBS_RESOURCE_SIZE]
Resource state.
Definition: coap_server.h:346
void coapServerDeinit(CoapServerContext *context)
Release CoAP server context.
Definition: coap_server.c:777
CoapMessage response
CoAP response message.
Definition: coap_server.h:306
error_t coapServerStop(CoapServerContext *context)
Stop CoAP server.
Definition: coap_server.c:392
General definitions for cryptographic algorithms.
Task parameters.
size_t bufferLen
Length of the buffer, in bytes.
Definition: coap_server.h:303
uint8_t length
Definition: tcp.h:375
error_t coapServerUpdateResource(CoapServerContext *context, const char_t *uri, const void *data, size_t length)
Update the state of an observable resource.
Definition: coap_server.c:525
#define CoapDtlsSession
Definition: coap_server.h:168
uint8_t token[COAP_MAX_TOKEN_LEN]
Token.
Definition: coap_server.h:366
NetContext * netContext
TCP/IP stack context.
Definition: coap_server.h:240
TLS session tickets.
uint16_t remotePort
Source port of the received CoAP request.
Definition: coap_server.h:301
Mutex object.
bool_t changed
The resource state has changed.
Definition: coap_server.h:372
systime_t retransmitTimeout
Retransmission timeout.
Definition: coap_server.h:370
uint32_t systime_t
System time.
uint8_t buffer[COAP_SERVER_BUFFER_SIZE]
Memory buffer for input/output operations.
Definition: coap_server.h:302
char char_t
Definition: compiler_port.h:55
IpAddr serverIpAddr
Server's IP address.
Definition: coap_server.h:361
CoapServerContext * context
Pointer to the CoAP server context.
Definition: coap_server.h:327
TlsContext * dtlsContext
DTLS context.
Definition: coap_server.h:333
CoapDtlsSession * sessions
DTLS sessions.
Definition: coap_server.h:275
CoapMessageType
CoAP message types.
Definition: coap_common.h:88
CoapObserverState
Observer states.
Definition: coap_server.h:189
@ COAP_OBSERVER_STATE_REGISTERED
Definition: coap_server.h:191
#define COAP_SERVER_MAX_URI_LEN
Definition: coap_server.h:140
TlsTicketContext dtlsTicketContext
DTLS ticket encryption context.
Definition: coap_server.h:312
uint_t numResources
Maximum number of observable resources.
Definition: coap_server.h:248
#define CoapServerContext
Definition: coap_server.h:164
CoapServerRequestCallback requestCallback
CoAP request callback.
Definition: coap_server.h:257
#define COAP_MAX_TOKEN_LEN
Definition: coap_common.h:45
error_t coapServerCreateResource(CoapServerContext *context, const char_t *uri)
Create a new observable resource.
Definition: coap_server.c:447
#define Socket
Definition: socket.h:36
uint8_t cookieSecret[COAP_SERVER_MAX_COOKIE_SECRET_SIZE]
Cookie secret.
Definition: coap_server.h:308
error_t(* CoapServerRequestCallback)(CoapServerContext *context, CoapCode method, const char_t *uri)
CoAP request callback function.
Definition: coap_server.h:221
IpAddr clientIpAddr
Client's IP address.
Definition: coap_server.h:362
CoapMessage request
CoAP request message.
Definition: coap_server.h:305
void coapServerGetDefaultSettings(CoapServerSettings *settings)
Initialize settings with default values.
Definition: coap_server.c:52
systime_t ackTimestamp
Time at which the last acknowledgement was received.
Definition: coap_server.h:371
systime_t retransmitTimestamp
Time at which the last message was sent.
Definition: coap_server.h:369
TLS (Transport Layer Security)
error_t coapServerStart(CoapServerContext *context)
Start CoAP server.
Definition: coap_server.c:294
#define COAP_SERVER_PRIVATE_CONTEXT
Definition: coap_server.h:152
CoapServerDtlsInitCallback dtlsInitCallback
DTLS initialization callback.
Definition: coap_server.h:255
bool_t running
Operational state of the CoAP server.
Definition: coap_server.h:291
thread_t * OsTaskId
Task identifier.
uint16_t port
CoAP port number.
Definition: coap_server.h:272
CoapResource * resources
Observable resources.
Definition: coap_server.h:249
#define COAP_SERVER_MAX_COOKIE_SECRET_SIZE
Definition: coap_server.h:133
IpAddr localIpAddr
Destination IP address of the received CoAP request.
Definition: coap_server.h:299
uint16_t mid
Message identifier.
Definition: coap_server.h:365
CoapObserverState state
Definition: coap_server.h:358
unsigned int uint_t
Definition: compiler_port.h:57
systime_t timestamp
Timestamp to manage timeout.
Definition: coap_server.h:335
Observable resource.
Definition: coap_server.h:344
TCP/IP stack core.
Observer.
Definition: coap_server.h:357
CoapDtlsSession * sessions
DTLS sessions.
Definition: coap_server.h:245
error_t(* CoapServerDtlsInitCallback)(CoapServerContext *context, TlsContext *dtlsContext)
DTLS initialization callback.
Definition: coap_server.h:211
CoAP server settings.
Definition: coap_server.h:238
void coapServerTask(CoapServerContext *context)
CoAP server task.
Definition: coap_server.c:675
size_t cookieSecretLen
Length of the cookie secret, in bytes.
Definition: coap_server.h:309
error_t(* CoapServerObserveCallback)(CoapServerContext *context, CoapObserver *observer, CoapResource *resource)
Observe callback function.
Definition: coap_server.h:229
Socket * socket
Underlying socket.
Definition: coap_server.h:297
#define COAP_SERVER_BUFFER_SIZE
Definition: coap_server.h:119
CoapCode
CoAP method and response codes.
Definition: coap_common.h:113
uint32_t seqNum
Sequence number.
Definition: coap_server.h:348
DTLS session.
Definition: coap_server.h:326
Definitions common to CoAP client and server.
#define COAP_SERVER_MAX_OBS_RESOURCE_SIZE
Definition: coap_server.h:126
Formatting and parsing of CoAP options.
error_t coapServerInit(CoapServerContext *context, const CoapServerSettings *settings)
CoAP server initialization.
Definition: coap_server.c:108
error_t coapServerSetCookieSecret(CoapServerContext *context, const uint8_t *cookieSecret, size_t cookieSecretLen)
Set cookie secret.
Definition: coap_server.c:264
uint_t retransmitCount
Retransmission counter.
Definition: coap_server.h:368