Commit fcc75c6a authored by Ilia Penev's avatar Ilia Penev Committed by Cesanta Bot

Fix CoAP packet size calculation

PUBLISHED_FROM=43532ec3951779d17438b457fe6de6dea8f514fd
parent e08b2343
...@@ -9694,7 +9694,7 @@ static uint32_t coap_calculate_packet_size(struct mg_coap_message *cm, ...@@ -9694,7 +9694,7 @@ static uint32_t coap_calculate_packet_size(struct mg_coap_message *cm,
prev_opt_number = 0; prev_opt_number = 0;
while (opt != NULL) { while (opt != NULL) {
*len += 1; /* basic delta/length */ *len += 1; /* basic delta/length */
*len += coap_get_ext_opt_size(opt->number); *len += coap_get_ext_opt_size(opt->number - prev_opt_number);
*len += coap_get_ext_opt_size((uint32_t) opt->value.len); *len += coap_get_ext_opt_size((uint32_t) opt->value.len);
/* /*
* Current implementation performs check if * Current implementation performs check if
...@@ -9708,6 +9708,7 @@ static uint32_t coap_calculate_packet_size(struct mg_coap_message *cm, ...@@ -9708,6 +9708,7 @@ static uint32_t coap_calculate_packet_size(struct mg_coap_message *cm,
return MG_COAP_ERROR | MG_COAP_OPTIOMG_FIELD; return MG_COAP_ERROR | MG_COAP_OPTIOMG_FIELD;
} }
*len += opt->value.len; *len += opt->value.len;
prev_opt_number = opt->number;
opt = opt->next; opt = opt->next;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment