1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/net/nanocoap: fix coap_get_total_hdr_len()

Before `coap_get_total_hdr_len()` did not take the extended TKL field
(RFC 8974) into account. This fixes the issue.
This commit is contained in:
Marian Buschsieweke 2024-11-01 13:20:04 +01:00
parent 00e25adfe3
commit 469edf4827
No known key found for this signature in database
GPG Key ID: 758BD52517F79C41

View File

@ -582,18 +582,6 @@ static inline void *coap_get_token(const coap_pkt_t *pkt)
return coap_hdr_data_ptr(pkt->hdr); return coap_hdr_data_ptr(pkt->hdr);
} }
/**
* @brief Get the total header length (4-byte header + token length)
*
* @param[in] pkt CoAP packet
*
* @returns total header length
*/
static inline unsigned coap_get_total_hdr_len(const coap_pkt_t *pkt)
{
return sizeof(coap_hdr_t) + coap_get_token_len(pkt);
}
/** /**
* @brief Get the total length of a CoAP packet in the packet buffer * @brief Get the total length of a CoAP packet in the packet buffer
* *
@ -676,6 +664,19 @@ static inline uint8_t *coap_hdr_data_ptr(const coap_hdr_t *hdr)
return ((uint8_t *)hdr) + sizeof(coap_hdr_t) + coap_hdr_tkl_ext_len(hdr); return ((uint8_t *)hdr) + sizeof(coap_hdr_t) + coap_hdr_tkl_ext_len(hdr);
} }
/**
* @brief Get the total header length (4-byte header + token length)
*
* @param[in] pkt CoAP packet
*
* @returns total header length
*/
static inline unsigned coap_get_total_hdr_len(const coap_pkt_t *pkt)
{
return sizeof(coap_hdr_t) + coap_hdr_tkl_ext_len(pkt->hdr) +
coap_get_token_len(pkt);
}
/** /**
* @brief Write the given raw message code to given CoAP header * @brief Write the given raw message code to given CoAP header
* *