/src/libcoap/include/coap3/coap_pdu_internal.h
Line | Count | Source |
1 | | /* |
2 | | * coap_pdu_internal.h -- CoAP PDU structure |
3 | | * |
4 | | * Copyright (C) 2010-2026 Olaf Bergmann <bergmann@tzi.org> |
5 | | * |
6 | | * SPDX-License-Identifier: BSD-2-Clause |
7 | | * |
8 | | * This file is part of the CoAP library libcoap. Please see README for terms |
9 | | * of use. |
10 | | */ |
11 | | |
12 | | /** |
13 | | * @file coap_pdu_internal.h |
14 | | * @brief CoAP PDU internal information |
15 | | */ |
16 | | |
17 | | #ifndef COAP_COAP_PDU_INTERNAL_H_ |
18 | | #define COAP_COAP_PDU_INTERNAL_H_ |
19 | | |
20 | | #ifdef WITH_LWIP |
21 | | #include <lwip/pbuf.h> |
22 | | #endif |
23 | | |
24 | | #ifdef __cplusplus |
25 | | extern "C" { |
26 | | #endif |
27 | | |
28 | | /** |
29 | | * @ingroup internal_api |
30 | | * @defgroup pdu_internal PDU |
31 | | * Internal API for PDUs |
32 | | * @{ |
33 | | */ |
34 | | |
35 | 20.2k | #define COAP_DEFAULT_VERSION 1 /* version of CoAP supported */ |
36 | | |
37 | | /* TCP Message format constants, do not modify */ |
38 | 6.45k | #define COAP_MESSAGE_SIZE_OFFSET_TCP8 13 |
39 | 2.20k | #define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */ |
40 | 756 | #define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */ |
41 | | |
42 | | /* Derived message size limits */ |
43 | 5.45k | #define COAP_MAX_MESSAGE_SIZE_TCP0 (COAP_MESSAGE_SIZE_OFFSET_TCP8-1) /* 12 */ |
44 | 1.45k | #define COAP_MAX_MESSAGE_SIZE_TCP8 (COAP_MESSAGE_SIZE_OFFSET_TCP16-1) /* 268 */ |
45 | 452 | #define COAP_MAX_MESSAGE_SIZE_TCP16 (COAP_MESSAGE_SIZE_OFFSET_TCP32-1) /* 65804 */ |
46 | | #define COAP_MAX_MESSAGE_SIZE_TCP32 (COAP_MESSAGE_SIZE_OFFSET_TCP32+0xFFFFFFFF) |
47 | | #if COAP_OSCORE_SUPPORT |
48 | | /* for oscore encryption */ |
49 | 0 | #define COAP_MAX_CHUNK_SIZE COAP_DEFAULT_MAX_PDU_RX_SIZE |
50 | 0 | #define OSCORE_CRYPTO_BUFFER_SIZE (COAP_MAX_CHUNK_SIZE+16) |
51 | | #endif /* COAP_OSCORE_SUPPORT */ |
52 | | |
53 | | /* Extended Token constants */ |
54 | 13.8k | #define COAP_TOKEN_EXT_1B_TKL 13 |
55 | 404 | #define COAP_TOKEN_EXT_2B_TKL 14 |
56 | 17.4k | #define COAP_TOKEN_EXT_1B_BIAS 13 |
57 | 626 | #define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */ |
58 | | |
59 | | #ifndef COAP_DEBUG_BUF_SIZE |
60 | | #if defined(WITH_CONTIKI) || defined(WITH_LWIP) |
61 | | #define COAP_DEBUG_BUF_SIZE 128 |
62 | | #else /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ |
63 | | /* 1024 derived from RFC7252 4.6. Message Size max payload */ |
64 | | #define COAP_DEBUG_BUF_SIZE (8 + 1024 * 2) |
65 | | #endif /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ |
66 | | #endif /* COAP_DEBUG_BUF_SIZE */ |
67 | | |
68 | | #ifndef COAP_DEFAULT_MAX_PDU_RX_SIZE |
69 | | #if defined(WITH_LWIP) |
70 | | #if !COAP_DISABLE_TCP |
71 | | /* Need to stop BERT if TCP */ |
72 | | #define COAP_DEFAULT_MAX_PDU_RX_SIZE (1152UL) |
73 | | #else /* COAP_DISABLE_TCP */ |
74 | | #define COAP_DEFAULT_MAX_PDU_RX_SIZE (COAP_RXBUFFER_SIZE) |
75 | | #endif /* COAP_DISABLE_TCP */ |
76 | | #elif defined(WITH_CONTIKI) |
77 | | #define COAP_DEFAULT_MAX_PDU_RX_SIZE (UIP_APPDATA_SIZE) |
78 | | #elif (UINT_MAX < (8UL*1024*1024+256)) |
79 | | #define COAP_DEFAULT_MAX_PDU_RX_SIZE (1500UL) |
80 | | #elif defined(RIOT_VERSION) && COAP_DISABLE_TCP |
81 | | #define COAP_DEFAULT_MAX_PDU_RX_SIZE (1500UL) |
82 | | #else |
83 | | /* 8 MiB max-message-size plus some space for options */ |
84 | 36.6k | #define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256) |
85 | | #endif |
86 | | #endif /* COAP_DEFAULT_MAX_PDU_RX_SIZE */ |
87 | | |
88 | | /** |
89 | | * Indicates that a response is suppressed. This will occur for error |
90 | | * responses if the request was received via IP multicast. |
91 | | */ |
92 | 0 | #define COAP_DROPPED_RESPONSE -2 |
93 | | |
94 | 3.08k | #define COAP_PDU_DELAYED -3 |
95 | | |
96 | 133M | #define COAP_PAYLOAD_START 0xFF /* payload marker */ |
97 | | |
98 | 33.6k | #define COAP_PDU_IS_EMPTY(pdu) ((pdu)->code == 0) |
99 | 33.8k | #define COAP_PDU_IS_REQUEST(pdu) (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32) |
100 | | /* Code 1.xx (32-63) and 6.xx (192-224) currently invalid */ |
101 | 8.12k | #define COAP_PDU_IS_RESPONSE(pdu) ((pdu)->code >= 64 && (pdu)->code < 192) |
102 | 45.3M | #define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224) |
103 | 0 | #define COAP_PDU_IS_PING(pdu) ((COAP_PDU_IS_EMPTY(pdu) && \ |
104 | 0 | ((pdu)->type == COAP_MESSAGE_CON)) || \ |
105 | 0 | ((pdu)->code == COAP_SIGNALING_CODE_PING)) |
106 | | |
107 | 7.01k | #define COAP_PDU_MAX_UDP_HEADER_SIZE 4 |
108 | 22.6k | #define COAP_PDU_MAX_TCP_HEADER_SIZE 6 |
109 | | |
110 | | /** |
111 | | * structure for CoAP PDUs |
112 | | * |
113 | | * Separate COAP_PDU_BUF is allocated with offsets held in coap_pdu_t. |
114 | | |
115 | | * token, if any, follows the fixed size header, then optional options until |
116 | | * payload marker (0xff) (if paylooad), then the optional payload. |
117 | | * |
118 | | * Memory layout is: |
119 | | * <---header--->|<---token---><---options--->0xff<---payload---> |
120 | | * |
121 | | * header is addressed with a negative offset to token, its maximum size is |
122 | | * max_hdr_size. |
123 | | * |
124 | | * allocated buffer always starts max_hdr_size before token. |
125 | | * |
126 | | * options starts at token + e_token_length. |
127 | | * payload starts at data, its length is used_size - (data - token). |
128 | | * |
129 | | * alloc_size, used_size and max_size are the offsets from token. |
130 | | */ |
131 | | |
132 | | struct coap_pdu_t { |
133 | | struct coap_pdu_t *next; /**< Next PDU in a delay chain */ |
134 | | coap_pdu_type_t type; /**< message type */ |
135 | | coap_pdu_code_t code; /**< request method (value 1--31) or response code |
136 | | (value 64-255) */ |
137 | | coap_mid_t mid; /**< message id, if any, in regular host byte |
138 | | order */ |
139 | | uint8_t max_hdr_size; /**< space reserved for protocol-specific header */ |
140 | | uint8_t hdr_size; /**< actual size used for protocol-specific |
141 | | header (0 until header is encoded) */ |
142 | | uint8_t crit_opt; /**< Set if unknown critical option for proxy */ |
143 | | uint16_t max_opt; /**< highest option number in PDU */ |
144 | | uint32_t e_token_length; /**< length of Token space (includes leading |
145 | | extended bytes */ |
146 | | unsigned ref; /**< reference count */ |
147 | | coap_bin_const_t actual_token; /**< Actual token in pdu */ |
148 | | size_t alloc_size; /**< allocated storage for token, options and |
149 | | payload */ |
150 | | size_t used_size; /**< used bytes of storage for token, options and |
151 | | payload */ |
152 | | size_t max_size; /**< maximum size for token, options and payload, |
153 | | or zero for variable size pdu */ |
154 | | uint8_t *token; /**< first byte of token (or extended length bytes |
155 | | prefix), if any, or options */ |
156 | | uint8_t *data; /**< first byte of payload, if any */ |
157 | | #ifdef WITH_LWIP |
158 | | struct pbuf *pbuf; /**< lwIP PBUF. The package data will always reside |
159 | | * inside the pbuf's payload, but this pointer |
160 | | * has to be kept because no exact offset can be |
161 | | * given. This field must not be accessed from |
162 | | * outside, because the pbuf's reference count |
163 | | * is checked to be 1 when the pbuf is assigned |
164 | | * to the pdu, and the pbuf stays exclusive to |
165 | | * this pdu. */ |
166 | | #endif |
167 | | const uint8_t *body_data; /**< Holds ptr to re-assembled data or NULL. This |
168 | | does not get released by coap_delete_pdu() */ |
169 | | size_t body_length; /**< Holds body data length */ |
170 | | size_t body_offset; /**< Holds body data offset */ |
171 | | size_t body_total; /**< Holds body data total size */ |
172 | | coap_lg_xmit_t *lg_xmit; /**< Holds ptr to lg_xmit if sending a set of |
173 | | blocks */ |
174 | | coap_session_t *session; /**< Session responsible for PDU or NULL */ |
175 | | coap_binary_t *data_free; /**< Data to be freed off by coap_delete_pdu() */ |
176 | | }; |
177 | | |
178 | | /** |
179 | | * Parses @p data into the CoAP PDU structure given in @p result. |
180 | | * The target pdu must be large enough to hold the token, options and data. |
181 | | * This function returns @c 0 on error or a number greater than zero on success. |
182 | | * |
183 | | * @param proto Session's protocol |
184 | | * @param data The raw data to parse as CoAP PDU. |
185 | | * @param length The actual size of @p data. |
186 | | * @param pdu The PDU structure to fill. Note that the structure must |
187 | | * provide space to hold the token, optional options and |
188 | | * optional data. |
189 | | * @param error_opts Filled in with any options that have an error in the parsing. |
190 | | * |
191 | | * @return 1 on success or @c 0 on error. |
192 | | */ |
193 | | int coap_pdu_parse2(coap_proto_t proto, |
194 | | const uint8_t *data, |
195 | | size_t length, |
196 | | coap_pdu_t *pdu, |
197 | | coap_opt_filter_t *error_opts); |
198 | | |
199 | | /** |
200 | | * Dynamically grows the size of @p pdu to @p new_size. The new size |
201 | | * must not exceed the PDU's configure maximum size. On success, this |
202 | | * function returns 1, otherwise 0. |
203 | | * |
204 | | * @param pdu The PDU to resize. |
205 | | * @param new_size The new size in bytes. |
206 | | * @return 1 if the operation succeeded, 0 otherwise. |
207 | | */ |
208 | | int coap_pdu_resize(coap_pdu_t *pdu, size_t new_size); |
209 | | |
210 | | /** |
211 | | * Dynamically grows the size of @p pdu to @p new_size if needed. The new size |
212 | | * must not exceed the PDU's configured maximum size. On success, this |
213 | | * function returns 1, otherwise 0. |
214 | | * |
215 | | * @param pdu The PDU to resize. |
216 | | * @param new_size The new size in bytes. |
217 | | * @return 1 if the operation succeeded, 0 otherwise. |
218 | | */ |
219 | | int coap_pdu_check_resize(coap_pdu_t *pdu, size_t new_size); |
220 | | |
221 | | /** |
222 | | * Interprets @p data to determine the number of bytes in the header. |
223 | | * This function returns @c 0 on error or a number greater than zero on success. |
224 | | * |
225 | | * @param proto Session's protocol |
226 | | * @param data The first byte of raw data to parse as CoAP PDU. |
227 | | * |
228 | | * @return A value greater than zero on success or @c 0 on error. |
229 | | */ |
230 | | size_t coap_pdu_parse_header_size(coap_proto_t proto, |
231 | | const uint8_t *data); |
232 | | |
233 | | /** |
234 | | * Parses @p data to extract the message size. |
235 | | * @p length must be at least coap_pdu_parse_header_size(proto, data). |
236 | | * This function returns @c 0 on error or a number greater than zero on success. |
237 | | * |
238 | | * @param proto Session's protocol |
239 | | * @param data The raw data to parse as CoAP PDU. |
240 | | * @param length The actual size of @p data. |
241 | | * |
242 | | * @return PDU size including token on success or @c 0 on error. |
243 | | */ |
244 | | size_t coap_pdu_parse_size(coap_proto_t proto, |
245 | | const uint8_t *data, |
246 | | size_t length); |
247 | | |
248 | | /** |
249 | | * Decode the protocol specific header for the specified PDU. |
250 | | * @param pdu A newly received PDU. |
251 | | * @param proto The target wire protocol. |
252 | | * @return 1 for success or 0 on error. |
253 | | */ |
254 | | |
255 | | int coap_pdu_parse_header(coap_pdu_t *pdu, coap_proto_t proto); |
256 | | |
257 | | /** |
258 | | * Verify consistency in the given CoAP PDU structure and locate the data. |
259 | | * This function returns @c 0 on error or a number greater than zero on |
260 | | * success. |
261 | | * This function only parses the token and options, up to the payload start |
262 | | * marker. |
263 | | * |
264 | | * @param pdu The PDU structure to check. |
265 | | * @param error_opts Updated with error option(s) on failure. |
266 | | * |
267 | | * @return 1 on success or @c 0 on error. |
268 | | */ |
269 | | int coap_pdu_parse_opt(coap_pdu_t *pdu, coap_opt_filter_t *error_opts); |
270 | | |
271 | | /** |
272 | | * Clears any contents from @p pdu and resets @c used_size, |
273 | | * and @c data pointers. @c max_size is set to @p size, any |
274 | | * other field is set to @c 0. Note that @p pdu must be a valid |
275 | | * pointer to a coap_pdu_t object created e.g. by coap_pdu_init(). |
276 | | * |
277 | | * @param pdu The PDU to clear. |
278 | | * @param size The maximum size of the PDU. |
279 | | */ |
280 | | void coap_pdu_clear(coap_pdu_t *pdu, size_t size); |
281 | | |
282 | | /** |
283 | | * Adds option of given @p number to @p pdu that is passed as first |
284 | | * parameter. |
285 | | * |
286 | | * The internal version of coap_add_option() may cause an @p option to be |
287 | | * inserted, even if there is any data in the @p pdu. |
288 | | * |
289 | | * Note: Where possible, the option @p data needs to be stripped of leading |
290 | | * zeros (big endian) to reduce the amount of data needed in the PDU, as well |
291 | | * as in some cases the maximum data size of an option can be exceeded if not |
292 | | * stripped and hence be illegal. This is done by using coap_encode_var_safe() |
293 | | * or coap_encode_var_safe8(). |
294 | | * |
295 | | * @param pdu The PDU where the option is to be added. |
296 | | * @param number The number of the new option. |
297 | | * @param len The length of the new option. |
298 | | * @param data The data of the new option. |
299 | | * |
300 | | * @return The overall length of the option or @c 0 on failure. |
301 | | */ |
302 | | size_t coap_add_option_internal(coap_pdu_t *pdu, |
303 | | coap_option_num_t number, |
304 | | size_t len, |
305 | | const uint8_t *data); |
306 | | /** |
307 | | * Removes (first) option of given number from the @p pdu. |
308 | | * |
309 | | * @param pdu The PDU to remove the option from. |
310 | | * @param number The number of the CoAP option to remove (first only removed). |
311 | | * |
312 | | * @return @c 1 if success else @c 0 if error. |
313 | | */ |
314 | | int coap_remove_option(coap_pdu_t *pdu, coap_option_num_t number); |
315 | | |
316 | | /** |
317 | | * Inserts option of given number in the @p pdu with the appropriate data. |
318 | | * The option will be inserted in the appropriate place in the options in |
319 | | * the pdu. |
320 | | * |
321 | | * @param pdu The PDU where the option is to be inserted. |
322 | | * @param number The number of the new option. |
323 | | * @param len The length of the new option. |
324 | | * @param data The data of the new option. |
325 | | * |
326 | | * @return The overall length of the option or @c 0 on failure. |
327 | | */ |
328 | | size_t coap_insert_option(coap_pdu_t *pdu, coap_option_num_t number, |
329 | | size_t len, const uint8_t *data); |
330 | | |
331 | | /** |
332 | | * Updates existing first option of given number in the @p pdu with the new |
333 | | * data. |
334 | | * |
335 | | * @param pdu The PDU where the option is to be updated. |
336 | | * @param number The number of the option to update (first only updated). |
337 | | * @param len The length of the updated option. |
338 | | * @param data The data of the updated option. |
339 | | * |
340 | | * @return The overall length of the updated option or @c 0 on failure. |
341 | | */ |
342 | | size_t coap_update_option(coap_pdu_t *pdu, |
343 | | coap_option_num_t number, |
344 | | size_t len, |
345 | | const uint8_t *data); |
346 | | |
347 | | /** |
348 | | * Compose the protocol specific header for the specified PDU. |
349 | | * |
350 | | * @param pdu A newly composed PDU. |
351 | | * @param proto The target wire protocol. |
352 | | * |
353 | | * @return Number of header bytes prepended before pdu->token or 0 on error. |
354 | | */ |
355 | | |
356 | | size_t coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto); |
357 | | |
358 | | /** |
359 | | * Updates token in @p pdu with length @p len and @p data. |
360 | | * This function returns @c 0 on error or a value greater than zero on success. |
361 | | * |
362 | | * @param pdu The PDU where the token is to be updated. |
363 | | * @param len The length of the new token. |
364 | | * @param data The token to add. |
365 | | * |
366 | | * @return A value greater than zero on success, or @c 0 on error. |
367 | | */ |
368 | | int coap_update_token(coap_pdu_t *pdu, |
369 | | size_t len, |
370 | | const uint8_t *data); |
371 | | |
372 | | /** |
373 | | * Check whether the option is allowed to be repeated or not. |
374 | | * This function returns @c 0 if not repeatable or @c 1 if repeatable |
375 | | * |
376 | | * @param number The option number to check for repeatability. |
377 | | * |
378 | | * @return @c 0 if not repeatable or @c 1 if repeatable. |
379 | | */ |
380 | | int coap_option_check_repeatable(coap_option_num_t number); |
381 | | |
382 | | /** |
383 | | * Creates a new CoAP PDU. |
384 | | * |
385 | | * Note: This function must be called in the locked state. |
386 | | * |
387 | | * @param type The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON, |
388 | | * COAP_MESSAGE_ACK, COAP_MESSAGE_RST). |
389 | | * @param code The message code of the PDU. |
390 | | * @param session The session that will be using this PDU |
391 | | * |
392 | | * @return The skeletal PDU or @c NULL if failure. |
393 | | */ |
394 | | coap_pdu_t *coap_new_pdu_lkd(coap_pdu_type_t type, coap_pdu_code_t code, |
395 | | coap_session_t *session); |
396 | | |
397 | | /** |
398 | | * Dispose of an CoAP PDU and free off associated storage. |
399 | | * |
400 | | * Note: This function must be called in the locked state. |
401 | | * |
402 | | * Note: In general you should not call this function directly. |
403 | | * When a PDU is sent with coap_send(), coap_delete_pdu() will be called |
404 | | * automatically for you. This is not for the case for coap_send_recv() |
405 | | * where the sending and receiving PDUs need to be explicitly deleted. |
406 | | * |
407 | | * Note: If called with a reference count > 0, the reference count is |
408 | | * decremented and the PDU is not deleted. |
409 | | * |
410 | | * @param pdu The PDU for free off. |
411 | | */ |
412 | | void coap_delete_pdu_lkd(coap_pdu_t *pdu); |
413 | | |
414 | | COAP_STATIC_INLINE void |
415 | 56 | coap_pdu_release_lkd(coap_pdu_t *pdu) { |
416 | 56 | coap_delete_pdu_lkd(pdu); |
417 | 56 | } Unexecuted instantiation: oscore_decrypt_target.c:coap_pdu_release_lkd Unexecuted instantiation: coap_address.c:coap_pdu_release_lkd Unexecuted instantiation: coap_debug.c:coap_pdu_release_lkd Unexecuted instantiation: coap_encode.c:coap_pdu_release_lkd Unexecuted instantiation: coap_mem.c:coap_pdu_release_lkd Unexecuted instantiation: coap_net.c:coap_pdu_release_lkd Unexecuted instantiation: coap_netif.c:coap_pdu_release_lkd Unexecuted instantiation: coap_openssl.c:coap_pdu_release_lkd Unexecuted instantiation: coap_option.c:coap_pdu_release_lkd Unexecuted instantiation: coap_oscore.c:coap_pdu_release_lkd Unexecuted instantiation: coap_pdu.c:coap_pdu_release_lkd Unexecuted instantiation: coap_proxy.c:coap_pdu_release_lkd Unexecuted instantiation: coap_prng.c:coap_pdu_release_lkd coap_resource.c:coap_pdu_release_lkd Line | Count | Source | 415 | 56 | coap_pdu_release_lkd(coap_pdu_t *pdu) { | 416 | 56 | coap_delete_pdu_lkd(pdu); | 417 | 56 | } |
Unexecuted instantiation: coap_session.c:coap_pdu_release_lkd Unexecuted instantiation: coap_str.c:coap_pdu_release_lkd Unexecuted instantiation: coap_strm_posix.c:coap_pdu_release_lkd Unexecuted instantiation: coap_subscribe.c:coap_pdu_release_lkd Unexecuted instantiation: coap_time.c:coap_pdu_release_lkd Unexecuted instantiation: coap_uri.c:coap_pdu_release_lkd Unexecuted instantiation: coap_ws.c:coap_pdu_release_lkd Unexecuted instantiation: oscore.c:coap_pdu_release_lkd Unexecuted instantiation: oscore_cbor.c:coap_pdu_release_lkd Unexecuted instantiation: oscore_context.c:coap_pdu_release_lkd Unexecuted instantiation: oscore_cose.c:coap_pdu_release_lkd Unexecuted instantiation: oscore_crypto.c:coap_pdu_release_lkd Unexecuted instantiation: coap_async.c:coap_pdu_release_lkd Unexecuted instantiation: coap_block.c:coap_pdu_release_lkd Unexecuted instantiation: coap_cache.c:coap_pdu_release_lkd Unexecuted instantiation: coap_dgrm_posix.c:coap_pdu_release_lkd Unexecuted instantiation: coap_dtls.c:coap_pdu_release_lkd Unexecuted instantiation: coap_io.c:coap_pdu_release_lkd Unexecuted instantiation: coap_io_posix.c:coap_pdu_release_lkd Unexecuted instantiation: coap_layers.c:coap_pdu_release_lkd Unexecuted instantiation: pdu_parse_udp_target.c:coap_pdu_release_lkd Unexecuted instantiation: async_target.c:coap_pdu_release_lkd Unexecuted instantiation: block_target.c:coap_pdu_release_lkd Unexecuted instantiation: split_uri_target.c:coap_pdu_release_lkd Unexecuted instantiation: pdu_parse_tcp_target.c:coap_pdu_release_lkd Unexecuted instantiation: observe_target.c:coap_pdu_release_lkd Unexecuted instantiation: pdu_parse_ws_target.c:coap_pdu_release_lkd Unexecuted instantiation: network_message_target.c:coap_pdu_release_lkd Unexecuted instantiation: oscore_conf_parse_target.c:coap_pdu_release_lkd Unexecuted instantiation: get_asn1_tag_target.c:coap_pdu_release_lkd Unexecuted instantiation: coap_asn1.c:coap_pdu_release_lkd Unexecuted instantiation: block_check_target.c:coap_pdu_release_lkd |
418 | | |
419 | | /** |
420 | | * Duplicate an existing PDU. Specific options can be ignored and not copied |
421 | | * across. The PDU data payload is not copied across. |
422 | | * |
423 | | * Note: This function must be called in the locked state. |
424 | | * |
425 | | * @param old_pdu The PDU to duplicate |
426 | | * @param session The session that will be using this PDU. |
427 | | * @param token_length The length of the token to use in this duplicated PDU. |
428 | | * @param token The token to use in this duplicated PDU. |
429 | | * @param drop_options A list of options not to copy into the duplicated PDU. |
430 | | * If @c NULL, then all options are copied across. |
431 | | * |
432 | | * @return The duplicated PDU or @c NULL if failure. |
433 | | */ |
434 | | coap_pdu_t *coap_pdu_duplicate_lkd(const coap_pdu_t *old_pdu, |
435 | | coap_session_t *session, |
436 | | size_t token_length, |
437 | | const uint8_t *token, |
438 | | coap_opt_filter_t *drop_options); |
439 | | |
440 | | /** |
441 | | * Increment reference counter on a pdu to stop it prematurely getting freed off |
442 | | * when coap_delete_pdu() is called. |
443 | | * |
444 | | * In other words, if coap_pdu_reference_lkd() is called once, then the first call |
445 | | * to coap_delete_pdu() will decrement the reference counter, but not delete the PDU |
446 | | * and the second call to coap_delete_pdu() then actually deletes the PDU. |
447 | | * |
448 | | * Note: This function must be called in the locked state. |
449 | | * |
450 | | * @param pdu The CoAP PDU. |
451 | | * @return same as PDU |
452 | | */ |
453 | | coap_pdu_t *coap_pdu_reference_lkd(coap_pdu_t *pdu); |
454 | | |
455 | | /** |
456 | | * Increment reference counter on a const pdu to stop it prematurely getting freed |
457 | | * off when coap_delete_pdu() is called. |
458 | | * |
459 | | * In other words, if coap_const_pdu_reference_lkd() is called once, then the first |
460 | | * call to coap_delete_pdu() will decrement the reference counter, but not delete |
461 | | * the PDU and the second call to coap_delete_pdu() then actually deletes the PDU. |
462 | | * |
463 | | * Needed when const coap_pdu_t* is passed from application handlers. |
464 | | * |
465 | | * Note: This function must be called in the locked state. |
466 | | * |
467 | | * @param pdu The CoAP PDU. |
468 | | * @return non const version of PDU. |
469 | | */ |
470 | | coap_pdu_t *coap_const_pdu_reference_lkd(const coap_pdu_t *pdu); |
471 | | |
472 | | /** @} */ |
473 | | |
474 | | #ifdef __cplusplus |
475 | | } |
476 | | #endif |
477 | | |
478 | | #endif /* COAP_COAP_PDU_INTERNAL_H_ */ |