Skip to content

Commit

Permalink
sys/net/nanocoap: fix invalid RST messages
Browse files Browse the repository at this point in the history
An RST message has no token, so don't reply with a token when sending
RST.
  • Loading branch information
maribu committed Dec 11, 2024
1 parent b9eb0bf commit 4c46407
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions sys/net/application_layer/nanocoap/nanocoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,15 +662,15 @@ ssize_t coap_build_reply(coap_pkt_t *pkt, unsigned code,
return -ENOSPC;
}

/* if code is COAP_CODE_EMPTY (zero), assume Reset (RST) type */
unsigned type = COAP_TYPE_RST;
if (code) {
if (coap_get_type(pkt) == COAP_TYPE_CON) {
type = COAP_TYPE_ACK;
}
else {
type = COAP_TYPE_NON;
}
unsigned type = COAP_TYPE_NON;
if (!code) {
/* if code is COAP_CODE_EMPTY (zero), assume Reset (RST) type.
* RST message have no token */
type = COAP_TYPE_RST;
tkl = 0;
}
else if (coap_get_type(pkt) == COAP_TYPE_CON) {
type = COAP_TYPE_ACK;
}

uint32_t no_response;
Expand Down

0 comments on commit 4c46407

Please sign in to comment.