mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
sys/net/nanocoap: introduce Accept option helper
This commit is contained in:
parent
1c00ce273e
commit
d916b33bc6
@ -628,6 +628,16 @@ uint8_t *coap_find_option(coap_pkt_t *pkt, unsigned opt_num);
|
||||
*/
|
||||
unsigned coap_get_content_type(coap_pkt_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief Get the Accept option value from a packet if present
|
||||
*
|
||||
* @param[in] pkt packet to work on
|
||||
*
|
||||
* @returns the packet's Accept option value if included,
|
||||
* COAP_FORMAT_NONE otherwise
|
||||
*/
|
||||
unsigned coap_get_accept(coap_pkt_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief Get a uint32 option value
|
||||
*
|
||||
|
@ -280,9 +280,9 @@ uint8_t *coap_iterate_option(coap_pkt_t *pkt, uint8_t **optpos,
|
||||
}
|
||||
}
|
||||
|
||||
unsigned coap_get_content_type(coap_pkt_t *pkt)
|
||||
static unsigned _get_content_format(coap_pkt_t *pkt, unsigned int opt_num)
|
||||
{
|
||||
uint8_t *opt_pos = coap_find_option(pkt, COAP_OPT_CONTENT_FORMAT);
|
||||
uint8_t *opt_pos = coap_find_option(pkt, opt_num);
|
||||
unsigned content_type = COAP_FORMAT_NONE;
|
||||
if (opt_pos) {
|
||||
uint16_t delta;
|
||||
@ -302,6 +302,16 @@ unsigned coap_get_content_type(coap_pkt_t *pkt)
|
||||
return content_type;
|
||||
}
|
||||
|
||||
unsigned coap_get_content_type(coap_pkt_t *pkt)
|
||||
{
|
||||
return _get_content_format(pkt, COAP_OPT_CONTENT_FORMAT);
|
||||
}
|
||||
|
||||
unsigned coap_get_accept(coap_pkt_t *pkt)
|
||||
{
|
||||
return _get_content_format(pkt, COAP_OPT_ACCEPT);
|
||||
}
|
||||
|
||||
ssize_t coap_opt_get_next(const coap_pkt_t *pkt, coap_optpos_t *opt,
|
||||
uint8_t **value, bool init_opt)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user