Skip to content

Commit 0f14f4b

Browse files
committed
Merge branch 'update_coap_to_4.7.2' of https://github.com/anttiylitokola/mbed-os-1 into dev_rollup
2 parents 80ed251 + 8d341ae commit 0f14f4b

File tree

4 files changed

+72
-22
lines changed

4 files changed

+72
-22
lines changed

features/frameworks/mbed-coap/CHANGELOG.md

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

3+
## [v4.7.2](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.7.2)
4+
5+
- Fix handling of duplicate blockwise ACK's
6+
CoAP data buffer was not added into duplication info store when creating response for blockwise request.
7+
This leads to case where whole bootstrap flow just timeouts if received any duplicate messages during blockwise operation.
8+
Fixes error: IOTCLT-3188 - UDP connection fails for lost ACK sending
9+
10+
- Remove error trace when building reset message without options
11+
This makes it possible to build the reset message without allocating option or getting error message.
12+
13+
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.7.1...v4.7.2)
14+
315
## [v4.7.1](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.7.1)
416

517
- Fix CoAP stored blockwise message release and list continue

features/frameworks/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.7.1",
3+
"version": "4.7.2",
44
"description": "COAP library",
55
"keywords": [
66
"coap",

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,10 @@ static int8_t sn_coap_builder_options_build(uint8_t **dst_packet_data_pptr, sn_c
547547
/* * * * Check if Options are used at all * * * */
548548
if (src_coap_msg_ptr->uri_path_ptr == NULL && src_coap_msg_ptr->token_ptr == NULL &&
549549
src_coap_msg_ptr->content_format == COAP_CT_NONE && src_coap_msg_ptr->options_list_ptr == NULL) {
550-
tr_error("sn_coap_builder_options_build - options not used!");
550+
/* If the empty message is confirmable it is CoAP ping. */
551+
if (src_coap_msg_ptr->msg_type != COAP_MSG_TYPE_CONFIRMABLE) {
552+
tr_error("sn_coap_builder_options_build - options not used!");
553+
}
551554
return 0;
552555
}
553556

features/frameworks/mbed-coap/source/sn_coap_protocol.c

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@
4949

5050
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT/* If Message duplication detection is not used at all, this part of code will not be compiled */
5151
static void sn_coap_protocol_linked_list_duplication_info_store(struct coap_s *handle, sn_nsdl_addr_s *src_addr_ptr, uint16_t msg_id, void *param);
52-
static coap_duplication_info_s *sn_coap_protocol_linked_list_duplication_info_search(struct coap_s *handle, sn_nsdl_addr_s *scr_addr_ptr, uint16_t msg_id);
52+
static coap_duplication_info_s *sn_coap_protocol_linked_list_duplication_info_search(const struct coap_s *handle, const sn_nsdl_addr_s *scr_addr_ptr, const uint16_t msg_id);
5353
static void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle, uint8_t *scr_addr_ptr, uint16_t port, uint16_t msg_id);
5454
static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(struct coap_s *handle);
55+
static bool sn_coap_protocol_update_duplicate_package_data(const struct coap_s *handle, const sn_nsdl_addr_s *dst_addr_ptr, const sn_coap_hdr_s *coap_msg_ptr, const int16_t data_size, const uint8_t *dst_packet_data_ptr);
5556
#endif
57+
5658
#if SN_COAP_BLOCKWISE_ENABLED || SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* If Message blockwising is not enabled, this part of code will not be compiled */
5759
static void sn_coap_protocol_linked_list_blockwise_msg_remove(struct coap_s *handle, coap_blockwise_msg_s *removed_msg_ptr);
5860
static void sn_coap_protocol_linked_list_blockwise_payload_store(struct coap_s *handle, sn_nsdl_addr_s *addr_ptr, uint16_t stored_payload_len, uint8_t *stored_payload_ptr, uint8_t *token_ptr, uint8_t token_len, uint32_t block_number);
@@ -65,6 +67,7 @@ static void sn_coap_protocol_handle_blockwise_timout(struct coa
6567
static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn_nsdl_addr_s *src_addr_ptr, sn_coap_hdr_s *received_coap_msg_ptr, void *param);
6668
static sn_coap_hdr_s *sn_coap_protocol_copy_header(struct coap_s *handle, sn_coap_hdr_s *source_header_ptr);
6769
#endif
70+
6871
#if ENABLE_RESENDINGS
6972
static uint8_t sn_coap_protocol_linked_list_send_msg_store(struct coap_s *handle, sn_nsdl_addr_s *dst_addr_ptr, uint16_t send_packet_data_len, uint8_t *send_packet_data_ptr, uint32_t sending_time, void *param);
7073
static sn_nsdl_transmit_s *sn_coap_protocol_linked_list_send_msg_search(struct coap_s *handle,sn_nsdl_addr_s *src_addr_ptr, uint16_t msg_id);
@@ -506,23 +509,12 @@ int16_t sn_coap_protocol_build(struct coap_s *handle, sn_nsdl_addr_s *dst_addr_p
506509
#endif /* ENABLE_RESENDINGS */
507510

508511
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
509-
if (src_coap_msg_ptr->msg_type == COAP_MSG_TYPE_ACKNOWLEDGEMENT &&
510-
handle->sn_coap_duplication_buffer_size != 0) {
511-
coap_duplication_info_s* info = sn_coap_protocol_linked_list_duplication_info_search(handle,
512-
dst_addr_ptr,
513-
src_coap_msg_ptr->msg_id);
514-
/* Update package data to duplication info struct if it's not there yet */
515-
if (info && info->packet_ptr == NULL) {
516-
info->packet_ptr = handle->sn_coap_protocol_malloc(byte_count_built);
517-
if (info->packet_ptr) {
518-
memcpy(info->packet_ptr, dst_packet_data_ptr, byte_count_built);
519-
info->packet_len = byte_count_built;
520-
} else {
521-
tr_error("sn_coap_protocol_build - failed to allocate duplication info!");
522-
return -4;
523-
}
524-
}
512+
513+
// copy coap data buffer to duplicate list for resending purposes
514+
if (!sn_coap_protocol_update_duplicate_package_data(handle, dst_addr_ptr, src_coap_msg_ptr, byte_count_built, dst_packet_data_ptr)) {
515+
return -4;
525516
}
517+
526518
#endif
527519

528520
#if SN_COAP_BLOCKWISE_ENABLED || SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* If Message blockwising is not enabled, this part of code will not be compiled */
@@ -725,6 +717,7 @@ sn_coap_hdr_s *sn_coap_protocol_parse(struct coap_s *handle, sn_nsdl_addr_s *src
725717
if (response) {
726718
/* Check that response has been created */
727719
if (response->packet_ptr) {
720+
tr_debug("sn_coap_protocol_parse - send ack for duplicate message");
728721
response->coap->sn_coap_tx_callback(response->packet_ptr,
729722
response->packet_len, response->address, response->param);
730723
}
@@ -1154,7 +1147,7 @@ static void sn_coap_protocol_linked_list_duplication_info_store(struct coap_s *h
11541147
}
11551148

11561149
/**************************************************************************//**
1157-
* \fn static int8_t sn_coap_protocol_linked_list_duplication_info_search(sn_nsdl_addr_s *addr_ptr, uint16_t msg_id)
1150+
* \fn static coap_duplication_info_s *sn_coap_protocol_linked_list_duplication_info_search(const struct coap_s *handle, const sn_nsdl_addr_s *scr_addr_ptr, const uint16_t msg_id)
11581151
*
11591152
* \brief Searches stored message from Linked list (Address and Message ID as key)
11601153
*
@@ -1164,8 +1157,8 @@ static void sn_coap_protocol_linked_list_duplication_info_store(struct coap_s *h
11641157
* \return Return value is 0 when message found and -1 if not found
11651158
*****************************************************************************/
11661159

1167-
static coap_duplication_info_s* sn_coap_protocol_linked_list_duplication_info_search(struct coap_s *handle,
1168-
sn_nsdl_addr_s *addr_ptr, uint16_t msg_id)
1160+
static coap_duplication_info_s* sn_coap_protocol_linked_list_duplication_info_search(const struct coap_s *handle,
1161+
const sn_nsdl_addr_s *addr_ptr, const uint16_t msg_id)
11691162
{
11701163
/* Loop all nodes in Linked list for searching Message ID */
11711164
ns_list_foreach(coap_duplication_info_s, stored_duplication_info_ptr, &handle->linked_list_duplication_msgs) {
@@ -2013,6 +2006,19 @@ static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn
20132006
}
20142007

20152008
sn_coap_builder_2(dst_ack_packet_data_ptr, src_coap_blockwise_ack_msg_ptr, handle->sn_coap_block_data_size);
2009+
2010+
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
2011+
// copy coap data buffer to duplicate list for resending purposes
2012+
if (!sn_coap_protocol_update_duplicate_package_data(handle,
2013+
src_addr_ptr,
2014+
src_coap_blockwise_ack_msg_ptr,
2015+
dst_packed_data_needed_mem,
2016+
dst_ack_packet_data_ptr)) {
2017+
sn_coap_parser_release_allocated_coap_msg_mem(handle, src_coap_blockwise_ack_msg_ptr);
2018+
handle->sn_coap_protocol_free(dst_ack_packet_data_ptr);
2019+
return NULL;
2020+
}
2021+
#endif
20162022
handle->sn_coap_tx_callback(dst_ack_packet_data_ptr, dst_packed_data_needed_mem, src_addr_ptr, param);
20172023

20182024
sn_coap_parser_release_allocated_coap_msg_mem(handle, src_coap_blockwise_ack_msg_ptr);
@@ -2509,3 +2515,32 @@ static sn_coap_hdr_s *sn_coap_protocol_copy_header(struct coap_s *handle, sn_coa
25092515
return destination_header_ptr;
25102516
}
25112517
#endif
2518+
2519+
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
2520+
static bool sn_coap_protocol_update_duplicate_package_data(const struct coap_s *handle,
2521+
const sn_nsdl_addr_s *dst_addr_ptr,
2522+
const sn_coap_hdr_s *coap_msg_ptr,
2523+
const int16_t data_size,
2524+
const uint8_t *dst_packet_data_ptr)
2525+
{
2526+
if (coap_msg_ptr->msg_type == COAP_MSG_TYPE_ACKNOWLEDGEMENT &&
2527+
handle->sn_coap_duplication_buffer_size != 0) {
2528+
coap_duplication_info_s* info = sn_coap_protocol_linked_list_duplication_info_search(handle,
2529+
dst_addr_ptr,
2530+
coap_msg_ptr->msg_id);
2531+
2532+
/* Update package data to duplication info struct if it's not there yet */
2533+
if (info && info->packet_ptr == NULL) {
2534+
info->packet_ptr = handle->sn_coap_protocol_malloc(data_size);
2535+
if (info->packet_ptr) {
2536+
memcpy(info->packet_ptr, dst_packet_data_ptr, data_size);
2537+
info->packet_len = data_size;
2538+
} else {
2539+
tr_error("sn_coap_protocol_update_duplication_package_data - failed to allocate duplication info!");
2540+
return false;
2541+
}
2542+
}
2543+
}
2544+
return true;
2545+
}
2546+
#endif

0 commit comments

Comments
 (0)