Skip to content
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

block.c: Report 4.08 for missing Block1 chunks of data #1288

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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