Skip to content

Commit ca1f4fe

Browse files
committed
Squashed 'features/nanostack/sal-stack-nanostack/' changes from 4a3c5c5..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
1 parent 90199fd commit ca1f4fe

File tree

100 files changed

+6770
-2508
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+6770
-2508
lines changed

nanostack/mac_api.h

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,11 @@ typedef void mcps_data_request(const mac_api_t *api, const mcps_data_req_t *data
129129
* @param ie_ext Information element list to MCPS-DATA.request
130130
* @param asynch_channel_list Optional channel list to asynch data request. Give NULL when normal data request.
131131
* @param priority Data request priority level
132+
* @param phy_mode_id Use mode switch if given phy_mode_id > 0
132133
*
133134
* Asynch data request is mac standard extension. asynch_channel_list include channel mask which channel message is requested to send.
134135
*/
135-
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);
136+
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);
136137

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

194195

196+
/**
197+
* @brief mode_switch_resolver Callback to resolve configuration behind received PHY mode ID
198+
* @param api The API which handled the response
199+
* @param phy_mode_id PHY mode ID to be resolved
200+
* @param rf_config Resolved configuration
201+
* @return 0 in case of success, negative otherwise
202+
*/
203+
typedef int8_t mode_switch_resolver(const mac_api_t *api, uint8_t phy_mode_id, phy_rf_channel_configuration_s *rf_config);
204+
205+
195206
/**
196207
* @brief mcps_purge_confirm MCPS-PURGE confirm is called as a response to MCPS-PURGE request
197208
* @param api The API which handled the request
@@ -272,37 +283,49 @@ typedef int8_t mac_api_enable_mcps_ext(mac_api_t *api,
272283
typedef int8_t mac_api_enable_mcps_edfe_ext(mac_api_t *api,
273284
mcps_edfe_handler *edfe_ind_cb);
274285

286+
/**
287+
* @brief mac_api_mode_switch_resolver_ext Initialises mode switch resolver callback. Upper layer must configure function when mode switch is used.
288+
* @param api mac_api_t pointer, which is created by application.
289+
* @param mode_resolver_cb Upper layer function to resolve received PHY mode ID
290+
* @param base_phy_mode Base PHY mode, device returns to this mode after mode switch transmission or reception
291+
* @return -1 if error, 0 otherwise
292+
*/
293+
typedef int8_t mac_api_mode_switch_resolver_ext(mac_api_t *api,
294+
mode_switch_resolver *mode_resolver_cb, uint8_t base_phy_mode);
295+
275296
/**
276297
* \brief Struct mac_api_s defines functions for two-way communications between external MAC and Upper layer.
277298
* Application creates mac_api_t object by calling external MAC's creator function.
278299
* Then object is passed to Upper layer which then initializes it's own callback functions.
279300
* Then MAC is operated by Upper layer by calling MLME or MCPS primitive functions.
280301
*/
281302
struct mac_api_s {
282-
mac_api_initialize *mac_initialize; /**< MAC initialize function to use */
283-
mac_api_enable_mcps_ext *mac_mcps_extension_enable; /**< MAC MCPS IE extension enable function, optional feature */
284-
mac_api_enable_mcps_edfe_ext *mac_mcps_edfe_enable; /**< MAC MCPS MCPS EDFE frame extension enable function, optional feature */
303+
mac_api_initialize *mac_initialize; /**< MAC initialize function to use */
304+
mac_api_enable_mcps_ext *mac_mcps_extension_enable; /**< MAC MCPS IE extension enable function, optional feature */
305+
mac_api_enable_mcps_edfe_ext *mac_mcps_edfe_enable; /**< MAC MCPS MCPS EDFE frame extension enable function, optional feature */
306+
mac_api_mode_switch_resolver_ext *mac_mode_switch_resolver_set; /**< MAC Mode switch resolver function set, optional feature */
285307
//External MAC callbacks
286-
mlme_request *mlme_req; /**< MAC MLME request function to use */
287-
mcps_data_request *mcps_data_req; /**< MAC MCPS data request function to use */
288-
mcps_data_request_ext *mcps_data_req_ext; /**< MAC MCPS data request with Information element extension function to use */
289-
mcps_purge_request *mcps_purge_req; /**< MAC MCPS purge request function to use */
308+
mlme_request *mlme_req; /**< MAC MLME request function to use */
309+
mcps_data_request *mcps_data_req; /**< MAC MCPS data request function to use */
310+
mcps_data_request_ext *mcps_data_req_ext; /**< MAC MCPS data request with Information element extension function to use */
311+
mcps_purge_request *mcps_purge_req; /**< MAC MCPS purge request function to use */
290312
//Upper layer callbacksMLME_ASSOCIATE
291-
mcps_data_confirm *data_conf_cb; /**< MAC MCPS data confirm callback function */
292-
mcps_data_confirm_ext *data_conf_ext_cb; /**< MAC MCPS data confirm with payload callback function */
293-
mcps_data_indication *data_ind_cb; /**< MAC MCPS data indication callback function */
294-
mcps_data_indication_ext *data_ind_ext_cb; /**< MAC MCPS data indication with IE extension's callback function */
295-
mcps_edfe_handler *edfe_ind_cb; /**< MAC MCPS EDFE detection extension's callback function */
296-
mcps_ack_data_req_ext *enhanced_ack_data_req_cb; /**< Enhanced ACK IE element and payload request from MAC user */
297-
mcps_purge_confirm *purge_conf_cb; /**< MAC MCPS purge confirm callback function */
298-
mlme_confirm *mlme_conf_cb; /**< MAC MLME confirm callback function */
299-
mlme_indication *mlme_ind_cb; /**< MAC MLME indication callback function */
300-
mac_ext_mac64_address_set *mac64_set; /**< MAC extension function to set mac64 address */
301-
mac_ext_mac64_address_get *mac64_get; /**< MAC extension function to get mac64 address */
302-
mac_storage_decription_sizes_get *mac_storage_sizes_get; /**< Getter function to query data storage sizes from MAC */
303-
304-
int8_t parent_id; /**< Upper layer id */
305-
uint16_t phyMTU; /**< Maximum Transmission Unit(MTU) used by MAC*/
313+
mcps_data_confirm *data_conf_cb; /**< MAC MCPS data confirm callback function */
314+
mcps_data_confirm_ext *data_conf_ext_cb; /**< MAC MCPS data confirm with payload callback function */
315+
mcps_data_indication *data_ind_cb; /**< MAC MCPS data indication callback function */
316+
mcps_data_indication_ext *data_ind_ext_cb; /**< MAC MCPS data indication with IE extension's callback function */
317+
mcps_edfe_handler *edfe_ind_cb; /**< MAC MCPS EDFE detection extension's callback function */
318+
mode_switch_resolver *mode_resolver_cb; /**< MAC Mode switch resolver callback function */
319+
mcps_ack_data_req_ext *enhanced_ack_data_req_cb; /**< Enhanced ACK IE element and payload request from MAC user */
320+
mcps_purge_confirm *purge_conf_cb; /**< MAC MCPS purge confirm callback function */
321+
mlme_confirm *mlme_conf_cb; /**< MAC MLME confirm callback function */
322+
mlme_indication *mlme_ind_cb; /**< MAC MLME indication callback function */
323+
mac_ext_mac64_address_set *mac64_set; /**< MAC extension function to set mac64 address */
324+
mac_ext_mac64_address_get *mac64_get; /**< MAC extension function to get mac64 address */
325+
mac_storage_decription_sizes_get *mac_storage_sizes_get; /**< Getter function to query data storage sizes from MAC */
326+
327+
int8_t parent_id; /**< Upper layer id */
328+
uint16_t phyMTU; /**< Maximum Transmission Unit(MTU) used by MAC*/
306329
};
307330

308331
/**

nanostack/net_ws_test.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ extern "C" {
3939

4040
#include "ns_types.h"
4141

42+
/**
43+
* \brief Set Wi-SUN version number
44+
*
45+
* Sets the Wi-SUN protocol version.
46+
* 1 = Wi-SUN FAN 1.0
47+
* 2 = Wi-SUN FAN 1.1
48+
*
49+
* Set version to 0 to stop override and use stack default
50+
*
51+
* \param interface_id Network Interface
52+
* \param version Wi-SUN version
53+
*
54+
* \return 0 OK
55+
* \return <0 Failure
56+
*/
57+
58+
int ws_test_version_set(int8_t interface_id, uint8_t version);
4259
/**
4360
* \brief Set Pan size.
4461
*

nanostack/net_ws_test_ext.h

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
* Copyright (c) 2021, Pelion and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef NET_WS_TEST_EXT_H_
19+
#define NET_WS_TEST_EXT_H_
20+
21+
/**
22+
* \file net_ws_test_ext.h
23+
* \brief Wi-SUN Library External Test API.
24+
*
25+
*/
26+
27+
#ifdef __cplusplus
28+
extern "C" {
29+
#endif
30+
31+
#include "ns_types.h"
32+
33+
/* Test procedure triggers
34+
*
35+
* Example about using the triggers during bootstrap to trigger
36+
* messages and state transitions.
37+
*
38+
* Border Router Node
39+
*
40+
* Join state 1 (select PAN)
41+
*
42+
* PROC_PA
43+
* ------- PAN Advertisement------------>
44+
*
45+
* PROC_EAPOL
46+
* Select EAPOL target
47+
* Join state 2 (authenticate)
48+
* <------ EAPOL authentication -------->
49+
* Join State 3 (acquire PAN configuration)
50+
*
51+
* PROC_PC
52+
* ------- PAN Configuration ----------->
53+
* Join state 4 (configure routing)
54+
*
55+
* PROC_DIO
56+
* ------- DIO ------------------------->
57+
* Neighbor discovery (NS probing for ETX)
58+
* Create RPL candidate parent set
59+
*
60+
* PROC_RPL
61+
* Select RPL parent
62+
* <------ DHCP ------------------------>
63+
*
64+
* PROC_DAO
65+
* <------ DAO --------------------------
66+
* ------- DAO acknowledge ------------->
67+
*
68+
* Join state 5 (operational)
69+
*
70+
*
71+
* On automatic mode the PROC_PAS, PROC_EAPOL, PROC_PCS, PROC_DIS and PROC_RPL
72+
* will be triggered automatically by the node during the bootstrap.
73+
*
74+
*/
75+
76+
/**
77+
* @brief Test procedure triggers.
78+
*/
79+
typedef enum {
80+
PROC_DIS, /* trigger DODAG information object solicit (node) */
81+
PROC_DIO, /* trigger DODAG information object (BR, node) */
82+
PROC_DAO, /* trigger Destination advertisement object (node) */
83+
84+
PROC_PAS, /* trigger PAN Advertisement Solicit (node) */
85+
PROC_PA, /* trigger PAN Advertisement (BR, node) */
86+
PROC_PCS, /* trigger PAN Configuration Solicit (node) */
87+
PROC_PC, /* trigger PAN Configuration (BR, node) */
88+
89+
PROC_EAPOL, /* trigger EAPOL target selection (initiates authentication, node) */
90+
PROC_RPL, /* trigger RPL parent selection (node) */
91+
92+
PROC_AUTO_ON, /* trigger bootstrap test procedures automatically */
93+
PROC_AUTO_OFF, /* disable automatic bootstrap test procedure triggering */
94+
95+
MSG_NONE
96+
} ws_test_proc_t;
97+
98+
/**
99+
* Trigger a test procedure
100+
*
101+
* Can be used to trigger a test procedure, e.g. to send a message (DIS,
102+
* DIO, DAO, PAS, PS, PCS and PC) or to trigger bootstrap state change
103+
* on node e.g. EAPOL target selection.
104+
*
105+
* \param interface_id Network Interface ID >= 0 or -1 for Wi-SUN mesh interface
106+
* Default value is -1
107+
* \param procedure Triggered procedure
108+
* \param parameters Parameters for future extensions, shall be set to NULL
109+
*
110+
* \return 0 Success
111+
* \return <0 Failure
112+
*/
113+
int ws_test_procedure_trigger(int8_t interface_id, ws_test_proc_t procedure, void *parameters);
114+
115+
#ifdef __cplusplus
116+
}
117+
#endif
118+
119+
#endif /* NET_WS_TEST_EXT_H_ */

nanostack/ns_sha256.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,45 +61,77 @@ static inline void ns_sha256_clone(ns_sha256_context *dst,
6161

6262
static inline void ns_sha256_starts(ns_sha256_context *ctx)
6363
{
64+
#if (MBEDTLS_VERSION_MAJOR >= 3)
65+
(void)mbedtls_sha256_starts(ctx, 0);
66+
#else
6467
(void)mbedtls_sha256_starts_ret(ctx, 0);
68+
#endif
6569
}
6670

6771
static inline void ns_sha256_update(ns_sha256_context *ctx, const void *input,
6872
size_t ilen)
6973
{
74+
#if (MBEDTLS_VERSION_MAJOR >= 3)
75+
(void)mbedtls_sha256_update(ctx, input, ilen);
76+
#else
7077
(void)mbedtls_sha256_update_ret(ctx, input, ilen);
78+
#endif
7179
}
7280

7381
static inline void ns_sha256_finish(ns_sha256_context *ctx, void *output)
7482
{
83+
#if (MBEDTLS_VERSION_MAJOR >= 3)
84+
(void)mbedtls_sha256_finish(ctx, output);
85+
#else
7586
(void)mbedtls_sha256_finish_ret(ctx, output);
87+
#endif
7688
}
7789

7890
static inline void ns_sha256(const void *input, size_t ilen, void *output)
7991
{
92+
#if (MBEDTLS_VERSION_MAJOR >= 3)
93+
(void)mbedtls_sha256(input, ilen, output, 0);
94+
#else
8095
(void)mbedtls_sha256_ret(input, ilen, output, 0);
96+
#endif
8197
}
8298

8399
/* Extensions to standard mbed TLS - output the first bits of a hash only */
84100
/* Number of bits must be a multiple of 32, and <=256 */
85101
static inline void ns_sha256_finish_nbits(ns_sha256_context *ctx, void *output, unsigned obits)
86102
{
87103
if (obits == 256) {
104+
#if (MBEDTLS_VERSION_MAJOR >= 3)
105+
(void)mbedtls_sha256_finish(ctx, output);
106+
#else
88107
(void)mbedtls_sha256_finish_ret(ctx, output);
108+
#endif
89109
} else {
90110
uint8_t sha256[32];
111+
#if (MBEDTLS_VERSION_MAJOR >= 3)
112+
(void)mbedtls_sha256_finish(ctx, sha256);
113+
#else
91114
(void)mbedtls_sha256_finish_ret(ctx, sha256);
115+
#endif
92116
memcpy(output, sha256, obits / 8);
93117
}
94118
}
95119

96120
static inline void ns_sha256_nbits(const void *input, size_t ilen, void *output, unsigned obits)
97121
{
98122
if (obits == 256) {
123+
#if (MBEDTLS_VERSION_MAJOR >= 3)
124+
(void)mbedtls_sha256(input, ilen, output, 0);
125+
#else
99126
(void)mbedtls_sha256_ret(input, ilen, output, 0);
127+
#endif
100128
} else {
101129
uint8_t sha256[32];
130+
#if (MBEDTLS_VERSION_MAJOR >= 3)
131+
(void)mbedtls_sha256(input, ilen, sha256, 0);
132+
#else
102133
(void)mbedtls_sha256_ret(input, ilen, sha256, 0);
134+
#endif
103135
memcpy(output, sha256, obits / 8);
104136
}
105137
}

nanostack/ns_time_api.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@
2828

2929
#include "ns_types.h"
3030

31+
/**
32+
* Time zone information structure.
33+
*
34+
* Daylight saving time and time zone information learned by network stack
35+
*
36+
*/
37+
typedef struct timezone_info {
38+
/** Timestamp of the Daylight saving time change*/
39+
uint64_t timestamp;
40+
/** Time zone information in minutes*/
41+
int16_t timezone;
42+
/** Change that is applied when timestamp is reached*/
43+
int16_t deviation;
44+
/** Time configuration status bit field
45+
* "bit xxxxxxxxxxxxxxxS" 0 = false 1 = true Daylight saving time status*/
46+
uint16_t status;
47+
} timezone_info_t;
48+
3149
/**
3250
* System time read callback.
3351
*
@@ -48,6 +66,22 @@ typedef uint64_t ns_time_api_system_time_callback(void);
4866
*/
4967
typedef void ns_time_api_system_time_write_callback(uint64_t write_time);
5068

69+
/**
70+
* New time zone and daylight saving time information learned from stack.
71+
*
72+
* Called when network stack learns the time zone and daylights saving time information.
73+
*
74+
* In Wi-SUN Border router can distribute this information to synchronize all nodes in network.
75+
* This information is updated roughly once a day using DHCPv6 protocol
76+
*
77+
* If network stack does not have the information this is not called and can be called when information becomes available.
78+
* This can be called multiple times with same information.
79+
*
80+
* \param info_ptr time zone and daylight saving time configuration.
81+
*
82+
*/
83+
typedef void ns_time_api_time_configuration_notify_callback(timezone_info_t *info_ptr);
84+
5185
/**
5286
* System time read callback set.
5387
*
@@ -68,4 +102,15 @@ void ns_time_api_system_time_callback_set(ns_time_api_system_time_callback callb
68102
*/
69103
void ns_time_api_system_time_write_callback_set(ns_time_api_system_time_write_callback callback_wr);
70104

105+
/**
106+
* Set system time configuration notify callback.
107+
*
108+
* Sets system time configuration notify callback that is called if network stack
109+
* learns time information from other devices in the network.
110+
*
111+
* \param callback_wr system time write callback.
112+
*
113+
*/
114+
void ns_time_api_time_configuration_notify_callback_set(ns_time_api_time_configuration_notify_callback callback_wr);
115+
71116
#endif /* NS_TIME_API_H_ */

nanostack/platform/arm_hal_phy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ typedef struct phy_signal_info_s {
143143
typedef struct phy_csma_params {
144144
uint32_t backoff_time; /**< CSMA Backoff us time before start CCA & TX. 0 should disable current backoff*/
145145
bool cca_enabled; /**< True will affect CCA check false start TX direct after backoff */
146+
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 */
146147
} phy_csma_params_t;
147148

148149
/** PHY modulation scheme */

0 commit comments

Comments
 (0)