Skip to content

Commit

Permalink
block.c: Report 4.08 for missing Block1 chunks of data
Browse files Browse the repository at this point in the history
Not applied to RFC9177 Q-Block1 missing blocks which are handled in
a different way.
  • Loading branch information
mrdeep1 committed Nov 23, 2023
1 parent 6b4fac9 commit 0613015
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/coap_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -2726,7 +2726,6 @@ coap_handle_request_put_block(coap_context_t *context,
p->uri_path = coap_new_str_const(uri_path->s, uri_path->length);
p->content_format = fmt;
p->total_len = total;
p->amount_so_far = length;
p->szx = block.szx;
p->block_option = block_option;
if (observe) {
Expand All @@ -2749,6 +2748,19 @@ coap_handle_request_put_block(coap_context_t *context,
response->code = COAP_RESPONSE_CODE(408);
goto free_lg_srcv;
}
#if COAP_Q_BLOCK_SUPPORT
if (block_option != COAP_OPTION_Q_BLOCK1) {
#endif /* COAP_Q_BLOCK_SUPPORT */
if (offset > p->amount_so_far) {
coap_add_data(response, sizeof("Missing block")-1,
(const uint8_t *)"Missing block");
response->code = COAP_RESPONSE_CODE(408);
goto free_lg_srcv;
}
p->amount_so_far += length;
#if COAP_Q_BLOCK_SUPPORT
}
#endif /* COAP_Q_BLOCK_SUPPORT */
#if COAP_Q_BLOCK_SUPPORT
if (block_option == COAP_OPTION_Q_BLOCK1) {
if (total != p->total_len) {
Expand Down Expand Up @@ -2845,7 +2857,16 @@ coap_handle_request_put_block(coap_context_t *context,
block.aszx),
buf);
response->code = COAP_RESPONSE_CODE(231);
goto skip_app_handler;
} else {
#if COAP_Q_BLOCK_SUPPORT
if (block_option != COAP_OPTION_Q_BLOCK1) {
#endif /* COAP_Q_BLOCK_SUPPORT */
coap_add_data(response, sizeof("Missing interim block")-1,
(const uint8_t *)"Missing interim block");
response->code = COAP_RESPONSE_CODE(408);
#if COAP_Q_BLOCK_SUPPORT
}
#endif /* COAP_Q_BLOCK_SUPPORT */
}
goto skip_app_handler;
}
Expand Down

0 comments on commit 0613015

Please sign in to comment.