forked from ARMmbed/mbed-os
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split Wi-SUN bootstrap to device types
Created new files for following Wi-SUN device types - 6LBR Wi-SUN border router - FFN Wi-SUN Full Functioning Node - LFN Wi-SUN Limited Functioning Node First phase splits the Async message handling to new Files
- Loading branch information
Mika Tervonen
authored and
Mika Tervonen
committed
Sep 1, 2021
1 parent
a3f3412
commit e60974d
Showing
12 changed files
with
1,076 additions
and
537 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
/* | ||
* Copyright (c) 2021, Pelion and affiliates. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <string.h> | ||
#include "nsconfig.h" | ||
#ifdef HAVE_WS | ||
#include "ns_types.h" | ||
#include "ns_trace.h" | ||
#include "nsdynmemLIB.h" | ||
#include "net_interface.h" | ||
#include "eventOS_event.h" | ||
#include "randLIB.h" | ||
#include "common_functions.h" | ||
#include "mac_common_defines.h" | ||
#include "sw_mac.h" | ||
#include "ccmLIB.h" | ||
#include "Core/include/ns_monitor.h" | ||
#include "NWK_INTERFACE/Include/protocol.h" | ||
#include "6LoWPAN/Bootstraps/protocol_6lowpan.h" | ||
#include "6LoWPAN/Bootstraps/protocol_6lowpan_interface.h" | ||
#include "ipv6_stack/protocol_ipv6.h" | ||
#include "ipv6_stack/ipv6_routing_table.h" | ||
#include "6LoWPAN/MAC/mac_helper.h" | ||
#include "6LoWPAN/MAC/mac_data_poll.h" | ||
#include "6LoWPAN/MAC/mpx_api.h" | ||
#include "6LoWPAN/MAC/mac_ie_lib.h" | ||
#include "MPL/mpl.h" | ||
#include "RPL/rpl_protocol.h" | ||
#include "RPL/rpl_control.h" | ||
#include "RPL/rpl_data.h" | ||
#include "RPL/rpl_policy.h" | ||
#include "Common_Protocols/icmpv6.h" | ||
#include "Common_Protocols/icmpv6_radv.h" | ||
#include "Common_Protocols/ipv6_constants.h" | ||
#include "Common_Protocols/ip.h" | ||
#include "Service_Libs/Trickle/trickle.h" | ||
#include "Service_Libs/fhss/channel_list.h" | ||
#include "Service_Libs/utils/ns_time.h" | ||
#include "6LoWPAN/ws/ws_common_defines.h" | ||
#include "6LoWPAN/ws/ws_common_defines.h" | ||
#include "6LoWPAN/ws/ws_config.h" | ||
#include "6LoWPAN/ws/ws_common.h" | ||
#include "6LoWPAN/ws/ws_bootstrap.h" | ||
#include "6LoWPAN/ws/ws_bbr_api_internal.h" | ||
#include "6LoWPAN/ws/ws_common_defines.h" | ||
#include "6LoWPAN/ws/ws_llc.h" | ||
#include "6LoWPAN/ws/ws_neighbor_class.h" | ||
#include "6LoWPAN/ws/ws_ie_lib.h" | ||
#include "6LoWPAN/ws/ws_stats.h" | ||
#include "6LoWPAN/ws/ws_cfg_settings.h" | ||
#include "6LoWPAN/lowpan_adaptation_interface.h" | ||
#include "Service_Libs/etx/etx.h" | ||
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h" | ||
#include "Service_Libs/nd_proxy/nd_proxy.h" | ||
#include "Service_Libs/blacklist/blacklist.h" | ||
#include "platform/topo_trace.h" | ||
#include "dhcp_service_api.h" | ||
#include "libDHCPv6/libDHCPv6.h" | ||
#include "libDHCPv6/libDHCPv6_vendordata.h" | ||
#include "DHCPv6_client/dhcpv6_client_api.h" | ||
#include "ws_management_api.h" | ||
#include "net_rpl.h" | ||
#include "mac_api.h" | ||
#include "6LoWPAN/ws/ws_pae_controller.h" | ||
#include "6LoWPAN/ws/ws_eapol_pdu.h" | ||
#include "6LoWPAN/ws/ws_eapol_auth_relay.h" | ||
#include "6LoWPAN/ws/ws_eapol_relay.h" | ||
#include "libNET/src/net_dns_internal.h" | ||
#include "Service_Libs/random_early_detection/random_early_detection_api.h" | ||
|
||
#define TRACE_GROUP "wsbs" | ||
|
||
static void ws_bootstrap_6lbr_pan_config_analyse(struct protocol_interface_info_entry *cur, const struct mcps_data_ind_s *data, const struct mcps_data_ie_list *ie_ext, ws_utt_ie_t *ws_utt, ws_us_ie_t *ws_us) | ||
{ | ||
ws_bs_ie_t ws_bs_ie; | ||
ws_bt_ie_t ws_bt_ie; | ||
llc_neighbour_req_t neighbor_info; | ||
|
||
if (data->SrcPANId != cur->ws_info->network_pan_id) { | ||
return; | ||
} | ||
if (!ws_wh_bt_read(ie_ext->headerIeList, ie_ext->headerIeListLength, &ws_bt_ie)) { | ||
tr_warn("BT-IE"); | ||
return; | ||
} | ||
|
||
if (!ws_wp_nested_bs_read(ie_ext->payloadIeList, ie_ext->payloadIeListLength, &ws_bs_ie)) { | ||
// Corrupted | ||
tr_error("No broadcast schedule"); | ||
return; | ||
} | ||
|
||
//If we are border router or learned configuration we only update already learned neighbours. | ||
|
||
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false)) { | ||
//Update Neighbor Broadcast and Unicast Parameters | ||
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, ws_utt, data->timestamp, (uint8_t *) data->SrcAddr); | ||
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, ws_us, &cur->ws_info->hopping_schdule); | ||
ws_neighbor_class_neighbor_broadcast_time_info_update(neighbor_info.ws_neighbor, &ws_bt_ie, data->timestamp); | ||
ws_neighbor_class_neighbor_broadcast_schedule_set(neighbor_info.ws_neighbor, &ws_bs_ie); | ||
} | ||
} | ||
|
||
static void ws_bootstrap_6lbr_pan_config_solicit_analyse(struct protocol_interface_info_entry *cur, const struct mcps_data_ind_s *data, ws_utt_ie_t *ws_utt, ws_us_ie_t *ws_us) | ||
{ | ||
llc_neighbour_req_t neighbor_info; | ||
|
||
if (data->SrcPANId != cur->ws_info->network_pan_id) { | ||
return; | ||
} | ||
|
||
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false)) { | ||
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, ws_utt, data->timestamp, (uint8_t *) data->SrcAddr); | ||
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, ws_us, &cur->ws_info->hopping_schdule); | ||
} | ||
} | ||
|
||
void ws_bootstrap_6lbr_asynch_ind(struct protocol_interface_info_entry *cur, const struct mcps_data_ind_s *data, const struct mcps_data_ie_list *ie_ext, uint8_t message_type) | ||
{ | ||
// Store weakest heard packet RSSI | ||
if (cur->ws_info->weakest_received_rssi > data->signal_dbm) { | ||
cur->ws_info->weakest_received_rssi = data->signal_dbm; | ||
} | ||
|
||
if (data->SrcAddrMode != MAC_ADDR_MODE_64_BIT) { | ||
// Not from long address | ||
return; | ||
} | ||
ws_stats_update(cur, STATS_WS_ASYNCH_RX, 1); | ||
//Validate network name | ||
switch (message_type) { | ||
case WS_FT_PAN_ADVERT: | ||
case WS_FT_PAN_ADVERT_SOL: | ||
case WS_FT_PAN_CONF_SOL: | ||
//Check Network Name | ||
if (!ws_bootstrap_network_name_matches(ie_ext, cur->ws_info->cfg->gen.network_name)) { | ||
// Not in our network | ||
return; | ||
} | ||
break; | ||
case WS_FT_PAN_CONF: | ||
break; | ||
default: | ||
return; | ||
} | ||
//UTT-IE and US-IE are mandatory for all Asynch Messages | ||
ws_utt_ie_t ws_utt; | ||
if (!ws_wh_utt_read(ie_ext->headerIeList, ie_ext->headerIeListLength, &ws_utt)) { | ||
// Corrupted | ||
return; | ||
} | ||
|
||
ws_us_ie_t ws_us; | ||
if (!ws_wp_nested_us_read(ie_ext->payloadIeList, ie_ext->payloadIeListLength, &ws_us)) { | ||
// Corrupted | ||
return; | ||
} | ||
|
||
if (!ws_bootstrap_validate_channel_plan(&ws_us, cur) || | ||
!ws_bootstrap_validate_channel_function(&ws_us, NULL)) { | ||
return; | ||
} | ||
|
||
//Handle Message's | ||
switch (message_type) { | ||
case WS_FT_PAN_ADVERT: | ||
// Analyse Advertisement | ||
ws_stats_update(cur, STATS_WS_ASYNCH_RX_PA, 1); | ||
tr_info("received ADVERT Src:%s panid:%x rssi:%d", trace_array(data->SrcAddr, 8), data->SrcPANId, data->signal_dbm); | ||
// Border routers do not do any analysing on the Advertisements heard from others | ||
// in future if we need PANID conflict detection we could use this | ||
break; | ||
case WS_FT_PAN_ADVERT_SOL: | ||
ws_stats_update(cur, STATS_WS_ASYNCH_RX_PAS, 1); | ||
tr_info("received ADVERT SOL Src:%s rssi:%d", trace_array(data->SrcAddr, 8), data->signal_dbm); | ||
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement, &cur->ws_info->trickle_params_pan_discovery); | ||
|
||
break; | ||
case WS_FT_PAN_CONF: | ||
ws_stats_update(cur, STATS_WS_ASYNCH_RX_PC, 1); | ||
tr_info("received CONFIG Src:%s rssi:%d", trace_array(data->SrcAddr, 8), data->signal_dbm); | ||
ws_bootstrap_6lbr_pan_config_analyse(cur, data, ie_ext, &ws_utt, &ws_us); | ||
break; | ||
case WS_FT_PAN_CONF_SOL: | ||
ws_stats_update(cur, STATS_WS_ASYNCH_RX_PCS, 1); | ||
tr_info("received CONFIG SOL Src:%s rssi:%d", trace_array(data->SrcAddr, 8), data->signal_dbm); | ||
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config, &cur->ws_info->trickle_params_pan_discovery); | ||
ws_bootstrap_6lbr_pan_config_solicit_analyse(cur, data, &ws_utt, &ws_us); | ||
default: | ||
// Unknown message do not process | ||
break; | ||
} | ||
} | ||
|
||
void ws_bootstrap_6lbr_asynch_confirm(struct protocol_interface_info_entry *interface, uint8_t asynch_message) | ||
{ | ||
ws_stats_update(interface, STATS_WS_ASYNCH_TX, 1); | ||
if (interface->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) { | ||
if (asynch_message == WS_FT_PAN_CONF && interface->ws_info->pending_key_index_info.state == PENDING_KEY_INDEX_ACTIVATE) { | ||
interface->ws_info->pending_key_index_info.state = NO_PENDING_PROCESS; | ||
tr_info("Activate new default key %u", interface->ws_info->pending_key_index_info.index + 1); | ||
mac_helper_security_auto_request_key_index_set(interface, interface->ws_info->pending_key_index_info.index, interface->ws_info->pending_key_index_info.index + 1); | ||
} | ||
} | ||
} | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2021, Pelion and affiliates. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef WS_BOOTSTRAP_6LBR_H_ | ||
#define WS_BOOTSTRAP_6LBR_H_ | ||
|
||
#ifdef HAVE_WS | ||
|
||
void ws_bootstrap_6lbr_asynch_ind(struct protocol_interface_info_entry *cur, const struct mcps_data_ind_s *data, const struct mcps_data_ie_list *ie_ext, uint8_t message_type); | ||
void ws_bootstrap_6lbr_asynch_confirm(struct protocol_interface_info_entry *interface, uint8_t asynch_message); | ||
|
||
#else | ||
|
||
#endif //HAVE_WS | ||
|
||
#endif /* WS_BOOTSTRAP_H_ */ |
Oops, something went wrong.