Skip to content

Update mbed-coap to version 4.6.1 #7739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions features/frameworks/mbed-coap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Change Log

## [v4.6.1](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.6.1)
**Closed issues:**
- IOTCLT-2900 - Blockwise handling leaking memory in some error cases

Fix unused parameter compiler warning when blockwise is not used.

-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.6.0...v4.6.1)

## [v4.6.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.6.0)
**New feature:**
- Add new API which clears one item from the resend queue based on token

-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.5.1...v4.6.0)

## [v4.5.1](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.5.1)
**Closed issues:**
- IOTCLT-2883 - Blockwise observations not completing
Expand Down
12 changes: 12 additions & 0 deletions features/frameworks/mbed-coap/mbed-coap/sn_coap_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,18 @@ extern void sn_coap_protocol_remove_sent_blockwise_message(struct coap_s *handle
*/
extern int8_t sn_coap_protocol_delete_retransmission(struct coap_s *handle, uint16_t msg_id);

/**
* \fn void sn_coap_protocol_delete_retransmission_by_token(struct coap_s *handle)
*
* \param *handle Pointer to CoAP library handle
* \token Token to be removed
* \token_len Length of the token
* \return returns 0 when success, -1 for invalid parameter, -2 if message was not found
*
* \brief If re-transmissions are enabled, this function removes message from retransmission buffer.
*/
extern int8_t sn_coap_protocol_delete_retransmission_by_token(struct coap_s *handle, uint8_t *token, uint8_t token_len);

/**
* \fn int8_t sn_coap_convert_block_size(uint16_t block_size)
*
Expand Down
2 changes: 1 addition & 1 deletion features/frameworks/mbed-coap/module.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mbed-coap",
"version": "4.5.1",
"version": "4.6.1",
"description": "COAP library",
"keywords": [
"coap",
Expand Down
52 changes: 36 additions & 16 deletions features/frameworks/mbed-coap/source/sn_coap_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,30 +120,17 @@ int8_t sn_coap_protocol_destroy(struct coap_s *handle)
ns_list_foreach_safe(coap_blockwise_msg_s, tmp, &handle->linked_list_blockwise_sent_msgs) {
if (tmp->coap == handle) {
if (tmp->coap_msg_ptr) {
if (tmp->coap_msg_ptr->payload_ptr) {
handle->sn_coap_protocol_free(tmp->coap_msg_ptr->payload_ptr);
tmp->coap_msg_ptr->payload_ptr = 0;
}
handle->sn_coap_protocol_free(tmp->coap_msg_ptr->payload_ptr);
sn_coap_parser_release_allocated_coap_msg_mem(tmp->coap, tmp->coap_msg_ptr);
}
ns_list_remove(&handle->linked_list_blockwise_sent_msgs, tmp);
handle->sn_coap_protocol_free(tmp);
tmp = 0;
}
}

ns_list_foreach_safe(coap_blockwise_payload_s, tmp, &handle->linked_list_blockwise_received_payloads) {
if (tmp->coap == handle) {
if (tmp->addr_ptr) {
handle->sn_coap_protocol_free(tmp->addr_ptr);
tmp->addr_ptr = 0;
}
if (tmp->payload_ptr) {
handle->sn_coap_protocol_free(tmp->payload_ptr);
tmp->payload_ptr = 0;
}
ns_list_remove(&handle->linked_list_blockwise_received_payloads, tmp);
handle->sn_coap_protocol_free(tmp);
tmp = 0;
sn_coap_protocol_linked_list_blockwise_payload_remove(handle, tmp);
}
}
#endif
Expand Down Expand Up @@ -363,9 +350,42 @@ int8_t sn_coap_protocol_delete_retransmission(struct coap_s *handle, uint16_t ms
return -2;
}

int8_t sn_coap_protocol_delete_retransmission_by_token(struct coap_s *handle, uint8_t *token, uint8_t token_len)
{
#if ENABLE_RESENDINGS /* If Message resending is not used at all, this part of code will not be compiled */
if (handle == NULL || token == NULL || token_len == 0) {
tr_error("sn_coap_protocol_delete_retransmission_by_token NULL");
return -1;
}

ns_list_foreach(coap_send_msg_s, stored_msg, &handle->linked_list_resent_msgs) {
uint8_t stored_token_len = (stored_msg->send_msg_ptr->packet_ptr[0] & 0x0F);
if (stored_token_len == token_len) {
uint8_t stored_token[8];
memcpy(stored_token, &stored_msg->send_msg_ptr->packet_ptr[4], stored_token_len);
if (memcmp(stored_token, token, stored_token_len) == 0) {
uint16_t temp_msg_id = (stored_msg->send_msg_ptr->packet_ptr[2] << 8);
temp_msg_id += (uint16_t)stored_msg->send_msg_ptr->packet_ptr[3];
tr_debug("sn_coap_protocol_delete_retransmission_by_token - removed msg_id: %d", temp_msg_id);
ns_list_remove(&handle->linked_list_resent_msgs, stored_msg);
--handle->count_resent_msgs;

/* Free memory of stored message */
sn_coap_protocol_release_allocated_send_msg_mem(handle, stored_msg);
return 0;
}
}
}
#endif
return -2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it correct that if if the #define is not enabled, this function will always return an error?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because this function handles cases where re-sending of messages is causing internal queue to be full hence there is a methodology to remove those messages. However, if the resending is not enabled then this function will always return error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to be sure, since the pattern looked strange.

}


int8_t prepare_blockwise_message(struct coap_s *handle, sn_coap_hdr_s *src_coap_msg_ptr)
{
(void) handle;
(void) src_coap_msg_ptr;

#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 ((src_coap_msg_ptr->payload_len > SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE) &&
(src_coap_msg_ptr->payload_len > handle->sn_coap_block_data_size) &&
Expand Down