Skip to content

Commit

Permalink
Wi-Sun IE FAN 1.1 update
Browse files Browse the repository at this point in the history
Added support for new Channel Plan 2.

Added support for new Wi-SUN nested IE header and payload element write/read.

Simplify Shedule Information write and set and length functions.
  • Loading branch information
Juha Heiskanen committed Aug 19, 2021
1 parent 1d56070 commit 42dba41
Show file tree
Hide file tree
Showing 7 changed files with 1,085 additions and 93 deletions.
27 changes: 27 additions & 0 deletions source/6LoWPAN/MAC/mac_ie_lib.c
Expand Up @@ -144,6 +144,33 @@ uint16_t mac_ie_nested_discover(uint8_t *payload_ptr, uint16_t length, mac_neste
return 0;
}

uint16_t mac_ie_nested_tagged_discover(uint8_t *payload_ptr, uint16_t length, mac_nested_payload_IE_t *nested_ie, uint8_t sub_tag_id)
{
mac_nested_payload_IE_t ie_element;
uint8_t *sub_tag_ptr;
while (length >= 2) {
mac_ie_nested_id_parse(&ie_element, payload_ptr);

if (length < ie_element.length + 2) {
return 0;
}

sub_tag_ptr = ie_element.content_ptr;
if (ie_element.length > 1 && nested_ie->id == ie_element.id && *sub_tag_ptr == sub_tag_id) {
sub_tag_ptr++;
ie_element.length--;
nested_ie->content_ptr = sub_tag_ptr;
nested_ie->length = ie_element.length;
return ie_element.length;
}

length -= ie_element.length + 2;

payload_ptr += ie_element.length + 2;
}
return 0;
}

uint8_t mac_ie_header_discover(uint8_t *header_ptr, uint16_t length, mac_header_IE_t *header_ie)
{
mac_header_IE_t ie_element;
Expand Down
3 changes: 3 additions & 0 deletions source/6LoWPAN/MAC/mac_ie_lib.h
Expand Up @@ -49,6 +49,9 @@ uint16_t mac_ie_payload_discover(uint8_t *payload_ptr, uint16_t length, struct m
/** Nested IE element discover inside parsed payload element */
uint16_t mac_ie_nested_discover(uint8_t *payload_ptr, uint16_t length, mac_nested_payload_IE_t *nested_ie);

/** Nested IE element discover with Sub Tag ID inside parsed payload element */
uint16_t mac_ie_nested_tagged_discover(uint8_t *payload_ptr, uint16_t length, mac_nested_payload_IE_t *nested_ie, uint8_t sub_tag_id);

/** Header IE elemnt discover */
uint8_t mac_ie_header_discover(uint8_t *header_ptr, uint16_t length, struct mac_header_IE_s *header_ie);

Expand Down
206 changes: 202 additions & 4 deletions source/6LoWPAN/ws/ws_common_defines.h
Expand Up @@ -28,19 +28,40 @@
#define WH_IE_MHDS_TYPE 5 /**< MHDS information for mesh routing */
#define WH_IE_VH_TYPE 6 /**< Vendor header information */
#define WH_IE_EA_TYPE 9 /**< Eapol Auhtenticator EUI-64 header information */
/* Wi-SUN FAN dfinition 1.1 */
#define WH_IE_LUTT_TYPE 10 /**< LFN Unicast Timing and Frame Type information */
#define WH_IE_LBT_TYPE 11 /**< LFN Broadcast Timing information */
#define WH_IE_NR_TYPE 12 /**< Node Role IE information */
#define WH_IE_LUS_TYPE 13 /**< LFN Unicast Schedule information */
#define WH_IE_FLUS_TYPE 14 /**< FFN for LFN unicast Schedule information */
#define WH_IE_LBS_TYPE 15 /**< LFN Broadcast Schedule information */
#define WH_IE_LND_TYPE 16 /**< LFN Network Discovery information */
#define WH_IE_LTO_TYPE 17 /**< LFN Timing information */
#define WH_IE_PANID_TYPE 18 /**< PAN Identifier information */


#define WS_WP_NESTED_IE 4 /**< WS nested Payload IE element'selement could include mltiple sub payload IE */

#define WS_WP_SUB_IE_ELEMENT_HEADER_LENGTH 2

/* Payload IE sub elements in side WS_WP_NESTED_IE */
#define WP_PAYLOAD_IE_US_TYPE 1 /**< Unicast Schedule information */
#define WP_PAYLOAD_IE_BS_TYPE 2 /**< Broadcast Schedule information */
#define WP_PAYLOAD_IE_VP_TYPE 3 /**< Vendor Payload information */
/* Long form subID's */
#define WP_PAYLOAD_IE_US_TYPE 1 /**< Unicast Schedule information */
#define WP_PAYLOAD_IE_BS_TYPE 2 /**< Broadcast Schedule information */
#define WP_PAYLOAD_IE_VP_TYPE 3 /**< Vendor Payload information */
/* Wi-SUN FAN definition 1.1 */
#define WP_PAYLOAD_IE_LFN_CHANNEL_PLAN_TYPE 4 /**< LFN Channel Plan information*/

/* Short form subID's */
#define WP_PAYLOAD_IE_PAN_TYPE 4 /**< PAN Information */
#define WP_PAYLOAD_IE_NETNAME_TYPE 5 /**< Network Name information */
#define WP_PAYLOAD_IE_PAN_VER_TYPE 6 /**< Pan configuration version */
#define WP_PAYLOAD_IE_GTKHASH_TYPE 7 /**< GTK Hash information */
/* Wi-SUN FAN dfinition 1.1 */
#define WP_PAYLOAD_IE_PCAP_TYPE 8 /**< PHY Capability information */
#define WP_PAYLOAD_IE_LFNVER_TYPE 9 /**< LFN Version information */
#define WP_PAYLOAD_IE_LGTKHASH_TYPE 10 /**< LFN GTK Hash Information */


/* WS frame types to WH_IE_UTT_TYPE */
#define WS_FT_PAN_ADVERT 0 /**< PAN Advert */
Expand All @@ -50,14 +71,25 @@
#define WS_FT_DATA 4 /**< data type inside MPX */
#define WS_FT_ACK 5 /**< Enhanced ACK */
#define WS_FT_EAPOL 6 /**< EAPOL message inside MPX */
/* Wi-SUN FAN 1.1 */
#define WS_FT_LPA 9 /**< LFN PAN Advert */
#define WS_FT_LPAS 10 /**< LFN PAN Advert Solicit */
#define WS_FT_LPC 11 /**< LFN PAN Config */
#define WS_FT_LPCS 12 /**< LFN PAN Config Solicit */


/* WS exluded channel Control */
#define WS_EXC_CHAN_CTRL_NONE 0 /**< No excluded channels */
#define WS_EXC_CHAN_CTRL_RANGE 1 /**< Excluded channels are in 1 or multiple channel range */
#define WS_EXC_CHAN_CTRL_BITMASK 2 /**< Excluded channels are marked to bitmask which length based on configured channels */
#define WS_EXC_CHAN_CTRL_BITMASK 2 /**< Excluded channels are marked to bitmask which length based on configured channels */

#define WS_EXCLUDED_MAX_RANGE_TO_SEND 3


#define WS_NR_ROLE_BR 0
#define WS_NR_ROLE_ROUTER 1
#define WS_NR_ROLE_LFN 2

/**
* @brief ws_pan_information_t PAN information
*/
Expand All @@ -68,6 +100,7 @@ typedef struct ws_pan_information_s {
bool use_parent_bs: 1; /**< 1 for force to follow parent broadcast schedule. 0 node may define own schedule. */
bool rpl_routing_method: 1; /**< 1 when RPL routing is selected and 0 when L2 routing. */
bool pan_version_set: 1; /**< 1 PAN version is set. */
bool lfn_window_style: 1; /**< 1 FFN management trasmission. */
unsigned version: 3; /**< Pan version support. */
} ws_pan_information_t;

Expand Down Expand Up @@ -125,6 +158,104 @@ typedef struct ws_utt_ie {
uint_fast24_t ufsi;
} ws_utt_ie_t;

/**
* @brief ws_utt_ie_t WS LUTT-IE
*/
typedef struct ws_lutt_ie {
uint8_t message_type;
uint16_t slot_number;
uint_fast24_t interval_offset;
} ws_lutt_ie_t;

/**
* @brief ws_lbt_ie_t WS LBT-IE
*/
typedef struct ws_lbt_ie {
uint16_t slot_number;
uint_fast24_t interval_offset;
} ws_lbt_ie_t;


/**
* @brief ws_nr_ie_t WS NR-IE
*/
typedef struct ws_nr_ie {
unsigned node_role: 3;
uint8_t clock_drift;
uint8_t timing_accurancy;
uint_fast24_t listen_interval_min;
uint_fast24_t listen_interval_max;
} ws_nr_ie_t;


/**
* @brief ws_lus_ie_t WS LUS-IE
*/
typedef struct ws_lus_ie {
uint8_t channel_plan_tag;
uint_fast24_t listen_interval;
} ws_lus_ie_t;

/**
* @brief ws_lus_ie_t WS FLUS-IE
*/
typedef struct ws_flus_ie {
uint8_t channel_plan_tag;
uint8_t dwell_interval;
} ws_flus_ie_t;

/**
* @brief ws_lnd_ie_t WS LND-IE
*/
typedef struct ws_lnd_ie {
uint8_t response_threshold;
uint8_t discovery_slot_time;
uint8_t discovery_slots;
uint16_t discovery_first_slot;
uint_fast24_t response_delay;
} ws_lnd_ie_t;

/**
* @brief ws_lto_ie_t WS LTO-IE
*/
typedef struct ws_lto_ie {
uint_fast24_t offset;
uint_fast24_t adjusted_listening_interval;
} ws_lto_ie_t;

/**
* @brief ws_lbs_ie_t WS LBS-IE
*/
typedef struct ws_lbs_ie {
uint8_t channel_plan_tag;
uint16_t broadcast_secheduler_id;
uint_fast24_t broadcast_interval;
} ws_lbs_ie_t;


/**
* @brief ws_panid_ie_t WS PANID-IE
*/
typedef struct ws_panid_ie {
uint16_t panid;
} ws_panid_ie_t;

/**
* @brief ws_pcab_ie_t WS PCAB-IE
*/
typedef struct ws_pcab_ie {
unsigned phy_type: 3;
uint16_t operation_mode;
} ws_pcab_ie_t;

/**
* @brief ws_pcab_read_ie_t WS PCAB-IE
*/
typedef struct ws_pcab_read_ie {
unsigned length_of_pcab: 3;
uint8_t *pcab_start;
} ws_pcab_read_ie_t;

/**
* @brief ws_bt_ie_t WS BT-IE read
*/
Expand All @@ -141,6 +272,26 @@ typedef struct ws_fc_ie {
uint8_t rx_flow_ctrl;
} ws_fc_ie_t;

/**
* @brief ws_lfnver_ie_t WS LFNVER-IE element
*/
typedef struct ws_lfnver_ie {
uint16_t lfn_version;
} ws_lfnver_ie_t;

/**
* @brief ws_lgtkhash_ie_t WS LGTKHASH-IE element
*/
typedef struct ws_lgtkhash_ie {
bool lgtk0: 1; /**< 1= LGTK0 in line 0 = elided */
bool lgtk1: 1; /**< 1= LGTK1 in line 0 = elided */
bool lgtk2: 1; /**< 1= LGTK2 in line 0 = elided */
unsigned active_lgtk_index: 2; /**< Indicate Active LGTK index 0-2 */
uint8_t *lgtk0_hash; /**< LGTK0 64-bit Hash if lgtk0=1*/
uint8_t *lgtk1_hash; /**< LGTK1 64-bit Hash if lgtk1=1*/
uint8_t *lgtk2_hash; /**< LGTK2 64-bit Hash if lgtk2=1*/
} ws_lgtkhash_ie_t;

/**
* @brief ws_channel_plan_zero_t WS channel plan 0 define domain and class
*/
Expand All @@ -158,6 +309,14 @@ typedef struct ws_channel_plan_one {
uint16_t number_of_channel;
} ws_channel_plan_one_t;

/**
* @brief ws_channel_plan_two_t WS channel plan 2 define regulator domain and chanel plan 1
*/
typedef struct ws_channel_plan_two {
uint8_t regulator_domain;
uint8_t channel_plan_id;
} ws_channel_plan_two_t;

/**
* @brief ws_channel_function_zero_t WS function 0 fixed channel
*/
Expand Down Expand Up @@ -189,6 +348,43 @@ typedef struct ws_excluded_channel_mask {
uint8_t mask_len_inline;
} ws_excluded_channel_mask_t;


typedef struct ws_excluded_channel_range_out {
unsigned excluded_range_length: 3;
ws_excluded_channel_range_data_t *exluded_range;
} ws_excluded_channel_range_out_t;


typedef struct ws_excluded_channel_mask_out {
uint16_t excluded_channel_count;
uint8_t channel_mask_bytes_inline;
uint32_t *channel_mask;
} ws_excluded_channel_mask_out_t;

/**
* @brief ws_generic_channel_info_t Generic Channel Info
*/
typedef struct ws_generic_channel_info {
unsigned channel_plan: 3;
unsigned channel_function: 3;
unsigned excluded_channel_ctrl: 2;
union {
ws_channel_plan_zero_t zero;
ws_channel_plan_one_t one;
ws_channel_plan_two_t two;
} plan;
union {
ws_channel_function_zero_t zero;
ws_channel_function_three_t three;
} function;
union {
ws_excluded_channel_range_out_t range;
ws_excluded_channel_mask_out_t mask;
ws_excluded_channel_range_t range_in;
ws_excluded_channel_mask_t mask_in;
} excluded_channels;
} ws_generic_channel_info_t;

/**
* @brief ws_us_ie_t WS US-IE read
*/
Expand All @@ -202,6 +398,7 @@ typedef struct ws_us_ie {
union {
ws_channel_plan_zero_t zero;
ws_channel_plan_one_t one;
ws_channel_plan_two_t two;
} plan;
union {
ws_channel_function_zero_t zero;
Expand All @@ -228,6 +425,7 @@ typedef struct ws_bs_ie {
union {
ws_channel_plan_zero_t zero;
ws_channel_plan_one_t one;
ws_channel_plan_two_t two;
} plan;
union {
ws_channel_function_zero_t zero;
Expand Down

0 comments on commit 42dba41

Please sign in to comment.