Skip to content

Commit bce32b0

Browse files
author
Cruz Monrreal
authored
Merge pull request #6876 from JuhPuur/master
Nanostack release for Mbed OS 5.9
2 parents 8be2e34 + 8bede89 commit bce32b0

File tree

69 files changed

+927
-516
lines changed

Some content is hidden

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

69 files changed

+927
-516
lines changed

features/frameworks/mbed-trace/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ yotta target x86-linux-native
169169
yotta test mbed_trace_test
170170
```
171171

172+
* In Mac
173+
174+
```
175+
yotta target x86-osx-native
176+
yotta test mbed_trace_test
177+
```
178+
172179
* In Windows
173180

174181
```

features/frameworks/mbed-trace/module.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
"cpputest": "ARMmbed/cpputest",
2828
"nanostack-libservice": "^3.6.0"
2929
},
30+
"x86-osx-native": {
31+
"cpputest": "ARMmbed/cpputest",
32+
"nanostack-libservice": "^3.6.0"
33+
},
3034
"x86-windows-native": {
3135
"cpputest": "ARMmbed/cpputest",
3236
"nanostack-libservice": "^3.6.0"

features/frameworks/mbed-trace/source/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ if(DEFINED TARGET_LIKE_X86_LINUX_NATIVE)
44
)
55
add_definitions("-g -O0 -fprofile-arcs -ftest-coverage")
66
target_link_libraries(mbed-trace gcov nanostack-libservice)
7+
elseif(DEFINED TARGET_LIKE_X86_OSX_NATIVE)
8+
add_library( mbed-trace
9+
mbed_trace.c
10+
)
11+
add_definitions("-g -O0")
12+
target_link_libraries(mbed-trace nanostack-libservice)
713
else()
814
add_library( mbed-trace
915
mbed_trace.c

features/frameworks/mbed-trace/test/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# only build tests on targets that declare they are like posix
2-
if(DEFINED TARGET_LIKE_X86_WINDOWS_NATIVE OR DEFINED TARGET_LIKE_X86_LINUX_NATIVE)
2+
if(DEFINED TARGET_LIKE_X86_WINDOWS_NATIVE OR DEFINED TARGET_LIKE_X86_LINUX_NATIVE OR DEFINED TARGET_LIKE_X86_OSX_NATIVE)
33

44
# describe the test executable
55
add_executable(mbed_trace_test EXCLUDE_FROM_ALL Test.cpp stubs/ip6tos_stub.c)
@@ -13,10 +13,13 @@ if(DEFINED TARGET_LIKE_X86_WINDOWS_NATIVE OR DEFINED TARGET_LIKE_X86_LINUX_NATIV
1313
if(DEFINED TARGET_LIKE_X86_WINDOWS_NATIVE)
1414
add_test(mbed_trace_test "build/x86-windows-native/test/mbed_trace_test")
1515
add_dependencies(all_tests mbed_trace_test)
16-
endif()
17-
if(DEFINED TARGET_LIKE_X86_LINUX_NATIVE)
16+
elseif(DEFINED TARGET_LIKE_X86_LINUX_NATIVE)
1817
SET(TEST_EXECUTABLE "../../../build/x86-linux-native/test/mbed_trace_test")
1918
add_test(mbed_trace_test ${TEST_EXECUTABLE})
2019
add_dependencies(all_tests mbed_trace_test)
20+
elseif(DEFINED TARGET_LIKE_X86_OSX_NATIVE)
21+
SET(TEST_EXECUTABLE "../../../build/x86-osx-native/test/mbed_trace_test")
22+
add_test(mbed_trace_test ${TEST_EXECUTABLE})
23+
add_dependencies(all_tests mbed_trace_test)
2124
endif()
2225
endif()

features/frameworks/mbed-trace/test/Test.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,17 @@ TEST(trace, filters_control)
454454
mbed_trace_exclude_filters_set(0);
455455
STRCMP_EQUAL("", mbed_trace_exclude_filters_get());
456456
}
457+
TEST(trace, cmd_printer)
458+
{
459+
buf[0] = 0;
460+
mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL);
461+
mbed_tracef(TRACE_LEVEL_CMD, "mygr", "default printer");
462+
STRCMP_EQUAL("default printer", buf);
463+
464+
mbed_trace_cmdprint_function_set( myprint );
465+
mbed_tracef(TRACE_LEVEL_CMD, "mygr", "custom printer");
466+
STRCMP_EQUAL("\n", buf); // because there is two print calls, second one add line feeds
467+
}
457468
TEST(trace, no_printer)
458469
{
459470
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hello");

features/frameworks/nanostack-libservice/mbed-client-libservice/common_functions.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,29 @@ NS_INLINE uint8_t *common_write_24_bit(uint_fast24_t value, uint8_t ptr[__static
114114
*/
115115
NS_INLINE uint_fast24_t common_read_24_bit(const uint8_t data_buf[__static 3]);
116116

117+
/*
118+
* Common write 24-bit variable to 8-bit pointer.
119+
*
120+
* Write 24 bits in little-endian byte order.
121+
*
122+
* \param value 24-bit variable
123+
* \param ptr pointer where data to be written
124+
*
125+
* \return updated pointer
126+
*/
127+
NS_INLINE uint8_t *common_write_24_bit_inverse(uint_fast24_t value, uint8_t ptr[__static 3]);
128+
129+
/*
130+
* Common read 24-bit variable from 8-bit pointer.
131+
*
132+
* Read 24 bits in little-endian byte order.
133+
*
134+
* \param data_buf pointer where data to be read
135+
*
136+
* \return 24-bit variable
137+
*/
138+
NS_INLINE uint_fast24_t common_read_24_bit_inverse(const uint8_t data_buf[__static 3]);
139+
117140
/*
118141
* Common write 16-bit variable to 8-bit pointer.
119142
*
@@ -420,6 +443,23 @@ COMMON_FUNCTIONS_FN uint_fast24_t common_read_24_bit(const uint8_t data_buf[__st
420443
return temp_24;
421444
}
422445

446+
COMMON_FUNCTIONS_FN uint8_t *common_write_24_bit_inverse(uint_fast24_t value, uint8_t ptr[__static 3])
447+
{
448+
*ptr++ = value;
449+
*ptr++ = value >> 8;
450+
*ptr++ = value >> 16;
451+
return ptr;
452+
}
453+
454+
COMMON_FUNCTIONS_FN uint_fast24_t common_read_24_bit_inverse(const uint8_t data_buf[__static 3])
455+
{
456+
uint_fast24_t temp_24;
457+
temp_24 = *data_buf++;
458+
temp_24 += (uint_fast24_t)(*data_buf++) << 8;
459+
temp_24 += (uint_fast24_t)(*data_buf++) << 16;
460+
return temp_24;
461+
}
462+
423463
COMMON_FUNCTIONS_FN uint8_t *common_write_16_bit(uint16_t value, uint8_t ptr[__static 2])
424464
{
425465
*ptr++ = value >> 8;

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ struct coap_security_s {
5151
#if defined(MBEDTLS_X509_CRT_PARSE_C)
5252
mbedtls_x509_crt _cacert;
5353
mbedtls_x509_crt _owncert;
54-
#endif
5554
mbedtls_pk_context _pkey;
55+
#endif
5656

5757
uint8_t _pw[64];
5858
uint8_t _pw_len;
@@ -109,8 +109,8 @@ static int coap_security_handler_init(coap_security_t *sec){
109109
#if defined(MBEDTLS_X509_CRT_PARSE_C)
110110
mbedtls_x509_crt_init( &sec->_cacert );
111111
mbedtls_x509_crt_init( &sec->_owncert );
112-
#endif
113112
mbedtls_pk_init( &sec->_pkey );
113+
#endif
114114

115115
memset(&sec->_cookie, 0, sizeof(simple_cookie_t));
116116
memset(&sec->_keyblk, 0, sizeof(key_block_t));
@@ -145,9 +145,8 @@ static void coap_security_handler_reset(coap_security_t *sec){
145145
#if defined(MBEDTLS_X509_CRT_PARSE_C)
146146
mbedtls_x509_crt_free(&sec->_cacert);
147147
mbedtls_x509_crt_free(&sec->_owncert);
148-
#endif
149-
150148
mbedtls_pk_free(&sec->_pkey);
149+
#endif
151150

152151
mbedtls_entropy_free( &sec->_entropy );
153152
mbedtls_ctr_drbg_free( &sec->_ctr_drbg );
@@ -196,6 +195,7 @@ void coap_security_destroy(coap_security_t *sec){
196195
}
197196
}
198197

198+
#ifdef MBEDTLS_SSL_SRV_C
199199
/**** Random number functions ****/
200200

201201
/**
@@ -265,6 +265,7 @@ static int simple_cookie_check(void *ctx,
265265
}
266266
return 0;
267267
}
268+
#endif // MBEDTLS_SSL_SRV_C
268269

269270
/**** Key export function ****/
270271
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)

features/nanostack/sal-stack-nanostack/nanostack/net_interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@ extern void net_get_version_information(uint8_t *ptr);
995995
*
996996
* Note! In Thread mode parent buffer size is automatically set during Thread initialization.
997997
*
998+
* \param interface_id Network interface ID.
998999
* \param big_packet_threshold Indicate how long packets are considered big. For Thread, must be 106 bytes.
9991000
* \param small_packets_per_child_count Number of small packets stored for each sleepy children. For Thread, must be at least 1.
10001001
* \param big_packets_total_count Total number of big packets parent can store for all sleepy children. For Thread, must be at least 1.

features/nanostack/sal-stack-nanostack/nanostack/net_test_api.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define NET_TEST_API_H_
2525

2626
#include "ns_types.h"
27+
#include "Service_Libs/mle_service/mle_service_api.h"
2728

2829
/**
2930
* \brief Makes TCP protocol drop given number of packets from a particular state (TX side).
@@ -56,4 +57,11 @@ int8_t arm_nwk_test_tcp_drop_rx(int state, uint8_t count);
5657
*/
5758
void arm_nwk_test_tcp_drop_reset(void);
5859

60+
/**
61+
* \brief Set callback for MLE message receiving filter.
62+
*
63+
* Testing API for setting MLE receive callback for message filtering purposes.
64+
*/
65+
void arm_nwk_test_mle_receive_filter_set(mle_service_filter_cb *response_filter_cb);
66+
5967
#endif //NET_TEST_API_H_

features/nanostack/sal-stack-nanostack/nanostack/net_thread_test.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,19 @@ int thread_test_increment_key_sequence_counter(int8_t interface_id);
274274
*/
275275
int thread_test_key_sequence_counter_update(int8_t interface_id, uint32_t thrKeySequenceCounter);
276276

277+
/**
278+
* \brief Resets cached values from stack
279+
*
280+
Resets link configuration from cache and from NVM.
281+
*
282+
*
283+
* \param interface_id Network Interface
284+
*
285+
* \return 0, OK
286+
* \return <0 Error
287+
*/
288+
int thread_test_stack_cache_reset(int8_t interface_id);
289+
277290
/**
278291
* \brief Set new Thread key rotation value
279292
*

features/nanostack/sal-stack-nanostack/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_bootstrap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ static int mle_router_accept_request_build(protocol_interface_info_entry_t *cur,
758758

759759
static void protocol_6lowpan_link_reject_handler(protocol_interface_info_entry_t *cur, uint8_t *ll64)
760760
{
761-
mle_neigh_table_entry_t *entry_temp = mle_class_get_entry_by_ll64(cur->id, 0, ll64, false);
761+
mle_neigh_table_entry_t *entry_temp = mle_class_get_entry_by_ll64(cur->id, 0, ll64, false, NULL);
762762
tr_debug("MLE link reject");
763763
if (entry_temp) {
764764
mle_class_remove_entry(cur->id, entry_temp);
@@ -1081,7 +1081,7 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml
10811081
mle_6lowpan_data->link_req_token_bucket--;
10821082
} else {
10831083
//Update only old information based on link request
1084-
entry_temp = mle_class_get_entry_by_ll64(interface_id, linkMargin, mle_msg->packet_src_address, false);
1084+
entry_temp = mle_class_get_entry_by_ll64(interface_id, linkMargin, mle_msg->packet_src_address, false, NULL);
10851085
if (entry_temp) {
10861086
mle_neigh_time_and_mode_update(entry_temp,mle_msg->data_ptr, mle_msg->data_length);
10871087
mle_neigh_entry_update_by_mle_tlv_list(interface_id, entry_temp, mle_msg->data_ptr, mle_msg->data_length, cur->mac, own_mac16);
@@ -1118,12 +1118,12 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml
11181118

11191119
tr_debug("Accept & Request");
11201120

1121-
entry_temp = mle_class_get_entry_by_ll64(interface_id, linkMargin, mle_msg->packet_src_address, false);
1121+
entry_temp = mle_class_get_entry_by_ll64(interface_id, linkMargin, mle_msg->packet_src_address, false, NULL);
11221122

11231123
if (!entry_temp) {
11241124
// If there is space for neighbors try to allocate new entry
11251125
if (mle_6lowpan_neighbor_limit_check(interface_id, mle_msg, true)) {
1126-
entry_temp = mle_class_get_entry_by_ll64(interface_id, linkMargin, mle_msg->packet_src_address, true);
1126+
entry_temp = mle_class_get_entry_by_ll64(interface_id, linkMargin, mle_msg->packet_src_address, true, NULL);
11271127
}
11281128
}
11291129

@@ -1185,7 +1185,7 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml
11851185
mode = *t_ptr;
11861186
}
11871187

1188-
entry_temp = mle_class_get_entry_by_ll64(interface_id, linkMargin, mle_msg->packet_src_address, false);
1188+
entry_temp = mle_class_get_entry_by_ll64(interface_id, linkMargin, mle_msg->packet_src_address, false, NULL);
11891189
if (!entry_temp) {
11901190
if ((mode & MLE_DEV_MASK) == MLE_FFD_DEV) {
11911191
// If there is space for neighbors synchronizes to new router
@@ -2787,7 +2787,7 @@ bool lowpan_neighbour_data_clean(int8_t interface_id, const uint8_t *link_local_
27872787
{
27882788
bool return_value = false;
27892789
#ifndef NO_MLE
2790-
mle_neigh_table_entry_t * neigh_entry = mle_class_get_entry_by_ll64(interface_id, 0, link_local_address, false);
2790+
mle_neigh_table_entry_t * neigh_entry = mle_class_get_entry_by_ll64(interface_id, 0, link_local_address, false, NULL);
27912791
if (neigh_entry) {
27922792
//Remove entry
27932793
if (neigh_entry->priorityFlag) {

features/nanostack/sal-stack-nanostack/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_interface.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ static int8_t set_6lowpan_nwk_down(protocol_interface_info_entry_t *cur)
8787
#endif
8888
}
8989
}
90-
uint16_t pan_id = cur->mac_parameters->pan_id;
90+
if (cur->lowpan_info & INTERFACE_NWK_BOOTSRAP_PANA_AUTHENTICATION) {
91+
pana_reset_values(cur->mac_parameters->pan_id);
92+
}
93+
9194
if (cur->interface_mode == INTERFACE_UP) {
9295
if (cur->mac_api) {
9396
mlme_reset_t reset;
@@ -105,9 +108,6 @@ static int8_t set_6lowpan_nwk_down(protocol_interface_info_entry_t *cur)
105108
reassembly_interface_reset(cur->id);
106109

107110
icmp_nd_routers_init();
108-
if (cur->lowpan_info & INTERFACE_NWK_BOOTSRAP_PANA_AUTHENTICATION) {
109-
pana_reset_values(pan_id);
110-
}
111111

112112
if (cur->pana_sec_info_temp) {
113113
ns_dyn_mem_free(cur->pana_sec_info_temp);

features/nanostack/sal-stack-nanostack/source/6LoWPAN/MAC/mac_helper.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,9 @@ void mac_helper_coordinator_address_set(protocol_interface_info_entry_t *interfa
433433
if (adr_type == ADDR_802_15_4_SHORT) {
434434
memcpy(interface->mac_parameters->mac_cordinator_info.mac_mlme_coord_address, adr_ptr, 2);
435435
interface->mac_parameters->mac_cordinator_info.cord_adr_mode = MAC_ADDR_MODE_16_BIT;
436+
uint16_t short_addr = common_read_16_bit(interface->mac_parameters->mac_cordinator_info.mac_mlme_coord_address);
436437
set_req.attr = macCoordShortAddress;
437-
set_req.value_pointer = &interface->mac_parameters->mac_cordinator_info.mac_mlme_coord_address;
438+
set_req.value_pointer = &short_addr;
438439
set_req.value_size = 2;
439440
} else if (adr_type == ADDR_802_15_4_LONG) {
440441
memcpy(interface->mac_parameters->mac_cordinator_info.mac_mlme_coord_address, adr_ptr, 8);
@@ -767,8 +768,10 @@ static uint8_t mac_helper_header_security_aux_header_length(uint8_t keyIdmode) {
767768
switch (keyIdmode) {
768769
case MAC_KEY_ID_MODE_SRC8_IDX:
769770
header_length += 4; //64-bit key source first part
771+
/* fall through */
770772
case MAC_KEY_ID_MODE_SRC4_IDX:
771773
header_length += 4; //32-bit key source inline
774+
/* fall through */
772775
case MAC_KEY_ID_MODE_IDX:
773776
header_length += 1;
774777
break;
@@ -830,13 +833,13 @@ void mac_helper_devicetable_remove(mac_api_t *mac_api, uint8_t attribute_index)
830833
mac_api->mlme_req(mac_api,MLME_SET , &set_req);
831834
}
832835

833-
void mac_helper_devicetable_set(mle_neigh_table_entry_t *entry_temp, protocol_interface_info_entry_t *cur, uint32_t frame_counter, uint8_t keyID)
836+
void mac_helper_devicetable_set(mle_neigh_table_entry_t *entry_temp, protocol_interface_info_entry_t *cur, uint32_t frame_counter, uint8_t keyID, bool force_set)
834837
{
835838
if (!cur->mac_api) {
836839
return;
837840
}
838841

839-
if (cur->mac_parameters->SecurityEnabled && cur->mac_parameters->mac_default_key_index != keyID) {
842+
if (!force_set && cur->mac_parameters->SecurityEnabled && cur->mac_parameters->mac_default_key_index != keyID) {
840843
tr_debug("Do not set counter by index %u != %u", cur->mac_parameters->mac_default_key_index, keyID);
841844
return;
842845
}

features/nanostack/sal-stack-nanostack/source/6LoWPAN/MAC/mac_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ int8_t mac_helper_link_frame_counter_set(int8_t interface_id, uint32_t seq_ptr);
110110

111111
void mac_helper_devicetable_remove(struct mac_api_s *mac_api, uint8_t attribute_index);
112112

113-
void mac_helper_devicetable_set(struct mle_neigh_table_entry_t *entry_temp, struct protocol_interface_info_entry *cur, uint32_t frame_counter, uint8_t keyID);
113+
void mac_helper_devicetable_set(struct mle_neigh_table_entry_t *entry_temp, struct protocol_interface_info_entry *cur, uint32_t frame_counter, uint8_t keyID, bool force_set);
114114

115115
int8_t mac_helper_mac_mlme_max_retry_set(int8_t interface_id, uint8_t mac_retry_set);
116116

features/nanostack/sal-stack-nanostack/source/6LoWPAN/MAC/mac_pairwise_key.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ int mac_pairwise_key_interface_unregister(int8_t interface_id)
252252
int mac_pairwise_key_add(int8_t interface_id, uint32_t valid_life_time, const uint8_t eui64[static 8], const uint8_t key[static 16])
253253
{
254254
protocol_interface_info_entry_t *interface = protocol_stack_interface_info_get_by_id(interface_id);
255+
bool new_entry_created;
256+
255257
if (!interface || !interface->mac_api) {
256258
return -1;
257259
}
@@ -264,7 +266,7 @@ int mac_pairwise_key_add(int8_t interface_id, uint32_t valid_life_time, const ui
264266
}
265267

266268
//Allocate mle entry
267-
mle_neigh_table_entry_t *mle_entry = mle_class_get_entry_by_mac64(interface_id, 0, eui64, true);
269+
mle_neigh_table_entry_t *mle_entry = mle_class_get_entry_by_mac64(interface_id, 0, eui64, true, &new_entry_created);
268270
if (!mle_entry) {
269271
return -1;
270272
}
@@ -282,7 +284,7 @@ int mac_pairwise_key_add(int8_t interface_id, uint32_t valid_life_time, const ui
282284
}
283285

284286
//Set device descriptor
285-
mac_helper_devicetable_set(mle_entry, interface, 0, interface->mac_parameters->mac_default_key_index);
287+
mac_helper_devicetable_set(mle_entry, interface, 0, interface->mac_parameters->mac_default_key_index, new_entry_created);
286288

287289
//set key descriptor
288290
if (mac_helper_security_pairwisekey_set(interface, key, eui64, key_desc->key_decriptor_attribute) != 0) {
@@ -308,7 +310,7 @@ int mac_pairwise_key_del(int8_t interface_id, const uint8_t eui64[static 8])
308310
return -1;
309311
}
310312
//Get from mle
311-
mle_neigh_table_entry_t *mle_entry = mle_class_get_entry_by_mac64(interface_id, 0, eui64, true);
313+
mle_neigh_table_entry_t *mle_entry = mle_class_get_entry_by_mac64(interface_id, 0, eui64, true, NULL);
312314
if (!mle_entry) {
313315
return -1;
314316
}

0 commit comments

Comments
 (0)