Skip to content

Commit 42dba41

Browse files
author
Juha Heiskanen
committed
Wi-Sun IE FAN 1.1 update
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.
1 parent 1d56070 commit 42dba41

File tree

7 files changed

+1085
-93
lines changed

7 files changed

+1085
-93
lines changed

source/6LoWPAN/MAC/mac_ie_lib.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,33 @@ uint16_t mac_ie_nested_discover(uint8_t *payload_ptr, uint16_t length, mac_neste
144144
return 0;
145145
}
146146

147+
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)
148+
{
149+
mac_nested_payload_IE_t ie_element;
150+
uint8_t *sub_tag_ptr;
151+
while (length >= 2) {
152+
mac_ie_nested_id_parse(&ie_element, payload_ptr);
153+
154+
if (length < ie_element.length + 2) {
155+
return 0;
156+
}
157+
158+
sub_tag_ptr = ie_element.content_ptr;
159+
if (ie_element.length > 1 && nested_ie->id == ie_element.id && *sub_tag_ptr == sub_tag_id) {
160+
sub_tag_ptr++;
161+
ie_element.length--;
162+
nested_ie->content_ptr = sub_tag_ptr;
163+
nested_ie->length = ie_element.length;
164+
return ie_element.length;
165+
}
166+
167+
length -= ie_element.length + 2;
168+
169+
payload_ptr += ie_element.length + 2;
170+
}
171+
return 0;
172+
}
173+
147174
uint8_t mac_ie_header_discover(uint8_t *header_ptr, uint16_t length, mac_header_IE_t *header_ie)
148175
{
149176
mac_header_IE_t ie_element;

source/6LoWPAN/MAC/mac_ie_lib.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ uint16_t mac_ie_payload_discover(uint8_t *payload_ptr, uint16_t length, struct m
4949
/** Nested IE element discover inside parsed payload element */
5050
uint16_t mac_ie_nested_discover(uint8_t *payload_ptr, uint16_t length, mac_nested_payload_IE_t *nested_ie);
5151

52+
/** Nested IE element discover with Sub Tag ID inside parsed payload element */
53+
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);
54+
5255
/** Header IE elemnt discover */
5356
uint8_t mac_ie_header_discover(uint8_t *header_ptr, uint16_t length, struct mac_header_IE_s *header_ie);
5457

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 202 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,40 @@
2828
#define WH_IE_MHDS_TYPE 5 /**< MHDS information for mesh routing */
2929
#define WH_IE_VH_TYPE 6 /**< Vendor header information */
3030
#define WH_IE_EA_TYPE 9 /**< Eapol Auhtenticator EUI-64 header information */
31+
/* Wi-SUN FAN dfinition 1.1 */
32+
#define WH_IE_LUTT_TYPE 10 /**< LFN Unicast Timing and Frame Type information */
33+
#define WH_IE_LBT_TYPE 11 /**< LFN Broadcast Timing information */
34+
#define WH_IE_NR_TYPE 12 /**< Node Role IE information */
35+
#define WH_IE_LUS_TYPE 13 /**< LFN Unicast Schedule information */
36+
#define WH_IE_FLUS_TYPE 14 /**< FFN for LFN unicast Schedule information */
37+
#define WH_IE_LBS_TYPE 15 /**< LFN Broadcast Schedule information */
38+
#define WH_IE_LND_TYPE 16 /**< LFN Network Discovery information */
39+
#define WH_IE_LTO_TYPE 17 /**< LFN Timing information */
40+
#define WH_IE_PANID_TYPE 18 /**< PAN Identifier information */
41+
3142

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

3445
#define WS_WP_SUB_IE_ELEMENT_HEADER_LENGTH 2
3546

3647
/* Payload IE sub elements in side WS_WP_NESTED_IE */
37-
#define WP_PAYLOAD_IE_US_TYPE 1 /**< Unicast Schedule information */
38-
#define WP_PAYLOAD_IE_BS_TYPE 2 /**< Broadcast Schedule information */
39-
#define WP_PAYLOAD_IE_VP_TYPE 3 /**< Vendor Payload information */
48+
/* Long form subID's */
49+
#define WP_PAYLOAD_IE_US_TYPE 1 /**< Unicast Schedule information */
50+
#define WP_PAYLOAD_IE_BS_TYPE 2 /**< Broadcast Schedule information */
51+
#define WP_PAYLOAD_IE_VP_TYPE 3 /**< Vendor Payload information */
52+
/* Wi-SUN FAN definition 1.1 */
53+
#define WP_PAYLOAD_IE_LFN_CHANNEL_PLAN_TYPE 4 /**< LFN Channel Plan information*/
54+
55+
/* Short form subID's */
4056
#define WP_PAYLOAD_IE_PAN_TYPE 4 /**< PAN Information */
4157
#define WP_PAYLOAD_IE_NETNAME_TYPE 5 /**< Network Name information */
4258
#define WP_PAYLOAD_IE_PAN_VER_TYPE 6 /**< Pan configuration version */
4359
#define WP_PAYLOAD_IE_GTKHASH_TYPE 7 /**< GTK Hash information */
60+
/* Wi-SUN FAN dfinition 1.1 */
61+
#define WP_PAYLOAD_IE_PCAP_TYPE 8 /**< PHY Capability information */
62+
#define WP_PAYLOAD_IE_LFNVER_TYPE 9 /**< LFN Version information */
63+
#define WP_PAYLOAD_IE_LGTKHASH_TYPE 10 /**< LFN GTK Hash Information */
64+
4465

4566
/* WS frame types to WH_IE_UTT_TYPE */
4667
#define WS_FT_PAN_ADVERT 0 /**< PAN Advert */
@@ -50,14 +71,25 @@
5071
#define WS_FT_DATA 4 /**< data type inside MPX */
5172
#define WS_FT_ACK 5 /**< Enhanced ACK */
5273
#define WS_FT_EAPOL 6 /**< EAPOL message inside MPX */
74+
/* Wi-SUN FAN 1.1 */
75+
#define WS_FT_LPA 9 /**< LFN PAN Advert */
76+
#define WS_FT_LPAS 10 /**< LFN PAN Advert Solicit */
77+
#define WS_FT_LPC 11 /**< LFN PAN Config */
78+
#define WS_FT_LPCS 12 /**< LFN PAN Config Solicit */
79+
5380

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

5986
#define WS_EXCLUDED_MAX_RANGE_TO_SEND 3
6087

88+
89+
#define WS_NR_ROLE_BR 0
90+
#define WS_NR_ROLE_ROUTER 1
91+
#define WS_NR_ROLE_LFN 2
92+
6193
/**
6294
* @brief ws_pan_information_t PAN information
6395
*/
@@ -68,6 +100,7 @@ typedef struct ws_pan_information_s {
68100
bool use_parent_bs: 1; /**< 1 for force to follow parent broadcast schedule. 0 node may define own schedule. */
69101
bool rpl_routing_method: 1; /**< 1 when RPL routing is selected and 0 when L2 routing. */
70102
bool pan_version_set: 1; /**< 1 PAN version is set. */
103+
bool lfn_window_style: 1; /**< 1 FFN management trasmission. */
71104
unsigned version: 3; /**< Pan version support. */
72105
} ws_pan_information_t;
73106

@@ -125,6 +158,104 @@ typedef struct ws_utt_ie {
125158
uint_fast24_t ufsi;
126159
} ws_utt_ie_t;
127160

161+
/**
162+
* @brief ws_utt_ie_t WS LUTT-IE
163+
*/
164+
typedef struct ws_lutt_ie {
165+
uint8_t message_type;
166+
uint16_t slot_number;
167+
uint_fast24_t interval_offset;
168+
} ws_lutt_ie_t;
169+
170+
/**
171+
* @brief ws_lbt_ie_t WS LBT-IE
172+
*/
173+
typedef struct ws_lbt_ie {
174+
uint16_t slot_number;
175+
uint_fast24_t interval_offset;
176+
} ws_lbt_ie_t;
177+
178+
179+
/**
180+
* @brief ws_nr_ie_t WS NR-IE
181+
*/
182+
typedef struct ws_nr_ie {
183+
unsigned node_role: 3;
184+
uint8_t clock_drift;
185+
uint8_t timing_accurancy;
186+
uint_fast24_t listen_interval_min;
187+
uint_fast24_t listen_interval_max;
188+
} ws_nr_ie_t;
189+
190+
191+
/**
192+
* @brief ws_lus_ie_t WS LUS-IE
193+
*/
194+
typedef struct ws_lus_ie {
195+
uint8_t channel_plan_tag;
196+
uint_fast24_t listen_interval;
197+
} ws_lus_ie_t;
198+
199+
/**
200+
* @brief ws_lus_ie_t WS FLUS-IE
201+
*/
202+
typedef struct ws_flus_ie {
203+
uint8_t channel_plan_tag;
204+
uint8_t dwell_interval;
205+
} ws_flus_ie_t;
206+
207+
/**
208+
* @brief ws_lnd_ie_t WS LND-IE
209+
*/
210+
typedef struct ws_lnd_ie {
211+
uint8_t response_threshold;
212+
uint8_t discovery_slot_time;
213+
uint8_t discovery_slots;
214+
uint16_t discovery_first_slot;
215+
uint_fast24_t response_delay;
216+
} ws_lnd_ie_t;
217+
218+
/**
219+
* @brief ws_lto_ie_t WS LTO-IE
220+
*/
221+
typedef struct ws_lto_ie {
222+
uint_fast24_t offset;
223+
uint_fast24_t adjusted_listening_interval;
224+
} ws_lto_ie_t;
225+
226+
/**
227+
* @brief ws_lbs_ie_t WS LBS-IE
228+
*/
229+
typedef struct ws_lbs_ie {
230+
uint8_t channel_plan_tag;
231+
uint16_t broadcast_secheduler_id;
232+
uint_fast24_t broadcast_interval;
233+
} ws_lbs_ie_t;
234+
235+
236+
/**
237+
* @brief ws_panid_ie_t WS PANID-IE
238+
*/
239+
typedef struct ws_panid_ie {
240+
uint16_t panid;
241+
} ws_panid_ie_t;
242+
243+
/**
244+
* @brief ws_pcab_ie_t WS PCAB-IE
245+
*/
246+
typedef struct ws_pcab_ie {
247+
unsigned phy_type: 3;
248+
uint16_t operation_mode;
249+
} ws_pcab_ie_t;
250+
251+
/**
252+
* @brief ws_pcab_read_ie_t WS PCAB-IE
253+
*/
254+
typedef struct ws_pcab_read_ie {
255+
unsigned length_of_pcab: 3;
256+
uint8_t *pcab_start;
257+
} ws_pcab_read_ie_t;
258+
128259
/**
129260
* @brief ws_bt_ie_t WS BT-IE read
130261
*/
@@ -141,6 +272,26 @@ typedef struct ws_fc_ie {
141272
uint8_t rx_flow_ctrl;
142273
} ws_fc_ie_t;
143274

275+
/**
276+
* @brief ws_lfnver_ie_t WS LFNVER-IE element
277+
*/
278+
typedef struct ws_lfnver_ie {
279+
uint16_t lfn_version;
280+
} ws_lfnver_ie_t;
281+
282+
/**
283+
* @brief ws_lgtkhash_ie_t WS LGTKHASH-IE element
284+
*/
285+
typedef struct ws_lgtkhash_ie {
286+
bool lgtk0: 1; /**< 1= LGTK0 in line 0 = elided */
287+
bool lgtk1: 1; /**< 1= LGTK1 in line 0 = elided */
288+
bool lgtk2: 1; /**< 1= LGTK2 in line 0 = elided */
289+
unsigned active_lgtk_index: 2; /**< Indicate Active LGTK index 0-2 */
290+
uint8_t *lgtk0_hash; /**< LGTK0 64-bit Hash if lgtk0=1*/
291+
uint8_t *lgtk1_hash; /**< LGTK1 64-bit Hash if lgtk1=1*/
292+
uint8_t *lgtk2_hash; /**< LGTK2 64-bit Hash if lgtk2=1*/
293+
} ws_lgtkhash_ie_t;
294+
144295
/**
145296
* @brief ws_channel_plan_zero_t WS channel plan 0 define domain and class
146297
*/
@@ -158,6 +309,14 @@ typedef struct ws_channel_plan_one {
158309
uint16_t number_of_channel;
159310
} ws_channel_plan_one_t;
160311

312+
/**
313+
* @brief ws_channel_plan_two_t WS channel plan 2 define regulator domain and chanel plan 1
314+
*/
315+
typedef struct ws_channel_plan_two {
316+
uint8_t regulator_domain;
317+
uint8_t channel_plan_id;
318+
} ws_channel_plan_two_t;
319+
161320
/**
162321
* @brief ws_channel_function_zero_t WS function 0 fixed channel
163322
*/
@@ -189,6 +348,43 @@ typedef struct ws_excluded_channel_mask {
189348
uint8_t mask_len_inline;
190349
} ws_excluded_channel_mask_t;
191350

351+
352+
typedef struct ws_excluded_channel_range_out {
353+
unsigned excluded_range_length: 3;
354+
ws_excluded_channel_range_data_t *exluded_range;
355+
} ws_excluded_channel_range_out_t;
356+
357+
358+
typedef struct ws_excluded_channel_mask_out {
359+
uint16_t excluded_channel_count;
360+
uint8_t channel_mask_bytes_inline;
361+
uint32_t *channel_mask;
362+
} ws_excluded_channel_mask_out_t;
363+
364+
/**
365+
* @brief ws_generic_channel_info_t Generic Channel Info
366+
*/
367+
typedef struct ws_generic_channel_info {
368+
unsigned channel_plan: 3;
369+
unsigned channel_function: 3;
370+
unsigned excluded_channel_ctrl: 2;
371+
union {
372+
ws_channel_plan_zero_t zero;
373+
ws_channel_plan_one_t one;
374+
ws_channel_plan_two_t two;
375+
} plan;
376+
union {
377+
ws_channel_function_zero_t zero;
378+
ws_channel_function_three_t three;
379+
} function;
380+
union {
381+
ws_excluded_channel_range_out_t range;
382+
ws_excluded_channel_mask_out_t mask;
383+
ws_excluded_channel_range_t range_in;
384+
ws_excluded_channel_mask_t mask_in;
385+
} excluded_channels;
386+
} ws_generic_channel_info_t;
387+
192388
/**
193389
* @brief ws_us_ie_t WS US-IE read
194390
*/
@@ -202,6 +398,7 @@ typedef struct ws_us_ie {
202398
union {
203399
ws_channel_plan_zero_t zero;
204400
ws_channel_plan_one_t one;
401+
ws_channel_plan_two_t two;
205402
} plan;
206403
union {
207404
ws_channel_function_zero_t zero;
@@ -228,6 +425,7 @@ typedef struct ws_bs_ie {
228425
union {
229426
ws_channel_plan_zero_t zero;
230427
ws_channel_plan_one_t one;
428+
ws_channel_plan_two_t two;
231429
} plan;
232430
union {
233431
ws_channel_function_zero_t zero;

0 commit comments

Comments
 (0)