Skip to content

Update mbed-coap to version 4.8.0 #10620

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 1 commit into from
May 21, 2019
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
6 changes: 6 additions & 0 deletions features/frameworks/mbed-coap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [v4.8.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.8.0)
- Make `sn_coap_protocol_linked_list_duplication_info_remove` API to public. User might want to delete some messages from the duplicate list.
- Enable support for unified client configuration.

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

## [v4.7.4](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.7.4)

- Remove dependency to yotta tool
Expand Down
15 changes: 15 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 @@ -298,6 +298,21 @@ extern void sn_coap_protocol_send_rst(struct coap_s *handle, uint16_t msg_id, sn
*/
extern uint16_t sn_coap_protocol_get_configured_blockwise_size(struct coap_s *handle);

/**
* \fn void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle, const uint8_t *src_addr_ptr, const uint16_t port, const uint16_t msg_id);
*
* \brief Removes stored Duplication info from Linked list.
*
* \param *handle Pointer to CoAP library handle
* \param *addr_ptr is pointer to Address key to be removed
* \param port is Port key to be removed
* \param msg_id is Message ID key to be removed
*/
extern void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle,
const uint8_t *src_addr_ptr,
const uint16_t port,
const uint16_t msg_id);

#endif /* SN_COAP_PROTOCOL_H_ */

#ifdef __cplusplus
Expand Down
8 changes: 8 additions & 0 deletions features/frameworks/mbed-coap/mbed-coap/sn_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
#include MBED_CLIENT_USER_CONFIG_FILE
#endif

#ifdef MBED_CLOUD_CLIENT_USER_CONFIG_FILE
#include MBED_CLOUD_CLIENT_USER_CONFIG_FILE
#endif

#ifdef MBED_CLOUD_CLIENT_CONFIGURATION_ENABLED
#include "mbed-cloud-client/MbedCloudClientConfig.h"
#endif

/**
* \brief Configuration options (set of defines and values)
*
Expand Down
79 changes: 38 additions & 41 deletions features/frameworks/mbed-coap/source/sn_coap_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT/* If Message duplication detection is not used at all, this part of code will not be compiled */
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);
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);
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);
static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(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_coap_hdr_s *coap_msg_ptr, const int16_t data_size, const uint8_t *dst_packet_data_ptr);
#endif
Expand Down Expand Up @@ -1181,31 +1180,53 @@ static coap_duplication_info_s* sn_coap_protocol_linked_list_duplication_info_se
return NULL;
}



/**************************************************************************//**
* \fn static void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle, uint8_t *addr_ptr, uint16_t port, uint16_t msg_id)
*
* \brief Removes stored Duplication info from Linked list
*
* \param *addr_ptr is pointer to Address key to be removed
*
* \param port is Port key to be removed
* \fn static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(struct coap_s *handle)
*
* \param msg_id is Message ID key to be removed
* \brief Removes old stored Duplication detection infos from Linked list
*****************************************************************************/

static void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle, uint8_t *addr_ptr, uint16_t port, uint16_t msg_id)
static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(struct coap_s *handle)
{
/* Loop all stored duplication messages in Linked list */
ns_list_foreach_safe(coap_duplication_info_s, removed_duplication_info_ptr, &handle->linked_list_duplication_msgs) {
if ((handle->system_time - removed_duplication_info_ptr->timestamp) > SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED) {
/* * * * Old Duplication info found, remove it from Linked list * * * */
ns_list_remove(&handle->linked_list_duplication_msgs, removed_duplication_info_ptr);
--handle->count_duplication_msgs;

/* Free memory of stored Duplication info */
handle->sn_coap_protocol_free(removed_duplication_info_ptr->address->addr_ptr);
removed_duplication_info_ptr->address->addr_ptr = 0;
handle->sn_coap_protocol_free(removed_duplication_info_ptr->address);
removed_duplication_info_ptr->address = 0;
handle->sn_coap_protocol_free(removed_duplication_info_ptr->packet_ptr);
removed_duplication_info_ptr->packet_ptr = 0;
handle->sn_coap_protocol_free(removed_duplication_info_ptr);
removed_duplication_info_ptr = 0;
}
}
}

#endif /* SN_COAP_DUPLICATION_MAX_MSGS_COUNT */

void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle, const uint8_t *scr_addr_ptr, const uint16_t port, const uint16_t msg_id)
{
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
/* Loop all stored duplication messages in Linked list */
ns_list_foreach(coap_duplication_info_s, removed_duplication_info_ptr, &handle->linked_list_duplication_msgs) {
/* If message's Address is same than is searched */
if (handle == removed_duplication_info_ptr->coap && 0 == memcmp(addr_ptr,
if (handle == removed_duplication_info_ptr->coap && 0 == memcmp(scr_addr_ptr,
removed_duplication_info_ptr->address->addr_ptr,
removed_duplication_info_ptr->address->addr_len)) {
/* If message's Address prt is same than is searched */
if (removed_duplication_info_ptr->address->port == port) {
/* If Message ID is same than is searched */
if (removed_duplication_info_ptr->msg_id == msg_id) {
/* * * * Correct Duplication info found, remove it from Linked list * * * */
tr_info("sn_coap_protocol_linked_list_duplication_info_remove - message id %d removed", msg_id);
ns_list_remove(&handle->linked_list_duplication_msgs, removed_duplication_info_ptr);
--handle->count_duplication_msgs;

Expand All @@ -1223,38 +1244,14 @@ static void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *
}
}
}
#else
(void)handle;
(void)scr_addr_ptr;
(void)port;
(void)msg_id;
#endif //SN_COAP_DUPLICATION_MAX_MSGS_COUNT
}

/**************************************************************************//**
* \fn static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(struct coap_s *handle)
*
* \brief Removes old stored Duplication detection infos from Linked list
*****************************************************************************/

static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(struct coap_s *handle)
{
/* Loop all stored duplication messages in Linked list */
ns_list_foreach_safe(coap_duplication_info_s, removed_duplication_info_ptr, &handle->linked_list_duplication_msgs) {
if ((handle->system_time - removed_duplication_info_ptr->timestamp) > SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED) {
/* * * * Old Duplication info found, remove it from Linked list * * * */
ns_list_remove(&handle->linked_list_duplication_msgs, removed_duplication_info_ptr);
--handle->count_duplication_msgs;

/* Free memory of stored Duplication info */
handle->sn_coap_protocol_free(removed_duplication_info_ptr->address->addr_ptr);
removed_duplication_info_ptr->address->addr_ptr = 0;
handle->sn_coap_protocol_free(removed_duplication_info_ptr->address);
removed_duplication_info_ptr->address = 0;
handle->sn_coap_protocol_free(removed_duplication_info_ptr->packet_ptr);
removed_duplication_info_ptr->packet_ptr = 0;
handle->sn_coap_protocol_free(removed_duplication_info_ptr);
removed_duplication_info_ptr = 0;
}
}
}

#endif /* SN_COAP_DUPLICATION_MAX_MSGS_COUNT */

#if SN_COAP_BLOCKWISE_ENABLED || SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
/**************************************************************************//**
* \fn static void sn_coap_protocol_linked_list_blockwise_msg_remove(struct coap_s *handle, coap_blockwise_msg_s *removed_msg_ptr)
Expand Down