Skip to content

Commit 3bb860b

Browse files
author
Arto Kinnunen
committed
Squashed 'features/nanostack/sal-stack-nanostack/' changes from 09d9e24..715ae9a
715ae9a Merge remote-tracking branch 'origin/release_internal' into release_external 42c9807 Nanostak trace level configuration (ARMmbed#2489) 6f52171 Bug fix: socket reference count made 16-bit (ARMmbed#2490) f51669a Bug fix: Do not print UFSI drift when fixed channel is used (ARMmbed#2488) 18fa048 RPL DAO timeout update: 660e178 Clear debug traces. cbac0bb DIO init send block for node fed5d1c Created different MPL configuration based on network size 7ad7e81 Wi-SUN recovery and BR BSI update: d207f4d Merge branch 'release_internal' into release_external d166c89 MPL: buffered max limit increased to 8k (ARMmbed#2482) 0f6666a Fixed Unit test's 1ff9b1d LLC drop a packet if FHSS shedule is not configured. 7cecc28 Fixed missing asynch trigle setup stop at if down process 7a8b2bf Wi-SUN fhss API default value setting fixes 164a370 Fixed coverity issues from management API 8b5b433 Corrected out of bounds access coverity warning (ARMmbed#2475) 4ffe6a1 Multicast forwarding is separated from the routing flag 30f4315 Wi-SUN discovery staten enter upxdate 083b84e Iotthd 4308 (ARMmbed#2473) fcc33d5 Removed time increment from NVM time read function on interface up 9c8e3af fhss_tx_handle update 5491a6b Fixed UFSI update print function (ARMmbed#2470) 86f64c5 FHSS WS: Check if BC schedule is stopped before computing timeout delay (ARMmbed#2469) a0b112a Corrected defects and coding style 2f4678a Corrected trace macro 5e96751 Distributed key storage NVM writes to longer time period 9b3891f FHSS WS: handle blocked interrupts (ARMmbed#2466) a792e83 Added validation at MAC ack buffer handler 2a465b2 DNS configuration lifetime validation git-subtree-dir: features/nanostack/sal-stack-nanostack git-subtree-split: 715ae9a
1 parent d2d0895 commit 3bb860b

35 files changed

+690
-160
lines changed

mbed_lib.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
"configuration": {
66
"help": "Build time configuration. Refer to Handbook for valid values. Default: full stack",
77
"value": "nanostack_full"
8+
},
9+
"trace_max_level": {
10+
"help": "One of mbed-trace level defines: TRACE_LEVEL_DEBUG, TRACE_LEVEL_INFO, TRACE_LEVEL_WARN or TRACE_LEVEL_ERROR",
11+
"value": null
812
}
913
},
1014
"macros": ["NS_USE_EXTERNAL_MBED_TLS"],

nanostack/ws_bbr_api.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,19 @@ int ws_bbr_pan_configuration_get(int8_t interface_id, uint16_t *pan_id);
334334
*/
335335
int ws_bbr_pan_configuration_validate(int8_t interface_id, uint16_t pan_id);
336336

337+
/**
338+
* Sets Wi-SUN BSI
339+
*
340+
* Sets Wi-SUN PAN BSI.
341+
*
342+
* \param interface_id Network interface ID.
343+
* \param new_bsi Identifier.
344+
*
345+
* \return 0, PAN BSI set.
346+
* \return <0 PAN BSI set failed.
347+
*/
348+
int ws_bbr_bsi_set(int8_t interface_id, uint16_t new_bsi);
349+
337350
/**
338351
* Sets memory used for key storages
339352
*

nanostack/ws_management_api.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ int ws_management_channel_plan_set(
382382
*
383383
* Change the default configuration for Wi-SUN FHSS operation.
384384
*
385+
* Calling with fhss_uc_dwell_interval = 0, fhss_broadcast_interval = 0xffffffff,
386+
* fhss_bc_dwell_interval = 0 restores stack defaults
385387
*
386388
* \param interface_id Network interface ID.
387389
* \param fhss_uc_dwell_interval default to 250 ms.
@@ -403,6 +405,7 @@ int ws_management_fhss_timing_configure(
403405
* Change the default configuration for Wi-SUN FHSS operation.
404406
* if application defined is used the behaviour is undefined
405407
*
408+
* Calling with dwell_interval = 0, channel_function = 0xff, fixed_channel = 0xffff restores stack defaults
406409
*
407410
* \param interface_id Network interface ID.
408411
* \param channel_function Unicast channel function.
@@ -458,6 +461,8 @@ int ws_management_fhss_unicast_channel_function_validate(
458461
* Change the default configuration for Wi-SUN FHSS operation.
459462
* if application defined is used the behaviour is undefined
460463
*
464+
* Calling with dwell_interval = 0, channel_function = 0xff,
465+
* broadcast_interval = 0xffffffff, fixed_channel = 0xffff restores stack defaults
461466
*
462467
* \param interface_id Network interface ID.
463468
* \param channel_function Broadcast channel function.

source/6LoWPAN/Thread/thread_bbr_api.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,13 +629,14 @@ static void thread_bbr_network_data_send(thread_bbr_t *this, uint8_t prefix[8],
629629

630630
static void thread_bbr_routing_enable(thread_bbr_t *this, bool multicast_routing_enabled)
631631
{
632+
// Start multicast proxying
633+
// We do not enable multicast forwarding as there is other default router present in network
634+
multicast_fwd_set_forwarding(this->interface_id, multicast_routing_enabled);
635+
632636
if (this->routing_enabled) {
633637
return;
634638
}
635639
tr_info("br: enable routing");
636-
// Start multicast proxying
637-
// We do not enable multicast forwarding as there is other default router present in network
638-
multicast_fwd_set_forwarding(this->interface_id, multicast_routing_enabled);
639640
this->routing_enabled = true;
640641
}
641642

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "ns_types.h"
2121
#include "ns_trace.h"
2222
#include "nsdynmemLIB.h"
23+
#include "randLIB.h"
24+
#include "common_functions.h"
2325
#include "net_interface.h"
2426
#include "socket_api.h"
2527
#include "eventOS_event.h"
@@ -31,6 +33,7 @@
3133
#include "6LoWPAN/ws/ws_bootstrap.h"
3234
#include "6LoWPAN/ws/ws_cfg_settings.h"
3335
#include "6LoWPAN/ws/ws_pae_key_storage.h"
36+
#include "6LoWPAN/ws/ws_pae_nvm_store.h"
3437
#include "RPL/rpl_control.h"
3538
#include "RPL/rpl_data.h"
3639
#include "Common_Protocols/icmpv6.h"
@@ -61,6 +64,20 @@ static uint8_t current_instance_id = RPL_INSTANCE_ID;
6164
#define BBR_CHECK_INTERVAL 60
6265
#define BBR_BACKUP_ULA_DELAY 300
6366

67+
//TAG ID This must be update if NVM_BBR_INFO_LEN or data structure
68+
#define NVM_BBR_INFO_TAG 1
69+
// BSI 2 bytes
70+
#define NVM_BBR_INFO_LEN 2
71+
72+
typedef struct bbr_info_nvm_tlv {
73+
uint16_t tag; /**< Unique tag */
74+
uint16_t len; /**< Number of the bytes after the length field */
75+
uint8_t data[NVM_BBR_INFO_LEN]; /**< Data */
76+
} bbr_info_nvm_tlv_t;
77+
78+
//NVM file name
79+
static const char *BBR_INFO_FILE = "pae_bbr_info";
80+
6481
/* when creating BBR make ULA dodag ID always and when network becomes available add prefix to DHCP
6582
*
6683
*
@@ -105,6 +122,52 @@ typedef struct dns_resolution {
105122
#define MAX_DNS_RESOLUTIONS 4
106123

107124
static dns_resolution_t pre_resolved_dns_queries[MAX_DNS_RESOLUTIONS] = {0};
125+
//BBR NVM info buffer
126+
127+
#define BBR_NVM_BSI_OFFSET 0
128+
static bbr_info_nvm_tlv_t bbr_info_nvm_tlv = {
129+
.tag = NVM_BBR_INFO_TAG,
130+
.len = 0,
131+
.data = {0}
132+
};
133+
134+
static uint16_t ws_bbr_fhss_bsi = 0;
135+
136+
static int8_t ws_bbr_nvm_info_read(bbr_info_nvm_tlv_t *tlv_entry)
137+
{
138+
tlv_entry->tag = NVM_BBR_INFO_TAG;
139+
tlv_entry->len = NVM_BBR_INFO_LEN;
140+
141+
int8_t ret_val = ws_pae_nvm_store_tlv_file_read(BBR_INFO_FILE, (nvm_tlv_t *) &bbr_info_nvm_tlv);
142+
143+
if (ret_val < 0 || tlv_entry->tag != NVM_BBR_INFO_TAG || tlv_entry->len != NVM_BBR_INFO_LEN) {
144+
ws_pae_nvm_store_tlv_file_remove(BBR_INFO_FILE);
145+
tlv_entry->len = 0;
146+
return -1;
147+
}
148+
return 0;
149+
}
150+
151+
static void ws_bbr_nvm_info_write(bbr_info_nvm_tlv_t *tlv_entry)
152+
{
153+
tlv_entry->tag = NVM_BBR_INFO_TAG;
154+
tlv_entry->len = NVM_BBR_INFO_LEN;
155+
ws_pae_nvm_store_tlv_file_write(BBR_INFO_FILE, (nvm_tlv_t *) tlv_entry);
156+
tr_debug("BBR info NVM update");
157+
}
158+
159+
static uint16_t ws_bbr_bsi_read(bbr_info_nvm_tlv_t *tlv_entry)
160+
{
161+
if (tlv_entry->tag != NVM_BBR_INFO_TAG || tlv_entry->len != NVM_BBR_INFO_LEN) {
162+
return 0;
163+
}
164+
return common_read_16_bit(tlv_entry->data + BBR_NVM_BSI_OFFSET);
165+
}
166+
167+
static void ws_bbr_bsi_write(bbr_info_nvm_tlv_t *tlv_entry, uint16_t bsi)
168+
{
169+
common_write_16_bit(bsi, tlv_entry->data + BBR_NVM_BSI_OFFSET);
170+
}
108171

109172
static void ws_bbr_rpl_version_timer_start(protocol_interface_info_entry_t *cur, uint8_t version)
110173
{
@@ -134,7 +197,6 @@ static void ws_bbr_rpl_version_increase(protocol_interface_info_entry_t *cur)
134197
ws_bbr_rpl_version_timer_start(cur, rpl_control_increment_dodag_version(protocol_6lowpan_rpl_root_dodag));
135198
}
136199

137-
138200
void ws_bbr_rpl_config(protocol_interface_info_entry_t *cur, uint8_t imin, uint8_t doubling, uint8_t redundancy, uint16_t dag_max_rank_increase, uint16_t min_hop_rank_increase)
139201
{
140202
if (imin == 0 || doubling == 0) {
@@ -785,6 +847,35 @@ bool ws_bbr_ready_to_start(protocol_interface_info_entry_t *cur)
785847

786848
return true;
787849
}
850+
851+
void ws_bbr_init(protocol_interface_info_entry_t *interface)
852+
{
853+
(void) interface;
854+
//Read From NVM
855+
if (ws_bbr_nvm_info_read(&bbr_info_nvm_tlv) < 0) {
856+
//NVM value not available Randomize Value Here by first time
857+
ws_bbr_fhss_bsi = randLIB_get_16bit();
858+
tr_debug("Randomized init value BSI %u", ws_bbr_fhss_bsi);
859+
} else {
860+
ws_bbr_fhss_bsi = ws_bbr_bsi_read(&bbr_info_nvm_tlv);
861+
tr_debug("Read BSI %u from NVM", ws_bbr_fhss_bsi);
862+
}
863+
}
864+
865+
866+
uint16_t ws_bbr_bsi_generate(protocol_interface_info_entry_t *interface)
867+
{
868+
(void) interface;
869+
//Give current one
870+
uint16_t bsi = ws_bbr_fhss_bsi;
871+
//Update value for next round
872+
ws_bbr_fhss_bsi++;
873+
//Store To NVN
874+
ws_bbr_bsi_write(&bbr_info_nvm_tlv, ws_bbr_fhss_bsi);
875+
ws_bbr_nvm_info_write(&bbr_info_nvm_tlv);
876+
return bsi;
877+
}
878+
788879
#endif //HAVE_WS_BORDER_ROUTER
789880

790881
/* Public APIs
@@ -1070,6 +1161,33 @@ int ws_bbr_rpl_parameters_validate(int8_t interface_id, uint8_t dio_interval_min
10701161
#endif
10711162
}
10721163

1164+
int ws_bbr_bsi_set(int8_t interface_id, uint16_t new_bsi)
1165+
{
1166+
(void) interface_id;
1167+
#ifdef HAVE_WS_BORDER_ROUTER
1168+
1169+
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
1170+
1171+
//Check if new value is different than current active
1172+
if (cur && cur->ws_info && cur->lowpan_info & INTERFACE_NWK_ACTIVE) {
1173+
if (cur->ws_info->hopping_schdule.fhss_bsi == new_bsi) {
1174+
return 0;
1175+
}
1176+
tr_debug("New BSI %u to delayed activate", new_bsi);
1177+
ws_bootstrap_restart_delayed(cur->id);
1178+
}
1179+
1180+
ws_bbr_bsi_write(&bbr_info_nvm_tlv, new_bsi);
1181+
ws_bbr_nvm_info_write(&bbr_info_nvm_tlv);
1182+
ws_bbr_fhss_bsi = new_bsi;
1183+
return 0;
1184+
#else
1185+
(void) new_bsi;
1186+
return -1;
1187+
#endif
1188+
}
1189+
1190+
10731191
int ws_bbr_pan_configuration_set(int8_t interface_id, uint16_t pan_id)
10741192
{
10751193
(void) interface_id;

source/6LoWPAN/ws/ws_bbr_api_internal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ bool ws_bbr_ready_to_start(protocol_interface_info_entry_t *cur);
3737

3838
bool ws_bbr_backbone_address_get(uint8_t *address);
3939

40+
uint16_t ws_bbr_bsi_generate(protocol_interface_info_entry_t *interface);
41+
void ws_bbr_init(protocol_interface_info_entry_t *interface);
42+
4043
#else
4144

4245
#define ws_bbr_seconds_timer( cur, seconds)
@@ -46,6 +49,8 @@ bool ws_bbr_backbone_address_get(uint8_t *address);
4649
#define ws_bbr_dhcp_address_lifetime_set(cur, dhcp_address_lifetime)
4750
#define ws_bbr_ready_to_start(cur) true
4851
#define ws_bbr_backbone_address_get(address) 0
52+
#define ws_bbr_bsi_generate(interface) 0
53+
#define ws_bbr_init(interface) (void) 0
4954

5055
#endif //HAVE_WS_BORDER_ROUTER
5156

0 commit comments

Comments
 (0)