-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sys/net/gcoap: get rid of API abuse #21125
Open
maribu
wants to merge
1
commit into
RIOT-OS:master
Choose a base branch
from
maribu:sys/net/gcoap/fix-api-abuse
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
github-actions
bot
added
Area: network
Area: Networking
Area: CoAP
Area: Constrained Application Protocol implementations
Area: sys
Area: System
labels
Jan 9, 2025
mguetschow
added
the
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
label
Jan 10, 2025
mguetschow
reviewed
Jan 10, 2025
maribu
force-pushed
the
sys/net/gcoap/fix-api-abuse
branch
from
January 10, 2025 16:23
f64472c
to
cbd44bb
Compare
I was so free to squash directly |
Sure! There's actually still the same problem in the other doc comments. |
maribu
force-pushed
the
sys/net/gcoap/fix-api-abuse
branch
from
January 10, 2025 16:25
cbd44bb
to
b7a8b01
Compare
benpicco
reviewed
Jan 10, 2025
benpicco
reviewed
Jan 10, 2025
benpicco
reviewed
Jan 10, 2025
benpicco
reviewed
Jan 10, 2025
Wait, there actually already is |
maribu
force-pushed
the
sys/net/gcoap/fix-api-abuse
branch
from
January 10, 2025 16:45
178cb6a
to
20d7bd3
Compare
benpicco
reviewed
Jan 10, 2025
maribu
force-pushed
the
sys/net/gcoap/fix-api-abuse
branch
from
January 10, 2025 20:10
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]>
maribu
force-pushed
the
sys/net/gcoap/fix-api-abuse
branch
from
January 10, 2025 20:31
482a91d
to
590ca5d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Area: CoAP
Area: Constrained Application Protocol implementations
Area: network
Area: Networking
Area: sys
Area: System
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
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_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.
Testing procedure
No change in behavior when using GCoAP.
Issues/PRs references
Not abusing the API by calling an (mostly) unitialized
coap_pkt_t
is 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_t
allows consistent use ofcoap_get_token()
.