Skip to content

Commit

Permalink
Squashed 'features/nanostack/sal-stack-nanostack/' changes from 4a3c5c5
Browse files Browse the repository at this point in the history
…..225a4af

225a4af Remove files from tests folder
58d2c8f Merge remote-tracking branch 'origin/release_internal' into release_external
921b4b3 Wi-SUN FAN 1.1 dynamic MDR data request enabler
b8722e8 Corrected BR removing of waiting list entry when supplicant is in key storage
0d54d7a Adjust trace levels (ARMmbed#2692)
681d9ea Added reset for pan id and version to BR network start
30d4fb2 Renaming and cleaning ws bootstrap (ARMmbed#2688)
e0da19d Add Wi-SUN host configuration (ARMmbed#2690)
50ecc3d Refactoring Wi-SUN stack (ARMmbed#2686)
9d2386d Renamed operation mode to operating mode.
2f755bc RF config resolver and some refactoring (ARMmbed#2683)
86c6d19 Fixed WS IE PCAP read operation wrong length usage.
cd3a4c2 Config: Remove additional HAVE_WS_ROUTER (ARMmbed#2684)
cdd7f2d Added API for configure supported Phy capability.
a00a3c0 Wi-SUN FAN 1.1 PCAP IE update
2d063d3 Moved State machine and timer functions to own files
edb8bec Corrected system time check function return values
85358a6 Moved Wi-SUN Bootstrap Event handling to separate device handlers
61cbdde MAC to support mode switch on single channel (ARMmbed#2678)
1006d29 Added storing of PAN ID to NVM in BBR
7bf0028 Corrected system time jump detection on BR startup
e60974d Split Wi-SUN bootstrap to device types
a3f3412 MAC data req: API to support mode switch (ARMmbed#2674)
cad5122 Removed automatic network size configuration (ARMmbed#2673)
35d3132 MAC: Callback set to resolve PHY mode ID (ARMmbed#2672)
0c5faca Added support for large system time changes (e.g. due to NTP) (ARMmbed#2670)
c94b306 LFN version and LGTK Hash IE advertisment and learn
8e07511 Use FAN version constant  instead of pure number
a5566b2 Channel Plan 2 validation and FAN 1.0 reject
42dba41 Wi-Sun IE FAN 1.1 update
1d56070 EU channel plan ids (FAN 1.1) supported (ARMmbed#2668)
fc4f41f Add test API empty function
37efc7e Add version 1.1 basic support
e1558fb Implemented mode switch PHR build and parse (ARMmbed#2665)
cbd8a15 Corrected frame counter storing threshold check
37f7ae9 Time configuration distribution using DHCPv6 vendor data
7415bc7 Added checks for Border Router frame counter space exhaustion (ARMmbed#2660)
f1a65ec Mode switch PHY API (ARMmbed#2663)
e54231b Do not check buffer age when virtual RF driver used (ARMmbed#2662)
cc8c7bd arm_network_certificate_chain_set() returns -2 when PANA is disabled
319dd91 Fix dubious semicolon in #define
2ff51ab Remove extra '\n' in traces
19376c8 Simplify array indexes
c808661 Fix ASAN warnings about overflows in bit shifts
f998008 Fix use-after-free in mac_helper_coordinator_address_set()
4d04541 Wi-SUN header and Paylod IE element lenght future proof update.
935898b Medium network PAN_TIMEOUT changed to 30 minutes
1af7cfe Updated nanostack to be compatible with mbed TLS 3.0 (ARMmbed#2657)
29744e0 If Router Solicitation creation fails no longer tries to retry the RS right away (ARMmbed#2655)
2b889e9 Added automatic test procedure triggering during bootstrap
ed9eb05 GTKs are removed only when fresh GTK hash is received
81ecdc2 Added empty function for test procedure trigger
14439b4 Added support for triggering test procedures
b8a67a9 Update CHANGELOG.md for Nanostack 14.0.0 (ARMmbed#2649)

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 225a4af
  • Loading branch information
artokin committed Sep 23, 2021
1 parent 90199fd commit ca1f4fe
Show file tree
Hide file tree
Showing 100 changed files with 6,770 additions and 2,508 deletions.
69 changes: 46 additions & 23 deletions nanostack/mac_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ typedef void mcps_data_request(const mac_api_t *api, const mcps_data_req_t *data
* @param ie_ext Information element list to MCPS-DATA.request
* @param asynch_channel_list Optional channel list to asynch data request. Give NULL when normal data request.
* @param priority Data request priority level
* @param phy_mode_id Use mode switch if given phy_mode_id > 0
*
* Asynch data request is mac standard extension. asynch_channel_list include channel mask which channel message is requested to send.
*/
typedef void mcps_data_request_ext(const mac_api_t *api, const mcps_data_req_t *data, const mcps_data_req_ie_list_t *ie_ext, const struct channel_list_s *asynch_channel_list, mac_data_priority_t priority);
typedef void mcps_data_request_ext(const mac_api_t *api, const mcps_data_req_t *data, const mcps_data_req_ie_list_t *ie_ext, const struct channel_list_s *asynch_channel_list, mac_data_priority_t priority, uint8_t phy_mode_id);

/**
* @brief mcps_purge_request MCPS_PURGE request call
Expand Down Expand Up @@ -192,6 +193,16 @@ typedef void mcps_ack_data_req_ext(const mac_api_t *api, mcps_ack_data_payload_t
typedef void mcps_edfe_handler(const mac_api_t *api, mcps_edfe_response_t *response_message);


/**
* @brief mode_switch_resolver Callback to resolve configuration behind received PHY mode ID
* @param api The API which handled the response
* @param phy_mode_id PHY mode ID to be resolved
* @param rf_config Resolved configuration
* @return 0 in case of success, negative otherwise
*/
typedef int8_t mode_switch_resolver(const mac_api_t *api, uint8_t phy_mode_id, phy_rf_channel_configuration_s *rf_config);


/**
* @brief mcps_purge_confirm MCPS-PURGE confirm is called as a response to MCPS-PURGE request
* @param api The API which handled the request
Expand Down Expand Up @@ -272,37 +283,49 @@ typedef int8_t mac_api_enable_mcps_ext(mac_api_t *api,
typedef int8_t mac_api_enable_mcps_edfe_ext(mac_api_t *api,
mcps_edfe_handler *edfe_ind_cb);

/**
* @brief mac_api_mode_switch_resolver_ext Initialises mode switch resolver callback. Upper layer must configure function when mode switch is used.
* @param api mac_api_t pointer, which is created by application.
* @param mode_resolver_cb Upper layer function to resolve received PHY mode ID
* @param base_phy_mode Base PHY mode, device returns to this mode after mode switch transmission or reception
* @return -1 if error, 0 otherwise
*/
typedef int8_t mac_api_mode_switch_resolver_ext(mac_api_t *api,
mode_switch_resolver *mode_resolver_cb, uint8_t base_phy_mode);

/**
* \brief Struct mac_api_s defines functions for two-way communications between external MAC and Upper layer.
* Application creates mac_api_t object by calling external MAC's creator function.
* Then object is passed to Upper layer which then initializes it's own callback functions.
* Then MAC is operated by Upper layer by calling MLME or MCPS primitive functions.
*/
struct mac_api_s {
mac_api_initialize *mac_initialize; /**< MAC initialize function to use */
mac_api_enable_mcps_ext *mac_mcps_extension_enable; /**< MAC MCPS IE extension enable function, optional feature */
mac_api_enable_mcps_edfe_ext *mac_mcps_edfe_enable; /**< MAC MCPS MCPS EDFE frame extension enable function, optional feature */
mac_api_initialize *mac_initialize; /**< MAC initialize function to use */
mac_api_enable_mcps_ext *mac_mcps_extension_enable; /**< MAC MCPS IE extension enable function, optional feature */
mac_api_enable_mcps_edfe_ext *mac_mcps_edfe_enable; /**< MAC MCPS MCPS EDFE frame extension enable function, optional feature */
mac_api_mode_switch_resolver_ext *mac_mode_switch_resolver_set; /**< MAC Mode switch resolver function set, optional feature */
//External MAC callbacks
mlme_request *mlme_req; /**< MAC MLME request function to use */
mcps_data_request *mcps_data_req; /**< MAC MCPS data request function to use */
mcps_data_request_ext *mcps_data_req_ext; /**< MAC MCPS data request with Information element extension function to use */
mcps_purge_request *mcps_purge_req; /**< MAC MCPS purge request function to use */
mlme_request *mlme_req; /**< MAC MLME request function to use */
mcps_data_request *mcps_data_req; /**< MAC MCPS data request function to use */
mcps_data_request_ext *mcps_data_req_ext; /**< MAC MCPS data request with Information element extension function to use */
mcps_purge_request *mcps_purge_req; /**< MAC MCPS purge request function to use */
//Upper layer callbacksMLME_ASSOCIATE
mcps_data_confirm *data_conf_cb; /**< MAC MCPS data confirm callback function */
mcps_data_confirm_ext *data_conf_ext_cb; /**< MAC MCPS data confirm with payload callback function */
mcps_data_indication *data_ind_cb; /**< MAC MCPS data indication callback function */
mcps_data_indication_ext *data_ind_ext_cb; /**< MAC MCPS data indication with IE extension's callback function */
mcps_edfe_handler *edfe_ind_cb; /**< MAC MCPS EDFE detection extension's callback function */
mcps_ack_data_req_ext *enhanced_ack_data_req_cb; /**< Enhanced ACK IE element and payload request from MAC user */
mcps_purge_confirm *purge_conf_cb; /**< MAC MCPS purge confirm callback function */
mlme_confirm *mlme_conf_cb; /**< MAC MLME confirm callback function */
mlme_indication *mlme_ind_cb; /**< MAC MLME indication callback function */
mac_ext_mac64_address_set *mac64_set; /**< MAC extension function to set mac64 address */
mac_ext_mac64_address_get *mac64_get; /**< MAC extension function to get mac64 address */
mac_storage_decription_sizes_get *mac_storage_sizes_get; /**< Getter function to query data storage sizes from MAC */

int8_t parent_id; /**< Upper layer id */
uint16_t phyMTU; /**< Maximum Transmission Unit(MTU) used by MAC*/
mcps_data_confirm *data_conf_cb; /**< MAC MCPS data confirm callback function */
mcps_data_confirm_ext *data_conf_ext_cb; /**< MAC MCPS data confirm with payload callback function */
mcps_data_indication *data_ind_cb; /**< MAC MCPS data indication callback function */
mcps_data_indication_ext *data_ind_ext_cb; /**< MAC MCPS data indication with IE extension's callback function */
mcps_edfe_handler *edfe_ind_cb; /**< MAC MCPS EDFE detection extension's callback function */
mode_switch_resolver *mode_resolver_cb; /**< MAC Mode switch resolver callback function */
mcps_ack_data_req_ext *enhanced_ack_data_req_cb; /**< Enhanced ACK IE element and payload request from MAC user */
mcps_purge_confirm *purge_conf_cb; /**< MAC MCPS purge confirm callback function */
mlme_confirm *mlme_conf_cb; /**< MAC MLME confirm callback function */
mlme_indication *mlme_ind_cb; /**< MAC MLME indication callback function */
mac_ext_mac64_address_set *mac64_set; /**< MAC extension function to set mac64 address */
mac_ext_mac64_address_get *mac64_get; /**< MAC extension function to get mac64 address */
mac_storage_decription_sizes_get *mac_storage_sizes_get; /**< Getter function to query data storage sizes from MAC */

int8_t parent_id; /**< Upper layer id */
uint16_t phyMTU; /**< Maximum Transmission Unit(MTU) used by MAC*/
};

/**
Expand Down
17 changes: 17 additions & 0 deletions nanostack/net_ws_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ extern "C" {

#include "ns_types.h"

/**
* \brief Set Wi-SUN version number
*
* Sets the Wi-SUN protocol version.
* 1 = Wi-SUN FAN 1.0
* 2 = Wi-SUN FAN 1.1
*
* Set version to 0 to stop override and use stack default
*
* \param interface_id Network Interface
* \param version Wi-SUN version
*
* \return 0 OK
* \return <0 Failure
*/

int ws_test_version_set(int8_t interface_id, uint8_t version);
/**
* \brief Set Pan size.
*
Expand Down
119 changes: 119 additions & 0 deletions nanostack/net_ws_test_ext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* 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 NET_WS_TEST_EXT_H_
#define NET_WS_TEST_EXT_H_

/**
* \file net_ws_test_ext.h
* \brief Wi-SUN Library External Test API.
*
*/

#ifdef __cplusplus
extern "C" {
#endif

#include "ns_types.h"

/* Test procedure triggers
*
* Example about using the triggers during bootstrap to trigger
* messages and state transitions.
*
* Border Router Node
*
* Join state 1 (select PAN)
*
* PROC_PA
* ------- PAN Advertisement------------>
*
* PROC_EAPOL
* Select EAPOL target
* Join state 2 (authenticate)
* <------ EAPOL authentication -------->
* Join State 3 (acquire PAN configuration)
*
* PROC_PC
* ------- PAN Configuration ----------->
* Join state 4 (configure routing)
*
* PROC_DIO
* ------- DIO ------------------------->
* Neighbor discovery (NS probing for ETX)
* Create RPL candidate parent set
*
* PROC_RPL
* Select RPL parent
* <------ DHCP ------------------------>
*
* PROC_DAO
* <------ DAO --------------------------
* ------- DAO acknowledge ------------->
*
* Join state 5 (operational)
*
*
* On automatic mode the PROC_PAS, PROC_EAPOL, PROC_PCS, PROC_DIS and PROC_RPL
* will be triggered automatically by the node during the bootstrap.
*
*/

/**
* @brief Test procedure triggers.
*/
typedef enum {
PROC_DIS, /* trigger DODAG information object solicit (node) */
PROC_DIO, /* trigger DODAG information object (BR, node) */
PROC_DAO, /* trigger Destination advertisement object (node) */

PROC_PAS, /* trigger PAN Advertisement Solicit (node) */
PROC_PA, /* trigger PAN Advertisement (BR, node) */
PROC_PCS, /* trigger PAN Configuration Solicit (node) */
PROC_PC, /* trigger PAN Configuration (BR, node) */

PROC_EAPOL, /* trigger EAPOL target selection (initiates authentication, node) */
PROC_RPL, /* trigger RPL parent selection (node) */

PROC_AUTO_ON, /* trigger bootstrap test procedures automatically */
PROC_AUTO_OFF, /* disable automatic bootstrap test procedure triggering */

MSG_NONE
} ws_test_proc_t;

/**
* Trigger a test procedure
*
* Can be used to trigger a test procedure, e.g. to send a message (DIS,
* DIO, DAO, PAS, PS, PCS and PC) or to trigger bootstrap state change
* on node e.g. EAPOL target selection.
*
* \param interface_id Network Interface ID >= 0 or -1 for Wi-SUN mesh interface
* Default value is -1
* \param procedure Triggered procedure
* \param parameters Parameters for future extensions, shall be set to NULL
*
* \return 0 Success
* \return <0 Failure
*/
int ws_test_procedure_trigger(int8_t interface_id, ws_test_proc_t procedure, void *parameters);

#ifdef __cplusplus
}
#endif

#endif /* NET_WS_TEST_EXT_H_ */
32 changes: 32 additions & 0 deletions nanostack/ns_sha256.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,45 +61,77 @@ static inline void ns_sha256_clone(ns_sha256_context *dst,

static inline void ns_sha256_starts(ns_sha256_context *ctx)
{
#if (MBEDTLS_VERSION_MAJOR >= 3)
(void)mbedtls_sha256_starts(ctx, 0);
#else
(void)mbedtls_sha256_starts_ret(ctx, 0);
#endif
}

static inline void ns_sha256_update(ns_sha256_context *ctx, const void *input,
size_t ilen)
{
#if (MBEDTLS_VERSION_MAJOR >= 3)
(void)mbedtls_sha256_update(ctx, input, ilen);
#else
(void)mbedtls_sha256_update_ret(ctx, input, ilen);
#endif
}

static inline void ns_sha256_finish(ns_sha256_context *ctx, void *output)
{
#if (MBEDTLS_VERSION_MAJOR >= 3)
(void)mbedtls_sha256_finish(ctx, output);
#else
(void)mbedtls_sha256_finish_ret(ctx, output);
#endif
}

static inline void ns_sha256(const void *input, size_t ilen, void *output)
{
#if (MBEDTLS_VERSION_MAJOR >= 3)
(void)mbedtls_sha256(input, ilen, output, 0);
#else
(void)mbedtls_sha256_ret(input, ilen, output, 0);
#endif
}

/* Extensions to standard mbed TLS - output the first bits of a hash only */
/* Number of bits must be a multiple of 32, and <=256 */
static inline void ns_sha256_finish_nbits(ns_sha256_context *ctx, void *output, unsigned obits)
{
if (obits == 256) {
#if (MBEDTLS_VERSION_MAJOR >= 3)
(void)mbedtls_sha256_finish(ctx, output);
#else
(void)mbedtls_sha256_finish_ret(ctx, output);
#endif
} else {
uint8_t sha256[32];
#if (MBEDTLS_VERSION_MAJOR >= 3)
(void)mbedtls_sha256_finish(ctx, sha256);
#else
(void)mbedtls_sha256_finish_ret(ctx, sha256);
#endif
memcpy(output, sha256, obits / 8);
}
}

static inline void ns_sha256_nbits(const void *input, size_t ilen, void *output, unsigned obits)
{
if (obits == 256) {
#if (MBEDTLS_VERSION_MAJOR >= 3)
(void)mbedtls_sha256(input, ilen, output, 0);
#else
(void)mbedtls_sha256_ret(input, ilen, output, 0);
#endif
} else {
uint8_t sha256[32];
#if (MBEDTLS_VERSION_MAJOR >= 3)
(void)mbedtls_sha256(input, ilen, sha256, 0);
#else
(void)mbedtls_sha256_ret(input, ilen, sha256, 0);
#endif
memcpy(output, sha256, obits / 8);
}
}
Expand Down
45 changes: 45 additions & 0 deletions nanostack/ns_time_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@

#include "ns_types.h"

/**
* Time zone information structure.
*
* Daylight saving time and time zone information learned by network stack
*
*/
typedef struct timezone_info {
/** Timestamp of the Daylight saving time change*/
uint64_t timestamp;
/** Time zone information in minutes*/
int16_t timezone;
/** Change that is applied when timestamp is reached*/
int16_t deviation;
/** Time configuration status bit field
* "bit xxxxxxxxxxxxxxxS" 0 = false 1 = true Daylight saving time status*/
uint16_t status;
} timezone_info_t;

/**
* System time read callback.
*
Expand All @@ -48,6 +66,22 @@ typedef uint64_t ns_time_api_system_time_callback(void);
*/
typedef void ns_time_api_system_time_write_callback(uint64_t write_time);

/**
* New time zone and daylight saving time information learned from stack.
*
* Called when network stack learns the time zone and daylights saving time information.
*
* In Wi-SUN Border router can distribute this information to synchronize all nodes in network.
* This information is updated roughly once a day using DHCPv6 protocol
*
* If network stack does not have the information this is not called and can be called when information becomes available.
* This can be called multiple times with same information.
*
* \param info_ptr time zone and daylight saving time configuration.
*
*/
typedef void ns_time_api_time_configuration_notify_callback(timezone_info_t *info_ptr);

/**
* System time read callback set.
*
Expand All @@ -68,4 +102,15 @@ void ns_time_api_system_time_callback_set(ns_time_api_system_time_callback callb
*/
void ns_time_api_system_time_write_callback_set(ns_time_api_system_time_write_callback callback_wr);

/**
* Set system time configuration notify callback.
*
* Sets system time configuration notify callback that is called if network stack
* learns time information from other devices in the network.
*
* \param callback_wr system time write callback.
*
*/
void ns_time_api_time_configuration_notify_callback_set(ns_time_api_time_configuration_notify_callback callback_wr);

#endif /* NS_TIME_API_H_ */
1 change: 1 addition & 0 deletions nanostack/platform/arm_hal_phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ typedef struct phy_signal_info_s {
typedef struct phy_csma_params {
uint32_t backoff_time; /**< CSMA Backoff us time before start CCA & TX. 0 should disable current backoff*/
bool cca_enabled; /**< True will affect CCA check false start TX direct after backoff */
bool mode_switch_phr; /**< True - Frame is a mode switch PHR. In this case PHY driver should skip FCS and send two byte PHR as it is given by TX callback */
} phy_csma_params_t;

/** PHY modulation scheme */
Expand Down
Loading

0 comments on commit ca1f4fe

Please sign in to comment.