-
Notifications
You must be signed in to change notification settings - Fork 13
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
CoAP: early token generation #668
base: main
Are you sure you want to change the base?
Conversation
Remove prototype for function that is never defined. Signed-off-by: Mike Szczys <[email protected]>
Use a compile-time constant for the length of the CoAP token (in bytes). Signed-off-by: Mike Szczys <[email protected]>
Visit the preview URL for this PR (updated for commit 78973cc): https://golioth-firmware-sdk-doxygen-dev--pr668-szczys-coap-ea-xdhe9u8i.web.app (expires Tue, 19 Nov 2024 15:29:53 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: a9993e61697a3983f3479e468bcb0b616f9a0578 |
src/coap_client.c
Outdated
@@ -675,7 +675,7 @@ enum golioth_status golioth_coap_client_observe_release(struct golioth_client *c | |||
} | |||
strncpy(request_msg.path, path, sizeof(request_msg.path) - 1); | |||
|
|||
size_t t_len = min(token_len, sizeof(request_msg.token)); | |||
size_t t_len = min(token_len, GOLIOTH_COAP_TOKEN_LEN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is removed in one of the last commits on this PR that changes the param list for this function.
540c9f0
to
8794984
Compare
Codecov ReportAttention: Patch coverage is
|
Add golioth_coap_next_token() to randomly generate the first token and increment a stored value for all future tokens. Signed-off-by: Mike Szczys <[email protected]>
Squash before merging Signed-off-by: Mike Szczys <[email protected]>
Squash before merging Signed-off-by: Mike Szczys <[email protected]>
Squash before merge Signed-off-by: Mike Szczys <[email protected]>
Squash before merging Signed-off-by: Mike Szczys <[email protected]>
TODO: unit tests for RPC Signed-off-by: Mike Szczys <[email protected]>
Squash before merge Signed-off-by: Mike Szczys <[email protected]>
Squash before merge. Signed-off-by: Mike Szczys <[email protected]>
Squash before merge Signed-off-by: Mike Szczys <[email protected]>
Squah before merging Signed-off-by: Mike Szczys <[email protected]>
Tokens are now generated by the calling function. The same token will automatically be used for each subsequent block because of the blockwise_transfer context struct. The workaround that overwrite the initial token for these requests is no longer necessary and has been removed. Squash before merging Signed-off-by: Mike Szczys <[email protected]>
Directly use the token stored in the request message instead of creating a new one. Remove the block_token storage from the client struct. Squash before merging Signed-off-by: Mike Szczys <[email protected]>
CoAP tokens are now generated by the Golioth SDK outside of the libcoap library. The call to golioth_sys_srand() in the libcoap client is no longer crucial as it will be called by Golioth's token generation function. However, the random seed initialization for libcoap's token generation should still be called just to ensure token generation is ready in the rare (and currently unanticipated) case where libcoap internally fetches a new token. One place that this is likely to occur is when libcoap uses etags. We are not currently using etags in our implementation. Use dynamically allocated memory to seed the token. This value will be stored in the libcoap coap_session_t struct and the seed array will no longer be needed. Note, both Golioth and libcoap token generation uses a simple increment after generating the initial random token. Avoid collision by getting a token from Golioth and incrementing it by half its max value before seeding libcoap. Signed-off-by: Mike Szczys <[email protected]>
This value is now available as a compile-time constant. Squash before merge Signed-off-by: Mike Szczys <[email protected]>
Remove the token_len parameter as the compile-time define is now used throughout the SDK. Change the appearance and type of the token param to match what is used with other functions that create coap requests. Signed-off-by: Mike Szczys <[email protected]>
8794984
to
78973cc
Compare
The calling function (internal to SDK, not in userspace) is now responsible for generating CoAP tokens.
Most of these commits will be squashed before merge. I left it this way for (hopefully) easier review.
Resolves https://github.com/golioth/firmware-issue-tracker/issues/724