summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-waveagent.c
blob: 4f872f07657d44f48193c2b4617b4db5d2316a17 (plain)
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
/* packet-waveagent.c
 * Routines for WaveAgent dissection
 * Copyright 2009-2011, Tom Cook <tcook@ixiacom.com>
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 * *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "config.h"

#include <epan/packet.h>
#define ETHERNET_INTERFACE      1
#define WLAN_INTERFACE          2

#define IPV4_TYPE               2
#define IPV6_TYPE               10

#define NUM_STATE_CHANGES       8
#define NUM_BSS                 8
#define SHORT_STR               256

#define WA_V2_PAYLOAD_OFFSET    40
#define WA_V3_PAYLOAD_OFFSET    44

void proto_register_waveagent(void);
void proto_reg_handoff_waveagent(void);

/* Initialize the protocol and registered fields */
static int proto_waveagent;
static int hf_waveagent_controlword;
static int hf_waveagent_payloadlen;
static int hf_waveagent_transnum;
static int hf_waveagent_rtoken;
static int hf_waveagent_flowid;
static int hf_waveagent_capstatus;
static int hf_waveagent_protocolversion;
static int hf_waveagent_capimpl;
static int hf_waveagent_id;
static int hf_waveagent_bindtag;
static int hf_waveagent_version;
static int hf_waveagent_brokerip;
static int hf_waveagent_brokerport;
static int hf_waveagent_bindlevel;
static int hf_waveagent_bindport;
static int hf_waveagent_numinterfaces;
static int hf_waveagent_capabilities2;
static int hf_waveagent_ifmask;
static int hf_waveagent_commandstatus;
static int hf_waveagent_syserrno;
static int hf_waveagent_statusstring;
static int hf_waveagent_rxdatapckts;
static int hf_waveagent_rxdatabytes;
static int hf_waveagent_rxpcktrate;
static int hf_waveagent_rxbyterate;
static int hf_waveagent_txdatapckts;
static int hf_waveagent_txdatabytes;
static int hf_waveagent_txpcktrate;
static int hf_waveagent_txbyterate;
static int hf_waveagent_looppckts;
static int hf_waveagent_loopbytes;
static int hf_waveagent_rxctlpckts;
static int hf_waveagent_rxctlbytes;
static int hf_waveagent_txctlpckts;
static int hf_waveagent_txctlbytes;
static int hf_waveagent_unknowncmds;
static int hf_waveagent_snap;
static int hf_waveagent_state;
static int hf_waveagent_appstate;
static int hf_waveagent_rx1pl;
static int hf_waveagent_rx2pl;
static int hf_waveagent_rx3pl;
static int hf_waveagent_rx4pl;
static int hf_waveagent_rx5pl;
static int hf_waveagent_rxoospkts;
/* static int hf_waveagent_rxmeanlatency; */
/* static int hf_waveagent_rxminlatency; */
/* static int hf_waveagent_rxmaxlatency; */
static int hf_waveagent_latencysum;
static int hf_waveagent_latencycount;
static int hf_waveagent_txflowstop;
static int hf_waveagent_jitter;
static int hf_waveagent_remoteport;
static int hf_waveagent_remoteaddr;
static int hf_waveagent_dscp;
static int hf_waveagent_fsflags;
static int hf_waveagent_fscbrflag;
static int hf_waveagent_fscombinedsetupflag;
/* static int hf_waveagent_totalbytes; */
static int hf_waveagent_payfill;
static int hf_waveagent_paysize;
static int hf_waveagent_avgrate;
static int hf_waveagent_rxflownum;
static int hf_waveagent_mode;
static int hf_waveagent_endpointtype;
static int hf_waveagent_totalframes;
static int hf_waveagent_bssidstartindex;
static int hf_waveagent_bssidstopindex;
static int hf_waveagent_ifindex;
static int hf_waveagent_iftype;
static int hf_waveagent_ifdescription;
static int hf_waveagent_ifmacaddr;
static int hf_waveagent_iflinkspeed;
static int hf_waveagent_ifdhcp;
static int hf_waveagent_ifwlanbssid;
static int hf_waveagent_ifwlanssid;
static int hf_waveagent_ifiptype;
static int hf_waveagent_ifipv4;
static int hf_waveagent_ifipv6;
static int hf_waveagent_ifdhcpserver;
static int hf_waveagent_ifgateway;
static int hf_waveagent_ifdnsserver;
static int hf_waveagent_ifethl2status;
static int hf_waveagent_ifwlanl2status;
static int hf_waveagent_ifl3status;
static int hf_waveagent_totalbssid;
static int hf_waveagent_returnedbssid;
static int hf_waveagent_scanbssid;
static int hf_waveagent_scanssid;
static int hf_waveagent_ifwlanrssi;
static int hf_waveagent_ifwlansupprates;
static int hf_waveagent_ifwlancapabilities;
static int hf_waveagent_ifwlanchannel;
static int hf_waveagent_ifwlanprivacy;
static int hf_waveagent_ifwlanbssmode;
static int hf_waveagent_ifwlannoise;
static int hf_waveagent_ifphytypes;
static int hf_waveagent_ifphytypebit0;
static int hf_waveagent_ifphytypebit1;
static int hf_waveagent_ifphytypebit2;
static int hf_waveagent_ifphytypebit3;
/* static int hf_waveagent_ifphytypebit4; */
static int hf_waveagent_ifwlanauthentication;
static int hf_waveagent_ifwlancipher;
static int hf_waveagent_delayfactor;
static int hf_waveagent_medialossrate;
static int hf_waveagent_txstartts;
static int hf_waveagent_txendts;
static int hf_waveagent_rxstartts;
static int hf_waveagent_rxendts;
static int hf_waveagent_oidcode;
static int hf_waveagent_oidvalue;
static int hf_waveagent_destip;
static int hf_waveagent_destport;
static int hf_waveagent_connectflags;
static int hf_waveagent_connecttype;
static int hf_waveagent_minrssi;
static int hf_waveagent_connecttimeout;
static int hf_waveagent_connectattempts;
static int hf_waveagent_reason;
static int hf_waveagent_sigsequencenum;
static int hf_waveagent_relaydestid;
static int hf_waveagent_relaysrcid;
static int hf_waveagent_relaymessagest;

/* Initialize the subtree pointers */
static int ett_waveagent;
static int ett_statechange;
static int ett_phytypes;
static int ett_fsflags;
static int ett_scindex[8];  /* NUM_STATE_CHANGES */
static int ett_bss[8];  /* NUM_BSS           */
static int ett_relaymessage;


static const value_string control_words[] = {
    { 0x01, "Receive, Count, Discard"},
    { 0x02, "Receive, Count, Loopback"},
    { 0x03, "Receive, Count, Push timestamp, Discard"},
    { 0x04, "Receive, Count, Push timestamp, Loopback"},
    { 0x08, "Transmit"},
    { 0x11, "Start Flow"},
    { 0x12, "Stop Flow"},
    { 0x20, "Stats Reset"},
    { 0x21, "Stats Request"},
    { 0x22, "Flow Stats Reset"},
    { 0x23, "Scan Results Request"},
    { 0x24, "Interface Info Request"},
    { 0x25, "Interface Change Info Request"},
    { 0x26, "OID Request"},
    { 0x2e, "Scan Results Response"},
    { 0x2f, "Stats Response"},
    { 0x30, "Interface Info Response"},
    { 0x31, "Interface Change Info Response"},
    { 0x32, "OID Response"},  /* XXX: is this correct ? entry originally located after 0x41 */
    { 0x3e, "Relay Message"},
    { 0x3f, "Relay Response"},
    { 0x40, "Client Connect Request"},
    { 0x41, "Client Disconnect Request"},
    { 0x80, "Capabilities Request"},
    { 0x81, "Capabilities Response"},
    { 0x82, "Reserve Request"},
    { 0x84, "Release Request"},
    { 0x85, "Flow Setup"},
    { 0x86, "Flow Destroy"},
    { 0x87, "Flow Connect"},
    { 0x88, "Flow Disconnect"},
    { 0x89, "Flow Listen"},
    { 0x8a, "Scan Request"},
    { 0x8b, "Learning Message"},
    { 0x8f, "Command Response"},
    { 0, NULL},
};
static value_string_ext control_words_ext = VALUE_STRING_EXT_INIT(control_words);

/* Dissects the WLAN interface stats structure */
static void dissect_wlan_if_stats(uint32_t starting_offset, proto_item *parent_tree, tvbuff_t *tvb)
{
    proto_item *phy_types;
    proto_tree *phy_types_tree;
    uint32_t    phy_types_bitfield, noise_floor;

    proto_tree_add_item(parent_tree,
        hf_waveagent_ifwlanbssid, tvb, starting_offset, 6, ENC_NA);

    /* two bytes of pad go here */

    proto_tree_add_item(parent_tree,
        hf_waveagent_ifwlanssid, tvb, starting_offset + 8, 32, ENC_ASCII);

    /* 4 byte SSID length field not reported */

    proto_tree_add_item(parent_tree,
        hf_waveagent_ifwlanrssi, tvb, starting_offset + 44, 4, ENC_BIG_ENDIAN);

    noise_floor = tvb_get_ntohl(tvb, starting_offset + 48);

    if (noise_floor != 0x7fffffff) {
        proto_tree_add_item(parent_tree,
            hf_waveagent_ifwlannoise, tvb, starting_offset + 48, 4, ENC_BIG_ENDIAN);
    }
    else {
        proto_tree_add_int_format_value(parent_tree,
            hf_waveagent_ifwlannoise, tvb, starting_offset + 48, 4, noise_floor,
            "Not Reported");
    }

    phy_types_bitfield = tvb_get_ntohl(tvb, starting_offset + 52);

    phy_types = proto_tree_add_uint(parent_tree, hf_waveagent_ifphytypes,
                                tvb, starting_offset + 52, 4, phy_types_bitfield);

    phy_types_tree = proto_item_add_subtree(phy_types, ett_phytypes);

    proto_tree_add_item(phy_types_tree,
            hf_waveagent_ifphytypebit0, tvb, starting_offset + 55, 1, ENC_LITTLE_ENDIAN);

    proto_tree_add_item(phy_types_tree,
            hf_waveagent_ifphytypebit1, tvb, starting_offset + 55, 1, ENC_LITTLE_ENDIAN);

    proto_tree_add_item(phy_types_tree,
            hf_waveagent_ifphytypebit2, tvb, starting_offset + 55, 1, ENC_LITTLE_ENDIAN);

    proto_tree_add_item(phy_types_tree,
            hf_waveagent_ifphytypebit3, tvb, starting_offset + 55, 1, ENC_LITTLE_ENDIAN);

    proto_tree_add_item(parent_tree,
        hf_waveagent_ifwlanauthentication, tvb, starting_offset + 56, 4, ENC_BIG_ENDIAN);

    proto_tree_add_item(parent_tree,
        hf_waveagent_ifwlancipher, tvb, starting_offset + 60, 4, ENC_BIG_ENDIAN);
}

static void dissect_wa_payload(uint32_t starting_offset, proto_item *parent_tree, tvbuff_t *tvb, uint32_t control_word, uint8_t version)
{
    switch (control_word)
    {
        case 0x11:   /* Flow start message */
            proto_tree_add_item(parent_tree,
                hf_waveagent_payfill, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_paysize, tvb, starting_offset+4, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_avgrate, tvb, starting_offset+8, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_totalframes, tvb, starting_offset+12, 4, ENC_BIG_ENDIAN);

            break;

        case 0x23:   /* Scan results request */
            proto_tree_add_item(parent_tree,
                hf_waveagent_ifindex, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_bssidstartindex, tvb, starting_offset+4, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_bssidstopindex, tvb, starting_offset+8, 4, ENC_BIG_ENDIAN);

            break;

        case 0x24:   /* Interface info request */
        case 0x25:   /* Interface change info request */
        case 0x8a:   /* Scan request */
            proto_tree_add_item(parent_tree,
                hf_waveagent_ifindex, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            break;

        case 0x26:   /* OID request */
            proto_tree_add_item(parent_tree,
                hf_waveagent_ifindex, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_oidcode, tvb, starting_offset+4, 4, ENC_BIG_ENDIAN);

            break;

        case 0x30: {  /* Interface stats response */
            uint32_t if_type;

            proto_tree_add_item(parent_tree,
                hf_waveagent_ifindex, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            if_type = tvb_get_ntohl(tvb, starting_offset + 4);

            proto_tree_add_item(parent_tree,
                hf_waveagent_iftype, tvb, starting_offset + 4, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_ifdhcp, tvb, starting_offset + 8, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_ifmacaddr, tvb, starting_offset + 12, 6, ENC_NA);

            /* 2 bytes of pad go here */

            proto_tree_add_item(parent_tree,
                hf_waveagent_iflinkspeed, tvb, starting_offset + 20, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_ifdescription, tvb, starting_offset + 24, 128, ENC_ASCII);

            /* 4 byte length field goes here - skip it */

            /* two bytes of pad go here */

            /* If we have WLAN interface, then report the following */
            if (if_type == WLAN_INTERFACE)
                dissect_wlan_if_stats(starting_offset + 156, parent_tree, tvb);

            /* Next come the BindingAddress fields (for each address):
                2 bytes:  IP type (v4 or v6)
                2 bytes:  address length
                4 bytes:  service number (not used)
                16 bytes: IP address     */

            /* for the bound IP address, report both IP type and address */

            proto_tree_add_item(parent_tree,
                hf_waveagent_ifiptype, tvb, starting_offset + 252, 2, ENC_BIG_ENDIAN);

            if (tvb_get_ntohs(tvb, starting_offset + 252) == IPV4_TYPE) {
                proto_tree_add_item(parent_tree,
                    hf_waveagent_ifipv4, tvb, starting_offset + 260, 4, ENC_BIG_ENDIAN);  /* grab the last 4 bytes of the IP address field */
            }
            else {
                proto_tree_add_item(parent_tree,
                    hf_waveagent_ifipv6, tvb, starting_offset + 260, 16, ENC_NA);
            }

            proto_tree_add_item(parent_tree,
                hf_waveagent_ifdhcpserver, tvb, starting_offset + 284, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_ifgateway,    tvb, starting_offset + 308, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_ifdnsserver,  tvb, starting_offset + 332, 4, ENC_BIG_ENDIAN);

            break;
        }

        case 0x31:  {  /* Interface change info response */
            uint32_t offset;
            uint32_t if_type;
            uint32_t delta;
            uint32_t iLoop;

            proto_tree_add_item(parent_tree,
                hf_waveagent_ifindex, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            if_type = tvb_get_ntohl(tvb, starting_offset + 4);

            proto_tree_add_item(parent_tree,
                hf_waveagent_iftype, tvb, starting_offset + 4, 4, ENC_BIG_ENDIAN);

            offset = starting_offset + 8;
            delta = 156;

            for (iLoop = 0; iLoop < NUM_STATE_CHANGES; iLoop++) {
                proto_item *stIndex;
                proto_tree *st_change_index_tree;
                uint32_t    if_status;
                int         current_offset;

                current_offset = offset + iLoop * delta;

                /* Check to see if the interface entry is valid */
                if_status = tvb_get_ntohl(tvb, current_offset);
                if (if_status == 0) continue;  /* No entry at this index, keep going */

                /* Add index specific trees to hide the details */
                stIndex = proto_tree_add_uint_format_value(parent_tree,
                    hf_waveagent_ifwlanl2status, tvb, current_offset, 4, if_status, "Interface state change %d", iLoop);

                st_change_index_tree = proto_item_add_subtree(stIndex, ett_scindex[iLoop]);

                if (if_type == WLAN_INTERFACE) {
                    proto_tree_add_item(st_change_index_tree,
                        hf_waveagent_ifwlanl2status, tvb, current_offset, 4, ENC_BIG_ENDIAN);
                } else {
                    proto_tree_add_item(st_change_index_tree,
                        hf_waveagent_ifethl2status, tvb, current_offset, 4, ENC_BIG_ENDIAN);
                }

                proto_tree_add_item(st_change_index_tree,
                    hf_waveagent_ifl3status, tvb, current_offset + 4, 4, ENC_BIG_ENDIAN);

                proto_tree_add_item(st_change_index_tree,
                    hf_waveagent_iflinkspeed, tvb, current_offset + 8, 4, ENC_BIG_ENDIAN);

                if (if_type == WLAN_INTERFACE) {
                    dissect_wlan_if_stats(current_offset + 12, st_change_index_tree, tvb);
                }

                proto_tree_add_item(st_change_index_tree,
                    hf_waveagent_snap, tvb, current_offset + 108, 8, ENC_BIG_ENDIAN);

                proto_tree_add_item(st_change_index_tree,
                    hf_waveagent_ifiptype, tvb, current_offset + 116, 2, ENC_BIG_ENDIAN);

                if (tvb_get_ntohs(tvb, current_offset + 116) == IPV4_TYPE) {
                    proto_tree_add_item(st_change_index_tree,
                        hf_waveagent_ifipv4, tvb, current_offset + 124, 4, ENC_BIG_ENDIAN);  /* grab the last 4 bytes of the IP address field */
                }
                else {
                    proto_tree_add_item(st_change_index_tree,
                        hf_waveagent_ifipv6, tvb, current_offset + 124, 16, ENC_NA);
                }

                /* 16 bytes of padding */
            }

            break;
        }

        case 0x32:   /* OID response */
            proto_tree_add_item(parent_tree,
                hf_waveagent_ifindex, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_oidcode, tvb, starting_offset + 4, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_oidvalue, tvb, starting_offset + 12, 1024, ENC_ASCII);

            break;

        case 0x2e: {  /* scan results response message */
            uint32_t       offset;
            proto_item    *pi;
            uint32_t       num_bss_entries;
            uint32_t       tag_len;
            uint32_t       delta;
            uint32_t       iLoop;
            wmem_strbuf_t *sb;

            proto_tree_add_item(parent_tree,
                hf_waveagent_ifindex, tvb, starting_offset, 4, ENC_BIG_ENDIAN);


            proto_tree_add_item(parent_tree,
                hf_waveagent_totalbssid, tvb, starting_offset + 4, 4, ENC_BIG_ENDIAN);

            pi = proto_tree_add_item(parent_tree,
                hf_waveagent_returnedbssid, tvb, starting_offset + 8, 4, ENC_BIG_ENDIAN);

            num_bss_entries = tvb_get_ntohl(tvb, starting_offset + 8);

            if (num_bss_entries > NUM_BSS) {
                proto_item_append_text(pi, " [**Too large: Limiting to " G_STRINGIFY(NUM_BSS) "]");
                num_bss_entries = NUM_BSS;
            }
            /* Add 4 bytes of pad for the offset */

            offset = starting_offset + 16;
            delta  = 148;

            sb = wmem_strbuf_new_sized(wmem_packet_scope(), 8);

            for (iLoop = 0; iLoop < num_bss_entries; iLoop++)
            {
                proto_item *bssIndex;
                proto_tree *bss_tree;
                int         current_offset;

                wmem_strbuf_truncate(sb, 0);

                current_offset = offset + iLoop * delta;

                bssIndex = proto_tree_add_item(parent_tree,
                    hf_waveagent_scanssid, tvb, current_offset, 32, ENC_ASCII);

                bss_tree = proto_item_add_subtree(bssIndex, ett_bss[iLoop]);

                tag_len = tvb_get_ntohl(tvb, current_offset + 52);

                if (tag_len != 0) {
                    uint32_t      isr;
                    uint8_t       isr_value;

                    for (isr = 0; isr < tag_len; isr++) {
                        isr_value = tvb_get_uint8(tvb, offset + 36 + isr);
                        if (isr_value == 0xFF){
                            proto_tree_add_string (bss_tree, hf_waveagent_ifwlansupprates, tvb, offset + 36 + isr,
                                                   1,
                                                   "BSS requires support for mandatory features of HT PHY (IEEE 802.11"
                                                   " - Clause 20)");
                        } else {
                            wmem_strbuf_append_printf(sb, "%2.1f%s ",
                                      (isr_value & 0x7F) * 0.5,
                                      (isr_value & 0x80) ? "(B)" : "");

                        }
                    }
                    wmem_strbuf_append(sb, " [Mbit/sec]");
                }
                else {
                    wmem_strbuf_append(sb, "Not defined");
                }

                proto_tree_add_string (bss_tree, hf_waveagent_ifwlansupprates, tvb, offset + 36,
                    tag_len, wmem_strbuf_get_str(sb));

                proto_tree_add_item(bss_tree,
                    hf_waveagent_scanbssid, tvb, current_offset + 56, 6, ENC_NA);

                proto_tree_add_item(bss_tree,
                    hf_waveagent_ifwlancapabilities, tvb, current_offset + 62, 2, ENC_BIG_ENDIAN);

                proto_tree_add_item(bss_tree,
                    hf_waveagent_ifwlanrssi, tvb, current_offset + 64, 4, ENC_BIG_ENDIAN);

                /*  For now this is just a 4 byte pad, so comment it out...  */
#if 0
                proto_tree_add_item(bss_tree,
                    hf_waveagent_ifwlansigquality, tvb, current_offset + 68, 4, ENC_BIG_ENDIAN);
#endif
                proto_tree_add_item(bss_tree,
                    hf_waveagent_ifwlanchannel, tvb, current_offset + 72, 4, ENC_BIG_ENDIAN);

                proto_tree_add_item(bss_tree,
                    hf_waveagent_ifwlanprivacy, tvb, current_offset + 76, 4, ENC_BIG_ENDIAN);

                proto_tree_add_item(bss_tree,
                    hf_waveagent_ifwlanbssmode, tvb, current_offset + 80, 4, ENC_BIG_ENDIAN);
            }
            break;
        }

        case 0x2f:   /* Stats response message */
            if (version < 3) {
                /* For version 2 WA protocol the capability status is not in the header but in the CAP
                   RESPONSE.  Need to read it here and then advance the payload offset.  This is a
                   packet that had a structure change in the beginning of the packet when moving
                   to v3 */
                proto_tree_add_item(parent_tree,
                    hf_waveagent_capstatus, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_protocolversion, tvb, starting_offset, 1, ENC_BIG_ENDIAN);

                starting_offset += 4;
            }

            proto_tree_add_item(parent_tree,
                hf_waveagent_capimpl, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                       hf_waveagent_state, tvb, starting_offset + 4, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                       hf_waveagent_appstate, tvb, starting_offset + 8, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_rxdatapckts, tvb, starting_offset + 12, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_rxdatabytes, tvb, starting_offset + 20, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_rxpcktrate, tvb, starting_offset + 28, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_rxbyterate, tvb, starting_offset + 36, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_txdatapckts, tvb, starting_offset + 44, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_txdatabytes, tvb, starting_offset + 52, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_txpcktrate, tvb, starting_offset + 60, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_txbyterate, tvb, starting_offset + 68, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_looppckts, tvb, starting_offset + 76, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_loopbytes, tvb, starting_offset + 84, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_rxctlpckts, tvb, starting_offset + 92, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_rxctlbytes, tvb, starting_offset + 100, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_txctlpckts, tvb, starting_offset + 108, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_txctlbytes, tvb, starting_offset + 116, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_unknowncmds, tvb, starting_offset + 124, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_snap, tvb, starting_offset + 132, 8, ENC_BIG_ENDIAN);

#if 0
            proto_tree_add_item(parent_tree,
                hf_waveagent_tstamp1, tvb, 140, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_tstamp2, tvb, 144, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_tstamp3, tvb, 148, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_tstamp4, tvb, 152, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_tstamp5, tvb, 156, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_tstamp6, tvb, 160, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_tstamp7, tvb, 164, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_tstamp8, tvb, 168, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_minlcldelta, tvb, 172, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_maxlcldelta, tvb, 176, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_avglcldelta, tvb, 180, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_minremdelta, tvb, 184, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_maxremdelta, tvb, 188, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_avgremdelta, tvb, 192, 4, ENC_BIG_ENDIAN);
#endif
            proto_tree_add_item(parent_tree,
                hf_waveagent_rx1pl, tvb, starting_offset + 284, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_rx2pl, tvb, starting_offset + 292, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_rx3pl, tvb, starting_offset + 300, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_rx4pl, tvb, starting_offset + 308, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_rx5pl, tvb, starting_offset + 316, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_rxoospkts, tvb, starting_offset + 324, 8, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_jitter, tvb, starting_offset + 356, 8, ENC_BIG_ENDIAN);

            if (version >= 3) {
                proto_tree_add_item(parent_tree,
                    hf_waveagent_delayfactor, tvb, starting_offset + 364, 8, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_medialossrate, tvb, starting_offset + 372, 8, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_txstartts, tvb, starting_offset + 380, 8, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_txendts, tvb, starting_offset + 388, 8, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_rxstartts, tvb, starting_offset + 396, 8, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_rxendts, tvb, starting_offset + 404, 8, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_latencysum, tvb, starting_offset + 412, 8, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_latencycount, tvb, starting_offset + 420, 8, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_txflowstop, tvb, starting_offset + 428, 8, ENC_BIG_ENDIAN);
            }

            break;

        case 0x40: {
            uint32_t offset;
            uint32_t delta;
            uint32_t iLoop;
            uint32_t num_bss_entries;

            proto_tree_add_item(parent_tree,
                hf_waveagent_ifindex, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_connectflags, tvb, starting_offset + 4, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_connecttype, tvb, starting_offset + 8, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_scanssid, tvb, starting_offset + 12, 32, ENC_ASCII);

            num_bss_entries = tvb_get_ntohl(tvb, starting_offset + 142);

            offset = starting_offset + 46;
            delta = 6;
            for (iLoop = 0; iLoop < num_bss_entries; iLoop++)
            {
                int current_offset;
                current_offset = offset + iLoop * delta;

                proto_tree_add_item(parent_tree,
                    hf_waveagent_scanbssid, tvb, current_offset, 6, ENC_NA);
            }

            proto_tree_add_item(parent_tree,
                hf_waveagent_minrssi, tvb, starting_offset + 146, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_connecttimeout, tvb, starting_offset + 150, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_connectattempts, tvb, starting_offset + 154, 4, ENC_BIG_ENDIAN);

            break;
        }

        case 0x41:
            proto_tree_add_item(parent_tree,
                hf_waveagent_ifindex, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_reason, tvb, starting_offset + 4, 4, ENC_BIG_ENDIAN);

            break;

        case 0x81:   /* Capabilities response */
            if (version < 3) {
                /* For version 2 WA protocol the capability status is not in the header but in the CAP
                   RESPONSE.  Need to read it here and then advance the payload offset.  This is a
                   packet that had a structure change in the beginning of the packet when moving
                   to v3 */
                proto_tree_add_item(parent_tree,
                    hf_waveagent_capstatus, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_protocolversion, tvb, starting_offset, 1, ENC_BIG_ENDIAN);

                starting_offset += 4;
            }

            proto_tree_add_item(parent_tree,
                hf_waveagent_capimpl, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_id, tvb, starting_offset + 4, 128, ENC_ASCII);

            proto_tree_add_item(parent_tree,
                hf_waveagent_bindtag, tvb, starting_offset + 136, 128, ENC_ASCII);

            proto_tree_add_item(parent_tree,
                hf_waveagent_version, tvb, starting_offset + 268, 128, ENC_ASCII);

            proto_tree_add_item(parent_tree,
                hf_waveagent_brokerip, tvb, starting_offset + 400, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_brokerport, tvb, starting_offset + 404, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_bindlevel, tvb, starting_offset + 408, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_bindport, tvb, starting_offset + 412, 4, ENC_BIG_ENDIAN);

            if (version >= 3) {
                proto_tree_add_item(parent_tree,
                    hf_waveagent_capabilities2, tvb, starting_offset + 416, 4, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_numinterfaces, tvb, starting_offset + 420, 4, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_ifmask, tvb, starting_offset + 424, 4, ENC_BIG_ENDIAN);
            }

            break;

        case 0x82:    /* Reserve request */
            proto_tree_add_item(parent_tree,
                hf_waveagent_bindtag, tvb, starting_offset, 128, ENC_ASCII);

            proto_tree_add_item(parent_tree,
                hf_waveagent_brokerip, tvb, starting_offset + 132, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_brokerport, tvb, starting_offset + 136, 4, ENC_BIG_ENDIAN);

            break;

        case 0x85: {   /* Flow setup */
            proto_tree *fs_flags;
            proto_tree *fs_flags_tree;
            uint32_t    flags_bitfield;

            if (version < 3) {
                proto_tree_add_item(parent_tree,
                    hf_waveagent_rxflownum, tvb, starting_offset, 4, ENC_BIG_ENDIAN);
            }

            proto_tree_add_item(parent_tree,
                hf_waveagent_mode, tvb, starting_offset + 7, 1, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_endpointtype, tvb, starting_offset + 7, 1, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_bindport, tvb, starting_offset + 8, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_bindlevel, tvb, starting_offset + 12, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_remoteport, tvb, starting_offset + 16, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_remoteaddr, tvb, starting_offset + 24, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_dscp, tvb, starting_offset + 40, 4, ENC_BIG_ENDIAN);

            flags_bitfield = tvb_get_ntohl(tvb, starting_offset + 44);

            fs_flags = proto_tree_add_uint(parent_tree, hf_waveagent_fsflags,
                                        tvb, starting_offset + 44, 4, flags_bitfield);

            fs_flags_tree = proto_item_add_subtree(fs_flags, ett_fsflags);

            proto_tree_add_item(fs_flags_tree,
                    hf_waveagent_fscbrflag, tvb, starting_offset + 47, 1, ENC_LITTLE_ENDIAN);

            proto_tree_add_item(fs_flags_tree,
                    hf_waveagent_fscombinedsetupflag, tvb, starting_offset + 47, 1, ENC_LITTLE_ENDIAN);

            if (version >= 3) {
                proto_tree_add_item(parent_tree,
                    hf_waveagent_ifindex, tvb, starting_offset + 48, 4, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_payfill, tvb, starting_offset + 52, 4, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_paysize, tvb, starting_offset + 56, 4, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_avgrate, tvb, starting_offset + 60, 4, ENC_BIG_ENDIAN);

                proto_tree_add_item(parent_tree,
                    hf_waveagent_totalframes, tvb, starting_offset + 64, 4, ENC_BIG_ENDIAN);
            }

            break;
        }

        case 0x8b:
            proto_tree_add_item(parent_tree,
                hf_waveagent_destip, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_destport, tvb, starting_offset + 4, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_connectflags, tvb, starting_offset + 8, 4, ENC_BIG_ENDIAN);

            break;

        case 0x3f:  /* Relay response */
        case 0x8f:  /* Command Response */
            proto_tree_add_item(parent_tree,
                hf_waveagent_commandstatus, tvb, starting_offset, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_syserrno, tvb, starting_offset + 4, 4, ENC_BIG_ENDIAN);

            proto_tree_add_item(parent_tree,
                hf_waveagent_statusstring, tvb, starting_offset + 8, 128, ENC_ASCII);

            break;
    }
}



static uint32_t dissect_wa_header(uint32_t starting_offset, proto_item *parent_tree, tvbuff_t *tvb, uint8_t version)
{
    uint32_t wa_payload_offset;

    proto_tree_add_item(parent_tree,
        hf_waveagent_controlword, tvb, 30+starting_offset, 2, ENC_BIG_ENDIAN);

    proto_tree_add_item(parent_tree,
        hf_waveagent_payloadlen, tvb, 20+starting_offset, 4, ENC_BIG_ENDIAN);

    proto_tree_add_item(parent_tree,
        hf_waveagent_transnum, tvb, 24+starting_offset, 4, ENC_BIG_ENDIAN);

    proto_tree_add_item(parent_tree,
        hf_waveagent_rtoken, tvb, 32+starting_offset, 4, ENC_BIG_ENDIAN);

    proto_tree_add_item(parent_tree,
        hf_waveagent_flowid, tvb, 36+starting_offset, 4, ENC_BIG_ENDIAN);

    if (version >= 3) {
        proto_tree_add_item(parent_tree,
            hf_waveagent_capstatus, tvb, 40+starting_offset, 4, ENC_BIG_ENDIAN);

        proto_tree_add_item(parent_tree,
            hf_waveagent_protocolversion, tvb, 40+starting_offset, 1, ENC_BIG_ENDIAN);

        wa_payload_offset = WA_V3_PAYLOAD_OFFSET + starting_offset;
    }
    else {
        wa_payload_offset = WA_V2_PAYLOAD_OFFSET + starting_offset;
    }

    proto_tree_add_item(parent_tree,
        hf_waveagent_sigsequencenum, tvb, 4+starting_offset, 1, ENC_BIG_ENDIAN);

    return wa_payload_offset;
}

/* Dissect the packets */
static int dissect_waveagent(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
    proto_item *ti, *rmi;
    proto_tree *waveagent_tree, *relay_message_tree, *payload_tree;
    uint8_t     signature_start, signature_end;
    uint8_t     version;
    uint32_t    magic_number;
    uint32_t    control_word, paylen;
    uint32_t    wa_payload_offset;

    /* Check that there's enough data */
    if (tvb_captured_length(tvb) < 52 )
        return 0;

    magic_number    = tvb_get_ntohl(tvb, 16) & 0x0FFFFFFF;  /* Mask magic number off */
    if(magic_number != 0x0F87C3A5){
        return 0;
    }

    signature_start = tvb_get_uint8(tvb, 0);
    signature_end   = tvb_get_uint8(tvb, 15);

    if ( ((signature_start != 0xcc) && (signature_start !=0xdd)) ||
         (signature_end != 0xE2))
        /*  This packet does not appear to belong to WaveAgent.
         *  Return 0 to give another dissector a chance to dissect it.
         */
        return 0;

    version         = ((tvb_get_ntohl(tvb, 16) & 0xF0000000) >> 28 == 1) ? 3 : 2;       /* Mask version bit off */

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "WA");
    col_clear(pinfo->cinfo, COL_INFO);

    /* Grab the control word, parse the WaveAgent payload accordingly */

    control_word = tvb_get_ntohl(tvb, 28);
    paylen       = tvb_get_ntohl(tvb, 20);

    col_add_fstr(pinfo->cinfo, COL_INFO, "%s (0x%x)",
        val_to_str_ext_const(control_word, &control_words_ext, "Unknown"), control_word);

    if (tree) {
        /* create display subtree for the protocol */
        ti = proto_tree_add_protocol_format(tree, proto_waveagent, tvb, 0, -1,
                        "WaveAgent, %s (0x%x), Payload Length %u Bytes",
                        val_to_str_ext_const(control_word, &control_words_ext, "Unknown"), control_word, paylen);

        waveagent_tree = proto_item_add_subtree(ti, ett_waveagent);

        wa_payload_offset = dissect_wa_header(0, waveagent_tree, tvb, version);

        payload_tree = waveagent_tree;

        /* Need to check for a relay message.  If so, parse the extra fields and then parse the WA packet */
        if (control_word == 0x3e)
        {
            proto_tree_add_item(waveagent_tree,
                hf_waveagent_relaydestid, tvb, wa_payload_offset, 4, ENC_BIG_ENDIAN);
            proto_tree_add_item(waveagent_tree,
                hf_waveagent_relaysrcid, tvb, wa_payload_offset+4, 4, ENC_BIG_ENDIAN);

            /* Parse control_word of the relay message */
            control_word = tvb_get_ntohl(tvb, wa_payload_offset+12+28);
                rmi = proto_tree_add_none_format(waveagent_tree, hf_waveagent_relaymessagest,
                                                 tvb, wa_payload_offset+12+28, 0,
                                                 "Relayed WaveAgent Message, %s (0x%x)",
                                                 val_to_str_ext_const(control_word, &control_words_ext, "Unknown"),
                                                 control_word);

            relay_message_tree = proto_item_add_subtree(rmi, ett_relaymessage);

            wa_payload_offset = dissect_wa_header(wa_payload_offset+12, relay_message_tree, tvb, version);
            payload_tree = relay_message_tree;
        }

        dissect_wa_payload(wa_payload_offset, payload_tree, tvb, control_word, version);
    }

    /* Return the amount of data this dissector was able to dissect */
    return tvb_captured_length(tvb);
}

static bool dissect_waveagent_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
    return dissect_waveagent(tvb, pinfo, tree) > 0;
}


#if 0
static const value_string status_values[] = {
    { 0, "OK" },
    { 1, "In Use" },
    { 0, NULL }
};
#endif

/* Register the protocol with Wireshark */

void proto_register_waveagent(void)
{
    static const value_string tcp_states[] = {
        {  0, "Closed" },
        {  1, "Listen" },
        {  2, "SYN Sent" },
        {  3, "SYN received" },
        {  4, "Established" },
        {  5, "FIN Wait 1" },
        {  6, "FIN Wait 2" },
        {  7, "Close Wait" },
        {  8, "Closing" },
        {  9, "Last ACK" },
        { 10, "Time Wait" },
        {  0, NULL },
    };

    static const value_string app_states[] = {
        {  0, "IDLE" },
        {  1, "READY" },
        {  0, NULL },
    };

    static const value_string wa_modes[] = {
        {  0, "In-band" },
        {  1, "Source" },
        {  2, "Sink" },
        {  3, "Loopback" },
        {  0, NULL },
    };

    static const value_string wa_endpointtypes[] = {
        {  0, "Undefined" },
        {  1, "Server" },
        {  2, "Client" },
        {  0, NULL },
    };

    static const value_string binding_levels[] = {
        {  0, "WLAN" },
        {  1, "Ethernet" },
        {  2, "IP" },
        {  3, "UDP" },
        {  4, "TCP" },
        {  5, "FIN Wait 1" },
        {  6, "FIN Wait 2" },
        {  7, "Close Wait" },
        {  8, "Closing" },
        {  9, "Last ACK" },
        { 10, "Time Wait" },
        {  0, NULL },
    };

    static const value_string if_types[] = {
        {  ETHERNET_INTERFACE, "Ethernet" },
        {  WLAN_INTERFACE, "WLAN" },
        {  0, NULL },
    };

    static const value_string no_yes[] = {
        {  0, "No" },
        {  1, "Yes" },
        {  0, NULL },
    };

    static const value_string ip_types[] = {
        {  0,  "Unspecified" },
        {  IPV4_TYPE,  "IPv4" },
        {  IPV6_TYPE, "IPv6" },
        {  0, NULL },
    };

    static const value_string if_l3_states[] = {
        {  0, "Uninitialized" },
        {  1, "Disconnected" },
        {  2, "Connected" },
        {  3, "Error" },
        {  0, NULL },
    };

    static const value_string if_wlan_states[] = {
        {  0, "Uninitialized" },
        {  1, "Not ready" },
        {  2, "Connected" },
        {  3, "Ad Hoc network formed" },
        {  4, "Disconnecting" },
        {  5, "Disconnected" },
        {  6, "Associating" },
        {  7, "Discovering" },
        {  8, "Authenticating" },
        {  0, NULL },
    };

    static const value_string if_eth_states[] = {
        {  0, "Uninitialized" },
        {  1, "Not Operational" },
        {  2, "Unreachable" },
        {  3, "Disconnected" },
        {  4, "Connecting" },
        {  5, "Connected" },
        {  6, "Operational" },
        {  7, "Error" },
        {  0, NULL },
    };

    static const value_string bss_modes[] = {
        {  0, "Infrastructure" },
        {  1, "IBSS" },
        {  2, "Unknown" },
        {  0, NULL },
    };

    static const value_string auth_algs[] = {
        {  0,  "Open" },
        {  1,  "Shared Key" },
        {  2,  "WPA" },
        {  4,  "WPA PSK" },
        {  8,  "WPA2" },
        { 16, "WPA2 PSK" },
        {  0, NULL },
    };

    static const value_string cipher_algs[] = {
        {  0,  "None" },
        {  1,  "WEP 40" },
        {  2,  "WEP 104" },
        {  4,  "WEP" },
        {  8,  "TKIP" },
        { 16, "CCMP" },
        {  0, NULL },
    };

    /* Setup list of header fields  See Section 1.6.1 for details*/
    static hf_register_info hf[] = {

    /* START: General purpose message fields - used in multiple messages */
        { &hf_waveagent_controlword,
        { "Control Word", "waveagent.cword",
        FT_UINT16, BASE_HEX | BASE_EXT_STRING, &control_words_ext, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_payloadlen,
        { "Payload Length", "waveagent.paylen",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_transnum,
        { "Transaction Number", "waveagent.transnum",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rtoken,
        { "Reservation Token", "waveagent.rtoken",
        FT_UINT32, BASE_HEX, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_flowid,
        { "Flow ID", "waveagent.flowid",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_capstatus,
        { "Capabilities Status", "waveagent.capstatus",
        FT_UINT32, BASE_HEX, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_protocolversion,
        { "Protocol Version", "waveagent.protocolversion",
        FT_UINT8, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_capimpl,
        { "Capabilities Implementation", "waveagent.capimpl",
        FT_UINT32, BASE_HEX, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_sigsequencenum,
        { "Signature Sequence Number", "waveagent.sigsequencenum",
        FT_UINT8, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_id,
        { "ID", "waveagent.id",
        FT_STRING, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_bindtag,
        { "Binding Tag", "waveagent.bindtag",
        FT_STRING, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_version,
        { "Version", "waveagent.version",
        FT_STRING, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_brokerip,
        { "Broker IP address", "waveagent.brokerip",
        FT_IPv4, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_brokerport,
        { "Broker Port", "waveagent.brokerport",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_bindlevel,
        { "Binding Level", "waveagent.bindlevel",
        FT_UINT32, BASE_DEC, VALS(binding_levels), 0x0,
        NULL, HFILL } },

        { &hf_waveagent_bindport,
        { "Binding Port", "waveagent.bindport",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifindex,
        { "Interface Index", "waveagent.ifindex",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },
    /* END: General purpose message fields - used in multiple messages */

    /* START: Capabilities response fields (specific to this message, other general fields are also used) */
        { &hf_waveagent_capabilities2,
        { "Additional Capabilities", "waveagent.capabilities2",
        FT_UINT32, BASE_HEX, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_numinterfaces,
        { "Number of WA Interfaces", "waveagent.numinterfaces",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifmask,
        { "Mask of Active Interfaces", "waveagent.ifmask",
        FT_UINT32, BASE_HEX, NULL, 0x0,
        NULL, HFILL } },
    /* END: Capabilities response fields (specific to this message, other general fields are also used) */

    /* START: Command response message fields */
        { &hf_waveagent_commandstatus,
        { "Status of Previous Command", "waveagent.cmdstat",
        FT_INT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_syserrno,
        { "System Error Number", "waveagent.syserrno",
        FT_INT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_statusstring,
        { "Status Message", "waveagent.statmsg",
        FT_STRING, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },
    /* END: Command response message fields */

    /* START: Stats response message fields */
        { &hf_waveagent_rxdatapckts,
        { "Received Data Packets", "waveagent.rxdpkts",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rxdatabytes,
        { "Received Data Bytes", "waveagent.rxdbytes",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rxpcktrate,
        { "Received Data Packet Rate (pps)", "waveagent.rxpktrate",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rxbyterate,
        { "Received Byte Rate", "waveagent.rxbyterate",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_txdatapckts,
        { "Transmitted Data Packets", "waveagent.txdpkts",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_txdatabytes,
        { "Transmitted Data Bytes", "waveagent.txdbytes",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_txpcktrate,
        { "Transmitted Data Packet Rate (pps)", "waveagent.txpktrate",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_txbyterate,
        { "Transmitted Byte Rate", "waveagent.txbyterate",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_looppckts,
        { "Loopback Packets", "waveagent.looppckts",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_loopbytes,
        { "Loopback Bytes", "waveagent.loopbytes",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rxctlpckts,
        { "Received Control Packets", "waveagent.rxctlpkts",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rxctlbytes,
        { "Received Control Bytes", "waveagent.rxctlbytes",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_txctlpckts,
        { "Transmitted Control Packets", "waveagent.txctlpkts",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_txctlbytes,
        { "Transmitted Control Bytes", "waveagent.txctlbytes",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_unknowncmds,
        { "Unknown Commands", "waveagent.unkcmds",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_snap,
        { "Time Snap for Counters", "waveagent.snap",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_appstate,
        { "TCP State", "waveagent.state",
        FT_UINT32, BASE_DEC, VALS(tcp_states), 0x0,
        NULL, HFILL } },

        { &hf_waveagent_state,
        { "Application State", "waveagent.appstate",
        FT_UINT32, BASE_DEC, VALS(app_states), 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rx1pl,
        { "Instances of single packet loss", "waveagent.rx1pl",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rx2pl,
        { "Instances of 2 sequential packets lost", "waveagent.rx2pl",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rx3pl,
        { "Instances of 3 sequential packets lost", "waveagent.rx3pl",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rx4pl,
        { "Instances of 4 sequential packets lost", "waveagent.rx4pl",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rx5pl,
        { "Instances of 5 sequential packets lost", "waveagent.rx5pl",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rxoospkts,
        { "Instances of out-of-sequence packets", "waveagent.rxoospkts",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

#if 0
        { &hf_waveagent_rxmeanlatency,
        { "Rx Mean latency", "waveagent.rxmeanlatency",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },
#endif

#if 0
        { &hf_waveagent_rxminlatency,
        { "Rx Minimum latency", "waveagent.rxminlatency",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },
#endif

#if 0
        { &hf_waveagent_rxmaxlatency,
        { "Rx Maximum latency", "waveagent.rxmaxlatency",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },
#endif

        { &hf_waveagent_jitter,
        { "Jitter (microseconds)", "waveagent.jitter",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_delayfactor,
        { "Delay Factor", "waveagent.delayfactor",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_medialossrate,
        { "Media Loss Rate", "waveagent.medialossrate",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_txstartts,
        { "Timestamp for first Tx flow packet", "waveagent.txstartts",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_txendts,
        { "Timestamp for last Tx flow packet", "waveagent.txendts",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rxstartts,
        { "Timestamp for first Rx flow packet", "waveagent.rxstartts",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_rxendts,
        { "Timestamp for last Rx flow packet", "waveagent.rxendts",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_latencysum,
        { "Sum of latencies across all received packets", "waveagent.latencysum",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_latencycount,
        { "Count of packets included in the latency sum", "waveagent.latencycount",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_txflowstop,
        { "Timestamp for Tx flow stop message", "waveagent.txflowstop",
        FT_UINT64, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },
    /* END Stats response message fields */

    /* START: Flow setup message */
        { &hf_waveagent_rxflownum,
        { "Received Flow Number", "waveagent.rxflownum",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_mode,
        { "WaveAgent Mode", "waveagent.trafficmode",
        FT_UINT8, BASE_DEC, VALS(wa_modes), 0x03,
        NULL, HFILL } },

        { &hf_waveagent_endpointtype,
        { "WaveAgent Endpoint Type", "waveagent.endpointtype",
        FT_UINT8, BASE_DEC, VALS(wa_endpointtypes), 0x0c,
        NULL, HFILL } },

        { &hf_waveagent_remoteport,
        { "Remote port", "waveagent.remoteport",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_remoteaddr,
        { "Remote address", "waveagent.remoteaddr",
        FT_IPv4, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_dscp,
        { "DSCP Setting", "waveagent.dscp",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_fsflags,
        { "Flow Setup Flags", "waveagent.fsflags",
        FT_UINT32, BASE_HEX, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_fscbrflag,
        { "CBR Transmit Mode", "waveagent.fscbrflag",
        FT_BOOLEAN, 4, NULL, 0x1, NULL, HFILL } },

        { &hf_waveagent_fscombinedsetupflag,
        { "Setup, Connect/Listen, Start Combined", "waveagent.fscombinedsetupflag",
        FT_BOOLEAN, 4, NULL, 0x2, NULL, HFILL } },

    /* END: Flow setup message */

    /* START: Flow start message fields */
        { &hf_waveagent_payfill,
        { "Payload Fill", "waveagent.payfill",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_paysize,
        { "WaveAgent Payload Size (bytes)", "waveagent.paysize",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_avgrate,
        { "Average Rate (header + payload + trailer bytes/s)", "waveagent.avgrate",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_totalframes,
        { "Total Frames", "waveagent.totalframes",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

    /* END: Flow start message fields */

    /* START: Scan results request (0x23) fields */
        { &hf_waveagent_bssidstartindex,
        { "Starting Index of BSSID list for reporting", "waveagent.bssidstartindex",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_bssidstopindex,
        { "Ending Index of BSSID list for reporting", "waveagent.bssidstopindex",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

    /* END: Scan results request (0x23) fields */

    /* START: WLAN Interface stats fields */
        { &hf_waveagent_ifwlanbssid,
        { "WLAN Interface Connected to BSSID", "waveagent.ifwlanbssid",
        FT_ETHER, 0, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifwlanssid,
        { "WLAN Interface Connected to SSID", "waveagent.ifwlanssid",
        FT_STRING, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifwlanrssi,
        { "WLAN Interface RSSI", "waveagent.ifwlanrssi",
        FT_INT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifwlannoise,
        { "WLAN Interface Noise Floor (dBm)", "waveagent.ifwlannoise",
        FT_INT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifphytypes,
        { "WLAN Interface Supported PHY Types", "waveagent.ifphytypes",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifphytypebit0,
        { "11b", "waveagent.ifphytypebit0",
        FT_BOOLEAN, 4, NULL, 0x1, NULL, HFILL } },

        { &hf_waveagent_ifphytypebit1,
        { "11g", "waveagent.ifphytypebit1",
        FT_BOOLEAN, 4, NULL, 0x2, NULL, HFILL } },

        { &hf_waveagent_ifphytypebit2,
        { "11a", "waveagent.ifphytypebit2",
        FT_BOOLEAN, 4, NULL, 0x4, NULL, HFILL } },

        { &hf_waveagent_ifphytypebit3,
        { "11n", "waveagent.ifphytypebit3",
        FT_BOOLEAN, 4, NULL, 0x8, NULL, HFILL } },

        { &hf_waveagent_ifwlanauthentication,
        { "WLAN Interface Authentication Algorithm", "waveagent.ifwlanauthentication",
        FT_UINT32, BASE_DEC, VALS(auth_algs), 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifwlancipher,
        { "WLAN Interface Encryption/Cipher Algorithm", "waveagent.ifwlancipher",
        FT_UINT32, BASE_DEC, VALS(cipher_algs), 0x0,
        NULL, HFILL } },
    /* END: WLAN Interface stats fields */

    /* START: Interface stats response (0x2d) fields */
        { &hf_waveagent_iftype,
        { "Interface type", "waveagent.iftype",
        FT_UINT32, BASE_DEC, VALS(if_types), 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifdescription,
        { "Name/Description of the adapter", "waveagent.ifdescription",
        FT_STRING, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifmacaddr,
        { "Interface MAC Address", "waveagent.ifmacaddr",
        FT_ETHER, 0, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_iflinkspeed,
        { "Interface Link Speed (kbps)", "waveagent.iflinkspeed",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifdhcp,
        { "Interface DHCP Enabled", "waveagent.ifdhcp",
        FT_UINT32, BASE_DEC, VALS(no_yes), 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifiptype,
        { "Interface IP Type", "waveagent.ifiptype",
        FT_UINT32, BASE_DEC, VALS(ip_types), 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifipv4,
        { "Interface Bound to IP Address", "waveagent.ifipv4",
        FT_IPv4, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifipv6,
        { "Interface Bound to IP Address", "waveagent.ifipv6",
        FT_IPv6, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifdhcpserver,
        { "Interface DHCP Server Address", "waveagent.ifdhcpserver",
        FT_IPv4, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifgateway,
        { "Interface Gateway", "waveagent.ifgateway",
        FT_IPv4, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifdnsserver,
        { "Interface DNS Server Address", "waveagent.ifdnsserver",
        FT_IPv4, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifethl2status,
        { "Ethernet L2 Interface Status", "waveagent.ifethl2status",
        FT_UINT32, BASE_DEC, VALS(if_eth_states), 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifwlanl2status,
        { "WLAN L2 Interface Status", "waveagent.ifwlanl2status",
        FT_UINT32, BASE_DEC, VALS(if_wlan_states), 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifl3status,
        { "L3 Interface Status", "waveagent.ifl3status",
        FT_UINT32, BASE_DEC, VALS(if_l3_states), 0x0,
        NULL, HFILL } },

    /* END: Interface stats response (0x2d) fields */

    /* START: Scan results response (0x2e) fields */
        { &hf_waveagent_totalbssid,
        { "Number of Found BSSID", "waveagent.totalbssid",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_returnedbssid,
        { "Number of BSSID Reported in This Response", "waveagent.returnedbssid",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_scanbssid,
        { "BSSID", "waveagent.scanbssid",
        FT_ETHER, 0, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_scanssid,
        { "SSID", "waveagent.scanssid",
        FT_STRING, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifwlansupprates,
        { "Supported Rates", "waveagent.ifwlansupportedrates",
        FT_STRING, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifwlancapabilities,
        { "Capabilities field", "waveagent.ifwlancapabilities",
        FT_UINT16, BASE_HEX, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifwlanchannel,
        { "Channel", "waveagent.ifwlanchannel",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifwlanprivacy,
        { "Privacy Enabled", "waveagent.ifwlanprivacy",
        FT_UINT32, BASE_DEC, VALS(no_yes), 0x0,
        NULL, HFILL } },

        { &hf_waveagent_ifwlanbssmode,
        { "BSS Mode", "waveagent.ifwlanbssmode",
        FT_UINT32, BASE_DEC, VALS(bss_modes), 0x0,
        NULL, HFILL } },
    /* END: Scan results response (0x2e) fields */

    /* START: OID fields */
        { &hf_waveagent_oidcode,
        { "OID Code", "waveagent.oidcode",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_oidvalue,
        { "OID Value", "waveagent.oidvalue",
        FT_STRING, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },
    /* END: OID fields */

    /* START: Learning Message fields */
        { &hf_waveagent_destip,
        { "Destination IP", "waveagent.destip",
        FT_IPv4, BASE_NONE, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_destport,
        { "Destination Port", "waveagent.destport",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_connectflags,
        { "Connect Flags", "waveagent.connectflags",
        FT_UINT32, BASE_HEX, NULL, 0x0,
        NULL, HFILL } },
    /* END: Learning Message fields */

    /* START: client connect fields */
        { &hf_waveagent_connecttype,
        { "Connect Type", "waveagent.connecttype",
        FT_UINT32, BASE_HEX, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_minrssi,
        { "Minimum RSSI", "waveagent.minrssi",
        FT_INT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_connecttimeout,
        { "Connect timeout (s)", "waveagent.connecttimeout",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_connectattempts,
        { "Connect attempts", "waveagent.connectattempt",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_reason,
        { "Reason", "waveagent.reason",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },
    /* END: client connect fields */

    /* START: relay server fields */
        { &hf_waveagent_relaydestid,
        { "ID of destination client (assigned by relay server)", "waveagent.relaydestid",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_relaysrcid,
        { "ID of source client (assigned by relay server)", "waveagent.relaysrcid",
        FT_UINT32, BASE_DEC, NULL, 0x0,
        NULL, HFILL } },

        { &hf_waveagent_relaymessagest,
        { "Relayed WaveAgent Message", "waveagent.relaymessagest",
        FT_NONE, BASE_NONE, NULL, 0x0,
        "This is a relayed WaveAgent message", HFILL } },

/* END: relay server fields */

    };

/* Setup protocol subtree array */
    static int *ett[] = {
        &ett_waveagent,
        &ett_statechange,
        &ett_phytypes,
        &ett_fsflags,
        &ett_scindex[0],
        &ett_scindex[1],
        &ett_scindex[2],
        &ett_scindex[3],
        &ett_scindex[4],
        &ett_scindex[5],
        &ett_scindex[6],
        &ett_scindex[7],
        &ett_bss[0],
        &ett_bss[1],
        &ett_bss[2],
        &ett_bss[3],
        &ett_bss[4],
        &ett_bss[5],
        &ett_bss[6],
        &ett_bss[7],
        &ett_relaymessage,
    };

    proto_waveagent = proto_register_protocol("WaveAgent", "waveagent", "waveagent");

    proto_register_field_array(proto_waveagent, hf, array_length(hf));
    proto_register_subtree_array(ett, array_length(ett));
}


void proto_reg_handoff_waveagent(void)
{
    heur_dissector_add("udp", dissect_waveagent_heur, "WaveAgent over UDP", "waveagent_udp", proto_waveagent, HEURISTIC_ENABLE);
}


/*
 * 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:
 */