From 328d46277d751313d1b513054091666cfcc384c1 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 21 Apr 2022 14:42:32 +0200 Subject: [PATCH] nanocoap: add coap_get_token() --- sys/include/net/nanocoap.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/include/net/nanocoap.h b/sys/include/net/nanocoap.h index f8fdd7a5e3..6bf964318f 100644 --- a/sys/include/net/nanocoap.h +++ b/sys/include/net/nanocoap.h @@ -395,6 +395,18 @@ static inline unsigned coap_get_token_len(const coap_pkt_t *pkt) return (pkt->hdr->ver_t_tkl & 0xf); } +/** + * @brief Get pointer to a message's token + * + * @param[in] pkt CoAP packet + * + * @returns pointer to the token position + */ +static inline void *coap_get_token(const coap_pkt_t *pkt) +{ + return (uint8_t*)pkt->hdr + sizeof(coap_hdr_t); +} + /** * @brief Get the total header length (4-byte header + token length) *