Skip to content

Commit 8d6bc1d

Browse files
authored
Merge pull request #4455 from anttiylitokola/master
mbed-coap fixes
2 parents a41e08c + d399395 commit 8d6bc1d

File tree

4 files changed

+127
-56
lines changed

4 files changed

+127
-56
lines changed

features/FEATURE_COMMON_PAL/mbed-coap/module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mbed-coap",
3-
"version": "4.0.3",
3+
"version": "4.0.6",
44
"description": "COAP library",
55
"keywords": [
66
"coap",

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct sn_coap_hdr_;
7171
#define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES 512 /**< Maximum allowed size of re-sending buffer */
7272
#define SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT 40 /**< Maximum allowed re-sending timeout */
7373

74-
#define RESPONSE_RANDOM_FACTOR 1 /**< Resending random factor, value is specified in IETF CoAP specification */
74+
#define RESPONSE_RANDOM_FACTOR 1.5 /**< Resending random factor, value is specified in IETF CoAP specification */
7575

7676
/* * For Message duplication detecting * */
7777

@@ -113,9 +113,12 @@ struct sn_coap_hdr_;
113113
#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 */
114114
#endif
115115

116+
#ifdef MBED_CONF_MBED_CLIENT_SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
117+
#define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED MBED_CONF_MBED_CLIENT_SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
118+
#endif
116119

117120
#ifndef SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
118-
#define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED 10 /**< Maximum time in seconds of data (messages and payload) to be stored for blockwising */
121+
#define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED 60 /**< Maximum time in seconds of data (messages and payload) to be stored for blockwising */
119122
#endif
120123

121124
#ifdef YOTTA_CFG_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE
@@ -156,16 +159,13 @@ typedef NS_LIST_HEAD(coap_send_msg_s, link) coap_send_msg_list_t;
156159
/* Structure which is stored to Linked list for message duplication detection purposes */
157160
typedef struct coap_duplication_info_ {
158161
uint32_t timestamp; /* Tells when duplication information is stored to Linked list */
159-
160-
uint8_t addr_len;
161-
uint8_t *addr_ptr;
162-
uint16_t port;
163-
164162
uint16_t msg_id;
165-
163+
uint16_t packet_len;
164+
uint8_t *packet_ptr;
166165
struct coap_s *coap; /* CoAP library handle */
167-
168-
ns_list_link_t link;
166+
sn_nsdl_addr_s *address;
167+
void *param;
168+
ns_list_link_t link;
169169
} coap_duplication_info_s;
170170

171171
typedef NS_LIST_HEAD(coap_duplication_info_s, link) coap_duplication_info_list_t;

features/FEATURE_COMMON_PAL/mbed-coap/source/sn_coap_parser.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,6 @@ static int8_t sn_coap_parser_options_parse(struct coap_s *handle, uint8_t **pack
280280
/* Get option length WITHOUT extensions */
281281
uint16_t option_len = (**packet_data_pptr & 0x0F);
282282

283-
/* Option number length 15 is reserved for the future use - ERROR */
284-
if (option_len == 15) {
285-
return -1;
286-
}
287-
288283
/* Resolve option delta */
289284
uint16_t option_number = (**packet_data_pptr >> COAP_OPTIONS_OPTION_NUMBER_SHIFT);
290285

@@ -313,6 +308,10 @@ static int8_t sn_coap_parser_options_parse(struct coap_s *handle, uint8_t **pack
313308
option_len += (*(*packet_data_pptr + 1) << 8) + 269;
314309
(*packet_data_pptr) += 2;
315310
}
311+
/* Option number length 15 is reserved for the future use - ERROR */
312+
else if (option_len == 15) {
313+
return -1;
314+
}
316315

317316
message_left = packet_len - (*packet_data_pptr - packet_data_start_ptr);
318317

0 commit comments

Comments
 (0)