Skip to content

Commit ee201bc

Browse files
author
Antti Yli-Tokola
committed
[mbed-os-5.15] Update mbed-coap to version v5.1.10
- Fix regression from previous release concerning 1024 byte blocksize operations. - Do not store ACK's into duplicate list. - Code size optimizations
1 parent 769fc9d commit ee201bc

File tree

11 files changed

+556
-552
lines changed

11 files changed

+556
-552
lines changed

features/frameworks/mbed-coap/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# Change Log
2+
## [v5.1.10](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.10)
3+
4+
- Fix regression from previous release concerning 1024 byte blocksize operations.
5+
- Do not store ACK's into duplicate list.
6+
7+
## [v5.1.9](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.9)
8+
9+
- Code size optimizations.
210

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

features/frameworks/mbed-coap/Makefile.test

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ TEST_MODULES = ./test_modules
1515
TEST_MODULE_MBED_TRACE = $(TEST_MODULES)/mbed-trace
1616
TEST_MODULE_NANOSTACK = $(TEST_MODULES)/nanostack-libservice
1717
TEST_MODULE_RANDLIB = $(TEST_MODULES)/mbed-client-randlib
18+
TEST_MODULE_CCPUTEST_VERSION = "v3.8"
19+
TEST_MODULE_CPPUTEST = $(TEST_MODULES)/cpputest
20+
TEST_MODULE_CPPUTEST_LIB = $(TEST_MODULE_CPPUTEST)/lib/libCppUTest.a
1821

1922
.PHONY: clone
2023
clone:
@@ -33,30 +36,43 @@ clone:
3336
if [ ! -d $(TEST_MODULE_RANDLIB) ]; \
3437
then git clone --depth 1 git@github.com:ARMmbed/mbed-client-randlib.git $(TEST_MODULE_RANDLIB); \
3538
fi;
39+
40+
if [ ! -d $(TEST_MODULE_CPPUTEST) ]; \
41+
then git clone --single-branch -b $(TEST_MODULE_CCPUTEST_VERSION) https://github.com/cpputest/cpputest.git $(TEST_MODULE_CPPUTEST); \
42+
fi;
43+
3644
.PHONY: test
37-
test: $(TESTDIRS)
45+
test: $(TEST_MODULE_CPPUTEST_LIB) $(TESTDIRS)
3846
@rm -rf ./lcov
3947
@rm -rf ./coverage
48+
@rm -rf ./valgrind_logs
4049
@mkdir -p lcov
4150
@mkdir -p lcov/results
4251
@mkdir coverage
52+
@mkdir valgrind_logs
4353
@find ./test -name '*.xml' | xargs cp -t ./lcov/results/
4454
@rm -f lcov/index.xml
4555
@./xsl_script.sh
4656
@cp junit_xsl.xslt lcov/.
4757
@xsltproc -o lcov/testresults.html lcov/junit_xsl.xslt lcov/index.xml
4858
@rm -f lcov/junit_xsl.xslt
4959
@rm -f lcov/index.xml
50-
@find ./ -name '*.gcno' | xargs cp --backup=numbered -t ./coverage/
51-
@find ./ -name '*.gcda' | xargs cp --backup=numbered -t ./coverage/
52-
@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
53-
@lcov -d test/. -c -o $(COVERAGEFILE)
60+
@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
61+
@lcov -q -d test/. -c -o $(COVERAGEFILE)
5462
@lcov -q -r $(COVERAGEFILE) "/usr*" -o $(COVERAGEFILE)
55-
@lcov -q -r $(COVERAGEFILE) "/test*" -o $(COVERAGEFILE)
56-
@lcov -q -r $(COVERAGEFILE) "/mbed-client-libservice*" -o $(COVERAGEFILE)
63+
@lcov -q -r $(COVERAGEFILE) "*unittest*" -o $(COVERAGEFILE)
64+
@lcov -q -r $(COVERAGEFILE) "*test_modules*" -o $(COVERAGEFILE)
5765
@genhtml -q $(COVERAGEFILE) --show-details --output-directory lcov/html
66+
@find ./test -name \valgrind*.xml -print0 | xargs -0 cp --target-directory=./valgrind_logs/
5867
@echo mbed-coap module unit tests built
5968

69+
$(TEST_MODULE_CPPUTEST_LIB):
70+
cd $(TEST_MODULE_CPPUTEST) && \
71+
./autogen.sh && \
72+
./configure --disable-memory-leak-detection && \
73+
make && \
74+
cd $(CUR_DIR); \
75+
6076
$(TESTDIRS):
6177
@make -C $(@:build-%=%)
6278

features/frameworks/mbed-coap/mbed-coap/sn_coap_header.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#ifndef SN_COAP_HEADER_H_
2424
#define SN_COAP_HEADER_H_
2525

26+
#include "sn_config.h"
27+
#include "ns_types.h"
28+
2629
#ifdef __cplusplus
2730
extern "C" {
2831
#endif
@@ -180,8 +183,8 @@ typedef enum sn_coap_status_ {
180183
*/
181184
typedef struct sn_coap_options_list_ {
182185
uint8_t etag_len; /**< 1-8 bytes. Repeatable */
183-
unsigned int use_size1:1;
184-
unsigned int use_size2:1;
186+
bool use_size1;
187+
bool use_size2;
185188

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

356362
/**
357363
* \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)
@@ -382,7 +388,10 @@ extern int16_t sn_coap_builder_2(uint8_t *dst_packet_data_ptr, const sn_coap_hdr
382388
* \return Return value is count of needed memory as bytes for build Packet data
383389
* Null if failed
384390
*/
385-
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);
391+
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);
392+
#ifdef SN_COAP_CONSTANT_NEEDED_SIZE
393+
#define sn_coap_builder_calc_needed_packet_data_size_2(m, p) (SN_COAP_CONSTANT_NEEDED_SIZE)
394+
#endif
386395

387396
/**
388397
* \fn sn_coap_hdr_s *sn_coap_build_response(struct coap_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code)

features/frameworks/mbed-coap/mbed-coap/sn_config.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,23 @@
6868
#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 */
6969
#endif
7070

71+
/**
72+
* \def SN_COAP_CONSTANT_NEEDED_SIZE
73+
* \brief Avoid needed size calculations
74+
* If this is defined, sn_coap_builder_calc_needed_packet_data_size always returns that value,
75+
* saving a lot of calculation code, at the cost of outgoing TX buffers being oversized, and
76+
* with danger of them being undersized.
77+
*
78+
* sn_coap_builder_payload_build does not have any size input to limit its output, so it is
79+
* always wise for users to assert that it has not output more than the size returned by
80+
* sn_coap_builder_calc_needed_packet_size, whether this option is defined or not.
81+
*/
82+
#ifdef MBED_CONF_MBED_CLIENT_SN_COAP_CONSTANT_NEEDED_SIZE
83+
#define SN_COAP_CONSTANT_NEEDED_SIZE MBED_CONF_MBED_CLIENT_SN_COAP_CONSTANT_NEEDED_SIZE
84+
#endif
85+
86+
//#define SN_COAP_CONSTANT_NEEDED_SIZE 1024
87+
7188
/**
7289
* \def SN_COAP_DISABLE_RESENDINGS
7390
* \brief Disables resending feature. Resending feature should not be needed

features/frameworks/mbed-coap/run_unit_tests.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

features/frameworks/mbed-coap/run_unit_tests_with_valgrind.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

features/frameworks/mbed-coap/source/include/sn_coap_header_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ extern "C" {
5858
* \brief This structure is returned by sn_coap_exec() for sending
5959
*/
6060
typedef struct sn_nsdl_transmit_ {
61+
uint8_t *packet_ptr;
62+
uint16_t packet_len;
6163
sn_nsdl_addr_s dst_addr_ptr;
6264

6365
sn_nsdl_capab_e protocol;
6466

65-
uint16_t packet_len;
66-
uint8_t *packet_ptr;
6767
} sn_nsdl_transmit_s;
6868

6969
/* * * * * * * * * * * * * * * * * * * * * * */

features/frameworks/mbed-coap/source/include/sn_coap_protocol_internal.h

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int8_t prepare_blockwise_message(struct coap_s *handle, struct sn_coap_hdr_ *coa
4545

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

5151
sn_nsdl_transmit_s send_msg_ptr;
@@ -86,25 +86,35 @@ typedef NS_LIST_HEAD(coap_blockwise_msg_s, link) coap_blockwise_msg_list_t;
8686

8787
/* Structure which is stored to Linked list for blockwise messages receiving purposes */
8888
typedef struct coap_blockwise_payload_ {
89-
uint32_t timestamp; /* Tells when Payload is stored to Linked list */
90-
9189
uint8_t addr_len;
92-
uint8_t *addr_ptr;
90+
uint8_t token_len;
91+
bool use_size1;
9392
uint16_t port;
93+
uint16_t payload_len;
94+
uint8_t *addr_ptr;
9495
uint32_t block_number;
9596
uint8_t *token_ptr;
96-
uint8_t token_len;
97-
98-
uint16_t payload_len;
9997
uint8_t *payload_ptr;
100-
unsigned int use_size1:1;
101-
98+
uint32_t timestamp; /* Tells when Payload is stored to Linked list */
10299
ns_list_link_t link;
103100
} coap_blockwise_payload_s;
104101

105102
typedef NS_LIST_HEAD(coap_blockwise_payload_s, link) coap_blockwise_payload_list_t;
106103

107104
struct coap_s {
105+
uint8_t sn_coap_resending_queue_msgs;
106+
uint8_t sn_coap_resending_count;
107+
uint8_t sn_coap_resending_intervall;
108+
uint8_t sn_coap_duplication_buffer_size;
109+
uint8_t sn_coap_internal_block2_resp_handling; /* If this is set then coap itself sends a next GET request automatically */
110+
uint16_t sn_coap_block_data_size;
111+
#if ENABLE_RESENDINGS
112+
uint16_t count_resent_msgs;
113+
#endif
114+
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
115+
uint16_t count_duplication_msgs;
116+
#endif
117+
108118
void *(*sn_coap_protocol_malloc)(uint16_t);
109119
void (*sn_coap_protocol_free)(void *);
110120

@@ -113,12 +123,10 @@ struct coap_s {
113123

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

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

124132
#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 */
@@ -127,20 +135,14 @@ struct coap_s {
127135
#endif
128136

129137
uint32_t system_time; /* System time seconds */
130-
uint16_t sn_coap_block_data_size;
131-
uint8_t sn_coap_resending_queue_msgs;
132138
uint32_t sn_coap_resending_queue_bytes;
133-
uint8_t sn_coap_resending_count;
134-
uint8_t sn_coap_resending_intervall;
135-
uint8_t sn_coap_duplication_buffer_size;
136-
uint8_t sn_coap_internal_block2_resp_handling; /* If this is set then coap itself sends a next GET request automatically */
137139
};
138140

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

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

145147
#ifdef __cplusplus
146148
}

0 commit comments

Comments
 (0)