Skip to content

Commit

Permalink
removed the dependence of AE message relay on DUA prefix (ARMmbed#1655)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakvenugopal authored Apr 16, 2018
1 parent 9e7e9e0 commit 41ca387
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions source/6LoWPAN/Thread/thread_extension_bbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,46 +891,39 @@ static int thread_extension_bbr_pbbr_start(thread_pbbr_t *this)
//If started only refresh network data
return 0;
}
// Register to backbone CoAP service
this->br_bb_service_id = coap_service_initialize(this->backbone_interface_id, this->pbbr_port, COAP_SERVICE_OPTIONS_SELECT_SOCKET_IF, NULL, NULL);
if(this->br_bb_service_id < 0) {
tr_error("pBBR Commercial service start failed");
thread_extension_bbr_pbbr_stop(this);
return -1;
}
// Allow only filtered addresses to be forwarded
multicast_fwd_full_for_scope(this->interface_id, 0x10);
multicast_fwd_full_for_scope(this->backbone_interface_id, 0);

//Register baseline 1.2 features
coap_service_register_uri(this->coap_service_id, THREAD_URI_BBR_MCAST_LISTENER_REPORT, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_extension_bbr_mlr_cb);
this->pbbr_started = true;

// Generate pbbr multicast address
memset(this->pbbr_multicast_address, 0, 16);
this->pbbr_multicast_address[0] = 0xff;
this->pbbr_multicast_address[1] = 0x30 | 3; //Thread specification says p and t bits are 1 Scope is 3
this->pbbr_multicast_address[2] = 0x00; //Reserved
this->pbbr_multicast_address[3] = 0x40; //Prefix length 64 bits
this->pbbr_multicast_address[15] = 2;
if (0 != thread_extension_network_prefix_get(this->interface_id, NULL, &this->pbbr_multicast_address[4], NULL)) {
//No domain prefix in settings DUA handling not used
tr_info("pBBR service started (Home network)");
return 0;
}

tr_info("pBBR service started (Commercial network)");
// Start commercial mode features
// Register Primary BBR backbone multicast address
multicast_add_address(this->pbbr_multicast_address, false);

// Register to backbone CoAP service
this->br_bb_service_id = coap_service_initialize(this->backbone_interface_id, this->pbbr_port, COAP_SERVICE_OPTIONS_SELECT_SOCKET_IF, NULL, NULL);
if(this->br_bb_service_id < 0) {
tr_error("pBBR Commercial service start failed");
thread_extension_bbr_pbbr_stop(this);
return -1;
}
// Register Primary BBR backbone multicast address
this->pbbr_started = true;

// Register commercial features
// Register Backbone commercial features
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);
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);
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);
coap_service_register_uri(this->br_bb_service_id, THREAD_URI_BBR_BMLR_NTF, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_extension_bbr_bmlr_cb);

// Register Mesh address registration URI
coap_service_register_uri(this->coap_service_id, THREAD_URI_BBR_MCAST_LISTENER_REPORT, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_extension_bbr_mlr_cb);
coap_service_register_uri(this->coap_service_id, THREAD_URI_BBR_DOMAIN_ADDRESS_REGISTRATION, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_extension_bbr_dua_cb);
// Register Mesh side relay URI
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);
Expand All @@ -942,7 +935,7 @@ static int thread_extension_bbr_pbbr_start(thread_pbbr_t *this)
thread_extension_bootstrap_network_certificate_enable(cur, this->coap_nmkp_virtual_service_id);
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);
coap_service_virtual_socket_set_cb(this->coap_nmkp_virtual_service_id, thread_pbbr_nmkp_virtual_socket_send_cb);
// Set the partition weight to be 72

return 0;
}

Expand Down Expand Up @@ -986,6 +979,8 @@ int8_t thread_extension_bbr_init(int8_t interface_id, int8_t backbone_interface_
}
ns_list_add_to_start(&pbbr_instance_list, this);

// Set the partition weight to be 72
thread_management_partition_weighting_set(this->interface_id, 72);
return 0;
}

Expand Down Expand Up @@ -1066,12 +1061,6 @@ void thread_extension_bbr_seconds_timer(int8_t interface_id, uint32_t seconds)

thread_extension_bbr_pbbr_start(this);
} else {
if(this->br_bb_service_id < 0 &&
thread_extension_network_prefix_get(cur->id, NULL, NULL, NULL) == 0) {
// Settings changed to commercial
thread_extension_bbr_pbbr_stop(this);
thread_extension_bbr_pbbr_start(this);
}
if (thread_extension_bbr_downgrade_to_secondary(cur)) {
tr_info("pbbr downgraded");
thread_extension_bbr_pbbr_stop(this);
Expand Down

0 comments on commit 41ca387

Please sign in to comment.