sys/net/gcoap: get rid of API abuse#21125
Merged
benpicco merged 1 commit intoRIOT-OS:masterfrom Jan 14, 2025
Merged
Conversation
mguetschow
reviewed
Jan 10, 2025
f64472c to
cbd44bb
Compare
Member
Author
|
I was so free to squash directly |
Contributor
|
Sure! There's actually still the same problem in the other doc comments. |
cbd44bb to
b7a8b01
Compare
benpicco
reviewed
Jan 10, 2025
benpicco
reviewed
Jan 10, 2025
benpicco
reviewed
Jan 10, 2025
benpicco
reviewed
Jan 10, 2025
Member
Author
|
Wait, there actually already is |
178cb6a to
20d7bd3
Compare
benpicco
reviewed
Jan 10, 2025
14d3575 to
482a91d
Compare
Calling `coap_get_token()` and `coap_get_token_length()` on an (mostly) uninitialized `coap_pkt_t` did work so far due to implementation details matching the expectations, but this is not backed up by any API contract. This fixes the API abuse by introducing and using a new API that does read a token and token length from a CoAP over UDP packet out of a buffer. This now provides the behavior expected by the caller and commits to it via API contract. Co-authored-by: mguetschow <[email protected]> Co-authored-by: benpicco <[email protected]>
482a91d to
590ca5d
Compare
benpicco
approved these changes
Jan 13, 2025
Member
Author
|
Thx :-) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution description
Calling
coap_get_token()andcoap_get_token_length()on an (mostly) uninitializedcoap_pkt_tdid work so far due to implementation details matching the expectations, but this is not backed up by any API contract.This fixes the API abuse by introducing and using a new API that does read a token and token length from a CoAP over UDP packet out of a buffer. This now provides the behavior expected by the caller and commits to it via API contract.
Testing procedure
No change in behavior when using GCoAP.
Issues/PRs references
Not abusing the API by calling an (mostly) unitialized
coap_pkt_tis useful for adding other CoAP formats (e.g. as used for CoAP over TCP and CoAP over WebSocket), ascoap_get_token()will look into a different location depending on the format: For that, adding information needed to deduce the CoAP format to thecoap_pkt_tallows consistent use ofcoap_get_token().