Skip to content

Commit f5fb3c1

Browse files
authored
Merge pull request #7739 from anttiylitokola/master
Update mbed-coap to version 4.6.1
2 parents d719c9e + f78f560 commit f5fb3c1

File tree

4 files changed

+63
-17
lines changed

4 files changed

+63
-17
lines changed

features/frameworks/mbed-coap/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Change Log
22

3+
## [v4.6.1](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.6.1)
4+
**Closed issues:**
5+
- IOTCLT-2900 - Blockwise handling leaking memory in some error cases
6+
7+
Fix unused parameter compiler warning when blockwise is not used.
8+
9+
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.6.0...v4.6.1)
10+
11+
## [v4.6.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.6.0)
12+
**New feature:**
13+
- Add new API which clears one item from the resend queue based on token
14+
15+
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.5.1...v4.6.0)
16+
317
## [v4.5.1](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.5.1)
418
**Closed issues:**
519
- IOTCLT-2883 - Blockwise observations not completing

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,18 @@ extern void sn_coap_protocol_remove_sent_blockwise_message(struct coap_s *handle
224224
*/
225225
extern int8_t sn_coap_protocol_delete_retransmission(struct coap_s *handle, uint16_t msg_id);
226226

227+
/**
228+
* \fn void sn_coap_protocol_delete_retransmission_by_token(struct coap_s *handle)
229+
*
230+
* \param *handle Pointer to CoAP library handle
231+
* \token Token to be removed
232+
* \token_len Length of the token
233+
* \return returns 0 when success, -1 for invalid parameter, -2 if message was not found
234+
*
235+
* \brief If re-transmissions are enabled, this function removes message from retransmission buffer.
236+
*/
237+
extern int8_t sn_coap_protocol_delete_retransmission_by_token(struct coap_s *handle, uint8_t *token, uint8_t token_len);
238+
227239
/**
228240
* \fn int8_t sn_coap_convert_block_size(uint16_t block_size)
229241
*

features/frameworks/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.5.1",
3+
"version": "4.6.1",
44
"description": "COAP library",
55
"keywords": [
66
"coap",

features/frameworks/mbed-coap/source/sn_coap_protocol.c

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,30 +120,17 @@ int8_t sn_coap_protocol_destroy(struct coap_s *handle)
120120
ns_list_foreach_safe(coap_blockwise_msg_s, tmp, &handle->linked_list_blockwise_sent_msgs) {
121121
if (tmp->coap == handle) {
122122
if (tmp->coap_msg_ptr) {
123-
if (tmp->coap_msg_ptr->payload_ptr) {
124-
handle->sn_coap_protocol_free(tmp->coap_msg_ptr->payload_ptr);
125-
tmp->coap_msg_ptr->payload_ptr = 0;
126-
}
123+
handle->sn_coap_protocol_free(tmp->coap_msg_ptr->payload_ptr);
127124
sn_coap_parser_release_allocated_coap_msg_mem(tmp->coap, tmp->coap_msg_ptr);
128125
}
129126
ns_list_remove(&handle->linked_list_blockwise_sent_msgs, tmp);
130127
handle->sn_coap_protocol_free(tmp);
131-
tmp = 0;
132128
}
133129
}
130+
134131
ns_list_foreach_safe(coap_blockwise_payload_s, tmp, &handle->linked_list_blockwise_received_payloads) {
135132
if (tmp->coap == handle) {
136-
if (tmp->addr_ptr) {
137-
handle->sn_coap_protocol_free(tmp->addr_ptr);
138-
tmp->addr_ptr = 0;
139-
}
140-
if (tmp->payload_ptr) {
141-
handle->sn_coap_protocol_free(tmp->payload_ptr);
142-
tmp->payload_ptr = 0;
143-
}
144-
ns_list_remove(&handle->linked_list_blockwise_received_payloads, tmp);
145-
handle->sn_coap_protocol_free(tmp);
146-
tmp = 0;
133+
sn_coap_protocol_linked_list_blockwise_payload_remove(handle, tmp);
147134
}
148135
}
149136
#endif
@@ -363,9 +350,42 @@ int8_t sn_coap_protocol_delete_retransmission(struct coap_s *handle, uint16_t ms
363350
return -2;
364351
}
365352

353+
int8_t sn_coap_protocol_delete_retransmission_by_token(struct coap_s *handle, uint8_t *token, uint8_t token_len)
354+
{
355+
#if ENABLE_RESENDINGS /* If Message resending is not used at all, this part of code will not be compiled */
356+
if (handle == NULL || token == NULL || token_len == 0) {
357+
tr_error("sn_coap_protocol_delete_retransmission_by_token NULL");
358+
return -1;
359+
}
360+
361+
ns_list_foreach(coap_send_msg_s, stored_msg, &handle->linked_list_resent_msgs) {
362+
uint8_t stored_token_len = (stored_msg->send_msg_ptr->packet_ptr[0] & 0x0F);
363+
if (stored_token_len == token_len) {
364+
uint8_t stored_token[8];
365+
memcpy(stored_token, &stored_msg->send_msg_ptr->packet_ptr[4], stored_token_len);
366+
if (memcmp(stored_token, token, stored_token_len) == 0) {
367+
uint16_t temp_msg_id = (stored_msg->send_msg_ptr->packet_ptr[2] << 8);
368+
temp_msg_id += (uint16_t)stored_msg->send_msg_ptr->packet_ptr[3];
369+
tr_debug("sn_coap_protocol_delete_retransmission_by_token - removed msg_id: %d", temp_msg_id);
370+
ns_list_remove(&handle->linked_list_resent_msgs, stored_msg);
371+
--handle->count_resent_msgs;
372+
373+
/* Free memory of stored message */
374+
sn_coap_protocol_release_allocated_send_msg_mem(handle, stored_msg);
375+
return 0;
376+
}
377+
}
378+
}
379+
#endif
380+
return -2;
381+
}
382+
366383

367384
int8_t prepare_blockwise_message(struct coap_s *handle, sn_coap_hdr_s *src_coap_msg_ptr)
368385
{
386+
(void) handle;
387+
(void) src_coap_msg_ptr;
388+
369389
#if SN_COAP_BLOCKWISE_ENABLED || SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* If Message blockwising is not enabled, this part of code will not be compiled */
370390
if ((src_coap_msg_ptr->payload_len > SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE) &&
371391
(src_coap_msg_ptr->payload_len > handle->sn_coap_block_data_size) &&

0 commit comments

Comments
 (0)