/src/libcoap/include/coap3/coap_block_internal.h
Line | Count | Source |
1 | | /* |
2 | | * coap_block_internal.h -- Structures, Enums & Functions that are not |
3 | | * exposed to application programming |
4 | | * |
5 | | * Copyright (C) 2010-2026 Olaf Bergmann <bergmann@tzi.org> |
6 | | * Copyright (C) 2021-2026 Jon Shallow <supjps-libcoap@jpshallow.com> |
7 | | * |
8 | | * SPDX-License-Identifier: BSD-2-Clause |
9 | | * |
10 | | * This file is part of the CoAP library libcoap. Please see README for terms |
11 | | * of use. |
12 | | */ |
13 | | |
14 | | /** |
15 | | * @file coap_block_internal.h |
16 | | * @brief CoAP block internal information |
17 | | */ |
18 | | |
19 | | #ifndef COAP_BLOCK_INTERNAL_H_ |
20 | | #define COAP_BLOCK_INTERNAL_H_ |
21 | | |
22 | | #ifdef __cplusplus |
23 | | extern "C" { |
24 | | #endif |
25 | | |
26 | | /** |
27 | | * @ingroup internal_api |
28 | | * @defgroup block_internal Block Transfer |
29 | | * Internal API for Block Transfer (RFC7959) |
30 | | * @{ |
31 | | */ |
32 | | |
33 | | /* |
34 | | * Use the top 20 bits of a 64 bit token for tracking current block in large transfer. |
35 | | * However, if smaller tokens are required. this would be set up to 48, leaving 16 bits |
36 | | * for unique tokens. |
37 | | */ |
38 | | #ifndef STATE_MAX_BLK_CNT_BITS |
39 | 72 | #define STATE_MAX_BLK_CNT_BITS 20 |
40 | | #endif /* STATE_MAX_BLK_CNT_BITS */ |
41 | 38 | #define STATE_TOKEN_BASE(t) ((t) & (0xffffffffffffffffULL >> STATE_MAX_BLK_CNT_BITS)) |
42 | | #define STATE_TOKEN_RETRY(t) ((uint64_t)(t) >> (64 - STATE_MAX_BLK_CNT_BITS)) |
43 | 34 | #define STATE_TOKEN_FULL(t,r) (STATE_TOKEN_BASE(t) + ((uint64_t)(r) << (64 - STATE_MAX_BLK_CNT_BITS))) |
44 | | |
45 | | #if COAP_Q_BLOCK_SUPPORT |
46 | 156 | #define COAP_BLOCK_SET_MASK (COAP_BLOCK_USE_LIBCOAP | \ |
47 | 156 | COAP_BLOCK_SINGLE_BODY | \ |
48 | 156 | COAP_BLOCK_TRY_Q_BLOCK | \ |
49 | 156 | COAP_BLOCK_USE_M_Q_BLOCK | \ |
50 | 156 | COAP_BLOCK_NO_PREEMPTIVE_RTAG | \ |
51 | 156 | COAP_BLOCK_STLESS_FETCH | \ |
52 | 156 | COAP_BLOCK_STLESS_BLOCK2 | \ |
53 | 156 | COAP_BLOCK_NOT_RANDOM_BLOCK1 | \ |
54 | 156 | COAP_BLOCK_FORCE_Q_BLOCK) |
55 | | #else /* ! COAP_Q_BLOCK_SUPPORT */ |
56 | | #define COAP_BLOCK_SET_MASK (COAP_BLOCK_USE_LIBCOAP | \ |
57 | | COAP_BLOCK_SINGLE_BODY | \ |
58 | | COAP_BLOCK_NO_PREEMPTIVE_RTAG | \ |
59 | | COAP_BLOCK_STLESS_FETCH | \ |
60 | | COAP_BLOCK_STLESS_BLOCK2 | \ |
61 | | COAP_BLOCK_NOT_RANDOM_BLOCK1) |
62 | | #endif /* ! COAP_Q_BLOCK_SUPPORT */ |
63 | | |
64 | 118 | #define COAP_BLOCK_MAX_SIZE_MASK 0x7000000 /* (svr)Mask to get the max supported block size */ |
65 | 110 | #define COAP_BLOCK_MAX_SIZE_SHIFT 24 /* (svr)Mask shift to get the max supported block size */ |
66 | 102 | #define COAP_BLOCK_MAX_SIZE_GET(a) (((a) & COAP_BLOCK_MAX_SIZE_MASK) >> COAP_BLOCK_MAX_SIZE_SHIFT) |
67 | 8 | #define COAP_BLOCK_MAX_SIZE_SET(a) (((a) << COAP_BLOCK_MAX_SIZE_SHIFT) & COAP_BLOCK_MAX_SIZE_MASK) |
68 | | |
69 | | #if COAP_Q_BLOCK_SUPPORT |
70 | | /* Internal use only and are dropped when setting block_mode */ |
71 | 237 | #define COAP_BLOCK_HAS_Q_BLOCK 0x40000000 /* Set when Q_BLOCK supported */ |
72 | 286 | #define COAP_BLOCK_PROBE_Q_BLOCK 0x80000000 /* Set when Q_BLOCK probing */ |
73 | | |
74 | | #define set_block_mode_probe_q(block_mode) \ |
75 | 0 | do { \ |
76 | 0 | block_mode |= COAP_BLOCK_PROBE_Q_BLOCK; \ |
77 | 0 | block_mode &= ~(COAP_BLOCK_TRY_Q_BLOCK | COAP_BLOCK_HAS_Q_BLOCK); \ |
78 | 0 | } while (0) |
79 | | |
80 | | #define set_block_mode_has_q(block_mode) \ |
81 | 0 | do { \ |
82 | 0 | block_mode |= COAP_BLOCK_HAS_Q_BLOCK; \ |
83 | 0 | block_mode &= ~(COAP_BLOCK_TRY_Q_BLOCK | COAP_BLOCK_PROBE_Q_BLOCK); \ |
84 | 0 | } while (0) |
85 | | |
86 | | #define set_block_mode_drop_q(block_mode) \ |
87 | 0 | do { \ |
88 | 0 | block_mode &= ~(COAP_BLOCK_TRY_Q_BLOCK |\ |
89 | 0 | COAP_BLOCK_PROBE_Q_BLOCK |\ |
90 | 0 | COAP_BLOCK_HAS_Q_BLOCK | \ |
91 | 0 | COAP_BLOCK_USE_M_Q_BLOCK | \ |
92 | 0 | COAP_BLOCK_FORCE_Q_BLOCK); \ |
93 | 0 | } while (0) |
94 | | |
95 | 0 | #define COAP_SINGLE_BLOCK_OR_Q (COAP_BLOCK_SINGLE_BODY|COAP_BLOCK_HAS_Q_BLOCK) |
96 | | #else /* ! COAP_Q_BLOCK_SUPPORT */ |
97 | | #define COAP_SINGLE_BLOCK_OR_Q (COAP_BLOCK_SINGLE_BODY) |
98 | | #endif /* ! COAP_Q_BLOCK_SUPPORT */ |
99 | | |
100 | | typedef enum { |
101 | | COAP_RECURSE_OK, |
102 | | COAP_RECURSE_NO |
103 | | } coap_recurse_t; |
104 | | |
105 | | struct coap_lg_range { |
106 | | uint32_t begin; |
107 | | uint32_t end; |
108 | | }; |
109 | | |
110 | | #ifndef COAP_RBLOCK_CNT |
111 | 1 | #define COAP_RBLOCK_CNT 6 |
112 | | #endif |
113 | | #if COAP_RBLOCK_CNT > COAP_DEFAULT_MAX_PAYLOADS -1 |
114 | | #error COAP_RBLOCK_CNT too large |
115 | | #endif |
116 | | #if COAP_RBLOCK_CNT < 2 |
117 | | #error COAP_RBLOCK_CNT too small |
118 | | #endif |
119 | | |
120 | | /** |
121 | | * Structure to keep track of received blocks |
122 | | */ |
123 | | typedef struct coap_rblock_t { |
124 | | uint32_t used; /**< Number of range blocks in use */ |
125 | | uint32_t retry; |
126 | | #if COAP_Q_BLOCK_SUPPORT |
127 | | uint32_t processing_payload_set; |
128 | | uint32_t latest_payload_set; |
129 | | #endif /* COAP_Q_BLOCK_SUPPORT */ |
130 | | struct coap_lg_range range[COAP_RBLOCK_CNT]; |
131 | | coap_tick_t last_seen; |
132 | | uint32_t total_blocks; /**< Set to block no + 1 when More bit unset */ |
133 | | } coap_rblock_t; |
134 | | |
135 | | /** |
136 | | * Structure to keep track of block1 specific information |
137 | | * (Requests) |
138 | | */ |
139 | | typedef struct coap_l_block1_t { |
140 | | coap_binary_t *app_token; /**< original PDU token */ |
141 | | uint64_t state_token; /**< state token */ |
142 | | size_t bert_size; /**< size of last BERT block */ |
143 | | uint32_t count; /**< the number of packets sent for payload */ |
144 | | coap_address_t upstream; /* Unicast IP of server if mcast client session */ |
145 | | } coap_l_block1_t; |
146 | | |
147 | | /** |
148 | | * Structure to keep track of block2 specific information |
149 | | * (Responses) |
150 | | */ |
151 | | typedef struct coap_l_block2_t { |
152 | | coap_resource_t *resource; /**< associated resource */ |
153 | | coap_string_t *query; /**< Associated query for the resource */ |
154 | | uint64_t etag; /**< ETag value */ |
155 | | coap_pdu_code_t request_method; /**< Method used to request this data */ |
156 | | uint8_t rtag_set; /**< Set if RTag is in receive PDU */ |
157 | | uint8_t rtag_length; /**< RTag length */ |
158 | | uint8_t rtag[8]; /**< RTag for block checking */ |
159 | | coap_time_t maxage_expire; /**< When this entry expires */ |
160 | | } coap_l_block2_t; |
161 | | |
162 | | typedef struct coap_lg_xmit_data_t { |
163 | | const uint8_t *data; /**< large data ptr */ |
164 | | size_t length; /**< large data length */ |
165 | | coap_get_large_data_t get_func; /**< Where to get data id needed */ |
166 | | coap_release_large_data_t release_func; /**< large data de-alloc function */ |
167 | | void *app_ptr; /**< application provided ptr for de-alloc function */ |
168 | | uint32_t ref; /**< Reference count */ |
169 | | } coap_lg_xmit_data_t; |
170 | | |
171 | | /** |
172 | | * Structure to hold large body (many blocks) transmission information |
173 | | */ |
174 | | struct coap_lg_xmit_t { |
175 | | struct coap_lg_xmit_t *next; |
176 | | uint8_t blk_size; /**< large block transmission size */ |
177 | | uint16_t option; /**< large block transmission CoAP option */ |
178 | | int last_block; /**< last acknowledged block number Block1 |
179 | | last transmitted Q-Block2 */ |
180 | | coap_lg_xmit_data_t *data_info; /**< Pointer to large data information */ |
181 | | union { |
182 | | coap_l_block1_t b1; |
183 | | coap_l_block2_t b2; |
184 | | } b; |
185 | | coap_pdu_t *sent_pdu; /**< The sent pdu with all the data */ |
186 | | coap_tick_t last_payload; /**< Last time MAX_PAYLOAD was sent or 0 */ |
187 | | coap_tick_t last_sent; /**< Last time any data sent */ |
188 | | coap_tick_t last_all_sent; /**< Last time all data sent or 0 */ |
189 | | coap_tick_t last_obs; /**< Last time used (Observe tracking) or 0 */ |
190 | | #if COAP_Q_BLOCK_SUPPORT |
191 | | coap_tick_t non_timeout_random_ticks; /** Used for Q-Block */ |
192 | | coap_rblock_t send_blocks; /**< list of blocks still to send */ |
193 | | #endif /* COAP_Q_BLOCK_SUPPORT */ |
194 | | uint32_t ref; /**< Reference count */ |
195 | | }; |
196 | | |
197 | | #if COAP_CLIENT_SUPPORT |
198 | | /** |
199 | | * Structure to hold large body (many blocks) client receive information |
200 | | */ |
201 | | struct coap_lg_crcv_t { |
202 | | struct coap_lg_crcv_t *next; |
203 | | uint8_t observe[3]; /**< Observe data (if observe_set) (only 24 bits) */ |
204 | | uint8_t observe_length;/**< Length of observe data */ |
205 | | uint8_t observe_set; /**< Set if this is an observe receive PDU */ |
206 | | uint8_t szx; /**< size of individual blocks */ |
207 | | uint8_t etag_set; /**< Set if ETag is in receive PDU */ |
208 | | uint8_t etag_length; /**< ETag length */ |
209 | | uint8_t etag[8]; /**< ETag for block checking */ |
210 | | uint16_t content_format; /**< Content format for the set of blocks */ |
211 | | uint8_t last_type; /**< Last request type (CON/NON) */ |
212 | | uint8_t initial; /**< If set, has not been used yet */ |
213 | | uint16_t block_option; /**< Block option in use */ |
214 | | uint16_t retry_counter; /**< Retry counter (part of state token) */ |
215 | | size_t total_len; /**< Length as indicated by SIZE2 option */ |
216 | | coap_binary_t *body_data; /**< Used for re-assembling entire body */ |
217 | | coap_binary_t *app_token; /**< app requesting PDU token */ |
218 | | coap_bin_const_t **obs_token; /**< Tokens used in setting up Observe |
219 | | (to handle large FETCH) */ |
220 | | size_t obs_token_cnt; /**< number of tokens used to set up Observe */ |
221 | | uint16_t o_block_option; /**< Block CoAP option used when initiating Observe */ |
222 | | uint8_t o_blk_size; /**< Block size used when initiating Observe */ |
223 | | uint8_t total_len_set; /**< Set if total_len is where the last block ends */ |
224 | | uint32_t ref; /**< Reference count */ |
225 | | uint64_t state_token; /**< state token */ |
226 | | coap_pdu_t *sent_pdu; /**< The sent pdu with all the data */ |
227 | | coap_rblock_t rec_blocks; /**< list of received blocks */ |
228 | | coap_tick_t last_used; /**< Last time all data sent or 0 */ |
229 | | coap_address_t upstream; /**< Unicast IP of server if mcast client session */ |
230 | | coap_lg_xmit_data_t *obs_data; /**< lg_xmit data info if large observe request */ |
231 | | }; |
232 | | #endif /* COAP_CLIENT_SUPPORT */ |
233 | | |
234 | | #if COAP_SERVER_SUPPORT |
235 | | /** |
236 | | * Structure to hold large body (many blocks) server receive information |
237 | | */ |
238 | | struct coap_lg_srcv_t { |
239 | | struct coap_lg_srcv_t *next; |
240 | | uint8_t observe[3]; /**< Observe data (if set) (only 24 bits) */ |
241 | | uint8_t observe_length;/**< Length of observe data */ |
242 | | uint8_t observe_set; /**< Set if this is an observe receive PDU */ |
243 | | uint8_t no_more_seen; /**< Set if block with more not set seen */ |
244 | | uint8_t rtag_set; /**< Set if RTag is in receive PDU */ |
245 | | uint8_t rtag_length; /**< RTag length */ |
246 | | uint8_t rtag[8]; /**< RTag for block checking */ |
247 | | uint16_t content_format; /**< Content format for the set of blocks */ |
248 | | uint8_t last_type; /**< Last request type (CON/NON) */ |
249 | | uint8_t szx; /**< size of individual blocks */ |
250 | | uint16_t block_option; /**< Block option in use */ |
251 | | uint8_t dont_timeout; /**< Set if app handler in use */ |
252 | | uint8_t total_len_set; /**< Set if total_len is where the last block ends */ |
253 | | coap_tick_t last_used; /**< Last time data sent or 0 */ |
254 | | size_t total_len; /**< Length as indicated by SIZE1 option */ |
255 | | coap_binary_t *body_data; /**< Used for re-assembling entire body */ |
256 | | coap_resource_t *resource; /**< associated resource */ |
257 | | coap_rblock_t rec_blocks; /** < list of received blocks */ |
258 | | coap_bin_const_t *last_token; /**< last used token */ |
259 | | uint32_t ref; /**< Reference count */ |
260 | | #if COAP_Q_BLOCK_SUPPORT |
261 | | int32_t r_m_payload_set; /**< Last payload set when requested missing blocks */ |
262 | | #endif /* COAP_Q_BLOCK_SUPPORT */ |
263 | | #if COAP_OSCORE_SUPPORT |
264 | | oscore_recipient_ctx_t *recipient_ctx; /**< OSCORE recipient context |
265 | | for lg_srcv_t */ |
266 | | #endif /* COAP_OSCORE_SUPPORT */ |
267 | | coap_cache_key_t *cache_key; /**< Cache key of (Q-)Block PDU */ |
268 | | }; |
269 | | #endif /* COAP_SERVER_SUPPORT */ |
270 | | |
271 | | #if COAP_Q_BLOCK_SUPPORT |
272 | | typedef enum { |
273 | | COAP_SEND_SKIP_PDU, |
274 | | COAP_SEND_INC_PDU, |
275 | | COAP_SEND_MISSING, |
276 | | } coap_send_pdu_t; |
277 | | #endif /* COAP_Q_BLOCK_SUPPORT */ |
278 | | |
279 | | #if COAP_CLIENT_SUPPORT |
280 | | coap_lg_crcv_t *coap_block_new_lg_crcv(coap_session_t *session, |
281 | | coap_pdu_t *pdu, |
282 | | coap_lg_xmit_t *lg_xmit); |
283 | | |
284 | | /** |
285 | | * Remove a lg_crcv. |
286 | | * If lg_crcv is being referenced, then the reference counter is decremented |
287 | | * but the lg_crcv data still exists until a coap_lg_crcv_release_lkd() is |
288 | | * invoked. |
289 | | * |
290 | | * Note: This function must be called in the locked state. |
291 | | * |
292 | | * @param session The CoAP session. |
293 | | * @param lg_crcv The lg_crcv being used. |
294 | | */ |
295 | | void coap_block_delete_lg_crcv(coap_session_t *session, |
296 | | coap_lg_crcv_t *lg_crcv); |
297 | | |
298 | | /** |
299 | | * Decrement reference counter on a lg_crcv. |
300 | | * Note that the lg_crcv storage may be deleted as a result and should not be |
301 | | * used after this call. |
302 | | * |
303 | | * Note: This function must be called in the locked state. |
304 | | * |
305 | | * @param session The CoAP session. |
306 | | * @param lg_crcv The lg_crcv being used. |
307 | | */ |
308 | | COAP_STATIC_INLINE void |
309 | 0 | coap_lg_crcv_release_lkd(coap_session_t *session,coap_lg_crcv_t *lg_crcv) { |
310 | 0 | coap_block_delete_lg_crcv(session, lg_crcv); |
311 | 0 | return; |
312 | 0 | } Unexecuted instantiation: oscore_decrypt_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_address.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_debug.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_encode.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_mem.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_net.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_netif.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_openssl.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_option.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_oscore.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_pdu.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_proxy.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_prng.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_resource.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_session.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_str.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_strm_posix.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_subscribe.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_time.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_uri.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_ws.c:coap_lg_crcv_release_lkd Unexecuted instantiation: oscore.c:coap_lg_crcv_release_lkd Unexecuted instantiation: oscore_cbor.c:coap_lg_crcv_release_lkd Unexecuted instantiation: oscore_context.c:coap_lg_crcv_release_lkd Unexecuted instantiation: oscore_cose.c:coap_lg_crcv_release_lkd Unexecuted instantiation: oscore_crypto.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_async.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_block.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_cache.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_dgrm_posix.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_dtls.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_io.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_io_posix.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_layers.c:coap_lg_crcv_release_lkd Unexecuted instantiation: pdu_parse_udp_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: dtls_define_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: uri_extended_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: ws_frame_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_event.c:coap_lg_crcv_release_lkd Unexecuted instantiation: async_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_fuzz_helper.c:coap_lg_crcv_release_lkd Unexecuted instantiation: block_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: split_uri_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: pdu_parse_tcp_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: persist_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: oscore_cbor_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: observe_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: pdu_parse_ws_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: cache_key_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: proxy_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: network_message_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: oscore_conf_parse_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: get_asn1_tag_target.c:coap_lg_crcv_release_lkd Unexecuted instantiation: coap_asn1.c:coap_lg_crcv_release_lkd Unexecuted instantiation: block_check_target.c:coap_lg_crcv_release_lkd |
313 | | |
314 | | /** |
315 | | * Increment reference counter on a lg_crcv. |
316 | | * |
317 | | * Note: This function must be called in the locked state. |
318 | | * |
319 | | * @param lg_crcv The lg_crcv being used. |
320 | | */ |
321 | | COAP_STATIC_INLINE void |
322 | 0 | coap_lg_crcv_reference_lkd(coap_lg_crcv_t *lg_crcv) { |
323 | 0 | lg_crcv->ref++; |
324 | 0 | return; |
325 | 0 | } Unexecuted instantiation: oscore_decrypt_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_address.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_debug.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_encode.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_mem.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_net.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_netif.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_openssl.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_option.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_oscore.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_pdu.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_proxy.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_prng.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_resource.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_session.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_str.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_strm_posix.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_subscribe.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_time.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_uri.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_ws.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: oscore.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: oscore_cbor.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: oscore_context.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: oscore_cose.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: oscore_crypto.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_async.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_block.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_cache.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_dgrm_posix.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_dtls.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_io.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_io_posix.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_layers.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: pdu_parse_udp_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: dtls_define_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: uri_extended_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: ws_frame_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_event.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: async_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_fuzz_helper.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: block_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: split_uri_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: pdu_parse_tcp_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: persist_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: oscore_cbor_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: observe_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: pdu_parse_ws_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: cache_key_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: proxy_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: network_message_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: oscore_conf_parse_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: get_asn1_tag_target.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: coap_asn1.c:coap_lg_crcv_reference_lkd Unexecuted instantiation: block_check_target.c:coap_lg_crcv_reference_lkd |
326 | | |
327 | | int coap_block_check_lg_crcv_timeouts(coap_session_t *session, |
328 | | coap_tick_t now, |
329 | | coap_tick_t *tim_rem); |
330 | | |
331 | | #if COAP_Q_BLOCK_SUPPORT |
332 | | coap_mid_t coap_send_q_block1(coap_session_t *session, |
333 | | coap_block_b_t block, |
334 | | coap_pdu_t *request, |
335 | | coap_send_pdu_t send_request); |
336 | | |
337 | | /** |
338 | | * Check if the next Q-Block1 needs to be sent, else get the next timeout value. |
339 | | * |
340 | | * @param session The Session to check. |
341 | | * @param now The current time in ticks. |
342 | | * @param tim_rem Updated with the remaining timeout time if return is @c 1. |
343 | | * |
344 | | * @return @c 1 if @p tim_rem is set, else @c 0 if there is no timeout. |
345 | | */ |
346 | | int coap_block_check_q_block1_xmit(coap_session_t *session, |
347 | | coap_tick_t now, coap_tick_t *tim_rem); |
348 | | |
349 | | coap_mid_t coap_block_test_q_block(coap_session_t *session, coap_pdu_t *actual); |
350 | | #endif /* COAP_Q_BLOCK_SUPPORT */ |
351 | | |
352 | | #endif /* COAP_CLIENT_SUPPORT */ |
353 | | |
354 | | #if COAP_Q_BLOCK_SUPPORT |
355 | | /** |
356 | | * Send the next set of Q-blocks - one if CON, else to the next appropriate MAX_PAYLOAD |
357 | | * boundary. Handles if blocks are reported as not being received. |
358 | | * |
359 | | * If rate limiting when called returns COAP_INVALID_MID. |
360 | | * |
361 | | * @param session The current session. |
362 | | * @param lg_xmit Contains information about the list of blocks to send. |
363 | | * @param block The first block to send using @p pdu template. |
364 | | * @param pdu The PDU to model the blocks on. @p pdu is always released |
365 | | * if send_pdu == COAP_SEND_INC_PDU |
366 | | * @param send_pdu Whether @p pdu should be sent first or just used as a PDU model. |
367 | | * |
368 | | * @return COAP_INVALID_MID if transmission error, else the last transmitted block mid. |
369 | | */ |
370 | | coap_mid_t coap_send_q_blocks(coap_session_t *session, |
371 | | coap_lg_xmit_t *lg_xmit, |
372 | | coap_block_b_t block, |
373 | | coap_pdu_t *pdu, |
374 | | coap_send_pdu_t send_pdu); |
375 | | #endif /* COAP_Q_BLOCK_SUPPORT */ |
376 | | |
377 | | #if COAP_SERVER_SUPPORT |
378 | | /** |
379 | | * Remove a lg_srcv. |
380 | | * If lg_srcv is being referenced, then the reference counter is decremented |
381 | | * but the lg_srcv data still exists until a coap_lg_srcv_release_lkd() is |
382 | | * invoked. |
383 | | * |
384 | | * Note: This function must be called in the locked state. |
385 | | * |
386 | | * @param session The CoAP session. |
387 | | * @param lg_srcv The lg_srcv being used. |
388 | | */ |
389 | | void coap_block_delete_lg_srcv(coap_session_t *session, |
390 | | coap_lg_srcv_t *lg_srcv); |
391 | | |
392 | | /** |
393 | | * Decrement reference counter on a lg_srcv. |
394 | | * Note that the lg_srcv storage may be deleted as a result and should not be |
395 | | * used after this call. |
396 | | * |
397 | | * Note: This function must be called in the locked state. |
398 | | * |
399 | | * @param session The CoAP session. |
400 | | * @param lg_srcv The lg_srcv being used. |
401 | | */ |
402 | | COAP_STATIC_INLINE void |
403 | 2 | coap_lg_srcv_release_lkd(coap_session_t *session,coap_lg_srcv_t *lg_srcv) { |
404 | 2 | coap_block_delete_lg_srcv(session, lg_srcv); |
405 | 2 | return; |
406 | 2 | } Unexecuted instantiation: oscore_decrypt_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_address.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_debug.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_encode.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_mem.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_net.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_netif.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_openssl.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_option.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_oscore.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_pdu.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_proxy.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_prng.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_resource.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_session.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_str.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_strm_posix.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_subscribe.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_time.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_uri.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_ws.c:coap_lg_srcv_release_lkd Unexecuted instantiation: oscore.c:coap_lg_srcv_release_lkd Unexecuted instantiation: oscore_cbor.c:coap_lg_srcv_release_lkd Unexecuted instantiation: oscore_context.c:coap_lg_srcv_release_lkd Unexecuted instantiation: oscore_cose.c:coap_lg_srcv_release_lkd Unexecuted instantiation: oscore_crypto.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_async.c:coap_lg_srcv_release_lkd coap_block.c:coap_lg_srcv_release_lkd Line | Count | Source | 403 | 2 | coap_lg_srcv_release_lkd(coap_session_t *session,coap_lg_srcv_t *lg_srcv) { | 404 | 2 | coap_block_delete_lg_srcv(session, lg_srcv); | 405 | 2 | return; | 406 | 2 | } |
Unexecuted instantiation: coap_cache.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_dgrm_posix.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_dtls.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_io.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_io_posix.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_layers.c:coap_lg_srcv_release_lkd Unexecuted instantiation: pdu_parse_udp_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: dtls_define_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: uri_extended_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: ws_frame_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_event.c:coap_lg_srcv_release_lkd Unexecuted instantiation: async_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_fuzz_helper.c:coap_lg_srcv_release_lkd Unexecuted instantiation: block_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: split_uri_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: pdu_parse_tcp_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: persist_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: oscore_cbor_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: observe_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: pdu_parse_ws_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: cache_key_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: proxy_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: network_message_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: oscore_conf_parse_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: get_asn1_tag_target.c:coap_lg_srcv_release_lkd Unexecuted instantiation: coap_asn1.c:coap_lg_srcv_release_lkd Unexecuted instantiation: block_check_target.c:coap_lg_srcv_release_lkd |
407 | | |
408 | | /** |
409 | | * Increment reference counter on a lg_srcv. |
410 | | * |
411 | | * Note: This function must be called in the locked state. |
412 | | * |
413 | | * @param lg_srcv The lg_srcv being used. |
414 | | */ |
415 | | COAP_STATIC_INLINE void |
416 | 2 | coap_lg_srcv_reference_lkd(coap_lg_srcv_t *lg_srcv) { |
417 | 2 | lg_srcv->ref++; |
418 | 2 | return; |
419 | 2 | } Unexecuted instantiation: oscore_decrypt_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_address.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_debug.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_encode.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_mem.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_net.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_netif.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_openssl.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_option.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_oscore.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_pdu.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_proxy.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_prng.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_resource.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_session.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_str.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_strm_posix.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_subscribe.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_time.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_uri.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_ws.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: oscore.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: oscore_cbor.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: oscore_context.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: oscore_cose.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: oscore_crypto.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_async.c:coap_lg_srcv_reference_lkd coap_block.c:coap_lg_srcv_reference_lkd Line | Count | Source | 416 | 2 | coap_lg_srcv_reference_lkd(coap_lg_srcv_t *lg_srcv) { | 417 | 2 | lg_srcv->ref++; | 418 | 2 | return; | 419 | 2 | } |
Unexecuted instantiation: coap_cache.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_dgrm_posix.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_dtls.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_io.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_io_posix.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_layers.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: pdu_parse_udp_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: dtls_define_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: uri_extended_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: ws_frame_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_event.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: async_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_fuzz_helper.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: block_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: split_uri_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: pdu_parse_tcp_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: persist_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: oscore_cbor_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: observe_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: pdu_parse_ws_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: cache_key_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: proxy_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: network_message_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: oscore_conf_parse_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: get_asn1_tag_target.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: coap_asn1.c:coap_lg_srcv_reference_lkd Unexecuted instantiation: block_check_target.c:coap_lg_srcv_reference_lkd |
420 | | |
421 | | int coap_block_check_lg_srcv_timeouts(coap_session_t *session, |
422 | | coap_tick_t now, |
423 | | coap_tick_t *tim_rem); |
424 | | |
425 | | #if COAP_Q_BLOCK_SUPPORT |
426 | | /** |
427 | | * Check if the next Q-Block2 needs to be sent, else get the next timeout value. |
428 | | * |
429 | | * @param session The Session to check. |
430 | | * @param now The current time in ticks. |
431 | | * @param tim_rem Updated with the remaining timeout time if return is @c 1. |
432 | | * |
433 | | * @return @c 1 if @p tim_rem is set, else @c 0 if there is no timeout. |
434 | | */ |
435 | | int coap_block_check_q_block2_xmit(coap_session_t *session, |
436 | | coap_tick_t now, coap_tick_t *tim_rem); |
437 | | |
438 | | coap_mid_t coap_send_q_block2(coap_session_t *session, |
439 | | coap_resource_t *resource, |
440 | | const coap_string_t *query, |
441 | | coap_pdu_code_t request_method, |
442 | | coap_block_b_t block, |
443 | | coap_pdu_t *response, |
444 | | coap_send_pdu_t send_response); |
445 | | #endif /* COAP_Q_BLOCK_SUPPORT */ |
446 | | |
447 | | int coap_handle_request_send_block(coap_session_t *session, |
448 | | coap_pdu_t *pdu, |
449 | | coap_pdu_t *response, |
450 | | coap_resource_t *resource, |
451 | | coap_string_t *query); |
452 | | |
453 | | /** |
454 | | * Handle the next incoming PUT/POST PDU - if (Q-)Block1 option, handle accordingly. |
455 | | * |
456 | | * @param context The context. |
457 | | * @param session The incoming session. |
458 | | * @param pdu The incoming PDU. |
459 | | * @param response The PDU set up for the response. |
460 | | * @param resource The matching resource (could be unknown / proxy). |
461 | | * @param observe The Observe option in the incoming PDU (if any). |
462 | | * @param added_block Set to 1 if block option added to response. |
463 | | * @param free_lg_srcv Contains the lg_srcv_t to release if set. |
464 | | * |
465 | | * @return @c 0 to invoke application handler, else @c 1 to just send response. |
466 | | */ |
467 | | int coap_handle_request_put_block(coap_context_t *context, |
468 | | coap_session_t *session, |
469 | | coap_pdu_t *pdu, |
470 | | coap_pdu_t *response, |
471 | | coap_resource_t *resource, |
472 | | coap_opt_t *observe, |
473 | | int *added_block, |
474 | | coap_lg_srcv_t **free_lg_srcv); |
475 | | |
476 | | coap_lg_xmit_t *coap_find_lg_xmit_response(const coap_session_t *session, |
477 | | const coap_pdu_t *request, |
478 | | const coap_resource_t *resource, |
479 | | const coap_string_t *query); |
480 | | |
481 | | /** |
482 | | * Associates given data with the @p response pdu that is passed as fourth |
483 | | * parameter. |
484 | | * |
485 | | * This function will fail if data has already been added to the @p pdu. |
486 | | * |
487 | | * If all the data can be transmitted in a single PDU, this is functionally |
488 | | * the same as coap_add_data() except @p release_func (if not NULL) will get |
489 | | * invoked after data transmission. The Content-Format, Max-Age and ETag |
490 | | * options may be added in as appropriate. |
491 | | * |
492 | | * Used by a server request handler to create the response. |
493 | | * |
494 | | * If the data spans multiple PDUs, then the data will get transmitted using |
495 | | * (Q-)Block2 (response) option with the addition of the Size2 and ETag |
496 | | * options. The underlying library will handle the transmission of the |
497 | | * individual blocks. Once the body of data has been transmitted (or a |
498 | | * failure occurred), then @p release_func (if not NULL) will get called so the |
499 | | * application can de-allocate the @p data based on @p app_data. It is the |
500 | | * responsibility of the application not to change the contents of @p data |
501 | | * until the data transfer has completed. |
502 | | * |
503 | | * There is no need for the application to include the (Q-)Block2 option in the |
504 | | * @p pdu. |
505 | | * |
506 | | * coap_add_data_large_response_lkd() (or the alternative coap_add_data_large_*() |
507 | | * functions) must be called only once per PDU and must be the last PDU update |
508 | | * before returning from the request handler function. |
509 | | * |
510 | | * Note: COAP_BLOCK_USE_LIBCOAP must be set by coap_context_set_block_mode() |
511 | | * for libcoap to work correctly when using this function. |
512 | | * |
513 | | * Note: This function must be called in the locked state. |
514 | | * |
515 | | * @param resource The resource the data is associated with. |
516 | | * @param session The coap session. |
517 | | * @param request The requesting pdu. |
518 | | * @param response The response pdu. |
519 | | * @param query The query taken from the (original) requesting pdu. |
520 | | * @param media_type The content format of the data. |
521 | | * @param maxage The maximum life of the data. If @c -1, then there |
522 | | * is no maxage. |
523 | | * @param etag ETag to use if not 0. |
524 | | * @param length The total length of the data. |
525 | | * @param data The entire data block to transmit. |
526 | | * @param release_func The function to call to de-allocate @p data or NULL if |
527 | | * the function is not required. |
528 | | * @param app_ptr A Pointer that the application can provide for when |
529 | | * release_func() is called. |
530 | | * |
531 | | * @return @c 1 if addition is successful, else @c 0. |
532 | | */ |
533 | | int coap_add_data_large_response_lkd(coap_resource_t *resource, |
534 | | coap_session_t *session, |
535 | | const coap_pdu_t *request, |
536 | | coap_pdu_t *response, |
537 | | const coap_string_t *query, |
538 | | uint16_t media_type, |
539 | | int maxage, |
540 | | uint64_t etag, |
541 | | size_t length, |
542 | | const uint8_t *data, |
543 | | coap_release_large_data_t release_func, |
544 | | void *app_ptr); |
545 | | |
546 | | #endif /* COAP_SERVER_SUPPORT */ |
547 | | |
548 | | #if COAP_CLIENT_SUPPORT |
549 | | int coap_handle_response_send_block(coap_session_t *session, coap_pdu_t *sent, |
550 | | coap_pdu_t *rcvd); |
551 | | |
552 | | int coap_handle_response_get_block(coap_context_t *context, |
553 | | coap_session_t *session, |
554 | | coap_pdu_t *sent, |
555 | | coap_pdu_t *rcvd, |
556 | | coap_recurse_t recursive); |
557 | | |
558 | | coap_mid_t coap_retransmit_oscore_pdu(coap_session_t *session, |
559 | | coap_pdu_t *pdu, |
560 | | coap_opt_t *echo); |
561 | | |
562 | | /** |
563 | | * Find the current lg_crcv for the session that matches the pdu. |
564 | | * If base lg_xmit is a mcast send, then create a secondorary lg_crcv. |
565 | | * |
566 | | * @param session The current session. |
567 | | * @param pdu The pdu that contains the appropriate token. |
568 | | * |
569 | | * @return The found lg_crcv or NULL. |
570 | | */ |
571 | | coap_lg_crcv_t *coap_find_lg_crcv(coap_session_t *session, coap_pdu_t *pdu); |
572 | | |
573 | | #endif /* COAP_CLIENT_SUPPORT */ |
574 | | |
575 | | /** |
576 | | * Find the current lg_xmit for the session that matches the pdu. |
577 | | * If client and base lg_xmit is a mcast send, then create a secondorary lg_xmit. |
578 | | * |
579 | | * @param session The current session. |
580 | | * @param pdu The pdu that contains the appropriate token. |
581 | | * |
582 | | * @return The found lg_xmit or NULL. |
583 | | */ |
584 | | coap_lg_xmit_t *coap_find_lg_xmit(coap_session_t *session, coap_pdu_t *pdu); |
585 | | |
586 | | /** |
587 | | * Remove a lg_xmit. |
588 | | * If lg_xmit is being referenced, then the reference counter is decremented |
589 | | * but the lg_xmit data still exists until a coap_lg_xmit_release_lkd() is |
590 | | * invoked. |
591 | | * |
592 | | * Note: This function must be called in the locked state. |
593 | | * |
594 | | * @param session The CoAP session. |
595 | | * @param lg_xmit The lg_xmit being used. |
596 | | */ |
597 | | void coap_block_delete_lg_xmit(coap_session_t *session, |
598 | | coap_lg_xmit_t *lg_xmit); |
599 | | |
600 | | /** |
601 | | * Decrement reference counter on a lg_xmit. |
602 | | * Note that the lg_xmit storage may be deleted as a result and should not be |
603 | | * used after this call. |
604 | | * |
605 | | * Note: This function must be called in the locked state. |
606 | | * |
607 | | * @param session The CoAP session. |
608 | | * @param lg_xmit The lg_xmit being used. |
609 | | */ |
610 | | COAP_STATIC_INLINE void |
611 | 0 | coap_lg_xmit_release_lkd(coap_session_t *session,coap_lg_xmit_t *lg_xmit) { |
612 | 0 | coap_block_delete_lg_xmit(session, lg_xmit); |
613 | 0 | return; |
614 | 0 | } Unexecuted instantiation: oscore_decrypt_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_address.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_debug.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_encode.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_mem.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_net.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_netif.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_openssl.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_option.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_oscore.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_pdu.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_proxy.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_prng.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_resource.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_session.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_str.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_strm_posix.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_subscribe.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_time.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_uri.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_ws.c:coap_lg_xmit_release_lkd Unexecuted instantiation: oscore.c:coap_lg_xmit_release_lkd Unexecuted instantiation: oscore_cbor.c:coap_lg_xmit_release_lkd Unexecuted instantiation: oscore_context.c:coap_lg_xmit_release_lkd Unexecuted instantiation: oscore_cose.c:coap_lg_xmit_release_lkd Unexecuted instantiation: oscore_crypto.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_async.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_block.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_cache.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_dgrm_posix.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_dtls.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_io.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_io_posix.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_layers.c:coap_lg_xmit_release_lkd Unexecuted instantiation: pdu_parse_udp_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: dtls_define_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: uri_extended_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: ws_frame_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_event.c:coap_lg_xmit_release_lkd Unexecuted instantiation: async_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_fuzz_helper.c:coap_lg_xmit_release_lkd Unexecuted instantiation: block_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: split_uri_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: pdu_parse_tcp_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: persist_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: oscore_cbor_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: observe_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: pdu_parse_ws_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: cache_key_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: proxy_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: network_message_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: oscore_conf_parse_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: get_asn1_tag_target.c:coap_lg_xmit_release_lkd Unexecuted instantiation: coap_asn1.c:coap_lg_xmit_release_lkd Unexecuted instantiation: block_check_target.c:coap_lg_xmit_release_lkd |
615 | | |
616 | | /** |
617 | | * Increment reference counter on a lg_xmit. |
618 | | * |
619 | | * Note: This function must be called in the locked state. |
620 | | * |
621 | | * @param lg_xmit The lg_xmit being used. |
622 | | */ |
623 | | COAP_STATIC_INLINE void |
624 | 0 | coap_lg_xmit_reference_lkd(coap_lg_xmit_t *lg_xmit) { |
625 | 0 | lg_xmit->ref++; |
626 | 0 | return; |
627 | 0 | } Unexecuted instantiation: oscore_decrypt_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_address.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_debug.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_encode.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_mem.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_net.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_netif.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_openssl.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_option.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_oscore.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_pdu.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_proxy.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_prng.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_resource.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_session.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_str.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_strm_posix.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_subscribe.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_time.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_uri.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_ws.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: oscore.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: oscore_cbor.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: oscore_context.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: oscore_cose.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: oscore_crypto.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_async.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_block.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_cache.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_dgrm_posix.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_dtls.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_io.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_io_posix.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_layers.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: pdu_parse_udp_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: dtls_define_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: uri_extended_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: ws_frame_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_event.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: async_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_fuzz_helper.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: block_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: split_uri_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: pdu_parse_tcp_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: persist_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: oscore_cbor_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: observe_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: pdu_parse_ws_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: cache_key_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: proxy_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: network_message_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: oscore_conf_parse_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: get_asn1_tag_target.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: coap_asn1.c:coap_lg_xmit_reference_lkd Unexecuted instantiation: block_check_target.c:coap_lg_xmit_reference_lkd |
628 | | |
629 | | int coap_block_check_lg_xmit_timeouts(coap_session_t *session, |
630 | | coap_tick_t now, |
631 | | coap_tick_t *tim_rem); |
632 | | |
633 | | #if COAP_Q_BLOCK_SUPPORT |
634 | | int coap_block_drop_resp_q_block_xmit(coap_session_t *session, |
635 | | coap_lg_xmit_t *lg_xmit); |
636 | | |
637 | | int coap_block_drop_resp_q_block2_crcv(coap_session_t *session, |
638 | | coap_lg_crcv_t *lg_crcv, |
639 | | coap_pdu_t *sent); |
640 | | #endif /* COAP_Q_BLOCK_SUPPORT */ |
641 | | |
642 | | /** |
643 | | * The function checks that the code in a newly formed lg_xmit created by |
644 | | * coap_add_data_large_response_lkd() is updated. |
645 | | * |
646 | | * @param session The session. |
647 | | * @param request The request PDU to to check. |
648 | | * @param response The response PDU to to update with response->code. |
649 | | * @param resource The requested resource. |
650 | | * @param query The requested query. |
651 | | */ |
652 | | void coap_check_code_lg_xmit(const coap_session_t *session, |
653 | | const coap_pdu_t *request, |
654 | | coap_pdu_t *response, |
655 | | const coap_resource_t *resource, |
656 | | const coap_string_t *query); |
657 | | |
658 | | /** |
659 | | * Set the context level CoAP block handling bits for handling RFC7959. |
660 | | * These bits flow down to a session when a session is created and if the peer |
661 | | * does not support something, an appropriate bit may get disabled in the |
662 | | * session block_mode. |
663 | | * The session block_mode then flows down into coap_crcv_t or coap_srcv_t where |
664 | | * again an appropriate bit may get disabled. |
665 | | * |
666 | | * Note: This function must be called before the session is set up. |
667 | | * |
668 | | * Note: COAP_BLOCK_USE_LIBCOAP must be set if libcoap is to do all the |
669 | | * block tracking and requesting, otherwise the application will have to do |
670 | | * all of this work (the default if coap_context_set_block_mode() is not |
671 | | * called). |
672 | | * |
673 | | * @param context The coap_context_t object. |
674 | | * @param block_mode Zero or more COAP_BLOCK_ or'd options |
675 | | */ |
676 | | void coap_context_set_block_mode_lkd(coap_context_t *context, |
677 | | uint32_t block_mode); |
678 | | |
679 | | /** |
680 | | * Set the context level maximum block size that the server supports when sending |
681 | | * or receiving packets with Block1 or Block2 options. |
682 | | * This maximum block size flows down to a session when a session is created. |
683 | | * |
684 | | * Note: This function must be called before the session is set up. |
685 | | * |
686 | | * Note: COAP_BLOCK_USE_LIBCOAP must be set using coap_context_set_block_mode() |
687 | | * if libcoap is to do this work. |
688 | | * |
689 | | * @param context The coap_context_t object. |
690 | | * @param max_block_size The maximum block size a server supports. Can be 0 |
691 | | * (reset), or must be 16, 32, 64, 128, 256, 512 or 1024. |
692 | | */ |
693 | | int coap_context_set_max_block_size_lkd(coap_context_t *context, size_t max_block_size); |
694 | | |
695 | | /** |
696 | | * Re-assemble payloads into a body. |
697 | | * |
698 | | * Note: This function must be called in the locked state. |
699 | | * |
700 | | * @param body_data The pointer to the data for the body holding the |
701 | | * representation so far or NULL if the first time. |
702 | | * @param length The length of @p data. |
703 | | * @param data The payload data to update the body with. |
704 | | * @param offset The offset of the @p data into the body. |
705 | | * @param total The estimated total size of the body. |
706 | | * |
707 | | * @return The current representation of the body or @c NULL if error. |
708 | | * If NULL, @p body_data will have been de-allocated. |
709 | | */ |
710 | | coap_binary_t *coap_block_build_body_lkd(coap_binary_t *body_data, size_t length, |
711 | | const uint8_t *data, size_t offset, size_t total); |
712 | | |
713 | | #if COAP_CLIENT_SUPPORT |
714 | | /** |
715 | | * Associates given data with the @p pdu that is passed as second parameter. |
716 | | * |
717 | | * This function will fail if data has already been added to the @p pdu. |
718 | | * |
719 | | * If all the data can be transmitted in a single PDU, this is functionally |
720 | | * the same as coap_add_data_lkd() except @p release_func (if not NULL) will get |
721 | | * invoked after data transmission. |
722 | | * |
723 | | * Used for a client request. |
724 | | * |
725 | | * If the data spans multiple PDUs, then the data will get transmitted using |
726 | | * (Q-)Block1 option with the addition of the Size1 and Request-Tag options. |
727 | | * The underlying library will handle the transmission of the individual blocks. |
728 | | * Once the body of data has been transmitted (or a failure occurred), then |
729 | | * @p release_func (if not NULL) will get called so the application can |
730 | | * de-allocate the @p data based on @p app_data. It is the responsibility of |
731 | | * the application not to change the contents of @p data until the data |
732 | | * transfer has completed. |
733 | | * |
734 | | * There is no need for the application to include the (Q-)Block1 option in the |
735 | | * @p pdu. |
736 | | * |
737 | | * coap_add_data_large_request_lkd() (or the alternative coap_add_data_large_*() |
738 | | * functions) must be called only once per PDU and must be the last PDU update |
739 | | * before the PDU is transmitted. The (potentially) initial data will get |
740 | | * transmitted when coap_send() is invoked. |
741 | | * |
742 | | * Note: COAP_BLOCK_USE_LIBCOAP must be set by coap_context_set_block_mode() |
743 | | * for libcoap to work correctly when using this function. |
744 | | * |
745 | | * Note: This function must be called in the locked state. |
746 | | * |
747 | | * @param session The session to associate the data with. |
748 | | * @param pdu The PDU to associate the data with. |
749 | | * @param length The length of data to transmit. |
750 | | * @param data The data to transmit. |
751 | | * @param release_func The function to call to de-allocate @p app_ptr or @c NULL |
752 | | * if the function is not required. |
753 | | * @param app_ptr A Pointer that the application can provide for when |
754 | | * release_func() is called. |
755 | | * |
756 | | * @return @c 1 if addition is successful, else @c 0. |
757 | | */ |
758 | | int coap_add_data_large_request_lkd(coap_session_t *session, |
759 | | coap_pdu_t *pdu, |
760 | | size_t length, |
761 | | const uint8_t *data, |
762 | | coap_release_large_data_t release_func, |
763 | | void *app_ptr); |
764 | | |
765 | | /** |
766 | | * Associates given data callback with the @p pdu that is passed as second parameter. |
767 | | * |
768 | | * This function will fail if data has already been added to the @p pdu. |
769 | | * |
770 | | * Used for a client request. |
771 | | * |
772 | | * If the data spans multiple PDUs, then the data will get transmitted using |
773 | | * (Q-)Block1 option with the addition of the Size1 and Request-Tag options. |
774 | | * The underlying library will handle the transmission of the individual blocks. |
775 | | * |
776 | | * Each individual block of data will get requested by the use of a call-back |
777 | | * function @p get_func before transmission. |
778 | | * |
779 | | * There is no need for the application to include the (Q-)Block1 option in the |
780 | | * @p pdu. |
781 | | * |
782 | | * coap_add_data_large_request_app() (or the alternative coap_add_data_large_*() |
783 | | * functions) must be called only once per PDU and must be the last PDU update |
784 | | * before the PDU is transmitted. The (potentially) initial data will get |
785 | | * transmitted when coap_send() is invoked. |
786 | | * |
787 | | * Note: COAP_BLOCK_USE_LIBCOAP must be set by coap_context_set_block_mode() |
788 | | * for libcoap to work correctly when using this function. |
789 | | * |
790 | | * Note: This function must be called in the locked state. |
791 | | * |
792 | | * @param session The session to associate the data with. |
793 | | * @param pdu The PDU to associate the data with. |
794 | | * @param length The length of data to transmit. |
795 | | * @param release_func The function to call to de-allocate @p app_ptr or @c NULL |
796 | | * if the function is not required. |
797 | | * @param get_func The function to call to get the next block of data |
798 | | * for transmission. |
799 | | * @param app_ptr A Pointer that the application can provide for when |
800 | | * @p get_func is called. |
801 | | * |
802 | | * @return @c 1 if addition is successful, else @c 0. |
803 | | */ |
804 | | int coap_add_data_large_request_app_lkd(coap_session_t *session, |
805 | | coap_pdu_t *pdu, |
806 | | size_t length, |
807 | | coap_release_large_data_t release_func, |
808 | | coap_get_large_data_t get_func, |
809 | | void *app_ptr); |
810 | | |
811 | | /** |
812 | | * The function checks if the token needs to be updated before PDU is |
813 | | * presented to the application (only relevant to clients). |
814 | | * |
815 | | * @param session The session. |
816 | | * @param pdu The PDU to to check for updating. |
817 | | */ |
818 | | void coap_check_update_token(coap_session_t *session, coap_pdu_t *pdu); |
819 | | #else /* ! COAP_CLIENT_SUPPORT */ |
820 | | #define coap_check_update_token(a,b) |
821 | | #endif /* ! COAP_CLIENT_SUPPORT */ |
822 | | |
823 | | /** @} */ |
824 | | |
825 | | #ifdef __cplusplus |
826 | | } |
827 | | #endif |
828 | | |
829 | | #endif /* COAP_BLOCK_INTERNAL_H_ */ |