@@ -831,9 +831,15 @@ static int thread_extension_bbr_pbbr_stop(thread_pbbr_t *this)
831
831
832
832
coap_service_unregister_uri (this -> coap_service_id , THREAD_URI_BBR_TRI_RX_NTF );
833
833
coap_service_unregister_uri (this -> coap_service_id , THREAD_URI_BBR_NMK_RX_NTF );
834
+ coap_service_unregister_uri (this -> coap_service_id , THREAD_URI_BBR_DOMAIN_ADDRESS_REGISTRATION );
835
+ coap_service_unregister_uri (this -> coap_service_id , THREAD_URI_BBR_MCAST_LISTENER_REPORT );
836
+
834
837
coap_service_delete (this -> br_bb_service_id );
835
838
this -> br_bb_service_id = -1 ;
836
839
840
+ coap_service_delete (this -> coap_nmkp_virtual_service_id );
841
+ this -> coap_nmkp_virtual_service_id = -1 ;
842
+
837
843
this -> pbbr_started = false;
838
844
return 0 ;
839
845
}
@@ -856,39 +862,46 @@ static int thread_extension_bbr_pbbr_start(thread_pbbr_t *this)
856
862
//If started only refresh network data
857
863
return 0 ;
858
864
}
859
- // Register Primary BBR backbone multicast address
865
+ // Allow only filtered addresses to be forwarded
866
+ multicast_fwd_full_for_scope (this -> interface_id , 0x10 );
867
+ //multicast_fwd_full_for_scope(this->backbone_interface_id, 0x10);
868
+
869
+ //Register baseline 1.2 features
870
+ coap_service_register_uri (this -> coap_service_id , THREAD_URI_BBR_MCAST_LISTENER_REPORT , COAP_SERVICE_ACCESS_POST_ALLOWED , thread_extension_bbr_mlr_cb );
871
+ this -> pbbr_started = true;
872
+
873
+ // Generate pbbr multicast address
860
874
memset (this -> pbbr_multicast_address , 0 , 16 );
861
875
this -> pbbr_multicast_address [0 ] = 0xff ;
862
876
this -> pbbr_multicast_address [1 ] = 0x30 | 3 ; //Thread specification says p and t bits are 1 Scope is 3
863
877
this -> pbbr_multicast_address [2 ] = 0x00 ; //Reserved
864
878
this -> pbbr_multicast_address [3 ] = 0x40 ; //Prefix length 64 bits
879
+ this -> pbbr_multicast_address [15 ] = 2 ;
865
880
if (0 != thread_extension_network_prefix_get (this -> interface_id , NULL , & this -> pbbr_multicast_address [4 ], NULL )) {
866
- //No domain prefix in settings
867
- tr_warn ( "invalid config " );
868
- return -1 ;
881
+ //No domain prefix in settings DUA handling not used
882
+ tr_info ( "pBBR service started (Home network) " );
883
+ return 0 ;
869
884
}
885
+ tr_info ("pBBR service started (Commercial network)" );
886
+ // Start commercial mode features
887
+ multicast_add_address (this -> pbbr_multicast_address , false);
870
888
871
- this -> pbbr_multicast_address [15 ] = 2 ;
872
-
873
- // Register to backbone CoAP URIs
889
+ // Register to backbone CoAP service
874
890
this -> br_bb_service_id = coap_service_initialize (this -> backbone_interface_id , this -> pbbr_port , COAP_SERVICE_OPTIONS_SELECT_SOCKET_IF , NULL , NULL );
875
891
if (this -> br_bb_service_id < 0 ) {
876
- tr_error ("pBBR service start failed" );
892
+ tr_error ("pBBR Commercial service start failed" );
877
893
thread_extension_bbr_pbbr_stop (this );
878
894
return -1 ;
879
895
}
880
- multicast_add_address (this -> pbbr_multicast_address , false);
881
- // Allow only filtered addresses to be forwarded
882
- multicast_fwd_full_for_scope (this -> interface_id , 0x10 );
883
- multicast_fwd_full_for_scope (this -> backbone_interface_id , 0x10 );
896
+ // Register Primary BBR backbone multicast address
884
897
898
+ // Register commercial features
885
899
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 );
886
900
coap_service_register_uri (this -> br_bb_service_id , THREAD_URI_BBR_BB_ANS_NTF , COAP_SERVICE_ACCESS_POST_ALLOWED , thread_pbbr_bb_ans_cb );
887
901
coap_service_register_uri (this -> br_bb_service_id , THREAD_URI_TRI_TX_NTF , COAP_SERVICE_ACCESS_POST_ALLOWED , thread_pbbr_relay_from_tri_cb );
902
+ coap_service_register_uri (this -> br_bb_service_id , THREAD_URI_BBR_BMLR_NTF , COAP_SERVICE_ACCESS_POST_ALLOWED , thread_extension_bbr_bmlr_cb );
888
903
889
904
// Register Mesh address registration URI
890
- coap_service_register_uri (this -> coap_service_id , THREAD_URI_BBR_MCAST_LISTENER_REPORT , COAP_SERVICE_ACCESS_POST_ALLOWED , thread_extension_bbr_mlr_cb );
891
- coap_service_register_uri (this -> coap_service_id , THREAD_URI_BBR_BMLR_NTF , COAP_SERVICE_ACCESS_POST_ALLOWED , thread_extension_bbr_bmlr_cb );
892
905
coap_service_register_uri (this -> coap_service_id , THREAD_URI_BBR_DOMAIN_ADDRESS_REGISTRATION , COAP_SERVICE_ACCESS_POST_ALLOWED , thread_extension_bbr_dua_cb );
893
906
// Register Mesh side relay URI
894
907
coap_service_register_uri (this -> coap_service_id , THREAD_URI_BBR_TRI_RX_NTF , COAP_SERVICE_ACCESS_POST_ALLOWED , thread_pbbr_relay_to_tri_cb );
@@ -901,8 +914,6 @@ static int thread_extension_bbr_pbbr_start(thread_pbbr_t *this)
901
914
coap_service_register_uri (this -> coap_nmkp_virtual_service_id , THREAD_URI_BBR_NMKP_REQ , COAP_SERVICE_ACCESS_POST_ALLOWED , thread_pbbr_nmkp_req_recv_cb );
902
915
coap_service_virtual_socket_set_cb (this -> coap_nmkp_virtual_service_id , thread_pbbr_nmkp_virtual_socket_send_cb );
903
916
// Set the partition weight to be 72
904
- tr_info ("pBBR service started" );
905
- this -> pbbr_started = true;
906
917
return 0 ;
907
918
}
908
919
@@ -935,6 +946,8 @@ int8_t thread_extension_bbr_init(int8_t interface_id, int8_t backbone_interface_
935
946
memcpy (this -> tri_address ,ADDR_LINK_LOCAL_ALL_ROUTERS ,16 );
936
947
this -> tri_port = THREAD_BBR_BACKBONE_PORT ;
937
948
this -> joiner_router_rloc = 0xffff ;
949
+ this -> coap_nmkp_virtual_service_id = -1 ;
950
+ this -> br_bb_service_id = -1 ;
938
951
939
952
this -> coap_service_id = coap_service_initialize (this -> interface_id , THREAD_MANAGEMENT_PORT , COAP_SERVICE_OPTIONS_NONE , NULL , NULL );
940
953
if (this -> coap_service_id < 0 ) {
@@ -944,11 +957,6 @@ int8_t thread_extension_bbr_init(int8_t interface_id, int8_t backbone_interface_
944
957
}
945
958
ns_list_add_to_start (& pbbr_instance_list , this );
946
959
947
- if (0 != thread_extension_network_prefix_get (this -> interface_id , NULL , NULL , NULL )) {
948
- // Not in Commercial network
949
- return 0 ;
950
- }
951
-
952
960
return 0 ;
953
961
}
954
962
@@ -1001,10 +1009,6 @@ void thread_extension_bbr_seconds_timer(int8_t interface_id, uint32_t seconds)
1001
1009
return ;
1002
1010
}
1003
1011
1004
- if (0 != thread_extension_network_prefix_get (this -> interface_id , NULL , NULL , NULL )) {
1005
- // Not in commercial network
1006
- return ;
1007
- }
1008
1012
protocol_interface_info_entry_t * cur ;
1009
1013
cur = protocol_stack_interface_info_get_by_id (this -> interface_id );
1010
1014
if (!cur ) {
@@ -1033,6 +1037,12 @@ void thread_extension_bbr_seconds_timer(int8_t interface_id, uint32_t seconds)
1033
1037
1034
1038
thread_extension_bbr_pbbr_start (this );
1035
1039
} else {
1040
+ if (this -> br_bb_service_id < 0 &&
1041
+ thread_extension_network_prefix_get (cur -> id , NULL , NULL , NULL ) == 0 ) {
1042
+ // Settings changed to commercial
1043
+ thread_extension_bbr_pbbr_stop (this );
1044
+ thread_extension_bbr_pbbr_start (this );
1045
+ }
1036
1046
if (thread_extension_bbr_downgrade_to_secondary (cur )) {
1037
1047
tr_info ("pbbr downgraded" );
1038
1048
thread_extension_bbr_pbbr_stop (this );
0 commit comments