diff --git a/features/frameworks/mbed-coap/CHANGELOG.md b/features/frameworks/mbed-coap/CHANGELOG.md index a2a27505797..17aafbd00e1 100644 --- a/features/frameworks/mbed-coap/CHANGELOG.md +++ b/features/frameworks/mbed-coap/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## [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 client library configurations for `DEFAULT_RESPONSE_TIMEOUT` and `SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED`. +- Increased the default timeouts of `DEFAULT_RESPONSE_TIMEOUT` and `SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED` to 300 seconds. + * These two are critical parameters for low-bandwidth high-latency networks. The defaults should be more geared towards such networks that are likely to have issues with transmissions. + * The increased defaults can increase the runtime HEAP usage when there is a lot of duplicates or retransmissions. + ## [v5.1.3](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.3) - Fix potential integer overflow when calculating CoAP data packet size: IOTCLT-3748 CVE-2019-17211 - mbed-coap integer overflow diff --git a/features/frameworks/mbed-coap/mbed-coap/sn_config.h b/features/frameworks/mbed-coap/mbed-coap/sn_config.h index f04ffe80c7a..a5c45caf43b 100644 --- a/features/frameworks/mbed-coap/mbed-coap/sn_config.h +++ b/features/frameworks/mbed-coap/mbed-coap/sn_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 ARM Limited. All rights reserved. + * Copyright (c) 2020 ARM Limited. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. @@ -98,6 +98,11 @@ * \brief Sets the CoAP re-send interval in seconds. * By default is 10 seconds. */ + +#ifdef MBED_CONF_MBED_CLIENT_DEFAULT_RESPONSE_TIMEOUT +#define DEFAULT_RESPONSE_TIMEOUT MBED_CONF_MBED_CLIENT_DEFAULT_RESPONSE_TIMEOUT +#endif + #ifndef DEFAULT_RESPONSE_TIMEOUT #define DEFAULT_RESPONSE_TIMEOUT 10 /**< Default re-sending timeout as seconds */ #endif @@ -219,8 +224,12 @@ * \brief Maximum time in seconds howe long message is kept for duplicate detection. * By default 60 seconds. */ +#ifdef MBED_CONF_MBED_CLIENT_SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED +#define SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED MBED_CONF_MBED_CLIENT_SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED +#endif + #ifndef SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED -#define SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED 60 /** RESPONSE_TIMEOUT * RESPONSE_RANDOM_FACTOR * (2 ^ MAX_RETRANSMIT - 1) + the expected maximum round trip time **/ +#define SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED 300 /** RESPONSE_TIMEOUT * RESPONSE_RANDOM_FACTOR * (2 ^ MAX_RETRANSMIT - 1) + the expected maximum round trip time **/ #endif /** @@ -234,7 +243,7 @@ #endif #ifndef SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED -#define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED 60 /**< Maximum time in seconds of data (messages and payload) to be stored for blockwising */ +#define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED 300 /**< Maximum time in seconds of data (messages and payload) to be stored for blockwising */ #endif /** diff --git a/features/frameworks/mbed-coap/source/sn_coap_protocol.c b/features/frameworks/mbed-coap/source/sn_coap_protocol.c index e3e156ead3c..0b86107f0e5 100644 --- a/features/frameworks/mbed-coap/source/sn_coap_protocol.c +++ b/features/frameworks/mbed-coap/source/sn_coap_protocol.c @@ -759,6 +759,14 @@ sn_coap_hdr_s *sn_coap_protocol_parse(struct coap_s *handle, sn_nsdl_addr_s *src goto cleanup; } +#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT + // copy data buffer to duplicate list for resending purposes + if (!sn_coap_protocol_update_duplicate_package_data(handle, src_addr_ptr, resp, packet_data_size, packet_data_ptr)) { + tr_error("sn_coap_protocol_parse - failed to update duplicate info!"); + goto cleanup; + } +#endif + sn_coap_parser_release_allocated_coap_msg_mem(handle, resp); handle->sn_coap_tx_callback(packet_data_ptr, packet_data_size, src_addr_ptr, param);