summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-isis-hello.c
blob: 083a0b129ffb561831e9927d27b0fecf5b17db4f (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
/* packet-isis-hello.c
 * Routines for decoding isis hello packets and their CLVs
 *
 * Stuart Stanley <stuarts@mxmail.net>
 *
 * 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>
#include <epan/expert.h>
#include <epan/nlpid.h>
#include "packet-osi.h"
#include "packet-isis.h"
#include "packet-isis-clv.h"


/*
 * Declarations for L1/L2 hello base header.
 */
#define ISIS_HELLO_CTYPE_MASK           0x03
#define ISIS_HELLO_CT_RESERVED_MASK     0xfc
#define ISIS_HELLO_PRIORITY_MASK        0x7f
#define ISIS_HELLO_P_RESERVED_MASK      0x80

#define ISIS_HELLO_TYPE_RESERVED        0
#define ISIS_HELLO_TYPE_LEVEL_1         1
#define ISIS_HELLO_TYPE_LEVEL_2         2
#define ISIS_HELLO_TYPE_LEVEL_12        3

/*
 * misc. bittest macros
 */

#define ISIS_RESTART_RR                 0x01
#define ISIS_RESTART_RA                 0x02
#define ISIS_RESTART_SA                 0x04
#define ISIS_MASK_RESTART_RR(x)            ((x)&ISIS_RESTART_RR)
#define ISIS_MASK_RESTART_RA(x)            ((x)&ISIS_RESTART_RA)
#define ISIS_MASK_RESTART_SA(x)            ((x)&ISIS_RESTART_SA)

void proto_register_isis_hello(void);
void proto_reg_handoff_isis_hello(void);

static int proto_isis_hello;

/* hello packets */
static int hf_isis_hello_circuit;
static int hf_isis_hello_circuit_reserved;
static int hf_isis_hello_source_id;
static int hf_isis_hello_holding_timer;
static int hf_isis_hello_pdu_length;
static int hf_isis_hello_priority;
static int hf_isis_hello_priority_reserved;
static int hf_isis_hello_lan_id;
static int hf_isis_hello_clv_type;
static int hf_isis_hello_clv_length;
static int hf_isis_hello_local_circuit_id;
static int hf_isis_hello_clv_ipv4_int_addr;
static int hf_isis_hello_clv_ipv6_int_addr;
/* static int hf_isis_hello_clv_ptp_adj; */
static int hf_isis_hello_clv_mt;
static int hf_isis_hello_clv_restart_flags;
static int hf_isis_hello_clv_restart_flags_rr;
static int hf_isis_hello_clv_restart_flags_ra;
static int hf_isis_hello_clv_restart_flags_sa;
static int hf_isis_hello_clv_restart_remain_time;
static int hf_isis_hello_clv_restart_neighbor;
/* Generated from convert_proto_tree_add_text.pl */
static int hf_isis_hello_extended_local_circuit_id;
static int hf_isis_hello_adjacency_state;
static int hf_isis_hello_neighbor_systemid;
static int hf_isis_hello_digest;
static int hf_isis_hello_digest_v;
static int hf_isis_hello_digest_a;
static int hf_isis_hello_digest_d;
static int hf_isis_hello_ect;
static int hf_isis_hello_bvid;
static int hf_isis_hello_bvid_u;
static int hf_isis_hello_bvid_m;
static int hf_isis_hello_area_address;
static int hf_isis_hello_instance_identifier;
static int hf_isis_hello_supported_itid;
static int hf_isis_hello_clv_nlpid_nlpid;
static int hf_isis_hello_clv_ip_authentication;
static int hf_isis_hello_authentication;

static int hf_isis_hello_aux_mcid;
static int hf_isis_hello_mcid;
static int hf_isis_hello_is_neighbor;
static int hf_isis_hello_mtid;
static int hf_isis_hello_checksum;
static int hf_isis_hello_checksum_status;
static int hf_isis_hello_trill_neighbor_sf;
static int hf_isis_hello_trill_neighbor_lf;
static int hf_isis_hello_trill_neighbor_ff;
static int hf_isis_hello_trill_neighbor_of;
static int hf_isis_hello_trill_neighbor_size;
static int hf_isis_hello_trill_neighbor_reserved;
static int hf_isis_hello_trill_neighbor_mtu;
static int hf_isis_hello_trill_neighbor_snpa;
static int hf_isis_hello_reverse_metric_flags;
static int hf_isis_hello_reverse_metric_flag_reserved;
static int hf_isis_hello_reverse_metric_flag_u;
static int hf_isis_hello_reverse_metric_flag_w;
static int hf_isis_hello_reverse_metric_metric;
static int hf_isis_hello_reverse_metric_sub_length;
static int hf_isis_hello_reverse_metric_sub_data;
static int hf_isis_hello_bfd_enabled_nlpid;
static int hf_isis_hello_neighbor_extended_local_circuit_id;
static int hf_isis_hello_vlan_flags_port_id;
static int hf_isis_hello_vlan_flags_nickname;
static int hf_isis_hello_vlan_flags_af;
static int hf_isis_hello_vlan_flags_ac;
static int hf_isis_hello_vlan_flags_vm;
static int hf_isis_hello_vlan_flags_by;
static int hf_isis_hello_vlan_flags_outer_vlan;
static int hf_isis_hello_vlan_flags_tr;
static int hf_isis_hello_vlan_flags_reserved;
static int hf_isis_hello_vlan_flags_designated_vlan;
static int hf_isis_hello_enabled_vlans;
static int hf_isis_hello_appointed_vlans;
static int hf_isis_hello_af_nickname;
static int hf_isis_hello_af_start_vlan;
static int hf_isis_hello_af_end_vlan;
static int hf_isis_hello_trill_version;
static int hf_isis_hello_trill_hello_reduction;
static int hf_isis_hello_trill_unassigned_1;
static int hf_isis_hello_trill_hop_by_hop_flags;
static int hf_isis_hello_trill_unassigned_2;
static int hf_isis_hello_clv_ipv6_glb_int_addr;

static int ett_isis_hello;
static int ett_isis_hello_clv_area_addr;
static int ett_isis_hello_clv_instance_identifier;
static int ett_isis_hello_clv_is_neighbors;
static int ett_isis_hello_clv_padding;
static int ett_isis_hello_clv_unknown;
static int ett_isis_hello_clv_nlpid;
static int ett_isis_hello_clv_nlpid_nlpid;
static int ett_isis_hello_clv_authentication;
static int ett_isis_hello_clv_ip_authentication;
static int ett_isis_hello_clv_ipv4_int_addr;
static int ett_isis_hello_clv_ipv6_int_addr;
static int ett_isis_hello_clv_ptp_adj;
static int ett_isis_hello_clv_mt;
static int ett_isis_hello_clv_restart;
static int ett_isis_hello_clv_restart_flags;
static int ett_isis_hello_clv_mt_port_cap;
static int ett_isis_hello_clv_mt_port_cap_spb_mcid;
static int ett_isis_hello_clv_mt_port_cap_spb_digest;
static int ett_isis_hello_clv_mt_port_cap_spb_bvid_tuples;
static int ett_isis_hello_clv_mt_port_cap_vlan_flags;
static int ett_isis_hello_clv_mt_port_cap_enabled_vlans;
static int ett_isis_hello_clv_mt_port_cap_appointedfwrdrs;
static int ett_isis_hello_clv_mt_port_cap_port_trill_ver;
static int ett_isis_hello_clv_mt_port_cap_vlans_appointed;
static int ett_isis_hello_clv_trill_neighbor;
static int ett_isis_hello_clv_checksum;
static int ett_isis_hello_clv_reverse_metric;
static int ett_isis_hello_clv_bfd_enabled;
static int ett_isis_hello_clv_ipv6_glb_int_addr;
static int ett_isis_hello_reverse_metric_flags;

static expert_field ei_isis_hello_short_pdu;
static expert_field ei_isis_hello_long_pdu;
static expert_field ei_isis_hello_bad_checksum;
static expert_field ei_isis_hello_authentication;
static expert_field ei_isis_hello_subtlv;
static expert_field ei_isis_hello_short_clv;
static expert_field ei_isis_hello_clv_mt;
static expert_field ei_isis_hello_clv_unknown;

static const value_string isis_hello_circuit_type_vals[] = {
    { ISIS_HELLO_TYPE_RESERVED,    "Reserved 0 (discard PDU)"},
    { ISIS_HELLO_TYPE_LEVEL_1,    "Level 1 only"},
    { ISIS_HELLO_TYPE_LEVEL_2,    "Level 2 only"},
    { ISIS_HELLO_TYPE_LEVEL_12,    "Level 1 and 2"},
    { 0,        NULL} };

extern const range_string mtid_strings[];

static void
dissect_hello_mt_port_cap_spb_mcid_clv(tvbuff_t *tvb, packet_info* pinfo,
        proto_tree *tree, int offset, int subtype, int sublen)
{
    const int MCID_LEN = 51;
    const int SUBLEN   = 2 * MCID_LEN;
    proto_tree *subtree;

    if (sublen != SUBLEN) {
        proto_tree_add_expert_format(tree, pinfo, &ei_isis_hello_short_clv, tvb, offset, -1,
                                     "Short SPB MCID TLV (%d vs %d)", sublen, SUBLEN);
        return;
    }


    subtree = proto_tree_add_subtree_format( tree, tvb, offset-2, sublen+2, ett_isis_hello_clv_mt_port_cap_spb_mcid, NULL,
                                "SPB MCID: Type: 0x%02x, Length: %d", subtype, sublen);

    /* MCID: */
    proto_tree_add_item(subtree, hf_isis_hello_mcid, tvb, offset, MCID_LEN, ENC_NA);
    offset += MCID_LEN;

    /* Aux MCID: */
    proto_tree_add_item(subtree, hf_isis_hello_aux_mcid, tvb, offset, MCID_LEN, ENC_NA);
    /* offset += MCID_LEN; */
}

static void
dissect_hello_mt_port_cap_spb_digest_clv(tvbuff_t *tvb, packet_info* pinfo,
        proto_tree *tree, int offset, int subtype, int sublen)
{
    const int DIGEST_LEN = 32;
    const int SUBLEN     = 1 + DIGEST_LEN;
    if (sublen != SUBLEN) {
        proto_tree_add_expert_format(tree, pinfo, &ei_isis_hello_short_clv, tvb, offset, -1,
                              "Short SPB Digest TLV (%d vs %d)", sublen, SUBLEN);
        return;
    }
    else {
        proto_tree *subtree;

        subtree = proto_tree_add_subtree_format( tree, tvb, offset-2, sublen+2, ett_isis_hello_clv_mt_port_cap_spb_digest, NULL,
                                  "SPB Digest: Type: 0x%02x, Length: %d", subtype, sublen);

        proto_tree_add_item( subtree, hf_isis_hello_digest_v, tvb, offset, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item( subtree, hf_isis_hello_digest_a, tvb, offset, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item( subtree, hf_isis_hello_digest_d, tvb, offset, 1, ENC_BIG_ENDIAN);
        ++offset;

        /* Digest: */
        proto_tree_add_item(subtree, hf_isis_hello_digest, tvb, offset, DIGEST_LEN, ENC_NA);
        /* offset += DIGEST_LEN; */
    }
}

static void
dissect_hello_mt_port_cap_spb_bvid_tuples_clv(tvbuff_t *tvb, packet_info* pinfo,
        proto_tree *tree, int offset, int subtype, int sublen)
{
    proto_tree *subtree;
    int subofs = offset;

    subtree = proto_tree_add_subtree_format( tree, tvb, offset-2, sublen+2, ett_isis_hello_clv_mt_port_cap_spb_bvid_tuples, NULL,
                              "SPB Base Vlan Identifiers: Type: 0x%02x, Length: %d", subtype, sublen);

    while (sublen > 0) {
        if (sublen < 6) {
            proto_tree_add_expert_format(tree, pinfo, &ei_isis_hello_short_clv, tvb, offset, -1,
                                  "Short SPB BVID header entry (%d vs %d)", sublen, 6);
            return;
        }
        else {
            proto_tree_add_item( subtree, hf_isis_hello_ect, tvb, subofs, 4, ENC_NA);
            proto_tree_add_item( subtree, hf_isis_hello_bvid, tvb, subofs+4, 2, ENC_BIG_ENDIAN);
            proto_tree_add_item( subtree, hf_isis_hello_bvid_u, tvb, subofs+4, 2, ENC_BIG_ENDIAN);
            proto_tree_add_item( subtree, hf_isis_hello_bvid_m, tvb, subofs+4, 2, ENC_BIG_ENDIAN);
        }
        sublen -= 6;
        subofs += 6;
    }
}

static void
dissect_hello_mt_port_cap_vlan_flags_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
        proto_tree *tree, int offset, int subtype, int sublen)
{
    proto_tree *subtree;

    subtree = proto_tree_add_subtree_format( tree, tvb, offset-2, sublen+2, ett_isis_hello_clv_mt_port_cap_vlan_flags, NULL,
                                "Special VLANs and Flags (t=%u, l=%u)", subtype, sublen);

    proto_tree_add_item(subtree, hf_isis_hello_vlan_flags_port_id, tvb, offset, 2, ENC_BIG_ENDIAN);
    offset += 2;

    proto_tree_add_item(subtree, hf_isis_hello_vlan_flags_nickname, tvb, offset, 2, ENC_BIG_ENDIAN);
    offset += 2;

    proto_tree_add_item(subtree, hf_isis_hello_vlan_flags_af, tvb, offset, 2, ENC_BIG_ENDIAN);
    proto_tree_add_item(subtree, hf_isis_hello_vlan_flags_ac, tvb, offset, 2, ENC_BIG_ENDIAN);
    proto_tree_add_item(subtree, hf_isis_hello_vlan_flags_vm, tvb, offset, 2, ENC_BIG_ENDIAN);
    proto_tree_add_item(subtree, hf_isis_hello_vlan_flags_by, tvb, offset, 2, ENC_BIG_ENDIAN);
    proto_tree_add_item(subtree, hf_isis_hello_vlan_flags_outer_vlan, tvb, offset, 2, ENC_BIG_ENDIAN);
    offset += 2;

    proto_tree_add_item(subtree, hf_isis_hello_vlan_flags_tr, tvb, offset, 2, ENC_BIG_ENDIAN);
    proto_tree_add_item(subtree, hf_isis_hello_vlan_flags_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
    proto_tree_add_item(subtree, hf_isis_hello_vlan_flags_designated_vlan, tvb, offset, 2, ENC_BIG_ENDIAN);

}

static void
parse_vlan_bitmap(proto_item *item, tvbuff_t *tvb, unsigned vlan, int offset, int sublen)
{
    int range=0, next=0;
    uint8_t mask, bitmap, i;

    while (sublen>0) {

        bitmap = tvb_get_uint8(tvb, offset);
        mask = 0x80;

        for (i=0; i<8; i++) {

           if (bitmap & mask) {

               if (range==0) {
                   proto_item_append_text(item, "%s%u", next++ ? ", " : "", vlan);
               }
               range++;

           } else {

               if (range>1) {
                   proto_item_append_text(item, "-%u", vlan-1);
               }
               range=0;

           }
           vlan++;
           mask>>=1;
        }
        offset++;
        sublen--;
    }

    if (range>1) {
        proto_item_append_text(item, "-%u", vlan-1);
    }
}


static void
dissect_hello_mt_port_cap_enabled_vlans_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
        proto_tree *tree, int offset, int subtype, int sublen)
{
    proto_tree *subtree;
    proto_item *item;
    unsigned vlan;

    subtree = proto_tree_add_subtree_format( tree, tvb, offset-2, sublen+2, ett_isis_hello_clv_mt_port_cap_enabled_vlans, NULL,
                                "Enabled-VLANs (t=%u, l=%u)", subtype, sublen);

    vlan = tvb_get_ntohs(tvb, offset) & 0xfff;
    offset+=2;
    sublen-=2;

    item = proto_tree_add_string(subtree, hf_isis_hello_enabled_vlans, tvb, offset, sublen, "");

    parse_vlan_bitmap(item, tvb, vlan, offset, sublen);
}

static void
dissect_hello_mt_port_cap_appointedfwrdrs_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
        proto_tree *tree, int offset, int subtype, int sublen)
{
    proto_tree *subtree;

    subtree = proto_tree_add_subtree_format( tree, tvb, offset-2, sublen+2, ett_isis_hello_clv_mt_port_cap_appointedfwrdrs, NULL,
                                "Appointed Forwarders (t=%u, l=%u)", subtype, sublen);

    while (sublen>=6) {
        proto_tree_add_item(subtree, hf_isis_hello_af_nickname, tvb, offset, 2, ENC_BIG_ENDIAN);
        proto_tree_add_item(subtree, hf_isis_hello_af_start_vlan, tvb, offset+2, 2, ENC_BIG_ENDIAN);
        proto_tree_add_item(subtree, hf_isis_hello_af_end_vlan, tvb, offset+4, 2, ENC_BIG_ENDIAN);

        offset += 6;
        sublen -=6;
    }
}

static void
dissect_hello_mt_port_cap_port_trill_ver_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
        proto_tree *tree, int offset, int subtype, int sublen)
{
    proto_tree *subtree;

    subtree = proto_tree_add_subtree_format( tree, tvb, offset-2, sublen+2, ett_isis_hello_clv_mt_port_cap_port_trill_ver, NULL,
                                "Port TRILL Version (t=%u, l=%u)", subtype, sublen);

    proto_tree_add_item(subtree, hf_isis_hello_trill_version, tvb, offset, 1, ENC_BIG_ENDIAN);

    offset++;

    proto_tree_add_item(subtree, hf_isis_hello_trill_hello_reduction, tvb, offset, 4, ENC_NA);
    proto_tree_add_item(subtree, hf_isis_hello_trill_unassigned_1, tvb, offset, 4, ENC_NA);
    proto_tree_add_item(subtree, hf_isis_hello_trill_hop_by_hop_flags, tvb, offset, 4, ENC_NA);
    proto_tree_add_item(subtree, hf_isis_hello_trill_unassigned_2, tvb, offset, 4, ENC_NA);
}

static void
dissect_hello_mt_port_cap_vlans_appointed_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
        proto_tree *tree, int offset, int subtype, int sublen)
{
    proto_tree *subtree;
    proto_item *item;
    unsigned vlan;

    subtree = proto_tree_add_subtree_format( tree, tvb, offset-2, sublen+2, ett_isis_hello_clv_mt_port_cap_vlans_appointed, NULL,
                                "Appointed VLANs (t=%u, l=%u)", subtype, sublen);

    vlan = tvb_get_ntohs(tvb, offset) & 0xfff;
    offset+=2;
    sublen-=2;

    item = proto_tree_add_string(subtree, hf_isis_hello_appointed_vlans, tvb, offset, sublen, "");

    parse_vlan_bitmap(item, tvb, vlan, offset, sublen);
}

static void
dissect_hello_mt_port_cap_clv(tvbuff_t *tvb, packet_info* pinfo,
        proto_tree *tree, int offset, isis_data_t *isis _U_, int length)
{
    if (length >= 2) {
        /* mtid */
        proto_tree_add_item(tree, hf_isis_hello_mtid, tvb, offset, 2, ENC_BIG_ENDIAN);
        length -= 2;
        offset += 2;
        while (length >= 2) {
            uint8_t subtype   = tvb_get_uint8(tvb, offset);
            uint8_t subtlvlen = tvb_get_uint8(tvb, offset+1);
            length -= 2;
            offset += 2;
            if (subtlvlen > length) {
                proto_tree_add_expert_format(tree, pinfo, &ei_isis_hello_short_clv, tvb, offset, -1,
                                      "Short type %d TLV (%d vs %d)", subtype, subtlvlen, length);
                return;
            }
            switch(subtype)
            {
            case 1:  /* TRILL Special VLANs and Flags */
                dissect_hello_mt_port_cap_vlan_flags_clv(tvb, pinfo, tree, offset, subtype, subtlvlen);
                break;
            case 2:  /* TRILL Enabled VLANs */
                dissect_hello_mt_port_cap_enabled_vlans_clv(tvb, pinfo, tree, offset, subtype, subtlvlen);
                break;
            case 3:  /* TRILL Appointed Forwarders */
                dissect_hello_mt_port_cap_appointedfwrdrs_clv(tvb, pinfo, tree, offset, subtype, subtlvlen);
                break;
            case 4:  /* SPB MCID */
                dissect_hello_mt_port_cap_spb_mcid_clv(tvb, pinfo, tree, offset, subtype, subtlvlen);
                break;
            case 5:  /* SPB Digest */
                dissect_hello_mt_port_cap_spb_digest_clv(tvb, pinfo, tree, offset, subtype, subtlvlen);
                break;
            case 6:  /* SPB BVID Tuples */
                dissect_hello_mt_port_cap_spb_bvid_tuples_clv(tvb, pinfo, tree, offset, subtype, subtlvlen);
                break;
            case 7:  /* Port TRILL Version */
                dissect_hello_mt_port_cap_port_trill_ver_clv(tvb, pinfo, tree, offset, subtype, subtlvlen);
                break;
            case 8:  /* TRILL VLANs Appointed */
                dissect_hello_mt_port_cap_vlans_appointed_clv(tvb, pinfo, tree, offset, subtype, subtlvlen);
                break;
            default:
                proto_tree_add_expert_format(tree, pinfo, &ei_isis_hello_subtlv, tvb, offset-2, subtlvlen+2,
                         "Unknown Sub-TLV: Type: %d, Length: %d", subtype, subtlvlen );
            }
            length -= subtlvlen;
            offset += subtlvlen;
        }
    }
}

/*
 * The Restart CLV is documented in RFC 3847 (Restart Signaling for
 * Intermediate System to Intermediate System).  The CLV looks like this
 *
 *  Type   211
 *  Length # of octets in the value field (1 to (3 + ID Length))
 *  Value
 *
 *                                    No. of octets
 *     +-----------------------+
 *     |   Flags               |     1
 *     +-----------------------+
 *     | Remaining Time        |     2
 *     +-----------------------+
 *     | Restarting Neighbor ID|     ID Length
 *     +-----------------------+
 *
 *   Flags (1 octet)
 *
 *      0  1  2  3  4  5  6  7
 *     +--+--+--+--+--+--+--+--+
 *     |  Reserved    |SA|RA|RR|
 *     +--+--+--+--+--+--+--+--+
 *
 *     RR - Restart Request
 *     RA - Restart Acknowledgement
 *     SA - Suppress adjacency advertisement
 *
 * The Remaining Time and Restarting Neighbor ID fields are only required when
 * the RA flag is set.  The Flags field is always required.
 *
 */
/*
 * Name: dissect_hello_restart_clv()
 *
 * Description:
 *    Decode for a restart clv - only found in IIHs
 *      hence no call in the common clv dissector
 *
 */

static void
dissect_hello_restart_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
        proto_tree *tree, int offset, isis_data_t *isis, int length)
{
    int restart_options=0;
    proto_item *hold_time_item;

    if (length >= 1) {
        static int * const flags[] = {
            &hf_isis_hello_clv_restart_flags_sa,
            &hf_isis_hello_clv_restart_flags_ra,
            &hf_isis_hello_clv_restart_flags_rr,
            NULL
        };

        restart_options = tvb_get_uint8(tvb, offset);
        proto_tree_add_bitmask_with_flags(tree, tvb, offset, hf_isis_hello_clv_restart_flags, ett_isis_hello_clv_restart_flags, flags, ENC_NA, BMT_NO_FALSE|BMT_NO_TFS);
    }

    /* The Remaining Time field should only be present if the RA flag is
     * set
     */
    if (length >= 3 && ISIS_MASK_RESTART_RA(restart_options)) {
        hold_time_item = proto_tree_add_item( tree, hf_isis_hello_clv_restart_remain_time,
            tvb, offset+1, 2, ENC_BIG_ENDIAN );
        proto_item_append_text( hold_time_item, "s" );
    }

    /* The Restarting Neighbor ID should only be present if the RA flag is
     * set.
     */
    if (length >= 3 + isis->system_id_len && ISIS_MASK_RESTART_RA(restart_options)) {
        proto_tree_add_item( tree, hf_isis_hello_clv_restart_neighbor, tvb, offset+3, isis->system_id_len, ENC_NA);
    }
}

/*
 * Name: dissect_hello_nlpid_clv()
 *
 * Description:
 *    Decode for a hello packets NLPID clv.  Calls into the
 *    clv common one.
 *
 * Input:
 *    tvbuff_t * : tvbuffer for packet data
 *    proto_tree * : proto tree to build on (may be null)
 *    int : current offset into packet data
 *    int : length of IDs in packet.
 *    int : length of this clv
 *
 * Output:
 *    void, will modify proto_tree if not null.
 */
static void
dissect_hello_nlpid_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
    proto_tree *tree, int offset, isis_data_t *isis _U_, int length)
{
    isis_dissect_nlpid_clv(tvb, tree, ett_isis_hello_clv_nlpid_nlpid, hf_isis_hello_clv_nlpid_nlpid, offset, length);
}

/*
 * Name: dissect_hello_mt_clv()
 *
 * Description:
 *    Decode for a hello packets Multi Topology clv.  Calls into the
 *    clv common one.
 *
 * Input:
 *    tvbuff_t * : tvbuffer for packet data
 *    proto_tree * : proto tree to build on (may be null)
 *    int : current offset into packet data
 *    int : length of IDs in packet.
 *    int : length of this clv
 *
 * Output:
 *    void, will modify proto_tree if not null.
 */

static void
dissect_hello_mt_clv(tvbuff_t *tvb, packet_info* pinfo,
    proto_tree *tree, int offset, isis_data_t *isis _U_, int length)
{
    isis_dissect_mt_clv(tvb, pinfo, tree, offset, length,
        hf_isis_hello_clv_mt, &ei_isis_hello_clv_mt);
}

/*
 * Name: dissect_hello_ip_int_addr_clv()
 *
 * Description:
 *    Decode for a hello packets ip interface addr clv.  Calls into the
 *    clv common one.
 *
 * Input:
 *    tvbuff_t * : tvbuffer for packet data
 *    proto_tree * : proto tree to build on (may be null)
 *    int : current offset into packet data
 *    int : length of IDs in packet.
 *    int : length of this clv
 *
 * Output:
 *    void, will modify proto_tree if not null.
 */
static void
dissect_hello_ip_int_addr_clv(tvbuff_t *tvb, packet_info* pinfo,
    proto_tree *tree, int offset, isis_data_t *isis _U_, int length)
{
    isis_dissect_ip_int_clv(tree, pinfo, tvb, &ei_isis_hello_short_clv,
        offset, length, hf_isis_hello_clv_ipv4_int_addr );
}

/*
 * Name: dissect_hello_ipv6_int_addr_clv()
 *
 * Description:
 *    Decode for a hello packets ipv6 interface addr clv.  Calls into the
 *    clv common one.
 *
 * Input:
 *    tvbuff_t * : tvbuffer for packet data
 *    proto_tree * : proto tree to build on (may be null)
 *    int : current offset into packet data
 *    int : length of IDs in packet.
 *    int : length of this clv
 *
 * Output:
 *    void, will modify proto_tree if not null.
 */
static void
dissect_hello_ipv6_int_addr_clv(tvbuff_t *tvb, packet_info* pinfo,
    proto_tree *tree, int offset, isis_data_t *isis _U_, int length)
{
    isis_dissect_ipv6_int_clv(tree, pinfo, tvb, &ei_isis_hello_short_clv,
        offset, length, hf_isis_hello_clv_ipv6_int_addr );
}

/*
 * Name: dissect_hello_authentication_clv()
 *
 * Description:
 *    Decode for a hello packets authentication clv.
 *      Calls into the CLV common one.
 *
 * Input:
 *    tvbuff_t * : tvbuffer for packet data
 *    proto_tree * : proto tree to build on (may be null)
 *    int : current offset into packet data
 *    int : length of IDs in packet.
 *    int : length of this clv
 *
 * Output:
 *    void, will modify proto_tree if not null.
 */
static void
dissect_hello_authentication_clv(tvbuff_t *tvb, packet_info* pinfo,
    proto_tree *tree, int offset, isis_data_t *isis _U_, int length)
{
    isis_dissect_authentication_clv(tree, pinfo, tvb, hf_isis_hello_authentication, hf_isis_clv_key_id, &ei_isis_hello_authentication, offset, length);
}

/*
 * Name: dissect_hello_ip_authentication_clv()
 *
 * Description:
 *    Decode for a hello packets IP authentication clv.
 *      Calls into the CLV common one.
 *
 * Input:
 *    tvbuff_t * : tvbuffer for packet data
 *    proto_tree * : proto tree to build on (may be null)
 *    int : current offset into packet data
 *    int : length of IDs in packet.
 *    int : length of this clv
 *
 * Output:
 *    void, will modify proto_tree if not null.
 */
static void
dissect_hello_ip_authentication_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
    proto_tree *tree, int offset, isis_data_t *isis _U_, int length)
{
    if ( length != 0 ) {
       proto_tree_add_item( tree, hf_isis_hello_clv_ip_authentication, tvb, offset, length, ENC_ASCII);
    }
}

/*
 * Name: dissect_hello_trill_neighbor_clv
 */
static void
dissect_hello_trill_neighbor_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
        proto_tree *tree, int offset, isis_data_t *isis _U_, int length) {

    uint8_t size = (tvb_get_uint8(tvb, offset)) & 0x1f;

    if(size==0)
        size=6;

    proto_tree_add_item(tree, hf_isis_hello_trill_neighbor_sf, tvb, offset, 1, ENC_NA);
    proto_tree_add_item(tree, hf_isis_hello_trill_neighbor_lf, tvb, offset, 1, ENC_NA);
    proto_tree_add_item(tree, hf_isis_hello_trill_neighbor_size, tvb, offset, 1, ENC_BIG_ENDIAN);

    offset++;
    length--;

    while(length>=(size+3)) {
        proto_tree_add_item(tree, hf_isis_hello_trill_neighbor_ff, tvb, offset, 1, ENC_NA);
        proto_tree_add_item(tree, hf_isis_hello_trill_neighbor_of, tvb, offset, 1, ENC_NA);
        proto_tree_add_item(tree, hf_isis_hello_trill_neighbor_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);

        offset++;
        length--;

        proto_tree_add_item(tree, hf_isis_hello_trill_neighbor_mtu, tvb, offset, 2, ENC_BIG_ENDIAN);

        offset += 2;
        length -= 2;

        proto_tree_add_item(tree, hf_isis_hello_trill_neighbor_snpa, tvb, offset, 6, ENC_NA);

        offset += 6;
        length -= 6;
    }
}

/*
 * Name: dissect_hello_reverse_metric_clv
 */
static void
dissect_hello_reverse_metric_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
        proto_tree *tree, int offset, isis_data_t *isis _U_, int length _U_) {

    uint32_t sub_length;

    static int * const flags[] = {
        &hf_isis_hello_reverse_metric_flag_reserved,
        &hf_isis_hello_reverse_metric_flag_u,
        &hf_isis_hello_reverse_metric_flag_w,
        NULL
    };

    proto_tree_add_bitmask(tree, tvb, offset, hf_isis_hello_reverse_metric_flags, ett_isis_hello_reverse_metric_flags, flags, ENC_NA);
    offset += 1;
    proto_tree_add_item(tree, hf_isis_hello_reverse_metric_metric, tvb, offset, 3, ENC_BIG_ENDIAN);
    offset += 3;
    proto_tree_add_item_ret_uint(tree, hf_isis_hello_reverse_metric_sub_length, tvb, offset, 1, ENC_BIG_ENDIAN, &sub_length);
    offset += 1;
    if (sub_length > 0) {
        proto_tree_add_item(tree, hf_isis_hello_reverse_metric_sub_data, tvb, offset, sub_length, ENC_NA);
    }
}

/*
 * Name: dissect_hello_bfd_enabled_clv
 *
 * Description:
 *    Decode for a hello packets BFD enabled clv.
 *
 * Input:
 *    tvbuff_t * : tvbuffer for packet data
 *    proto_tree * : proto tree to build on (may be null)
 *    int : current offset into packet data
 *    int : length of IDs in packet.
 *    int : length of this clv
 *
 * Output:
 *    void, will modify proto_tree if not null.
 */
static void
dissect_hello_bfd_enabled_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
        proto_tree *tree, int offset, isis_data_t *isis _U_, int length) {

    while (length >= 3) {
        /* mtid */
        proto_tree_add_item(tree, hf_isis_hello_mtid, tvb, offset, 2, ENC_BIG_ENDIAN);
        length -= 2;
        offset += 2;
        /* nlpid */
        proto_tree_add_item(tree, hf_isis_hello_bfd_enabled_nlpid, tvb, offset, 1, ENC_NA);
        length -= 1;
        offset += 1;
    };
}

/*
 * Name: dissect_hello_checksum_clv()
 *
 * Description:
 *      dump and verify the optional checksum in TLV 12
 *
 * Input:
 *      tvbuff_t * : tvbuffer for packet data
 *      proto_tree * : protocol display tree to fill out.  May be NULL
 *      int : offset into packet data where we are.
 *      int : length of clv we are decoding
 *
 * Output:
 *      void, but we will add to proto tree if !NULL.
 */

static void
dissect_hello_checksum_clv(tvbuff_t *tvb, packet_info* pinfo,
        proto_tree *tree, int offset, isis_data_t *isis, int length) {

    uint16_t checksum, cacl_checksum=0;

    if ( length != 2 ) {
        proto_tree_add_expert_format(tree, pinfo, &ei_isis_hello_short_clv, tvb, offset, length,
                                "incorrect checksum length (%u), should be (2)", length );
        return;
    }

    checksum = tvb_get_ntohs(tvb, offset);

    if (checksum == 0) {
        /* No checksum present */
        proto_tree_add_checksum(tree, tvb, offset, hf_isis_hello_checksum, hf_isis_hello_checksum_status, &ei_isis_hello_bad_checksum, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
    } else {
        if (osi_check_and_get_checksum(tvb, 0, isis->pdu_length, offset, &cacl_checksum)) {
            /* Successfully processed checksum, verify it */
            proto_tree_add_checksum(tree, tvb, offset, hf_isis_hello_checksum, hf_isis_hello_checksum_status, &ei_isis_hello_bad_checksum, pinfo, cacl_checksum, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
        } else {
            /* We didn't capture the entire packet, so we can't verify it */
            proto_tree_add_checksum(tree, tvb, offset, hf_isis_hello_checksum, hf_isis_hello_checksum_status, &ei_isis_hello_bad_checksum, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
        }
    }
}



/*
 * Name: dissect_hello_area_address_clv()
 *
 * Description:
 *    Decode for a hello packets area address clv.
 *      Calls into the CLV common one.
 *
 * Input:
 *    tvbuff_t * : tvbuffer for packet data
 *    proto_tree * : proto tree to build on (may be null)
 *    int : current offset into packet data
 *    int : length of IDs in packet.
 *    int : length of this clv
 *
 * Output:
 *    void, will modify proto_tree if not null.
 */
static void
dissect_hello_area_address_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
    proto_tree *tree, int offset, isis_data_t *isis _U_, int length)
{
    isis_dissect_area_address_clv(tree, pinfo, tvb, &ei_isis_hello_short_clv, hf_isis_hello_area_address, offset, length);
}

/*
 * Name: dissect_hello_instance_identifier_clv()
 *
 * Description:
 *    Decode for a hello packets Instance Identifier clv.
 *      Calls into the CLV common one.
 *
 * Input:
 *    tvbuff_t * : tvbuffer for packet data
 *    proto_tree * : proto tree to build on (may be null)
 *    int : current offset into packet data
 *    int : length of IDs in packet.
 *    int : length of this clv
 *
 * Output:
 *    void, will modify proto_tree if not null.
 */
static void
dissect_hello_instance_identifier_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
    proto_tree *tree, int offset, isis_data_t *isis _U_, int length)
{
    isis_dissect_instance_identifier_clv(tree, pinfo, tvb, &ei_isis_hello_short_clv, hf_isis_hello_instance_identifier, hf_isis_hello_supported_itid, offset, length);
}

static const value_string adj_state_vals[] = {
    { 0, "Up" },
    { 1, "Initializing" },
    { 2, "Down" },
    { 0, NULL }
};

static void
dissect_hello_ptp_adj_clv(tvbuff_t *tvb, packet_info* pinfo,
        proto_tree *tree, int offset, isis_data_t *isis, int length)
{
    switch(length)
    {
    case 1:
        proto_tree_add_item(tree, hf_isis_hello_adjacency_state, tvb, offset, 1, ENC_BIG_ENDIAN);
        break;
    case 5:
        proto_tree_add_item(tree, hf_isis_hello_adjacency_state, tvb, offset, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(tree, hf_isis_hello_extended_local_circuit_id, tvb, offset+1, 4, ENC_BIG_ENDIAN);
        break;
    case 11:
        proto_tree_add_item(tree, hf_isis_hello_adjacency_state, tvb, offset, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(tree, hf_isis_hello_extended_local_circuit_id, tvb, offset+1, 4, ENC_BIG_ENDIAN);
        proto_tree_add_item(tree, hf_isis_hello_neighbor_systemid, tvb, offset+5, isis->system_id_len, ENC_NA);
    break;
    case 15:
        proto_tree_add_item(tree, hf_isis_hello_adjacency_state, tvb, offset, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(tree, hf_isis_hello_extended_local_circuit_id, tvb, offset+1, 4, ENC_BIG_ENDIAN);
        proto_tree_add_item(tree, hf_isis_hello_neighbor_systemid, tvb, offset+5, isis->system_id_len, ENC_NA);
        proto_tree_add_item(tree, hf_isis_hello_neighbor_extended_local_circuit_id, tvb, offset+5+isis->system_id_len, 4, ENC_BIG_ENDIAN);
    break;
    default:
        proto_tree_add_expert_format(tree, pinfo, &ei_isis_hello_short_clv, tvb, offset, -1,
                   "malformed TLV (%d vs 1,5,11,15)", length );
    }
}

/*
 * Name: isis_dissect_is_neighbors_clv()
 *
 * Description:
 *    Take apart a IS neighbor packet.  A neighbor is n 6 byte packets.
 *    (they tend to be an 802.3 MAC address, but it's not required).
 *
 * Input:
 *    tvbuff_t * : tvbuffer for packet data
 *    proto_tree * : protocol display tree to fill out.  May be NULL
 *    int : offset into packet data where we are.
 *    int : length of IDs in packet.
 *    int : length of clv we are decoding
 *
 * Output:
 *    void, but we will add to proto tree if !NULL.
 */
static void
dissect_hello_is_neighbors_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
    isis_data_t *isis _U_, int length)
{
    while ( length > 0 ) {
        if (length<6) {
            proto_tree_add_expert_format(tree, pinfo, &ei_isis_hello_short_clv, tvb, offset, -1,
                "short is neighbor (%d vs 6)", length );
            return;
        }
        /*
         * Lets turn the area address into "standard" 0000.0000.etc
         * format string.
         */
        proto_tree_add_item(tree, hf_isis_hello_is_neighbor, tvb, offset, 6, ENC_NA);
        offset += 6;
        length -= 6;
    }
}

/*
 * Name: dissect_hello_padding_clv()
 *
 * Description:
 *    Decode for a hello packet's padding clv.  Padding does nothing,
 *    so we just return.
 *
 * Input:
 *    tvbuff_t * : tvbuffer for packet data
 *    proto_tree * : proto tree to build on (may be null)
 *    int : current offset into packet data
 *    int : length of IDs in packet.
 *    int : length of this clv
 *
 * Output:
 *    void
 */
static void
dissect_hello_padding_clv(tvbuff_t *tvb _U_, packet_info* pinfo _U_, proto_tree *tree _U_, int offset _U_,
    isis_data_t *isis _U_, int length _U_)
{
    /* nothing to do here! */
}

/*
 * Name: dissect_hello_ipv6_glb_int_addr_clv()
 *
 * Description:
 *    Decode for a hello packets ipv6 gobal interface addr clv.  Calls into the
 *    clv 233.
 *
 * Input:
 *    tvbuff_t * : tvbuffer for packet data
 *    proto_tree * : proto tree to build on (may be null)
 *    int : current offset into packet data
 *    int : length of IDs in packet.
 *    int : length of this clv
 *
 * Output:
 *    void, will modify proto_tree if not null.
 */
static void
dissect_hello_ipv6_glb_int_addr_clv(tvbuff_t *tvb, packet_info* pinfo,
    proto_tree *tree, int offset, isis_data_t *isis _U_, int length)
{
    isis_dissect_ipv6_int_clv(tree, pinfo, tvb, &ei_isis_hello_short_clv,
        offset, length, hf_isis_hello_clv_ipv6_glb_int_addr );
}
static const isis_clv_handle_t clv_l1_hello_opts[] = {
    {
        ISIS_CLV_AREA_ADDRESS,
        "Area address(es)",
        &ett_isis_hello_clv_area_addr,
        dissect_hello_area_address_clv
    },
    {
        ISIS_CLV_IS_NEIGHBORS,
        "IS Neighbor(s)",
        &ett_isis_hello_clv_is_neighbors,
        dissect_hello_is_neighbors_clv
    },
    {
        ISIS_CLV_INSTANCE_IDENTIFIER,
        "Instance Identifier",
        &ett_isis_hello_clv_instance_identifier,
        dissect_hello_instance_identifier_clv
    },
    {
        ISIS_CLV_PADDING,
        "Padding",
        &ett_isis_hello_clv_padding,
        dissect_hello_padding_clv
    },
    {
        ISIS_CLV_PROTOCOLS_SUPPORTED,
        "Protocols Supported",
        &ett_isis_hello_clv_nlpid,
        dissect_hello_nlpid_clv
    },
    {
        ISIS_CLV_IP_ADDR,
        "IP Interface address(es)",
        &ett_isis_hello_clv_ipv4_int_addr,
        dissect_hello_ip_int_addr_clv
    },
    {
        ISIS_CLV_IP6_ADDR,
        "IPv6 Interface address(es)",
        &ett_isis_hello_clv_ipv6_int_addr,
        dissect_hello_ipv6_int_addr_clv
    },
    {
        ISIS_CLV_RESTART,
        "Restart Signaling",
        &ett_isis_hello_clv_restart,
        dissect_hello_restart_clv
    },
    {
        ISIS_CLV_AUTHENTICATION,
        "Authentication",
        &ett_isis_hello_clv_authentication,
        dissect_hello_authentication_clv
    },
    {
        ISIS_CLV_IP_AUTHENTICATION,
        "IP Authentication",
        &ett_isis_hello_clv_ip_authentication,
        dissect_hello_ip_authentication_clv
    },
    {
        ISIS_CLV_MT_PORT_CAP,
        "MT Port Capability",
        &ett_isis_hello_clv_mt_port_cap,
        dissect_hello_mt_port_cap_clv
    },
    {
        ISIS_CLV_MT_SUPPORTED,
        "Multi Topology",
        &ett_isis_hello_clv_mt,
        dissect_hello_mt_clv
    },
    {
        ISIS_CLV_TRILL_NEIGHBOR,
        "TRILL Neighbor",
        &ett_isis_hello_clv_trill_neighbor,
        dissect_hello_trill_neighbor_clv
    },
    {
        ISIS_CLV_CHECKSUM,
        "Checksum",
        &ett_isis_hello_clv_checksum,
        dissect_hello_checksum_clv
    },
    {
        ISIS_CLV_IPV6_GBL_INT_ADDR,
        "IPv6 Global Interface Address",
        &ett_isis_hello_clv_ipv6_glb_int_addr,
        dissect_hello_ipv6_glb_int_addr_clv
    },
    {
        ISIS_CLV_REVERSE_METRIC,
        "Reverse Metric",
        &ett_isis_hello_clv_reverse_metric,
        dissect_hello_reverse_metric_clv
    },
    {
        ISIS_CLV_BFD_ENABLED,
        "BFD Enabled",
        &ett_isis_hello_clv_bfd_enabled,
        dissect_hello_bfd_enabled_clv
    },
    {
        0,
        "",
        NULL,
        NULL
    }
};

static const isis_clv_handle_t clv_l2_hello_opts[] = {
    {
        ISIS_CLV_AREA_ADDRESS,
        "Area address(es)",
        &ett_isis_hello_clv_area_addr,
        dissect_hello_area_address_clv
    },
    {
        ISIS_CLV_IS_NEIGHBORS,
        "IS Neighbor(s)",
        &ett_isis_hello_clv_is_neighbors,
        dissect_hello_is_neighbors_clv
    },
    {
        ISIS_CLV_INSTANCE_IDENTIFIER,
        "Instance Identifier",
        &ett_isis_hello_clv_instance_identifier,
        dissect_hello_instance_identifier_clv
    },
    {
        ISIS_CLV_PADDING,
        "Padding",
        &ett_isis_hello_clv_padding,
        dissect_hello_padding_clv
    },
    {
        ISIS_CLV_PROTOCOLS_SUPPORTED,
        "Protocols Supported",
        &ett_isis_hello_clv_nlpid,
        dissect_hello_nlpid_clv
    },
    {
        ISIS_CLV_IP_ADDR,
        "IP Interface address(es)",
        &ett_isis_hello_clv_ipv4_int_addr,
        dissect_hello_ip_int_addr_clv
    },
    {
        ISIS_CLV_IP6_ADDR,
        "IPv6 Interface address(es)",
        &ett_isis_hello_clv_ipv6_int_addr,
        dissect_hello_ipv6_int_addr_clv
    },
    {
        ISIS_CLV_AUTHENTICATION,
        "Authentication",
        &ett_isis_hello_clv_authentication,
        dissect_hello_authentication_clv
    },
    {
        ISIS_CLV_IP_AUTHENTICATION,
        "IP Authentication",
        &ett_isis_hello_clv_ip_authentication,
        dissect_hello_ip_authentication_clv
    },
    {
        ISIS_CLV_RESTART,
        "Restart Signaling",
        &ett_isis_hello_clv_restart,
        dissect_hello_restart_clv
    },
    {
        ISIS_CLV_MT_SUPPORTED,
        "Multi Topology",
        &ett_isis_hello_clv_mt,
        dissect_hello_mt_clv
    },
    {
        ISIS_CLV_CHECKSUM,
        "Checksum",
        &ett_isis_hello_clv_checksum,
        dissect_hello_checksum_clv
    },
    {
        ISIS_CLV_IPV6_GBL_INT_ADDR,
        "IPv6 Global Interface Address",
        &ett_isis_hello_clv_ipv6_glb_int_addr,
        dissect_hello_ipv6_glb_int_addr_clv
    },
    {
        ISIS_CLV_BFD_ENABLED,
        "BFD Enabled",
        &ett_isis_hello_clv_bfd_enabled,
        dissect_hello_bfd_enabled_clv
    },
    {
        0,
        "",
        NULL,
        NULL
    }
};

static const isis_clv_handle_t clv_ptp_hello_opts[] = {
    {
        ISIS_CLV_AREA_ADDRESS,
        "Area address(es)",
        &ett_isis_hello_clv_area_addr,
        dissect_hello_area_address_clv
    },
    {
        ISIS_CLV_INSTANCE_IDENTIFIER,
        "Instance Identifier",
        &ett_isis_hello_clv_instance_identifier,
        dissect_hello_instance_identifier_clv
    },
    {
        ISIS_CLV_PADDING,
        "Padding",
        &ett_isis_hello_clv_padding,
        dissect_hello_padding_clv
    },
    {
        ISIS_CLV_PROTOCOLS_SUPPORTED,
        "Protocols Supported",
        &ett_isis_hello_clv_nlpid,
        dissect_hello_nlpid_clv
    },
    {
        ISIS_CLV_IP_ADDR,
        "IP Interface address(es)",
        &ett_isis_hello_clv_ipv4_int_addr,
        dissect_hello_ip_int_addr_clv
    },
    {
        ISIS_CLV_IP6_ADDR,
        "IPv6 Interface address(es)",
        &ett_isis_hello_clv_ipv6_int_addr,
        dissect_hello_ipv6_int_addr_clv
    },
    {
        ISIS_CLV_AUTHENTICATION,
        "Authentication",
        &ett_isis_hello_clv_authentication,
        dissect_hello_authentication_clv
    },
    {
        ISIS_CLV_IP_AUTHENTICATION,
        "IP Authentication",
        &ett_isis_hello_clv_ip_authentication,
        dissect_hello_ip_authentication_clv
    },
    {
        ISIS_CLV_MT_PORT_CAP,
        "MT Port Capability",
        &ett_isis_hello_clv_mt_port_cap,
        dissect_hello_mt_port_cap_clv
    },
    {
        ISIS_CLV_RESTART,
        "Restart Signaling",
        &ett_isis_hello_clv_restart,
        dissect_hello_restart_clv
    },
    {
        ISIS_CLV_PTP_ADJ_STATE,
        "Point-to-point Adjacency State",
        &ett_isis_hello_clv_ptp_adj,
        dissect_hello_ptp_adj_clv
    },
    {
        ISIS_CLV_MT_SUPPORTED,
        "Multi Topology",
        &ett_isis_hello_clv_mt,
        dissect_hello_mt_clv
    },
    {
        ISIS_CLV_CHECKSUM,
        "Checksum",
        &ett_isis_hello_clv_checksum,
        dissect_hello_checksum_clv
    },
    {
        ISIS_CLV_IPV6_GBL_INT_ADDR,
        "IPv6 Global Interface Address",
        &ett_isis_hello_clv_ipv6_glb_int_addr,
        dissect_hello_ipv6_glb_int_addr_clv
    },
    {
        ISIS_CLV_BFD_ENABLED,
        "BFD Enabled",
        &ett_isis_hello_clv_bfd_enabled,
        dissect_hello_bfd_enabled_clv
    },
    {
        0,
        "",
        NULL,
        NULL
    }
};

/*
 * Name: isis_dissect_isis_hello()
 *
 * Description:
 *    This procedure rips apart the various types of ISIS hellos.  L1H and
 *    L2H's are identical for the most part, while the PTP hello has
 *    a shorter header.
 */
static void
dissect_isis_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
    const isis_clv_handle_t *opts, isis_data_t *isis)
{
    proto_item    *ti;
    proto_tree    *hello_tree;
    uint16_t       pdu_length;
    bool           pdu_length_too_short = false;

    /*
     * We are passed a tvbuff for the entire ISIS PDU, because some ISIS
     * PDUs may contain a checksum CLV, and that's a checksum covering
     * the entire PDU.  Skip the part of the header that's already been
     * dissected.
     */
    offset += 8;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "ISIS HELLO");

    ti = proto_tree_add_item(tree, proto_isis_hello, tvb, offset, -1, ENC_NA);
    hello_tree = proto_item_add_subtree(ti, ett_isis_hello);

    if (isis->header_length < 8 + 1) {
        /* Not large enough to include the part of the header that
           we dissect here. */
        expert_add_info(pinfo, isis->header_length_item, isis->ei_bad_header_length);
        return;
    }
    proto_tree_add_item(hello_tree, hf_isis_hello_circuit, tvb, offset, 1, ENC_BIG_ENDIAN);
    proto_tree_add_item(hello_tree, hf_isis_hello_circuit_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset += 1;

    if (isis->header_length < 8 + 1 + isis->system_id_len) {
        /* Not large enough to include the part of the header that
           we dissect here. */
        expert_add_info(pinfo, isis->header_length_item, isis->ei_bad_header_length);
        return;
    }
    proto_tree_add_item(hello_tree, hf_isis_hello_source_id, tvb, offset, isis->system_id_len, ENC_NA);
    col_append_fstr(pinfo->cinfo, COL_INFO, ", System-ID: %s", tvb_print_system_id( pinfo->pool, tvb, offset, isis->system_id_len ));
    offset += isis->system_id_len;

    if (isis->header_length < 8 + 1 + isis->system_id_len + 2) {
        /* Not large enough to include the part of the header that
           we dissect here. */
        expert_add_info(pinfo, isis->header_length_item, isis->ei_bad_header_length);
        return;
    }
    proto_tree_add_item(hello_tree, hf_isis_hello_holding_timer, tvb,
                        offset, 2, ENC_BIG_ENDIAN);
    offset += 2;

    if (isis->header_length < 8 + 1 + isis->system_id_len + 2 + 2) {
        /* Not large enough to include the part of the header that
           we dissect here. */
        expert_add_info(pinfo, isis->header_length_item, isis->ei_bad_header_length);
        return;
    }
    pdu_length = tvb_get_ntohs(tvb, offset);
    ti = proto_tree_add_uint(hello_tree, hf_isis_hello_pdu_length, tvb,
                             offset, 2, pdu_length);
    if (pdu_length < isis->header_length) {
        expert_add_info(pinfo, ti, &ei_isis_hello_short_pdu);
        pdu_length_too_short = true;
    } else if (pdu_length > tvb_reported_length(tvb) + isis->header_length) {
        expert_add_info(pinfo, ti, &ei_isis_hello_long_pdu);
    }
    offset += 2;

    if (opts == clv_ptp_hello_opts) {
        if (isis->header_length < 8 + 1 + isis->system_id_len + 2 + 2 + 1) {
            /* Not large enough to include the part of the header that
               we dissect here. */
            expert_add_info(pinfo, isis->header_length_item, isis->ei_bad_header_length);
            return;
        }
        proto_tree_add_item(hello_tree, hf_isis_hello_local_circuit_id, tvb,
                         offset, 1, ENC_BIG_ENDIAN );
        offset += 1;
    } else {
        if (isis->header_length < 8 + 1 + isis->system_id_len + 2 + 2 + 1) {
            /* Not large enough to include the part of the header that
               we dissect here. */
            expert_add_info(pinfo, isis->header_length_item, isis->ei_bad_header_length);
            return;
        }
        proto_tree_add_item(hello_tree, hf_isis_hello_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(hello_tree, hf_isis_hello_priority_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset += 1;

        if (isis->header_length < 8 + 1 + isis->system_id_len + 2 + 2 + 1 + isis->system_id_len + 1) {
            /* Not large enough to include the part of the header that
               we dissect here. */
            expert_add_info(pinfo, isis->header_length_item, isis->ei_bad_header_length);
            return;
        }
        proto_tree_add_item(hello_tree, hf_isis_hello_lan_id, tvb, offset, isis->system_id_len + 1, ENC_NA);
        offset += isis->system_id_len + 1;
    }

    if (pdu_length_too_short) {
        return;
    }
    /*
     * Now, we need to decode our CLVs.  We need to pass in
     * our list of valid ones!
     */
    isis->pdu_length = pdu_length;
    isis_dissect_clvs(tvb, pinfo, hello_tree, offset,
            opts, &ei_isis_hello_short_clv, isis, ett_isis_hello_clv_unknown,
            hf_isis_hello_clv_type, hf_isis_hello_clv_length,
            &ei_isis_hello_clv_unknown);
}


static int
dissect_isis_l1_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
    isis_data_t* isis = (isis_data_t*)data;
    dissect_isis_hello(tvb, pinfo, tree, 0, clv_l1_hello_opts, isis);
    return tvb_captured_length(tvb);
}

static int
dissect_isis_l2_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
    isis_data_t* isis = (isis_data_t*)data;
    dissect_isis_hello(tvb, pinfo, tree, 0, clv_l2_hello_opts, isis);
    return tvb_captured_length(tvb);
}

static int
dissect_isis_ptp_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
    isis_data_t* isis = (isis_data_t*)data;
    dissect_isis_hello(tvb, pinfo, tree, 0, clv_ptp_hello_opts, isis);
    return tvb_captured_length(tvb);
}

/*
 * Name: isis_register_hello()
 *
 * Description:
 *    Register our protocol sub-sets with protocol manager.
 *
 * Input:
 *    int : protocol index for the ISIS protocol
 *
 * Output:
 *    void
 */
void
proto_register_isis_hello(void)
{
    static hf_register_info hf[] = {
        { &hf_isis_hello_circuit,
        { "Circuit type", "isis.hello.circuit_type",
            FT_UINT8, BASE_HEX, VALS(isis_hello_circuit_type_vals), ISIS_HELLO_CTYPE_MASK, NULL, HFILL }},

        { &hf_isis_hello_circuit_reserved,
        { "Reserved", "isis.hello.reserved",
            FT_UINT8, BASE_HEX, NULL, ISIS_HELLO_CT_RESERVED_MASK, NULL, HFILL }},

        { &hf_isis_hello_source_id,
        { "SystemID {Sender of PDU}", "isis.hello.source_id",
            FT_SYSTEM_ID, BASE_NONE, NULL, 0x0, NULL, HFILL }},

        { &hf_isis_hello_holding_timer,
        { "Holding timer", "isis.hello.holding_timer",
            FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},

        { &hf_isis_hello_pdu_length,
        { "PDU length", "isis.hello.pdu_length",
            FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},

        { &hf_isis_hello_priority,
         { "Priority", "isis.hello.priority",
            FT_UINT8, BASE_DEC, NULL, ISIS_HELLO_PRIORITY_MASK, NULL, HFILL }},

        { &hf_isis_hello_priority_reserved,
         { "Reserved", "isis.hello.reserved",
            FT_UINT8, BASE_DEC, NULL, ISIS_HELLO_P_RESERVED_MASK, NULL, HFILL }},

        { &hf_isis_hello_lan_id,
        { "SystemID {Designated IS}", "isis.hello.lan_id",
            FT_SYSTEM_ID, BASE_NONE, NULL, 0x0, NULL, HFILL }},

        { &hf_isis_hello_clv_type,
        { "Type", "isis.hello.clv.type",
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},

        { &hf_isis_hello_clv_length,
        { "Length", "isis.hello.clv.length",
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},

        { &hf_isis_hello_local_circuit_id,
        { "Local circuit ID", "isis.hello.local_circuit_id",
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},

        { &hf_isis_hello_clv_ipv4_int_addr,
        { "IPv4 interface address", "isis.hello.clv_ipv4_int_addr",
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},

        { &hf_isis_hello_clv_ipv6_int_addr,
        { "IPv6 interface address", "isis.hello.clv_ipv6_int_addr",
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},

#if 0
        { &hf_isis_hello_clv_ptp_adj,
        { "Point-to-point Adjacency", "isis.hello.clv_ptp_adj",
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
#endif

        { &hf_isis_hello_clv_mt,
        { "MT-ID", "isis.hello.clv_mt",
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},

        { &hf_isis_hello_clv_restart_flags,
        { "Restart Signaling Flags", "isis.hello.clv_restart_flags",
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},

        { &hf_isis_hello_clv_restart_flags_rr,
        { "Restart Request", "isis.hello.clv_restart_flags.rr",
            FT_BOOLEAN, 8, NULL, ISIS_RESTART_RR,
            "When set, the router is beginning a graceful restart", HFILL }},

        { &hf_isis_hello_clv_restart_flags_ra,
        { "Restart Acknowledgment", "isis.hello.clv_restart_flags.ra",
            FT_BOOLEAN, 8, NULL, ISIS_RESTART_RA,
            "When set, the router is willing to enter helper mode", HFILL }},

        { &hf_isis_hello_clv_restart_flags_sa,
        { "Suppress Adjacency", "isis.hello.clv_restart_flags.sa",
            FT_BOOLEAN, 8, NULL, ISIS_RESTART_SA,
            "When set, the router is starting as opposed to restarting", HFILL }},

        { &hf_isis_hello_clv_restart_remain_time,
        { "Remaining holding time", "isis.hello.clv_restart.remain_time",
            FT_UINT16, BASE_DEC, NULL, 0x0,
            "How long the helper router will maintain the existing adjacency", HFILL }},

        { &hf_isis_hello_clv_restart_neighbor,
        { "Restarting Neighbor ID", "isis.hello.clv_restart.neighbor",
            FT_SYSTEM_ID, BASE_NONE, NULL, 0x0,
            "The System ID of the restarting neighbor", HFILL }},

      /* Generated from convert_proto_tree_add_text.pl */
      { &hf_isis_hello_mcid, { "MCID", "isis.hello.mcid", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_aux_mcid, { "Aux MCID", "isis.hello.aux_mcid", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_digest, { "Digest", "isis.hello.digest", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_digest_v, { "V", "isis.hello.digest.v", FT_UINT8, BASE_DEC, NULL, 0x10, NULL, HFILL }},
      { &hf_isis_hello_digest_a, { "A", "isis.hello.digest.a", FT_UINT8, BASE_DEC, NULL, 0x0c, NULL, HFILL }},
      { &hf_isis_hello_digest_d, { "D", "isis.hello.digest.d", FT_UINT8, BASE_DEC, NULL, 0x03, NULL, HFILL }},
      { &hf_isis_hello_ect, { "ECT", "isis.hello.ect", FT_BYTES, SEP_DASH, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_bvid, { "BVID", "isis.hello.bvid", FT_UINT16, BASE_HEX_DEC, NULL, 0xFFF0, NULL, HFILL }},
      { &hf_isis_hello_bvid_u, { "U", "isis.hello.bvid.u", FT_UINT16, BASE_HEX_DEC, NULL, 0x0008, NULL, HFILL }},
      { &hf_isis_hello_bvid_m, { "M", "isis.hello.bvid.m", FT_UINT16, BASE_HEX_DEC, NULL, 0x0004, NULL, HFILL }},
      { &hf_isis_hello_area_address, { "Area address", "isis.hello.area_address", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_instance_identifier, { "Instance Identifier", "isis.hello.iid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_supported_itid, { "Supported ITID", "isis.hello.supported_itid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_clv_nlpid_nlpid, { "NLPID", "isis.hello.clv_nlpid.nlpid", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_clv_ip_authentication, { "NLPID", "isis.hello.clv_ip_authentication", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_authentication, { "Authentication", "isis.hello.clv_authentication", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_mtid, { "Topology ID", "isis.hello.mtid", FT_UINT16, BASE_DEC|BASE_RANGE_STRING, RVALS(mtid_strings), 0x0fff, NULL, HFILL }},
      { &hf_isis_hello_trill_neighbor_sf, { "Smallest flag", "isis.hello.trill_neighbor.sf", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x80, NULL, HFILL }},
      { &hf_isis_hello_trill_neighbor_lf, { "Largest flag", "isis.hello.trill_neighbor.lf", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x40, NULL, HFILL }},
      { &hf_isis_hello_trill_neighbor_size, { "SNPA Size", "isis.hello.trill_neighbor.size", FT_UINT8, BASE_DEC, NULL, 0x1f, NULL, HFILL }},
      { &hf_isis_hello_trill_neighbor_ff, { "Failed flag", "isis.hello.trill_neighbor.ff", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x80, NULL, HFILL }},
      { &hf_isis_hello_trill_neighbor_of, { "OOMF flag", "isis.hello.trill_neighbor.of", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x40, NULL, HFILL }},
      { &hf_isis_hello_trill_neighbor_reserved, { "Reserved", "isis.hello.trill_neighbor.reserved", FT_UINT8, BASE_DEC, NULL, 0x3f, NULL, HFILL }},
      { &hf_isis_hello_trill_neighbor_mtu, { "Tested MTU", "isis.hello.trill_neighbor.mtu", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_trill_neighbor_snpa, { "SNPA", "isis.hello.trill_neighbor.snpa", FT_SYSTEM_ID, BASE_NONE, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_checksum, { "Checksum", "isis.hello.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_checksum_status, { "Checksum Status", "isis.hello.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
      { &hf_isis_hello_adjacency_state, { "Adjacency State", "isis.hello.adjacency_state", FT_UINT8, BASE_DEC, VALS(adj_state_vals), 0x0, NULL, HFILL }},
      { &hf_isis_hello_extended_local_circuit_id, { "Extended Local circuit ID", "isis.hello.extended_local_circuit_id", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_neighbor_systemid, { "Neighbor SystemID", "isis.hello.neighbor_systemid", FT_SYSTEM_ID, BASE_NONE, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_neighbor_extended_local_circuit_id, { "Neighbor Extended Local circuit ID", "isis.hello.neighbor_extended_local_circuit_id", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_vlan_flags_port_id, { "Port ID", "isis.hello.vlan_flags.port_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_vlan_flags_nickname, { "Nickname", "isis.hello.vlan_flags.nickname", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_vlan_flags_af, { "Appointed Forwarder", "isis.hello.vlan_flags.af", FT_BOOLEAN, 16, TFS(&tfs_set_notset), 0x8000, NULL, HFILL }},
      { &hf_isis_hello_vlan_flags_ac, { "Access Port", "isis.hello.vlan_flags.ac", FT_BOOLEAN, 16, TFS(&tfs_set_notset), 0x4000, NULL, HFILL }},
      { &hf_isis_hello_vlan_flags_vm, { "VLAN Mapping Detected", "isis.hello.vlan_flags.vm", FT_BOOLEAN, 16, TFS(&tfs_set_notset), 0x2000, NULL, HFILL }},
      { &hf_isis_hello_vlan_flags_by, { "Bypass Pseudonode", "isis.hello.vlan_flags.by", FT_BOOLEAN, 16, TFS(&tfs_set_notset), 0x1000, NULL, HFILL }},
      { &hf_isis_hello_vlan_flags_outer_vlan, { "Outer VLAN", "isis.hello.vlan_flags.outer_vlan", FT_UINT16, BASE_DEC, NULL, 0x0fff, NULL, HFILL }},
      { &hf_isis_hello_vlan_flags_tr, { "Trunk Port", "isis.hello.vlan_flags.tr", FT_BOOLEAN, 16, TFS(&tfs_set_notset), 0x8000, NULL, HFILL }},
      { &hf_isis_hello_vlan_flags_reserved, { "Reserved", "isis.hello.vlan_flags.reserved", FT_BOOLEAN, 16, TFS(&tfs_set_notset), 0x7000, NULL, HFILL }},
      { &hf_isis_hello_vlan_flags_designated_vlan, { "Designated VLAN", "isis.hello.vlan_flags.designated_vlan", FT_UINT16, BASE_DEC, NULL, 0x0fff, NULL, HFILL }},
      { &hf_isis_hello_enabled_vlans, { "Enabled VLANs", "isis.hello.enabled_vlans", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_appointed_vlans, { "Appointed VLANs", "isis.hello.appointed_vlans", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_af_nickname, { "Nickname", "isis.hello.af.nickname", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_af_start_vlan, { "Start VLAN", "isis.hello.af.start_vlan", FT_UINT16, BASE_DEC, NULL, 0x0fff, NULL, HFILL }},
      { &hf_isis_hello_af_end_vlan, { "End VLAN", "isis.hello.af.end_vlan", FT_UINT16, BASE_DEC, NULL, 0x0fff, NULL, HFILL }},
      { &hf_isis_hello_trill_version, { "Maximum version", "isis.hello.trill.maximum_version", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_trill_hello_reduction, { "Hello Reduction", "isis.hello.trill.hello_reduction", FT_BOOLEAN, 32, TFS(&tfs_supported_not_supported), 0x80000000, NULL, HFILL }},
      { &hf_isis_hello_trill_unassigned_1, { "Unassigned", "isis.hello.trill.unassigned_1", FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x60000000, NULL, HFILL }},
      { &hf_isis_hello_trill_hop_by_hop_flags, { "Hop-by-hop Extended Header Flags", "isis.hello.trill.hop_by_hop_flags", FT_BOOLEAN, 32, TFS(&tfs_supported_not_supported), 0x1ffc0000, NULL, HFILL }},
      { &hf_isis_hello_trill_unassigned_2, { "Unassigned", "isis.hello.trill.unassigned_2",FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x0003ffff, NULL, HFILL }},
      { &hf_isis_hello_is_neighbor, { "IS Neighbor", "isis.hello.is_neighbor", FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_reverse_metric_flags, { "Flags", "isis.hello.reverse_metric.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_reverse_metric_flag_reserved, { "Reserved", "isis.hello.reverse_metric.flags.reserved", FT_UINT8, BASE_HEX, NULL, 0xFC, NULL, HFILL }},
      { &hf_isis_hello_reverse_metric_flag_u, { "U", "isis.hello.reverse_metric.flags.u", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x02, NULL, HFILL }},
      { &hf_isis_hello_reverse_metric_flag_w, { "W", "isis.hello.reverse_metric.flags.w", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x01, NULL, HFILL }},
      { &hf_isis_hello_reverse_metric_metric, { "Metric", "isis.hello.reverse_metric.metric", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_reverse_metric_sub_length, { "Sub-TLV length", "isis.hello.reverse_metric.sub_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_reverse_metric_sub_data, { "Sub-TLV data", "isis.hello.reverse_metric.sub_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
      { &hf_isis_hello_bfd_enabled_nlpid, { "NLPID", "isis.hello.bfd_enabled.nlpid", FT_UINT8, BASE_HEX, VALS(nlpid_vals), 0x0, NULL, HFILL }},

      /* rfc6119 */
      { &hf_isis_hello_clv_ipv6_glb_int_addr,
        { "IPv6 Global interface address", "isis.hello.clv_ipv6_glb_int_addr",
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
    };

    static int *ett[] = {
        &ett_isis_hello,
        &ett_isis_hello_clv_area_addr,
        &ett_isis_hello_clv_instance_identifier,
        &ett_isis_hello_clv_is_neighbors,
        &ett_isis_hello_clv_padding,
        &ett_isis_hello_clv_unknown,
        &ett_isis_hello_clv_nlpid,
        &ett_isis_hello_clv_nlpid_nlpid,
        &ett_isis_hello_clv_authentication,
        &ett_isis_hello_clv_ip_authentication,
        &ett_isis_hello_clv_ipv4_int_addr,
        &ett_isis_hello_clv_ipv6_int_addr,
        &ett_isis_hello_clv_ptp_adj,
        &ett_isis_hello_clv_mt,
        &ett_isis_hello_clv_restart,
        &ett_isis_hello_clv_restart_flags,
        &ett_isis_hello_clv_mt_port_cap,
        &ett_isis_hello_clv_mt_port_cap_spb_mcid,
        &ett_isis_hello_clv_mt_port_cap_spb_digest,
        &ett_isis_hello_clv_mt_port_cap_spb_bvid_tuples,
        &ett_isis_hello_clv_mt_port_cap_vlan_flags,
        &ett_isis_hello_clv_mt_port_cap_enabled_vlans,
        &ett_isis_hello_clv_mt_port_cap_appointedfwrdrs,
        &ett_isis_hello_clv_mt_port_cap_port_trill_ver,
        &ett_isis_hello_clv_mt_port_cap_vlans_appointed,
        &ett_isis_hello_clv_trill_neighbor,
        &ett_isis_hello_clv_checksum,
        &ett_isis_hello_clv_reverse_metric,
        &ett_isis_hello_clv_bfd_enabled,
        &ett_isis_hello_clv_ipv6_glb_int_addr, /* CLV 233, rfc6119 */
        &ett_isis_hello_reverse_metric_flags
    };

    static ei_register_info ei[] = {
        { &ei_isis_hello_short_pdu, { "isis.lsp.hello_pdu", PI_MALFORMED, PI_ERROR, "PDU length less than header length", EXPFILL }},
        { &ei_isis_hello_long_pdu, { "isis.lsp.hello_pdu", PI_MALFORMED, PI_ERROR, "PDU length greater than packet length", EXPFILL }},
        { &ei_isis_hello_bad_checksum, { "isis.hello.bad_checksum", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
        { &ei_isis_hello_subtlv, { "isis.hello.subtlv.unknown", PI_PROTOCOL, PI_WARN, "Unknown Sub-TLV", EXPFILL }},
        { &ei_isis_hello_authentication, { "isis.hello.authentication.unknown", PI_PROTOCOL, PI_WARN, "Unknown authentication type", EXPFILL }},
        { &ei_isis_hello_short_clv, { "isis.hello.short_clv", PI_MALFORMED, PI_ERROR, "Short CLV", EXPFILL }},
        { &ei_isis_hello_clv_mt, { "isis.hello.clv_mt.malformed", PI_MALFORMED, PI_ERROR, "malformed MT-ID", EXPFILL }},
        { &ei_isis_hello_clv_unknown, { "isis.hello.clv.unknown", PI_UNDECODED, PI_NOTE, "Unknown option", EXPFILL }},
    };

    expert_module_t* expert_isis_hello;

    /* Register the protocol name and description */
    proto_isis_hello = proto_register_protocol("ISIS HELLO", "ISIS HELLO", "isis.hello");

    proto_register_field_array(proto_isis_hello, hf, array_length(hf));
    proto_register_subtree_array(ett, array_length(ett));
    expert_isis_hello = expert_register_protocol(proto_isis_hello);
    expert_register_field_array(expert_isis_hello, ei, array_length(ei));
}

void
proto_reg_handoff_isis_hello(void)
{
    dissector_add_uint("isis.type", ISIS_TYPE_L1_HELLO, create_dissector_handle(dissect_isis_l1_hello, proto_isis_hello));
    dissector_add_uint("isis.type", ISIS_TYPE_L2_HELLO, create_dissector_handle(dissect_isis_l2_hello, proto_isis_hello));
    dissector_add_uint("isis.type", ISIS_TYPE_PTP_HELLO, create_dissector_handle(dissect_isis_ptp_hello, proto_isis_hello));
}

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