Skip to content

Commit

Permalink
Add version 1.1 basic support
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mika Tervonen authored and Mika Tervonen committed Aug 18, 2021
1 parent e1558fb commit 37efc7e
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 4 deletions.
17 changes: 17 additions & 0 deletions nanostack/net_ws_test.h
Expand Up @@ -39,6 +39,23 @@ extern "C" {

#include "ns_types.h"

/**
* \brief Set Wi-SUN version number
*
* Sets the Wi-SUN protocol version.
* 1 = Wi-SUN FAN 1.0
* 2 = Wi-SUN FAN 1.1
*
* Set version to 0 to stop override and use stack default
*
* \param interface_id Network Interface
* \param version Wi-SUN version
*
* \return 0 OK
* \return <0 Failure
*/

int ws_test_version_set(int8_t interface_id, uint8_t version);
/**
* \brief Set Pan size.
*
Expand Down
10 changes: 8 additions & 2 deletions source/6LoWPAN/ws/ws_bootstrap.c
Expand Up @@ -136,6 +136,7 @@ typedef enum {
WS_EAPOL_PARENT_SYNCH, /**< Broadcast synch with EAPOL parent*/
} ws_parent_synch_e;

uint16_t test_pan_version = 1;

static void ws_bootsrap_create_ll_address(uint8_t *ll_address, const uint8_t *mac64)
{
Expand Down Expand Up @@ -1668,7 +1669,6 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
cur->ws_info->pan_information.routing_cost = pan_information.routing_cost;
cur->ws_info->pan_information.rpl_routing_method = pan_information.rpl_routing_method;
cur->ws_info->pan_information.use_parent_bs = pan_information.use_parent_bs;
cur->ws_info->pan_information.version = pan_information.version;
}
}
}
Expand Down Expand Up @@ -3753,6 +3753,10 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
cur->ws_info->pan_information.rpl_routing_method = true;
cur->ws_info->pan_information.use_parent_bs = true;
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_0;
// initialize for FAN 1.1 defaults
if (ws_version_1_1(cur)) {
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_1;
}

uint8_t *gtkhash = ws_pae_controller_gtk_hash_ptr_get(cur);
ws_llc_set_gtkhash(cur, gtkhash);
Expand Down Expand Up @@ -3880,7 +3884,9 @@ static int8_t ws_bootstrap_neighbor_set(protocol_interface_info_entry_t *cur, pa

// Add EAPOL neighbor
cur->ws_info->network_pan_id = parent_ptr->pan_id;
cur->ws_info->pan_information = parent_ptr->pan_information;
cur->ws_info->pan_information.pan_size = parent_ptr->pan_information.pan_size;
cur->ws_info->pan_information.routing_cost = parent_ptr->pan_information.routing_cost;
cur->ws_info->pan_information.use_parent_bs = parent_ptr->pan_information.use_parent_bs;
cur->ws_info->pan_information.pan_version = 0; // This is learned from actual configuration

// If PAN ID changes, clear learned neighbors and activate FHSS
Expand Down
2 changes: 2 additions & 0 deletions source/6LoWPAN/ws/ws_bootstrap.h
Expand Up @@ -63,6 +63,8 @@ struct ws_neighbor_class_entry;
struct ws_stack_info;
struct ws_neighbour_info;

extern uint16_t test_pan_version;

int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode);

void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur);
Expand Down
8 changes: 6 additions & 2 deletions source/6LoWPAN/ws/ws_common.c
Expand Up @@ -472,12 +472,13 @@ int8_t ws_common_allocate_and_init(protocol_interface_info_entry_t *cur)
ns_list_init(&cur->ws_info->parent_list_free);
ns_list_init(&cur->ws_info->parent_list_reserved);

cur->ws_info->version = test_pan_version;

cur->ws_info->network_pan_id = 0xffff;
cur->ws_info->pan_information.use_parent_bs = true;
cur->ws_info->pan_information.rpl_routing_method = true;
cur->ws_info->pan_information.pan_version_set = false;
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_0;

cur->ws_info->pending_key_index_info.state = NO_PENDING_PROCESS;

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


// initialize for FAN 1.1 defaults
if (ws_version_1_1(cur)) {
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_1;
}
return 0;
}

Expand Down
10 changes: 10 additions & 0 deletions source/6LoWPAN/ws/ws_common.h
Expand Up @@ -100,6 +100,7 @@ typedef struct ws_info_s {
trickle_t trickle_pan_advertisement_solicit;
trickle_t trickle_pan_advertisement;
trickle_params_t trickle_params_pan_discovery;
uint8_t version; // Wi-SUN version information 1 = 1.0 2 = 1.x
uint8_t rpl_state; // state from rpl_event_t
uint8_t pas_requests; // Amount of PAN solicits sent
uint8_t device_min_sens; // Device min sensitivity set by the application
Expand Down Expand Up @@ -201,9 +202,18 @@ uint8_t ws_common_temporary_entry_size(uint8_t mac_table_size);
void ws_common_border_router_alive_update(protocol_interface_info_entry_t *interface);

#define ws_info(cur) ((cur)->ws_info)
#ifdef HAVE_WS_VERSION_1_1
#define ws_version_1_0(cur) (((cur)->ws_info) && ((cur)->ws_info)->version == 1)
#define ws_version_1_1(cur) (((cur)->ws_info) && ((cur)->ws_info)->version > 1)
#else
#define ws_version_1_1(cur) (false)
#define ws_version_1_0(cur) ((cur)->ws_info)
#endif
#define ws_test_proc_auto_trg(cur) ((cur)->ws_info->test_proc_trg.auto_trg_enabled == true)
#else
#define ws_info(cur) ((ws_info_t *) NULL)
#define ws_version_1_1(cur) (false)
#define ws_version_1_0(cur) (false)
#define ws_test_proc_auto_trg(cur) (false)
#define ws_common_seconds_timer(cur, seconds)
#define ws_common_neighbor_update(cur, ll_address) ((void) 0)
Expand Down
1 change: 1 addition & 0 deletions source/6LoWPAN/ws/ws_common_defines.h
Expand Up @@ -247,6 +247,7 @@ typedef struct ws_bs_ie {
#define WS_MPX_MAX_MTU 1576

#define WS_FAN_VERSION_1_0 1
#define WS_FAN_VERSION_1_1 2

#define WS_NEIGHBOR_LINK_TIMEOUT 2200

Expand Down
19 changes: 19 additions & 0 deletions source/6LoWPAN/ws/ws_test_api.c
Expand Up @@ -43,6 +43,25 @@

#ifdef HAVE_WS

int ws_test_version_set(int8_t interface_id, uint8_t version)
{
test_pan_version = version;

protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
if (cur) {
if (!ws_info(cur)) {
return -1;
}
cur->ws_info->version = version;
if (ws_version_1_0(cur)) {
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_0;
} else if (ws_version_1_1(cur)) {
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_1;
}
}
return 0;
}

int ws_test_pan_size_set(int8_t interface_id, uint16_t pan_size)
{

Expand Down
1 change: 1 addition & 0 deletions source/configs/base/cfg_ws_router.h
Expand Up @@ -22,5 +22,6 @@
#define HAVE_6LOWPAN_ND
#define HAVE_MPL
#define HAVE_WS
#define HAVE_WS_VERSION_1_1
#define HAVE_PAE_SUPP
#define HAVE_EAPOL_RELAY
1 change: 1 addition & 0 deletions source/configs/cfg_generic.h
Expand Up @@ -32,4 +32,5 @@
#define TCP_TEST
#define THREAD_THCI_SUPPORT
#define HAVE_WS
#define HAVE_WS_VERSION_1_1
#define MLE_TEST

0 comments on commit 37efc7e

Please sign in to comment.