15 #ifndef COAP_OPTION_H_ 16 #define COAP_OPTION_H_ 26 #define PCHAR(p) ((coap_opt_t *)(p)) 76 #define COAP_OPT_FILTER_SHORT 6 84 #define COAP_OPT_FILTER_LONG 2 88 #if (COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG > 16) 89 #error COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG must be less or equal 16 93 #define COAP_OPT_FILTER_SIZE \ 94 (((COAP_OPT_FILTER_SHORT + 1) >> 1) + COAP_OPT_FILTER_LONG) +1 122 #define COAP_OPT_ALL NULL size_t length
the option value length
uint8_t coap_opt_t
Use byte-oriented access methods here because sliding a complex struct coap_opt_t over the data buffe...
COAP_STATIC_INLINE int coap_option_clrb(coap_opt_filter_t filter, uint16_t type)
Clears the corresponding bit for type in filter.
size_t coap_opt_size(const coap_opt_t *opt)
Returns the size of the given option, taking into account a possible option jump. ...
size_t coap_opt_parse(const coap_opt_t *opt, size_t length, coap_option_t *result)
Parses the option pointed to by opt into result.
COAP_STATIC_INLINE int coap_option_setb(coap_opt_filter_t filter, uint16_t type)
Sets the corresponding bit for type in filter.
void coap_delete_optlist(coap_optlist_t *optlist_chain)
Removes all entries from the optlist_chain, freeing off their memory usage.
int coap_insert_optlist(coap_optlist_t **optlist_chain, coap_optlist_t *optlist)
Adds optlist to the given optlist_chain.
struct coap_optlist_t * next
next entry in the optlist chain
size_t length
remaining length of PDU
int coap_option_filter_set(coap_opt_filter_t filter, uint16_t type)
Sets the corresponding entry for type in filter.
coap_opt_t * coap_option_next(coap_opt_iterator_t *oi)
Updates the iterator oi to point to the next option.
coap_optlist_t * coap_new_optlist(uint16_t number, size_t length, const uint8_t *data)
Create a new optlist entry.
coap_opt_filter_t filter
option filter
#define COAP_OPT_FILTER_SIZE
The number of elements in coap_opt_filter_t.
uint16_t type
decoded option type
struct coap_optlist_t coap_optlist_t
Representation of chained list of CoAP options to install.
Representation of chained list of CoAP options to install.
size_t coap_opt_encode_size(uint16_t delta, size_t length)
Compute storage bytes needed for an option with given delta and length.
coap_opt_t * coap_check_option(coap_pdu_t *pdu, uint16_t type, coap_opt_iterator_t *oi)
Retrieves the first option of type type from pdu.
structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload mark...
int coap_option_filter_get(coap_opt_filter_t filter, uint16_t type)
Checks if type is contained in filter.
uint16_t coap_opt_length(const coap_opt_t *opt)
Returns the length of the given option.
Representation of CoAP options.
uint16_t coap_opt_delta(const coap_opt_t *opt)
Decodes the delta value of the next option.
uint8_t * data
the option data
int coap_add_optlist_pdu(coap_pdu_t *pdu, coap_optlist_t **optlist_chain)
The current optlist of optlist_chain is first sorted (as per RFC7272 ordering requirements) and then ...
coap_opt_t * next_option
pointer to the unparsed next option
Iterator to run through PDU options.
unsigned int bad
iterator object is ok if not set
int coap_option_filter_unset(coap_opt_filter_t filter, uint16_t type)
Clears the corresponding entry for type in filter.
COAP_STATIC_INLINE void coap_option_filter_clear(coap_opt_filter_t f)
Clears filter f.
uint16_t number
the option number (no delta coding)
#define COAP_STATIC_INLINE
Pre-defined constants that reflect defaults for CoAP.
unsigned int filtered
denotes whether or not filter is used
uint16_t coap_opt_filter_t[COAP_OPT_FILTER_SIZE]
Fixed-size vector we use for option filtering.
COAP_STATIC_INLINE int coap_option_getb(coap_opt_filter_t filter, uint16_t type)
Gets the corresponding bit for type in filter.
size_t coap_opt_encode(coap_opt_t *opt, size_t n, uint16_t delta, const uint8_t *val, size_t length)
Encodes option with given delta into opt.
size_t coap_opt_setheader(coap_opt_t *opt, size_t maxlen, uint16_t delta, size_t length)
Encodes the given delta and length values into opt.
const uint8_t * coap_opt_value(const coap_opt_t *opt)
Returns a pointer to the value of the given option.
coap_opt_iterator_t * coap_option_iterator_init(const coap_pdu_t *pdu, coap_opt_iterator_t *oi, const coap_opt_filter_t filter)
Initializes the given option iterator oi to point to the beginning of the pdu's option list...