Skip to content

Commit 05babec

Browse files
authored
Merge pull request ARMmbed#13607 from teetak01/coap-5.1.7-for-master
Update Mbed CoAP to v5.1.7
2 parents f38aa59 + cbd3685 commit 05babec

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

connectivity/libraries/mbed-coap/CHANGELOG.md

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

3+
## [v5.1.7](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.7)
4+
5+
- Removed comparison of IP addresses when validating message resending. This avoids unnessary network errors due to load balancers causing frequent IP address changes.
6+
37
## [v5.1.6](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.6)
48

59
- Multiple fixes for out-ouf-bounds memory accesses, a memory leak and an infinite loop condition in packet parser.

connectivity/libraries/mbed-coap/source/sn_coap_protocol.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static uint32_t sn_coap_calculate_new_resend_time(const uint32_t cu
8585
static uint16_t read_packet_msg_id(const coap_send_msg_s *stored_msg);
8686
static uint16_t get_new_message_id(void);
8787

88-
static bool compare_address_and_port(const sn_nsdl_addr_s* left, const sn_nsdl_addr_s* right);
88+
static bool compare_port(const sn_nsdl_addr_s* left, const sn_nsdl_addr_s* right);
8989

9090
/* * * * * * * * * * * * * * * * * */
9191
/* * * * GLOBAL DECLARATIONS * * * */
@@ -829,10 +829,8 @@ sn_coap_hdr_s *sn_coap_protocol_parse(struct coap_s *handle, sn_nsdl_addr_s *src
829829

830830
/* Get node count i.e. count of active resending messages */
831831
uint16_t stored_resending_msgs_count = handle->count_resent_msgs;
832-
833832
/* Check if there is ongoing active message resendings */
834833
if (stored_resending_msgs_count > 0) {
835-
836834
/* Remove resending message from active message resending Linked list, if any exists */
837835
sn_coap_protocol_linked_list_send_msg_remove(handle, src_addr_ptr, returned_dst_coap_msg_ptr->msg_id);
838836
}
@@ -1013,13 +1011,12 @@ static void sn_coap_protocol_linked_list_send_msg_remove(struct coap_s *handle,
10131011
ns_list_foreach(coap_send_msg_s, stored_msg_ptr, &handle->linked_list_resent_msgs) {
10141012
/* Get message ID from stored resending message */
10151013
uint16_t temp_msg_id = read_packet_msg_id(stored_msg_ptr);
1016-
10171014
/* If message's Message ID is same than is searched */
10181015
if (temp_msg_id == msg_id) {
10191016
/* If message's Source address and port is same than is searched */
1020-
if (compare_address_and_port(src_addr_ptr, &stored_msg_ptr->send_msg_ptr.dst_addr_ptr)) {
1021-
/* * * Message found * * */
10221017

1018+
if (compare_port(src_addr_ptr, &stored_msg_ptr->send_msg_ptr.dst_addr_ptr)) {
1019+
/* * * Message found * * */
10231020
/* Remove message from Linked list */
10241021
ns_list_remove(&handle->linked_list_resent_msgs, stored_msg_ptr);
10251022
--handle->count_resent_msgs;
@@ -1142,7 +1139,7 @@ static coap_duplication_info_s* sn_coap_protocol_linked_list_duplication_info_se
11421139
/* If message's Message ID is same than is searched */
11431140
if (stored_duplication_info_ptr->msg_id == msg_id) {
11441141
/* If message's Source address & port is same than is searched */
1145-
if (compare_address_and_port(addr_ptr, stored_duplication_info_ptr->address)) {
1142+
if (compare_port(addr_ptr, stored_duplication_info_ptr->address)) {
11461143
/* * * Correct Duplication info found * * * */
11471144
return stored_duplication_info_ptr;
11481145
}
@@ -1911,7 +1908,7 @@ static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn
19111908
// Response with COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE if the payload size is more than we can handle
19121909
if (received_coap_msg_ptr->options_list_ptr->size1 > SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE) {
19131910
// Include maximum size that stack can handle into response
1914-
tr_error("sn_coap_handle_blockwise_message - (recv block1) COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE!");
1911+
tr_info("sn_coap_handle_blockwise_message - (recv block1) entity too large");
19151912
src_coap_blockwise_ack_msg_ptr->msg_code = COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE;
19161913
}
19171914
else {
@@ -1924,7 +1921,7 @@ static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn
19241921

19251922
if (block_size > handle->sn_coap_block_data_size) {
19261923
// Include maximum size that stack can handle into response
1927-
tr_error("sn_coap_handle_blockwise_message - (recv block1) COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE!");
1924+
tr_info("sn_coap_handle_blockwise_message - (recv block1) entity too large");
19281925
src_coap_blockwise_ack_msg_ptr->msg_code = COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE;
19291926
src_coap_blockwise_ack_msg_ptr->options_list_ptr->size1 = handle->sn_coap_block_data_size;
19301927
}
@@ -2521,14 +2518,11 @@ void *sn_coap_protocol_calloc(struct coap_s *handle, uint16_t length)
25212518
return result;
25222519
}
25232520

2524-
static bool compare_address_and_port(const sn_nsdl_addr_s* left, const sn_nsdl_addr_s* right)
2521+
static bool compare_port(const sn_nsdl_addr_s* left, const sn_nsdl_addr_s* right)
25252522
{
25262523
bool match = false;
2527-
25282524
if (left->port == right->port) {
2529-
if (0 == memcmp(left->addr_ptr, right->addr_ptr, left->addr_len)) {
2530-
match = true;
2531-
}
2525+
match = true;
25322526
}
25332527

25342528
return match;

0 commit comments

Comments
 (0)