Skip to content

Commit c250202

Browse files
authored
Merge pull request #15102 from artokin/nanostack_release_v15_0_0_mbed_os_5_15
Nanostack release v15.0.0 to mbed-os-5.15
2 parents b4040f2 + 53c82ec commit c250202

File tree

105 files changed

+6817
-2518
lines changed

Some content is hidden

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

105 files changed

+6817
-2518
lines changed

components/802.15.4_RF/stm-s2lp-rf-driver/source/NanostackRfPhys2lp.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,15 @@ class RFPins {
134134
UnlockedSPI spi;
135135
DigitalOut CS;
136136
DigitalOut SDN;
137+
#if INTERRUPT_GPIO == S2LP_GPIO0
137138
InterruptIn RF_S2LP_GPIO0;
139+
#elif INTERRUPT_GPIO == S2LP_GPIO1
138140
InterruptIn RF_S2LP_GPIO1;
141+
#elif INTERRUPT_GPIO == S2LP_GPIO2
139142
InterruptIn RF_S2LP_GPIO2;
143+
#else
140144
InterruptIn RF_S2LP_GPIO3;
145+
#endif
141146
Timeout cca_timer;
142147
Timeout backup_timer;
143148
Timer tx_timer;
@@ -153,10 +158,15 @@ RFPins::RFPins(PinName spi_sdi, PinName spi_sdo,
153158
: spi(spi_sdi, spi_sdo, spi_sclk),
154159
CS(spi_cs),
155160
SDN(spi_sdn),
161+
#if INTERRUPT_GPIO == S2LP_GPIO0
156162
RF_S2LP_GPIO0(spi_gpio0),
163+
#elif INTERRUPT_GPIO == S2LP_GPIO1
157164
RF_S2LP_GPIO1(spi_gpio1),
165+
#elif INTERRUPT_GPIO == S2LP_GPIO2
158166
RF_S2LP_GPIO2(spi_gpio2),
167+
#else
159168
RF_S2LP_GPIO3(spi_gpio3),
169+
#endif
160170
irq_thread(osPriorityRealtime, 1024)
161171
{
162172
irq_thread.start(mbed::callback(this, &RFPins::rf_irq_task));

features/nanostack/coap-service/source/coap_security_handler.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323

2424
#ifdef COAP_SECURITY_AVAILABLE
2525

26+
#include "mbedtls/version.h"
2627
#include "mbedtls/sha256.h"
2728
#include "mbedtls/error.h"
2829
#include "mbedtls/platform.h"
2930
#include "mbedtls/ssl_cookie.h"
3031
#include "mbedtls/entropy.h"
31-
#include "mbedtls/entropy_poll.h"
3232
#include "mbedtls/ctr_drbg.h"
3333
#include "mbedtls/hmac_drbg.h"
3434
#include "mbedtls/ssl_ciphersuites.h"
@@ -310,6 +310,7 @@ static int simple_cookie_check(void *ctx,
310310

311311
/**** Key export function ****/
312312
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
313+
#if (MBEDTLS_VERSION_MAJOR < 3)
313314
static int export_key_block(void *ctx,
314315
const unsigned char *mk, const unsigned char *kb,
315316
size_t maclen, size_t keylen, size_t ivlen)
@@ -330,6 +331,7 @@ static int export_key_block(void *ctx,
330331
return 0;
331332
}
332333
#endif
334+
#endif
333335

334336
static int coap_security_handler_configure_keys(coap_security_t *sec, coap_security_keys_t keys, bool is_server)
335337
{
@@ -343,9 +345,15 @@ static int coap_security_handler_configure_keys(coap_security_t *sec, coap_secur
343345
break;
344346
}
345347

348+
#if (MBEDTLS_VERSION_MAJOR >= 3)
349+
if (mbedtls_pk_parse_key(&sec->_pkey, keys._priv_key, keys._priv_key_len, NULL, 0, DRBG_RANDOM, &sec->_drbg) < 0) {
350+
break;
351+
}
352+
#else
346353
if (mbedtls_pk_parse_key(&sec->_pkey, keys._priv_key, keys._priv_key_len, NULL, 0) < 0) {
347354
break;
348355
}
356+
#endif
349357

350358
if (0 != mbedtls_ssl_conf_own_cert(&sec->_conf, &sec->_owncert, &sec->_pkey)) {
351359
break;
@@ -378,10 +386,15 @@ static int coap_security_handler_configure_keys(coap_security_t *sec, coap_secur
378386
mbedtls_ssl_conf_ciphersuites(&sec->_conf, ECJPAKE_SUITES);
379387
#endif /* !defined(MBEDTLS_SSL_CONF_SINGLE_CIPHERSUITE) */
380388

389+
#if (MBEDTLS_VERSION_MAJOR >= 3)
390+
tr_error("FATAL ERROR: support for mbedtls_ssl_set_export_keys_cb() not implemented");
391+
#else
381392
//NOTE: If thread starts supporting PSK in other modes, then this will be needed!
382393
mbedtls_ssl_conf_export_keys_cb(&sec->_conf,
383394
export_key_block,
384395
&sec->_keyblk);
396+
#endif
397+
385398
ret = 0;
386399
#endif
387400
break;
@@ -512,9 +525,15 @@ int coap_security_handler_continue_connecting(coap_security_t *sec)
512525
return ret;
513526
}
514527

528+
#if (MBEDTLS_VERSION_MAJOR >= 3)
529+
if (sec->_ssl.private_state == MBEDTLS_SSL_HANDSHAKE_OVER) {
530+
return 0;
531+
}
532+
#else
515533
if (sec->_ssl.state == MBEDTLS_SSL_HANDSHAKE_OVER) {
516534
return 0;
517535
}
536+
#endif
518537
}
519538

520539
if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) {

features/nanostack/coap-service/source/include/coap_security_handler.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@
2020
#include "ns_types.h"
2121

2222
#ifdef NS_USE_EXTERNAL_MBED_TLS
23-
#if !defined(MBEDTLS_CONFIG_FILE)
24-
#include "mbedtls/config.h"
25-
#else
2623
// cppcheck-suppress preprocessorErrorDirective
27-
#include MBEDTLS_CONFIG_FILE
28-
#endif
24+
#include "mbedtls/version.h"
2925

3026
#if defined(MBEDTLS_SSL_TLS_C)
3127
#include "mbedtls/ssl.h"

features/nanostack/coap-service/test/coap-service/unittest/coap_security_handler/test_coap_security_handler.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ bool test_coap_security_handler_connect()
184184
}
185185

186186
mbedtls_stub.counter = 0;
187-
mbedtls_stub.retArray[5] = MBEDTLS_ERR_SSL_BAD_HS_FINISHED;
187+
mbedtls_stub.retArray[5] = MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL;
188188

189189
if (-1 != coap_security_handler_connect_non_blocking(handle, true, DTLS, keys, 0, 1)) {
190190
return false;
@@ -230,9 +230,9 @@ bool test_coap_security_handler_continue_connecting()
230230
}
231231

232232
mbedtls_stub.counter = 0;
233-
mbedtls_stub.retArray[0] = MBEDTLS_ERR_SSL_BAD_HS_FINISHED;
233+
mbedtls_stub.retArray[0] = MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL;
234234

235-
if (MBEDTLS_ERR_SSL_BAD_HS_FINISHED != coap_security_handler_continue_connecting(handle)) {
235+
if (MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL != coap_security_handler_continue_connecting(handle)) {
236236
return false;
237237
}
238238

features/nanostack/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ int mbedtls_ssl_handshake_step(mbedtls_ssl_context *ssl)
2727

2828
if (mbedtls_stub.retArray[mbedtls_stub.counter] == HANDSHAKE_FINISHED_VALUE ||
2929
mbedtls_stub.retArray[mbedtls_stub.counter] == HANDSHAKE_FINISHED_VALUE_RETURN_ZERO) {
30-
30+
#if (MBEDTLS_VERSION_MAJOR >= 3)
31+
ssl->private_state = MBEDTLS_SSL_HANDSHAKE_OVER;
32+
#else
3133
ssl->state = MBEDTLS_SSL_HANDSHAKE_OVER;
34+
#endif
3235
if (mbedtls_stub.retArray[mbedtls_stub.counter] == HANDSHAKE_FINISHED_VALUE_RETURN_ZERO) {
3336
return 0;
3437
}
@@ -346,9 +349,16 @@ int mbedtls_entropy_add_source(mbedtls_entropy_context *a,
346349
}
347350

348351
//From pk.h
352+
#if (MBEDTLS_VERSION_MAJOR >= 3)
353+
int mbedtls_pk_parse_key(mbedtls_pk_context *ctx,
354+
const unsigned char *b, size_t c,
355+
const unsigned char *d, size_t e,
356+
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng)
357+
#else
349358
int mbedtls_pk_parse_key(mbedtls_pk_context *a,
350359
const unsigned char *b, size_t c,
351360
const unsigned char *d, size_t e)
361+
#endif
352362
{
353363
if (mbedtls_stub.useCounter) {
354364
return mbedtls_stub.retArray[mbedtls_stub.counter++];
@@ -396,6 +406,7 @@ void mbedtls_ssl_conf_dtls_cookies(mbedtls_ssl_config *conf,
396406
}
397407
}
398408

409+
#if (MBEDTLS_VERSION_MAJOR < 3)
399410
void mbedtls_ssl_conf_export_keys_cb(mbedtls_ssl_config *conf,
400411
mbedtls_ssl_export_keys_t *f_export_keys,
401412
void *p_export_keys)
@@ -408,6 +419,7 @@ void mbedtls_ssl_conf_export_keys_cb(mbedtls_ssl_config *conf,
408419
f_export_keys(p_export_keys, &value, "", 0, 20, 0); //success case
409420
}
410421
}
422+
#endif
411423

412424
int mbedtls_ssl_session_reset(mbedtls_ssl_context *ssl)
413425
{

features/nanostack/sal-stack-nanostack/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
/**

features/nanostack/sal-stack-nanostack/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
*

0 commit comments

Comments
 (0)