Skip to content

[mbed-os-5.15] Update mbed-coap to version v5.1.10 #14682

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
Jun 10, 2021
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
8 changes: 8 additions & 0 deletions features/frameworks/mbed-coap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Change Log
## [v5.1.10](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.10)

- Fix regression from previous release concerning 1024 byte blocksize operations.
- Do not store ACK's into duplicate list.

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

- Code size optimizations.

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

Expand Down
30 changes: 23 additions & 7 deletions features/frameworks/mbed-coap/Makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ TEST_MODULES = ./test_modules
TEST_MODULE_MBED_TRACE = $(TEST_MODULES)/mbed-trace
TEST_MODULE_NANOSTACK = $(TEST_MODULES)/nanostack-libservice
TEST_MODULE_RANDLIB = $(TEST_MODULES)/mbed-client-randlib
TEST_MODULE_CCPUTEST_VERSION = "v3.8"
TEST_MODULE_CPPUTEST = $(TEST_MODULES)/cpputest
TEST_MODULE_CPPUTEST_LIB = $(TEST_MODULE_CPPUTEST)/lib/libCppUTest.a

.PHONY: clone
clone:
Expand All @@ -33,30 +36,43 @@ clone:
if [ ! -d $(TEST_MODULE_RANDLIB) ]; \
then git clone --depth 1 [email protected]:ARMmbed/mbed-client-randlib.git $(TEST_MODULE_RANDLIB); \
fi;

if [ ! -d $(TEST_MODULE_CPPUTEST) ]; \
then git clone --single-branch -b $(TEST_MODULE_CCPUTEST_VERSION) https://github.com/cpputest/cpputest.git $(TEST_MODULE_CPPUTEST); \
fi;

.PHONY: test
test: $(TESTDIRS)
test: $(TEST_MODULE_CPPUTEST_LIB) $(TESTDIRS)
@rm -rf ./lcov
@rm -rf ./coverage
@rm -rf ./valgrind_logs
@mkdir -p lcov
@mkdir -p lcov/results
@mkdir coverage
@mkdir valgrind_logs
@find ./test -name '*.xml' | xargs cp -t ./lcov/results/
@rm -f lcov/index.xml
@./xsl_script.sh
@cp junit_xsl.xslt lcov/.
@xsltproc -o lcov/testresults.html lcov/junit_xsl.xslt lcov/index.xml
@rm -f lcov/junit_xsl.xslt
@rm -f lcov/index.xml
@find ./ -name '*.gcno' | xargs cp --backup=numbered -t ./coverage/
@find ./ -name '*.gcda' | xargs cp --backup=numbered -t ./coverage/
@gcovr --object-directory ./coverage --exclude-unreachable-branches -e '.*/builds/.*' -e '.*/CppUTest/.*' -e '.*/mbed-client-libservice/.*' -e '.*/test/.*' -e '.*/stubs/.*' -e '.*/mbed-coap/.*' -x -o ./lcov/gcovr.xml
@lcov -d test/. -c -o $(COVERAGEFILE)
@gcovr -r . --filter='.*/sn_coap_builder.c' --filter='.*/sn_coap_protocol.c' --filter='.*/sn_coap_parser.c' --filter='.*/sn_coap_header_check.c' -x -o ./lcov/gcovr.xml
@lcov -q -d test/. -c -o $(COVERAGEFILE)
@lcov -q -r $(COVERAGEFILE) "/usr*" -o $(COVERAGEFILE)
@lcov -q -r $(COVERAGEFILE) "/test*" -o $(COVERAGEFILE)
@lcov -q -r $(COVERAGEFILE) "/mbed-client-libservice*" -o $(COVERAGEFILE)
@lcov -q -r $(COVERAGEFILE) "*unittest*" -o $(COVERAGEFILE)
@lcov -q -r $(COVERAGEFILE) "*test_modules*" -o $(COVERAGEFILE)
@genhtml -q $(COVERAGEFILE) --show-details --output-directory lcov/html
@find ./test -name \valgrind*.xml -print0 | xargs -0 cp --target-directory=./valgrind_logs/
@echo mbed-coap module unit tests built

$(TEST_MODULE_CPPUTEST_LIB):
cd $(TEST_MODULE_CPPUTEST) && \
./autogen.sh && \
./configure --disable-memory-leak-detection && \
make && \
cd $(CUR_DIR); \

$(TESTDIRS):
@make -C $(@:build-%=%)

Expand Down
17 changes: 13 additions & 4 deletions features/frameworks/mbed-coap/mbed-coap/sn_coap_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#ifndef SN_COAP_HEADER_H_
#define SN_COAP_HEADER_H_

#include "sn_config.h"
#include "ns_types.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -180,8 +183,8 @@ typedef enum sn_coap_status_ {
*/
typedef struct sn_coap_options_list_ {
uint8_t etag_len; /**< 1-8 bytes. Repeatable */
unsigned int use_size1:1;
unsigned int use_size2:1;
bool use_size1;
bool use_size2;

uint16_t proxy_uri_len; /**< 1-1034 bytes. */
uint16_t uri_host_len; /**< 1-255 bytes. */
Expand Down Expand Up @@ -351,7 +354,10 @@ extern int16_t sn_coap_builder(uint8_t *dst_packet_data_ptr, const sn_coap_hdr_s
* \return Return value is count of needed memory as bytes for build Packet data
* Null if failed
*/
extern uint16_t sn_coap_builder_calc_needed_packet_data_size(const sn_coap_hdr_s *src_coap_msg_ptr);
extern uint16_t (sn_coap_builder_calc_needed_packet_data_size)(const sn_coap_hdr_s *src_coap_msg_ptr);
#ifdef SN_COAP_CONSTANT_NEEDED_SIZE
#define sn_coap_builder_calc_needed_packet_data_size(m) (SN_COAP_CONSTANT_NEEDED_SIZE)
#endif

/**
* \fn int16_t sn_coap_builder_2(uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_msg_ptr, uint16_t blockwise_size)
Expand Down Expand Up @@ -382,7 +388,10 @@ extern int16_t sn_coap_builder_2(uint8_t *dst_packet_data_ptr, const sn_coap_hdr
* \return Return value is count of needed memory as bytes for build Packet data
* Null if failed
*/
extern uint16_t sn_coap_builder_calc_needed_packet_data_size_2(const sn_coap_hdr_s *src_coap_msg_ptr, uint16_t blockwise_payload_size);
extern uint16_t (sn_coap_builder_calc_needed_packet_data_size_2)(const sn_coap_hdr_s *src_coap_msg_ptr, uint16_t blockwise_payload_size);
#ifdef SN_COAP_CONSTANT_NEEDED_SIZE
#define sn_coap_builder_calc_needed_packet_data_size_2(m, p) (SN_COAP_CONSTANT_NEEDED_SIZE)
#endif

/**
* \fn sn_coap_hdr_s *sn_coap_build_response(struct coap_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code)
Expand Down
17 changes: 17 additions & 0 deletions features/frameworks/mbed-coap/mbed-coap/sn_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@
#define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE 0 /**< Must be 2^x and x is at least 4. Suitable values: 0, 16, 32, 64, 128, 256, 512 and 1024 */
#endif

/**
* \def SN_COAP_CONSTANT_NEEDED_SIZE
* \brief Avoid needed size calculations
* If this is defined, sn_coap_builder_calc_needed_packet_data_size always returns that value,
* saving a lot of calculation code, at the cost of outgoing TX buffers being oversized, and
* with danger of them being undersized.
*
* sn_coap_builder_payload_build does not have any size input to limit its output, so it is
* always wise for users to assert that it has not output more than the size returned by
* sn_coap_builder_calc_needed_packet_size, whether this option is defined or not.
*/
#ifdef MBED_CONF_MBED_CLIENT_SN_COAP_CONSTANT_NEEDED_SIZE
#define SN_COAP_CONSTANT_NEEDED_SIZE MBED_CONF_MBED_CLIENT_SN_COAP_CONSTANT_NEEDED_SIZE
#endif

//#define SN_COAP_CONSTANT_NEEDED_SIZE 1024
Copy link
Contributor

Choose a reason for hiding this comment

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

Should remove redundant code rather than comment out


/**
* \def SN_COAP_DISABLE_RESENDINGS
* \brief Disables resending feature. Resending feature should not be needed
Expand Down
22 changes: 0 additions & 22 deletions features/frameworks/mbed-coap/run_unit_tests.sh

This file was deleted.

14 changes: 0 additions & 14 deletions features/frameworks/mbed-coap/run_unit_tests_with_valgrind.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ extern "C" {
* \brief This structure is returned by sn_coap_exec() for sending
*/
typedef struct sn_nsdl_transmit_ {
uint8_t *packet_ptr;
uint16_t packet_len;
sn_nsdl_addr_s dst_addr_ptr;

sn_nsdl_capab_e protocol;

uint16_t packet_len;
uint8_t *packet_ptr;
} sn_nsdl_transmit_s;

/* * * * * * * * * * * * * * * * * * * * * * */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int8_t prepare_blockwise_message(struct coap_s *handle, struct sn_coap_hdr_ *coa

/* Structure which is stored to Linked list for message sending purposes */
typedef struct coap_send_msg_ {
uint8_t resending_counter; /* Tells how many times message is still tried to resend */
uint_fast8_t resending_counter; /* Tells how many times message is still tried to resend */
uint32_t resending_time; /* Tells next resending time */

sn_nsdl_transmit_s send_msg_ptr;
Expand Down Expand Up @@ -86,25 +86,35 @@ typedef NS_LIST_HEAD(coap_blockwise_msg_s, link) coap_blockwise_msg_list_t;

/* Structure which is stored to Linked list for blockwise messages receiving purposes */
typedef struct coap_blockwise_payload_ {
uint32_t timestamp; /* Tells when Payload is stored to Linked list */

uint8_t addr_len;
uint8_t *addr_ptr;
uint8_t token_len;
bool use_size1;
uint16_t port;
uint16_t payload_len;
uint8_t *addr_ptr;
uint32_t block_number;
uint8_t *token_ptr;
uint8_t token_len;

uint16_t payload_len;
uint8_t *payload_ptr;
unsigned int use_size1:1;

uint32_t timestamp; /* Tells when Payload is stored to Linked list */
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the massive spacing? Are you using tabs instead of spaces ?

ns_list_link_t link;
} coap_blockwise_payload_s;

typedef NS_LIST_HEAD(coap_blockwise_payload_s, link) coap_blockwise_payload_list_t;

struct coap_s {
uint8_t sn_coap_resending_queue_msgs;
uint8_t sn_coap_resending_count;
uint8_t sn_coap_resending_intervall;
uint8_t sn_coap_duplication_buffer_size;
uint8_t sn_coap_internal_block2_resp_handling; /* If this is set then coap itself sends a next GET request automatically */
uint16_t sn_coap_block_data_size;
#if ENABLE_RESENDINGS
uint16_t count_resent_msgs;
#endif
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
uint16_t count_duplication_msgs;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the massive spacing here ?

#endif

void *(*sn_coap_protocol_malloc)(uint16_t);
void (*sn_coap_protocol_free)(void *);

Expand All @@ -113,12 +123,10 @@ struct coap_s {

#if ENABLE_RESENDINGS /* If Message resending is not used at all, this part of code will not be compiled */
coap_send_msg_list_t linked_list_resent_msgs; /* Active resending messages are stored to this Linked list */
uint16_t count_resent_msgs;
#endif

#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT /* If Message duplication detection is not used at all, this part of code will not be compiled */
coap_duplication_info_list_t linked_list_duplication_msgs; /* Messages for duplicated messages detection is stored to this Linked list */
uint16_t count_duplication_msgs;
#endif

#if SN_COAP_BLOCKWISE_ENABLED || SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* If Message blockwise is not enabled, this part of code will not be compiled */
Expand All @@ -127,20 +135,14 @@ struct coap_s {
#endif

uint32_t system_time; /* System time seconds */
uint16_t sn_coap_block_data_size;
uint8_t sn_coap_resending_queue_msgs;
uint32_t sn_coap_resending_queue_bytes;
uint8_t sn_coap_resending_count;
uint8_t sn_coap_resending_intervall;
uint8_t sn_coap_duplication_buffer_size;
uint8_t sn_coap_internal_block2_resp_handling; /* If this is set then coap itself sends a next GET request automatically */
};

/* Utility function which performs a call to sn_coap_protocol_malloc() and memset's the result to zero. */
void *sn_coap_protocol_calloc(struct coap_s *handle, uint16_t length);
void *sn_coap_protocol_calloc(struct coap_s *handle, uint_fast16_t length);

/* Utility function which performs a call to sn_coap_protocol_malloc() and memcopy's the source to result buffer. */
void *sn_coap_protocol_malloc_copy(struct coap_s *handle, const void *source, uint16_t length);
void *sn_coap_protocol_malloc_copy(struct coap_s *handle, const void *source, uint_fast16_t length);

#ifdef __cplusplus
}
Expand Down
Loading