Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nanocoap: add coap_get_token() #17976

Merged
merged 3 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
gcoap: make use of coap_get_token()
  • Loading branch information
benpicco committed Apr 21, 2022
commit 3d0c1d09c471aa1e444a44532894f12422b4d27d
2 changes: 1 addition & 1 deletion sys/net/application_layer/gcoap/forward_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ static int _gcoap_forward_proxy_via_coap(coap_pkt_t *client_pkt,
pkt.hdr->id = client_pkt->hdr->id;

if (token_len) {
memcpy(pkt.token, client_pkt->token, token_len);
memcpy(coap_get_token(&pkt), coap_get_token(client_pkt), token_len);
}

/* copy all options from client_pkt to pkt */
Expand Down
4 changes: 2 additions & 2 deletions sys/net/application_layer/gcoap/gcoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ static size_t _handle_req(gcoap_socket_t *sock, coap_pkt_t *pdu, uint8_t *buf,
memo->token_len = coap_get_token_len(pdu);
memo->socket = *sock;
if (memo->token_len) {
memcpy(&memo->token[0], pdu->token, memo->token_len);
memcpy(&memo->token[0], coap_get_token(pdu), memo->token_len);
}
DEBUG("gcoap: Registered observer for: %s\n", memo->resource->path);
}
Expand Down Expand Up @@ -803,7 +803,7 @@ static void _find_req_memo(gcoap_request_memo_t **memo_ptr, coap_pkt_t *src_pdu,
}
} else if (coap_get_token_len(memo_pdu) == cmplen) {
memo_pdu->token = coap_hdr_data_ptr(memo_pdu->hdr);
if ((memcmp(src_pdu->token, memo_pdu->token, cmplen) == 0)
if ((memcmp(coap_get_token(src_pdu), memo_pdu->token, cmplen) == 0)
&& sock_udp_ep_equal(&memo->remote_ep, remote)) {
*memo_ptr = memo;
break;
Expand Down