Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit ac55c15

Browse files
Merge branch 'release_internal' into release_external
* release_internal: (319 commits) Fix GCC_ARM/ARM compiler warnings (ARMmbed#1777) Coverity tool reported error fix (ARMmbed#1776) Removed Debug trace support from common mac header class coverity reported error fixes. (ARMmbed#1770) Removed debug trace which could be called at interrupt routine Clarify parameter name in phy_csma_params_t (ARMmbed#1773) fixes for coverity tool reported issues. (ARMmbed#1772) Update copyright year (ARMmbed#1771) address error handling fix. (ARMmbed#1769) Clean multicast address when interface is shutdown correct interface passed to address compare. (ARMmbed#1768) Thread device registers new address upon receipt of error notification. (ARMmbed#1767) replace ETX calculation for Wi-SUN refactor RPL dis sending Fixed broken neighbor purge from list Thread network data handling refactored (ARMmbed#1762) Fix broken MLE neigbor list write operation. updated address error payload (ARMmbed#1761) Add CBOR parsing to simpleenrolment message fix duplicate address detection (ARMmbed#1760) ...
2 parents 82bbdcc + f9b9e47 commit ac55c15

File tree

251 files changed

+19909
-4861
lines changed

Some content is hidden

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

251 files changed

+19909
-4861
lines changed

nanostack/ccmLIB.h

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014-2017, Arm Limited and affiliates.
2+
* Copyright (c) 2014-2018, Arm Limited and affiliates.
33
* SPDX-License-Identifier: Apache-2.0
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -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: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2017, Arm Limited and affiliates.
2+
* Copyright (c) 2016-2018, Arm Limited and affiliates.
33
* SPDX-License-Identifier: Apache-2.0
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -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: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2017, Arm Limited and affiliates.
2+
* Copyright (c) 2015-2018, Arm Limited and affiliates.
33
* SPDX-License-Identifier: Apache-2.0
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -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);

0 commit comments

Comments
 (0)