Coverage Report

Created: 2026-08-14 07:12

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