50
50
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT /* If Message duplication detection is not used at all, this part of code will not be compiled */
51
51
static void sn_coap_protocol_linked_list_duplication_info_store (struct coap_s * handle , sn_nsdl_addr_s * src_addr_ptr , uint16_t msg_id , void * param );
52
52
static coap_duplication_info_s * sn_coap_protocol_linked_list_duplication_info_search (const struct coap_s * handle , const sn_nsdl_addr_s * scr_addr_ptr , const uint16_t msg_id );
53
- static void sn_coap_protocol_linked_list_duplication_info_remove (struct coap_s * handle , uint8_t * scr_addr_ptr , uint16_t port , uint16_t msg_id );
54
53
static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones (struct coap_s * handle );
55
54
static bool sn_coap_protocol_update_duplicate_package_data (const struct coap_s * handle , const sn_nsdl_addr_s * dst_addr_ptr , const sn_coap_hdr_s * coap_msg_ptr , const int16_t data_size , const uint8_t * dst_packet_data_ptr );
56
55
#endif
@@ -1181,31 +1180,53 @@ static coap_duplication_info_s* sn_coap_protocol_linked_list_duplication_info_se
1181
1180
return NULL ;
1182
1181
}
1183
1182
1183
+
1184
+
1184
1185
/**************************************************************************/ /**
1185
- * \fn static void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle, uint8_t *addr_ptr, uint16_t port, uint16_t msg_id)
1186
- *
1187
- * \brief Removes stored Duplication info from Linked list
1188
- *
1189
- * \param *addr_ptr is pointer to Address key to be removed
1190
- *
1191
- * \param port is Port key to be removed
1186
+ * \fn static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(struct coap_s *handle)
1192
1187
*
1193
- * \param msg_id is Message ID key to be removed
1188
+ * \brief Removes old stored Duplication detection infos from Linked list
1194
1189
*****************************************************************************/
1195
1190
1196
- static void sn_coap_protocol_linked_list_duplication_info_remove (struct coap_s * handle , uint8_t * addr_ptr , uint16_t port , uint16_t msg_id )
1191
+ static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones (struct coap_s * handle )
1192
+ {
1193
+ /* Loop all stored duplication messages in Linked list */
1194
+ ns_list_foreach_safe (coap_duplication_info_s , removed_duplication_info_ptr , & handle -> linked_list_duplication_msgs ) {
1195
+ if ((handle -> system_time - removed_duplication_info_ptr -> timestamp ) > SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED ) {
1196
+ /* * * * Old Duplication info found, remove it from Linked list * * * */
1197
+ ns_list_remove (& handle -> linked_list_duplication_msgs , removed_duplication_info_ptr );
1198
+ -- handle -> count_duplication_msgs ;
1199
+
1200
+ /* Free memory of stored Duplication info */
1201
+ handle -> sn_coap_protocol_free (removed_duplication_info_ptr -> address -> addr_ptr );
1202
+ removed_duplication_info_ptr -> address -> addr_ptr = 0 ;
1203
+ handle -> sn_coap_protocol_free (removed_duplication_info_ptr -> address );
1204
+ removed_duplication_info_ptr -> address = 0 ;
1205
+ handle -> sn_coap_protocol_free (removed_duplication_info_ptr -> packet_ptr );
1206
+ removed_duplication_info_ptr -> packet_ptr = 0 ;
1207
+ handle -> sn_coap_protocol_free (removed_duplication_info_ptr );
1208
+ removed_duplication_info_ptr = 0 ;
1209
+ }
1210
+ }
1211
+ }
1212
+
1213
+ #endif /* SN_COAP_DUPLICATION_MAX_MSGS_COUNT */
1214
+
1215
+ void sn_coap_protocol_linked_list_duplication_info_remove (struct coap_s * handle , const uint8_t * scr_addr_ptr , const uint16_t port , const uint16_t msg_id )
1197
1216
{
1217
+ #if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
1198
1218
/* Loop all stored duplication messages in Linked list */
1199
1219
ns_list_foreach (coap_duplication_info_s , removed_duplication_info_ptr , & handle -> linked_list_duplication_msgs ) {
1200
1220
/* If message's Address is same than is searched */
1201
- if (handle == removed_duplication_info_ptr -> coap && 0 == memcmp (addr_ptr ,
1221
+ if (handle == removed_duplication_info_ptr -> coap && 0 == memcmp (scr_addr_ptr ,
1202
1222
removed_duplication_info_ptr -> address -> addr_ptr ,
1203
1223
removed_duplication_info_ptr -> address -> addr_len )) {
1204
1224
/* If message's Address prt is same than is searched */
1205
1225
if (removed_duplication_info_ptr -> address -> port == port ) {
1206
1226
/* If Message ID is same than is searched */
1207
1227
if (removed_duplication_info_ptr -> msg_id == msg_id ) {
1208
1228
/* * * * Correct Duplication info found, remove it from Linked list * * * */
1229
+ tr_info ("sn_coap_protocol_linked_list_duplication_info_remove - message id %d removed" , msg_id );
1209
1230
ns_list_remove (& handle -> linked_list_duplication_msgs , removed_duplication_info_ptr );
1210
1231
-- handle -> count_duplication_msgs ;
1211
1232
@@ -1223,38 +1244,14 @@ static void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *
1223
1244
}
1224
1245
}
1225
1246
}
1247
+ #else
1248
+ (void )handle ;
1249
+ (void )scr_addr_ptr ;
1250
+ (void )port ;
1251
+ (void )msg_id ;
1252
+ #endif //SN_COAP_DUPLICATION_MAX_MSGS_COUNT
1226
1253
}
1227
1254
1228
- /**************************************************************************/ /**
1229
- * \fn static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(struct coap_s *handle)
1230
- *
1231
- * \brief Removes old stored Duplication detection infos from Linked list
1232
- *****************************************************************************/
1233
-
1234
- static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones (struct coap_s * handle )
1235
- {
1236
- /* Loop all stored duplication messages in Linked list */
1237
- ns_list_foreach_safe (coap_duplication_info_s , removed_duplication_info_ptr , & handle -> linked_list_duplication_msgs ) {
1238
- if ((handle -> system_time - removed_duplication_info_ptr -> timestamp ) > SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED ) {
1239
- /* * * * Old Duplication info found, remove it from Linked list * * * */
1240
- ns_list_remove (& handle -> linked_list_duplication_msgs , removed_duplication_info_ptr );
1241
- -- handle -> count_duplication_msgs ;
1242
-
1243
- /* Free memory of stored Duplication info */
1244
- handle -> sn_coap_protocol_free (removed_duplication_info_ptr -> address -> addr_ptr );
1245
- removed_duplication_info_ptr -> address -> addr_ptr = 0 ;
1246
- handle -> sn_coap_protocol_free (removed_duplication_info_ptr -> address );
1247
- removed_duplication_info_ptr -> address = 0 ;
1248
- handle -> sn_coap_protocol_free (removed_duplication_info_ptr -> packet_ptr );
1249
- removed_duplication_info_ptr -> packet_ptr = 0 ;
1250
- handle -> sn_coap_protocol_free (removed_duplication_info_ptr );
1251
- removed_duplication_info_ptr = 0 ;
1252
- }
1253
- }
1254
- }
1255
-
1256
- #endif /* SN_COAP_DUPLICATION_MAX_MSGS_COUNT */
1257
-
1258
1255
#if SN_COAP_BLOCKWISE_ENABLED || SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
1259
1256
/**************************************************************************/ /**
1260
1257
* \fn static void sn_coap_protocol_linked_list_blockwise_msg_remove(struct coap_s *handle, coap_blockwise_msg_s *removed_msg_ptr)
0 commit comments