@@ -120,30 +120,17 @@ int8_t sn_coap_protocol_destroy(struct coap_s *handle)
120
120
ns_list_foreach_safe (coap_blockwise_msg_s , tmp , & handle -> linked_list_blockwise_sent_msgs ) {
121
121
if (tmp -> coap == handle ) {
122
122
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 );
127
124
sn_coap_parser_release_allocated_coap_msg_mem (tmp -> coap , tmp -> coap_msg_ptr );
128
125
}
129
126
ns_list_remove (& handle -> linked_list_blockwise_sent_msgs , tmp );
130
127
handle -> sn_coap_protocol_free (tmp );
131
- tmp = 0 ;
132
128
}
133
129
}
130
+
134
131
ns_list_foreach_safe (coap_blockwise_payload_s , tmp , & handle -> linked_list_blockwise_received_payloads ) {
135
132
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 );
147
134
}
148
135
}
149
136
#endif
@@ -363,9 +350,42 @@ int8_t sn_coap_protocol_delete_retransmission(struct coap_s *handle, uint16_t ms
363
350
return -2 ;
364
351
}
365
352
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
+
366
383
367
384
int8_t prepare_blockwise_message (struct coap_s * handle , sn_coap_hdr_s * src_coap_msg_ptr )
368
385
{
386
+ (void ) handle ;
387
+ (void ) src_coap_msg_ptr ;
388
+
369
389
#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 */
370
390
if ((src_coap_msg_ptr -> payload_len > SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE ) &&
371
391
(src_coap_msg_ptr -> payload_len > handle -> sn_coap_block_data_size ) &&
0 commit comments