Coverage Report

Created: 2026-06-10 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libcoap/include/coap3/coap_option.h
Line
Count
Source
1
/*
2
 * coap_option.h -- helpers for handling options in CoAP PDUs
3
 *
4
 * Copyright (C) 2010-2013,2022-2026 Olaf Bergmann <bergmann@tzi.org>
5
 *
6
 * SPDX-License-Identifier: BSD-2-Clause
7
 *
8
 * This file is part of the CoAP library libcoap. Please see README for terms
9
 * of use.
10
 */
11
12
/**
13
 * @file coap_option.h
14
 * @brief Helpers for handling options in CoAP PDUs
15
 */
16
17
#ifndef COAP_OPTION_H_
18
#define COAP_OPTION_H_
19
20
#if defined(RIOT_VERSION)
21
#include <thread.h>
22
#endif /* RIOT_VERSION */
23
24
#if defined(_WIN32)
25
#include <stddef.h>
26
#include <stdint.h>
27
#endif /* _WIN32 */
28
29
#ifndef NULL
30
#define NULL 0
31
#endif
32
33
#ifdef __cplusplus
34
extern "C" {
35
#endif
36
37
typedef uint16_t coap_option_num_t;
38
39
/*
40
 * CoAP option numbers (be sure to update coap_option_check_critical()
41
 * and coap_option_check_repeatable() when adding options).
42
 */
43
44
/*
45
 * The C, U, and N flags indicate the properties
46
 * Critical, Unsafe, and NoCacheKey, respectively.
47
 * If U is set, then N has no meaning as per
48
 * https://rfc-editor.org/rfc/rfc7252#section-5.10
49
 * and is set to a -.
50
 *
51
 * Separately, R is for the options that can be repeated
52
 *
53
 * The least significant byte of the option is set as followed
54
 * as per https://rfc-editor.org/rfc/rfc7252#section-5.4.6
55
 *
56
 *   0   1   2   3   4   5   6   7
57
 * --+---+---+---+---+---+---+---+
58
 *           | NoCacheKey| U | C |
59
 * --+---+---+---+---+---+---+---+
60
 *
61
 * https://rfc-editor.org/rfc/rfc8613#section-4 goes on to define E, I and U
62
 * properties Encrypted and Integrity Protected, Integrity Protected Only, and
63
 * Unprotected respectively.  Integrity Protected Only is not currently used.
64
 *
65
 * An Option is tagged with CUNREIU with any of the letters replaced with _ if
66
 * not set, or - for N if U is set (see above) for aiding understanding of the
67
 * Option.
68
 */
69
70
typedef enum coap_code_opt_num_t {
71
  COAP_OPTION_IF_MATCH      =   1, /* C__RE__, opaque,      0-8 B, none, RFC7252 */
72
  COAP_OPTION_URI_HOST      =   3, /* CU-___U, String,    1-255 B, none, RFC7252 */
73
  COAP_OPTION_ETAG          =   4, /* ___RE__, opaque,      1-8 B, none, RFC7252 */
74
  COAP_OPTION_IF_NONE_MATCH =   5, /* C___E__, empty,         0 B, none, RFC7252 */
75
  COAP_OPTION_OBSERVE       =   6, /* _U-_E_U, empty/uint,0/0-3 B, none, RFC7641 */
76
  COAP_OPTION_URI_PORT      =   7, /* CU-___U, uint,        0-2 B, none, RFC7252 */
77
  COAP_OPTION_LOCATION_PATH =   8, /* ___RE__, String,    0-255 B, none, RFC7252 */
78
  COAP_OPTION_OSCORE        =   9, /* C_____U, *,         0-255 B, none, RFC8613 */
79
  COAP_OPTION_URI_PATH      =  11, /* CU-RE__, String,    0-255 B, none, RFC7252 */
80
  COAP_OPTION_CONTENT_FORMAT=  12, /* ____E__, uint,        0-2 B, none, RFC7252 */
81
  COAP_OPTION_URI_PATH_ABB  =  13, /* C___E__, uint,        0-4 B, none, RFC TBD */
82
  /* COAP_OPTION_MAXAGE default 60 seconds if not set */
83
  COAP_OPTION_MAXAGE        =  14, /* _U-_E_U, uint,        0-4 B, 60,   RFC7252 */
84
  COAP_OPTION_URI_QUERY     =  15, /* CU-RE__, String,    1-255 B, none, RFC7252 */
85
  COAP_OPTION_HOP_LIMIT     =  16, /* ______U, uint,          1 B, none, RFC8768 */
86
  COAP_OPTION_ACCEPT        =  17, /* C___E__, uint,        0-2 B, none, RFC7252 */
87
  COAP_OPTION_Q_BLOCK1      =  19, /* CU__E_U, uint,        0-3 B, none, RFC9177 */
88
  COAP_OPTION_LOCATION_QUERY=  20, /* ___RE__, String,    0-255 B, none, RFC7252 */
89
  COAP_OPTION_EDHOC         =  21, /* C_____U, empty,         0 B, none, RFC9668 */
90
  COAP_OPTION_BLOCK2        =  23, /* CU-_E_U, uint,        0-3 B, none, RFC7959 */
91
  COAP_OPTION_BLOCK1        =  27, /* CU-_E_U, uint,        0-3 B, none, RFC7959 */
92
  COAP_OPTION_SIZE2         =  28, /* __N_E_U, uint,        0-4 B, none, RFC7959 */
93
  COAP_OPTION_Q_BLOCK2      =  31, /* CU_RE_U, uint,        0-3 B, none, RFC9177 */
94
  COAP_OPTION_PROXY_URI     =  35, /* CU-___U, String,   1-1034 B, none, RFC7252 */
95
  COAP_OPTION_PROXY_SCHEME  =  39, /* CU-___U, String,    1-255 B, none, RFC7252 */
96
  COAP_OPTION_SIZE1         =  60, /* __N_E_U, uint,        0-4 B, none, RFC7252 */
97
  COAP_OPTION_ECHO          = 252, /* __N_E_U, opaque,     0-40 B, none, RFC9175 */
98
  COAP_OPTION_NORESPONSE    = 258, /* _U-_E_U, uint,        0-1 B, none, RFC7967 */
99
  COAP_OPTION_RTAG          = 292, /* ___RE_U, opaque,      0-8 B, none, RFC9175 */
100
} coap_code_opt_num_t;
101
102
0
#define  COAP_OPTION_CONTENT_TYPE COAP_OPTION_CONTENT_FORMAT
103
104
#if (UINT_MAX > 65535)
105
139k
#define COAP_MAX_OPT 65535 /**< the highest option number we know */
106
#else /* UINT_MAX <= 65535 */
107
#define COAP_MAX_OPT 65534 /**< the highest option number we know */
108
#endif /* UINT_MAX <= 65535 */
109
110
/* Signaling options */
111
112
/* Applies to COAP_SIGNALING_CSM (7.01) */
113
typedef enum coap_sig_csm_opt_t {
114
  COAP_SIG_OPT_MAX_MESSAGE_SIZE      = 2, /* ____E_U, uint,     0-4 B, 1152, RFC8323 */
115
  COAP_SIG_OPT_BLOCK_WISE_TRANSFER   = 4, /* ____E_U, empty,      0 B, none, RFC8323 */
116
  COAP_SIG_OPT_EXTENDED_TOKEN_LENGTH = 6, /* ____E_U, uint,     0-3 B, 8,    RFC8974 */
117
} coap_sig_csm_opt_t;
118
119
/* Applies to COAP_SIGNALING_PING / COAP_SIGNALING_PONG (7.02 / 7.03) */
120
typedef enum coap_sig_ping_opt_t {
121
  COAP_SIG_OPT_CUSTODY               = 2, /* ____E_U, empty,      0 B, none, RFC8323 */
122
} coap_sig_ping_opt_t;
123
124
/* Applies to COAP_SIGNALING_RELEASE (7.04) */
125
typedef enum coap_sig_release_opt_t {
126
  COAP_SIG_OPT_ALTERNATIVE_ADDRESS   = 2, /* ___RE_U, String, 1-255 B, none, RFC8323 */
127
  COAP_SIG_OPT_HOLD_OFF              = 4, /* ____E_U, uint,     0-3 B, none, RFC8323 */
128
} coap_sig_release_opt_t;
129
130
/* Applies to COAP_SIGNALING_ABORT (7.05 )*/
131
typedef enum coap_sig_abort_opt_t {
132
  COAP_SIG_OPT_BAD_CSM_OPTION        = 2, /* ____E_U, uint,     0-2 B, none, RFC8323 */
133
} coap_sig_abort_opt_t;
134
135
/* Backward Application compatability */
136
#define COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE      COAP_SIG_OPT_MAX_MESSAGE_SIZE
137
#define COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER   COAP_SIG_OPT_BLOCK_WISE_TRANSFER
138
#define COAP_SIGNALING_OPTION_EXTENDED_TOKEN_LENGTH COAP_SIG_OPT_EXTENDED_TOKEN_LENGTH
139
#define COAP_SIGNALING_OPTION_CUSTODY               COAP_SIG_OPT_CUSTODY
140
#define COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS   COAP_SIG_OPT_ALTERNATIVE_ADDRESS
141
#define COAP_SIGNALING_OPTION_HOLD_OFF              COAP_SIG_OPT_HOLD_OFF
142
#define COAP_SIGNALING_OPTION_BAD_CSM_OPTION        COAP_SIG_OPT_BAD_CSM_OPTION
143
144
/**
145
 * Use byte-oriented access methods here because sliding a complex struct
146
 * coap_opt_t over the data buffer may cause bus error on certain platforms.
147
 */
148
typedef uint8_t coap_opt_t;
149
#define PCHAR(p) ((coap_opt_t *)(p))
150
151
/**
152
 * Representation of CoAP options.
153
 */
154
typedef struct {
155
  uint16_t delta;
156
  size_t length;
157
  const uint8_t *value;
158
} coap_option_t;
159
160
/**
161
 * Parses the option pointed to by @p opt into @p result. This function returns
162
 * the number of bytes that have been parsed, or @c 0 on error. An error is
163
 * signaled when illegal delta or length values are encountered or when option
164
 * parsing would result in reading past the option (i.e. beyond opt + length).
165
 *
166
 * @param opt    The beginning of the option to parse.
167
 * @param length The maximum length of @p opt.
168
 * @param result A pointer to the coap_option_t structure that is filled with
169
 *               actual values iff coap_opt_parse() > 0.
170
 * @return       The number of bytes parsed or @c 0 on error.
171
 */
172
size_t coap_opt_parse(const coap_opt_t *opt,
173
                      size_t length,
174
                      coap_option_t *result);
175
176
/**
177
 * Returns the size of the given option, taking into account a possible option
178
 * jump.
179
 *
180
 * @param opt An option jump or the beginning of the option.
181
 * @return    The number of bytes between @p opt and the end of the option
182
 *            starting at @p opt. In case of an error, this function returns
183
 *            @c 0 as options need at least one byte storage space.
184
 */
185
size_t coap_opt_size(const coap_opt_t *opt);
186
187
/**
188
 * @ingroup application_api
189
 * @defgroup opt_filter Option Filters
190
 * API for access option filters
191
 * @{
192
 */
193
194
/**
195
 * The number of option types below 256 that can be stored in an
196
 * option filter. COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG must be
197
 * at most 16. Each coap_option_filter_t object reserves
198
 * ((COAP_OPT_FILTER_SHORT + 1) / 2) * 2 bytes for short options.
199
 */
200
391k
#define COAP_OPT_FILTER_SHORT 6
201
202
/**
203
 * The number of option types above 255 that can be stored in an
204
 * option filter. COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG must be
205
 * at most 16. Each coap_option_filter_t object reserves
206
 * COAP_OPT_FILTER_LONG * 2 bytes for short options.
207
 */
208
187k
#define COAP_OPT_FILTER_LONG  2
209
210
/* Ensure that COAP_OPT_FILTER_SHORT and COAP_OPT_FILTER_LONG are set
211
 * correctly. */
212
#if (COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG > 16)
213
#error COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG must be less or equal 16
214
#endif /* (COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG > 16) */
215
216
/*
217
 * mask contains a bit vector that indicates which fields in the long_opts[]
218
 * and subsequent short_opts[] are used. The first COAP_OPT_FILTER_LONG bits
219
 * correspond to the long option types that are stored in long_opts[]
220
 * elements. The next COAP_OPT_FILTER_SHORT bits correspond to the short
221
 * option types that are stored in short_opts[].
222
 */
223
typedef struct coap_opt_filter_t {
224
  uint16_t mask;
225
  uint16_t long_opts[COAP_OPT_FILTER_LONG];
226
  uint8_t short_opts[COAP_OPT_FILTER_SHORT];
227
} coap_opt_filter_t;
228
229
/** Pre-defined filter that includes all options. */
230
2.33k
#define COAP_OPT_ALL NULL
231
232
/**
233
 * Clears filter @p filter.
234
 *
235
 * @param filter The filter to clear.
236
 */
237
void coap_option_filter_clear(coap_opt_filter_t *filter);
238
239
/**
240
 * Sets the corresponding entry for @p number in @p filter. This
241
 * function returns @c 1 if bit was set or @c 0 on error (i.e. when
242
 * there is not enough space to fit the given number in the filter).
243
 *
244
 * @param filter The filter object to change.
245
 * @param number The option number for which the bit should be set.
246
 *
247
 * @return       @c 1 if bit was set, @c 0 otherwise.
248
 */
249
int coap_option_filter_set(coap_opt_filter_t *filter, coap_option_num_t number);
250
251
/**
252
 * Clears the corresponding entry for @p number in @p filter. This
253
 * function returns @c 1 if bit was set or @c 0 if not previously set.
254
 *
255
 * @param filter The filter object to change.
256
 * @param number The option number that should be cleared from the filter.
257
 *
258
 * @return       @c 1 if bit was cleared, @c 0 otherwise.
259
 */
260
int coap_option_filter_unset(coap_opt_filter_t *filter,
261
                             coap_option_num_t number);
262
263
/**
264
 * Checks if @p number is contained in @p filter. This function returns
265
 * @c 1 if found, @c 0 if not.
266
 *
267
 * @param filter The filter object to search.
268
 * @param number The option number to search for.
269
 *
270
 * @return       @c 1 if @p number was found, @c 0 otherwise
271
 */
272
int coap_option_filter_get(coap_opt_filter_t *filter, coap_option_num_t number);
273
274
/**
275
 * Iterator to run through PDU options. This object must be
276
 * initialized with coap_option_iterator_init(). Call
277
 * coap_option_next() to walk through the list of options until
278
 * coap_option_next() returns @c NULL.
279
 *
280
 * @code
281
 * coap_opt_t *option;
282
 * coap_opt_iterator_t opt_iter;
283
 * coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
284
 *
285
 * while ((option = coap_option_next(&opt_iter))) {
286
 *   ... do something with option ...
287
 * }
288
 * @endcode
289
 */
290
typedef struct {
291
  size_t length;                /**< remaining length of PDU */
292
  coap_option_num_t number;     /**< decoded option number */
293
  unsigned int bad:1;           /**< iterator object is ok if not set */
294
  unsigned int filtered:1;      /**< denotes whether or not filter is used */
295
  coap_opt_t *next_option;      /**< pointer to the unparsed next option */
296
  coap_opt_filter_t filter;     /**< option filter */
297
} coap_opt_iterator_t;
298
299
/**
300
 * Initializes the given option iterator @p oi to point to the beginning of the
301
 * @p pdu's option list. This function returns @p oi on success, @c NULL
302
 * otherwise (i.e. when no options exist). Note that a length check on the
303
 * option list must be performed before coap_option_iterator_init() is called.
304
 *
305
 * @param pdu    The PDU the options of which should be walked through.
306
 * @param oi     An iterator object that will be initilized.
307
 * @param filter An optional option number filter.
308
 *               With @p number != @c COAP_OPT_ALL, coap_option_next()
309
 *               will return only options matching this bitmask.
310
 *               Fence-post options @c 14, @c 28, @c 42, ... are always
311
 *               skipped.
312
 *
313
 * @return       The iterator object @p oi on success, @c NULL otherwise.
314
 */
315
coap_opt_iterator_t *coap_option_iterator_init(const coap_pdu_t *pdu,
316
                                               coap_opt_iterator_t *oi,
317
                                               const coap_opt_filter_t *filter);
318
319
/**
320
 * Updates the iterator @p oi to point to the next option. This function returns
321
 * a pointer to that option or @c NULL if no more options exist. The contents of
322
 * @p oi will be updated. In particular, @c oi->n specifies the current option's
323
 * ordinal number (counted from @c 1), @c oi->number is the option's number
324
 * value, and @c oi->option points to the beginning of the current option
325
 * itself. When * advanced past the last option, @c oi->option will be @c NULL.
326
 *
327
 * Note that options are skipped whose corresponding bits in the filter
328
 * specified with coap_option_iterator_init() are @c 0. Options with numbers
329
 * that do not fit in this filter hence will always be returned.
330
 *
331
 * @param oi The option iterator to update.
332
 *
333
 * @return   The next option or @c NULL if no more options exist.
334
 */
335
coap_opt_t *coap_option_next(coap_opt_iterator_t *oi);
336
337
/**
338
 * Retrieves the first option of number @p number from @p pdu. @p oi must
339
 * point to a coap_opt_iterator_t object that will be initialized by this
340
 * function to filter only options with number @p number. This function returns
341
 * the first option with this number, or @c NULL if not found.
342
 *
343
 * @param pdu  The PDU to parse for options.
344
 * @param number The option number to search for.
345
 * @param oi   An iterator object to use.
346
 *
347
 * @return     A pointer to the first option of number @p number, or @c NULL if
348
 *             not found.
349
 */
350
coap_opt_t *coap_check_option(const coap_pdu_t *pdu,
351
                              coap_option_num_t number,
352
                              coap_opt_iterator_t *oi);
353
354
/**
355
 * Encodes the given delta and length values into @p opt. This function returns
356
 * the number of bytes that were required to encode @p delta and @p length or @c
357
 * 0 on error. Note that the result indicates by how many bytes @p opt must be
358
 * advanced to encode the option value.
359
 *
360
 * @param opt    The option buffer space where @p delta and @p length are
361
 *               written.
362
 * @param maxlen The maximum length of @p opt.
363
 * @param delta  The actual delta value to encode.
364
 * @param length The actual length value to encode.
365
 *
366
 * @return       The number of bytes used or @c 0 on error.
367
 */
368
size_t coap_opt_setheader(coap_opt_t *opt,
369
                          size_t maxlen,
370
                          uint16_t delta,
371
                          size_t length);
372
373
/**
374
 * Compute storage bytes needed for an option with given @p delta and
375
 * @p length
376
 *
377
 * @param delta  The option delta.
378
 * @param length The option length.
379
 *
380
 * @return       The number of bytes required to encode this option.
381
 */
382
size_t coap_opt_encode_size(uint16_t delta, size_t length);
383
384
/**
385
 * Encodes option with given @p delta into @p opt. This function returns the
386
 * number of bytes written to @p opt or @c 0 on error. This happens especially
387
 * when @p opt does not provide sufficient space to store the option value,
388
 * delta, and option jumps when required.
389
 *
390
 * @param opt    The option buffer space where @p val is written.
391
 * @param n      Maximum length of @p opt.
392
 * @param delta  The option delta.
393
 * @param val    The option value to copy into @p opt.
394
 * @param length The actual length of @p val.
395
 *
396
 * @return       The number of bytes that have been written to @p opt or @c 0 on
397
 *               error. The return value will always be less than @p n.
398
 */
399
size_t coap_opt_encode(coap_opt_t *opt,
400
                       size_t n,
401
                       uint16_t delta,
402
                       const uint8_t *val,
403
                       size_t length);
404
405
/**
406
 * Returns the length of the given option. @p opt must point to an option jump
407
 * or the beginning of the option. This function returns @c 0 when @p opt is not
408
 * an option or the actual length of @p opt (which can be @c 0 as well).
409
 *
410
 * @note {The rationale for using @c 0 in case of an error is that in most
411
 * contexts, the result of this function is used to skip the next
412
 * coap_opt_length() bytes.}
413
 *
414
 * @param opt  The option whose length should be returned.
415
 *
416
 * @return     The option's length or @c 0 when undefined.
417
 */
418
uint32_t coap_opt_length(const coap_opt_t *opt);
419
420
/**
421
 * Returns a pointer to the value of the given option. @p opt must point to an
422
 * option jump or the beginning of the option. This function returns @c NULL if
423
 * @p opt is not a valid option.
424
 *
425
 * @param opt The option whose value should be returned.
426
 *
427
 * @return    A pointer to the option value or @c NULL on error.
428
 */
429
const uint8_t *coap_opt_value(const coap_opt_t *opt);
430
431
/**
432
 * Representation of chained list of CoAP options to install.
433
 *
434
 * @code
435
 * coap_optlist_t *optlist_chain = NULL;
436
 * coap_pdu_t *pdu = coap_new_pdu(session);
437
 *
438
 * ... other set up code ...
439
 * coap_insert_optlist(&optlist_chain, coap_new_optlist(COAP_OPTION_OBSERVE,
440
 *                    COAP_OBSERVE_ESTABLISH, NULL));
441
 *
442
 * coap_add_optlist_pdu(pdu, &optlist_chain);
443
 * ... other code ...
444
 * coap_delete_optlist(optlist_chain);
445
 * @endcode
446
 */
447
typedef struct coap_optlist_t {
448
  struct coap_optlist_t *next;  /**< next entry in the optlist chain */
449
  coap_option_num_t number;     /**< the option number (no delta coding) */
450
  size_t length;                /**< the option value length */
451
  uint8_t *data;                /**< the option data */
452
} coap_optlist_t;
453
454
/**
455
 * Create a new optlist entry.
456
 *
457
 * Note: Where possible, the option data needs to be stripped of leading zeros
458
 * (big endian) to reduce the amount of data needed in the PDU, as well as in
459
 * some cases the maximum data size of an opton can be exceeded if not stripped
460
 * and hence be illegal.  This is done by using coap_encode_var_safe() or
461
 * coap_encode_var_safe8().
462
 *
463
 * @param number    The option number (COAP_OPTION_*)
464
 * @param length    The option length
465
 * @param data      The option value data
466
 *
467
 * @return          A pointer to the new optlist entry, or @c NULL if error
468
 */
469
coap_optlist_t *coap_new_optlist(coap_option_num_t number,
470
                                 size_t length,
471
                                 const uint8_t *data);
472
473
/**
474
 * The current optlist of @p optlist_chain is first sorted (as per RFC7272
475
 * ordering requirements) and then added to the @p pdu.
476
 *
477
 * @param pdu  The pdu to add the options to from the chain list
478
 * @param optlist_chain The chained list of optlist to add to the pdu
479
 *
480
 * @return     @c 1 if succesful or @c 0 if failure;
481
 */
482
int coap_add_optlist_pdu(coap_pdu_t *pdu, coap_optlist_t **optlist_chain);
483
484
485
/**
486
 * @brief Sorts the optlist chain
487
 *
488
 * @param options The optlist chain to sort
489
 *
490
 * @return @c 1 if sorted successfully, @c 0 otherwise.
491
 */
492
int coap_sort_optlist(coap_optlist_t **options);
493
494
/**
495
 * Adds @p optlist to the given @p optlist_chain. The optlist_chain variable
496
 * be set to NULL before the initial call to coap_insert_optlist().
497
 * The optlist_chain will need to be deleted using coap_delete_optlist()
498
 * when no longer required.
499
 *
500
 * @param optlist_chain The chain to add optlist to
501
 * @param optlist  The optlist to add to the queue
502
 *
503
 * @return         @c 1 if successful, @c 0 otherwise.
504
 */
505
int coap_insert_optlist(coap_optlist_t **optlist_chain,
506
                        coap_optlist_t *optlist);
507
508
/**
509
 * Removes all entries from the @p optlist_chain, freeing off their
510
 * memory usage.
511
 *
512
 * @param optlist_chain The optlist chain to remove all the entries from
513
 */
514
void coap_delete_optlist(coap_optlist_t *optlist_chain);
515
516
/** @} */
517
518
/**
519
 * Sets the corresponding bit for @p type in @p filter. This function returns @c
520
 * 1 if bit was set or @c -1 on error (i.e. when the given type does not fit in
521
 * the filter).
522
 *
523
 * @deprecated Use coap_option_filter_set() instead.
524
 *
525
 * @param filter The filter object to change.
526
 * @param type   The type for which the bit should be set.
527
 *
528
 * @return       @c 1 if bit was set, @c -1 otherwise.
529
 */
530
COAP_STATIC_INLINE COAP_DEPRECATED int
531
0
coap_option_setb(coap_opt_filter_t *filter, coap_option_num_t type) {
532
0
  return coap_option_filter_set(filter, type) ? 1 : -1;
533
0
}
Unexecuted instantiation: persist_target.c:coap_option_setb
Unexecuted instantiation: coap_address.c:coap_option_setb
Unexecuted instantiation: coap_debug.c:coap_option_setb
Unexecuted instantiation: coap_encode.c:coap_option_setb
Unexecuted instantiation: coap_mem.c:coap_option_setb
Unexecuted instantiation: coap_net.c:coap_option_setb
Unexecuted instantiation: coap_netif.c:coap_option_setb
Unexecuted instantiation: coap_openssl.c:coap_option_setb
Unexecuted instantiation: coap_option.c:coap_option_setb
Unexecuted instantiation: coap_oscore.c:coap_option_setb
Unexecuted instantiation: coap_pdu.c:coap_option_setb
Unexecuted instantiation: coap_proxy.c:coap_option_setb
Unexecuted instantiation: coap_prng.c:coap_option_setb
Unexecuted instantiation: coap_resource.c:coap_option_setb
Unexecuted instantiation: coap_session.c:coap_option_setb
Unexecuted instantiation: coap_str.c:coap_option_setb
Unexecuted instantiation: coap_strm_posix.c:coap_option_setb
Unexecuted instantiation: coap_subscribe.c:coap_option_setb
Unexecuted instantiation: coap_time.c:coap_option_setb
Unexecuted instantiation: coap_uri.c:coap_option_setb
Unexecuted instantiation: coap_ws.c:coap_option_setb
Unexecuted instantiation: oscore.c:coap_option_setb
Unexecuted instantiation: oscore_cbor.c:coap_option_setb
Unexecuted instantiation: oscore_context.c:coap_option_setb
Unexecuted instantiation: oscore_cose.c:coap_option_setb
Unexecuted instantiation: oscore_crypto.c:coap_option_setb
Unexecuted instantiation: coap_async.c:coap_option_setb
Unexecuted instantiation: coap_block.c:coap_option_setb
Unexecuted instantiation: coap_cache.c:coap_option_setb
Unexecuted instantiation: coap_dgrm_posix.c:coap_option_setb
Unexecuted instantiation: coap_dtls.c:coap_option_setb
Unexecuted instantiation: coap_io.c:coap_option_setb
Unexecuted instantiation: coap_io_posix.c:coap_option_setb
Unexecuted instantiation: coap_layers.c:coap_option_setb
534
535
/**
536
 * Clears the corresponding bit for @p type in @p filter. This function returns
537
 * @c 1 if bit was cleared or @c -1 on error (i.e. bit not set).
538
 *
539
 * @deprecated Use coap_option_filter_unset() instead.
540
 *
541
 * @param filter The filter object to change.
542
 * @param type   The type for which the bit should be cleared.
543
 *
544
 * @return       @c 1 if bit was set, @c -1 otherwise.
545
 */
546
COAP_STATIC_INLINE COAP_DEPRECATED int
547
0
coap_option_clrb(coap_opt_filter_t *filter, coap_option_num_t type) {
548
0
  return coap_option_filter_unset(filter, type) ? 1 : -1;
549
0
}
Unexecuted instantiation: persist_target.c:coap_option_clrb
Unexecuted instantiation: coap_address.c:coap_option_clrb
Unexecuted instantiation: coap_debug.c:coap_option_clrb
Unexecuted instantiation: coap_encode.c:coap_option_clrb
Unexecuted instantiation: coap_mem.c:coap_option_clrb
Unexecuted instantiation: coap_net.c:coap_option_clrb
Unexecuted instantiation: coap_netif.c:coap_option_clrb
Unexecuted instantiation: coap_openssl.c:coap_option_clrb
Unexecuted instantiation: coap_option.c:coap_option_clrb
Unexecuted instantiation: coap_oscore.c:coap_option_clrb
Unexecuted instantiation: coap_pdu.c:coap_option_clrb
Unexecuted instantiation: coap_proxy.c:coap_option_clrb
Unexecuted instantiation: coap_prng.c:coap_option_clrb
Unexecuted instantiation: coap_resource.c:coap_option_clrb
Unexecuted instantiation: coap_session.c:coap_option_clrb
Unexecuted instantiation: coap_str.c:coap_option_clrb
Unexecuted instantiation: coap_strm_posix.c:coap_option_clrb
Unexecuted instantiation: coap_subscribe.c:coap_option_clrb
Unexecuted instantiation: coap_time.c:coap_option_clrb
Unexecuted instantiation: coap_uri.c:coap_option_clrb
Unexecuted instantiation: coap_ws.c:coap_option_clrb
Unexecuted instantiation: oscore.c:coap_option_clrb
Unexecuted instantiation: oscore_cbor.c:coap_option_clrb
Unexecuted instantiation: oscore_context.c:coap_option_clrb
Unexecuted instantiation: oscore_cose.c:coap_option_clrb
Unexecuted instantiation: oscore_crypto.c:coap_option_clrb
Unexecuted instantiation: coap_async.c:coap_option_clrb
Unexecuted instantiation: coap_block.c:coap_option_clrb
Unexecuted instantiation: coap_cache.c:coap_option_clrb
Unexecuted instantiation: coap_dgrm_posix.c:coap_option_clrb
Unexecuted instantiation: coap_dtls.c:coap_option_clrb
Unexecuted instantiation: coap_io.c:coap_option_clrb
Unexecuted instantiation: coap_io_posix.c:coap_option_clrb
Unexecuted instantiation: coap_layers.c:coap_option_clrb
550
551
/**
552
 * Gets the corresponding bit for @p type in @p filter. This function returns @c
553
 * 1 if the bit is set @c 0 if not.
554
 *
555
 * @deprecated Use coap_option_filter_get() instead.
556
 *
557
 * @param filter The filter object to read bit from.
558
 * @param type   The type for which the bit should be read.
559
 *
560
 * @return       @c 1 if bit was set, @c 0 if not.
561
 */
562
COAP_STATIC_INLINE COAP_DEPRECATED int
563
0
coap_option_getb(coap_opt_filter_t *filter, coap_option_num_t type) {
564
0
  return coap_option_filter_get(filter, type);
565
0
}
Unexecuted instantiation: persist_target.c:coap_option_getb
Unexecuted instantiation: coap_address.c:coap_option_getb
Unexecuted instantiation: coap_debug.c:coap_option_getb
Unexecuted instantiation: coap_encode.c:coap_option_getb
Unexecuted instantiation: coap_mem.c:coap_option_getb
Unexecuted instantiation: coap_net.c:coap_option_getb
Unexecuted instantiation: coap_netif.c:coap_option_getb
Unexecuted instantiation: coap_openssl.c:coap_option_getb
Unexecuted instantiation: coap_option.c:coap_option_getb
Unexecuted instantiation: coap_oscore.c:coap_option_getb
Unexecuted instantiation: coap_pdu.c:coap_option_getb
Unexecuted instantiation: coap_proxy.c:coap_option_getb
Unexecuted instantiation: coap_prng.c:coap_option_getb
Unexecuted instantiation: coap_resource.c:coap_option_getb
Unexecuted instantiation: coap_session.c:coap_option_getb
Unexecuted instantiation: coap_str.c:coap_option_getb
Unexecuted instantiation: coap_strm_posix.c:coap_option_getb
Unexecuted instantiation: coap_subscribe.c:coap_option_getb
Unexecuted instantiation: coap_time.c:coap_option_getb
Unexecuted instantiation: coap_uri.c:coap_option_getb
Unexecuted instantiation: coap_ws.c:coap_option_getb
Unexecuted instantiation: oscore.c:coap_option_getb
Unexecuted instantiation: oscore_cbor.c:coap_option_getb
Unexecuted instantiation: oscore_context.c:coap_option_getb
Unexecuted instantiation: oscore_cose.c:coap_option_getb
Unexecuted instantiation: oscore_crypto.c:coap_option_getb
Unexecuted instantiation: coap_async.c:coap_option_getb
Unexecuted instantiation: coap_block.c:coap_option_getb
Unexecuted instantiation: coap_cache.c:coap_option_getb
Unexecuted instantiation: coap_dgrm_posix.c:coap_option_getb
Unexecuted instantiation: coap_dtls.c:coap_option_getb
Unexecuted instantiation: coap_io.c:coap_option_getb
Unexecuted instantiation: coap_io_posix.c:coap_option_getb
Unexecuted instantiation: coap_layers.c:coap_option_getb
566
567
#ifdef __cplusplus
568
}
569
#endif
570
571
#endif /* COAP_OPTION_H_ */