mirror of https://github.com/ARMmbed/mbed-os.git
Update mbed-coap to version 5.1.5
BLOCK2 code-branch was missing handling for duplicate packets. As part of the fix, added also a call to update the duplicate package data via a new function sn_coap_protocol_update_duplicate_package_data_all. The new implementation handles all CoAP messages, not just those with COAP_MSG_TYPE_ACKNOWLEDGEMENT.pull/12866/head
parent
fe9f311a6d
commit
e254ce9975
|
@ -1,2 +1,3 @@
|
||||||
test/*
|
test/*
|
||||||
|
test_modules/*
|
||||||
unittest/*
|
unittest/*
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## [v5.1.5](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.5)
|
||||||
|
|
||||||
|
- Added handling for duplicate message handling for Block2 messages. Previously CoAP was silently ignoring the duplicate messages. Now proper response will be sent.
|
||||||
|
- Added extended version of `sn_coap_protocol_update_duplicate_package_data`, `sn_coap_protocol_update_duplicate_package_data_all` which will handle all CoAP data in the list.
|
||||||
|
|
||||||
## [v5.1.4](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.4)
|
## [v5.1.4](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.4)
|
||||||
|
|
||||||
- Add also 4.13 (Request Entity Too Large) responses to duplicate info list.
|
- Add also 4.13 (Request Entity Too Large) responses to duplicate info list.
|
||||||
|
|
|
@ -53,6 +53,8 @@ static coap_duplication_info_s *sn_coap_protocol_linked_list_duplication_info_se
|
||||||
static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(struct coap_s *handle);
|
static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(struct coap_s *handle);
|
||||||
static void sn_coap_protocol_duplication_info_free(struct coap_s *handle, coap_duplication_info_s *duplication_info_ptr);
|
static void sn_coap_protocol_duplication_info_free(struct coap_s *handle, coap_duplication_info_s *duplication_info_ptr);
|
||||||
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);
|
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);
|
||||||
|
static bool sn_coap_protocol_update_duplicate_package_data_all(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);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#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 */
|
#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 */
|
||||||
|
@ -690,6 +692,8 @@ sn_coap_hdr_s *sn_coap_protocol_parse(struct coap_s *handle, sn_nsdl_addr_s *src
|
||||||
tr_debug("sn_coap_protocol_parse - send ack for duplicate message");
|
tr_debug("sn_coap_protocol_parse - send ack for duplicate message");
|
||||||
handle->sn_coap_tx_callback(response->packet_ptr,
|
handle->sn_coap_tx_callback(response->packet_ptr,
|
||||||
response->packet_len, response->address, response->param);
|
response->packet_len, response->address, response->param);
|
||||||
|
} else {
|
||||||
|
tr_error("sn_coap_protocol_parse - response not yet build");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2235,6 +2239,20 @@ static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn
|
||||||
}
|
}
|
||||||
|
|
||||||
sn_coap_builder_2(dst_ack_packet_data_ptr, src_coap_blockwise_ack_msg_ptr, handle->sn_coap_block_data_size);
|
sn_coap_builder_2(dst_ack_packet_data_ptr, src_coap_blockwise_ack_msg_ptr, handle->sn_coap_block_data_size);
|
||||||
|
|
||||||
|
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
|
||||||
|
// copy coap data buffer to duplicate list for resending purposes
|
||||||
|
if (!sn_coap_protocol_update_duplicate_package_data_all(handle,
|
||||||
|
src_addr_ptr,
|
||||||
|
src_coap_blockwise_ack_msg_ptr,
|
||||||
|
dst_packed_data_needed_mem,
|
||||||
|
dst_ack_packet_data_ptr)) {
|
||||||
|
sn_coap_parser_release_allocated_coap_msg_mem(handle, src_coap_blockwise_ack_msg_ptr);
|
||||||
|
handle->sn_coap_protocol_free(dst_ack_packet_data_ptr);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
handle->sn_coap_tx_callback(dst_ack_packet_data_ptr, dst_packed_data_needed_mem, src_addr_ptr, param);
|
handle->sn_coap_tx_callback(dst_ack_packet_data_ptr, dst_packed_data_needed_mem, src_addr_ptr, param);
|
||||||
|
|
||||||
handle->sn_coap_protocol_free(dst_ack_packet_data_ptr);
|
handle->sn_coap_protocol_free(dst_ack_packet_data_ptr);
|
||||||
|
@ -2434,27 +2452,38 @@ static sn_coap_hdr_s *sn_coap_protocol_copy_header(struct coap_s *handle, const
|
||||||
|
|
||||||
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
|
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
|
||||||
static bool sn_coap_protocol_update_duplicate_package_data(const struct coap_s *handle,
|
static bool sn_coap_protocol_update_duplicate_package_data(const struct coap_s *handle,
|
||||||
const sn_nsdl_addr_s *dst_addr_ptr,
|
const sn_nsdl_addr_s *dst_addr_ptr,
|
||||||
const sn_coap_hdr_s *coap_msg_ptr,
|
const sn_coap_hdr_s *coap_msg_ptr,
|
||||||
const int16_t data_size,
|
const int16_t data_size,
|
||||||
const uint8_t *dst_packet_data_ptr)
|
const uint8_t *dst_packet_data_ptr)
|
||||||
{
|
{
|
||||||
if (coap_msg_ptr->msg_type == COAP_MSG_TYPE_ACKNOWLEDGEMENT &&
|
if (coap_msg_ptr->msg_type == COAP_MSG_TYPE_ACKNOWLEDGEMENT &&
|
||||||
handle->sn_coap_duplication_buffer_size != 0) {
|
handle->sn_coap_duplication_buffer_size != 0) {
|
||||||
coap_duplication_info_s* info = sn_coap_protocol_linked_list_duplication_info_search(handle,
|
return sn_coap_protocol_update_duplicate_package_data_all(handle, dst_addr_ptr, coap_msg_ptr, data_size, dst_packet_data_ptr);
|
||||||
dst_addr_ptr,
|
}
|
||||||
coap_msg_ptr->msg_id);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update package data to duplication info struct if it's not there yet */
|
static bool sn_coap_protocol_update_duplicate_package_data_all(const struct coap_s *handle,
|
||||||
if (info && info->packet_ptr == NULL) {
|
const sn_nsdl_addr_s *dst_addr_ptr,
|
||||||
info->packet_ptr = handle->sn_coap_protocol_malloc(data_size);
|
const sn_coap_hdr_s *coap_msg_ptr,
|
||||||
if (info->packet_ptr) {
|
const int16_t data_size,
|
||||||
memcpy(info->packet_ptr, dst_packet_data_ptr, data_size);
|
const uint8_t *dst_packet_data_ptr)
|
||||||
info->packet_len = data_size;
|
{
|
||||||
} else {
|
coap_duplication_info_s* info = sn_coap_protocol_linked_list_duplication_info_search(handle,
|
||||||
tr_error("sn_coap_protocol_update_duplication_package_data - failed to allocate duplication info!");
|
dst_addr_ptr,
|
||||||
return false;
|
coap_msg_ptr->msg_id);
|
||||||
}
|
|
||||||
|
/* Update package data to duplication info struct if it's not there yet */
|
||||||
|
if (info && info->packet_ptr == NULL) {
|
||||||
|
info->packet_ptr = handle->sn_coap_protocol_malloc(data_size);
|
||||||
|
if (info->packet_ptr) {
|
||||||
|
tr_debug("sn_coap_protocol_update_duplication_package_data - added to duplicate list!");
|
||||||
|
memcpy(info->packet_ptr, dst_packet_data_ptr, data_size);
|
||||||
|
info->packet_len = data_size;
|
||||||
|
} else {
|
||||||
|
tr_error("sn_coap_protocol_update_duplication_package_data - failed to allocate duplication info!");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue