nanocoap/cache: Extend with option-only cache keygen#20043
nanocoap/cache: Extend with option-only cache keygen#20043benpicco merged 2 commits intoRIOT-OS:masterfrom
Conversation
|
Before I forget to mention it, this also modifies the digest a bit to include the option number in the digest. |
benpicco
left a comment
There was a problem hiding this comment.
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.
| 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.
| 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.