|
45 | 45 | #include "6LoWPAN/Thread/thread_border_router_api_internal.h"
|
46 | 46 | #include "6LoWPAN/Thread/thread_beacon.h"
|
47 | 47 | #include "6LoWPAN/Thread/thread_nvm_store.h"
|
| 48 | +#include "6LoWPAN/Thread/thread_commercial_bootstrap.h" |
48 | 49 | #include "6LoWPAN/MAC/mac_helper.h"
|
49 | 50 | #include "6LoWPAN/Thread/thread_mle_message_handler.h"
|
50 | 51 | #include "mac_api.h"
|
@@ -88,11 +89,6 @@ static void thread_neighbor_remove(int8_t interface_id, mle_neigh_table_entry_t
|
88 | 89 | static void thread_bootsrap_network_join_start(struct protocol_interface_info_entry *cur_interface, discovery_response_list_t *nwk_info);
|
89 | 90 | static int8_t thread_child_keep_alive(int8_t interface_id, const uint8_t *mac64);
|
90 | 91 |
|
91 |
| -static int stringlen(const char *s, int n) |
92 |
| -{ |
93 |
| - char *end = memchr(s, 0, n); |
94 |
| - return end?end-s:n; |
95 |
| -} |
96 | 92 |
|
97 | 93 | int thread_bootstrap_reset_child_info(protocol_interface_info_entry_t *cur, mle_neigh_table_entry_t *child)
|
98 | 94 | {
|
@@ -1942,33 +1938,7 @@ static void thread_network_select_by_steering_data(device_configuration_s *devic
|
1942 | 1938 |
|
1943 | 1939 | static void thread_network_select(struct protocol_interface_info_entry *interface_prt, device_configuration_s *device_configuration_ptr, thread_nwk_discovery_response_list_t *discover_response)
|
1944 | 1940 | {
|
1945 |
| - discovery_response_list_t *discovered_network_ptr = NULL; |
1946 |
| - |
1947 |
| - if (thread_info(interface_prt)->version == THREAD_VERSION_1_2 && thread_info(interface_prt)->ccm_ptr) { |
1948 |
| - /* If we have domain certificate, search for domain to join */ |
1949 |
| - if (thread_info(interface_prt)->ccm_ptr->domain_certificate_ptr) { |
1950 |
| - ns_list_foreach_safe(discovery_response_list_t, cur_class, discover_response) { |
1951 |
| - if ((stringlen((const char*) cur_class->thread_domain, 16)) && |
1952 |
| - (!memcmp(cur_class->thread_domain, thread_info(interface_prt)->ccm_ptr->domain_name, stringlen((const char*) cur_class->thread_domain, 16)))) |
1953 |
| - { |
1954 |
| - discovered_network_ptr = cur_class; |
1955 |
| - break; |
1956 |
| - } |
1957 |
| - } |
1958 |
| - } |
1959 |
| - |
1960 |
| - /* No domain, use device certificate*/ |
1961 |
| - if (!discovered_network_ptr) { |
1962 |
| - ns_list_foreach_safe(discovery_response_list_t, cur_class, discover_response) { |
1963 |
| - if (cur_class->ccm_supported) |
1964 |
| - { |
1965 |
| - discovered_network_ptr = cur_class; |
1966 |
| - break; |
1967 |
| - } |
1968 |
| - } |
1969 |
| - } |
1970 |
| - } |
1971 |
| - |
| 1941 | + discovery_response_list_t *discovered_network_ptr = thread_commercial_bootstrap_network_select(interface_prt, discover_response); |
1972 | 1942 |
|
1973 | 1943 | /* If network found */
|
1974 | 1944 | if (discovered_network_ptr) {
|
@@ -2169,17 +2139,7 @@ static void thread_bootsrap_network_join_start(struct protocol_interface_info_en
|
2169 | 2139 | tr_debug("Start commission with %s", trace_ipv6(parentLLAddress));
|
2170 | 2140 | cur_interface->bootsrap_state_machine_cnt = 0;
|
2171 | 2141 |
|
2172 |
| - if (thread_info(cur_interface)->version == THREAD_VERSION_1_2 && thread_info(cur_interface)->ccm_ptr) { |
2173 |
| - if (thread_info(cur_interface)->ccm_ptr->domain_certificate_ptr && nwk_info->nmk_port) { |
2174 |
| - thread_joiner_application_nmkp_commission_start(cur_interface->id, parentLLAddress, nwk_info->nmk_port, thread_bootstrap_joiner_application_commission_done_cb); |
2175 |
| - } else if (thread_info(cur_interface)->ccm_ptr->device_certificate_ptr && nwk_info->ae_port) { |
2176 |
| - thread_joiner_application_ae_commission_start(cur_interface->id, parentLLAddress, nwk_info->ae_port, thread_bootstrap_joiner_application_commission_done_cb); |
2177 |
| - } else if (nwk_info->joiner_port) { |
2178 |
| - thread_joiner_application_pskd_commission_start(cur_interface->id, parentLLAddress, nwk_info->joiner_port, nwk_info->pan_id, nwk_info->extented_pan_id, nwk_info->channel, thread_bootstrap_joiner_application_commission_done_cb); |
2179 |
| - } else { |
2180 |
| - return; |
2181 |
| - } |
2182 |
| - } else { |
| 2142 | + if (0 > thread_commercial_bootstrap_commission_start(cur_interface, parentLLAddress, nwk_info, thread_bootstrap_joiner_application_commission_done_cb)) { |
2183 | 2143 | thread_joiner_application_pskd_commission_start(cur_interface->id, parentLLAddress, nwk_info->joiner_port, nwk_info->pan_id, nwk_info->extented_pan_id, nwk_info->channel, thread_bootstrap_joiner_application_commission_done_cb);
|
2184 | 2144 | }
|
2185 | 2145 | ns_dyn_mem_free(nwk_info);
|
|
0 commit comments