42
42
#include "MLE/mle.h"
43
43
#include "Service_Libs/mle_service/mle_service_api.h"
44
44
#include "Common_Protocols/icmpv6.h"
45
+ #include "Common_Protocols/ip.h"
45
46
#ifdef HAVE_RPL
46
47
#include "RPL/rpl_data.h"
47
48
#endif
@@ -93,6 +94,7 @@ typedef struct {
93
94
fragmenter_tx_list_t activeUnicastList ; //Unicast packets waiting data confirmation from MAC
94
95
buffer_list_t directTxQueue ; //Waiting free tx process
95
96
uint16_t directTxQueue_size ;
97
+ uint16_t activeTxList_size ;
96
98
uint16_t indirect_big_packet_threshold ;
97
99
uint16_t max_indirect_big_packets_total ;
98
100
uint16_t max_indirect_small_packets_per_child ;
@@ -103,6 +105,8 @@ typedef struct {
103
105
ns_list_link_t link ; /*!< List link entry */
104
106
} fragmenter_interface_t ;
105
107
108
+ #define LOWPAN_ACTIVE_UNICAST_ONGOING_MAX 10
109
+
106
110
static NS_LIST_DEFINE (fragmenter_interface_list , fragmenter_interface_t , link ) ;
107
111
108
112
/* Adaptation interface local functions */
@@ -365,6 +369,8 @@ int8_t lowpan_adaptation_interface_init(int8_t interface_id, uint16_t mac_mtu_si
365
369
ns_list_init (& interface_ptr -> indirect_tx_queue );
366
370
ns_list_init (& interface_ptr -> directTxQueue );
367
371
ns_list_init (& interface_ptr -> activeUnicastList );
372
+ interface_ptr -> activeTxList_size = 0 ;
373
+ interface_ptr -> directTxQueue_size = 0 ;
368
374
369
375
ns_list_add_to_end (& fragmenter_interface_list , interface_ptr );
370
376
@@ -390,13 +396,14 @@ int8_t lowpan_adaptation_interface_free(int8_t interface_id)
390
396
ns_list_remove (& fragmenter_interface_list , interface_ptr );
391
397
//free active tx process
392
398
lowpan_list_free (& interface_ptr -> activeUnicastList , false);
399
+ interface_ptr -> activeTxList_size = 0 ;
393
400
lowpan_active_buffer_state_reset (& interface_ptr -> active_broadcast_tx_buf );
394
401
395
402
//Free Indirect entry
396
403
lowpan_list_free (& interface_ptr -> indirect_tx_queue , true);
397
404
398
405
buffer_free_list (& interface_ptr -> directTxQueue );
399
-
406
+ interface_ptr -> directTxQueue_size = 0 ;
400
407
//Free Dynamic allocated entries
401
408
ns_dyn_mem_free (interface_ptr -> fragment_indirect_tx_buffer );
402
409
ns_dyn_mem_free (interface_ptr );
@@ -415,6 +422,7 @@ int8_t lowpan_adaptation_interface_reset(int8_t interface_id)
415
422
416
423
//free active tx process
417
424
lowpan_list_free (& interface_ptr -> activeUnicastList , false);
425
+ interface_ptr -> activeTxList_size = 0 ;
418
426
lowpan_active_buffer_state_reset (& interface_ptr -> active_broadcast_tx_buf );
419
427
//Clean fragmented message flag
420
428
interface_ptr -> fragmenter_active = false;
@@ -423,6 +431,7 @@ int8_t lowpan_adaptation_interface_reset(int8_t interface_id)
423
431
lowpan_list_free (& interface_ptr -> indirect_tx_queue , true);
424
432
425
433
buffer_free_list (& interface_ptr -> directTxQueue );
434
+ interface_ptr -> directTxQueue_size = 0 ;
426
435
427
436
return 0 ;
428
437
}
@@ -597,6 +606,7 @@ static fragmenter_tx_entry_t *lowpan_adaptation_tx_process_init(fragmenter_inter
597
606
return NULL ;
598
607
}
599
608
ns_list_add_to_end (& interface_ptr -> activeUnicastList , tx_entry );
609
+ interface_ptr -> activeTxList_size ++ ;
600
610
} else {
601
611
tx_entry = & interface_ptr -> active_broadcast_tx_buf ;
602
612
}
@@ -969,6 +979,10 @@ static bool lowpan_buffer_tx_allowed(fragmenter_interface_t *interface_ptr, buff
969
979
if (!is_unicast && interface_ptr -> active_broadcast_tx_buf .buf ) {
970
980
return false;
971
981
}
982
+
983
+ if (is_unicast && interface_ptr -> activeTxList_size >= LOWPAN_ACTIVE_UNICAST_ONGOING_MAX ) {
984
+ return false;
985
+ }
972
986
// Do not accept more than one active unicast TX per destination
973
987
if (is_unicast && lowpan_adaptation_is_destination_tx_active (& interface_ptr -> activeUnicastList , buf )) {
974
988
return false;
@@ -992,6 +1006,20 @@ int8_t lowpan_adaptation_interface_tx(protocol_interface_info_entry_t *cur, buff
992
1006
goto tx_error_handler ;
993
1007
}
994
1008
1009
+ uint8_t traffic_class = buf -> options .traffic_class >> IP_TCLASS_DSCP_SHIFT ;
1010
+ if (traffic_class ) {
1011
+ tr_debug ("TC %u, prority update" , traffic_class );
1012
+ }
1013
+ if (traffic_class == IP_DSCP_EF ) {
1014
+ buffer_priority_set (buf , QOS_EXPEDITE_FORWARD );
1015
+ } else if (traffic_class == IP_DSCP_CS6 ) {
1016
+ //Network Control
1017
+ buffer_priority_set (buf , QOS_NETWORK_CTRL );
1018
+ } else if (traffic_class ) {
1019
+ buffer_priority_set (buf , QOS_HIGH );
1020
+ }
1021
+
1022
+
995
1023
//Check packet size
996
1024
bool fragmented_needed = lowpan_adaptation_request_longer_than_mtu (cur , buf , interface_ptr );
997
1025
if (fragmented_needed ) {
@@ -1166,6 +1194,7 @@ static void lowpan_adaptation_data_process_clean(fragmenter_interface_t *interfa
1166
1194
} else if (buf -> link_specific .ieee802_15_4 .requestAck ) {
1167
1195
ns_list_remove (& interface_ptr -> activeUnicastList , tx_ptr );
1168
1196
ns_dyn_mem_free (tx_ptr );
1197
+ interface_ptr -> activeTxList_size -- ;
1169
1198
}
1170
1199
1171
1200
socket_tx_buffer_event_and_free (buf , socket_event );
0 commit comments