FETCH Observe: Handle Observes when FETCH body is large

Assemble all the blocks before checking for Observe registration
or de-registration.

Track all the tokens used for the large FETCH registration and
re-use them for the de-registration as the server can elect to use
any of them when re-assembling the body for the registration Token.
This commit is contained in:
Jon Shallow authored and Jon Shallow committed 2022-11-30 11:35:25 +00:00
1 parent a152ca7cdb
commit 73b59182fd
8 files changed
+263 -119

No files matched your search

+7 -5
View File
@@ -122,7 +122,9 @@ struct coap_lg_crcv_t {
size_t total_len; /**< Length as indicated by SIZE2 option */
coap_binary_t *body_data; /**< Used for re-assembling entire body */
coap_binary_t *app_token; /**< app requesting PDU token */
coap_binary_t *obs_token; /**< Initial Observe response PDU token */
coap_binary_t **obs_token; /**< Tokens used in setting up Observe
(to handle large FETCH) */
size_t obs_token_cnt; /**< number of tokens used to set up Observe */
uint64_t state_token; /**< state token */
coap_pdu_t pdu; /**< skeletal PDU */
coap_rblock_t rec_blocks; /** < list of received blocks */
@@ -161,7 +163,8 @@ struct coap_lg_srcv_t {
#if COAP_CLIENT_SUPPORT
coap_lg_crcv_t * coap_block_new_lg_crcv(coap_session_t *session,
coap_pdu_t *pdu);
coap_pdu_t *pdu,
coap_lg_xmit_t *lg_xmit);
void coap_block_delete_lg_crcv(coap_session_t *session,
coap_lg_crcv_t *lg_crcv);
@@ -192,9 +195,8 @@ int coap_handle_request_put_block(coap_context_t *context,
coap_resource_t *resource,
coap_string_t *uri_path,
coap_opt_t *observe,
coap_string_t *query,
coap_method_handler_t h,
int *added_block);
int *added_block,
coap_lg_srcv_t **free_lg_srcv);
coap_lg_xmit_t * coap_find_lg_xmit_response(const coap_session_t *session,
const coap_pdu_t *request,
+4
View File
@@ -131,6 +131,10 @@ COAP_STATIC_INLINE void coap_memory_init(void) {}
memp_malloc(MEMP_ ## type) : NULL)
#define coap_free_type(type, p) memp_free(MEMP_ ## type, p)
/* As these are fixed size, return value if already defined */
#define coap_realloc_type(type, p, asize) \
((p) ? ((asize) <= memp_pools[MEMP_ ## type]->size) ? (p) : NULL : coap_malloc_type(type, asize))
/* Those are just here to make uri.c happy where string allocation has not been
* made conditional.
*/