Skip to content

Commit

Permalink
coap_session.c: Fix token generation in coap_session_new_token()
Browse files Browse the repository at this point in the history
Revert out change from #1276 and decrement token in coap_session_init_token() to
make sure starting token used is the same as that provided to
coap_session_init_token().
  • Loading branch information
mrdeep1 committed Feb 29, 2024
1 parent a733325 commit e253183
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/coap_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1596,13 +1596,18 @@ void
coap_session_init_token(coap_session_t *session, size_t len,
const uint8_t *data) {
session->tx_token = coap_decode_var_bytes8(data, len);
/*
* Decrement as when first used by coap_session_new_token() it will
* get incremented
*/
session->tx_token--;
}

void
coap_session_new_token(coap_session_t *session, size_t *len,
uint8_t *data) {
*len = coap_encode_var_safe8(data,
sizeof(session->tx_token), session->tx_token++);
sizeof(session->tx_token), ++session->tx_token);
}

uint16_t
Expand Down

0 comments on commit e253183

Please sign in to comment.