@@ -124,6 +124,11 @@ static NS_LIST_DEFINE(duplicate_dua_tr_list, duplicate_dua_tr_t, link);
124
124
#define THREAD_BBR_STATUS_NOT_SPECIFIED 6
125
125
#define THREAD_BBR_STATUS_BB_LINK_NOT_OPERATIONAL 7
126
126
127
+
128
+ static void thread_border_router_multicast_store_add (thread_pbbr_t * this , uint8_t * destination_addr_ptr );
129
+ static void thread_border_router_multicast_store_del (thread_pbbr_t * this , uint8_t * destination_addr_ptr );
130
+ static void thread_border_router_multicast_store_activate (thread_pbbr_t * this );
131
+
127
132
static int stringlen (const char * s , int n )
128
133
{
129
134
char * end = memchr (s , 0 , n );
@@ -195,7 +200,6 @@ static duplicate_dua_tr_t *thread_border_router_dup_tr_find(int8_t interface_id,
195
200
return this ;
196
201
}
197
202
198
-
199
203
/*
200
204
* Target EID TLV
201
205
* ML-EID TLV
@@ -652,7 +656,7 @@ static int thread_extension_bbr_bmlr_req_send(int8_t service_id, const uint8_t b
652
656
ptr = thread_meshcop_tlv_data_write (ptr , TMFCOP_TLV_IPV6_ADDRESS , addr_len , address_ptr );
653
657
ptr = thread_meshcop_tlv_data_write_uint32 (ptr , TMFCOP_TLV_TIMEOUT , timeout );
654
658
655
- tr_debug ("thread BMLR.ntf send; timeout: %" PRIu32 , timeout );
659
+ tr_debug ("thread BMLR.ntf send %s ; timeout: %" PRIu32 , trace_ipv6 ( address_ptr ) , timeout );
656
660
657
661
coap_service_request_send (service_id , COAP_REQUEST_OPTIONS_NONE , br_addr , THREAD_MANAGEMENT_PORT ,
658
662
COAP_MSG_TYPE_NON_CONFIRMABLE , COAP_MSG_CODE_REQUEST_POST , THREAD_URI_BBR_BMLR_NTF , COAP_CT_OCTET_STREAM , payload , ptr - payload , NULL );
@@ -732,6 +736,7 @@ static int thread_extension_bbr_mlr_cb(int8_t service_id, uint8_t source_address
732
736
while (remaining > 0 ) {
733
737
//Go through all addresses
734
738
if (!addr_is_ipv6_multicast (addr_ptr )) {
739
+ tr_err ("Invalid /n/mr not multicast address" );
735
740
bbr_status = THREAD_BBR_STATUS_TARGET_EID_NOT_VALID ;
736
741
if (!invalid_addr_ptr ) {
737
742
invalid_addr_ptr = addr_ptr ;
@@ -741,12 +746,12 @@ static int thread_extension_bbr_mlr_cb(int8_t service_id, uint8_t source_address
741
746
//tr_debug("Multicast address: %s delete", trace_ipv6(addr_ptr));
742
747
addr_multicast_fwd_remove (cur , addr_ptr );
743
748
// TODO remove address from NVM
744
- tr_info ( "delete multicast address from NVM" );
749
+ thread_border_router_multicast_store_del ( this , addr_ptr );
745
750
} else {
746
751
//tr_debug("Multicast address: %s Timeout value: %"PRIu32, trace_ipv6(addr_ptr),timeout_value);
747
752
multicast_fwd_add (this -> interface_id , addr_ptr , timeout_value );
748
753
if (timeout_value == 0xffffffff ) {
749
- tr_info ( "Store multicast address to NVM" );
754
+ thread_border_router_multicast_store_add ( this , addr_ptr );
750
755
}
751
756
// send BMLR.ntf message to backend
752
757
thread_extension_bbr_bmlr_req_send (this -> br_bb_service_id , this -> pbbr_multicast_address , addr_data_ptr , 16 , timeout_value );
@@ -892,6 +897,51 @@ static int thread_extension_bbr_dua_cb(int8_t service_id, uint8_t source_address
892
897
coap_service_response_send (this -> coap_service_id , COAP_REQUEST_OPTIONS_NONE , request_ptr , response_code , COAP_CT_OCTET_STREAM , payload , ptr - payload );
893
898
return 0 ;
894
899
}
900
+
901
+
902
+ /*POC for multicast NVM*/
903
+ #define MULTICAST_ADDRESS_STORE_AMOUNT 3
904
+
905
+ typedef struct {
906
+ uint8_t addr [16 ];
907
+ } multicast_addr_t ;
908
+ static multicast_addr_t multicast_store [MULTICAST_ADDRESS_STORE_AMOUNT ] = {0 };
909
+
910
+ static void thread_border_router_multicast_store_add (thread_pbbr_t * this , uint8_t * destination_addr_ptr )
911
+ {
912
+ (void )this ;
913
+ tr_info ("Store multicast address to NVM" );
914
+ for (int n = 0 ; n < MULTICAST_ADDRESS_STORE_AMOUNT ;n ++ ) {
915
+ if (memcmp (multicast_store [n ].addr , ADDR_UNSPECIFIED ,16 ) == 0 ) {
916
+ memcpy (multicast_store [n ].addr ,destination_addr_ptr ,16 );
917
+ break ;
918
+ }
919
+ }
920
+ }
921
+
922
+ static void thread_border_router_multicast_store_del (thread_pbbr_t * this , uint8_t * destination_addr_ptr )
923
+ {
924
+ (void )this ;
925
+ tr_info ("delete multicast address from NVM" );
926
+ for (int n = 0 ; n < MULTICAST_ADDRESS_STORE_AMOUNT ;n ++ ) {
927
+ if (memcmp (multicast_store [n ].addr , destination_addr_ptr ,16 ) == 0 ) {
928
+ memcpy (multicast_store [n ].addr ,ADDR_UNSPECIFIED ,16 );
929
+ }
930
+ }
931
+ }
932
+
933
+ static void thread_border_router_multicast_store_activate (thread_pbbr_t * this )
934
+ {
935
+ (void )this ;
936
+ for (int n = 0 ; n < MULTICAST_ADDRESS_STORE_AMOUNT ;n ++ ) {
937
+ if (memcmp (multicast_store [n ].addr , ADDR_UNSPECIFIED ,16 ) != 0 ) {
938
+ multicast_fwd_add (this -> interface_id , multicast_store [n ].addr , 0xffffffff );
939
+ thread_extension_bbr_bmlr_req_send (this -> br_bb_service_id , this -> pbbr_multicast_address , multicast_store [n ].addr , 16 , 0xffffffff );
940
+ }
941
+ }
942
+ }
943
+
944
+
895
945
static bool thread_extension_bbr_downgrade_to_secondary (struct protocol_interface_info_entry * cur )
896
946
{
897
947
uint16_t rloc16 = mac_helper_mac16_address_get (cur );
@@ -1021,6 +1071,7 @@ static int thread_extension_bbr_pbbr_start(thread_pbbr_t *this)
1021
1071
// Register Primary BBR backbone multicast address
1022
1072
multicast_add_address (this -> pbbr_multicast_address , false);
1023
1073
this -> pbbr_started = true;
1074
+ thread_border_router_multicast_store_activate (this );
1024
1075
1025
1076
// Register Backbone commercial features
1026
1077
coap_service_register_uri (this -> br_bb_service_id , THREAD_URI_BBR_BB_QRY_NTF , COAP_SERVICE_ACCESS_POST_ALLOWED , thread_pbbr_bb_qry_cb );
@@ -1237,6 +1288,14 @@ void thread_extension_bbr_seconds_timer(int8_t interface_id, uint32_t seconds)
1237
1288
tr_info ("pbbr downgraded" );
1238
1289
thread_extension_bbr_pbbr_stop (this );
1239
1290
}
1291
+ uint8_t bbr_rloc_addr [16 ];
1292
+ // If there is no pBBR or I am not pBBR reset
1293
+ if (0 != thread_extension_primary_bbr_get (cur , bbr_rloc_addr , NULL , NULL , NULL ) ||
1294
+ !addr_get_entry (cur ,bbr_rloc_addr )) {
1295
+ tr_info ("pbbr stop network data not correct" );
1296
+ thread_extension_bbr_pbbr_stop (this );
1297
+ }
1298
+
1240
1299
1241
1300
}
1242
1301
// Check secondary state if we need to drop
0 commit comments