Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-wisun.c
bloba028cc1cf3a05c4de50420f38b1cc358b0181df8
1 /* packet-wisun.c
3 * Wi-SUN IE Dissectors for Wireshark
4 * By Owen Kirby <osk@exegin.com>
5 * Copyright 2007 Exegin Technologies Limited
6 * Copyright 2022-2023 Silicon Laboratories Inc.
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 *------------------------------------------------------------
11 #include "config.h"
12 #include <epan/packet.h>
13 #include <epan/expert.h>
14 #include <epan/proto_data.h>
15 #include <wsutil/pint.h>
16 #include <epan/reassemble.h>
17 #include <epan/oids.h>
18 #include <epan/oui.h>
19 #include <epan/tfs.h>
20 #include <epan/unit_strings.h>
22 #include <wsutil/array.h>
23 #include "packet-ieee802154.h"
25 void proto_register_wisun(void);
26 void proto_reg_handoff_wisun(void);
28 /* EDFE support */
29 typedef struct {
30 ieee802154_map_rec initiator;
31 ieee802154_map_rec target;
32 } edfe_exchange_t;
34 // for each exchange, maps both source address and destination address to a
35 // (distinct) tree that uses the frame number of the first exchange frame to
36 // map to the shared edfe_exchange_t
37 static wmem_map_t* edfe_byaddr;
39 static dissector_handle_t eapol_handle; // for the eapol relay
41 static dissector_handle_t ieee802154_nofcs_handle; // for Netricity Segment Control
43 static dissector_table_t vhie_dissector_table;
44 static dissector_table_t vpie_dissector_table;
46 static reassembly_table netricity_reassembly_table;
49 /* Wi-SUN Header IE Sub-ID Values. */
50 #define WISUN_SUBID_UTT 0x01
51 #define WISUN_SUBID_BT 0x02
52 #define WISUN_SUBID_FC 0x03
53 #define WISUN_SUBID_RSL 0x04
54 #define WISUN_SUBID_MHDS 0x05
55 #define WISUN_SUBID_VH 0x06
56 #define WISUN_SUBID_N_NFT 0x07
57 #define WISUN_SUBID_N_LQI 0x08
58 #define WISUN_SUBID_EA 0x09
60 /* Wi-SUN Header IE Sub-ID Values for FAN 1.1 */
61 #define WISUN_SUBID_LUTT 0x0A
62 #define WISUN_SUBID_LBT 0x0B
63 #define WISUN_SUBID_NR 0x0C
64 #define WISUN_SUBID_LUS 0x0D
65 #define WISUN_SUBID_FLUS 0x0E
66 #define WISUN_SUBID_LBS 0x0F
67 #define WISUN_SUBID_LND 0x10
68 #define WISUN_SUBID_LTO 0x11
69 #define WISUN_SUBID_PANID 0x12
70 #define WISUN_SUBID_RT 0x1D
71 #define WISUN_SUBID_LBC 0xC0
73 /* Wi-SUN Payload/Nested ID values. */
74 #define WISUN_PIE_SUBID_US 0x01
75 #define WISUN_PIE_SUBID_BS 0x02
76 #define WISUN_PIE_SUBID_VP 0x03
77 #define WISUN_PIE_SUBID_PAN 0x04
78 #define WISUN_PIE_SUBID_NETNAME 0x05
79 #define WISUN_PIE_SUBID_PANVER 0x06
80 #define WISUN_PIE_SUBID_GTKHASH 0x07
82 /* Wi-SUN Payload IE Sub-ID Values for FAN 1.1 */
83 #define WISUN_PIE_SUBID_POM 0x08
84 #define WISUN_PIE_SUBID_LCP 0x04
85 #define WISUN_PIE_SUBID_LFNVER 0x40
86 #define WISUN_PIE_SUBID_LGTKHASH 0x41
87 #define WISUN_PIE_SUBID_LBATS 0x09
88 #define WISUN_PIE_SUBID_JM 0x0a
90 #define WISUN_LGTKHASH_LGTK0_INCLUDED_MASK 0x01
91 #define WISUN_LGTKHASH_LGTK1_INCLUDED_MASK 0x02
92 #define WISUN_LGTKHASH_LGTK2_INCLUDED_MASK 0x04
94 #define WISUN_CHANNEL_PLAN 0x07
95 #define WISUN_CHANNEL_FUNCTION 0x38
96 #define WISUN_CHANNEL_EXCLUDE 0xc0
98 #define WISUN_CHANNEL_PLAN_REGULATORY 0
99 #define WISUN_CHANNEL_PLAN_EXPLICIT 1
100 #define WISUN_CHANNEL_PLAN_REGULATORY_ID 2
101 #define WISUN_CHANNEL_FUNCTION_FIXED 0
102 #define WISUN_CHANNEL_FUNCTION_TR51CF 1
103 #define WISUN_CHANNEL_FUNCTION_DH1CF 2
104 #define WISUN_CHANNEL_FUNCTION_VENDOR 3
105 #define WISUN_CHANNEL_EXCLUDE_NONE 0
106 #define WISUN_CHANNEL_EXCLUDE_RANGE 1
107 #define WISUN_CHANNEL_EXCLUDE_MASK 2
109 #define WISUN_CH_PLAN_EXPLICIT_FREQ 0x00ffffff
110 #define WISUN_CH_PLAN_EXPLICIT_RESERVED 0xf0000000
111 #define WISUN_CH_PLAN_EXPLICIT_SPACING 0x0f000000
113 #define WISUN_EAPOL_RELAY_UDP_PORT 10253
115 #define WISUN_WSIE_NODE_ROLE_ID_FFN_BR 0x00
116 #define WISUN_WSIE_NODE_ROLE_ID_FFN 0x01
117 #define WISUN_WSIE_NODE_ROLE_ID_LFN 0x02
118 #define WISUN_WSIE_NODE_ROLE_ID_MASK 0x07
119 #define WISUN_WSIE_NODE_ROLE_ID_RESERVED 0x78
120 #define WISUN_WSIE_NODE_ROLE_LBATS_IMPLEMENTED 0x80
122 #define WISUN_PIE_PHY_OPERATING_MODES_MASK 0x0F
123 #define WISUN_PIE_PHY_TYPE 0xF0
125 #define WISUN_PIE_JM_ID_PLF 1
126 #define WISUN_PIE_JM_ID_MASK 0x3f
127 #define WISUN_PIE_JM_LEN_MASK 0xc0
129 #define WISUN_CMD_MDR 0x03
131 static int proto_wisun;
132 static int hf_wisun_subid;
133 static int hf_wisun_unknown_ie;
134 static int hf_wisun_uttie;
135 static int hf_wisun_uttie_type;
136 static int hf_wisun_uttie_ufsi;
137 static int hf_wisun_btie;
138 static int hf_wisun_btie_slot;
139 static int hf_wisun_btie_bio;
140 static int hf_wisun_fcie;
141 static int hf_wisun_fcie_tx;
142 static int hf_wisun_fcie_rx;
143 static int hf_wisun_fcie_src;
144 static int hf_wisun_fcie_initial_frame;
145 static int hf_wisun_rslie;
146 static int hf_wisun_rslie_rsl;
147 static int hf_wisun_vhie;
148 static int hf_wisun_vhie_vid;
149 static int hf_wisun_eaie;
150 static int hf_wisun_eaie_eui;
152 // LFN (FAN 1.1)
153 static int hf_wisun_luttie;
154 static int hf_wisun_luttie_usn;
155 static int hf_wisun_luttie_uio;
156 static int hf_wisun_lbtie;
157 static int hf_wisun_lbtie_slot;
158 static int hf_wisun_lbtie_bio;
159 static int hf_wisun_nrie;
160 static int hf_wisun_nrie_nr_id;
161 static int hf_wisun_nrie_reserved_bits;
162 static int hf_wisun_nrie_lbats;
163 static int hf_wisun_nrie_timing_accuracy;
164 static int hf_wisun_nrie_listening_interval_min;
165 static int hf_wisun_nrie_listening_interval_max;
166 static int hf_wisun_lusie;
167 static int hf_wisun_lusie_listen_interval;
168 static int hf_wisun_lusie_channel_plan_tag;
169 static int hf_wisun_flusie;
170 static int hf_wisun_flusie_dwell_interval;
171 static int hf_wisun_flusie_channel_plan_tag;
172 static int hf_wisun_lbsie;
173 static int hf_wisun_lbsie_broadcast_interval;
174 static int hf_wisun_lbsie_broadcast_id;
175 static int hf_wisun_lbsie_channel_plan_tag;
176 static int hf_wisun_lbsie_broadcast_sync_period;
177 static int hf_wisun_lndie;
178 static int hf_wisun_lndie_response_threshold;
179 static int hf_wisun_lndie_response_delay;
180 static int hf_wisun_lndie_discovery_slot_time;
181 static int hf_wisun_lndie_discovery_slots;
182 static int hf_wisun_lndie_discovery_first_slot;
183 static int hf_wisun_ltoie;
184 static int hf_wisun_ltoie_offset;
185 static int hf_wisun_ltoie_listening_interval;
186 static int hf_wisun_panidie;
187 static int hf_wisun_panidie_panid;
188 static int hf_wisun_rtie;
189 static int hf_wisun_rtie_rendezvous_time;
190 static int hf_wisun_rtie_wakeup_interval;
191 static int hf_wisun_lbcie;
192 static int hf_wisun_lbcie_broadcast_interval;
193 static int hf_wisun_lbcie_broadcast_sync_period;
195 static int hf_wisun_pie;
196 static int hf_wisun_wsie;
197 static int hf_wisun_wsie_type;
198 static int hf_wisun_wsie_id;
199 static int hf_wisun_wsie_length;
200 static int hf_wisun_wsie_id_short;
201 static int hf_wisun_wsie_length_short;
202 static int hf_wisun_usie;
203 static int hf_wisun_usie_dwell_interval;
204 static int hf_wisun_usie_clock_drift;
205 static int hf_wisun_usie_timing_accuracy;
206 static int hf_wisun_usie_channel_control;
207 static int hf_wisun_usie_channel_plan;
208 static int hf_wisun_usie_channel_function;
209 static int hf_wisun_usie_channel_exclude;
210 static int hf_wisun_usie_regulatory_domain;
211 static int hf_wisun_usie_operating_class;
212 static int hf_wisun_usie_channel_plan_id;
213 static int hf_wisun_usie_explicit;
214 static int hf_wisun_usie_explicit_frequency;
215 static int hf_wisun_usie_explicit_reserved;
216 static int hf_wisun_usie_explicit_spacing;
217 static int hf_wisun_usie_number_channels;
218 static int hf_wisun_usie_fixed_channel;
219 static int hf_wisun_usie_hop_count;
220 static int hf_wisun_usie_hop_list;
221 static int hf_wisun_usie_number_ranges;
222 static int hf_wisun_usie_exclude_range_start;
223 static int hf_wisun_usie_exclude_range_end;
224 static int hf_wisun_usie_exclude_mask;
225 static int hf_wisun_bsie;
226 static int hf_wisun_bsie_bcast_interval;
227 static int hf_wisun_bsie_bcast_schedule_id;
228 static int hf_wisun_vpie;
229 static int hf_wisun_vpie_vid;
230 static int hf_wisun_lcpie;
231 static int hf_wisun_panie;
232 static int hf_wisun_panie_size;
233 static int hf_wisun_panie_cost;
234 static int hf_wisun_panie_flags;
235 static int hf_wisun_panie_flag_parent_bsie;
236 static int hf_wisun_panie_flag_routing_method;
237 static int hf_wisun_panie_flag_lfn_window_style;
238 static int hf_wisun_panie_flag_version;
239 static int hf_wisun_netnameie;
240 static int hf_wisun_netnameie_name;
241 static int hf_wisun_panverie;
242 static int hf_wisun_panverie_version;
243 static int hf_wisun_gtkhashie;
244 static int hf_wisun_gtkhashie_gtk0;
245 static int hf_wisun_gtkhashie_gtk1;
246 static int hf_wisun_gtkhashie_gtk2;
247 static int hf_wisun_gtkhashie_gtk3;
248 static int hf_wisun_pomie;
249 static int hf_wisun_pomie_hdr;
250 static int hf_wisun_pomie_number_operating_modes;
251 static int hf_wisun_pomie_mdr_command_capable_flag;
252 static int hf_wisun_pomie_reserved;
253 static int hf_wisun_pomie_phy_mode_id;
254 static int hf_wisun_pomie_phy_type;
255 static int hf_wisun_pomie_phy_mode_fsk;
256 static int hf_wisun_pomie_phy_mode_ofdm;
257 static int hf_wisun_lfnverie;
258 static int hf_wisun_lfnverie_version;
259 static int hf_wisun_lgtkhashie;
260 static int hf_wisun_lgtkhashie_flags;
261 static int hf_wisun_lgtkhashie_flag_includes_lgtk0;
262 static int hf_wisun_lgtkhashie_flag_includes_lgtk1;
263 static int hf_wisun_lgtkhashie_flag_includes_lgtk2;
264 static int hf_wisun_lgtkhashie_flag_active_lgtk_index;
265 static int hf_wisun_lgtkhashie_gtk0;
266 static int hf_wisun_lgtkhashie_gtk1;
267 static int hf_wisun_lgtkhashie_gtk2;
268 static int hf_wisun_lbatsie;
269 static int hf_wisun_lbatsie_additional_tx;
270 static int hf_wisun_lbatsie_next_tx_delay;
271 static int hf_wisun_jmie;
272 static int hf_wisun_jmie_version;
273 static int hf_wisun_jmie_metric_hdr;
274 static int hf_wisun_jmie_metric_id;
275 static int hf_wisun_jmie_metric_len;
276 static int hf_wisun_jmie_metric_plf;
277 static int hf_wisun_jmie_metric_plf_data;
278 static int hf_wisun_jmie_metric_unknown;
280 static int proto_wisun_sec;
281 static int hf_wisun_sec_function;
282 static int hf_wisun_sec_error_type;
283 static int hf_wisun_sec_error_nonce;
285 // EAPOL Relay
286 static dissector_handle_t wisun_eapol_relay_handle;
287 static int proto_wisun_eapol_relay;
288 static int hf_wisun_eapol_relay_sup;
289 static int hf_wisun_eapol_relay_kmp_id;
290 static int hf_wisun_eapol_relay_direction;
292 static int hf_wisun_cmd_subid;
293 static int hf_wisun_cmd_mdr_phy_mode_id;
294 static int hf_wisun_cmd_mdr_phy_type;
295 static int hf_wisun_cmd_mdr_phy_mode_fsk;
296 static int hf_wisun_cmd_mdr_phy_mode_ofdm;
298 // Netricity
299 static int proto_wisun_netricity_sc;
300 static int hf_wisun_netricity_nftie;
301 static int hf_wisun_netricity_nftie_type;
302 static int hf_wisun_netricity_lqiie;
303 static int hf_wisun_netricity_lqiie_lqi;
304 static int hf_wisun_netricity_sc_flags;
305 static int hf_wisun_netricity_sc_reserved;
306 static int hf_wisun_netricity_sc_tone_map_request;
307 static int hf_wisun_netricity_sc_contention_control;
308 static int hf_wisun_netricity_sc_channel_access_priority;
309 static int hf_wisun_netricity_sc_last_segment;
310 static int hf_wisun_netricity_sc_segment_count;
311 static int hf_wisun_netricity_sc_segment_length;
312 // Reassembly
313 static int hf_wisun_netricity_scr_segments;
314 static int hf_wisun_netricity_scr_segment;
315 static int hf_wisun_netricity_scr_segment_overlap;
316 static int hf_wisun_netricity_scr_segment_overlap_conflicts;
317 static int hf_wisun_netricity_scr_segment_multiple_tails;
318 static int hf_wisun_netricity_scr_segment_too_long_segment;
319 static int hf_wisun_netricity_scr_segment_error;
320 static int hf_wisun_netricity_scr_segment_count;
321 static int hf_wisun_netricity_scr_reassembled_in;
322 static int hf_wisun_netricity_scr_reassembled_length;
324 static int ett_wisun_phy_mode_id;
325 static int ett_wisun_unknown_ie;
326 static int ett_wisun_uttie;
327 static int ett_wisun_btie;
328 static int ett_wisun_fcie;
329 static int ett_wisun_rslie;
330 static int ett_wisun_vhie;
331 static int ett_wisun_eaie;
332 static int ett_wisun_pie;
333 static int ett_wisun_wsie_bitmap;
334 static int ett_wisun_usie;
335 static int ett_wisun_bsie;
336 static int ett_wisun_vpie;
337 static int ett_wisun_lcpie;
338 static int ett_wisun_usie_channel_control;
339 static int ett_wisun_usie_explicit;
340 static int ett_wisun_luttie;
341 static int ett_wisun_nrie;
342 static int ett_wisun_lusie;
343 static int ett_wisun_flusie;
344 static int ett_wisun_lbsie;
345 static int ett_wisun_lndie;
346 static int ett_wisun_ltoie;
347 static int ett_wisun_panidie;
348 static int ett_wisun_rtie;
349 static int ett_wisun_lbcie;
350 static int ett_wisun_panie;
351 static int ett_wisun_panie_flags;
352 static int ett_wisun_netnameie;
353 static int ett_wisun_panverie;
354 static int ett_wisun_gtkhashie;
355 static int ett_wisun_pomie;
356 static int ett_wisun_pomie_hdr;
357 static int ett_wisun_lfnverie;
358 static int ett_wisun_lgtkhashie;
359 static int ett_wisun_lgtkhashie_flags;
360 static int ett_wisun_lbatsie;
361 static int ett_wisun_jmie;
362 static int ett_wisun_jmie_metric_hdr;
363 static int ett_wisun_jmie_metric_plf;
364 static int ett_wisun_jmie_metric_unknown;
365 static int ett_wisun_sec;
366 static int ett_wisun_eapol_relay;
367 // Netricity
368 static int ett_wisun_netricity_nftie;
369 static int ett_wisun_netricity_lqiie;
370 static int ett_wisun_netricity_sc;
371 static int ett_wisun_netricity_sc_bitmask;
372 static int ett_wisun_netricity_scr_segment;
373 static int ett_wisun_netricity_scr_segments;
375 static const fragment_items netricity_scr_frag_items = {
376 /* Fragment subtrees */
377 &ett_wisun_netricity_scr_segment,
378 &ett_wisun_netricity_scr_segments,
380 /* Fragment fields */
381 &hf_wisun_netricity_scr_segments,
382 &hf_wisun_netricity_scr_segment,
383 &hf_wisun_netricity_scr_segment_overlap,
384 &hf_wisun_netricity_scr_segment_overlap_conflicts,
385 &hf_wisun_netricity_scr_segment_multiple_tails,
386 &hf_wisun_netricity_scr_segment_too_long_segment,
387 &hf_wisun_netricity_scr_segment_error,
388 &hf_wisun_netricity_scr_segment_count,
390 /* Reassembled in field */
391 &hf_wisun_netricity_scr_reassembled_in,
393 /* Reassembled length field */
394 &hf_wisun_netricity_scr_reassembled_length,
395 /* Reassembled data field */
396 NULL,
398 /* Tag */
399 "Netricity Segments"
402 static const value_string wisun_wsie_types[] = {
403 { 0, "Short" },
404 { 1, "Long" },
405 { 0, NULL }
408 static const value_string wisun_subid_vals[] = {
409 { WISUN_SUBID_UTT, "Unicast Timing IE" },
410 { WISUN_SUBID_BT, "Broadcast Timing IE" },
411 { WISUN_SUBID_FC, "Flow Control IE" },
412 { WISUN_SUBID_RSL, "Received Signal Level IE" },
413 { WISUN_SUBID_MHDS, "Multi-Hop Delivery Service IE" },
414 { WISUN_SUBID_VH, "Vendor Header IE" },
415 { WISUN_SUBID_N_NFT, "Netricity Frame Type IE" },
416 { WISUN_SUBID_N_LQI, "Link Quality Index IE" },
417 { WISUN_SUBID_EA, "EAPOL Authenticator EUI-64 IE" },
418 { WISUN_SUBID_LUTT, "LFN Unicast Timing and Frame Type IE" },
419 { WISUN_SUBID_LBT, "LFN Broadcast Timing IE" },
420 { WISUN_SUBID_NR, "Node Role IE" },
421 { WISUN_SUBID_LUS, "LFN Unicast Schedule IE" },
422 { WISUN_SUBID_FLUS, "FFN for LFN Unicast Schedule IE" },
423 { WISUN_SUBID_LBS, "LFN Broadcast Schedule IE" },
424 { WISUN_SUBID_LND, "LFN Network Discovery IE" },
425 { WISUN_SUBID_LTO, "LFN Timing Offset IE" },
426 { WISUN_SUBID_PANID, "PAN Identifier IE" },
427 { WISUN_SUBID_RT, "Rendezvous Time IE" },
428 { WISUN_SUBID_LBC, "LFN Broadcast Configuration IE" },
429 { 0, NULL }
432 static const value_string wisun_wsie_names[] = {
433 { WISUN_PIE_SUBID_US, "Unicast Schedule IE" },
434 { WISUN_PIE_SUBID_BS, "Broadcast Schedule IE" },
435 { WISUN_PIE_SUBID_VP, "Vendor Payload IE" },
436 { WISUN_PIE_SUBID_LCP, "LFN Channel Plan IE" },
437 { 0, NULL }
440 static const value_string wisun_wsie_names_short[] = {
441 { WISUN_PIE_SUBID_PAN, "PAN Information IE" },
442 { WISUN_PIE_SUBID_NETNAME, "Network Name IE" },
443 { WISUN_PIE_SUBID_PANVER, "PAN Version IE" },
444 { WISUN_PIE_SUBID_GTKHASH, "GTK Hash IE" },
445 { WISUN_PIE_SUBID_POM, "PHY Operating Modes IE" },
446 { WISUN_PIE_SUBID_LFNVER, "LFN Version IE" },
447 { WISUN_PIE_SUBID_LGTKHASH, "LFN GTK Hash IE" },
448 { WISUN_PIE_SUBID_LBATS, "LFN Broadcast Additional Transmit Schedule IE" },
449 { WISUN_PIE_SUBID_JM, "Join Metrics IE" },
450 { 0, NULL }
453 static const value_string wisun_frame_type_vals[] = {
454 { 0, "PAN Advertisement" },
455 { 1, "PAN Advertisement Solicit" },
456 { 2, "PAN Configuration" },
457 { 3, "PAN Configuration Solicit" },
458 { 4, "Data" },
459 { 5, "Acknowledgment" },
460 { 6, "EAPOL" },
461 { 7, "Reserved" },
462 { 8, "Reserved" },
463 { 9, "LFN PAN Advertisement" },
464 { 10, "LFN PAN Advertisement Solicit" },
465 { 11, "LFN PAN Configuration" },
466 { 12, "LFN PAN Configuration Solicit" },
467 { 13, "LFN Time Synchronization" },
468 { 14, "Reserved" },
469 { 15, "Reserved (Extended Type)" },
470 { 0, NULL }
473 static const value_string wisun_usie_clock_drift_names[] = {
474 { 0, "Better than 1ppm" },
475 { 255, "Not provided" },
476 { 0, NULL }
479 static const value_string wisun_channel_plan_names[] = {
480 { WISUN_CHANNEL_PLAN_REGULATORY, "Regulatory Domain and Operating Class" },
481 { WISUN_CHANNEL_PLAN_EXPLICIT, "Explicit Spacing and Number" },
482 { WISUN_CHANNEL_PLAN_REGULATORY_ID, "Regulatory Domain and Channel Plan ID" },
483 { 0, NULL }
486 static const range_string wisun_channel_plan_id_names[] = {
487 { 0, 0, "Reserved" },
488 { 1, 1, "902_928_200" },
489 { 2, 2, "902_928_400" },
490 { 3, 3, "902_928_600" },
491 { 4, 4, "902_928_800" },
492 { 5, 5, "902_928_1200" },
493 { 6, 20, "Reserved" },
494 { 21, 21, "920_928_200" },
495 { 22, 22, "920_928_400" },
496 { 23, 23, "920_928_600" },
497 { 24, 24, "920_928_800" },
498 { 25, 31, "Reserved" },
499 { 32, 32, "863_870_100" },
500 { 33, 33, "863_870_200" },
501 { 34, 34, "870_876_100" },
502 { 35, 35, "870_876_200" },
503 { 36, 36, "863_876_100" },
504 { 37, 37, "863_876_200" },
505 { 38, 63, "Reserved" },
506 { 0, 0, NULL }
509 static const value_string wisun_channel_function_names[] = {
510 { WISUN_CHANNEL_FUNCTION_FIXED, "Fixed Channel" },
511 { WISUN_CHANNEL_FUNCTION_TR51CF, "TR51 Channel Function" },
512 { WISUN_CHANNEL_FUNCTION_DH1CF, "Direct Hash Channel Function" },
513 { WISUN_CHANNEL_FUNCTION_VENDOR, "Vendor Defined Channel Function" },
514 { 0, NULL }
517 static const value_string wisun_channel_exclude_names[] = {
518 { WISUN_CHANNEL_EXCLUDE_NONE, "None" },
519 { WISUN_CHANNEL_EXCLUDE_RANGE, "Ranges" },
520 { WISUN_CHANNEL_EXCLUDE_MASK, "Bitmask" },
521 { 0, NULL }
524 static const value_string wisun_channel_regulatory_domains_names[] = {
525 { 0, "World" },
526 { 1, "North America" },
527 { 2, "Japan" },
528 { 3, "Europe" },
529 { 4, "China" },
530 { 5, "India" },
531 { 6, "Mexico" },
532 { 7, "Brazil" },
533 { 8, "Australia / NZ" },
534 { 9, "Korea" },
535 { 10, "Philippines" },
536 { 11, "Malaysia" },
537 { 12, "Hong Kong" },
538 { 13, "Singapore" },
539 { 14, "Thailand" },
540 { 15, "Vietnam" },
541 { 0, NULL }
544 static const value_string wisun_channel_spacing_names[] = {
545 { 0, "200 kHz" },
546 { 1, "400 kHz" },
547 { 2, "600 kHz" },
548 { 3, "100 kHz" },
549 { 4, "800 kHz" },
550 { 5, "1000 kHz" },
551 { 6, "1200 kHz" },
552 { 7, "2400 kHz" },
553 { 0, NULL }
556 static const value_string wisun_routing_methods[] = {
557 { 0, "MHDS" },
558 { 1, "RPL" },
559 { 0, NULL }
562 static const value_string wisun_window_style[] = {
563 { 0, "LFN Managed Transmission" },
564 { 1, "FFN Managed Transmission" },
565 { 0, NULL }
568 static const value_string wisun_metric_id[] = {
569 { WISUN_PIE_JM_ID_PLF, "PAN Load Factor" },
570 { 0, NULL }
573 static const value_string wisun_metric_len[] = {
574 { 0, "0" },
575 { 1, "1" },
576 { 2, "2" },
577 { 3, "4" },
578 { 0, NULL }
581 static const value_string wisun_sec_functions[] = {
582 { 0x01, "SM Error" },
583 { 0, NULL }
586 static const value_string wisun_sec_sm_errors[] = {
587 { 0x01, "No Session" },
588 { 0x02, "Unavailable Key" },
589 { 0x03, "Unsupported Security" },
590 { 0x04, "Invalid Parameter" },
591 { 0x06, "Unsupported Security" },
592 { 0, NULL }
595 static const value_string wisun_wsie_node_role_vals[] = {
596 { 0, "FFN Border Router" },
597 { 1, "FFN Router" },
598 { 2, "LFN" },
599 { 3, "Reserved" },
600 { 4, "Reserved" },
601 { 5, "Reserved" },
602 { 6, "Reserved" },
603 { 7, "Reserved" },
604 { 0, NULL }
607 static const value_string wisun_phy_type_vals[] = {
608 { 0, "FSK without FEC" },
609 { 1, "FSK with NRNSC FEC" },
610 { 2, "OFDM Option1" },
611 { 3, "OFDM Option2" },
612 { 4, "OFDM Option3" },
613 { 5, "OFDM Option4" },
614 { 0, NULL }
617 static const range_string wisun_phy_mode_fsk_vals[] = {
618 { 0, 0, "Reserved" },
619 { 1, 1, "FSK Mode 1a" },
620 { 2, 2, "FSK Mode 1b" },
621 { 3, 3, "FSK Mode 2a" },
622 { 4, 4, "FSK Mode 2b" },
623 { 5, 5, "FSK Mode 3" },
624 { 6, 6, "FSK Mode 4a" },
625 { 7, 7, "FSK Mode 4b" },
626 { 8, 8, "FSK Mode 5" },
627 { 9, 15, "Reserved" },
628 { 0, 0, NULL }
631 static const range_string wisun_phy_mode_ofdm_vals[] = {
632 { 0, 0, "MCS0" },
633 { 1, 1, "MCS1" },
634 { 2, 2, "MCS2" },
635 { 3, 3, "MCS3" },
636 { 4, 4, "MCS4" },
637 { 5, 5, "MCS5" },
638 { 6, 6, "MCS6" },
639 { 7, 15, "Reserved" },
640 { 0, 0, NULL }
643 static const value_string wisun_cmd_vals[] = {
644 { 3, "MDR Command" },
645 { 0, NULL }
648 static const true_false_string wisun_netricity_sc_contention_control_tfs = {
649 "Contention-free access",
650 "Contention allowed in next contention state"
653 static int * const wisun_format_nested_ie[] = {
654 &hf_wisun_wsie_type,
655 &hf_wisun_wsie_id,
656 &hf_wisun_wsie_length,
657 NULL
660 static int * const wisun_format_nested_ie_short[] = {
661 &hf_wisun_wsie_type,
662 &hf_wisun_wsie_id_short,
663 &hf_wisun_wsie_length_short,
664 NULL
667 static expert_field ei_wisun_subid_unsupported;
668 static expert_field ei_wisun_wsie_unsupported;
669 static expert_field ei_wisun_usie_channel_plan_invalid;
670 static expert_field ei_wisun_edfe_start_not_found;
671 static expert_field ei_wisun_usie_explicit_reserved_bits_not_zero;
672 static expert_field ei_wisun_nrie_reserved_bits_not_zero;
673 static expert_field ei_wisun_jmie_metric_unsupported;
675 static unsigned
676 wisun_add_wbxml_uint(tvbuff_t *tvb, proto_tree *tree, int hf, unsigned offset)
678 unsigned val = 0;
679 unsigned len = 0;
680 uint8_t b;
681 do {
682 b = tvb_get_uint8(tvb, offset + len++);
683 val = (val << 7) | (b & 0x7f);
684 } while (b & 0x80 && len < 2);
685 proto_tree_add_uint(tree, hf, tvb, offset, len, val);
686 return val;
689 static unsigned
690 wisun_vidlen(unsigned vid)
692 return vid > 0x7f ? 2 : 1;
695 static void
696 wisun_add_phy_mode_id(tvbuff_t *tvb, proto_tree *tree,
697 const unsigned offset, const int hf, int *const hf_type,
698 int *const hf_fsk, int *const hf_ofdm)
700 uint8_t phy_type = (tvb_get_uint8(tvb, offset) & WISUN_PIE_PHY_TYPE) >> 4;
701 int *const wisun_phy_mode_fsk_fields[] = {
702 hf_type,
703 hf_fsk,
704 NULL
706 int *const wisun_phy_mode_ofdm_fields[] = {
707 hf_type,
708 hf_ofdm,
709 NULL
712 if (phy_type < 2) {
713 // 0 and 1 are FSK modes
714 proto_tree_add_bitmask(tree, tvb, offset, hf, ett_wisun_phy_mode_id, wisun_phy_mode_fsk_fields, ENC_NA);
715 } else {
716 // The rest are OFDM modes
717 proto_tree_add_bitmask(tree, tvb, offset, hf, ett_wisun_phy_mode_id, wisun_phy_mode_ofdm_fields, ENC_NA);
722 /*-----------------------------------------------
723 * Wi-SUN Header IE Dissection
724 *---------------------------------------------*/
725 static proto_tree *
726 wisun_create_hie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, int ett)
728 proto_tree *subtree = ieee802154_create_hie_tree(tvb, tree, hf, ett);
729 proto_tree_add_item(subtree, hf_wisun_subid, tvb, 2, 1, ENC_LITTLE_ENDIAN);
730 return subtree;
733 static int
734 dissect_wisun_uttie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset)
736 uint8_t frame_type = tvb_get_uint8(tvb, offset);
737 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Wi-SUN");
738 col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(frame_type, wisun_frame_type_vals, "Unknown Wi-SUN Frame"));
739 proto_tree_add_item(tree, hf_wisun_uttie_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
740 proto_tree_add_item(tree, hf_wisun_uttie_ufsi, tvb, offset+1, 3, ENC_LITTLE_ENDIAN);
741 return 4;
744 static int
745 dissect_wisun_btie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
747 proto_tree_add_item(tree, hf_wisun_btie_slot, tvb, offset, 2, ENC_LITTLE_ENDIAN);
748 /* as of FAN TPS 1v14, this is 3 bytes instead of 4 */
749 proto_tree_add_item(tree, hf_wisun_btie_bio, tvb, offset+2, 3, ENC_LITTLE_ENDIAN);
750 return 5;
753 static void
754 edfe_insert_exchange(uint64_t* addr, edfe_exchange_t* exchange)
756 wmem_tree_t* byframe = (wmem_tree_t *)wmem_map_lookup(edfe_byaddr, addr);
757 if (!byframe) {
758 byframe = wmem_tree_new(wmem_file_scope());
759 wmem_map_insert(edfe_byaddr, addr, byframe);
761 wmem_tree_insert32(byframe, exchange->initiator.start_fnum, exchange);
764 static int
765 dissect_wisun_fcie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset, ieee802154_packet *packet)
767 uint32_t tx;
768 proto_tree_add_item_ret_uint(tree, hf_wisun_fcie_tx, tvb, offset, 1, ENC_LITTLE_ENDIAN, &tx);
769 uint32_t rx;
770 proto_tree_add_item_ret_uint(tree, hf_wisun_fcie_rx, tvb, offset+1, 1, ENC_LITTLE_ENDIAN, &rx);
772 // EDFE processing
773 ieee802154_hints_t* hints = (ieee802154_hints_t *)p_get_proto_data(wmem_file_scope(), pinfo,
774 proto_get_id_by_filter_name(IEEE802154_PROTOABBREV_WPAN), 0);
775 if (packet && hints && packet->dst_addr_mode == IEEE802154_FCF_ADDR_EXT) {
776 // first packet has source address
777 if (!hints->map_rec && packet->src_addr_mode == IEEE802154_FCF_ADDR_EXT) {
778 edfe_exchange_t* ex = wmem_new(wmem_file_scope(), edfe_exchange_t);
779 ex->initiator.proto = "Wi-SUN";
780 ex->target.proto = "Wi-SUN";
781 ex->initiator.start_fnum = pinfo->num;
782 ex->target.start_fnum = pinfo->num;
783 ex->initiator.end_fnum = ~(unsigned)0;
784 ex->target.end_fnum = ~(unsigned)0;
786 ex->initiator.addr64 = packet->src64;
787 ex->target.addr64 = packet->dst64;
788 edfe_insert_exchange(&ex->initiator.addr64, ex);
789 edfe_insert_exchange(&ex->target.addr64, ex);
790 } else if (packet->src_addr_mode == IEEE802154_FCF_ADDR_NONE) {
791 if (!hints->map_rec) {
792 wmem_tree_t* byframe = (wmem_tree_t *)wmem_map_lookup(edfe_byaddr, &packet->dst64);
793 if (byframe) {
794 edfe_exchange_t *ex = (edfe_exchange_t *)wmem_tree_lookup32_le(byframe, pinfo->num);
795 if (ex && pinfo->num <= ex->initiator.end_fnum) {
796 hints->map_rec = ex->initiator.addr64 == packet->dst64 ? &ex->target : &ex->initiator;
797 if (tx == 0 && rx == 0) {
798 // last frame
799 ex->initiator.end_fnum = pinfo->num;
804 if (hints->map_rec) {
805 // Set address to ensure that 6LoWPAN reassembly works
806 // Adapted from packet-ieee802.15.4.c
807 uint64_t *p_addr = wmem_new(pinfo->pool, uint64_t);
808 /* Copy and convert the address to network byte order. */
809 *p_addr = pntoh64(&(hints->map_rec->addr64));
810 set_address(&pinfo->dl_src, AT_EUI64, 8, p_addr);
811 copy_address_shallow(&pinfo->src, &pinfo->dl_src);
812 proto_item* src = proto_tree_add_eui64(tree, hf_wisun_fcie_src, tvb, 0, 0, hints->map_rec->addr64);
813 proto_item_set_generated(src);
814 proto_item* frm = proto_tree_add_uint(tree, hf_wisun_fcie_initial_frame, tvb, 0, 0, hints->map_rec->start_fnum);
815 proto_item_set_generated(frm);
816 } else {
817 expert_add_info(pinfo, tree, &ei_wisun_edfe_start_not_found);
822 return 2;
825 static int
826 dissect_wisun_rslie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
828 uint32_t rsl = tvb_get_uint8(tvb, offset);
829 if (rsl == 0xff) {
830 // "A value of 255 MUST be used to indicate not measured" [FANTPS 1v21]
831 proto_tree_add_uint_format_value(tree, hf_wisun_rslie_rsl, tvb, offset, 1, rsl, "not measured");
832 } else {
833 // "This provides a range of -174 (0) to +80 (254) dBm" [FANTPS 1v21]
834 proto_tree_add_uint_format_value(tree, hf_wisun_rslie_rsl, tvb, offset, 1, rsl, "%d dBm", rsl-174);
836 return 1;
839 static int
840 dissect_wisun_vhie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset)
842 unsigned vid = wisun_add_wbxml_uint(tvb, tree, hf_wisun_vhie_vid, offset);
843 if (!dissector_try_uint(vhie_dissector_table, vid,
844 tvb_new_subset_remaining(tvb, offset + wisun_vidlen(vid)),
845 pinfo, tree))
846 call_data_dissector(tvb_new_subset_remaining(tvb, offset + wisun_vidlen(vid)), pinfo, tree);
847 return tvb_reported_length(tvb);
850 static int
851 dissect_wisun_eaie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
853 proto_tree_add_item(tree, hf_wisun_eaie_eui, tvb, offset, 8, ENC_BIG_ENDIAN);
854 return 8;
857 static int
858 dissect_wisun_luttie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset)
860 uint8_t frame_type = tvb_get_uint8(tvb, offset);
861 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Wi-SUN");
862 col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(frame_type, wisun_frame_type_vals, "Unknown LFN Wi-SUN Frame"));
863 proto_tree_add_item(tree, hf_wisun_uttie_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
864 proto_tree_add_item(tree, hf_wisun_luttie_usn, tvb, offset+1, 2, ENC_LITTLE_ENDIAN);
865 proto_tree_add_item(tree, hf_wisun_luttie_uio, tvb, offset+3, 3, ENC_LITTLE_ENDIAN);
866 return 6;
869 static int
870 dissect_wisun_nrie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
872 unsigned start_offset = offset;
873 uint8_t bitmask = tvb_get_uint8(tvb, offset);
874 uint8_t node_role = bitmask & WISUN_WSIE_NODE_ROLE_ID_MASK;
875 int *const nrie_bitmask[] = {
876 &hf_wisun_nrie_lbats,
877 &hf_wisun_nrie_reserved_bits,
878 &hf_wisun_nrie_nr_id,
879 NULL
882 proto_tree_add_bitmask_list(tree, tvb, offset, 1, nrie_bitmask, ENC_LITTLE_ENDIAN);
883 if ((bitmask & ~(WISUN_WSIE_NODE_ROLE_LBATS_IMPLEMENTED|WISUN_WSIE_NODE_ROLE_ID_MASK)) != 0) {
884 expert_add_info(pinfo, tree, &ei_wisun_nrie_reserved_bits_not_zero);
886 offset++;
888 proto_tree_add_item(tree, hf_wisun_usie_clock_drift, tvb, offset, 1, ENC_LITTLE_ENDIAN);
889 offset++;
891 unsigned clock_drift = tvb_get_uint8(tvb, offset);
892 // "Resolution is 10 microseconds and the valid range of the field value is 0-255 (0 to 2.55msec)" [FANTPS 1v21]
893 proto_tree_add_uint_format_value(tree, hf_wisun_nrie_timing_accuracy, tvb, offset, 1, clock_drift, "%1.2fms", clock_drift/100.0);
894 offset++;
896 if (node_role == WISUN_WSIE_NODE_ROLE_ID_LFN) {
897 proto_tree_add_item(tree, hf_wisun_nrie_listening_interval_min, tvb, offset, 3, ENC_LITTLE_ENDIAN);
898 offset += 3;
899 proto_tree_add_item(tree, hf_wisun_nrie_listening_interval_max, tvb, offset, 3, ENC_LITTLE_ENDIAN);
900 offset += 3;
903 return offset - start_offset;
906 static int
907 dissect_wisun_lusie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
909 proto_tree_add_item(tree, hf_wisun_lusie_listen_interval, tvb, offset, 3, ENC_LITTLE_ENDIAN);
910 proto_tree_add_item(tree, hf_wisun_lusie_channel_plan_tag, tvb, offset+3, 1, ENC_LITTLE_ENDIAN);
911 return 4;
914 static int
915 dissect_wisun_lbtie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
917 proto_tree_add_item(tree, hf_wisun_lbtie_slot, tvb, offset, 2, ENC_LITTLE_ENDIAN);
918 /* as of FAN TPS 1v14, this is 3 bytes instead of 4 */
919 proto_tree_add_item(tree, hf_wisun_lbtie_bio, tvb, offset+2, 3, ENC_LITTLE_ENDIAN);
920 return 5;
923 static int
924 dissect_wisun_flusie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
926 proto_tree_add_item(tree, hf_wisun_flusie_dwell_interval, tvb, offset, 1, ENC_LITTLE_ENDIAN);
927 proto_tree_add_item(tree, hf_wisun_flusie_channel_plan_tag, tvb, offset+1, 1, ENC_LITTLE_ENDIAN);
928 return 2;
931 static int
932 dissect_wisun_lbsie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
934 proto_tree_add_item(tree, hf_wisun_lbsie_broadcast_interval, tvb, offset, 3, ENC_LITTLE_ENDIAN);
935 proto_tree_add_item(tree, hf_wisun_lbsie_broadcast_id, tvb, offset+3, 2, ENC_LITTLE_ENDIAN);
936 proto_tree_add_item(tree, hf_wisun_lbsie_channel_plan_tag, tvb, offset+5, 1, ENC_LITTLE_ENDIAN);
937 proto_tree_add_item(tree, hf_wisun_lbsie_broadcast_sync_period, tvb, offset+6, 1, ENC_LITTLE_ENDIAN);
938 return 7;
941 static int
942 dissect_wisun_lndie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
944 proto_tree_add_item(tree, hf_wisun_lndie_response_threshold, tvb, offset, 1, ENC_LITTLE_ENDIAN);
945 proto_tree_add_item(tree, hf_wisun_lndie_response_delay, tvb, offset+1, 3, ENC_LITTLE_ENDIAN);
946 proto_tree_add_item(tree, hf_wisun_lndie_discovery_slot_time, tvb, offset+4, 1, ENC_LITTLE_ENDIAN);
947 proto_tree_add_item(tree, hf_wisun_lndie_discovery_slots, tvb, offset+5, 1, ENC_LITTLE_ENDIAN);
948 proto_tree_add_item(tree, hf_wisun_lndie_discovery_first_slot, tvb, offset+6, 2, ENC_LITTLE_ENDIAN);
949 return 8;
952 static int
953 dissect_wisun_ltoie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
955 proto_tree_add_item(tree, hf_wisun_ltoie_offset, tvb, offset, 3, ENC_LITTLE_ENDIAN);
956 proto_tree_add_item(tree, hf_wisun_ltoie_listening_interval, tvb, offset+3, 3, ENC_LITTLE_ENDIAN);
957 return 6;
960 static int
961 dissect_wisun_panidie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
963 proto_tree_add_item(tree, hf_wisun_panidie_panid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
964 return 2;
967 static int
968 dissect_wisun_rtie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
970 proto_tree_add_item(tree, hf_wisun_rtie_rendezvous_time, tvb, offset, 2, ENC_LITTLE_ENDIAN);
971 proto_tree_add_item(tree, hf_wisun_rtie_wakeup_interval, tvb, offset+2, 2, ENC_LITTLE_ENDIAN);
972 return 4;
975 static int
976 dissect_wisun_lbcie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
978 proto_tree_add_item(tree, hf_wisun_lbcie_broadcast_interval, tvb, offset, 3, ENC_LITTLE_ENDIAN);
979 proto_tree_add_item(tree, hf_wisun_lbcie_broadcast_sync_period, tvb, offset+3, 1, ENC_LITTLE_ENDIAN);
980 return 4;
983 static int
984 dissect_wisun_netricity_nftie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
986 uint8_t frame_type = tvb_get_uint8(tvb, offset);
987 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Wi-SUN Netricity");
988 col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(frame_type, wisun_frame_type_vals, "Unknown Wi-SUN Netricity Frame"));
989 proto_tree_add_item(tree, hf_wisun_netricity_nftie_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
990 return 1;
993 static int
994 dissect_wisun_netricity_lqiie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
996 uint8_t lqi = tvb_get_uint8(tvb, offset);
997 switch (lqi) {
998 case 0:
999 // "-10 dB or lower (0x00)" [IEEE1901.2-2013]
1000 proto_tree_add_uint_format_value(tree, hf_wisun_netricity_lqiie_lqi, tvb, offset, 1, lqi, "0 (SNR -10 dB or lower)");
1001 break;
1002 case 255:
1003 // "A value of 255 MUST be used to indicate 'not measured'" [NTPS 1v04]
1004 proto_tree_add_uint_format_value(tree, hf_wisun_netricity_lqiie_lqi, tvb, offset, 1, lqi, "255 (not measured)");
1005 break;
1006 default:
1007 // "where the value of -9.75 dB is represented as 0x01 and the value of 52.75 dB is represented as 0xFE" [IEEE1901.2-2013]
1008 proto_tree_add_uint_format_value(tree, hf_wisun_netricity_lqiie_lqi, tvb, offset, 1, lqi, "%d (SNR %1.2f dB)", lqi,
1009 (lqi-1) * (52.75+9.75) / (0xfe - 0x01) - 9.75);
1011 return 1;
1014 static int
1015 dissect_wisun_hie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1017 unsigned offset;
1018 proto_tree *subtree;
1019 uint8_t subid = tvb_get_uint8(tvb, 2);
1020 ieee802154_packet *packet = (ieee802154_packet*)data;
1022 offset = 3;
1023 switch (subid) {
1024 case WISUN_SUBID_UTT:
1025 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_uttie, ett_wisun_uttie);
1026 offset += dissect_wisun_uttie(tvb, pinfo, subtree, offset);
1027 break;
1029 case WISUN_SUBID_BT:
1030 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_btie, ett_wisun_btie);
1031 offset += dissect_wisun_btie(tvb, pinfo, subtree, offset);
1032 break;
1034 case WISUN_SUBID_FC:
1035 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_fcie, ett_wisun_fcie);
1036 offset += dissect_wisun_fcie(tvb, pinfo, subtree, offset, packet);
1037 break;
1039 case WISUN_SUBID_RSL:
1040 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_rslie, ett_wisun_rslie);
1041 offset += dissect_wisun_rslie(tvb, pinfo, subtree, offset);
1042 break;
1044 case WISUN_SUBID_VH:
1045 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_vhie, ett_wisun_vhie);
1046 offset += dissect_wisun_vhie(tvb, pinfo, subtree, offset);
1047 break;
1049 case WISUN_SUBID_N_NFT:
1050 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_netricity_nftie, ett_wisun_netricity_nftie);
1051 offset += dissect_wisun_netricity_nftie(tvb, pinfo, subtree, offset);
1052 break;
1054 case WISUN_SUBID_N_LQI:
1055 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_netricity_lqiie, ett_wisun_netricity_lqiie);
1056 offset += dissect_wisun_netricity_lqiie(tvb, pinfo, subtree, offset);
1057 break;
1059 case WISUN_SUBID_EA:
1060 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_eaie, ett_wisun_eaie);
1061 offset += dissect_wisun_eaie(tvb, pinfo, subtree, offset);
1062 break;
1064 case WISUN_SUBID_LUTT:
1065 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_luttie, ett_wisun_luttie);
1066 offset += dissect_wisun_luttie(tvb, pinfo, subtree, offset);
1067 break;
1069 case WISUN_SUBID_LBT:
1070 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_lbtie, ett_wisun_btie);
1071 offset += dissect_wisun_lbtie(tvb, pinfo, subtree, offset);
1072 break;
1074 case WISUN_SUBID_NR:
1075 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_nrie, ett_wisun_nrie);
1076 offset += dissect_wisun_nrie(tvb, pinfo, subtree, offset);
1077 break;
1079 case WISUN_SUBID_LUS:
1080 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_lusie, ett_wisun_lusie);
1081 offset += dissect_wisun_lusie(tvb, pinfo, subtree, offset);
1082 break;
1084 case WISUN_SUBID_FLUS:
1085 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_flusie, ett_wisun_flusie);
1086 offset += dissect_wisun_flusie(tvb, pinfo, subtree, offset);
1087 break;
1089 case WISUN_SUBID_LBS:
1090 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_lbsie, ett_wisun_lbsie);
1091 offset += dissect_wisun_lbsie(tvb, pinfo, subtree, offset);
1092 break;
1094 case WISUN_SUBID_LND:
1095 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_lndie, ett_wisun_lndie);
1096 offset += dissect_wisun_lndie(tvb, pinfo, subtree, offset);
1097 break;
1099 case WISUN_SUBID_LTO:
1100 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_ltoie, ett_wisun_ltoie);
1101 offset += dissect_wisun_ltoie(tvb, pinfo, subtree, offset);
1102 break;
1104 case WISUN_SUBID_PANID:
1105 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_panidie, ett_wisun_panidie);
1106 offset += dissect_wisun_panidie(tvb, pinfo, subtree, offset);
1107 break;
1109 case WISUN_SUBID_RT:
1110 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_rtie, ett_wisun_rtie);
1111 offset += dissect_wisun_rtie(tvb, pinfo, subtree, offset);
1112 break;
1114 case WISUN_SUBID_LBC:
1115 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_lbcie, ett_wisun_lbcie);
1116 offset += dissect_wisun_lbcie(tvb, pinfo, subtree, offset);
1117 break;
1119 default:
1120 subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_unknown_ie, ett_wisun_unknown_ie);
1121 expert_add_info(pinfo, subtree, &ei_wisun_subid_unsupported);
1122 call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, subtree);
1123 offset = tvb_reported_length(tvb);
1124 break;
1126 return offset;
1129 /*-----------------------------------------------
1130 * Wi-SUN Payload IE Dissection
1131 *---------------------------------------------*/
1132 static int
1133 dissect_wisun_schedule_common(tvbuff_t *tvb, packet_info *pinfo, unsigned offset, proto_tree *tree)
1135 static int * const fields_usie_channel[] = {
1136 &hf_wisun_usie_channel_plan,
1137 &hf_wisun_usie_channel_function,
1138 &hf_wisun_usie_channel_exclude,
1139 NULL
1142 static int * const fields_usie_channel_plan_explicit[] = {
1143 &hf_wisun_usie_explicit_frequency,
1144 &hf_wisun_usie_explicit_spacing,
1145 &hf_wisun_usie_explicit_reserved,
1146 NULL
1148 int count;
1149 proto_item *ti;
1151 uint8_t control = tvb_get_uint8(tvb, offset);
1152 proto_tree_add_bitmask_with_flags(tree, tvb, offset, hf_wisun_usie_channel_control, ett_wisun_usie_channel_control,
1153 fields_usie_channel, ENC_LITTLE_ENDIAN, BMT_NO_FLAGS);
1154 offset++;
1156 switch ((control & WISUN_CHANNEL_PLAN) >> 0) {
1157 case WISUN_CHANNEL_PLAN_REGULATORY:
1158 proto_tree_add_item(tree, hf_wisun_usie_regulatory_domain, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1159 offset++;
1160 proto_tree_add_item(tree, hf_wisun_usie_operating_class, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1161 offset++;
1162 break;
1164 case WISUN_CHANNEL_PLAN_EXPLICIT:
1165 ti = proto_tree_add_bitmask(tree, tvb, offset, hf_wisun_usie_explicit, ett_wisun_usie_explicit,
1166 fields_usie_channel_plan_explicit, ENC_LITTLE_ENDIAN);
1167 offset += 3;
1168 if (tvb_get_uint8(tvb, offset) & 0xf0) {
1169 expert_add_info(pinfo, ti, &ei_wisun_usie_explicit_reserved_bits_not_zero);
1171 offset++;
1172 proto_tree_add_item(tree, hf_wisun_usie_number_channels, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1173 offset += 2;
1174 break;
1176 case WISUN_CHANNEL_PLAN_REGULATORY_ID:
1177 proto_tree_add_item(tree, hf_wisun_usie_regulatory_domain, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1178 offset++;
1179 proto_tree_add_item(tree, hf_wisun_usie_channel_plan_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1180 offset++;
1181 break;
1183 default:
1184 expert_add_info(pinfo, tree, &ei_wisun_usie_channel_plan_invalid);
1185 return tvb_reported_length(tvb);
1188 switch ((control & WISUN_CHANNEL_FUNCTION) >> 3) {
1189 case WISUN_CHANNEL_FUNCTION_FIXED:
1190 proto_tree_add_item(tree, hf_wisun_usie_fixed_channel, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1191 offset += 2;
1192 break;
1194 case WISUN_CHANNEL_FUNCTION_VENDOR:
1195 count = tvb_get_uint8(tvb, offset);
1196 proto_tree_add_item(tree, hf_wisun_usie_hop_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1197 offset++;
1198 while (count--) {
1199 proto_tree_add_item(tree, hf_wisun_usie_hop_list, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1200 offset++;
1202 break;
1204 default:
1205 /* Hopping list is implied by the hashing function. */
1206 break;
1209 switch ((control & WISUN_CHANNEL_EXCLUDE) >> 6) {
1210 case WISUN_CHANNEL_EXCLUDE_RANGE:
1211 count = tvb_get_uint8(tvb, offset);
1212 proto_tree_add_item(tree, hf_wisun_usie_number_ranges, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1213 offset++;
1214 while (count) {
1215 proto_tree_add_item(tree, hf_wisun_usie_exclude_range_start, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1216 offset += 2;
1217 proto_tree_add_item(tree, hf_wisun_usie_exclude_range_end, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1218 offset += 2;
1219 count--;
1221 break;
1223 case WISUN_CHANNEL_EXCLUDE_MASK:
1224 count = tvb_reported_length_remaining(tvb, offset);
1225 proto_tree_add_item(tree, hf_wisun_usie_exclude_mask, tvb, offset, count, ENC_NA);
1226 offset += count;
1227 break;
1229 default:
1230 /* Assume there is nothing to exclude. */
1231 break;
1233 return offset;
1236 static int
1237 dissect_wisun_usie_btie_common(tvbuff_t *tvb, packet_info *pinfo _U_, unsigned offset, proto_tree *tree)
1239 proto_tree_add_item(tree, hf_wisun_usie_dwell_interval, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1240 offset++;
1241 proto_tree_add_item(tree, hf_wisun_usie_clock_drift, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1242 offset++;
1244 unsigned clock_drift = tvb_get_uint8(tvb, offset);
1245 // "Resolution is 10 microseconds and the valid range of the field value is 0-255 (0 to 2.55msec)" [FANTPS 1v21]
1246 proto_tree_add_uint_format_value(tree, hf_wisun_usie_timing_accuracy, tvb, offset, 1, clock_drift, "%1.2fms", clock_drift/100.0);
1247 offset++;
1249 return offset;
1252 static int
1253 dissect_wisun_usie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1255 proto_item *item;
1256 proto_tree *subtree;
1257 unsigned offset = 0;
1259 item = proto_tree_add_item(tree, hf_wisun_usie, tvb, 0, tvb_reported_length_remaining(tvb, 0), ENC_NA);
1260 subtree = proto_item_add_subtree(item, ett_wisun_usie);
1262 proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie, ENC_LITTLE_ENDIAN);
1263 offset += 2;
1265 offset = dissect_wisun_usie_btie_common(tvb, pinfo, offset, subtree);
1267 return dissect_wisun_schedule_common(tvb, pinfo, offset, subtree);
1270 static int
1271 dissect_wisun_bsie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1273 proto_item *item;
1274 proto_tree *subtree;
1275 unsigned offset = 0;
1277 item = proto_tree_add_item(tree, hf_wisun_bsie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
1278 subtree = proto_item_add_subtree(item, ett_wisun_bsie);
1280 proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie, ENC_LITTLE_ENDIAN);
1281 offset += 2;
1282 proto_tree_add_item(subtree, hf_wisun_bsie_bcast_interval, tvb, offset, 4, ENC_LITTLE_ENDIAN);
1283 offset += 4;
1284 proto_tree_add_item(subtree, hf_wisun_bsie_bcast_schedule_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1285 offset += 2;
1287 offset = dissect_wisun_usie_btie_common(tvb, pinfo, offset, subtree);
1289 return dissect_wisun_schedule_common(tvb, pinfo, offset, subtree);
1292 static int
1293 dissect_wisun_vpie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
1295 proto_item *item;
1296 proto_tree *subtree;
1297 unsigned vid;
1299 item = proto_tree_add_item(tree, hf_wisun_vpie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
1300 subtree = proto_item_add_subtree(item, ett_wisun_vpie);
1302 vid = wisun_add_wbxml_uint(tvb, subtree, hf_wisun_vpie_vid, 2);
1303 if (!dissector_try_uint(vpie_dissector_table, vid,
1304 tvb_new_subset_remaining(tvb, 2 + wisun_vidlen(vid)),
1305 pinfo, subtree))
1306 call_data_dissector(tvb_new_subset_remaining(tvb, 2 + wisun_vidlen(vid)), pinfo, subtree);
1307 return tvb_reported_length(tvb);
1310 static int
1311 dissect_wisun_lcpie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1313 proto_item *item;
1314 proto_tree *subtree;
1315 unsigned offset = 0;
1317 item = proto_tree_add_item(tree, hf_wisun_lcpie, tvb, 0, tvb_reported_length_remaining(tvb, 0), ENC_NA);
1318 subtree = proto_item_add_subtree(item, ett_wisun_lcpie);
1320 proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie, ENC_LITTLE_ENDIAN);
1321 offset += 2;
1323 proto_tree_add_item(subtree, hf_wisun_lusie_channel_plan_tag, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1324 offset += 1;
1326 return dissect_wisun_schedule_common(tvb, pinfo, offset, subtree);
1329 static int
1330 dissect_wisun_panie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
1332 proto_item *item;
1333 proto_tree *subtree;
1334 unsigned offset = 0;
1335 uint32_t routingCost;
1336 static int * const fields_panie_flags[] = {
1337 &hf_wisun_panie_flag_parent_bsie,
1338 &hf_wisun_panie_flag_routing_method,
1339 &hf_wisun_panie_flag_lfn_window_style,
1340 &hf_wisun_panie_flag_version,
1341 NULL
1344 item = proto_tree_add_item(tree, hf_wisun_panie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
1345 subtree = proto_item_add_subtree(item, ett_wisun_panie);
1347 proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
1348 offset += 2;
1349 proto_tree_add_item(subtree, hf_wisun_panie_size, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1350 offset += 2;
1351 proto_tree_add_item_ret_uint(subtree, hf_wisun_panie_cost, tvb, offset, 2, ENC_LITTLE_ENDIAN, &routingCost);
1352 offset += 2;
1353 proto_tree_add_bitmask_with_flags(subtree, tvb, offset, hf_wisun_panie_flags, ett_wisun_panie_flags,
1354 fields_panie_flags, ENC_LITTLE_ENDIAN, BMT_NO_FLAGS);
1355 offset++;
1357 col_append_sep_fstr(pinfo->cinfo, COL_INFO, ", ", "Routing Cost: %d", routingCost);
1359 return offset;
1362 static int
1363 dissect_wisun_netnameie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
1365 proto_item *item;
1366 proto_tree *subtree;
1368 item = proto_tree_add_item(tree, hf_wisun_netnameie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
1369 subtree = proto_item_add_subtree(item, ett_wisun_netnameie);
1371 proto_tree_add_bitmask(subtree, tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
1372 proto_tree_add_item(subtree, hf_wisun_netnameie_name, tvb, 2, tvb_reported_length_remaining(tvb, 2), ENC_ASCII);
1374 col_append_sep_fstr(pinfo->cinfo, COL_INFO, ", ", "Netname: %s",
1375 tvb_get_string_enc(pinfo->pool, tvb, 2, tvb_reported_length_remaining(tvb, 2), ENC_ASCII));
1376 return tvb_reported_length(tvb);
1379 static int
1380 dissect_wisun_panverie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
1382 proto_item *item;
1383 proto_tree *subtree;
1385 item = proto_tree_add_item(tree, hf_wisun_panverie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
1386 subtree = proto_item_add_subtree(item, ett_wisun_panverie);
1388 proto_tree_add_bitmask(subtree, tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
1389 proto_tree_add_item(subtree, hf_wisun_panverie_version, tvb, 2, 2, ENC_LITTLE_ENDIAN);
1391 col_append_sep_fstr(pinfo->cinfo, COL_INFO, ", ", "PAN Version: %d", tvb_get_uint16(tvb, 2, ENC_LITTLE_ENDIAN));
1393 return tvb_reported_length(tvb);
1396 static int
1397 dissect_wisun_gtkhashie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
1399 proto_item *item;
1400 proto_tree *subtree;
1402 item = proto_tree_add_item(tree, hf_wisun_gtkhashie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
1403 subtree = proto_item_add_subtree(item, ett_wisun_gtkhashie);
1405 proto_tree_add_bitmask(subtree, tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
1406 proto_tree_add_item(subtree, hf_wisun_gtkhashie_gtk0, tvb, 2, 8, ENC_NA);
1407 proto_tree_add_item(subtree, hf_wisun_gtkhashie_gtk1, tvb, 10, 8, ENC_NA);
1408 proto_tree_add_item(subtree, hf_wisun_gtkhashie_gtk2, tvb, 18, 8, ENC_NA);
1409 proto_tree_add_item(subtree, hf_wisun_gtkhashie_gtk3, tvb, 26, 8, ENC_NA);
1410 return 34;
1413 static int
1414 dissect_wisun_pomie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
1416 proto_item *item;
1417 proto_tree *subtree;
1418 uint8_t number_operating_modes;
1419 unsigned offset = 0;
1421 static int* const wisun_pomie_fields[] = {
1422 &hf_wisun_pomie_number_operating_modes,
1423 &hf_wisun_pomie_mdr_command_capable_flag,
1424 &hf_wisun_pomie_reserved,
1425 NULL
1428 item = proto_tree_add_item(tree, hf_wisun_pomie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
1429 subtree = proto_item_add_subtree(item, ett_wisun_pomie);
1431 proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
1433 offset += 2;
1434 number_operating_modes = tvb_get_uint8(tvb, offset) & WISUN_PIE_PHY_OPERATING_MODES_MASK;
1435 proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_pomie_hdr, ett_wisun_pomie_hdr, wisun_pomie_fields, ENC_NA);
1437 offset++;
1438 for (uint8_t i = 0; i < number_operating_modes; i++) {
1439 wisun_add_phy_mode_id(tvb, subtree, offset, hf_wisun_pomie_phy_mode_id, &hf_wisun_pomie_phy_type,
1440 &hf_wisun_pomie_phy_mode_fsk, &hf_wisun_pomie_phy_mode_ofdm);
1441 offset++;
1444 return tvb_reported_length(tvb);
1447 static int
1448 dissect_wisun_lfnverie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
1450 proto_item *item;
1451 proto_tree *subtree;
1453 item = proto_tree_add_item(tree, hf_wisun_lfnverie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
1454 subtree = proto_item_add_subtree(item, ett_wisun_lfnverie);
1456 proto_tree_add_bitmask(subtree, tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
1457 proto_tree_add_item(subtree, hf_wisun_lfnverie_version, tvb, 2, 2, ENC_LITTLE_ENDIAN);
1459 col_append_sep_fstr(pinfo->cinfo, COL_INFO, ", ", "LFN Version: %d", tvb_get_uint16(tvb, 2, ENC_LITTLE_ENDIAN));
1461 return tvb_reported_length(tvb);
1464 static int
1465 dissect_wisun_lgtkhashie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
1467 proto_item *item;
1468 proto_tree *subtree;
1469 unsigned offset = 0;
1470 uint8_t lgtkhash_control = 0;
1472 static int * const fields_lgtkhashie_flags[] = {
1473 &hf_wisun_lgtkhashie_flag_includes_lgtk0,
1474 &hf_wisun_lgtkhashie_flag_includes_lgtk1,
1475 &hf_wisun_lgtkhashie_flag_includes_lgtk2,
1476 &hf_wisun_lgtkhashie_flag_active_lgtk_index,
1477 NULL
1480 item = proto_tree_add_item(tree, hf_wisun_lgtkhashie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
1481 subtree = proto_item_add_subtree(item, ett_wisun_lgtkhashie);
1483 proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
1484 offset += 2;
1486 lgtkhash_control = tvb_get_uint8(tvb, offset);
1487 proto_tree_add_bitmask_with_flags(subtree, tvb, offset, hf_wisun_lgtkhashie_flags, ett_wisun_lgtkhashie_flags,
1488 fields_lgtkhashie_flags, ENC_LITTLE_ENDIAN, BMT_NO_FLAGS);
1489 offset++;
1491 if (lgtkhash_control & WISUN_LGTKHASH_LGTK0_INCLUDED_MASK) {
1492 proto_tree_add_item(subtree, hf_wisun_lgtkhashie_gtk0, tvb, offset, 8, ENC_NA);
1493 offset += 8;
1496 if (lgtkhash_control & WISUN_LGTKHASH_LGTK1_INCLUDED_MASK) {
1497 proto_tree_add_item(subtree, hf_wisun_lgtkhashie_gtk1, tvb, offset, 8, ENC_NA);
1498 offset += 8;
1501 if (lgtkhash_control & WISUN_LGTKHASH_LGTK2_INCLUDED_MASK) {
1502 proto_tree_add_item(subtree, hf_wisun_lgtkhashie_gtk2, tvb, offset, 8, ENC_NA);
1503 offset += 8;
1506 return offset;
1509 static int
1510 dissect_wisun_lbatsie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
1512 unsigned offset = 0;
1513 proto_item *item;
1514 proto_tree *subtree;
1516 item = proto_tree_add_item(tree, hf_wisun_lbatsie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
1517 subtree = proto_item_add_subtree(item, ett_wisun_lbatsie);
1519 proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
1520 offset += 2;
1521 proto_tree_add_item(subtree, hf_wisun_lbatsie_additional_tx, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1522 offset += 1;
1523 proto_tree_add_item(subtree, hf_wisun_lbatsie_next_tx_delay, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1524 offset += 2;
1525 return offset;
1528 static int
1529 dissect_wisun_jmie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
1531 static int * const fields_jmie_metric_hdr[] = {
1532 &hf_wisun_jmie_metric_id,
1533 &hf_wisun_jmie_metric_len,
1534 NULL
1536 unsigned offset = 0;
1537 proto_item *item;
1538 proto_tree *subtree;
1540 item = proto_tree_add_item(tree, hf_wisun_jmie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
1541 subtree = proto_item_add_subtree(item, ett_wisun_jmie);
1543 proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
1544 offset += 2;
1545 proto_tree_add_item(subtree, hf_wisun_jmie_version, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1546 offset += 1;
1547 while (tvb_reported_length_remaining(tvb, offset) > 0) {
1548 uint8_t metric_hdr = tvb_get_uint8(tvb, offset);
1549 uint8_t metric_len = (metric_hdr & WISUN_PIE_JM_LEN_MASK) >> 6;
1550 proto_tree *metric_subtree;
1552 if (metric_len == 3)
1553 metric_len = 4;
1555 switch (metric_hdr & WISUN_PIE_JM_ID_MASK) {
1556 case WISUN_PIE_JM_ID_PLF:
1557 item = proto_tree_add_item(subtree, hf_wisun_jmie_metric_plf, tvb, offset, 1 + metric_len, ENC_NA);
1558 metric_subtree = proto_item_add_subtree(item, ett_wisun_jmie_metric_plf);
1559 proto_tree_add_bitmask(metric_subtree, tvb, offset, hf_wisun_jmie_metric_hdr, ett_wisun_jmie_metric_hdr, fields_jmie_metric_hdr, ENC_NA);
1560 offset += 1;
1561 proto_tree_add_item(metric_subtree, hf_wisun_jmie_metric_plf_data, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1562 break;
1563 default:
1564 item = proto_tree_add_item(subtree, hf_wisun_jmie_metric_unknown, tvb, offset, 1 + metric_len, ENC_NA);
1565 metric_subtree = proto_item_add_subtree(item, ett_wisun_jmie_metric_unknown);
1566 proto_tree_add_bitmask(metric_subtree, tvb, offset, hf_wisun_jmie_metric_hdr, ett_wisun_jmie_metric_hdr, fields_jmie_metric_hdr, ENC_NA);
1567 offset += 1;
1568 expert_add_info(pinfo, metric_subtree, &ei_wisun_jmie_metric_unsupported);
1569 call_data_dissector(tvb_new_subset_length(tvb, offset, metric_len), pinfo, metric_subtree);
1570 break;
1572 offset += metric_len;
1574 return offset;
1577 static int
1578 dissect_wisun_pie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ies_tree, void *data)
1580 proto_tree *tree = ieee802154_create_pie_tree(tvb, ies_tree, hf_wisun_pie, ett_wisun_pie);
1581 unsigned offset = 2;
1582 while (tvb_reported_length_remaining(tvb, offset) > 1) {
1583 /* Wi-SUN Payload IE contains nested IE's using the same format as IEEE802.15.4 */
1584 uint16_t wsie_ie = tvb_get_letohs(tvb, offset);
1585 uint16_t wsie_len;
1586 tvbuff_t * wsie_tvb;
1588 if (wsie_ie & IEEE802154_PSIE_TYPE_MASK) {
1589 /* long format: Table 7-17-Sub-ID allocation for long format */
1590 wsie_len = (wsie_ie & IEEE802154_PSIE_LENGTH_MASK_LONG);
1591 wsie_tvb = tvb_new_subset_length(tvb, offset, wsie_len + 2);
1592 switch ((wsie_ie & IEEE802154_PSIE_ID_MASK_LONG) >> 11) {
1593 case WISUN_PIE_SUBID_US:
1594 dissect_wisun_usie(wsie_tvb, pinfo, tree, data);
1595 break;
1596 case WISUN_PIE_SUBID_BS:
1597 dissect_wisun_bsie(wsie_tvb, pinfo, tree, data);
1598 break;
1599 case WISUN_PIE_SUBID_VP:
1600 dissect_wisun_vpie(wsie_tvb, pinfo, tree, data);
1601 break;
1602 case WISUN_PIE_SUBID_LCP:
1603 dissect_wisun_lcpie(wsie_tvb, pinfo, tree, data);
1604 break;
1605 default:{
1606 proto_item *item = proto_tree_add_item(tree, hf_wisun_unknown_ie, wsie_tvb, 0, tvb_reported_length(wsie_tvb), ENC_NA);
1607 proto_tree *subtree = proto_item_add_subtree(item, ett_wisun_unknown_ie);
1608 proto_tree_add_bitmask(subtree, wsie_tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie, ENC_LITTLE_ENDIAN);
1609 expert_add_info(pinfo, subtree, &ei_wisun_wsie_unsupported);
1610 call_data_dissector(tvb_new_subset_remaining(wsie_tvb, 2), pinfo, subtree);
1611 break;
1614 } else {
1615 /* short format: Table 7-16-Sub-ID allocation for short format */
1616 wsie_len = (wsie_ie & IEEE802154_PSIE_LENGTH_MASK_SHORT);
1617 wsie_tvb = tvb_new_subset_length(tvb, offset, wsie_len + 2);
1618 switch ((wsie_ie & IEEE802154_PSIE_ID_MASK_SHORT) >> 8) {
1619 case WISUN_PIE_SUBID_PAN:
1620 dissect_wisun_panie(wsie_tvb, pinfo, tree, data);
1621 break;
1622 case WISUN_PIE_SUBID_NETNAME:
1623 dissect_wisun_netnameie(wsie_tvb, pinfo, tree, data);
1624 break;
1625 case WISUN_PIE_SUBID_PANVER:
1626 dissect_wisun_panverie(wsie_tvb, pinfo, tree, data);
1627 break;
1628 case WISUN_PIE_SUBID_GTKHASH:
1629 dissect_wisun_gtkhashie(wsie_tvb, pinfo, tree, data);
1630 break;
1631 case WISUN_PIE_SUBID_POM:
1632 dissect_wisun_pomie(wsie_tvb, pinfo, tree, data);
1633 break;
1634 case WISUN_PIE_SUBID_LFNVER:
1635 dissect_wisun_lfnverie(wsie_tvb, pinfo, tree, data);
1636 break;
1637 case WISUN_PIE_SUBID_LGTKHASH:
1638 dissect_wisun_lgtkhashie(wsie_tvb, pinfo, tree, data);
1639 break;
1640 case WISUN_PIE_SUBID_LBATS:
1641 dissect_wisun_lbatsie(wsie_tvb, pinfo, tree, data);
1642 break;
1643 case WISUN_PIE_SUBID_JM:
1644 dissect_wisun_jmie(wsie_tvb, pinfo, tree, data);
1645 break;
1646 default:{
1647 proto_item *item = proto_tree_add_item(tree, hf_wisun_unknown_ie, wsie_tvb, 0, tvb_reported_length(wsie_tvb), ENC_NA);
1648 proto_tree *subtree = proto_item_add_subtree(item, ett_wisun_unknown_ie);
1649 proto_tree_add_bitmask(subtree, wsie_tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie, ENC_LITTLE_ENDIAN);
1650 expert_add_info(pinfo, subtree, &ei_wisun_wsie_unsupported);
1651 call_data_dissector(tvb_new_subset_remaining(wsie_tvb, 2), pinfo, subtree);
1652 break;
1656 offset += tvb_reported_length(wsie_tvb);
1658 return offset;
1662 static int
1663 dissect_wisun_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1665 unsigned offset = 0;
1666 uint8_t cmd_subid;
1668 cmd_subid = tvb_get_uint8(tvb, offset);
1669 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Wi-SUN");
1670 col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(cmd_subid, wisun_cmd_vals, "Unknown Wi-SUN MAC Command"));
1671 proto_tree_add_item(tree, hf_wisun_cmd_subid, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1672 offset += 1;
1673 switch (cmd_subid) {
1674 case WISUN_CMD_MDR:
1675 wisun_add_phy_mode_id(tvb, tree, offset, hf_wisun_cmd_mdr_phy_mode_id, &hf_wisun_cmd_mdr_phy_type,
1676 &hf_wisun_cmd_mdr_phy_mode_fsk, &hf_wisun_cmd_mdr_phy_mode_ofdm);
1677 break;
1678 default:
1679 call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, tree);
1680 break;
1682 return offset;
1685 /*-----------------------------------------------
1686 * Wi-SUN FAN Security Extensions Dissection
1687 *---------------------------------------------*/
1688 static int
1689 dissect_wisun_sec(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1691 proto_item *ws_root;
1692 proto_tree *ws_tree;
1693 uint8_t function = tvb_get_uint8(tvb, 0);
1694 const char *function_name = val_to_str_const(function, wisun_sec_functions, "Unknown Function");
1696 /* Create the protocol tree. */
1697 ws_root = proto_tree_add_protocol_format(tree, proto_wisun_sec, tvb, 0, -1, "Wi-SUN %s", function_name);
1698 ws_tree = proto_item_add_subtree(ws_root, ett_wisun_sec);
1700 /* Add the protocol name. */
1701 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Wi-SUN");
1702 col_set_str(pinfo->cinfo, COL_INFO, function_name);
1704 /* Decode based on the function code. */
1705 proto_tree_add_item(ws_tree, hf_wisun_sec_function, tvb, 0, 1, ENC_LITTLE_ENDIAN);
1706 switch (function) {
1707 case 0x01:{
1708 const char *err_name = val_to_str_const(tvb_get_uint8(tvb, 1), wisun_sec_sm_errors, "Unknown Error");
1709 col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", err_name);
1710 proto_item_append_text(ws_root, ": %s", err_name);
1712 proto_tree_add_item(ws_tree, hf_wisun_sec_error_type, tvb, 1, 1, ENC_LITTLE_ENDIAN);
1713 proto_tree_add_item(ws_tree, hf_wisun_sec_error_nonce, tvb, 2, tvb_reported_length_remaining(tvb, 2), ENC_NA);
1714 return tvb_reported_length(tvb);
1717 default:
1718 call_data_dissector(tvb_new_subset_remaining(tvb, 2), pinfo, ws_tree);
1719 return tvb_reported_length(tvb);
1724 /*-----------------------------------------------
1725 * Wi-SUN FAN EAPOL Relay
1726 *---------------------------------------------*/
1728 static int dissect_wisun_eapol_relay(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1730 unsigned offset = 0;
1731 proto_item *subitem = proto_tree_add_item(tree, proto_wisun_eapol_relay, tvb, offset, 9, ENC_NA);
1732 proto_tree *subtree = proto_item_add_subtree(subitem, ett_wisun_eapol_relay);
1734 proto_tree_add_item(subtree, hf_wisun_eapol_relay_sup, tvb, offset, 8, ENC_BIG_ENDIAN);
1735 offset += 8;
1736 proto_tree_add_item(subtree, hf_wisun_eapol_relay_kmp_id, tvb, offset, 1, ENC_NA);
1737 offset += 1;
1739 int up = 0;
1740 // eapol.type == EAP_PACKET?
1741 if (tvb_get_uint8(tvb, offset+1) == 0) {
1742 up = tvb_get_uint8(tvb, offset+4) == 2; // eap.code == EAP_CODE_RESPONSE
1743 } else {
1744 up = (tvb_get_uint8(tvb, offset+6) & 0x80) == 0; // Key Info ACK==0
1746 proto_item* diritem = proto_tree_add_boolean(subtree, hf_wisun_eapol_relay_direction, tvb, offset, 0, (uint64_t) up);
1747 proto_item_set_generated(diritem);
1749 int r = call_dissector(eapol_handle, tvb_new_subset_remaining(tvb, offset), pinfo, tree);
1751 // UTF-8 arrow up or down
1752 col_append_str(pinfo->cinfo, COL_INFO, up ? " [Relay \xe2\x86\x91]" : " [Relay \xe2\x86\x93]");
1754 return offset + r;
1757 /*-----------------------------------------------
1758 * Wi-SUN Netricity Segment Control
1759 *---------------------------------------------*/
1761 static int dissect_wisun_netricity_sc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1763 static int * const fields_sc[] = {
1764 &hf_wisun_netricity_sc_reserved,
1765 &hf_wisun_netricity_sc_tone_map_request,
1766 &hf_wisun_netricity_sc_contention_control,
1767 &hf_wisun_netricity_sc_channel_access_priority,
1768 &hf_wisun_netricity_sc_last_segment,
1769 NULL
1772 unsigned offset = 0;
1774 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Wi-SUN Netricity");
1776 proto_item *subitem = proto_tree_add_item(tree, proto_wisun_netricity_sc, tvb, offset, -1, ENC_NA);
1777 proto_tree *subtree = proto_item_add_subtree(subitem, ett_wisun_netricity_sc);
1779 bool is_last = tvb_get_uint8(tvb, 0) & 1;
1780 proto_tree_add_bitmask(subtree, tvb, offset++, hf_wisun_netricity_sc_flags, ett_wisun_netricity_sc_bitmask, fields_sc, ENC_BIG_ENDIAN);
1781 uint32_t seg_count;
1782 uint32_t seg_len;
1783 proto_tree_add_item_ret_uint(subtree, hf_wisun_netricity_sc_segment_count, tvb, offset, 2, ENC_BIG_ENDIAN, &seg_count);
1784 proto_tree_add_item_ret_uint(subtree, hf_wisun_netricity_sc_segment_length, tvb, offset, 2, ENC_BIG_ENDIAN, &seg_len);
1785 offset += 2;
1787 bool is_segmented = !is_last || seg_count != 0;
1788 proto_tree *ieee802154_tree;
1789 ieee802154_packet *packet;
1790 tvbuff_t *frame = tvb_new_subset_remaining(tvb, offset);
1791 // if security is used, all segments have the flag set in the FCF, but only the first has the Auxiliary Security Header
1792 unsigned mhr_len = ieee802154_dissect_header(frame, pinfo,
1793 is_segmented ? subtree : tree,
1794 seg_count == 0 ? 0 : IEEE802154_DISSECT_HEADER_OPTION_NO_AUX_SEC_HDR,
1795 &ieee802154_tree, &packet);
1796 if (!mhr_len) {
1797 return tvb_captured_length(tvb);
1799 frame = tvb_new_subset_length(frame, 0, mhr_len + seg_len);
1801 if (is_segmented) {
1802 bool save_fragmented = pinfo->fragmented;
1803 pinfo->fragmented = true;
1804 fragment_head *frag_msg = fragment_add_seq_check(&netricity_reassembly_table,
1805 frame,
1806 seg_count == 0 ? 0 : mhr_len,
1807 pinfo,
1808 packet->seqno,
1809 NULL,
1810 seg_count,
1811 (seg_count == 0 ? mhr_len : 0) + seg_len,
1812 !is_last);
1813 tvbuff_t *reframe = process_reassembled_data(tvb, offset, pinfo, "Reassembled segments", frag_msg, &netricity_scr_frag_items, NULL, subtree);
1815 if (reframe) {
1816 call_dissector(ieee802154_nofcs_handle, reframe, pinfo, tree);
1817 col_append_fstr(pinfo->cinfo, COL_INFO, " (Reassembled %u segments)", seg_count + 1);
1818 } else {
1819 call_data_dissector(tvb_new_subset_remaining(frame, mhr_len), pinfo, subtree);
1820 col_append_fstr(pinfo->cinfo, COL_INFO, " (Segment %u)", seg_count);
1823 pinfo->fragmented = save_fragmented;
1824 } else {
1825 tvbuff_t *payload = ieee802154_decrypt_payload(frame, mhr_len, pinfo, ieee802154_tree, packet);
1826 if (payload) {
1827 unsigned pie_size = ieee802154_dissect_payload_ies(payload, pinfo, ieee802154_tree, packet);
1828 payload = tvb_new_subset_remaining(payload, pie_size);
1829 ieee802154_dissect_frame_payload(payload, pinfo, ieee802154_tree, packet, true);
1833 return tvb_captured_length(tvb);
1836 /*-----------------------------------------------
1837 * Wi-SUN Protocol Registration
1838 *---------------------------------------------*/
1839 void proto_register_wisun(void)
1841 static hf_register_info hf[] = {
1842 /* Wi-SUN Header IEs */
1843 { &hf_wisun_subid,
1844 { "Header Sub ID", "wisun.subid", FT_UINT8, BASE_HEX|BASE_SPECIAL_VALS, VALS(wisun_subid_vals), 0x0,
1845 NULL, HFILL }
1848 { &hf_wisun_unknown_ie,
1849 { "Unknown IE", "wisun.unknown", FT_NONE, BASE_NONE, NULL, 0x0,
1850 NULL, HFILL }
1853 { &hf_wisun_uttie,
1854 { "UTT-IE", "wisun.uttie", FT_NONE, BASE_NONE, NULL, 0x0,
1855 "Unicast Timing IE", HFILL }
1858 { &hf_wisun_uttie_type,
1859 { "Frame Type", "wisun.uttie.type", FT_UINT8, BASE_DEC|BASE_SPECIAL_VALS, VALS(wisun_frame_type_vals), 0x0,
1860 NULL, HFILL }
1863 { &hf_wisun_uttie_ufsi,
1864 { "UFSI", "wisun.uttie.ufsi", FT_UINT24, BASE_DEC, NULL, 0x0,
1865 "Unicast Fractional Sequence Interval", HFILL }
1868 { &hf_wisun_btie,
1869 { "BT-IE", "wisun.btie", FT_NONE, BASE_NONE, NULL, 0x0,
1870 "Broadcast Timing IE", HFILL }
1873 { &hf_wisun_btie_slot,
1874 { "BSN", "wisun.btie.slot", FT_UINT24, BASE_DEC, NULL, 0x0,
1875 "Broadcast Slot Number", HFILL }
1878 { &hf_wisun_btie_bio,
1879 { "BIO", "wisun.btie.bio", FT_UINT24, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0,
1880 "Broadcast Interval Offset", HFILL }
1883 { &hf_wisun_fcie,
1884 { "FC-IE", "wisun.fcie", FT_NONE, BASE_NONE, NULL, 0x0,
1885 "Flow Control IE", HFILL }
1888 { &hf_wisun_fcie_tx,
1889 { "Transmit Flow Control", "wisun.fcie.tx", FT_UINT8, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0,
1890 NULL, HFILL }
1893 { &hf_wisun_fcie_rx,
1894 { "Receive Flow Control", "wisun.fcie.rx", FT_UINT8, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0,
1895 NULL, HFILL }
1898 { &hf_wisun_fcie_src,
1899 { "Source Address", "wisun.fcie.src", FT_EUI64, BASE_NONE, NULL, 0x0,
1900 NULL, HFILL }
1903 { &hf_wisun_fcie_initial_frame,
1904 { "Initial Frame", "wisun.fcie.initial_frame", FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0,
1905 NULL, HFILL }
1908 { &hf_wisun_rslie,
1909 { "RSL-IE", "wisun.rslie", FT_NONE, BASE_NONE, NULL, 0x0,
1910 "Received Signal Level IE", HFILL }
1913 { &hf_wisun_rslie_rsl,
1914 { "Received Signal Level", "wisun.rslie.rsl", FT_UINT8, BASE_DEC, NULL, 0x0,
1915 NULL, HFILL }
1918 { &hf_wisun_vhie,
1919 { "VH-IE", "wisun.vhie", FT_NONE, BASE_NONE, NULL, 0x0,
1920 "Vendor Header IE", HFILL }
1923 { &hf_wisun_vhie_vid,
1924 { "Vendor ID", "wisun.vhie.vid", FT_UINT16, BASE_DEC, NULL, 0x0,
1925 NULL, HFILL }
1928 { &hf_wisun_eaie,
1929 { "EA-IE", "wisun.eaie", FT_NONE, BASE_NONE, NULL, 0x0,
1930 "EAPOL Authenticator IE", HFILL }
1933 { &hf_wisun_eaie_eui,
1934 { "Authenticator EUI-64", "wisun.eaie.eui", FT_EUI64, BASE_NONE, NULL, 0x0,
1935 NULL, HFILL }
1938 { &hf_wisun_luttie,
1939 { "LUTT-IE", "wisun.luttie", FT_NONE, BASE_NONE, NULL, 0x0,
1940 "LFN Unicast Timing and Frame Type IE", HFILL }
1943 { &hf_wisun_luttie_usn,
1944 { "USN", "wisun.luttie.usn", FT_UINT16, BASE_DEC, NULL, 0x0,
1945 "Unicast Slot Number", HFILL }
1948 { &hf_wisun_luttie_uio,
1949 { "UIO", "wisun.luttie.uio", FT_UINT24, BASE_DEC, NULL, 0x0,
1950 "Unicast Interval Offset", HFILL }
1953 { &hf_wisun_lbtie,
1954 { "LBT-IE", "wisun.lbtie", FT_NONE, BASE_NONE, NULL, 0x0,
1955 "LFN Broadcast Timing IE", HFILL }
1958 { &hf_wisun_lbtie_slot,
1959 { "LFN BSN", "wisun.lbtie.slot", FT_UINT24, BASE_DEC, NULL, 0x0,
1960 "LFN Broadcast Slot Number", HFILL }
1963 { &hf_wisun_lbtie_bio,
1964 { "LFN BIO", "wisun.lbtie.bio", FT_UINT24, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0,
1965 "LFN Broadcast Interval Offset", HFILL }
1968 { &hf_wisun_nrie,
1969 { "NR-IE", "wisun.nrie", FT_NONE, BASE_NONE, NULL, 0x0,
1970 "Node Role IE", HFILL }
1973 { &hf_wisun_nrie_nr_id,
1974 { "Node Role ID", "wisun.nrie.nr_id", FT_UINT8, BASE_DEC, VALS(wisun_wsie_node_role_vals), WISUN_WSIE_NODE_ROLE_ID_MASK,
1975 NULL, HFILL }
1978 { &hf_wisun_nrie_reserved_bits,
1979 { "Reserved", "wisun.nrie.reserved", FT_UINT8, BASE_DEC, NULL, WISUN_WSIE_NODE_ROLE_ID_RESERVED,
1980 NULL, HFILL }
1983 { &hf_wisun_nrie_lbats,
1984 { "LBATS Implemented", "wisun.nrie.lbats", FT_BOOLEAN, 8, NULL, WISUN_WSIE_NODE_ROLE_LBATS_IMPLEMENTED,
1985 NULL, HFILL }
1988 { &hf_wisun_nrie_timing_accuracy,
1989 { "Timing Accuracy", "wisun.nrie.timing_accuracy", FT_UINT8, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0,
1990 NULL, HFILL }
1993 { &hf_wisun_nrie_listening_interval_min,
1994 { "Listening Interval Min", "wisun.nriw.listening_interval_min", FT_UINT24, BASE_DEC, NULL, 0x0,
1995 NULL, HFILL }
1998 { &hf_wisun_nrie_listening_interval_max,
1999 { "Listening Interval Max", "wisun.nriw.listening_interval_max", FT_UINT24, BASE_DEC, NULL, 0x0,
2000 NULL, HFILL }
2003 { &hf_wisun_lusie,
2004 { "LUS-IE", "wisun.lusie", FT_NONE, BASE_NONE, NULL, 0x0,
2005 "LFN Unicast Schedule IE", HFILL }
2008 { &hf_wisun_lusie_listen_interval,
2009 { "Listen Interval", "wisun.lusie.listen", FT_UINT24, BASE_DEC, NULL, 0x0,
2010 NULL, HFILL }
2013 { &hf_wisun_lusie_channel_plan_tag,
2014 { "Channel Plan Tag", "wisun.lusie.channeltag", FT_UINT8, BASE_DEC, NULL, 0x0,
2015 NULL, HFILL }
2018 { &hf_wisun_flusie,
2019 { "FLUS-IE", "wisun.flusie", FT_NONE, BASE_NONE, NULL, 0x0,
2020 "FFN for LFN Unicast Schedule IE", HFILL }
2023 { &hf_wisun_flusie_dwell_interval,
2024 { "Dwell Interval", "wisun.flusie.dwell", FT_UINT8, BASE_DEC, NULL, 0x0,
2025 NULL, HFILL }
2028 { &hf_wisun_flusie_channel_plan_tag,
2029 { "Channel Plan Tag", "wisun.flusie.channeltag", FT_UINT8, BASE_DEC, NULL, 0x0,
2030 NULL, HFILL }
2033 { &hf_wisun_lbsie,
2034 { "LBS-IE", "wisun.lbsie", FT_NONE, BASE_NONE, NULL, 0x0,
2035 "LFN Broadcast Schedule IE", HFILL }
2038 { &hf_wisun_lbsie_broadcast_interval,
2039 { "Broadcast Interval", "wisun.lbsie.broadcast", FT_UINT24, BASE_DEC, NULL, 0x0,
2040 NULL, HFILL }
2043 { &hf_wisun_lbsie_broadcast_id,
2044 { "Broadcast Schedule Identifier", "wisun.lbsie.broadcast_id", FT_UINT16, BASE_DEC, NULL, 0x0,
2045 NULL, HFILL }
2048 { &hf_wisun_lbsie_channel_plan_tag,
2049 { "Channel Plan Tag", "wisun.lbsie.channeltag", FT_UINT8, BASE_DEC, NULL, 0x0,
2050 NULL, HFILL }
2053 { &hf_wisun_lbsie_broadcast_sync_period,
2054 { "Broadcast Sync Period", "wisun.lbsie.broadcast_sync_period", FT_UINT8, BASE_DEC, NULL, 0x0,
2055 NULL, HFILL }
2058 { &hf_wisun_lndie,
2059 { "LFN Network Discovery IE", "wisun.lndie", FT_NONE, BASE_NONE, NULL, 0x0,
2060 NULL, HFILL }
2063 { &hf_wisun_lndie_response_threshold,
2064 { "Response Threshold", "wisun.lndie.response_threshold", FT_UINT8, BASE_DEC, NULL, 0x0,
2065 NULL, HFILL }
2068 { &hf_wisun_lndie_response_delay,
2069 { "Response Delay", "wisun.lndie.response_delay", FT_UINT24, BASE_DEC, NULL, 0x0,
2070 NULL, HFILL }
2073 { &hf_wisun_lndie_discovery_slot_time,
2074 { "Discovery Slot Time (DST)", "wisun.lndie.discovery_slot_time", FT_UINT8, BASE_DEC, NULL, 0x0,
2075 NULL, HFILL }
2078 { &hf_wisun_lndie_discovery_slots,
2079 { "Discovery Slots", "wisun.lndie.discovery_slots", FT_UINT8, BASE_DEC, NULL, 0x0,
2080 NULL, HFILL }
2083 { &hf_wisun_lndie_discovery_first_slot,
2084 { "Discovery First Slot", "wisun.lndie.discovery_first_slot", FT_UINT16, BASE_DEC, NULL, 0x0,
2085 NULL, HFILL }
2088 { &hf_wisun_ltoie,
2089 { "LTO-IE", "wisun.ltoie", FT_NONE, BASE_NONE, NULL, 0x0,
2090 "LFN Timing Offset IE", HFILL }
2093 { &hf_wisun_ltoie_offset,
2094 { "Offset", "wisun.ltoie.offset", FT_UINT24, BASE_DEC, NULL, 0x0,
2095 NULL, HFILL }
2098 { &hf_wisun_ltoie_listening_interval,
2099 { "Adjusted Listening Interval", "wisun.ltoie.listening_interval", FT_UINT24, BASE_DEC, NULL, 0x0,
2100 NULL, HFILL }
2103 { &hf_wisun_panidie,
2104 { "PANID-IE", "wisun.panidie", FT_NONE, BASE_NONE, NULL, 0x0,
2105 "PAN Identifier IE", HFILL }
2108 { &hf_wisun_panidie_panid,
2109 { "PAN Identifier", "wisun.panidie.panid", FT_UINT16, BASE_DEC, NULL, 0x0,
2110 NULL, HFILL }
2113 { &hf_wisun_rtie,
2114 { "Rendezvous Time IE", "wisun.rtie", FT_NONE, BASE_NONE, NULL, 0x0,
2115 NULL, HFILL }
2118 { &hf_wisun_rtie_rendezvous_time,
2119 { "Rendezvous Time", "wisun.rtie.rendezvous", FT_UINT16, BASE_DEC, NULL, 0x0,
2120 NULL, HFILL }
2123 { &hf_wisun_rtie_wakeup_interval,
2124 { "Wake-up Interval", "wisun.rtie.wakeup", FT_UINT16, BASE_DEC, NULL, 0x0,
2125 NULL, HFILL }
2128 { &hf_wisun_lbcie,
2129 { "LFN Broadcast Configuration IE", "wisun.lbcie", FT_NONE, BASE_NONE, NULL, 0x0,
2130 NULL, HFILL }
2133 { &hf_wisun_lbcie_broadcast_interval,
2134 { "Broadcast Interval", "wisun.lbcie.broadcast", FT_UINT24, BASE_DEC, NULL, 0x0,
2135 NULL, HFILL }
2138 { &hf_wisun_lbcie_broadcast_sync_period,
2139 { "Broadcast Sync Period", "wisun.lbcie.broadcast_sync_period", FT_UINT8, BASE_DEC, NULL, 0x0,
2140 NULL, HFILL }
2143 /* Wi-SUN Payload IE */
2144 { &hf_wisun_pie,
2145 { "Wi-SUN Payload IE", "wisun.pie", FT_NONE, BASE_NONE, NULL, 0x0,
2146 NULL, HFILL }
2149 { &hf_wisun_wsie,
2150 { "Wi-SUN Sub IE", "wisun.wsie", FT_UINT16, BASE_HEX, NULL, 0x0,
2151 NULL, HFILL }
2154 { &hf_wisun_wsie_type,
2155 { "Type", "wisun.wsie.type", FT_UINT16, BASE_DEC, VALS(wisun_wsie_types), IEEE802154_PSIE_TYPE_MASK,
2156 NULL, HFILL }
2159 { &hf_wisun_wsie_id,
2160 { "Sub ID", "wisun.wsie.id", FT_UINT16, BASE_HEX, VALS(wisun_wsie_names), IEEE802154_PSIE_ID_MASK_LONG,
2161 NULL, HFILL }
2164 { &hf_wisun_wsie_length,
2165 { "Length", "wisun.wsie.length", FT_UINT16, BASE_DEC, NULL, IEEE802154_PSIE_LENGTH_MASK_LONG,
2166 NULL, HFILL }
2169 { &hf_wisun_wsie_id_short,
2170 { "Sub ID", "wisun.wsie.id", FT_UINT16, BASE_HEX, VALS(wisun_wsie_names_short), IEEE802154_PSIE_ID_MASK_SHORT,
2171 NULL, HFILL }
2174 { &hf_wisun_wsie_length_short,
2175 { "Length", "wisun.wsie.length", FT_UINT16, BASE_DEC, NULL, IEEE802154_PSIE_LENGTH_MASK_SHORT,
2176 NULL, HFILL }
2179 { &hf_wisun_usie,
2180 { "Unicast Schedule IE", "wisun.usie", FT_NONE, BASE_NONE, NULL, 0x0,
2181 NULL, HFILL }
2184 { &hf_wisun_usie_dwell_interval,
2185 { "Dwell Interval", "wisun.usie.dwell", FT_UINT8, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0,
2186 NULL, HFILL }
2189 { &hf_wisun_usie_clock_drift,
2190 { "Clock Drift", "wisun.usie.drift", FT_UINT8, BASE_DEC|BASE_SPECIAL_VALS, VALS(wisun_usie_clock_drift_names), 0x0,
2191 "Clock Drift in +/- ppm", HFILL }
2194 { &hf_wisun_usie_timing_accuracy,
2195 { "Timing Accuracy", "wisun.usie.accuracy", FT_UINT8, BASE_DEC, NULL, 0x0,
2196 NULL, HFILL }
2199 { &hf_wisun_usie_channel_control,
2200 { "Channel Control", "wisun.usie.channel", FT_UINT8, BASE_HEX, NULL, 0x0,
2201 NULL, HFILL }
2204 { &hf_wisun_usie_channel_plan,
2205 { "Channel Plan", "wisun.usie.channel.plan", FT_UINT8, BASE_DEC, VALS(wisun_channel_plan_names), WISUN_CHANNEL_PLAN,
2206 NULL, HFILL }
2209 { &hf_wisun_usie_channel_function,
2210 { "Channel Function", "wisun.usie.channel.function", FT_UINT8, BASE_DEC, VALS(wisun_channel_function_names), WISUN_CHANNEL_FUNCTION,
2211 NULL, HFILL }
2214 { &hf_wisun_usie_channel_exclude,
2215 { "Excluded Channels", "wisun.usie.channel.exclude", FT_UINT8, BASE_DEC, VALS(wisun_channel_exclude_names), WISUN_CHANNEL_EXCLUDE,
2216 NULL, HFILL }
2219 { &hf_wisun_usie_regulatory_domain,
2220 { "Regulatory Domain", "wisun.usie.domain", FT_UINT8, BASE_DEC, VALS(wisun_channel_regulatory_domains_names), 0x0,
2221 NULL, HFILL }
2224 { &hf_wisun_usie_operating_class,
2225 { "Operating Class", "wisun.usie.class", FT_UINT8, BASE_DEC, NULL, 0x0,
2226 NULL, HFILL }
2229 { &hf_wisun_usie_channel_plan_id,
2230 { "Channel Plan ID", "wisun.usie.channel_plan_id", FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(wisun_channel_plan_id_names), 0x0,
2231 NULL, HFILL }
2234 { &hf_wisun_usie_explicit,
2235 { "Explicit Channel Plan", "wisun.usie.explicit", FT_UINT32, BASE_HEX, NULL, 0x0,
2236 NULL, HFILL }
2239 { &hf_wisun_usie_explicit_frequency,
2240 { "CH0 Frequency", "wisun.usie.explicit.frequency", FT_UINT32, BASE_DEC|BASE_UNIT_STRING, UNS(&units_khz), WISUN_CH_PLAN_EXPLICIT_FREQ,
2241 NULL, HFILL }
2244 { &hf_wisun_usie_explicit_reserved,
2245 { "Reserved", "wisun.usie.explicit.reserved", FT_UINT32, BASE_DEC, NULL, WISUN_CH_PLAN_EXPLICIT_RESERVED,
2246 NULL, HFILL }
2249 { &hf_wisun_usie_explicit_spacing,
2250 { "Channel Spacing", "wisun.usie.explicit.spacing", FT_UINT32, BASE_DEC, VALS(wisun_channel_spacing_names), WISUN_CH_PLAN_EXPLICIT_SPACING,
2251 NULL, HFILL }
2254 { &hf_wisun_usie_number_channels,
2255 { "Number of Channels", "wisun.usie.num_channels", FT_UINT16, BASE_DEC, NULL, 0x0,
2256 NULL, HFILL }
2259 { &hf_wisun_usie_fixed_channel,
2260 { "Fixed Channel", "wisun.usie.fixed_channel", FT_UINT16, BASE_DEC, NULL, 0x0,
2261 NULL, HFILL }
2264 { &hf_wisun_usie_hop_count,
2265 { "Channel Hop Count", "wisun.usie.hop_count", FT_UINT8, BASE_DEC, NULL, 0x0,
2266 NULL, HFILL }
2269 { &hf_wisun_usie_hop_list,
2270 { "Channel Hop List", "wisun.usie.hop_list", FT_UINT8, BASE_DEC, NULL, 0x0,
2271 NULL, HFILL }
2274 { &hf_wisun_usie_number_ranges,
2275 { "Number of Excluded Ranges", "wisun.usie.num_ranges", FT_UINT8, BASE_DEC, NULL, 0x0,
2276 NULL, HFILL }
2279 { &hf_wisun_usie_exclude_range_start,
2280 { "Excluded Channel Range Start", "wisun.usie.exclude.range.start", FT_UINT16, BASE_DEC, NULL, 0x0,
2281 NULL, HFILL }
2284 { &hf_wisun_usie_exclude_range_end,
2285 { "Excluded Channel Range End", "wisun.usie.exclude.range.end", FT_UINT16, BASE_DEC, NULL, 0x0,
2286 NULL, HFILL }
2289 { &hf_wisun_usie_exclude_mask,
2290 { "Excluded Channel Mask", "wisun.usie.exclude.mask", FT_BYTES, BASE_NONE, NULL, 0x0,
2291 NULL, HFILL }
2294 { &hf_wisun_bsie,
2295 { "BS-IE", "wisun.bsie", FT_NONE, BASE_NONE, NULL, 0x0,
2296 "Broadcast Schedule IE", HFILL }
2299 { &hf_wisun_bsie_bcast_interval,
2300 { "Broadcast Interval", "wisun.bsie.interval", FT_UINT32, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0,
2301 NULL, HFILL }
2304 { &hf_wisun_bsie_bcast_schedule_id,
2305 { "Broadcast Schedule ID", "wisun.bsie.schedule", FT_UINT16, BASE_DEC, NULL, 0x0,
2306 NULL, HFILL }
2309 { &hf_wisun_vpie,
2310 { "Vendor Payload IE", "wisun.vpie", FT_NONE, BASE_NONE, NULL, 0x0,
2311 NULL, HFILL }
2314 { &hf_wisun_vpie_vid,
2315 { "Vendor ID", "wisun.vpie.vid", FT_UINT16, BASE_DEC, NULL, 0x0,
2316 NULL, HFILL }
2319 { &hf_wisun_lcpie,
2320 { "LCP-IE", "wisun.lcpie", FT_NONE, BASE_NONE, NULL, 0x0,
2321 "LFN Channel Plan IE", HFILL }
2324 { &hf_wisun_panie,
2325 { "PAN-IE", "wisun.panie", FT_NONE, BASE_NONE, NULL, 0x0,
2326 "PAN Information IE", HFILL }
2329 { &hf_wisun_panie_size,
2330 { "PAN Size", "wisun.panie.size", FT_UINT16, BASE_DEC, NULL, 0x0,
2331 NULL, HFILL }
2334 { &hf_wisun_panie_cost,
2335 { "Routing Cost", "wisun.panie.cost", FT_UINT16, BASE_DEC, NULL, 0x0,
2336 NULL, HFILL }
2339 { &hf_wisun_panie_flags,
2340 { "PAN Flags", "wisun.panie.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
2341 NULL, HFILL }
2344 { &hf_wisun_panie_flag_parent_bsie,
2345 { "Use Parent BS-IE", "wisun.panie.flags.parent_bsie", FT_BOOLEAN, 8, NULL, 0x01,
2346 NULL, HFILL }
2349 { &hf_wisun_panie_flag_routing_method,
2350 { "Routing Method", "wisun.panie.flags.routing_method", FT_UINT8, BASE_HEX, VALS(wisun_routing_methods), 0x02,
2351 NULL, HFILL }
2354 { &hf_wisun_panie_flag_lfn_window_style,
2355 { "LFN Window Style", "wisun.panie.flags.lfn_window_style", FT_UINT8, BASE_DEC, VALS(wisun_window_style), 0x04,
2356 NULL, HFILL }
2359 { &hf_wisun_panie_flag_version,
2360 { "FAN TPS Version", "wisun.panie.flags.version", FT_UINT8, BASE_DEC, NULL, 0xe0,
2361 NULL, HFILL }
2364 { &hf_wisun_netnameie,
2365 { "Network Name IE", "wisun.netnameie", FT_NONE, BASE_NONE, NULL, 0x0,
2366 NULL, HFILL }
2369 { &hf_wisun_netnameie_name,
2370 { "Network Name", "wisun.netnameie.name", FT_STRING, BASE_NONE, NULL, 0x0,
2371 NULL, HFILL }
2374 { &hf_wisun_panverie,
2375 { "PAN Version IE", "wisun.panverie", FT_NONE, BASE_NONE, NULL, 0x0,
2376 NULL, HFILL }
2379 { &hf_wisun_panverie_version,
2380 { "PAN Version", "wisun.panverie.version", FT_UINT16, BASE_DEC, NULL, 0x0,
2381 NULL, HFILL }
2384 { &hf_wisun_gtkhashie,
2385 { "GTK Hash IE", "wisun.gtkhashie", FT_NONE, BASE_NONE, NULL, 0x0,
2386 NULL, HFILL }
2389 { &hf_wisun_gtkhashie_gtk0,
2390 { "GTK0 Hash", "wisun.gtkhashie.gtk0", FT_BYTES, BASE_NONE, NULL, 0x0,
2391 NULL, HFILL }
2394 { &hf_wisun_gtkhashie_gtk1,
2395 { "GTK1 Hash", "wisun.gtkhashie.gtk1", FT_BYTES, BASE_NONE, NULL, 0x0,
2396 NULL, HFILL }
2399 { &hf_wisun_gtkhashie_gtk2,
2400 { "GTK2 Hash", "wisun.gtkhashie.gtk2", FT_BYTES, BASE_NONE, NULL, 0x0,
2401 NULL, HFILL }
2404 { &hf_wisun_gtkhashie_gtk3,
2405 { "GTK3 Hash", "wisun.gtkhashie.gtk3", FT_BYTES, BASE_NONE, NULL, 0x0,
2406 NULL, HFILL }
2409 { &hf_wisun_pomie,
2410 { "POM-IE", "wisun.pomie", FT_NONE, BASE_NONE, NULL, 0x0,
2411 "PHY Operating Modes IE", HFILL }
2414 { &hf_wisun_pomie_hdr,
2415 { "PHY Operating Modes Header", "wisun.pomie.hdr", FT_UINT8, BASE_HEX | BASE_NO_DISPLAY_VALUE, NULL, 0x0,
2416 NULL, HFILL }
2419 { &hf_wisun_pomie_number_operating_modes,
2420 { "Number of PHY Operating Modes", "wisun.pomie.number_operating_modes", FT_UINT8, BASE_DEC, NULL, 0x0F,
2421 NULL, HFILL }
2424 { &hf_wisun_pomie_mdr_command_capable_flag,
2425 { "MDR Command Capable Flag", "wisun.pomie.mdr_command_capable_flag", FT_UINT8, BASE_DEC, NULL, 0x10,
2426 NULL, HFILL }
2429 { &hf_wisun_pomie_reserved,
2430 { "Reserved", "wisun.pomie.reserved", FT_UINT8, BASE_DEC, NULL, 0xE0,
2431 NULL, HFILL }
2434 { &hf_wisun_pomie_phy_mode_id,
2435 { "PHY Operating Modes ID", "wisun.pomie.phy_mode_id", FT_UINT8, BASE_HEX | BASE_NO_DISPLAY_VALUE, NULL, 0x0,
2436 NULL, HFILL }
2439 { &hf_wisun_pomie_phy_type,
2440 { "PHY Type", "wisun.pomie.phy_type", FT_UINT8, BASE_HEX, VALS(wisun_phy_type_vals), WISUN_PIE_PHY_TYPE,
2441 NULL, HFILL }
2444 { &hf_wisun_pomie_phy_mode_fsk,
2445 { "PHY Mode FSK", "wisun.pomie.phy_mode_fsk", FT_UINT8, BASE_HEX | BASE_RANGE_STRING, RVALS(wisun_phy_mode_fsk_vals), WISUN_PIE_PHY_OPERATING_MODES_MASK,
2446 NULL, HFILL }
2449 { &hf_wisun_pomie_phy_mode_ofdm,
2450 { "PHY Mode OFDM", "wisun.pomie.phy_mode_ofdm", FT_UINT8, BASE_HEX | BASE_RANGE_STRING, RVALS(wisun_phy_mode_ofdm_vals), WISUN_PIE_PHY_OPERATING_MODES_MASK,
2451 NULL, HFILL }
2454 { &hf_wisun_lfnverie,
2455 { "LFN Version IE", "wisun.lfnverie", FT_NONE, BASE_NONE, NULL, 0x0,
2456 NULL, HFILL }
2459 { &hf_wisun_lfnverie_version,
2460 { "LFN Version", "wisun.lfnverie.version", FT_UINT16, BASE_DEC, NULL, 0x0,
2461 NULL, HFILL }
2464 { &hf_wisun_lgtkhashie,
2465 { "LFN GTK Hash IE", "wisun.lgtkhashie", FT_NONE, BASE_NONE, NULL, 0x0,
2466 NULL, HFILL }
2469 { &hf_wisun_lgtkhashie_flags,
2470 { "LFN GTK Hash Flags", "wisun.lgtkhashie.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
2471 NULL, HFILL }
2474 { &hf_wisun_lgtkhashie_flag_includes_lgtk0,
2475 { "LFN GTK Hash Flag Includes LGTK0", "wisun.lgtkhashie.flag.includes_lgtk0", FT_BOOLEAN, 8, NULL, 0x01,
2476 NULL, HFILL }
2479 { &hf_wisun_lgtkhashie_flag_includes_lgtk1,
2480 { "LFN GTK Hash Flag Includes LGTK1", "wisun.lgtkhashie.flag.includes_lgtk1", FT_BOOLEAN, 8, NULL, 0x02,
2481 NULL, HFILL }
2484 { &hf_wisun_lgtkhashie_flag_includes_lgtk2,
2485 { "LFN GTK Hash Flag Includes LGTK2", "wisun.lgtkhashie.flag.includes_lgtk2", FT_BOOLEAN, 8, NULL, 0x04,
2486 NULL, HFILL }
2489 { &hf_wisun_lgtkhashie_flag_active_lgtk_index,
2490 { "LFN GTK Hash Flag Active LGTK Index", "wisun.lgtkhashie.flag.active_lgtk_index", FT_UINT8, BASE_DEC, NULL, 0x18,
2491 NULL, HFILL }
2494 { &hf_wisun_lgtkhashie_gtk0,
2495 { "LGTK0 Hash", "wisun.lgtkhashie.lgtk0", FT_BYTES, BASE_NONE, NULL, 0x0,
2496 NULL, HFILL }
2499 { &hf_wisun_lgtkhashie_gtk1,
2500 { "LGTK1 Hash", "wisun.lgtkhashie.lgtk1", FT_BYTES, BASE_NONE, NULL, 0x0,
2501 NULL, HFILL }
2504 { &hf_wisun_lgtkhashie_gtk2,
2505 { "LGTK2 Hash", "wisun.lgtkhashie.lgtk2", FT_BYTES, BASE_NONE, NULL, 0x0,
2506 NULL, HFILL }
2509 { &hf_wisun_lbatsie,
2510 { "LBATS-IE", "wisun.lbatsie", FT_NONE, BASE_NONE, NULL, 0x0,
2511 "LFN Broadcast Additional Transmit Schedule IE", HFILL }
2514 { &hf_wisun_lbatsie_additional_tx,
2515 { "Additional Transmissions", "wisun.lbatsie.additional_tx", FT_UINT8, BASE_DEC, NULL, 0x0,
2516 NULL, HFILL }
2519 { &hf_wisun_lbatsie_next_tx_delay,
2520 { "Next Transmit Delay", "wisun.lbatsie.next_tx_delay", FT_UINT16, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0,
2521 NULL, HFILL }
2524 { &hf_wisun_jmie,
2525 { "JM-IE", "wisun.jmie", FT_NONE, BASE_NONE, NULL, 0x0,
2526 "Join Metrics IE", HFILL }
2529 { &hf_wisun_jmie_version,
2530 { "Content Version", "wisun.jmie.version", FT_UINT8, BASE_DEC, NULL, 0x0,
2531 NULL, HFILL }
2534 { &hf_wisun_jmie_metric_hdr,
2535 { "Metric Header", "wisun.jmie.metric.hdr", FT_UINT8, BASE_HEX, NULL, 0x0,
2536 NULL, HFILL }
2539 { &hf_wisun_jmie_metric_id,
2540 { "Metric ID", "wisun.jmie.metric.id", FT_UINT8, BASE_DEC, VALS(wisun_metric_id), WISUN_PIE_JM_ID_MASK,
2541 NULL, HFILL }
2544 { &hf_wisun_jmie_metric_len,
2545 { "Metric Length", "wisun.jmie.metric.len", FT_UINT8, BASE_DEC, VALS(wisun_metric_len), WISUN_PIE_JM_LEN_MASK,
2546 NULL, HFILL }
2549 { &hf_wisun_jmie_metric_plf,
2550 { "JM-PLF", "wisun.jmie.metric.plf", FT_NONE, BASE_NONE, NULL, 0x0,
2551 NULL, HFILL }
2554 { &hf_wisun_jmie_metric_plf_data,
2555 { "PAN Load Factor", "wisun.jmie.metric.plf.data", FT_UINT8, BASE_DEC|BASE_UNIT_STRING, UNS(&units_percent), 0x0,
2556 NULL, HFILL }
2559 { &hf_wisun_jmie_metric_unknown,
2560 { "Unknown Metric", "wisun.jmie.metric.unknown", FT_NONE, BASE_NONE, NULL, 0x0,
2561 NULL, HFILL }
2564 /* Wi-SUN FAN Security Extension */
2565 { &hf_wisun_sec_function,
2566 { "Function Code", "wisun.sec.function", FT_UINT8, BASE_HEX, VALS(wisun_sec_functions), 0x0,
2567 NULL, HFILL }
2570 { &hf_wisun_sec_error_type,
2571 { "Error Type", "wisun.sec.error", FT_UINT8, BASE_HEX, VALS(wisun_sec_sm_errors), 0x0,
2572 NULL, HFILL }
2575 { &hf_wisun_sec_error_nonce,
2576 { "Initiator Nonce", "wisun.sec.nonce", FT_BYTES, BASE_NONE, NULL, 0x0,
2577 NULL, HFILL }
2580 /* EAPOL Relay */
2581 { &hf_wisun_eapol_relay_sup,
2582 { "SUP EUI-64", "wisun.eapol_relay.sup", FT_EUI64, BASE_NONE, NULL, 0x0,
2583 NULL, HFILL }},
2585 { &hf_wisun_eapol_relay_kmp_id,
2586 { "KMP ID", "wisun.eapol_relay.kmp_id", FT_UINT8, BASE_DEC, VALS(ieee802154_mpx_kmp_id_vals), 0x0,
2587 NULL, HFILL }},
2589 { &hf_wisun_eapol_relay_direction,
2590 { "Direction", "wisun.eapol_relay.direction", FT_BOOLEAN, BASE_NONE, TFS(&tfs_up_down), 0x0,
2591 NULL, HFILL }},
2593 { &hf_wisun_cmd_subid,
2594 { "Command Sub-ID", "wisun.cmd", FT_UINT8, BASE_DEC, VALS(wisun_cmd_vals), 0x0,
2595 "Wi-SUN MAC Command Sub-ID", HFILL }},
2597 { &hf_wisun_cmd_mdr_phy_mode_id,
2598 { "PHY Mode ID", "wisun.cmd.mdr.phy_mode_id", FT_UINT8, BASE_DEC, NULL, 0x0,
2599 NULL, HFILL }},
2601 { &hf_wisun_cmd_mdr_phy_type,
2602 { "PHY Type", "wisun.cmd.mdr.phy_type", FT_UINT8, BASE_HEX, VALS(wisun_phy_type_vals), WISUN_PIE_PHY_TYPE,
2603 NULL, HFILL }
2606 { &hf_wisun_cmd_mdr_phy_mode_fsk,
2607 { "PHY Mode FSK", "wisun.cmd.mdr.phy_mode_fsk", FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(wisun_phy_mode_fsk_vals), WISUN_PIE_PHY_OPERATING_MODES_MASK,
2608 NULL, HFILL }
2611 { &hf_wisun_cmd_mdr_phy_mode_ofdm,
2612 { "PHY Mode OFDM", "wisun.cmd.mdr.phy_mode_ofdm", FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(wisun_phy_mode_ofdm_vals), WISUN_PIE_PHY_OPERATING_MODES_MASK,
2613 NULL, HFILL }
2616 /* Wi-SUN Netricity */
2617 { &hf_wisun_netricity_nftie,
2618 { "Netricity Frame Type IE", "wisun.netricity.nftie", FT_NONE, BASE_NONE, NULL, 0x0,
2619 NULL, HFILL }
2622 { &hf_wisun_netricity_nftie_type,
2623 { "Frame Type", "wisun.netricity.nftie.type", FT_UINT8, BASE_DEC, VALS(wisun_frame_type_vals), 0x0,
2624 NULL, HFILL }
2627 { &hf_wisun_netricity_lqiie,
2628 { "Link Quality Index IE", "wisun.netricity.lqiie", FT_NONE, BASE_NONE, NULL, 0x0,
2629 NULL, HFILL }
2632 { &hf_wisun_netricity_lqiie_lqi,
2633 { "Link Quality Index", "wisun.netricity.lqiie.lqi", FT_UINT8, BASE_DEC, NULL, 0x0,
2634 NULL, HFILL }
2637 /* Wi-SUN Netricity Segment Control Field and reassembly */
2638 { &hf_wisun_netricity_sc_flags,
2639 { "Segment Control", "wisun.netricity.sc.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
2640 NULL, HFILL }
2642 { &hf_wisun_netricity_sc_reserved,
2643 { "Reserved", "wisun.netricity.sc.reserved", FT_UINT8, BASE_DEC, NULL, 0xf0,
2644 NULL, HFILL }
2646 { &hf_wisun_netricity_sc_tone_map_request,
2647 { "Tone Map Request", "wisun.netricity.sc.tone_map_request", FT_BOOLEAN, 8, NULL, 1<<3,
2648 NULL, HFILL }
2650 { &hf_wisun_netricity_sc_contention_control,
2651 { "Contention Control", "wisun.netricity.sc.contention_control", FT_BOOLEAN, 8, TFS(&wisun_netricity_sc_contention_control_tfs), 1<<2,
2652 NULL, HFILL }
2654 { &hf_wisun_netricity_sc_channel_access_priority,
2655 { "Channel access priority", "wisun.netricity.sc.channel_access_priority", FT_BOOLEAN, 8, TFS(&tfs_high_normal), 1<<1,
2656 NULL, HFILL }
2658 { &hf_wisun_netricity_sc_last_segment,
2659 { "Last Segment", "wisun.netricity.sc.last_segment", FT_BOOLEAN, 8, NULL, 1<<0,
2660 NULL, HFILL }
2662 { &hf_wisun_netricity_sc_segment_count,
2663 { "Segment Count", "wisun.netricity.sc.segment_count", FT_UINT16, BASE_DEC, NULL, 0xfc00,
2664 NULL, HFILL }
2666 { &hf_wisun_netricity_sc_segment_length,
2667 { "Segment Length", "wisun.netricity.sc.segment_length", FT_UINT16, BASE_DEC, NULL, 0x03ff,
2668 NULL, HFILL }
2671 { &hf_wisun_netricity_scr_segments,
2672 { "Message segments", "wisun.netricity.scr.segments",
2673 FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }
2675 { &hf_wisun_netricity_scr_segment,
2676 { "Message segment", "wisun.netricity.scr.segment",
2677 FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL }
2679 { &hf_wisun_netricity_scr_segment_overlap,
2680 { "Message segment overlap", "wisun.netricity.scr.segment.overlap",
2681 FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL }
2683 { &hf_wisun_netricity_scr_segment_overlap_conflicts,
2684 { "Message segment overlapping with conflicting data", "wisun.netricity.scr.segment.overlap.conflicts",
2685 FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL }
2687 { &hf_wisun_netricity_scr_segment_multiple_tails,
2688 { "Message has multiple tail segments", "wisun.netricity.scr.segment.multiple_tails",
2689 FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL }
2691 { &hf_wisun_netricity_scr_segment_too_long_segment,
2692 { "Message segment too long", "wisun.netricity.scr.segment.too_long_segment",
2693 FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL }
2695 { &hf_wisun_netricity_scr_segment_error,
2696 { "Message segment reassembly error", "wisun.netricity.scr.segment.error",
2697 FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL }
2699 { &hf_wisun_netricity_scr_segment_count,
2700 { "Message segment count", "wisun.netricity.scr.segment.count",
2701 FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }
2703 { &hf_wisun_netricity_scr_reassembled_in,
2704 { "Reassembled in", "wisun.netricity.scr.reassembled.in",
2705 FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL }
2707 { &hf_wisun_netricity_scr_reassembled_length,
2708 { "Reassembled length", "wisun.netricity.scr.reassembled.length",
2709 FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }
2715 /* Subtrees */
2716 static int *ett[] = {
2717 &ett_wisun_phy_mode_id,
2718 &ett_wisun_unknown_ie,
2719 &ett_wisun_uttie,
2720 &ett_wisun_btie,
2721 &ett_wisun_fcie,
2722 &ett_wisun_rslie,
2723 &ett_wisun_vhie,
2724 &ett_wisun_eaie,
2725 &ett_wisun_pie,
2726 &ett_wisun_wsie_bitmap,
2727 &ett_wisun_usie,
2728 &ett_wisun_bsie,
2729 &ett_wisun_vpie,
2730 &ett_wisun_lcpie,
2731 &ett_wisun_usie_channel_control,
2732 &ett_wisun_usie_explicit,
2733 &ett_wisun_panie,
2734 &ett_wisun_panie_flags,
2735 &ett_wisun_netnameie,
2736 &ett_wisun_panverie,
2737 &ett_wisun_pomie,
2738 &ett_wisun_pomie_hdr,
2739 &ett_wisun_gtkhashie,
2740 &ett_wisun_lfnverie,
2741 &ett_wisun_lgtkhashie,
2742 &ett_wisun_lgtkhashie_flags,
2743 &ett_wisun_lbatsie,
2744 &ett_wisun_jmie,
2745 &ett_wisun_jmie_metric_hdr,
2746 &ett_wisun_jmie_metric_plf,
2747 &ett_wisun_jmie_metric_unknown,
2748 &ett_wisun_sec,
2749 &ett_wisun_eapol_relay,
2750 &ett_wisun_netricity_nftie,
2751 &ett_wisun_netricity_lqiie,
2752 &ett_wisun_netricity_sc,
2753 &ett_wisun_netricity_sc_bitmask,
2754 &ett_wisun_netricity_scr_segment,
2755 &ett_wisun_netricity_scr_segments,
2756 &ett_wisun_luttie,
2757 &ett_wisun_nrie,
2758 &ett_wisun_lusie,
2759 &ett_wisun_flusie,
2760 &ett_wisun_lbsie,
2761 &ett_wisun_lndie,
2762 &ett_wisun_ltoie,
2763 &ett_wisun_panidie,
2764 &ett_wisun_rtie,
2765 &ett_wisun_lbcie,
2768 static ei_register_info ei[] = {
2769 { &ei_wisun_subid_unsupported, { "wisun.subid.unsupported", PI_PROTOCOL, PI_WARN,
2770 "Unsupported Header Sub ID", EXPFILL }},
2771 { &ei_wisun_usie_channel_plan_invalid, { "wisun.usie.channel.plan.invalid", PI_PROTOCOL, PI_WARN,
2772 "Invalid Channel Plan", EXPFILL }},
2773 { &ei_wisun_wsie_unsupported, { "wisun.wsie.unsupported", PI_PROTOCOL, PI_WARN,
2774 "Unsupported Sub-IE ID", EXPFILL }},
2775 { &ei_wisun_edfe_start_not_found, { "wisun.edfe.start_not_found", PI_SEQUENCE, PI_WARN,
2776 "EDFE Transfer: start frame not found", EXPFILL }},
2777 { &ei_wisun_usie_explicit_reserved_bits_not_zero, { "wisun.usie.explicit.reserved.invalid", PI_MALFORMED, PI_ERROR,
2778 "Reserved bits not zero", EXPFILL }},
2779 { &ei_wisun_nrie_reserved_bits_not_zero, { "wisun.nrie.reserved.invalid", PI_MALFORMED, PI_ERROR,
2780 "Reserved bits not zero", EXPFILL }},
2781 { &ei_wisun_jmie_metric_unsupported, { "wisun.jmie.metric.unsupported", PI_PROTOCOL, PI_WARN,
2782 "Unsupported Metric ID", EXPFILL }},
2785 expert_module_t* expert_wisun;
2787 proto_wisun = proto_register_protocol("Wi-SUN Field Area Network", "Wi-SUN", "wisun");
2788 proto_wisun_sec = proto_register_protocol("Wi-SUN FAN Security Extension", "Wi-SUN WM-SEC", "wisun.sec");
2789 proto_wisun_eapol_relay = proto_register_protocol("Wi-SUN FAN EAPOL Relay", "Wi-SUN EAPOL Relay", "wisun.eapol_relay");
2790 proto_wisun_netricity_sc = proto_register_protocol("Wi-SUN Netricity Segment", "Wi-SUN Netricity Segment", "wisun.netricity.sc");
2792 proto_register_field_array(proto_wisun, hf, array_length(hf));
2793 proto_register_subtree_array(ett, array_length(ett));
2795 expert_wisun = expert_register_protocol(proto_wisun);
2796 expert_register_field_array(expert_wisun, ei, array_length(ei));
2798 register_dissector("wisun.sec", dissect_wisun_sec, proto_wisun_sec);
2800 edfe_byaddr = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_int64_hash, g_int64_equal);
2802 wisun_eapol_relay_handle = register_dissector("wisun.eapol_relay", dissect_wisun_eapol_relay, proto_wisun_eapol_relay);
2804 register_dissector("wisun.netricity.sc", dissect_wisun_netricity_sc, proto_wisun_netricity_sc);
2805 reassembly_table_register(&netricity_reassembly_table, &addresses_reassembly_table_functions);
2807 vhie_dissector_table = register_dissector_table("wisun.vhie.vid", "Wi-SUN Vendor Header IEs",
2808 proto_wisun, FT_UINT16, BASE_DEC);
2809 vpie_dissector_table = register_dissector_table("wisun.vpie.vid", "Wi-SUN Vendor Payload IEs",
2810 proto_wisun, FT_UINT16, BASE_DEC);
2813 void proto_reg_handoff_wisun(void)
2815 dissector_add_uint(IEEE802154_HEADER_IE_DTABLE, IEEE802154_HEADER_IE_WISUN, create_dissector_handle(dissect_wisun_hie, proto_wisun));
2816 dissector_add_uint(IEEE802154_PAYLOAD_IE_DTABLE, IEEE802154_PAYLOAD_IE_WISUN, create_dissector_handle(dissect_wisun_pie, proto_wisun));
2817 dissector_add_uint(IEEE802154_CMD_VENDOR_DTABLE, OUI_WISUN, create_dissector_handle(dissect_wisun_cmd, proto_wisun));
2819 oid_add_from_string("id-kp-wisun-fan-device", "1.3.6.1.4.1.45605.1");
2821 // For EAPOL relay
2822 dissector_add_uint("udp.port", WISUN_EAPOL_RELAY_UDP_PORT, wisun_eapol_relay_handle);
2823 eapol_handle = find_dissector("eapol");
2825 // For Netricity reassembly
2826 ieee802154_nofcs_handle = find_dissector("wpan_nofcs");
2830 * Editor modelines - https://www.wireshark.org/tools/modelines.html
2832 * Local variables:
2833 * c-basic-offset: 4
2834 * tab-width: 8
2835 * indent-tabs-mode: nil
2836 * End:
2838 * vi: set shiftwidth=4 tabstop=8 expandtab:
2839 * :indentSize=4:tabSize=8:noTabs=true: