Skip to content

Commit 0fec52d

Browse files
authored
Merge pull request #5001 from anttiylitokola/master
Update mbed-coap to version 4.0.10
2 parents fc4afab + e7c8a4d commit 0fec52d

File tree

6 files changed

+121
-33
lines changed

6 files changed

+121
-33
lines changed

features/FEATURE_COMMON_PAL/mbed-coap/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## [v4.0.10](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.0.10)
4+
5+
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.0.9...v4.0.10)
6+
7+
**Closed issues:**
8+
- IOTMAC-615 Node mDS registration failure during OTA transfer
9+
310
## [v4.0.9](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.0.9)
411

512
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.0.8...v4.0.9)

features/FEATURE_COMMON_PAL/mbed-coap/module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mbed-coap",
3-
"version": "4.0.9",
3+
"version": "4.0.10",
44
"description": "COAP library",
55
"keywords": [
66
"coap",

features/FEATURE_COMMON_PAL/mbed-coap/source/sn_coap_builder.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ sn_coap_hdr_s *sn_coap_build_response(struct coap_s *handle, sn_coap_hdr_s *coap
5959

6060
coap_res_ptr = sn_coap_parser_alloc_message(handle);
6161
if (!coap_res_ptr) {
62+
tr_error("sn_coap_build_response - failed to allocate message!");
6263
return NULL;
6364
}
6465

@@ -83,6 +84,7 @@ sn_coap_hdr_s *sn_coap_build_response(struct coap_s *handle, sn_coap_hdr_s *coap
8384
coap_res_ptr->token_len = coap_packet_ptr->token_len;
8485
coap_res_ptr->token_ptr = handle->sn_coap_protocol_malloc(coap_res_ptr->token_len);
8586
if (!coap_res_ptr->token_ptr) {
87+
tr_error("sn_coap_build_response - failed to allocate token!");
8688
handle->sn_coap_protocol_free(coap_res_ptr);
8789
return NULL;
8890
}
@@ -98,7 +100,6 @@ int16_t sn_coap_builder(uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_ms
98100

99101
int16_t sn_coap_builder_2(uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_msg_ptr, uint16_t blockwise_payload_size)
100102
{
101-
tr_debug("sn_coap_builder_2");
102103
uint8_t *base_packet_data_ptr = NULL;
103104

104105
/* * * * Check given pointers * * * */
@@ -108,8 +109,8 @@ int16_t sn_coap_builder_2(uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_
108109

109110
/* Initialize given Packet data memory area with zero values */
110111
uint16_t dst_byte_count_to_be_built = sn_coap_builder_calc_needed_packet_data_size_2(src_coap_msg_ptr, blockwise_payload_size);
111-
tr_debug("sn_coap_builder_2 - message len: [%d]", dst_byte_count_to_be_built);
112112
if (!dst_byte_count_to_be_built) {
113+
tr_error("sn_coap_builder_2 - failed to allocate message!");
113114
return -1;
114115
}
115116

@@ -123,6 +124,7 @@ int16_t sn_coap_builder_2(uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_
123124
/* * * * * * * * * * * * * * * * * * */
124125
if (sn_coap_builder_header_build(&dst_packet_data_ptr, src_coap_msg_ptr) != 0) {
125126
/* Header building failed */
127+
tr_error("sn_coap_builder_2 - header building failed!");
126128
return -1;
127129
}
128130

@@ -149,7 +151,6 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size(sn_coap_hdr_s *src_coap_ms
149151
uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_msg_ptr, uint16_t blockwise_payload_size)
150152
{
151153
(void)blockwise_payload_size;
152-
tr_debug("sn_coap_builder_calc_needed_packet_data_size_2");
153154
uint16_t returned_byte_count = 0;
154155

155156
if (!src_coap_msg_ptr) {
@@ -168,6 +169,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
168169
/* TOKEN - Length is 1-8 bytes */
169170
if (src_coap_msg_ptr->token_ptr != NULL) {
170171
if (src_coap_msg_ptr->token_len > 8 || src_coap_msg_ptr->token_len < 1) { /* Check that option is not longer than defined */
172+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - token too large!");
171173
return 0;
172174
}
173175

@@ -180,6 +182,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
180182
if (repeatable_option_size) {
181183
returned_byte_count += repeatable_option_size;
182184
} else {
185+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - uri path size failed!");
183186
return 0;
184187
}
185188
}
@@ -188,6 +191,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
188191
/* CONTENT FORMAT - An integer option, up to 2 bytes */
189192
if (src_coap_msg_ptr->content_format != COAP_CT_NONE) {
190193
if ((uint32_t) src_coap_msg_ptr->content_format > 0xffff) {
194+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - content format too large!");
191195
return 0;
192196
}
193197

@@ -198,6 +202,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
198202
/* ACCEPT - An integer option, up to 2 bytes */
199203
if (src_coap_msg_ptr->options_list_ptr->accept != COAP_CT_NONE) {
200204
if ((uint32_t) src_coap_msg_ptr->options_list_ptr->accept > 0xffff) {
205+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - accept too large!");
201206
return 0;
202207
}
203208

@@ -222,6 +227,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
222227
}
223228

224229
else {
230+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - proxy uri too large!");
225231
return 0;
226232
}
227233

@@ -235,6 +241,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
235241
if (repeatable_option_size) {
236242
returned_byte_count += repeatable_option_size;
237243
} else {
244+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - etag too large!");
238245
return 0;
239246
}
240247
}
@@ -249,6 +256,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
249256
}
250257

251258
else {
259+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - uri host too large!");
252260
return 0;
253261
}
254262

@@ -261,12 +269,14 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
261269
if (repeatable_option_size) {
262270
returned_byte_count += repeatable_option_size;
263271
} else {
272+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - location path too large!");
264273
return 0;
265274
}
266275
}
267276
/* URI PORT - An integer option, up to 2 bytes */
268277
if (src_coap_msg_ptr->options_list_ptr->uri_port != COAP_OPTION_URI_PORT_NONE) {
269278
if ((uint32_t) src_coap_msg_ptr->options_list_ptr->uri_port > 0xffff) {
279+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - uri port too large!");
270280
return 0;
271281
}
272282
returned_byte_count += sn_coap_builder_options_build_add_uint_option(NULL, src_coap_msg_ptr->options_list_ptr->uri_port, COAP_OPTION_URI_PORT, &tempInt);
@@ -278,6 +288,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
278288
if (repeatable_option_size) {
279289
returned_byte_count += repeatable_option_size;
280290
} else {
291+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - location query too large!");
281292
return 0;
282293
}
283294
}
@@ -295,13 +306,15 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
295306
if (repeatable_option_size) {
296307
returned_byte_count += repeatable_option_size;
297308
} else {
309+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - observe too large!");
298310
return 0;
299311
}
300312
}
301313

302314
/* BLOCK 1 - An integer option, up to 3 bytes */
303315
if (src_coap_msg_ptr->options_list_ptr->block1 != COAP_OPTION_BLOCK_NONE) {
304316
if ((uint32_t) src_coap_msg_ptr->options_list_ptr->block1 > 0xffffff) {
317+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - block1 too large!");
305318
return 0;
306319
}
307320
returned_byte_count += sn_coap_builder_options_build_add_uint_option(NULL, src_coap_msg_ptr->options_list_ptr->block1, COAP_OPTION_BLOCK1, &tempInt);
@@ -313,6 +326,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
313326
/* BLOCK 2 - An integer option, up to 3 bytes */
314327
if (src_coap_msg_ptr->options_list_ptr->block2 != COAP_OPTION_BLOCK_NONE) {
315328
if ((uint32_t) src_coap_msg_ptr->options_list_ptr->block2 > 0xffffff) {
329+
tr_error("sn_coap_builder_calc_needed_packet_data_size_2 - block2 too large!");
316330
return 0;
317331
}
318332
returned_byte_count += sn_coap_builder_options_build_add_uint_option(NULL, src_coap_msg_ptr->options_list_ptr->block2, COAP_OPTION_BLOCK2, &tempInt);
@@ -483,6 +497,7 @@ static int8_t sn_coap_builder_header_build(uint8_t **dst_packet_data_pptr, sn_co
483497
{
484498
/* * * * Check validity of Header values * * * */
485499
if (sn_coap_header_validity_check(src_coap_msg_ptr, COAP_VERSION) != 0) {
500+
tr_error("sn_coap_builder_header_build - header build failed!");
486501
return -1;
487502
}
488503

@@ -526,6 +541,7 @@ static int8_t sn_coap_builder_options_build(uint8_t **dst_packet_data_pptr, sn_c
526541
/* * * * Check if Options are used at all * * * */
527542
if (src_coap_msg_ptr->uri_path_ptr == NULL && src_coap_msg_ptr->token_ptr == NULL &&
528543
src_coap_msg_ptr->content_format == COAP_CT_NONE && src_coap_msg_ptr->options_list_ptr == NULL) {
544+
tr_error("sn_coap_builder_options_build - options not used!");
529545
return 0;
530546
}
531547

features/FEATURE_COMMON_PAL/mbed-coap/source/sn_coap_header_check.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#include "mbed-coap/sn_coap_protocol.h"
3030
#include "sn_coap_header_internal.h"
3131
#include "sn_coap_protocol_internal.h"
32+
#include "mbed-trace/mbed_trace.h"
33+
34+
#define TRACE_GROUP "coap"
3235

3336
/**
3437
* \fn int8_t sn_coap_header_validity_check(sn_coap_hdr_s *src_coap_msg_ptr, coap_version_e coap_version)
@@ -56,6 +59,7 @@ int8_t sn_coap_header_validity_check(sn_coap_hdr_s *src_coap_msg_ptr, coap_versi
5659
case COAP_MSG_TYPE_RESET:
5760
break; /* Ok cases */
5861
default:
62+
tr_error("sn_coap_header_validity_check - unknown message type!");
5963
return -1; /* Failed case */
6064
}
6165

@@ -91,6 +95,7 @@ int8_t sn_coap_header_validity_check(sn_coap_hdr_s *src_coap_msg_ptr, coap_versi
9195
case COAP_MSG_CODE_RESPONSE_CONTINUE:
9296
break; /* Ok cases */
9397
default:
98+
tr_error("sn_coap_header_validity_check - unknown message code!");
9499
return -1; /* Failed case */
95100
}
96101

0 commit comments

Comments
 (0)