mirror of https://github.com/ARMmbed/mbed-os.git
173 lines
5.6 KiB
C
173 lines
5.6 KiB
C
/*
|
|
* 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"
|
|
#if defined(HAVE_WS) && defined(HAVE_WS_HOST)
|
|
#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"
|
|
|
|
|
|
void ws_bootstrap_lfn_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)ie_ext;
|
|
// 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);
|
|
tr_warn("Wi-SUN LFN Mode received message id: %x", message_type);
|
|
}
|
|
|
|
void ws_bootstrap_lfn_asynch_confirm(struct protocol_interface_info_entry *interface, uint8_t asynch_message)
|
|
{
|
|
(void)asynch_message;
|
|
ws_stats_update(interface, STATS_WS_ASYNCH_TX, 1);
|
|
}
|
|
|
|
void ws_bootstrap_lfn_event_handler(protocol_interface_info_entry_t *cur, arm_event_s *event)
|
|
{
|
|
(void)cur;
|
|
ws_bootsrap_event_type_e event_type;
|
|
event_type = (ws_bootsrap_event_type_e)event->event_type;
|
|
|
|
switch (event_type) {
|
|
case WS_INIT_EVENT:
|
|
tr_debug("tasklet init");
|
|
break;
|
|
/* case WS_DISCOVERY_START:
|
|
case WS_CONFIGURATION_START:
|
|
case WS_OPERATION_START:
|
|
case WS_ROUTING_READY:
|
|
case WS_FAST_DISCONNECT:
|
|
case WS_NORMAL_DISCONNECT:
|
|
*/
|
|
default:
|
|
tr_err("Invalid event received");
|
|
break;
|
|
}
|
|
}
|
|
|
|
void ws_bootstrap_lfn_state_machine(protocol_interface_info_entry_t *cur)
|
|
{
|
|
|
|
switch (cur->nwk_bootstrap_state) {
|
|
case ER_WAIT_RESTART:
|
|
tr_debug("WS SM:Wait for startup");
|
|
break;
|
|
case ER_ACTIVE_SCAN:
|
|
tr_debug("WS SM:Active Scan");
|
|
break;
|
|
case ER_SCAN:
|
|
tr_debug("WS SM:configuration Scan");
|
|
break;
|
|
case ER_PANA_AUTH:
|
|
tr_info("authentication start");
|
|
// Advertisements stopped during the EAPOL
|
|
break;
|
|
case ER_RPL_SCAN:
|
|
tr_debug("WS SM:Wait RPL to contact DODAG root");
|
|
break;
|
|
case ER_BOOTSRAP_DONE:
|
|
tr_info("WS SM:Bootstrap Done");
|
|
// Bootstrap_done event to application
|
|
break;
|
|
case ER_RPL_NETWORK_LEAVING:
|
|
tr_debug("WS SM:RPL Leaving ready trigger discovery");
|
|
break;
|
|
default:
|
|
tr_warn("WS SM:Invalid state %d", cur->nwk_bootstrap_state);
|
|
}
|
|
}
|
|
|
|
void ws_bootstrap_lfn_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds)
|
|
{
|
|
(void)cur;
|
|
(void)seconds;
|
|
}
|
|
|
|
|
|
#endif //HAVE_WS_BORDER_ROUTER && HAVE_WS
|