Skip to content

Commit 37efc7e

Browse files
Mika TervonenMika Tervonen
authored andcommitted
Add version 1.1 basic support
Add compile flag and version check for FAN 1.1 Dynamic testing API to allow testing against different versions Fixed processing of pan information version number to follow specification
1 parent e1558fb commit 37efc7e

File tree

9 files changed

+65
-4
lines changed

9 files changed

+65
-4
lines changed

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
*

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ typedef enum {
136136
WS_EAPOL_PARENT_SYNCH, /**< Broadcast synch with EAPOL parent*/
137137
} ws_parent_synch_e;
138138

139+
uint16_t test_pan_version = 1;
139140

140141
static void ws_bootsrap_create_ll_address(uint8_t *ll_address, const uint8_t *mac64)
141142
{
@@ -1668,7 +1669,6 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
16681669
cur->ws_info->pan_information.routing_cost = pan_information.routing_cost;
16691670
cur->ws_info->pan_information.rpl_routing_method = pan_information.rpl_routing_method;
16701671
cur->ws_info->pan_information.use_parent_bs = pan_information.use_parent_bs;
1671-
cur->ws_info->pan_information.version = pan_information.version;
16721672
}
16731673
}
16741674
}
@@ -3753,6 +3753,10 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
37533753
cur->ws_info->pan_information.rpl_routing_method = true;
37543754
cur->ws_info->pan_information.use_parent_bs = true;
37553755
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_0;
3756+
// initialize for FAN 1.1 defaults
3757+
if (ws_version_1_1(cur)) {
3758+
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_1;
3759+
}
37563760

37573761
uint8_t *gtkhash = ws_pae_controller_gtk_hash_ptr_get(cur);
37583762
ws_llc_set_gtkhash(cur, gtkhash);
@@ -3880,7 +3884,9 @@ static int8_t ws_bootstrap_neighbor_set(protocol_interface_info_entry_t *cur, pa
38803884

38813885
// Add EAPOL neighbor
38823886
cur->ws_info->network_pan_id = parent_ptr->pan_id;
3883-
cur->ws_info->pan_information = parent_ptr->pan_information;
3887+
cur->ws_info->pan_information.pan_size = parent_ptr->pan_information.pan_size;
3888+
cur->ws_info->pan_information.routing_cost = parent_ptr->pan_information.routing_cost;
3889+
cur->ws_info->pan_information.use_parent_bs = parent_ptr->pan_information.use_parent_bs;
38843890
cur->ws_info->pan_information.pan_version = 0; // This is learned from actual configuration
38853891

38863892
// If PAN ID changes, clear learned neighbors and activate FHSS

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ struct ws_neighbor_class_entry;
6363
struct ws_stack_info;
6464
struct ws_neighbour_info;
6565

66+
extern uint16_t test_pan_version;
67+
6668
int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode);
6769

6870
void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur);

source/6LoWPAN/ws/ws_common.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,13 @@ int8_t ws_common_allocate_and_init(protocol_interface_info_entry_t *cur)
472472
ns_list_init(&cur->ws_info->parent_list_free);
473473
ns_list_init(&cur->ws_info->parent_list_reserved);
474474

475+
cur->ws_info->version = test_pan_version;
476+
475477
cur->ws_info->network_pan_id = 0xffff;
476478
cur->ws_info->pan_information.use_parent_bs = true;
477479
cur->ws_info->pan_information.rpl_routing_method = true;
478480
cur->ws_info->pan_information.pan_version_set = false;
479481
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_0;
480-
481482
cur->ws_info->pending_key_index_info.state = NO_PENDING_PROCESS;
482483

483484
cur->ws_info->hopping_schdule.regulatory_domain = REG_DOMAIN_EU;
@@ -490,7 +491,10 @@ int8_t ws_common_allocate_and_init(protocol_interface_info_entry_t *cur)
490491
ws_common_regulatory_domain_config(cur, &cur->ws_info->hopping_schdule);
491492
cur->ws_info->pending_key_index_info.state = NO_PENDING_PROCESS;
492493

493-
494+
// initialize for FAN 1.1 defaults
495+
if (ws_version_1_1(cur)) {
496+
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_1;
497+
}
494498
return 0;
495499
}
496500

source/6LoWPAN/ws/ws_common.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ typedef struct ws_info_s {
100100
trickle_t trickle_pan_advertisement_solicit;
101101
trickle_t trickle_pan_advertisement;
102102
trickle_params_t trickle_params_pan_discovery;
103+
uint8_t version; // Wi-SUN version information 1 = 1.0 2 = 1.x
103104
uint8_t rpl_state; // state from rpl_event_t
104105
uint8_t pas_requests; // Amount of PAN solicits sent
105106
uint8_t device_min_sens; // Device min sensitivity set by the application
@@ -201,9 +202,18 @@ uint8_t ws_common_temporary_entry_size(uint8_t mac_table_size);
201202
void ws_common_border_router_alive_update(protocol_interface_info_entry_t *interface);
202203

203204
#define ws_info(cur) ((cur)->ws_info)
205+
#ifdef HAVE_WS_VERSION_1_1
206+
#define ws_version_1_0(cur) (((cur)->ws_info) && ((cur)->ws_info)->version == 1)
207+
#define ws_version_1_1(cur) (((cur)->ws_info) && ((cur)->ws_info)->version > 1)
208+
#else
209+
#define ws_version_1_1(cur) (false)
210+
#define ws_version_1_0(cur) ((cur)->ws_info)
211+
#endif
204212
#define ws_test_proc_auto_trg(cur) ((cur)->ws_info->test_proc_trg.auto_trg_enabled == true)
205213
#else
206214
#define ws_info(cur) ((ws_info_t *) NULL)
215+
#define ws_version_1_1(cur) (false)
216+
#define ws_version_1_0(cur) (false)
207217
#define ws_test_proc_auto_trg(cur) (false)
208218
#define ws_common_seconds_timer(cur, seconds)
209219
#define ws_common_neighbor_update(cur, ll_address) ((void) 0)

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ typedef struct ws_bs_ie {
247247
#define WS_MPX_MAX_MTU 1576
248248

249249
#define WS_FAN_VERSION_1_0 1
250+
#define WS_FAN_VERSION_1_1 2
250251

251252
#define WS_NEIGHBOR_LINK_TIMEOUT 2200
252253

source/6LoWPAN/ws/ws_test_api.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@
4343

4444
#ifdef HAVE_WS
4545

46+
int ws_test_version_set(int8_t interface_id, uint8_t version)
47+
{
48+
test_pan_version = version;
49+
50+
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
51+
if (cur) {
52+
if (!ws_info(cur)) {
53+
return -1;
54+
}
55+
cur->ws_info->version = version;
56+
if (ws_version_1_0(cur)) {
57+
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_0;
58+
} else if (ws_version_1_1(cur)) {
59+
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_1;
60+
}
61+
}
62+
return 0;
63+
}
64+
4665
int ws_test_pan_size_set(int8_t interface_id, uint16_t pan_size)
4766
{
4867

source/configs/base/cfg_ws_router.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
#define HAVE_6LOWPAN_ND
2323
#define HAVE_MPL
2424
#define HAVE_WS
25+
#define HAVE_WS_VERSION_1_1
2526
#define HAVE_PAE_SUPP
2627
#define HAVE_EAPOL_RELAY

source/configs/cfg_generic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@
3232
#define TCP_TEST
3333
#define THREAD_THCI_SUPPORT
3434
#define HAVE_WS
35+
#define HAVE_WS_VERSION_1_1
3536
#define MLE_TEST

0 commit comments

Comments
 (0)