@@ -512,6 +512,7 @@ static int thread_border_relay_to_leader_cb(int8_t service_id, uint8_t source_ad
512512 return -1 ;
513513}
514514
515+ #ifdef HAVE_THREAD_BORDER_ROUTER
515516static bool thread_bbr_i_host_prefix (struct protocol_interface_info_entry * cur , uint8_t prefix_ptr [8 ], uint8_t * br_count , bool * i_am_lowest )
516517{
517518 bool i_host_this_prefix = false;
@@ -568,6 +569,7 @@ static void thread_bbr_network_data_remove(thread_bbr_t *this)
568569 memset (this -> bbr_prefix ,0 ,8 );
569570 this -> br_info_published = false;
570571}
572+
571573static void thread_bbr_network_data_send (thread_bbr_t * this , uint8_t prefix [8 ], uint8_t eui64 [8 ])
572574{
573575 thread_border_router_info_t br_info = { 0 };
@@ -594,8 +596,8 @@ static void thread_bbr_network_data_send(thread_bbr_t *this, uint8_t prefix[8],
594596 thread_border_router_prefix_add (this -> interface_id , this -> bbr_prefix , 64 , & br_info );
595597 thread_border_router_publish (this -> interface_id );
596598 this -> br_info_published = true;
597-
598599}
600+
599601static void thread_bbr_routing_enable (thread_bbr_t * this )
600602{
601603 if (this -> routing_enabled ) {
@@ -691,17 +693,18 @@ static void thread_bbr_status_check(thread_bbr_t *this, uint32_t seconds)
691693 } else {
692694 this -> br_delete_timer = randLIB_get_random_in_range (5 ,10 );
693695 }
694- tr_info ("br: too many BRs start remove jitter: %d" , this -> br_delete_timer );
696+ tr_info ("br: too many BRs start remove jitter:%" PRIu32 , this -> br_delete_timer );
695697 return ;
696698 }
697699 if (this -> br_info_published && !bbr_prefix_ptr ) {
698700 // Need to disable ND proxy will give a 20 second delay for it We could also disable routing immediately
699701 this -> br_delete_timer = 20 ;
700- tr_info ("br: can not be border router need to remove after: %d" , this -> br_delete_timer );
702+ tr_info ("br: can not be border router need to remove after: %" PRIu32 , this -> br_delete_timer );
701703 return ;
702704 }
703705 }
704706}
707+
705708static bool thread_bbr_activated (thread_bbr_t * this , uint32_t seconds )
706709{
707710 protocol_interface_info_entry_t * cur ;
@@ -740,7 +743,6 @@ static bool thread_bbr_activated(thread_bbr_t *this, uint32_t seconds)
740743 return false;
741744}
742745
743- #ifdef HAVE_THREAD_BORDER_ROUTER
744746bool thread_bbr_routing_enabled (protocol_interface_info_entry_t * cur )
745747{
746748 thread_bbr_t * this = thread_bbr_find_by_interface (cur -> thread_info -> interface_id );
@@ -756,7 +758,7 @@ void thread_bbr_network_data_update_notify(protocol_interface_info_entry_t *cur)
756758 (void ) cur ;
757759 thread_mdns_network_data_update_notify ();
758760}
759- #endif
761+ #endif /* HAVE_THREAD_BORDER_ROUTER*/
760762
761763static void thread_bbr_udp_proxy_service_stop (int8_t interface_id )
762764{
@@ -766,7 +768,6 @@ static void thread_bbr_udp_proxy_service_stop(int8_t interface_id)
766768 tr_error ("Failed to find BA instance" );
767769 return ;
768770 }
769- tr_debug ("thread_border_router_udp_proxy_service_stop %d" , interface_id );
770771
771772 socket_close (this -> udp_proxy_socket );
772773 this -> udp_proxy_socket = -1 ;
@@ -787,19 +788,18 @@ int thread_bbr_commissioner_proxy_service_update(int8_t interface_id)
787788 goto return_fail ;
788789 }
789790
790- if (cur -> thread_info -> registered_commissioner .commissioner_valid ) {
791- // relay is needed
791+ if (! cur -> thread_info -> registered_commissioner .commissioner_valid ) {
792+ // commissioner not enabled
792793 if (this -> udp_proxy_socket != -1 ) {
793- // UDP service is already running
794- return 0 ;
794+ thread_bbr_udp_proxy_service_stop (interface_id );
795795 }
796- } else if (this -> udp_proxy_socket != -1 ) {
797- // UDP service is running and need to delete
798- thread_bbr_udp_proxy_service_stop (interface_id );
799796 return 0 ;
800797 }
801- tr_debug ("thread_border_router_udp_proxy_service_start %d" , interface_id );
802798
799+ if (this -> udp_proxy_socket != -1 ) {
800+ // commissioner is valid and UDP service is already running
801+ return 0 ;
802+ }
803803
804804 // Set source parameters, if commissioner is available
805805 ret_val = thread_management_get_commissioner_address (this -> interface_id , & ns_source_addr .address [0 ], 0 );
0 commit comments