Skip to content

Commit 2dc41c0

Browse files
author
Arto Kinnunen
committed
Merge remote-tracking branch 'origin/koli'
* origin/koli: (254 commits) Put smarter dag max rank increment 2048. 0 affect a lot of troubles. RPL print update, nud and aneighbour update Fix merge compile problems Fix LLC unit test's LLC data indication and fhss channel set update Fix crash which will happen if address registration fail and operation is triggered again by NULL pointer. Enabled proper wi-sun security level 6. Fix data for 6lowpan when mle is disabled. Wi-sun trigle timer update: Function name code conventions fix. mac_neighbor_info() macro defned for simplify code Added check when weighting rule update must do network scan. Fix ns_dyn_mem_init stub Added Neighbor connected and trusted state update for wisun Integrate Mac neighbour table to Thread and 6Lowpan code Mac neighbour table update Thread Neighbor class update Removed almost duplicate mle entry discover for ll64 Rename some parameters which will help integration to new neighbor table. Function parameter and name refactor. ...
2 parents f9b23d4 + 2fc10b5 commit 2dc41c0

File tree

325 files changed

+22470
-8436
lines changed

Some content is hidden

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

325 files changed

+22470
-8436
lines changed

nanostack/ccmLIB.h

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@
1818
#define CCMLIB_H_
1919

2020
#include "ns_types.h"
21+
#include "platform/arm_hal_aes.h"
2122

2223
/**
2324
*
2425
* \file ccmLIB.h
2526
* \brief CCM Library API.
2627
*
2728
* \section ccm-api CCM Library API:
28-
* - ccm_sec_init(), A function to init CCM library.
29+
* - ccm_sec_init(), A function to init CCM context.
2930
* - ccm_process_run(), A function to run configured CCM process.
3031
*
3132
* \section ccm-instruction CCM process sequence:
32-
* 1. Init CCM library by, ccm key, ccm_sec_init()
33+
* 1. Init CCM context by, ccm key, ccm_sec_init()
3334
* - security level
3435
* - 128-bit CCM key
3536
* - mode: AES_CCM_ENCRYPT or AES_CCM_DECRYPT
@@ -41,11 +42,6 @@
4142
* -If 0 Process ok
4243
* -< 0 MIC fail or parameter fail
4344
*
44-
* \section ccm-mutex CCM Mutex for Multi Thread System
45-
* If you are running a multi thread system and the CCM library will be used for multiple thread, do the following:
46-
* 1. Add compiler flag to library build process CCM_USE_MUTEX.
47-
* 2. Define OS-specific mutex at the application.
48-
* 3. Implement arm_ccm_mutex_lock() arm_ccm_mutex_unlock() function for using the generated and initialized mutex.
4945
*/
5046
#ifdef __cplusplus
5147
extern "C" {
@@ -63,41 +59,39 @@ extern "C" {
6359
#define AES_CCM_DECRYPT 0x01 /**< Decryption mode */
6460

6561

66-
/**
67-
* \brief A function for locking CCM mutex if the OS is multi thread. If you are using single thread create an empty function.
68-
*/
69-
extern void arm_ccm_mutex_lock(void);
70-
/**
71-
* \brief A function for unlocking CCM mutex if the OS is multi thread. If you are using single thread create an empty function
72-
*/
73-
extern void arm_ccm_mutex_unlock(void);
74-
7562
/*!
7663
* \struct ccm_globals_t
7764
* \brief CCM global structure.
7865
* The structure is used for configuring NONCE, adata and data before calling ccm_process_run().
7966
*/
8067
typedef struct {
81-
uint8_t exp_nonce[15]; /**< CCM NONCE buffer Nonce. */
82-
uint8_t *data_ptr; /**< Pointer to data IN. */
83-
uint16_t data_len; /**< Length of data IN. */
68+
uint8_t exp_nonce[15]; /**< CCM NONCE buffer Nonce. */
69+
uint8_t *data_ptr; /**< Pointer to data IN. */
70+
uint16_t data_len; /**< Length of data IN. */
8471
const uint8_t *adata_ptr; /**< Pointer to authentication data. */
85-
uint16_t adata_len; /**< Length of authentication data. */
86-
uint8_t mic_len; /**< ccm_sec_init() sets here the length of MIC. */
87-
uint8_t *mic; /**< Encrypt process writes MIC. Decrypt reads it and compares it with the MIC obtained from data. */
72+
uint16_t adata_len; /**< Length of authentication data. */
73+
unsigned ccm_encode_mode:1; /**< Encryption modeAES_CCM_ENCRYPT or AES_CCM_DECRYPT. */
74+
unsigned ccm_sec_level:3; /**< Encryption operation security level 0-7. */
75+
unsigned ccm_l_param:4; /**< Can be 2 or 3. 2 when NONCE length is 13 and 3 when 12*/
76+
uint8_t mic_len; /**< ccm_sec_init() sets here the length of MIC. */
77+
uint8_t *mic; /**< Encrypt process writes MIC. Decrypt reads it and compares it with the MIC obtained from data. */
78+
const uint8_t *key_ptr; /**< Encyption key pointer to 128-bit key. */
79+
arm_aes_context_t *aes_context; /**< Allocated AES context. */
8880
} ccm_globals_t;
8981

82+
9083
/**
91-
* \brief A function to initialize the CCM library.
84+
* \brief A function to initialize the CCM context.
85+
* \param ccm_context pointer to initialized XXM context
9286
* \param sec_level Used CCM security level (0-7).
9387
* \param ccm_key Pointer to 128-key.
9488
* \param mode AES_CCM_ENCRYPT or AES_CCM_DECRYPT.
9589
* \param ccm_l Can be 2 or 3. 2 when NONCE length is 13 and 3 when 12. (NONCE length = (15-ccm_l))
9690
*
97-
* \return Pointer to Global CCM parameter buffer.
98-
* \return 0 When parameter fails or CCM is busy.
91+
* \return true when AES context allocation is OK and given parameters.
92+
* \return false CCM parameters or AES context allocation fail.
9993
*/
100-
extern ccm_globals_t *ccm_sec_init(uint8_t sec_level, const uint8_t *ccm_key, uint8_t mode, uint8_t ccm_l);
94+
extern bool ccm_sec_init(ccm_globals_t *ccm_context, uint8_t sec_level, const uint8_t *ccm_key, uint8_t mode, uint8_t ccm_l);
10195

10296
/**
10397
* \brief A function to run the configured CCM process.
@@ -109,6 +103,14 @@ extern ccm_globals_t *ccm_sec_init(uint8_t sec_level, const uint8_t *ccm_key, ui
109103
* \return -2 Null pointer given to function.
110104
*/
111105
extern int8_t ccm_process_run(ccm_globals_t *ccm_params);
106+
107+
/**
108+
* \brief A function to free aes context. Call only if ccm_process_run() is not called
109+
* \param ccm_params CCM parameters
110+
*
111+
*/
112+
extern void ccm_free(ccm_globals_t *ccm_params);
113+
112114
#ifdef __cplusplus
113115
}
114116
#endif

nanostack/fhss_api.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,16 @@ typedef bool fhss_use_broadcast_queue(const fhss_api_t *api, bool is_broadcast_a
7474
* @param is_broadcast_addr Destination address type of packet (true if broadcast address).
7575
* @param destination_address Destination MAC address.
7676
* @param frame_type Frame type of packet (Frames types are defined by FHSS api).
77-
* @param synch_info Pointer to where FHSS synchronization info is written (if synch frame).
7877
* @param frame_length MSDU length of the frame.
7978
* @param phy_header_length PHY header length.
8079
* @param phy_tail_length PHY tail length.
80+
* @param tx_time TX time.
8181
* @return 0 Success.
8282
* @return -1 Transmission of the packet is currently not allowed, try again.
8383
* @return -2 Invalid api.
8484
* @return -3 Broadcast packet on Unicast channel (not allowed), push packet back to queue.
85-
* @return -4 Synchronization info missing.
8685
*/
87-
typedef int fhss_tx_handle(const fhss_api_t *api, bool is_broadcast_addr, uint8_t *destination_address, int frame_type, uint8_t *synch_info, uint16_t frame_length, uint8_t phy_header_length, uint8_t phy_tail_length);
86+
typedef int fhss_tx_handle(const fhss_api_t *api, bool is_broadcast_addr, uint8_t *destination_address, int frame_type, uint16_t frame_length, uint8_t phy_header_length, uint8_t phy_tail_length, uint32_t tx_time);
8887

8988
/**
9089
* @brief Check TX permission.
@@ -152,6 +151,17 @@ typedef uint32_t fhss_read_timestamp(const fhss_api_t *api);
152151
*/
153152
typedef uint16_t fhss_get_retry_period(const fhss_api_t *api, uint8_t *destination_address, uint16_t phy_mtu);
154153

154+
/**
155+
* @brief Write synchronization info to given pointer.
156+
* @param api FHSS instance.
157+
* @param ptr Pointer to data. Start of written data for Synch frame. Start of IE header for Data frame.
158+
* @param length Length of IE header. Ignored when Synch frame.
159+
* @param frame_type Frame type of packet (Frames types are defined by FHSS api).
160+
* @param tx_time TX time must be referenced to the first symbol following the SFD of the transmitted frame.
161+
* @return -1 on fail, write length otherwise.
162+
*/
163+
typedef int16_t fhss_write_synch_info(const fhss_api_t *api, uint8_t *ptr, uint8_t length, int frame_type, uint32_t tx_time);
164+
155165
/**
156166
* @brief Initialize MAC functions.
157167
* @param api FHSS instance.
@@ -177,6 +187,7 @@ struct fhss_api {
177187
fhss_synch_state_set *synch_state_set; /**< Change synchronization state. */
178188
fhss_read_timestamp *read_timestamp; /**< Read timestamp. */
179189
fhss_get_retry_period *get_retry_period; /**< Get retransmission period. */
190+
fhss_write_synch_info *write_synch_info; /**< Write synchronization info to TX frame*/
180191
fhss_init_callbacks *init_callbacks; /**< Initialize MAC functions. */
181192
};
182193

@@ -256,6 +267,18 @@ typedef int mac_broadcast_notify(const fhss_api_t *fhss_api, uint32_t broadcast_
256267
*/
257268
typedef int mac_read_coordinator_mac_address(const fhss_api_t *fhss_api, uint8_t *mac_address);
258269

270+
/**
271+
* @brief Read synchronization info for a specific peer.
272+
* @param fhss_api FHSS instance.
273+
* @param info_ptr Pointer to info data.
274+
* @param mac_address MAC address pointer.
275+
* @param info_type Type of the read info (UTT-IE, BT-IE, US-IE, BS-IE).
276+
* @param rx_timestamp Time of reception of the element.
277+
* @return >=0 Length of the info.
278+
* @return -1 Fail.
279+
*/
280+
typedef int mac_read_synch_info(const fhss_api_t *fhss_api, uint8_t *info_ptr, uint8_t *mac_address, int info_type, uint32_t rx_timestamp);
281+
259282
/**
260283
* \brief Struct fhss_callback defines functions that software MAC needs to implement.
261284
* Function pointers are passed to FHSS using fhss_init_callbacks function.
@@ -270,6 +293,7 @@ struct fhss_callback {
270293
mac_tx_poll *tx_poll; /**< Poll TX queue. */
271294
mac_broadcast_notify *broadcast_notify; /**< Broadcast channel notification from FHSS. */
272295
mac_read_coordinator_mac_address *read_coord_mac_address; /**< Read coordinator MAC address. */
296+
mac_read_synch_info *read_synch_info; /**< Read information element for a specific MAC address. */
273297
};
274298

275299
#ifdef __cplusplus

nanostack/fhss_config.h

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@
2828
extern "C" {
2929
#endif
3030

31+
#include "fhss_ws_extension.h"
32+
33+
/**
34+
* @brief WS channel functions.
35+
*/
36+
typedef enum
37+
{
38+
/** Fixed channel. */
39+
WS_FIXED_CHANNEL,
40+
/** TR51 channel function. */
41+
WS_TR51CF,
42+
/** Direct Hash channel function. */
43+
WS_DH1CF,
44+
/** Vendor Defined channel function. */
45+
WS_VENDOR_DEF_CF
46+
} fhss_ws_channel_functions;
47+
3148
/**
3249
* \brief Struct fhss_tuning_parameter defines FHSS tuning parameters.
3350
* All delays are given in microseconds.
@@ -63,20 +80,59 @@ typedef struct fhss_configuration
6380

6481
} fhss_configuration_t;
6582

83+
/**
84+
* @brief Get channel using vendor defined channel function.
85+
* @param api FHSS instance.
86+
* @param slot Slot number in channel schedule.
87+
* @param eui64 EUI-64 address of node for which the (unicast) schedule is calculated. NULL for broadcast schedule.
88+
* @param bsi Broadcast schedule identifier used in (broadcast) schedule calculation.
89+
* @param number_of_channels Number of channels in schedule.
90+
* @return Channel.
91+
*/
92+
typedef int32_t fhss_vendor_defined_cf(const fhss_api_t *api, uint16_t slot, uint8_t eui64[8], uint16_t bsi, uint16_t number_of_channels);
93+
94+
/**
95+
* \brief Struct fhss_ws_configuration defines configuration of WS FHSS.
96+
*/
97+
typedef struct fhss_ws_configuration
98+
{
99+
/** WS channel function. */
100+
fhss_ws_channel_functions ws_channel_function;
101+
102+
/** Broadcast schedule identifier. */
103+
uint16_t bsi;
104+
105+
/** Unicast dwell interval. Range: 15-250 milliseconds. */
106+
uint8_t fhss_uc_dwell_interval;
107+
108+
/** Broadcast interval. Duration between broadcast dwell intervals. Range: 0-16777216 milliseconds. */
109+
uint32_t fhss_broadcast_interval;
110+
111+
/** Broadcast dwell interval. Range: 15-250 milliseconds. */
112+
uint8_t fhss_bc_dwell_interval;
113+
114+
/** Channel mask. */
115+
uint32_t channel_mask[8];
116+
117+
/** Vendor defined channel function. */
118+
fhss_vendor_defined_cf *vendor_defined_cf;
119+
120+
} fhss_ws_configuration_t;
121+
66122
/**
67123
* \brief Struct fhss_timer defines interface between FHSS and FHSS platform timer.
68124
* Application must implement FHSS timer driver which is then used by FHSS with this interface.
69125
*/
70126
typedef struct fhss_timer
71127
{
72-
/** Start timeout (1us) */
128+
/** Start timeout (1us). Timer must support multiple simultaneous timeouts */
73129
int (*fhss_timer_start)(uint32_t, void (*fhss_timer_callback)(const fhss_api_t *fhss_api, uint16_t), const fhss_api_t *fhss_api);
74130

75131
/** Stop timeout */
76-
int (*fhss_timer_stop)(const fhss_api_t *fhss_api);
132+
int (*fhss_timer_stop)(void (*fhss_timer_callback)(const fhss_api_t *fhss_api, uint16_t), const fhss_api_t *fhss_api);
77133

78134
/** Get remaining time of started timeout*/
79-
uint32_t (*fhss_get_remaining_slots)(const fhss_api_t *fhss_api);
135+
uint32_t (*fhss_get_remaining_slots)(void (*fhss_timer_callback)(const fhss_api_t *fhss_api, uint16_t), const fhss_api_t *fhss_api);
80136

81137
/** Get timestamp since initialization of driver. Overflow of 32-bit counter is allowed (1us) */
82138
uint32_t (*fhss_get_timestamp)(const fhss_api_t *fhss_api);

nanostack/fhss_ws_extension.h

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* Copyright (c) 2015-2017, Arm Limited 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+
/**
19+
* \file fhss_ws_extension.h
20+
* \brief
21+
*/
22+
23+
#ifndef FHSS_WS_EXT_H
24+
#define FHSS_WS_EXT_H
25+
26+
#include "ns_types.h"
27+
#include "fhss_api.h"
28+
29+
#ifdef __cplusplus
30+
extern "C" {
31+
#endif
32+
33+
/**
34+
* @brief unicast_timing_info Unicast timing/hopping schedule information structure.
35+
*/
36+
typedef struct unicast_timing_info {
37+
unsigned unicast_channel_function:3; /**< Unicast schedule channel function */
38+
uint8_t unicast_dwell_interval; /**< Unicast dwell interval */
39+
uint16_t unicast_number_of_channels; /**< Unicast number of channels */
40+
uint_fast24_t ufsi; /**< Unicast fractional sequence interval */
41+
uint32_t utt_rx_timestamp; /**< UTT-IE reception timestamp */
42+
} unicast_timing_info_t;
43+
44+
/**
45+
* @brief broadcast_timing_info Broadcast timing/hopping schedule information structure.
46+
*/
47+
typedef struct broadcast_timing_info {
48+
unsigned broadcast_channel_function:3; /**< Broadcast schedule channel function */
49+
uint8_t broadcast_dwell_interval; /**< Broadcast dwell interval */
50+
uint16_t broadcast_slot; /**< Broadcast slot number */
51+
uint16_t broadcast_schedule_id; /**< Broadcast schedule identifier */
52+
uint_fast24_t broadcast_interval_offset; /**< Broadcast interval offset */
53+
uint32_t broadcast_interval; /**< Broadcast interval */
54+
uint32_t bt_rx_timestamp; /**< BT-IE reception timestamp */
55+
} broadcast_timing_info_t;
56+
57+
/**
58+
* @brief fhss_ws_neighbor_timing_info Neighbor timing/hopping schedule information structure.
59+
*/
60+
typedef struct fhss_ws_neighbor_timing_info {
61+
uint8_t clock_drift; /**< Neighbor clock drift */
62+
uint8_t timing_accuracy; /**< Neighbor timing accuracy */
63+
unicast_timing_info_t uc_timing_info; /**< Neighbor unicast timing info */
64+
broadcast_timing_info_t bc_timing_info; /**< Neighbor broadcast timing info */
65+
uint32_t *excluded_channels; /**< Neighbor excluded channels (bit mask) */
66+
} fhss_ws_neighbor_timing_info_t;
67+
68+
/**
69+
* @brief Get neighbor timing/hopping schedule.
70+
* @param api FHSS instance.
71+
* @param eui64 EUI-64 address of node for which the info is requested.
72+
* @return Neighbor timing/hopping schedule.
73+
*/
74+
typedef fhss_ws_neighbor_timing_info_t *fhss_get_neighbor_info(const fhss_api_t *api, uint8_t eui64[8]);
75+
76+
/**
77+
* @brief Set parent which broadcast channels must be listened by FHSS.
78+
* @param fhss_api FHSS instance.
79+
* @param eui64 EUI-64 address of parent.
80+
* @param bc_timing_info Pointer to parent broadcast timing/hopping schedule info.
81+
* @return 0 on success, -1 on fail.
82+
*/
83+
extern int ns_fhss_ws_set_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info);
84+
85+
/**
86+
* @brief Remove parent which was set by ns_fhss_ws_set_parent function.
87+
* @param fhss_api FHSS instance.
88+
* @param eui64 EUI-64 address of parent.
89+
* @return 0 on success, -1 on fail.
90+
*/
91+
extern int ns_fhss_ws_remove_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8]);
92+
93+
/**
94+
* @brief Set neighbor timing/hopping schedule request function.
95+
* @param fhss_api FHSS instance.
96+
* @param get_neighbor_info Neighbor info function pointer.
97+
* @return 0 on success, -1 on fail.
98+
*/
99+
extern int ns_fhss_set_neighbor_info_fp(const fhss_api_t *fhss_api, fhss_get_neighbor_info *get_neighbor_info);
100+
101+
/**
102+
* @brief Set node hop count. Hop count is used to specify TX/RX slot. When hop count is set to 0xFF, TX/RX slots are ignored.
103+
* @param fhss_api FHSS instance.
104+
* @param hop_count Hop count to be set.
105+
* @return 0 on success, -1 on fail.
106+
*/
107+
extern int ns_fhss_ws_set_hop_count(const fhss_api_t *fhss_api, const uint8_t hop_count);
108+
109+
#ifdef __cplusplus
110+
}
111+
#endif
112+
113+
#endif // FHSS_WS_EXT_H

0 commit comments

Comments
 (0)