Skip to content

Commit

Permalink
fixup! sys/net/gcoap: reduce insanity of hack
Browse files Browse the repository at this point in the history
  • Loading branch information
maribu committed Nov 1, 2024
1 parent 5a0a688 commit ac25b6e
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions sys/include/net/nanocoap.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ struct _coap_request_ctx {
#endif
};

/* forward declarations */
static inline uint8_t *coap_hdr_data_ptr(const coap_hdr_t *hdr);
static inline size_t coap_hdr_get_token_len(const coap_hdr_t *hdr);

/**
* @brief Get resource path associated with a CoAP request
*
Expand Down Expand Up @@ -548,28 +552,9 @@ static inline unsigned coap_get_id(const coap_pkt_t *pkt)
*/
static inline unsigned coap_get_token_len(const coap_pkt_t *pkt)
{
uint8_t tkl = pkt->hdr->ver_t_tkl & 0xf;

if (!IS_USED(MODULE_NANOCOAP_TOKEN_EXT)) {
return tkl;
}

void *ext = pkt->hdr + 1;
switch (tkl) {
case 13:
return tkl + *(uint8_t *)ext;
case 14:
return tkl + 255 + byteorder_bebuftohs(ext);
case 15:
assert(0);
/* fall-through */
default:
return tkl;
}
return coap_hdr_get_token_len(pkt->hdr);
}

static inline uint8_t *coap_hdr_data_ptr(const coap_hdr_t *hdr);

/**
* @brief Get pointer to a message's token
*
Expand Down

0 comments on commit ac25b6e

Please sign in to comment.