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/cache: Extend with option-only cache keygen #20043

Merged
merged 2 commits into from
Feb 13, 2024

Conversation

bergzand
Copy link
Member

@bergzand bergzand commented Nov 2, 2023

Contribution description

This adds a pair of functions to the nanocoap_cache module to generate cache keys only based on the options in a request. These can be used to correlate individual requests of a blockwise tranfer with each other. For example in a larger coreconf request.

It would still be up to the user to match the peers and the coap method code in the requests involved.

Testing procedure

I've extended the unittest for the nanocoap_cache module

Issues/PRs references

Could be useful for CORECONF and such.

@bergzand bergzand added the Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation label Nov 2, 2023
@github-actions github-actions bot added Area: network Area: Networking Area: tests Area: tests and testing framework Area: CoAP Area: Constrained Application Protocol implementations Area: sys Area: System labels Nov 2, 2023
@bergzand bergzand requested a review from chrysn November 2, 2023 15:33
@bergzand
Copy link
Member Author

bergzand commented Nov 3, 2023

Before I forget to mention it, this also modifies the digest a bit to include the option number in the digest.

@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 14, 2023
@riot-ci
Copy link

riot-ci commented Dec 14, 2023

Murdock results

✔️ PASSED

2c9bf3f unittests: Extend nanocoap_cache with option-only

Success Failures Total Runtime
10011 0 10011 15m:00s

Artifacts

Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you have a use for those functions.

* @param[in] req The request to generate the cache key from
* @param[out] cache_key The generated cache key
*/
void nanocoap_cache_key_options_generate(const coap_pkt_t *req, uint8_t *cache_key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void nanocoap_cache_key_options_generate(const coap_pkt_t *req, uint8_t *cache_key);
void nanocoap_cache_key_options_generate(const coap_pkt_t *req, void *cache_key);

* @param[in] req The request to generate the cache key from
* @param[out] cache_key The generated cache key
*/
void nanocoap_cache_key_blockreq_options_generate(const coap_pkt_t *req, uint8_t *cache_key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void nanocoap_cache_key_blockreq_options_generate(const coap_pkt_t *req, uint8_t *cache_key);
void nanocoap_cache_key_blockreq_options_generate(const coap_pkt_t *req, void *cache_key);

@bergzand
Copy link
Member Author

I suppose you have a use for those functions.

They're useful for correlating individual requests of a full CoAP blockwise transfer. Such as detecting that a client decided to restart the transfer.

To generate cache keys based on only the options of a request. This for
matching requests of a blockwise transfer with each other
@bergzand
Copy link
Member Author

bergzand commented Feb 12, 2024

They're useful for correlating individual requests of a full CoAP blockwise transfer. Such as detecting that a client decided to restart the transfer.

Just to clarify (as I would otherwise just be repeating what is already in the docs and the commit message, this is supposed to be used in blockwise handlers such as the post handler in the gcoap_block_server example to detect different parallel access to the resource and prevent the whole slew of issues that could happen

@benpicco benpicco added this pull request to the merge queue Feb 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 12, 2024
@benpicco benpicco added this pull request to the merge queue Feb 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 13, 2024
@benpicco benpicco added this pull request to the merge queue Feb 13, 2024
Merged via the queue into RIOT-OS:master with commit d08fb3f Feb 13, 2024
25 checks passed
@MrKevinWeiss MrKevinWeiss added this to the Release 2024.04 milestone Apr 30, 2024
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 Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants