63
63
#if defined(HAVE_THREAD_V2 ) && defined(HAVE_THREAD_BORDER_ROUTER )
64
64
#define TRACE_GROUP "pBBR"
65
65
66
+ static uint8_t dua_response_status = 0xff ;
67
+ static uint8_t dua_status_count = 1 ;
68
+ static uint8_t ba_response_status_count = 0 ;
69
+
66
70
/*
67
71
* Border router instance data.
68
72
*/
@@ -104,7 +108,7 @@ static NS_LIST_DEFINE(duplicate_dua_tr_list, duplicate_dua_tr_t, link);
104
108
#define THREAD_BBR_MLR_REGISTRATION_TIMEOUT 600 //<* Default MLR timeout in seconds
105
109
#define THREAD_BBR_DUA_REGISTRATION_TIMEOUT 3600
106
110
#define THREAD_BBR_DUA_REGISTRATION_DELAY 5000 // 5 seconds in ms
107
- #define THREAD_BBR_BACKBONE_PORT 61631 //<* Backbone border router
111
+ #define THREAD_BBR_BACKBONE_PORT 5683 //<* Backbone border router
108
112
#define THREAD_BBR_DUA_DAD_QUERY_TIMEOUT 1 // wait period for Duplicate Address Detection
109
113
#define THREAD_BBR_DUA_DAD_REPEATS 2 // multicast repeated as part of DUA
110
114
@@ -510,8 +514,10 @@ static int thread_pbbr_bb_qry_cb(int8_t service_id, uint8_t source_address[16],
510
514
(void )source_port ;
511
515
uint16_t addr_len ;
512
516
uint8_t * addr_data_ptr ;
517
+ uint8_t * ml_eid_ptr ;
513
518
uint16_t rloc ;
514
519
uint16_t * rloc_ptr = NULL ;
520
+ uint32_t last_transaction_time ;
515
521
tr_info ("Thread BBR BB_QRY.ntf Received" );
516
522
517
523
thread_pbbr_t * this = thread_border_router_find_by_service (service_id );
@@ -537,6 +543,16 @@ static int thread_pbbr_bb_qry_cb(int8_t service_id, uint8_t source_address[16],
537
543
tr_warn ("Invalid BB_QRY.ntf message" );
538
544
return -1 ;
539
545
}
546
+
547
+ // Test code for b/ba response override
548
+ if (ba_response_status_count ) {
549
+ device_configuration_s * device_config = thread_joiner_application_get_device_config (this -> interface_id );
550
+ ml_eid_ptr = device_config -> eui64 ;
551
+ last_transaction_time = protocol_core_monotonic_time ;
552
+ ba_response_status_count -- ;
553
+ goto send_response ;
554
+ }
555
+
540
556
ipv6_route_t * route = ipv6_route_choose_next_hop (addr_data_ptr , this -> interface_id , NULL );
541
557
if (!route || route -> prefix_len < 128 || !route -> on_link || route -> info .source != ROUTE_THREAD_PROXIED_DUA_HOST || !route -> info .info ) {
542
558
//address not in mesh
@@ -546,9 +562,10 @@ static int thread_pbbr_bb_qry_cb(int8_t service_id, uint8_t source_address[16],
546
562
rloc_ptr = & rloc ;
547
563
}
548
564
549
- uint32_t last_transaction_time = protocol_core_monotonic_time - ((thread_pbbr_dua_info_t * )route -> info .info )-> last_contact_time ;
550
- uint8_t * ml_eid_ptr = ((thread_pbbr_dua_info_t * )route -> info .info )-> mleid_ptr ;
565
+ last_transaction_time = protocol_core_monotonic_time - ((thread_pbbr_dua_info_t * )route -> info .info )-> last_contact_time ;
566
+ ml_eid_ptr = ((thread_pbbr_dua_info_t * )route -> info .info )-> mleid_ptr ;
551
567
568
+ send_response :
552
569
// This address is valid in our MESH
553
570
return thread_border_router_bb_ans_send (this , source_address , addr_data_ptr , ml_eid_ptr , last_transaction_time , link_configuration_ptr -> name , rloc_ptr );
554
571
}
@@ -893,6 +910,7 @@ static int thread_extension_bbr_dua_cb(int8_t service_id, uint8_t source_address
893
910
if (!cur ) {
894
911
return -1 ;
895
912
}
913
+
896
914
if (0 == thread_extension_primary_bbr_get (cur , bbr_rloc_addr , NULL , NULL , NULL ) &&
897
915
!addr_get_entry (cur , bbr_rloc_addr )) {
898
916
// Primary pBBR present and I am not the pBBR
@@ -918,6 +936,13 @@ static int thread_extension_bbr_dua_cb(int8_t service_id, uint8_t source_address
918
936
919
937
tr_debug ("DUA.req addr:%s ml_eid:%s" , trace_array (addr_data_ptr , addr_len ), trace_array (ml_eid_ptr , ml_eid_len ));
920
938
939
+ // Test code for dua response override
940
+ if (dua_response_status != 0xff && dua_status_count ) {
941
+ bbr_status = dua_response_status ;
942
+ dua_status_count -- ;
943
+ goto send_response ;
944
+ }
945
+
921
946
entry_keep_alive = false;
922
947
ipv6_route_t * route = ipv6_route_lookup_with_info (addr_data_ptr , 128 , this -> interface_id , NULL , ROUTE_THREAD_PROXIED_DUA_HOST , NULL , 0 );
923
948
@@ -1481,4 +1506,24 @@ void thread_extension_bbr_old_partition_data_clean(int8_t interface_id)
1481
1506
}
1482
1507
}
1483
1508
1509
+ void thread_extension_bbr_status_override_get (uint8_t * dua_status , uint8_t * dua_count , uint8_t * ba_failure_count )
1510
+ {
1511
+ if (* dua_status ) {
1512
+ * dua_status = dua_response_status ;
1513
+ }
1514
+ if (* dua_count ) {
1515
+ * dua_count = dua_status_count ;
1516
+ }
1517
+ if (* ba_failure_count ) {
1518
+ * ba_failure_count = ba_response_status_count ;
1519
+ }
1520
+ }
1521
+
1522
+ void thread_extension_bbr_status_override_set (uint8_t dua_status , uint8_t dua_count , uint8_t ba_failure_count )
1523
+ {
1524
+ dua_response_status = dua_status ;
1525
+ dua_status_count = dua_count ;
1526
+ ba_response_status_count = ba_failure_count ;
1527
+ }
1528
+
1484
1529
#endif //HAVE_THREAD_BORDER_ROUTER && HAVE_THREAD_V2
0 commit comments