Coverage Report

Created: 2026-06-30 06:23

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