@@ -82,6 +82,7 @@ typedef struct {
82
82
/* Neighbor discovery options according to RFC6106 (rfc4861) */
83
83
#define RFC6106_RECURSIVE_DNS_SERVER_OPTION 25
84
84
#define RFC6106_DNS_SEARCH_LIST_OPTION 31
85
+
85
86
static NS_LIST_DEFINE (border_router_instance_list , thread_border_router_t , link ) ;
86
87
87
88
@@ -457,6 +458,7 @@ void thread_border_router_delete(int8_t interface_id)
457
458
ns_dyn_mem_free (this -> recursive_dns_server_option );
458
459
ns_dyn_mem_free (this );
459
460
}
461
+
460
462
void thread_border_router_seconds_timer (int8_t interface_id , uint32_t seconds )
461
463
{
462
464
thread_border_router_t * this = thread_border_router_find_by_interface (interface_id );
@@ -783,17 +785,19 @@ static void thread_tmf_client_network_data_set_cb(int8_t interface_id, int8_t st
783
785
if (!cur ) {
784
786
return ;
785
787
}
786
- // Save the old address
787
- cur -> thread_info -> localServerDataBase .registered_rloc16 = mac_helper_mac16_address_get (cur );
788
- cur -> thread_info -> localServerDataBase .release_old_address = false;
788
+
789
789
cur -> thread_info -> localServerDataBase .publish_active = false;
790
790
791
- tr_debug ("border router status %s, addr: %x" ,status ?"Fail" :"Ok " , cur -> thread_info -> localServerDataBase .registered_rloc16 );
791
+ tr_debug ("BR a/sd response status: %s, addr: %x" ,status ?"Fail" :"OK " , cur -> thread_info -> localServerDataBase .registered_rloc16 );
792
792
793
793
if (cur -> thread_info -> localServerDataBase .publish_pending ) {
794
794
cur -> thread_info -> localServerDataBase .publish_pending = false;
795
795
thread_border_router_publish (cur -> id );
796
796
}
797
+
798
+ // always update RLOC to new one. If COAP response fails then resubmit timer will trigger new a/sd
799
+ cur -> thread_info -> localServerDataBase .registered_rloc16 = mac_helper_mac16_address_get (cur );
800
+ cur -> thread_info -> localServerDataBase .release_old_address = false;
797
801
}
798
802
#endif
799
803
@@ -817,6 +821,9 @@ int thread_border_router_publish(int8_t interface_id)
817
821
return -2 ;
818
822
}
819
823
824
+ rloc16 = mac_helper_mac16_address_get (cur );
825
+ tr_debug ("Border router old: %x, new: %x" , cur -> thread_info -> localServerDataBase .registered_rloc16 , rloc16 );
826
+
820
827
if (cur -> thread_info -> localServerDataBase .publish_active ) {
821
828
cur -> thread_info -> localServerDataBase .publish_pending = true;
822
829
tr_debug ("Activate pending status for publish" );
@@ -831,20 +838,18 @@ int thread_border_router_publish(int8_t interface_id)
831
838
if (!ptr ) {
832
839
return -3 ;
833
840
}
834
- rloc16 = mac_helper_mac16_address_get (cur );
835
841
836
842
ptr = thread_tmfcop_tlv_data_write_header (ptr , TMFCOP_TLV_NETWORK_DATA , network_data_len );
837
843
ptr = thread_nd_own_service_list_data_write (& cur -> thread_info -> localServerDataBase , ptr , rloc16 );
838
844
839
- tr_debug ("Border router old: %x, new: %x" , cur -> thread_info -> localServerDataBase .registered_rloc16 , rloc16 );
840
-
841
845
if (cur -> thread_info -> localServerDataBase .registered_rloc16 != 0xffff &&
842
846
cur -> thread_info -> localServerDataBase .release_old_address &&
843
847
cur -> thread_info -> localServerDataBase .registered_rloc16 != rloc16 ) {
844
848
// Our address has changed so we must register our network with new address and remove the old address
845
- tr_debug ("Border router Address changed remove old" );
849
+ tr_debug ("BR address changed - remove old %x" , cur -> thread_info -> localServerDataBase . registered_rloc16 );
846
850
ptr = thread_tmfcop_tlv_data_write_uint16 (ptr ,TMFCOP_TLV_RLOC16 ,cur -> thread_info -> localServerDataBase .registered_rloc16 );
847
851
}
852
+
848
853
cur -> thread_info -> localServerDataBase .registered_rloc16 = rloc16 ;
849
854
ret_val = thread_management_client_network_data_register (cur -> id , payload_ptr , ptr - payload_ptr , thread_tmf_client_network_data_set_cb );
850
855
if (payload_ptr ) {
0 commit comments