request-tag: Add in support for sending Request-Tag option with every request

If multiple requests (apart from DELETE) are sent at the same time to
the same resource, and the responses need to make use of the Block2 option,
there is no way for the server to differentiate between which block set a
request (if there is a resource content change) is for unless a Request-Tag
is used.

Disable this functionality by setting COAP_BLOCK_NO_PREEMPTIVE_RTAG when
calling coap_context_set_block_mode().  Request-Tag will still be sent
with any request that includes Block1 option.
This commit is contained in:
Jon Shallow authored and Jon Shallow committed 2022-11-26 12:47:21 +00:00
1 parent 1b6498fab5
commit c9f40d7d09
8 files changed
+310 -233

No files matched your search

+1
View File
@@ -60,6 +60,7 @@ typedef struct {
#define COAP_BLOCK_USE_LIBCOAP 0x01 /* Use libcoap to do block requests */
#define COAP_BLOCK_SINGLE_BODY 0x02 /* Deliver the data as a single body */
#define COAP_BLOCK_NO_PREEMPTIVE_RTAG 0x10 /* Don't use pre-emptive Request-Tags */
/**
* Returns the value of the least significant byte of a Block option @p opt.
+19 -9
View File
@@ -70,8 +70,11 @@ typedef struct coap_l_block2_t {
coap_resource_t *resource; /**< associated resource */
coap_string_t *query; /**< Associated query for the resource */
uint64_t etag; /**< ETag value */
coap_time_t maxage_expire; /**< When this entry expires */
coap_pdu_code_t request_method; /**< Method used to request this data */
uint8_t rtag_set; /**< Set if RTag is in receive PDU */
uint8_t rtag_length; /**< RTag length */
uint8_t rtag[8]; /**< RTag for block checking */
coap_time_t maxage_expire; /**< When this entry expires */
} coap_l_block2_t;
/**
@@ -192,6 +195,11 @@ int coap_handle_request_put_block(coap_context_t *context,
coap_string_t *query,
coap_method_handler_t h,
int *added_block);
coap_lg_xmit_t * coap_find_lg_xmit_response(const coap_session_t *session,
const coap_pdu_t *request,
const coap_resource_t *resource,
const coap_string_t *query);
#endif /* COAP_SERVER_SUPPORT */
#if COAP_CLIENT_SUPPORT
@@ -216,15 +224,17 @@ int coap_block_check_lg_xmit_timeouts(coap_session_t *session,
* The function checks that the code in a newly formed lg_xmit created by
* coap_add_data_large_response() is updated.
*
* @param session The session
* @param response The response PDU to to check
* @param resource The requested resource
* @param query The requested query
* @param request_method The requested method
* @param session The session.
* @param request The request PDU to to check.
* @param response The response PDU to to update with response->code.
* @param resource The requested resource.
* @param query The requested query.
*/
void coap_check_code_lg_xmit(coap_session_t *session, coap_pdu_t *response,
coap_resource_t *resource, coap_string_t *query,
coap_pdu_code_t request_method);
void coap_check_code_lg_xmit(const coap_session_t *session,
const coap_pdu_t *request,
coap_pdu_t *response,
const coap_resource_t *resource,
const coap_string_t *query);
/** @} */