-
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
nanocoap/cache: Extend with option-only cache keygen #20043
Conversation
Before I forget to mention it, this also modifies the digest a bit to include the option number in the digest. |
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.
I suppose you have a use for those functions.
sys/include/net/nanocoap/cache.h
Outdated
* @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); |
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.
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); |
sys/include/net/nanocoap/cache.h
Outdated
* @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); |
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.
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); |
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
db18cb7
to
2c9bf3f
Compare
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 |
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.