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