summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ntp.c
blob: 2b1be72f85066dc55c0e27045d5bb572a0c72920 (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
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
/* packet-ntp.c
 * Routines for NTP packet dissection
 * Copyright 1999, Nathan Neulinger <nneul@umr.edu>
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * Copied from packet-tftp.c
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "config.h"

#include <math.h>

#include <epan/packet.h>
#include <epan/expert.h>
#include <epan/addr_resolv.h>
#include <epan/tvbparse.h>
#include <epan/conversation.h>

#include <wsutil/epochs.h>

#include "packet-ntp.h"

void proto_register_ntp(void);
void proto_reg_handoff_ntp(void);

static dissector_handle_t ntp_handle;

/*
 * Dissecting NTP packets version 3 and 4 (RFC5905, RFC2030, RFC1769, RFC1361,
 * RFC1305).
 *
 * Those packets have simple structure:
 *                      1                   2                   3
 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |LI | VN  |Mode |    Stratum    |     Poll      |   Precision   |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                          Root Delay                           |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                       Root Dispersion                         |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                    Reference Identifier                       |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                   Reference Timestamp (64)                    |
 * |                                                               |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                   Originate Timestamp (64)                    |
 * |                                                               |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                    Receive Timestamp (64)                     |
 * |                                                               |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                    Transmit Timestamp (64)                    |
 * |                                                               |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                 Key Identifier (optional) (32)                |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                 Message Digest (optional) (128/160)           |
 * |                                                               |
 * |                                                               |
 * |                                                               |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * NTP timestamps are represented as a 64-bit unsigned fixed-point number,
 * in seconds relative to 0h on 1 January 1900. The integer part is in the
 * first 32 bits and the fraction part in the last 32 bits.
 *
 *
 * NTP Control messages as defined in version 2, 3 and 4 (RFC1119, RFC1305) use
 * the following structure:
 *                      1                   2                   3
 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |00 | VN  | 110 |R E M| OpCode  |           Sequence            |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |            Status             |        Association ID         |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |            Offset             |             Count             |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                                                               |
 * |                     Data (468 octets max)                     |
 * |                                                               |
 * |                               |        Padding (zeros)        |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                 Authenticator (optional) (96)                 |
 * |                                                               |
 * |                                                               |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *
 * Not yet implemented: complete dissection of TPCTRL_OP_SETTRAP,
 * NTPCTRL_OP_ASYNCMSG, NTPCTRL_OP_UNSETTRAPSETTRAP Control-Messages
 *
 */

#define UDP_PORT_NTP	123
#define TCP_PORT_NTP	123

/* Leap indicator, 2bit field is used to warn of a inserted/deleted
 * second, or clock unsynchronized indication.
 */
#define NTP_LI_MASK	0xC0

#define NTP_LI_NONE	0
#define NTP_LI_61	1
#define NTP_LI_59	2
#define NTP_LI_UNKNOWN	3

static const value_string li_types[] = {
	{ NTP_LI_NONE,	  "no warning" },
	{ NTP_LI_61,	  "last minute of the day has 61 seconds" },
	{ NTP_LI_59,	  "last minute of the day has 59 seconds" },
	{ NTP_LI_UNKNOWN, "unknown (clock unsynchronized)" },
	{ 0,		  NULL}
};

/* Version info, 3bit field informs about NTP version used in particular
 * packet. According to rfc2030, version info could be only 3 or 4, but I
 * have noticed packets with 1 or even 6 as version numbers. They are
 * produced as a result of ntptrace command. Are those packets malformed
 * on purpose? I don't know yet, probably some browsing through ntp sources
 * would help. My solution is to put them as reserved for now.
 */
#define NTP_VN_MASK	0x38

static const value_string ver_nums[] = {
	{ 0,	"reserved" },
	{ 1,	"NTP Version 1" },
	{ 2,	"NTP Version 2" },
	{ 3,	"NTP Version 3" },
	{ 4,	"NTP Version 4" },
	{ 5,	"reserved" },
	{ 6,	"reserved" },
	{ 7,	"reserved" },
	{ 0,	NULL}
};

/* Mode, 3bit field representing mode of communication.
 */
#define NTP_MODE_MASK   7

#define NTP_MODE_RSV	0
#define NTP_MODE_SYMACT	1
#define NTP_MODE_SYMPAS	2
#define NTP_MODE_CLIENT	3
#define NTP_MODE_SERVER	4
#define NTP_MODE_BCAST	5
#define NTP_MODE_CTRL	6
#define NTP_MODE_PRIV	7

static const value_string mode_types[] = {
	{ NTP_MODE_RSV,		"reserved" },
	{ NTP_MODE_SYMACT,	"symmetric active" },
	{ NTP_MODE_SYMPAS,	"symmetric passive" },
	{ NTP_MODE_CLIENT,	"client" },
	{ NTP_MODE_SERVER,	"server" },
	{ NTP_MODE_BCAST,	"broadcast" },
	{ NTP_MODE_CTRL,	"reserved for NTP control message"},
	{ NTP_MODE_PRIV,	"reserved for private use" },
	{ 0,		NULL}
};

static const value_string info_mode_types[] = {
	{ NTP_MODE_RSV,		"reserved" },
	{ NTP_MODE_SYMACT,	"symmetric active" },
	{ NTP_MODE_SYMPAS,	"symmetric passive" },
	{ NTP_MODE_CLIENT,	"client" },
	{ NTP_MODE_SERVER,	"server" },
	{ NTP_MODE_BCAST,	"broadcast" },
	{ NTP_MODE_CTRL,	"control"},
	{ NTP_MODE_PRIV,	"private" },
	{ 0,		NULL}
};

/* According to rfc, unspecified or invalid (stratum-0) servers should
 * set their Reference ID (4bytes field) according to following table:
 * https://www.iana.org/assignments/ntp-parameters/ntp-parameters.xhtml#ntp-parameters-2
 */
static const struct {
	const char *id;
	const char *data;
} kod_messages[] = {
	/* IANA / RFC 5905 */
	{ "ACST",	"The association belongs to a unicast server" },
	{ "AUTH",	"Server authentication failed" },
	{ "AUTO",	"Autokey sequence failed" },
	{ "BCST",	"The association belongs to a broadcast server" },
	{ "CRYP",	"Cryptographic authentication or identification failed" },
	{ "DENY",	"Access denied by remote server" },
	{ "DROP",	"Lost peer in symmetric mode" },
	{ "RSTR",	"Access denied due to local policy" },
	{ "INIT",	"The association has not yet synchronized for the first time" },
	{ "MCST",	"The association belongs to a dynamically discovered server" },
	{ "NKEY",	"No key found. Either the key was never installed or is not trusted" },
	{ "NTSN",	"Network Time Security (NTS) negative-acknowledgment (NAK)" },
	{ "RATE",	"Rate exceeded. The server has temporarily denied access because the client exceeded the rate threshold" },
	{ "RMOT",	"Alteration of association from a remote host running ntpdc." },
	{ "STEP",	"A step change in system time has occurred, but the association has not yet resynchronized" },
	{ "\0\0\0\0",	"NULL" },
	{ NULL,		NULL}
};

/* According to rfc 4330, primary (stratum-1) servers should set
 * their Reference ID (4bytes field) according to following table:
 */
static const struct {
	const char *id;
	const char *data;
} primary_sources[] = {
	/* IANA / RFC 5905 */
	{ "GOES",	"Geostationary Orbit Environment Satellite" },
	{ "GPS\0",	"Global Position System" },
	{ "GAL\0",	"Galileo Positioning System" },
	{ "PPS\0",	"Generic pulse-per-second" },
	{ "IRIG",	"Inter-Range Instrumentation Group" },
	{ "WWVB",	"LF Radio WWVB Ft. Collins, CO 60 kHz" },
	{ "DCF\0",	"LF Radio DCF77 Mainflingen, DE 77.5 kHz" },
	{ "HBG\0",	"LF Radio HBG Prangins, HB 75 kHz" },
	{ "MSF\0",	"LF Radio MSF Anthorn, UK 60 kHz" },
	{ "JJY\0",	"LF Radio JJY Fukushima, JP 40 kHz, Saga, JP 60 kHz" },
	{ "LORC",	"MF Radio LORAN C station, 100 kHz" },
	{ "TDF\0",	"MF Radio Allouis, FR 162 kHz" },
	{ "CHU\0",	"HF Radio CHU Ottawa, Ontario" },
	{ "WWV\0",	"HF Radio WWV Ft. Collins, CO" },
	{ "WWVH",	"HF Radio WWVH Kauai, HI" },
	{ "NIST",	"NIST telephone modem" },
	{ "ACTS",	"NIST telephone modem" },
	{ "USNO",	"USNO telephone modem" },
	{ "PTB\0",	"European telephone modem" },

	/* Unofficial codes */
	{ "LOCL",	"uncalibrated local clock" },
	{ "CESM",	"calibrated Cesium clock" },
	{ "RBDM",	"calibrated Rubidium clock" },
	{ "OMEG",	"OMEGA radionavigation system" },
	{ "DCN\0",	"DCN routing protocol" },
	{ "TSP\0",	"TSP time protocol" },
	{ "DTS\0",	"Digital Time Service" },
	{ "ATOM",	"Atomic clock (calibrated)" },
	{ "VLF\0",	"VLF radio (OMEGA,, etc.)" },
	{ "1PPS",	"External 1 PPS input" },
	{ "FREE",	"(Internal clock)" },
	// { "INIT",	"(Initialization)" },
	{ "\0\0\0\0",	"NULL" },
	{ NULL,		NULL}
};


#define NTPCTRL_R_MASK 0x80

#define ctrl_r_types ext_r_types

#define NTPCTRL_ERROR_MASK 0x40
#define NTPCTRL_MORE_MASK 0x20
#define NTPCTRL_OP_MASK 0x1f

#define NTPCTRL_OP_UNSPEC 0		/* unspeciffied */
#define NTPCTRL_OP_READSTAT 1		/* read status */
#define NTPCTRL_OP_READVAR 2		/* read variables */
#define NTPCTRL_OP_WRITEVAR 3		/* write variables */
#define NTPCTRL_OP_READCLOCK 4		/* read clock variables */
#define NTPCTRL_OP_WRITECLOCK 5		/* write clock variables */
#define NTPCTRL_OP_SETTRAP 6		/* set trap address */
#define NTPCTRL_OP_ASYNCMSG 7		/* asynchronous message */
#define NTPCTRL_OP_CONFIGURE 8		/* runtime configuration */
#define NTPCTRL_OP_SAVECONFIG 9		/* save config to file */
#define NTPCTRL_OP_READ_MRU 10		/* retrieve MRU (mrulist) */
#define NTPCTRL_OP_READ_ORDLIST_A 11	/* ordered list req. auth. */
#define NTPCTRL_OP_REQ_NONCE 12		/* request a client nonce */
#define NTPCTRL_OP_UNSETTRAP 31		/* unset trap */

static const value_string ctrl_op_types[] = {
	{ NTPCTRL_OP_UNSPEC,		"reserved" },
	{ NTPCTRL_OP_READSTAT,		"read status" },
	{ NTPCTRL_OP_READVAR,		"read variables" },
	{ NTPCTRL_OP_WRITEVAR,		"write variables" },
	{ NTPCTRL_OP_READCLOCK,		"read clock variables" },
	{ NTPCTRL_OP_WRITECLOCK,	"write clock variables" },
	{ NTPCTRL_OP_SETTRAP,		"set trap address/port" },
	{ NTPCTRL_OP_ASYNCMSG,		"asynchronous message" },
	{ NTPCTRL_OP_CONFIGURE,		"runtime configuration" },
	{ NTPCTRL_OP_SAVECONFIG,	"save config to file" },
	{ NTPCTRL_OP_READ_MRU,		"retrieve MRU (mrulist)" },
	{ NTPCTRL_OP_READ_ORDLIST_A,	"retrieve ordered list" },
	{ NTPCTRL_OP_REQ_NONCE,		"request a client nonce" },
	{ NTPCTRL_OP_UNSETTRAP,		"unset trap address/port" },
	{ 0,		NULL}
};

#define NTPCTRL_SYSSTATUS_LI_MASK		0xC000
#define NTPCTRL_SYSSTATUS_CLK_MASK		0x3F00
#define NTPCTRL_SYSSTATUS_COUNT_MASK	0x00F0
#define NTPCTRL_SYSSTATUS_CODE_MASK		0x000F

static const value_string ctrl_sys_status_clksource_types[] = {
	{ 0,		"unspecified or unknown" },
	{ 1,		"Calibrated atomic clock (e.g. HP 5061)" },
	{ 2,		"VLF (band 4) or LF (band 5) radio (e.g. OMEGA, WWVB)" },
	{ 3,		"HF (band 7) radio (e.g. CHU, MSF, WWV/H)" },
	{ 4,		"UHF (band 9) satellite (e.g. GOES, GPS)" },
	{ 5,		"local net (e.g. DCN, TSP, DTS)" },
	{ 6,		"UDP/NTP" },
	{ 7,		"UDP/TIME" },
	{ 8,		"eyeball-and-wristwatch" },
	{ 9,		"telephone modem (e.g. NIST)" },
	{ 0,		NULL}
};

static const value_string ctrl_sys_status_event_types[] = {
	{ 0,		"unspecified" },
	{ 1,		"frequency correction (drift) file not available" },
	{ 2,		"frequency correction started (frequency stepped)" },
	{ 3,		"spike detected and ignored, starting stepout timer" },
	{ 4,		"frequency training started" },
	{ 5,		"clock synchronized" },
	{ 6,		"system restart" },
	{ 7,		"panic stop (required step greater than panic threshold)" },
	{ 8,		"no system peer" },
	{ 9,		"leap second insertion/deletion armed" },
	{ 10,		"leap second disarmed" },
	{ 11,		"leap second inserted or deleted" },
	{ 12,		"clock stepped (stepout timer expired)" },
	{ 13,		"kernel loop discipline status changed" },
	{ 14,		"leapseconds table loaded from file" },
	{ 15,		"leapseconds table outdated, updated file needed" },
	{ 0,		NULL}
};

#define NTPCTRL_PEERSTATUS_STATUS_MASK		0xF800
#define NTPCTRL_PEERSTATUS_CONFIG_MASK		0x8000
#define NTPCTRL_PEERSTATUS_AUTHENABLE_MASK	0x4000
#define NTPCTRL_PEERSTATUS_AUTHENTIC_MASK	0x2000
#define NTPCTRL_PEERSTATUS_REACH_MASK		0x1000
#define NTPCTRL_PEERSTATUS_BCAST_MASK		0x0800
#define NTPCTRL_PEERSTATUS_SEL_MASK		0x0700
#define NTPCTRL_PEERSTATUS_COUNT_MASK		0x00F0
#define NTPCTRL_PEERSTATUS_CODE_MASK		0x000F

static const true_false_string tfs_ctrl_peer_status_config = {"configured (peer.config)", "not configured (peer.config)" };
static const true_false_string tfs_ctrl_peer_status_authenable = { "authentication enabled (peer.authenable)", "authentication disabled (peer.authenable)" };
static const true_false_string tfs_ctrl_peer_status_authentic = { "authentication okay (peer.authentic)", "authentication not okay (peer.authentic)" };
static const true_false_string tfs_ctrl_peer_status_reach = {"reachability okay (peer.reach != 0)", "reachability not okay (peer.reach != 0)" };

static const value_string ctrl_peer_status_selection_types[] = {
	{ 0,		"rejected" },
	{ 1,		"passed sanity checks (tests 1 through 8 in Section 3.4.3)" },
	{ 2,		"passed correctness checks (intersection algorithm in Section 4.2.1)" },
	{ 3,		"passed candidate checks (if limit check implemented)" },
	{ 4,		"passed outlier checks (clustering algorithm in Section 4.2.2)" },
	{ 5,		"current synchronization source; max distance exceeded (if limit check implemented)" },
	{ 6,		"current synchronization source; max distance okay" },
	{ 7,		"reserved" },
	{ 0,		NULL}
};

static const value_string ctrl_peer_status_event_types[] = {
	{ 0,		"unspecified" },
	{ 1,		"association mobilized" },
	{ 2,		"association demobilized" },
	{ 3,		"peer unreachable (peer.reach was nonzero now zero)" },
	{ 4,		"peer reachable (peer.reach was zero now nonzero)" },
	{ 5,		"association restarted or timed out" },
	{ 6,		"no server found (ntpdate mode)" },
	{ 7,		"rate exceeded (kiss code RATE)" },
	{ 8,		"access denied (kiss code DENY)" },
	{ 9,		"leap armed from server LI code" },
	{ 10,		"become system peer" },
	{ 11,		"reference clock event (see clock status word)" },
	{ 12,		"authentication failure" },
	{ 13,		"popcorn spike suppressor" },
	{ 14,		"entering interleave mode" },
	{ 15,		"interleave error (recovered)" },
	{ 0,		NULL}
};

#define NTPCTRL_CLKSTATUS_STATUS_MASK	0xFF00
#define NTPCTRL_CLKSTATUS_CODE_MASK		0x00FF

static const value_string ctrl_clk_status_types[] = {
	{ 0,		"clock operating within nominals" },
	{ 1,		"reply timeout" },
	{ 2,		"bad reply format" },
	{ 3,		"hardware or software fault" },
	{ 4,		"propagation failure" },
	{ 5,		"bad date format or value" },
	{ 6,		"bad time format or value" },
	{ 0,		NULL}
};

#define NTP_CTRL_ERRSTATUS_CODE_MASK	0xFF00

static const value_string ctrl_err_status_types[] = {
	{ 0,		"unspecified" },
	{ 1,		"authentication failure" },
	{ 2,		"invalid message length or format" },
	{ 3,		"invalid opcode" },
	{ 4,		"unknown association identifier" },
	{ 5,		"unknown variable name" },
	{ 6,		"invalid variable value" },
	{ 7,		"administratively prohibited" },
	{ 0,		NULL}
};

static const value_string err_values_types[] = {
	{ 0,		"No error" },
	{ 1,		"incompatible implementation number"},
	{ 2,		"unimplemented request code" },
	{ 3,		"format error" },
	{ 4,		"no data available" },
	{ 5,		"unknown" },
	{ 6,		"unknown" },
	{ 7,		"authentication failure"},
	{ 0,		NULL}
};

#define NTPPRIV_R_MASK 0x80

#define NTPPRIV_MORE_MASK 0x40

#define NTPPRIV_AUTH_MASK 0x80
#define NTPPRIV_SEQ_MASK 0x7f

#define XNTPD_OLD 0x02
#define XNTPD 0x03

static const value_string priv_impl_types[] = {
	{ 0,		"UNIV" },
	{ XNTPD_OLD,	"XNTPD_OLD (pre-IPv6)" },
	{ XNTPD,	"XNTPD" },
	{ 0,		NULL}
};

static const value_string priv_mode7_int_action[] = {
	{ 1,	"Interface exists" },
	{ 2,	"Interface created" },
	{ 3,	"Interface deleted" },
	{ 0,	NULL}
};

#define PRIV_RC_PEER_LIST       0
#define PRIV_RC_PEER_LIST_SUM   1
#define PRIV_RC_PEER_INFO       2
#define PRIV_RC_PEER_STATS      3
#define PRIV_RC_SYS_INFO        4
#define PRIV_RC_SYS_STATS       5
#define PRIV_RC_IO_STATS        6
#define PRIV_RC_MEM_STATS       7
#define PRIV_RC_LOOP_INFO       8
#define PRIV_RC_TIMER_STATS     9
#define PRIV_RC_CONFIG         10
#define PRIV_RC_UNCONFIG       11
#define PRIV_RC_SET_SYS_FLAG   12
#define PRIV_RC_CLR_SYS_FLAG   13
#define PRIV_RC_GET_RESTRICT   16
#define PRIV_RC_RESADDFLAGS    17
#define PRIV_RC_RESSUBFLAGS    18
#define PRIV_RC_UNRESTRICT     19
#define PRIV_RC_MON_GETLIST    20
#define PRIV_RC_RESET_STATS    21
#define PRIV_RC_RESET_PEER     22
#define PRIV_RC_TRUSTKEY       26
#define PRIV_RC_UNTRUSTKEY     27
#define PRIV_RC_AUTHINFO       28
#define PRIV_RC_TRAPS          29
#define PRIV_RC_ADD_TRAP       30
#define PRIV_RC_CLR_TRAP       31
#define PRIV_RC_REQUEST_KEY    32
#define PRIV_RC_CONTROL_KEY    33
#define PRIV_RC_CTL_STATS      34
#define PRIV_RC_GET_CLOCKINFO  36
#define PRIV_RC_SET_CLKFUDGE   37
#define PRIV_RC_GET_KERNEL     38
#define PRIV_RC_GET_CLKBUGINFO 39
#define PRIV_RC_MON_GETLIST_1  42
#define PRIV_RC_IF_STATS       44
#define PRIV_RC_IF_RELOAD      45

static const value_string priv_rc_types[] = {
	{ PRIV_RC_PEER_LIST,		"PEER_LIST" },
	{ PRIV_RC_PEER_LIST_SUM,	"PEER_LIST_SUM" },
	{ PRIV_RC_PEER_INFO,		"PEER_INFO" },
	{ PRIV_RC_PEER_STATS,		"PEER_STATS" },
	{ PRIV_RC_SYS_INFO,		"SYS_INFO" },
	{ PRIV_RC_SYS_STATS,		"SYS_STATS" },
	{ PRIV_RC_IO_STATS,		"IO_STATS" },
	{ PRIV_RC_MEM_STATS,		"MEM_STATS" },
	{ PRIV_RC_LOOP_INFO,		"LOOP_INFO" },
	{ PRIV_RC_TIMER_STATS,		"TIMER_STATS" },
	{ PRIV_RC_CONFIG,		"CONFIG" },
	{ PRIV_RC_UNCONFIG,		"UNCONFIG" },
	{ PRIV_RC_SET_SYS_FLAG,		"SET_SYS_FLAG" },
	{ PRIV_RC_CLR_SYS_FLAG,		"CLR_SYS_FLAG" },
	{ 14,				"MONITOR" },
	{ 15,				"NOMONITOR" },
	{ PRIV_RC_GET_RESTRICT,		"GET_RESTRICT" },
	{ PRIV_RC_RESADDFLAGS,		"RESADDFLAGS" },
	{ PRIV_RC_RESSUBFLAGS,		"RESSUBFLAGS" },
	{ PRIV_RC_UNRESTRICT,		"UNRESTRICT" },
	{ PRIV_RC_MON_GETLIST,		"MON_GETLIST" },
	{ PRIV_RC_RESET_STATS,		"RESET_STATS" },
	{ PRIV_RC_RESET_PEER,		"RESET_PEER" },
	{ 23,				"REREAD_KEYS" },
	{ 24,				"DO_DIRTY_HACK" },
	{ 25,				"DONT_DIRTY_HACK" },
	{ PRIV_RC_TRUSTKEY,		"TRUSTKEY" },
	{ PRIV_RC_UNTRUSTKEY,		"UNTRUSTKEY" },
	{ PRIV_RC_AUTHINFO,		"AUTHINFO" },
	{ PRIV_RC_TRAPS,		"TRAPS" },
	{ PRIV_RC_ADD_TRAP,		"ADD_TRAP" },
	{ PRIV_RC_CLR_TRAP,		"CLR_TRAP" },
	{ PRIV_RC_REQUEST_KEY,		"REQUEST_KEY" },
	{ PRIV_RC_CONTROL_KEY,		"CONTROL_KEY" },
	{ PRIV_RC_CTL_STATS,		"GET_CTLSTATS" },
	{ 35,				"GET_LEAPINFO" },
	{ PRIV_RC_GET_CLOCKINFO,	"GET_CLOCKINFO" },
	{ PRIV_RC_SET_CLKFUDGE,		"SET_CLKFUDGE" },
	{ PRIV_RC_GET_KERNEL,		"GET_KERNEL" },
	{ PRIV_RC_GET_CLKBUGINFO,	"GET_CLKBUGINFO" },
	{ 41,				"SET_PRECISION" },
	{ PRIV_RC_MON_GETLIST_1,	"MON_GETLIST_1" },
	{ 43,				"HOSTNAME_ASSOCID" },
	{ PRIV_RC_IF_STATS,		"IF_STATS" },
	{ PRIV_RC_IF_RELOAD,		"IF_RELOAD" },
	{ 0,				NULL}
};
static value_string_ext priv_rc_types_ext = VALUE_STRING_EXT_INIT(priv_rc_types);

#define PRIV_INFO_FLAG_CONFIG        0x1
#define PRIV_INFO_FLAG_SYSPEER       0x2
#define PRIV_INFO_FLAG_BURST         0x4
#define PRIV_INFO_FLAG_REFCLOCK      0x8
#define PRIV_INFO_FLAG_PREFER        0x10
#define PRIV_INFO_FLAG_AUTHENABLE    0x20
#define PRIV_INFO_FLAG_SEL_CANDIDATE 0x40
#define PRIV_INFO_FLAG_SHORTLIST     0x80
/* XXX PRIV_INFO_FLAG_IBURST is unused, is a field needed? */
#define PRIV_INFO_FLAG_IBURST        0x100

#define PRIV_CONF_FLAG_AUTHENABLE    0x01
#define PRIV_CONF_FLAG_PREFER        0x02
#define PRIV_CONF_FLAG_BURST         0x04
#define PRIV_CONF_FLAG_IBURST        0x08
#define PRIV_CONF_FLAG_NOSELECT      0x10
#define PRIV_CONF_FLAG_SKEY          0x20

#define PRIV_SYS_FLAG_BCLIENT    0x01
#define PRIV_SYS_FLAG_PPS        0x02
#define PRIV_SYS_FLAG_NTP        0x04
#define PRIV_SYS_FLAG_KERNEL     0x08
#define PRIV_SYS_FLAG_MONITOR    0x10
#define PRIV_SYS_FLAG_FILEGEN    0x20
#define PRIV_SYS_FLAG_AUTH       0x40
#define PRIV_SYS_FLAG_CAL        0x80

#define PRIV_RESET_FLAG_ALLPEERS 0x00000001
#define PRIV_RESET_FLAG_IO       0x00000002
#define PRIV_RESET_FLAG_SYS      0x00000004
#define PRIV_RESET_FLAG_MEM      0x00000008
#define PRIV_RESET_FLAG_TIMER    0x00000010
#define PRIV_RESET_FLAG_AUTH     0x00000020
#define PRIV_RESET_FLAG_CTL      0x00000040

static const range_string stratum_rvals[] = {
	{ 0,	0, "unspecified or invalid" },
	{ 1,	1, "primary reference" },
	{ 2,	15, "secondary reference" },
	{ 16,	16, "unsynchronized" },
	{ 17,	255, "reserved" },
	{ 0,	0, NULL }
};

#define NTP_MD5_ALGO 0
#define NTP_SHA_ALGO 1

static const value_string authentication_types[] = {
	{ NTP_MD5_ALGO,		"MD5" },
	{ NTP_SHA_ALGO,		"SHA" },
	{ 0,		NULL}
};

/*
 * NTP Extension Field Types.
 * https://www.iana.org/assignments/ntp-parameters/ntp-parameters.xhtml#ntp-parameters-3
 */
static const value_string ntp_ext_field_types[] = {
	{ 0x0002, "No-Operation Request" },
	{ 0x0102, "Association Message Request" },
	{ 0x0104, "Unique Identifier" },
	{ 0x0202, "Certificate Message Request" },
	{ 0x0204, "NTS Cookie" },
	{ 0x0302, "Cookie Message Request" },
	{ 0x0304, "NTS Cookie Placeholder" },
	{ 0x0402, "Autokey Message Request" },
	{ 0x0404, "NTS Authenticator and Encrypted Extension Fields" },
	{ 0x0502, "Leapseconds Message Request" },
	{ 0x0602, "Sign Message Request" },
	{ 0x0702, "IFF Identity Message Request" },
	{ 0x0802, "GQ Identity Message Request" },
	{ 0x0902, "MV Identity Message Request" },
	{ 0x2005, "Checksum Complement" },
	{ 0x8002, "No-Operation Response" },
	{ 0x8102, "Association Message Response" },
	{ 0x8202, "Certificate Message Response" },
	{ 0x8302, "Cookie Message Response" },
	{ 0x8402, "Autokey Message Response" },
	{ 0x8502, "Leapseconds Message Response" },
	{ 0x8602, "Sign Message Response" },
	{ 0x8702, "IFF Identity Message Response" },
	{ 0x8802, "GQ Identity Message Response" },
	{ 0x8902, "MV Identity Message Response" },
	{ 0xC002, "No-Operation Error Response" },
	{ 0xC102, "Association Message Error Response" },
	{ 0xC202, "Certificate Message Error Response" },
	{ 0xC302, "Cookie Message Error Response" },
	{ 0xC402, "Autokey Message Error Response" },
	{ 0xC502, "Leapseconds Message Error Response" },
	{ 0xC602, "Sign Message Error Response" },
	{ 0xC702, "IFF Identity Message Error Response" },
	{ 0xC802, "GQ Identity Message Error Response" },
	{ 0xC902, "MV Identity Message Error Response" },
	{ 0, NULL }
};


typedef struct {
	guint32 req_frame;
	guint32 resp_frame;
	nstime_t req_time;
	guint32 seq;
} ntp_trans_info_t;

typedef struct {
	wmem_tree_t *trans;
} ntp_conv_info_t;


static int proto_ntp = -1;

static int hf_ntp_flags = -1;
static int hf_ntp_flags_li = -1;
static int hf_ntp_flags_vn = -1;
static int hf_ntp_flags_mode = -1;
static int hf_ntp_stratum = -1;
static int hf_ntp_ppoll = -1;
static int hf_ntp_precision = -1;
static int hf_ntp_rootdelay = -1;
static int hf_ntp_rootdispersion = -1;
static int hf_ntp_refid = -1;
static int hf_ntp_reftime = -1;
static int hf_ntp_org = -1;
static int hf_ntp_rec = -1;
static int hf_ntp_xmt = -1;
static int hf_ntp_keyid = -1;
static int hf_ntp_mac = -1;
static int hf_ntp_padding = -1;
static int hf_ntp_key_type = -1;
static int hf_ntp_key_index = -1;
static int hf_ntp_key_signature = -1;
static int hf_ntp_response_in = -1;
static int hf_ntp_request_in = -1;
static int hf_ntp_delta_time = -1;

static int hf_ntp_ext = -1;
static int hf_ntp_ext_type = -1;
static int hf_ntp_ext_length = -1;
static int hf_ntp_ext_value = -1;

static int hf_ntpctrl_flags2 = -1;
static int hf_ntpctrl_flags2_r = -1;
static int hf_ntpctrl_flags2_error = -1;
static int hf_ntpctrl_flags2_more = -1;
static int hf_ntpctrl_flags2_opcode = -1;
static int hf_ntpctrl_sequence = -1;
static int hf_ntpctrl_status = -1;
static int hf_ntpctrl_error_status_word = -1;
static int hf_ntpctrl_sys_status_li = -1;
static int hf_ntpctrl_sys_status_clksrc = -1;
static int hf_ntpctrl_sys_status_count = -1;
static int hf_ntpctrl_sys_status_code = -1;
static int hf_ntpctrl_peer_status_b0 = -1;
static int hf_ntpctrl_peer_status_b1 = -1;
static int hf_ntpctrl_peer_status_b2 = -1;
static int hf_ntpctrl_peer_status_b3 = -1;
static int hf_ntpctrl_peer_status_b4 = -1;
static int hf_ntpctrl_peer_status_selection = -1;
static int hf_ntpctrl_peer_status_count = -1;
static int hf_ntpctrl_peer_status_code = -1;
static int hf_ntpctrl_clk_status = -1;
static int hf_ntpctrl_clk_status_code = -1;
static int hf_ntpctrl_associd = -1;
static int hf_ntpctrl_offset = -1;
static int hf_ntpctrl_count = -1;
static int hf_ntpctrl_data = -1;
static int hf_ntpctrl_item = -1;
static int hf_ntpctrl_trapmsg = -1;
static int hf_ntpctrl_ordlist = -1;
static int hf_ntpctrl_configuration = -1;
static int hf_ntpctrl_mru = -1;
static int hf_ntpctrl_nonce = -1;

static int hf_ntppriv_flags_r = -1;
static int hf_ntppriv_flags_more = -1;
static int hf_ntppriv_auth_seq = -1;
static int hf_ntppriv_auth = -1;
static int hf_ntppriv_seq = -1;
static int hf_ntppriv_impl = -1;
static int hf_ntppriv_reqcode = -1;
static int hf_ntppriv_errcode = -1;
static int hf_ntppriv_numitems = -1;
static int hf_ntppriv_mbz = -1;
static int hf_ntppriv_mode7_item = -1;
static int hf_ntppriv_itemsize = -1;
static int hf_ntppriv_avgint = -1;
static int hf_ntppriv_lsint = -1;
static int hf_ntppriv_count = -1;
static int hf_ntppriv_restr = -1;
static int hf_ntppriv_addr = -1;
static int hf_ntppriv_daddr = -1;
static int hf_ntppriv_flags = -1;
static int hf_ntppriv_port = -1;
static int hf_ntppriv_mode = -1;
static int hf_ntppriv_version = -1;
static int hf_ntppriv_v6_flag = -1;
static int hf_ntppriv_unused = -1;
static int hf_ntppriv_addr6 = -1;
static int hf_ntppriv_daddr6 = -1;
static int hf_ntppriv_tstamp = -1;
static int hf_ntppriv_mode7_addr = -1;
static int hf_ntppriv_mode7_mask = -1;
static int hf_ntppriv_mode7_bcast = -1;
static int hf_ntppriv_mode7_port = -1;
static int hf_ntppriv_mode7_hmode = -1;
static int hf_ntppriv_mode7_peer_flags = -1;
static int hf_ntppriv_mode7_v6_flag = -1;
static int hf_ntppriv_mode7_unused = -1;
static int hf_ntppriv_mode7_addr6 = -1;
static int hf_ntppriv_mode7_mask6 = -1;
static int hf_ntppriv_mode7_bcast6 = -1;
static int hf_ntppriv_mode7_peer_flags_config = -1;
static int hf_ntppriv_mode7_peer_flags_syspeer = -1;
static int hf_ntppriv_mode7_peer_flags_burst = -1;
static int hf_ntppriv_mode7_peer_flags_refclock = -1;
static int hf_ntppriv_mode7_peer_flags_prefer = -1;
static int hf_ntppriv_mode7_peer_flags_authenable = -1;
static int hf_ntppriv_mode7_peer_flags_sel_candidate = -1;
static int hf_ntppriv_mode7_peer_flags_shortlist = -1;
static int hf_ntppriv_mode7_dstaddr = -1;
static int hf_ntppriv_mode7_srcaddr = -1;
static int hf_ntppriv_mode7_srcport = -1;
static int hf_ntppriv_mode7_count = -1;
static int hf_ntppriv_mode7_hpoll = -1;
static int hf_ntppriv_mode7_reach = -1;
static int hf_ntppriv_mode7_delay = -1;
static int hf_ntppriv_mode7_offset = -1;
static int hf_ntppriv_mode7_dispersion = -1;
static int hf_ntppriv_mode7_dstaddr6 = -1;
static int hf_ntppriv_mode7_srcaddr6 = -1;
static int hf_ntppriv_mode7_leap = -1;
static int hf_ntppriv_mode7_pmode = -1;
static int hf_ntppriv_mode7_version = -1;
static int hf_ntppriv_mode7_unreach = -1;
static int hf_ntppriv_mode7_flash = -1;
static int hf_ntppriv_mode7_ttl = -1;
static int hf_ntppriv_mode7_flash2 = -1;
static int hf_ntppriv_mode7_associd = -1;
static int hf_ntppriv_mode7_pkeyid = -1;
static int hf_ntppriv_mode7_timer = -1;
static int hf_ntppriv_mode7_filtdelay = -1;
static int hf_ntppriv_mode7_filtoffset = -1;
static int hf_ntppriv_mode7_order = -1;
static int hf_ntppriv_mode7_selectdis = -1;
static int hf_ntppriv_mode7_estbdelay = -1;
static int hf_ntppriv_mode7_bdelay = -1;
static int hf_ntppriv_mode7_authdelay = -1;
static int hf_ntppriv_mode7_stability = -1;
static int hf_ntppriv_mode7_timeup = -1;
static int hf_ntppriv_mode7_timereset = -1;
static int hf_ntppriv_mode7_timereceived = -1;
static int hf_ntppriv_mode7_timetosend = -1;
static int hf_ntppriv_mode7_timereachable = -1;
static int hf_ntppriv_mode7_sent = -1;
static int hf_ntppriv_mode7_processed = -1;
static int hf_ntppriv_mode7_badauth = -1;
static int hf_ntppriv_mode7_bogusorg = -1;
static int hf_ntppriv_mode7_oldpkt = -1;
static int hf_ntppriv_mode7_seldisp = -1;
static int hf_ntppriv_mode7_selbroken = -1;
static int hf_ntppriv_mode7_candidate = -1;
static int hf_ntppriv_mode7_minpoll = -1;
static int hf_ntppriv_mode7_maxpoll = -1;
static int hf_ntppriv_mode7_config_flags = -1;
static int hf_ntppriv_mode7_config_flags_auth = -1;
static int hf_ntppriv_mode7_config_flags_prefer = -1;
static int hf_ntppriv_mode7_config_flags_burst = -1;
static int hf_ntppriv_mode7_config_flags_iburst = -1;
static int hf_ntppriv_mode7_config_flags_noselect = -1;
static int hf_ntppriv_mode7_config_flags_skey = -1;
static int hf_ntppriv_mode7_key_file = -1;
static int hf_ntppriv_mode7_sys_flags = -1;
static int hf_ntppriv_mode7_sys_flags8 = -1;
static int hf_ntppriv_mode7_sys_flags_bclient = -1;
static int hf_ntppriv_mode7_sys_flags_pps = -1;
static int hf_ntppriv_mode7_sys_flags_ntp = -1;
static int hf_ntppriv_mode7_sys_flags_kernel = -1;
static int hf_ntppriv_mode7_sys_flags_monitor = -1;
static int hf_ntppriv_mode7_sys_flags_filegen = -1;
static int hf_ntppriv_mode7_sys_flags_auth = -1;
static int hf_ntppriv_mode7_sys_flags_cal = -1;
static int hf_ntppriv_mode7_reset_stats_flags = -1;
static int hf_ntppriv_mode7_reset_stats_flags_allpeers = -1;
static int hf_ntppriv_mode7_reset_stats_flags_io = -1;
static int hf_ntppriv_mode7_reset_stats_flags_sys = -1;
static int hf_ntppriv_mode7_reset_stats_flags_mem = -1;
static int hf_ntppriv_mode7_reset_stats_flags_timer = -1;
static int hf_ntppriv_mode7_reset_stats_flags_auth = -1;
static int hf_ntppriv_mode7_reset_stats_flags_ctl = -1;
static int hf_ntppriv_mode7_req = -1;
static int hf_ntppriv_mode7_badpkts = -1;
static int hf_ntppriv_mode7_responses = -1;
static int hf_ntppriv_mode7_frags = -1;
static int hf_ntppriv_mode7_errors = -1;
static int hf_ntppriv_mode7_tooshort = -1;
static int hf_ntppriv_mode7_inputresp = -1;
static int hf_ntppriv_mode7_inputfrag = -1;
static int hf_ntppriv_mode7_inputerr = -1;
static int hf_ntppriv_mode7_badoffset = -1;
static int hf_ntppriv_mode7_badversion = -1;
static int hf_ntppriv_mode7_datatooshort = -1;
static int hf_ntppriv_mode7_badop = -1;
static int hf_ntppriv_mode7_asyncmsgs = -1;
static int hf_ntppriv_mode7_type = -1;
static int hf_ntppriv_mode7_clock_flags = -1;
static int hf_ntppriv_mode7_lastevent = -1;
static int hf_ntppriv_mode7_currentstatus = -1;
static int hf_ntppriv_mode7_polls = -1;
static int hf_ntppriv_mode7_noresponse = -1;
static int hf_ntppriv_mode7_badformat = -1;
static int hf_ntppriv_mode7_baddata = -1;
static int hf_ntppriv_mode7_timestarted = -1;
static int hf_ntppriv_mode7_fudgetime1 = -1;
static int hf_ntppriv_mode7_fudgetime2 = -1;
static int hf_ntppriv_mode7_fudgeval1 = -1;
static int hf_ntppriv_mode7_fudgeval2 = -1;
static int hf_ntppriv_mode7_kernel_offset = -1;
static int hf_ntppriv_mode7_freq = -1;
static int hf_ntppriv_mode7_maxerror = -1;
static int hf_ntppriv_mode7_esterror = -1;
static int hf_ntppriv_mode7_status = -1;
static int hf_ntppriv_mode7_shift = -1;
static int hf_ntppriv_mode7_constant = -1;
static int hf_ntppriv_mode7_precision = -1;
static int hf_ntppriv_mode7_tolerance = -1;
static int hf_ntppriv_mode7_ppsfreq = -1;
static int hf_ntppriv_mode7_jitter = -1;
static int hf_ntppriv_mode7_stabil = -1;
static int hf_ntppriv_mode7_jitcnt = -1;
static int hf_ntppriv_mode7_calcnt = -1;
static int hf_ntppriv_mode7_errcnt = -1;
static int hf_ntppriv_mode7_stbcnt = -1;
static int hf_ntppriv_mode7_key = -1;
static int hf_ntppriv_mode7_numkeys = -1;
static int hf_ntppriv_mode7_numfreekeys = -1;
static int hf_ntppriv_mode7_keylookups = -1;
static int hf_ntppriv_mode7_keynotfound = -1;
static int hf_ntppriv_mode7_encryptions = -1;
static int hf_ntppriv_mode7_decryptions = -1;
static int hf_ntppriv_mode7_expired = -1;
static int hf_ntppriv_mode7_keyuncached = -1;
static int hf_ntppriv_mode7_local_addr = -1;
static int hf_ntppriv_mode7_trap_addr = -1;
static int hf_ntppriv_mode7_trap_port = -1;
static int hf_ntppriv_mode7_sequence = -1;
static int hf_ntppriv_mode7_settime = -1;
static int hf_ntppriv_mode7_origtime = -1;
static int hf_ntppriv_mode7_resets = -1;
static int hf_ntppriv_traps_flags = -1;
static int hf_ntppriv_mode7_local_addr6 = -1;
static int hf_ntppriv_mode7_trap_addr6 = -1;
static int hf_ntppriv_mode7_last_offset = -1;
static int hf_ntppriv_mode7_drift_comp = -1;
static int hf_ntppriv_mode7_compliance = -1;
static int hf_ntppriv_mode7_watchdog_timer = -1;
static int hf_ntppriv_mode7_poll32 = -1;
static int hf_ntppriv_mode7_denied = -1;
static int hf_ntppriv_mode7_oldversion = -1;
static int hf_ntppriv_mode7_newversion = -1;
static int hf_ntppriv_mode7_badlength = -1;
static int hf_ntppriv_mode7_limitrejected = -1;
static int hf_ntppriv_mode7_lamport = -1;
static int hf_ntppriv_mode7_tsrounding = -1;
static int hf_ntppriv_mode7_totalmem = -1;
static int hf_ntppriv_mode7_freemem = -1;
static int hf_ntppriv_mode7_findpeer_calls = -1;
static int hf_ntppriv_mode7_allocations = -1;
static int hf_ntppriv_mode7_demobilizations = -1;
static int hf_ntppriv_mode7_hashcount = -1;
static int hf_ntppriv_mode7_totalrecvbufs = -1;
static int hf_ntppriv_mode7_freerecvbufs = -1;
static int hf_ntppriv_mode7_fullrecvbufs = -1;
static int hf_ntppriv_mode7_lowwater = -1;
static int hf_ntppriv_mode7_dropped = -1;
static int hf_ntppriv_mode7_ignored = -1;
static int hf_ntppriv_mode7_received = -1;
static int hf_ntppriv_mode7_notsent = -1;
static int hf_ntppriv_mode7_interrupts = -1;
static int hf_ntppriv_mode7_int_received = -1;
static int hf_ntppriv_mode7_alarms = -1;
static int hf_ntppriv_mode7_overflows = -1;
static int hf_ntppriv_mode7_xmtcalls = -1;
static int hf_ntppriv_mode7_rflags = -1;
static int hf_ntppriv_mode7_mflags = -1;
static int hf_ntppriv_mode7_int_name = -1;
static int hf_ntppriv_mode7_int_flags = -1;
static int hf_ntppriv_mode7_last_ttl = -1;
static int hf_ntppriv_mode7_num_mcast = -1;
static int hf_ntppriv_mode7_uptime = -1;
static int hf_ntppriv_mode7_scopeid = -1;
static int hf_ntppriv_mode7_ifindex = -1;
static int hf_ntppriv_mode7_ifnum = -1;
static int hf_ntppriv_mode7_peercnt = -1;
static int hf_ntppriv_mode7_family = -1;
static int hf_ntppriv_mode7_ignore_pkt = -1;
static int hf_ntppriv_mode7_action = -1;
static int hf_ntppriv_mode7_nvalues = -1;
static int hf_ntppriv_mode7_ntimes = -1;
static int hf_ntppriv_mode7_svalues = -1;
static int hf_ntppriv_mode7_stimes = -1;
static int hf_ntppriv_mode7_values = -1;
static int hf_ntppriv_mode7_times = -1;
static int hf_ntppriv_mode7_which = -1;
static int hf_ntppriv_mode7_fudgetime = -1;
static int hf_ntppriv_mode7_fudgeval_flags = -1;
static int hf_ntppriv_mode7_ippeerlimit = -1;
static int hf_ntppriv_mode7_restrict_flags = -1;

static gint ett_ntp = -1;
static gint ett_ntp_flags = -1;
static gint ett_ntp_ext = -1;
static gint ett_ntp_ext_flags = -1;
static gint ett_ntpctrl_flags2 = -1;
static gint ett_ntpctrl_status = -1;
static gint ett_ntpctrl_data = -1;
static gint ett_ntpctrl_item = -1;
static gint ett_ntppriv_auth_seq = -1;
static gint ett_mode7_item = -1;
static gint ett_ntp_authenticator = -1;
static gint ett_ntppriv_peer_list_flags = -1;
static gint ett_ntppriv_config_flags = -1;
static gint ett_ntppriv_sys_flag_flags = -1;
static gint ett_ntppriv_reset_stats_flags = -1;

static expert_field ei_ntp_ext = EI_INIT;

static const char *mon_names[12] = {
	"Jan",
	"Feb",
	"Mar",
	"Apr",
	"May",
	"Jun",
	"Jul",
	"Aug",
	"Sep",
	"Oct",
	"Nov",
	"Dec"
};

static int * const ntp_header_fields[] = {
	&hf_ntp_flags_li,
	&hf_ntp_flags_vn,
	&hf_ntp_flags_mode,
	NULL
};

/*
	* dissect peer status word:
	*                      1
	*  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
	* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	* | Status  | Sel | Count | Code  |
	* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	*/
static int * const peer_status_flags[] = {
	&hf_ntpctrl_peer_status_b0,
	&hf_ntpctrl_peer_status_b1,
	&hf_ntpctrl_peer_status_b2,
	&hf_ntpctrl_peer_status_b3,
	&hf_ntpctrl_peer_status_b4,
	&hf_ntpctrl_peer_status_selection,
	&hf_ntpctrl_peer_status_count,
	&hf_ntpctrl_peer_status_code,
	NULL
};

static int * const ntppriv_peer_list_flags[] = {
	&hf_ntppriv_mode7_peer_flags_config,
	&hf_ntppriv_mode7_peer_flags_syspeer,
	&hf_ntppriv_mode7_peer_flags_burst,
	&hf_ntppriv_mode7_peer_flags_refclock,
	&hf_ntppriv_mode7_peer_flags_prefer,
	&hf_ntppriv_mode7_peer_flags_authenable,
	&hf_ntppriv_mode7_peer_flags_sel_candidate,
	&hf_ntppriv_mode7_peer_flags_shortlist,
	NULL
};

static int * const ntppriv_config_flags[] = {
	&hf_ntppriv_mode7_config_flags_auth,
	&hf_ntppriv_mode7_config_flags_prefer,
	&hf_ntppriv_mode7_config_flags_burst,
	&hf_ntppriv_mode7_config_flags_iburst,
	&hf_ntppriv_mode7_config_flags_noselect,
	&hf_ntppriv_mode7_config_flags_skey,
	NULL
};

static int * const ntppriv_sys_flag_flags[] = {
	&hf_ntppriv_mode7_sys_flags_bclient,
	&hf_ntppriv_mode7_sys_flags_pps,
	&hf_ntppriv_mode7_sys_flags_ntp,
	&hf_ntppriv_mode7_sys_flags_kernel,
	&hf_ntppriv_mode7_sys_flags_monitor,
	&hf_ntppriv_mode7_sys_flags_filegen,
	&hf_ntppriv_mode7_sys_flags_auth,
	&hf_ntppriv_mode7_sys_flags_cal,
	NULL
};

static int * const ntppriv_reset_stats_flags[] = {
	&hf_ntppriv_mode7_reset_stats_flags_allpeers,
	&hf_ntppriv_mode7_reset_stats_flags_io,
	&hf_ntppriv_mode7_reset_stats_flags_sys,
	&hf_ntppriv_mode7_reset_stats_flags_mem,
	&hf_ntppriv_mode7_reset_stats_flags_timer,
	&hf_ntppriv_mode7_reset_stats_flags_auth,
	&hf_ntppriv_mode7_reset_stats_flags_ctl,
	NULL
};

/* parser definitions */
static tvbparse_wanted_t *want;
static tvbparse_wanted_t *want_ignore;

/*
 * NTP_BASETIME is in fact epoch - ntp_start_time; ntp_start_time
 * is January 1, 2036, 00:00:00 UTC.
 */
#define NTP_BASETIME EPOCH_DELTA_1900_01_01_00_00_00_UTC
#define NTP_FLOAT_DENOM 4294967296.0
#define NTP_TS_SIZE 110

/* tvb_ntp_fmt_ts_sec - converts an NTP timestamps second part (32bits) to an human readable string.
* TVB and an offset (IN).
* returns pointer to filled buffer.  This buffer will be freed automatically once
* dissection of the next packet occurs.
*/
const char *
tvb_ntp_fmt_ts_sec(tvbuff_t *tvb, gint offset)
{
	guint32 tempstmp;
	time_t temptime;
	struct tm *bd;
	char *buff;

	tempstmp = tvb_get_ntohl(tvb, offset);
	if (tempstmp == 0){
		return "NULL";
	}

	/* We need a temporary variable here so the unsigned math
	* works correctly (for years > 2036 according to RFC 2030
	* chapter 3).
	*/
	temptime = (time_t)(tempstmp - NTP_BASETIME);
	bd = gmtime(&temptime);
	if (!bd){
		return "Not representable";
	}

	buff = (char *)wmem_alloc(wmem_packet_scope(), NTP_TS_SIZE);
	snprintf(buff, NTP_TS_SIZE,
		"%s %2d, %d %02d:%02d:%02d UTC",
		mon_names[bd->tm_mon],
		bd->tm_mday,
		bd->tm_year + 1900,
		bd->tm_hour,
		bd->tm_min,
		bd->tm_sec);
	return buff;
}

void
ntp_to_nstime(tvbuff_t *tvb, gint offset, nstime_t *nstime)
{
	guint32 tempstmp;

	/* We need a temporary variable here so the unsigned math
	 * works correctly (for years > 2036 according to RFC 2030
	 * chapter 3).
	 */
	tempstmp  = tvb_get_ntohl(tvb, offset);
	if (tempstmp)
		nstime->secs = (time_t)(tempstmp - NTP_BASETIME);
	else
		nstime->secs = (time_t)tempstmp; /* 0 */

	nstime->nsecs = (int)(tvb_get_ntohl(tvb, offset+4)/(NTP_FLOAT_DENOM/1000000000.0));
}


static int
dissect_ntp_ext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree, int offset)
{
	proto_tree *ext_tree;
	proto_item *tf;
	guint16 extlen;
	int value_length;

	extlen = tvb_get_ntohs(tvb, offset+2);
	tf = proto_tree_add_item(ntp_tree, hf_ntp_ext, tvb, offset, extlen, ENC_NA);
	ext_tree = proto_item_add_subtree(tf, ett_ntp_ext);

	proto_tree_add_item(ext_tree, hf_ntp_ext_type, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	tf = proto_tree_add_item(ext_tree, hf_ntp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	if (extlen < 8) {
		/* Extension length isn't enough for the extension header.
		 * Report the error, and return an offset that goes to
		 * the end of the tvbuff, so we stop dissecting.
		 */
		expert_add_info_format(pinfo, tf, &ei_ntp_ext, "Extension length %u < 8", extlen);
		return tvb_reported_length(tvb);
	}
	if (extlen % 4) {
		/* Extension length isn't a multiple of 4.
		 * Report the error, and return an offset that goes
		 * to the end of the tvbuff, so we stop dissecting.
		 */
		expert_add_info_format(pinfo, tf, &ei_ntp_ext, "Extension length %u isn't a multiple of 4",
				extlen);
		return tvb_reported_length(tvb);
	}

	value_length = extlen - 4;
	proto_tree_add_item(ext_tree, hf_ntp_ext_value, tvb, offset, value_length, ENC_NA);
	offset += value_length;

	return offset;
}

static void
dissect_ntp_std(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree, ntp_conv_info_t *ntp_conv)
{
	guint8 stratum;
	gint8 ppoll;
	gint8 precision;
	guint32 rootdelay;
	double rootdelay_double;
	guint32 rootdispersion;
	double rootdispersion_double;
	guint32 refid_addr;
	gchar *buff;
	int i;
	int efs_end;
	guint16 last_extlen = 0;
	int macofs;
	guint maclen;
	ntp_trans_info_t *ntp_trans;
	wmem_tree_key_t key[3];
	guint64 flags;
	guint32 seq;

	proto_tree_add_bitmask_ret_uint64(ntp_tree, tvb, 0, hf_ntp_flags, ett_ntp_flags,
	                                  ntp_header_fields, ENC_NA, &flags);

	seq = 0xffffffff;
	key[0].length = 1;
	key[0].key = &seq;
	key[1].length = 1;
	key[1].key = &pinfo->num;
	key[2].length = 0;
	key[2].key = NULL;
	if ((flags & NTP_MODE_MASK) == NTP_MODE_CLIENT) {
		if (!PINFO_FD_VISITED(pinfo)) {
			ntp_trans = wmem_new(wmem_file_scope(), ntp_trans_info_t);
			ntp_trans->req_frame = pinfo->num;
			ntp_trans->resp_frame = 0;
			ntp_trans->req_time = pinfo->abs_ts;
			ntp_trans->seq = seq;
			wmem_tree_insert32_array(ntp_conv->trans, key, (void *)ntp_trans);
		} else {
			ntp_trans = (ntp_trans_info_t *)wmem_tree_lookup32_array_le(ntp_conv->trans, key);
			if (ntp_trans && ntp_trans->resp_frame != 0 && ntp_trans->seq == seq) {
				proto_item *resp_it;

				resp_it = proto_tree_add_uint(ntp_tree, hf_ntp_response_in, tvb, 0, 0, ntp_trans->resp_frame);
				proto_item_set_generated(resp_it);
			}
		}
	} else if ((flags & NTP_MODE_MASK) == NTP_MODE_SERVER) {
		ntp_trans = (ntp_trans_info_t *)wmem_tree_lookup32_array_le(ntp_conv->trans, key);
		if (ntp_trans && ntp_trans->seq == seq) {
			if (!PINFO_FD_VISITED(pinfo)) {
				if (ntp_trans->resp_frame == 0) {
					ntp_trans->resp_frame = pinfo->num;
				}
			} else if (ntp_trans->resp_frame == pinfo->num) {
				proto_item *req_it;
				nstime_t delta;

				req_it = proto_tree_add_uint(ntp_tree, hf_ntp_request_in, tvb, 0, 0, ntp_trans->req_frame);
				proto_item_set_generated(req_it);
				nstime_delta(&delta, &pinfo->abs_ts, &ntp_trans->req_time);
				req_it = proto_tree_add_time(ntp_tree, hf_ntp_delta_time, tvb, 0, 0, &delta);
				proto_item_set_generated(req_it);
			}
		}
	}

	/* Stratum, 1byte field represents distance from primary source
	 */
	proto_tree_add_item(ntp_tree, hf_ntp_stratum, tvb, 1, 1, ENC_NA);
	stratum = tvb_get_guint8(tvb, 1);

	/* Poll interval, 1byte field indicating the maximum interval
	 * between successive messages, in seconds to the nearest
	 * power of two.
	 */
	ppoll = tvb_get_gint8(tvb, 2);
	proto_tree_add_int_format_value(ntp_tree, hf_ntp_ppoll, tvb, 2, 1,
		ppoll, ppoll >= 0 ? "%d (%.0f seconds)" : "%d (%5.3f seconds)",
		ppoll, pow(2, ppoll));

	/* Precision, 1 byte field indicating the precision of the
	 * local clock, in seconds to the nearest power of two.
	 */
	precision = tvb_get_gint8(tvb, 3);
	proto_tree_add_int_format_value(ntp_tree, hf_ntp_precision, tvb, 3, 1,
		precision, "%d (%11.9f seconds)", precision, pow(2, precision));

	/* Root Delay is a 32-bit signed fixed-point number indicating
	 * the total roundtrip delay to the primary reference source,
	 * in seconds with fraction point between bits 15 and 16.
	 */
	rootdelay = tvb_get_ntohl(tvb, 4);
	rootdelay_double = (rootdelay >> 16) + (rootdelay & 0xffff) / 65536.0;
	proto_tree_add_uint_format_value(ntp_tree, hf_ntp_rootdelay, tvb, 4, 4,
		rootdelay, "%8.6f seconds", rootdelay_double);

	/* Root Dispersion, 32-bit unsigned fixed-point number indicating
	 * the nominal error relative to the primary reference source, in
	 * seconds with fraction point between bits 15 and 16.
	 */
	rootdispersion = tvb_get_ntohl(tvb, 8);
	rootdispersion_double = (rootdispersion >> 16) + (rootdispersion & 0xffff) / 65536.0;
	proto_tree_add_uint_format_value(ntp_tree, hf_ntp_rootdispersion, tvb, 8, 4,
		rootdispersion, "%8.6f seconds", rootdispersion_double);

	/* Now, there is a problem with secondary servers.  Standards
	 * asks from stratum-2 - stratum-15 servers to set this to the
	 * low order 32 bits of the latest transmit timestamp of the
	 * reference source.
	 * But, all V3 and V4 servers set this to IP address of their
	 * higher level server. My decision was to resolve this address.
	 */
	buff = (gchar *)wmem_alloc(wmem_packet_scope(), NTP_TS_SIZE);
	if (stratum == 0) {
		snprintf (buff, NTP_TS_SIZE, "Unidentified Kiss-o\'-Death message '%s'",
			tvb_get_string_enc(wmem_packet_scope(), tvb, 12, 4, ENC_ASCII));
		for (i = 0; kod_messages[i].id; i++) {
			if (tvb_memeql(tvb, 12, kod_messages[i].id, 4) == 0) {
				snprintf(buff, NTP_TS_SIZE, "%s",
					kod_messages[i].data);
				break;
			}
		}
	} else if (stratum == 1) {
		snprintf (buff, NTP_TS_SIZE, "Unidentified reference source '%s'",
			tvb_get_string_enc(wmem_packet_scope(), tvb, 12, 4, ENC_ASCII));
		for (i = 0; primary_sources[i].id; i++) {
			if (tvb_memeql(tvb, 12, (const guint8*)primary_sources[i].id, 4) == 0) {
				snprintf(buff, NTP_TS_SIZE, "%s",
					primary_sources[i].data);
				break;
			}
		}
	} else {
		int buffpos;
		refid_addr = tvb_get_ipv4(tvb, 12);
		buffpos = snprintf(buff, NTP_TS_SIZE, "%s", get_hostname (refid_addr));
		if (buffpos >= NTP_TS_SIZE) {
			buff[NTP_TS_SIZE-4]='.';
			buff[NTP_TS_SIZE-3]='.';
			buff[NTP_TS_SIZE-2]='.';
			buff[NTP_TS_SIZE-1]=0;
		}
	}
	proto_tree_add_bytes_format_value(ntp_tree, hf_ntp_refid, tvb, 12, 4,
					NULL, "%s", buff);

	/* Reference Timestamp: This is the time at which the local clock was
	 * last set or corrected.
	 */
	proto_tree_add_item(ntp_tree, hf_ntp_reftime, tvb, 16, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);

	/* Originate Timestamp: This is the time at which the request departed
	 * the client for the server.
	 */
	proto_tree_add_item(ntp_tree, hf_ntp_org, tvb, 24, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);

	/* Receive Timestamp: This is the time at which the request arrived at
	 * the server.
	 */
	proto_tree_add_item(ntp_tree, hf_ntp_rec, tvb, 32, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);

	/* Transmit Timestamp: This is the time at which the reply departed the
	 * server for the client.
	 */
	proto_tree_add_item(ntp_tree, hf_ntp_xmt, tvb, 40, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);

	/*
	 * Optional fields:
	 *
	 * - Optional Extension fields (EFs), at minimum 16 bytes each.
	 *   Used for Autokey (RFC 5906, requires a MAC) and others.
	 *
	 * - Optional Message Authentication Codes (MACs), consisting of a
	 *   32-bit key ID concatenated with the digest. Per RFC 7822, this MAC
	 *   can be 24 bytes (SHA-1, AES-CMAC from RFC 8573), 20 octets (MD5),
	 *   or 4 bytes (crypto-NAK, MAC contains four zeroes). However,
	 *   implementations such as chrony and NTPsec support additional hash
	 *   algorithms such as SHA-512 which result in a MAC of 68 bytes.
	 *
	 * Since MACs cannot unambiguously be recognized from EFs based on size
	 * alone due to the larger, non-standard MAC algorithms, follow this:
	 *
	 * 1. Find the end of EFs, stopping as soon as it looks invalid (too
	 *    small or large Length field).
	 * 2. If there is any trailing data, assume a MAC is present. If it is
	 *    too small, remove a field that was assumed to be an EF.
	 */
	efs_end = 48;
	while (tvb_reported_length_remaining(tvb, efs_end) >= 16) {
		guint16 extlen = tvb_get_ntohs(tvb, efs_end + 2);
		if (extlen < 16) {
			break;
		}
		if (tvb_reported_length_remaining(tvb, efs_end) < extlen) {
			break;
		}
		efs_end += extlen;
		last_extlen = extlen;
	}

	maclen = tvb_reported_length_remaining(tvb, efs_end);
	if (maclen == 0) {
		/* MAC is missing. */
	} else if (maclen == 4 && tvb_get_ntohl(tvb, efs_end) == 0) {
		/* crypto-NAK - continue as normal. */
	} else if (maclen < 20) {
		/* last field was most likely not an EF, remove it. */
		efs_end -= last_extlen;
	}

	macofs = 48;
	while (macofs < efs_end) {
		macofs = dissect_ntp_ext(tvb, pinfo, ntp_tree, macofs);
	}

	/* When the NTP authentication scheme is implemented, the
	 * Key Identifier and Message Digest fields contain the
	 * message authentication code (MAC) information defined in
	 * Appendix C of RFC-1305. Will print this as hex code for now.
	 */
	if (tvb_reported_length_remaining(tvb, macofs) >= 4)
		proto_tree_add_item(ntp_tree, hf_ntp_keyid, tvb, macofs, 4, ENC_NA);
	macofs += 4;
	maclen = tvb_reported_length_remaining(tvb, macofs);
	if (maclen > 0)
		proto_tree_add_item(ntp_tree, hf_ntp_mac, tvb, macofs, maclen, ENC_NA);
}

static void
dissect_ntp_ctrl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ntp_tree, ntp_conv_info_t *ntp_conv)
{
	guint8 flags2;
	proto_tree *data_tree, *item_tree, *auth_tree;
	proto_item *td, *ti;
	guint16 associd;
	guint16 datalen;
	guint16 data_offset;
	gint length_remaining;
	gboolean auth_diss = FALSE;
	ntp_trans_info_t *ntp_trans;
	guint32 seq;
	wmem_tree_key_t key[3];

	tvbparse_t *tt;
	tvbparse_elem_t *element;

	static int * const ntpctrl_flags[] = {
		&hf_ntpctrl_flags2_r,
		&hf_ntpctrl_flags2_error,
		&hf_ntpctrl_flags2_more,
		&hf_ntpctrl_flags2_opcode,
		NULL
	};
	proto_tree_add_bitmask(ntp_tree, tvb, 0, hf_ntp_flags, ett_ntp_flags, ntp_header_fields, ENC_NA);
	proto_tree_add_bitmask(ntp_tree, tvb, 1, hf_ntpctrl_flags2, ett_ntpctrl_flags2, ntpctrl_flags, ENC_NA);
	flags2 = tvb_get_guint8(tvb, 1);

	proto_tree_add_item_ret_uint(ntp_tree, hf_ntpctrl_sequence, tvb, 2, 2, ENC_BIG_ENDIAN, &seq);
	key[0].length = 1;
	key[0].key = &seq;
	key[1].length = 1;
	key[1].key = &pinfo->num;
	key[2].length = 0;
	key[2].key = NULL;
	associd = tvb_get_ntohs(tvb, 6);
	/*
	 * further processing of status is only necessary in server responses
	 */
	if (flags2 & NTPCTRL_R_MASK) {
		ntp_trans = (ntp_trans_info_t *)wmem_tree_lookup32_array_le(ntp_conv->trans, key);
		if (ntp_trans && ntp_trans->seq == seq) {
			if (!PINFO_FD_VISITED(pinfo)) {
				if (ntp_trans->resp_frame == 0) {
					ntp_trans->resp_frame = pinfo->num;
				}
			} else {
				proto_item *req_it;
				nstime_t delta;

				req_it = proto_tree_add_uint(ntp_tree, hf_ntp_request_in, tvb, 0, 0, ntp_trans->req_frame);
				proto_item_set_generated(req_it);
				nstime_delta(&delta, &pinfo->abs_ts, &ntp_trans->req_time);
				req_it = proto_tree_add_time(ntp_tree, hf_ntp_delta_time, tvb, 0, 0, &delta);
				proto_item_set_generated(req_it);
			}
		}
		if (flags2 & NTPCTRL_ERROR_MASK) {
			/*
			 * if error bit is set: dissect error status word
			 *                      1
			 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
			 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
			 * |  Error Code   |   reserved    |
			 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
			 */
			static int * const errorstatus[] = {
				&hf_ntpctrl_error_status_word,
				NULL
			};

			/* Check if this is an error response... */
			proto_tree_add_bitmask(ntp_tree, tvb, 4, hf_ntpctrl_status, ett_ntpctrl_status, errorstatus, ENC_BIG_ENDIAN);
		} else {
			/* ...otherwise status word depends on OpCode */
			switch (flags2 & NTPCTRL_OP_MASK) {
			case NTPCTRL_OP_READSTAT:
			case NTPCTRL_OP_READVAR:
			case NTPCTRL_OP_WRITEVAR:
			case NTPCTRL_OP_ASYNCMSG:
				if (associd)
					proto_tree_add_bitmask(ntp_tree, tvb, 4, hf_ntpctrl_status, ett_ntpctrl_status, peer_status_flags, ENC_BIG_ENDIAN);
				else
				{
					/*
					 * dissect system status word:
					 *                      1
					 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
					 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
					 * |LI | ClkSource | Count | Code  |
					 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
					 */
					static int * const systemstatus[] = {
						&hf_ntpctrl_sys_status_li,
						&hf_ntpctrl_sys_status_clksrc,
						&hf_ntpctrl_sys_status_count,
						&hf_ntpctrl_sys_status_code,
						NULL
					};

					proto_tree_add_bitmask(ntp_tree, tvb, 4, hf_ntpctrl_status, ett_ntpctrl_status, systemstatus, ENC_BIG_ENDIAN);
				}
				break;
			case NTPCTRL_OP_READCLOCK:
			case NTPCTRL_OP_WRITECLOCK:
				{
				/*
				 * dissect clock status word:
				 *                      1
				 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
				 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
				 * | Clock Status  |  Event Code   |
				 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
				 */
				static int * const clockstatus[] = {
					&hf_ntpctrl_clk_status,
					&hf_ntpctrl_clk_status_code,
					NULL
				};

				proto_tree_add_bitmask(ntp_tree, tvb, 4, hf_ntpctrl_status, ett_ntpctrl_status, clockstatus, ENC_BIG_ENDIAN);
				}
				break;
			case NTPCTRL_OP_SETTRAP:
			case NTPCTRL_OP_UNSETTRAP:
			default:
				proto_tree_add_item(ntp_tree, hf_ntpctrl_status, tvb, 4, 2, ENC_BIG_ENDIAN);
				break;
			}
		}
	}
	else
	{
		if (!PINFO_FD_VISITED(pinfo)) {
			ntp_trans = wmem_new(wmem_file_scope(), ntp_trans_info_t);
			ntp_trans->req_frame = pinfo->num;
			ntp_trans->resp_frame = 0;
			ntp_trans->req_time = pinfo->abs_ts;
			ntp_trans->seq = seq;
			wmem_tree_insert32_array(ntp_conv->trans, key, (void *)ntp_trans);
		} else {
			ntp_trans = (ntp_trans_info_t *)wmem_tree_lookup32_array_le(ntp_conv->trans, key);
			if (ntp_trans && ntp_trans->resp_frame != 0 && ntp_trans->seq == seq) {
				proto_item *resp_it;

				resp_it = proto_tree_add_uint(ntp_tree, hf_ntp_response_in, tvb, 0, 0, ntp_trans->resp_frame);
				proto_item_set_generated(resp_it);
			}
		}
		proto_tree_add_item(ntp_tree, hf_ntpctrl_status, tvb, 4, 2, ENC_BIG_ENDIAN);
	}
	proto_tree_add_item(ntp_tree, hf_ntpctrl_associd, tvb, 6, 2, ENC_BIG_ENDIAN);
	proto_tree_add_item(ntp_tree, hf_ntpctrl_offset, tvb, 8, 2, ENC_BIG_ENDIAN);
	datalen = tvb_get_ntohs(tvb, 10);
	proto_tree_add_uint(ntp_tree, hf_ntpctrl_count, tvb, 10, 2, datalen);

	/*
	 * dissect Data part of the NTP control message
	 */
	if (datalen) {
		data_offset = 12;
		td = proto_tree_add_item(ntp_tree, hf_ntpctrl_data, tvb, data_offset, datalen, ENC_NA);
		data_tree = proto_item_add_subtree(td, ett_ntpctrl_data);
		switch(flags2 & NTPCTRL_OP_MASK) {
		case NTPCTRL_OP_READSTAT:
			if (!associd) {
				/*
				 * if associd == 0 then data part contains a list of the form
				 * <association identifier><status word>,
				 */
				while(datalen) {
					ti = proto_tree_add_item(data_tree, hf_ntpctrl_item, tvb, data_offset, 4, ENC_NA);
					item_tree = proto_item_add_subtree(ti, ett_ntpctrl_item);
					proto_tree_add_item(item_tree, hf_ntpctrl_associd, tvb, data_offset, 2, ENC_BIG_ENDIAN);
					data_offset += 2;
					proto_tree_add_bitmask(ntp_tree, tvb, data_offset, hf_ntpctrl_status, ett_ntpctrl_status, peer_status_flags, ENC_BIG_ENDIAN);
					data_offset += 2;
					datalen -= 4;
				}
				break;
			}
			/*
			 * but if associd != 0,
			 * then data part could be the same as if opcode is NTPCTRL_OP_READVAR
			 * --> so, no "break" here!
			 */
			/* FALL THROUGH */
		case NTPCTRL_OP_READVAR:
		case NTPCTRL_OP_WRITEVAR:
		case NTPCTRL_OP_READCLOCK:
		case NTPCTRL_OP_WRITECLOCK:
			tt = tvbparse_init(pinfo->pool, tvb, data_offset, datalen, NULL, want_ignore);
			while( (element = tvbparse_get(tt, want)) != NULL ) {
				tvbparse_tree_add_elem(data_tree, element);
			}
			break;
		case NTPCTRL_OP_ASYNCMSG:
			proto_tree_add_item(data_tree, hf_ntpctrl_trapmsg, tvb, data_offset, datalen, ENC_ASCII);
			break;
		case NTPCTRL_OP_CONFIGURE:
		case NTPCTRL_OP_SAVECONFIG:
			proto_tree_add_item(data_tree, hf_ntpctrl_configuration, tvb, data_offset, datalen, ENC_ASCII);
			auth_diss = TRUE;
			break;
		case NTPCTRL_OP_READ_MRU:
			proto_tree_add_item(data_tree, hf_ntpctrl_mru, tvb, data_offset, datalen, ENC_ASCII);
			auth_diss = TRUE;
			break;
		case NTPCTRL_OP_READ_ORDLIST_A:
			proto_tree_add_item(data_tree, hf_ntpctrl_ordlist, tvb, data_offset, datalen, ENC_ASCII);
			auth_diss = TRUE;
			break;
		case NTPCTRL_OP_REQ_NONCE:
			proto_tree_add_item(data_tree, hf_ntpctrl_nonce, tvb, data_offset, datalen, ENC_ASCII);
			auth_diss = TRUE;
			break;
		/* these opcodes doesn't carry any data: NTPCTRL_OP_SETTRAP, NTPCTRL_OP_UNSETTRAP, NTPCTRL_OP_UNSPEC */
		}
	}

	data_offset = 12+datalen;

	/* Check if there is authentication */
	if (((flags2 & NTPCTRL_R_MASK) == 0) || auth_diss == TRUE)
	{
		gint padding_length;

		length_remaining = tvb_reported_length_remaining(tvb, data_offset);
		/* Check padding presence */
		padding_length = (data_offset & 7) ? 8 - (data_offset & 7) : 0;
		if (length_remaining > padding_length)
		{
			if (padding_length)
			{
				proto_tree_add_item(ntp_tree, hf_ntp_padding, tvb, data_offset, padding_length, ENC_NA);
				data_offset += padding_length;
				length_remaining -= padding_length;
			}
			auth_tree = proto_tree_add_subtree(ntp_tree, tvb, data_offset, -1, ett_ntp_authenticator, NULL, "Authenticator");
			switch (length_remaining)
			{
			case 20:
				ti = proto_tree_add_uint(auth_tree, hf_ntp_key_type, tvb, data_offset, 0, NTP_MD5_ALGO);
				proto_item_set_generated(ti);
				proto_tree_add_item(auth_tree, hf_ntp_key_index, tvb, data_offset, 4, ENC_BIG_ENDIAN);
				proto_tree_add_item(auth_tree, hf_ntp_key_signature, tvb, data_offset+4, 16, ENC_NA);
				break;
			case 24:
				ti = proto_tree_add_uint(auth_tree, hf_ntp_key_type, tvb, data_offset, 0, NTP_SHA_ALGO);
				proto_item_set_generated(ti);
				proto_tree_add_item(auth_tree, hf_ntp_key_index, tvb, data_offset, 4, ENC_BIG_ENDIAN);
				proto_tree_add_item(auth_tree, hf_ntp_key_signature, tvb, data_offset+4, 20, ENC_NA);
				break;
			}
		}
	}
}

/*
 * Initialize tvb-parser, which is used to dissect data part of NTP control
 * messages
 *
 * Here some constants are defined, which describes character groups used for
 * various purposes. These groups are then used to configure the two global
 * variables "want_ignore" and "want" that we use for dissection
 */
static void
init_parser(void)
{
	/* specify what counts as character */
	tvbparse_wanted_t *want_identifier_str = tvbparse_chars(-1, 1, 0,
		"abcdefghijklmnopqrstuvwxyz-_ABCDEFGHIJKLMNOPQRSTUVWXYZ.0123456789", NULL, NULL, NULL);
	/* this is the equal sign used in assignments */
	tvbparse_wanted_t *want_equalsign = tvbparse_char(-1, "=", NULL, NULL, NULL);
	/* possible characters allowed for values */
	tvbparse_wanted_t *want_value = tvbparse_set_oneof(0, NULL, NULL, NULL,
		tvbparse_quoted(-1, NULL, NULL, tvbparse_shrink_token_cb, '\"', '\\'),
		tvbparse_quoted(-1, NULL, NULL, tvbparse_shrink_token_cb, '\'', '\\'),
		tvbparse_chars(-1, 1, 0, "abcdefghijklmnopqrstuvwxyz-_ABCDEFGHIJKLMNOPQRSTUVWXYZ.0123456789 ", NULL, NULL, NULL),
		NULL);
	tvbparse_wanted_t *want_comma = tvbparse_until(-1, NULL, NULL, NULL,
		tvbparse_char(-1, ",", NULL, NULL, NULL), TP_UNTIL_SPEND);
	/* the following specifies an identifier */
	tvbparse_wanted_t *want_identifier = tvbparse_set_seq(-1, NULL, NULL, NULL,
		want_identifier_str,
		tvbparse_some(-1, 0, 1, NULL, NULL, NULL, want_comma),
		NULL);
	/* the following specifies an assignment of the form identifier=value */
	tvbparse_wanted_t *want_assignment = tvbparse_set_seq(-1, NULL, NULL, NULL,
		want_identifier_str,
		want_equalsign,
		tvbparse_some(-1, 0, 1, NULL, NULL, NULL, want_value),
		tvbparse_some(-1, 0, 1, NULL, NULL, NULL, want_comma),
		NULL);

	/* we ignore white space characters */
	want_ignore = tvbparse_chars(-1, 1, 0, " \t\r\n", NULL, NULL, NULL);
	/* data part of control messages consists of either identifiers or assignments */
	want = tvbparse_set_oneof(-1, NULL, NULL, NULL,
		want_assignment,
		want_identifier,
		NULL);
}

static void
dissect_ntp_priv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ntp_tree, ntp_conv_info_t *ntp_conv)
{
	guint32 impl, reqcode;
	guint64 flags, auth_seq;
	ntp_trans_info_t *ntp_trans;
	wmem_tree_key_t key[3];
	guint32 seq;

	static int * const priv_flags[] = {
		&hf_ntppriv_flags_r,
		&hf_ntppriv_flags_more,
		&hf_ntp_flags_vn,
		&hf_ntp_flags_mode,
		NULL
	};

	static int * const auth_flags[] = {
		&hf_ntppriv_auth,
		&hf_ntppriv_seq,
		NULL
	};

	proto_tree_add_bitmask_ret_uint64(ntp_tree, tvb, 0, hf_ntp_flags, ett_ntp_flags, priv_flags, ENC_NA, &flags);
	proto_tree_add_bitmask_ret_uint64(ntp_tree, tvb, 1, hf_ntppriv_auth_seq, ett_ntppriv_auth_seq, auth_flags, ENC_NA, &auth_seq);
	proto_tree_add_item_ret_uint(ntp_tree, hf_ntppriv_impl, tvb, 2, 1, ENC_NA, &impl);
	proto_tree_add_item_ret_uint(ntp_tree, hf_ntppriv_reqcode, tvb, 3, 1, ENC_NA, &reqcode);

	col_append_fstr(pinfo->cinfo, COL_INFO, ", %s, %s",
		(flags & NTPPRIV_R_MASK) ? "Response" : "Request",
		val_to_str_ext_const(reqcode, &priv_rc_types_ext, "Unknown"));


	seq = 0xff000000 | impl;
	key[0].length = 1;
	key[0].key = &seq;
	key[1].length = 1;
	key[1].key = &pinfo->num;
	key[2].length = 0;
	key[2].key = NULL;

	if (flags & NTPPRIV_R_MASK) {
		/* response */
		ntp_trans = (ntp_trans_info_t *)wmem_tree_lookup32_array_le(ntp_conv->trans, key);
		if (ntp_trans && ntp_trans->seq == seq) {
			if (!PINFO_FD_VISITED(pinfo)) {
				if (ntp_trans->resp_frame == 0) {
					ntp_trans->resp_frame = pinfo->num;
				}
			} else {
				proto_item *req_it;
				nstime_t delta;

				req_it = proto_tree_add_uint(ntp_tree, hf_ntp_request_in, tvb, 0, 0, ntp_trans->req_frame);
				proto_item_set_generated(req_it);
				nstime_delta(&delta, &pinfo->abs_ts, &ntp_trans->req_time);
				req_it = proto_tree_add_time(ntp_tree, hf_ntp_delta_time, tvb, 0, 0, &delta);
				proto_item_set_generated(req_it);
			}
		}
	} else {
		/* request */
		if (!PINFO_FD_VISITED(pinfo)) {
			ntp_trans = wmem_new(wmem_file_scope(), ntp_trans_info_t);
			ntp_trans->req_frame = pinfo->num;
			ntp_trans->resp_frame = 0;
			ntp_trans->req_time = pinfo->abs_ts;
			ntp_trans->seq = seq;
			wmem_tree_insert32_array(ntp_conv->trans, key, (void *)ntp_trans);
		} else {
			ntp_trans = (ntp_trans_info_t *)wmem_tree_lookup32_array_le(ntp_conv->trans, key);
			if (ntp_trans && ntp_trans->resp_frame != 0 && ntp_trans->seq == seq) {
				proto_item *resp_it;

				resp_it = proto_tree_add_uint(ntp_tree, hf_ntp_response_in, tvb, 0, 0, ntp_trans->resp_frame);
				proto_item_set_generated(resp_it);
			}
		}
	}

	if (impl == XNTPD) {

		guint64 numitems;
		guint64 itemsize;
		guint16 offset;
		guint i;

		guint32 v6_flag = 0;

		proto_item *mode7_item;
		proto_tree *mode7_item_tree = NULL;

		proto_tree_add_bits_item(ntp_tree, hf_ntppriv_errcode, tvb, 32, 4, ENC_BIG_ENDIAN);
		proto_tree_add_bits_ret_val(ntp_tree, hf_ntppriv_numitems, tvb, 36, 12, &numitems, ENC_BIG_ENDIAN);
		proto_tree_add_bits_item(ntp_tree, hf_ntppriv_mbz, tvb, 48, 4, ENC_BIG_ENDIAN);
		proto_tree_add_bits_ret_val(ntp_tree, hf_ntppriv_itemsize, tvb, 52, 12, &itemsize, ENC_BIG_ENDIAN);

		for (i = 0; i < (guint16)numitems; i++) {

			offset = 8 + (guint16)itemsize * i;

			if ((reqcode != PRIV_RC_MON_GETLIST) && (reqcode != PRIV_RC_MON_GETLIST_1)) {
				mode7_item = proto_tree_add_string_format(ntp_tree, hf_ntppriv_mode7_item, tvb, offset,(gint)itemsize,
					"", "%s Item", val_to_str_ext_const(reqcode, &priv_rc_types_ext, "Unknown") );
				mode7_item_tree = proto_item_add_subtree(mode7_item, ett_mode7_item);
			}

			switch (reqcode) {
			case PRIV_RC_MON_GETLIST:
			case PRIV_RC_MON_GETLIST_1:

				mode7_item = proto_tree_add_string_format(ntp_tree, hf_ntppriv_mode7_item, tvb, offset,
					(gint)itemsize, "Monlist Item", "Monlist item: address: %s:%u",
					tvb_ip_to_str(pinfo->pool, tvb, offset + 16), tvb_get_ntohs(tvb, offset + ((reqcode == PRIV_RC_MON_GETLIST_1) ? 28 : 20)));
				mode7_item_tree = proto_item_add_subtree(mode7_item, ett_mode7_item);

				proto_tree_add_item(mode7_item_tree, hf_ntppriv_avgint, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_lsint, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_restr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_count, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				if (reqcode == PRIV_RC_MON_GETLIST_1) {
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_daddr, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
				}
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_port, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_version, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item_ret_uint(mode7_item_tree, hf_ntppriv_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN, &v6_flag);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_unused, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				if (v6_flag != 0) {
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_addr6, tvb, offset, 16, ENC_NA);
					offset += 16;
					if (reqcode == PRIV_RC_MON_GETLIST_1)
						proto_tree_add_item(mode7_item_tree, hf_ntppriv_daddr6, tvb, offset, 16, ENC_NA);
				}
				break;

			case PRIV_RC_PEER_LIST:

				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_port, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hmode, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_peer_flags, ett_ntppriv_peer_list_flags, ntppriv_peer_list_flags, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
				break;

			case PRIV_RC_PEER_LIST_SUM:

				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dstaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcport, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntp_stratum, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hpoll, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntp_ppoll, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_reach, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_peer_flags, ett_ntppriv_peer_list_flags, ntppriv_peer_list_flags, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hmode, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_delay, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_offset, tvb, offset, 8, ENC_BIG_ENDIAN);
				offset += 8;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dispersion, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dstaddr6, tvb, offset, 16, ENC_NA);
				offset += 16;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcaddr6, tvb, offset, 16, ENC_NA);
				break;

			case PRIV_RC_PEER_INFO:

				if (flags & NTPPRIV_R_MASK) {
					/* response */
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dstaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcport, tvb, offset, 2, ENC_BIG_ENDIAN);
					offset += 2;
					proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_peer_flags, ett_ntppriv_peer_list_flags, ntppriv_peer_list_flags, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_leap, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hmode, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_pmode, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntp_stratum, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntp_ppoll, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hpoll, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntp_precision, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_version, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 1, ENC_NA);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_reach, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unreach, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_flash, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_flash2, tvb, offset, 2, ENC_BIG_ENDIAN);
					offset += 2;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_associd, tvb, offset, 2, ENC_BIG_ENDIAN);
					offset += 2;
					proto_tree_add_item(mode7_item_tree, hf_ntp_keyid, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_pkeyid, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntp_refid, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timer, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntp_rootdelay, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntp_rootdispersion, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntp_reftime, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
					offset += 8;
					proto_tree_add_item(mode7_item_tree, hf_ntp_org, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
					offset += 8;
					proto_tree_add_item(mode7_item_tree, hf_ntp_rec, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
					offset += 8;
					proto_tree_add_item(mode7_item_tree, hf_ntp_xmt, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
					offset += 8;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_filtdelay, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_filtoffset, tvb, offset, 8, ENC_BIG_ENDIAN);
					offset += 8;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_order, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_delay, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dispersion, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_offset, tvb, offset, 8, ENC_BIG_ENDIAN);
					offset += 8;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_selectdis, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_estbdelay, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dstaddr6, tvb, offset, 16, ENC_NA);
					offset += 16;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcaddr6, tvb, offset, 16, ENC_NA);
				} else {
					/* request */
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_port, tvb, offset, 2, ENC_BIG_ENDIAN);
					offset += 2;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hmode, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_peer_flags, ett_ntppriv_peer_list_flags, ntppriv_peer_list_flags, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
				}
				break;

			case PRIV_RC_PEER_STATS:

				if (flags & NTPPRIV_R_MASK) {
					/* response */
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dstaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcport, tvb, offset, 2, ENC_BIG_ENDIAN);
					offset += 2;
					proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_peer_flags, ett_ntppriv_peer_list_flags, ntppriv_peer_list_flags, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereceived, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timetosend, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereachable, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_sent, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_processed, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badauth, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_bogusorg, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_oldpkt, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_seldisp, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_selbroken, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_candidate, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 1, ENC_NA);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 1, ENC_NA);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 1, ENC_NA);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dstaddr6, tvb, offset, 16, ENC_NA);
					offset += 16;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcaddr6, tvb, offset, 16, ENC_NA);
				} else {
					/* request */
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_port, tvb, offset, 2, ENC_BIG_ENDIAN);
					offset += 2;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hmode, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_peer_flags, ett_ntppriv_peer_list_flags, ntppriv_peer_list_flags, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
				}
				break;

			case PRIV_RC_SYS_INFO:
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_pmode, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_leap, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntp_stratum, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntp_precision, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntp_rootdelay, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntp_rootdispersion, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntp_refid, tvb, offset, 4, ENC_NA);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntp_reftime, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
				offset += 8;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_poll32, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_sys_flags8, ett_ntppriv_sys_flag_flags, ntppriv_sys_flag_flags, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 3, ENC_NA);
				offset += 3;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_bdelay, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_freq, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_authdelay, tvb, offset, 8, ENC_BIG_ENDIAN);
				offset += 8;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_stability, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
				break;

			case PRIV_RC_SYS_STATS:
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timeup, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_denied, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_oldversion, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_newversion, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badversion, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badlength, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_processed, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badauth, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereceived, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_limitrejected, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_lamport, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_tsrounding, tvb, offset, 4, ENC_BIG_ENDIAN);
				break;

			case PRIV_RC_IO_STATS:
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_totalrecvbufs, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_freerecvbufs, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fullrecvbufs, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_lowwater, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dropped, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ignored, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_received, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_sent, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_notsent, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_interrupts, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_int_received, tvb, offset, 4, ENC_BIG_ENDIAN);
				break;

			case PRIV_RC_MEM_STATS:
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_totalmem, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_freemem, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_findpeer_calls, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_allocations, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_demobilizations, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hashcount, tvb, offset, (gint)itemsize - 20, ENC_NA);
				break;

			case PRIV_RC_LOOP_INFO:
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_last_offset, tvb, offset, 8, ENC_BIG_ENDIAN);
				offset += 8;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_drift_comp, tvb, offset, 8, ENC_BIG_ENDIAN);
				offset += 8;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_compliance, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_watchdog_timer, tvb, offset, 4, ENC_BIG_ENDIAN);
				break;

			case PRIV_RC_TIMER_STATS:
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_alarms, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_overflows, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_xmtcalls, tvb, offset, 4, ENC_BIG_ENDIAN);
				break;

			case PRIV_RC_CONFIG:

				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hmode, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_version, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_minpoll, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_maxpoll, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_config_flags, ett_ntppriv_config_flags, ntppriv_config_flags, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 2, ENC_NA);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntp_keyid, tvb, offset, 4, ENC_NA);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_key_file, tvb, offset, 128, ENC_ASCII);
				offset += 128;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
				break;

			case PRIV_RC_UNCONFIG:

				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
				break;

			case PRIV_RC_SET_SYS_FLAG:
			case PRIV_RC_CLR_SYS_FLAG:

				proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_sys_flags, ett_ntppriv_sys_flag_flags, ntppriv_sys_flag_flags, ENC_BIG_ENDIAN);
				break;

			case PRIV_RC_GET_RESTRICT:
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mask, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_count, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_rflags, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mflags, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
				offset += 16;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mask6, tvb, offset, 16, ENC_NA);
				break;

			case PRIV_RC_RESADDFLAGS:
			case PRIV_RC_RESSUBFLAGS:
			case PRIV_RC_UNRESTRICT:
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mask, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ippeerlimit, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_restrict_flags, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mflags, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
				offset += 16;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mask6, tvb, offset, 16, ENC_NA);
				break;

			case PRIV_RC_RESET_STATS:

				proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_reset_stats_flags, ett_ntppriv_reset_stats_flags, ntppriv_reset_stats_flags, ENC_BIG_ENDIAN);
				break;

			case PRIV_RC_RESET_PEER:

				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
				break;

			case PRIV_RC_TRUSTKEY:
			case PRIV_RC_UNTRUSTKEY:

				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_key, tvb, offset, 8, ENC_LITTLE_ENDIAN);
				break;

			case PRIV_RC_AUTHINFO:

				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_numkeys, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_numfreekeys, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_keylookups, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_keynotfound, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_encryptions, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_decryptions, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_expired, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_keyuncached, tvb, offset, 4, ENC_BIG_ENDIAN);
				break;

			case PRIV_RC_TRAPS:

				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_local_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_trap_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_trap_port, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_sequence, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_settime, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_origtime, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_resets, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_traps_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_local_addr6, tvb, offset, 16, ENC_NA);
				offset += 16;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_trap_addr6, tvb, offset, 16, ENC_NA);
				break;

			case PRIV_RC_ADD_TRAP:
			case PRIV_RC_CLR_TRAP:

				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_local_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_trap_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_trap_port, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 2, ENC_NA);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_local_addr6, tvb, offset, 16, ENC_NA);
				offset += 16;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_trap_addr6, tvb, offset, 16, ENC_NA);
				break;

			case PRIV_RC_REQUEST_KEY:
			case PRIV_RC_CONTROL_KEY:

				proto_tree_add_item(mode7_item_tree, hf_ntp_keyid, tvb, offset, 4, ENC_NA);
				break;

			case PRIV_RC_CTL_STATS:

				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_req, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badpkts, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_responses, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_frags, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_errors, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_tooshort, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_inputresp, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_inputfrag, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_inputerr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badoffset, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badversion, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_datatooshort, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badop, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_asyncmsgs, tvb, offset, 4, ENC_BIG_ENDIAN);
				break;

			case PRIV_RC_GET_CLOCKINFO:

				if (flags & NTPPRIV_R_MASK) {
					/* response */
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_type, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_clock_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_lastevent, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_currentstatus, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_polls, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_noresponse, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badformat, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_baddata, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timestarted, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fudgetime1, tvb, offset, 8, ENC_BIG_ENDIAN);
					offset += 8;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fudgetime2, tvb, offset, 8, ENC_BIG_ENDIAN);
					offset += 8;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fudgeval1, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fudgeval2, tvb, offset, 4, ENC_BIG_ENDIAN);
				} else {
					/* request */
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				}
				break;

			case PRIV_RC_SET_CLKFUDGE:
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_which, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fudgetime, tvb, offset, 8, ENC_BIG_ENDIAN);
				offset += 8;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fudgeval_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
				break;

			case PRIV_RC_GET_KERNEL:

				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_kernel_offset, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_freq, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_maxerror, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_esterror, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_status, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_shift, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_constant, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_precision, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_tolerance, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ppsfreq, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_jitter, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_stabil, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_jitcnt, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_calcnt, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_errcnt, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_stbcnt, tvb, offset, 4, ENC_BIG_ENDIAN);
				break;

			case PRIV_RC_GET_CLKBUGINFO:
				if (flags & NTPPRIV_R_MASK) {
					/* response */
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_nvalues, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ntimes, tvb, offset, 1, ENC_BIG_ENDIAN);
					offset += 1;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_svalues, tvb, offset, 2, ENC_BIG_ENDIAN);
					offset += 2;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_stimes, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 4;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_values, tvb, offset, 64, ENC_NA);
					offset += 64;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_times, tvb, offset, 256, ENC_NA);
				} else {
					/* request */
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
				}
				break;

			case PRIV_RC_IF_STATS:
			case PRIV_RC_IF_RELOAD:
				v6_flag = tvb_get_ntohl(tvb, offset + 48);
				if (v6_flag == 0) {
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 16;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_bcast, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 16;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mask, tvb, offset, 4, ENC_BIG_ENDIAN);
					offset += 16;
				} else {
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
					offset += 16;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_bcast6, tvb, offset, 16, ENC_NA);
					offset += 16;
					proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mask6, tvb, offset, 16, ENC_NA);
					offset += 16;
				}
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_int_name, tvb, offset, 32, ENC_ASCII);
				offset += 32;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_int_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_last_ttl, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_num_mcast, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_received, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_sent, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_notsent, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_uptime, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_scopeid, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ifindex, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ifnum, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_peercnt, tvb, offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_family, tvb, offset, 2, ENC_BIG_ENDIAN);
				offset += 2;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ignore_pkt, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_action, tvb, offset, 1, ENC_BIG_ENDIAN);
				offset += 1;
				proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
				break;

			}
		}
	}
	if ((flags & NTPPRIV_R_MASK) == 0 && (auth_seq & NTPPRIV_AUTH_MASK)) {
		/* request message with authentication bit */
		gint len;
		proto_tree_add_item(ntp_tree, hf_ntppriv_tstamp, tvb, 184, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
		proto_tree_add_item(ntp_tree, hf_ntp_keyid, tvb, 192, 4, ENC_NA);
		len = tvb_reported_length_remaining(tvb, 196);
		if (len)
			proto_tree_add_item(ntp_tree, hf_ntp_mac, tvb, 196, len, ENC_NA);
	}
}

/* dissect_ntp - dissects NTP packet data
 * tvb - tvbuff for packet data (IN)
 * pinfo - packet info
 * proto_tree - resolved protocol tree
 */
static int
dissect_ntp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
	proto_tree *ntp_tree;
	proto_item *ti = NULL;
	guint8 flags;
	conversation_t *conversation;
	ntp_conv_info_t *ntp_conv;
	void (*dissector)(tvbuff_t *, packet_info *, proto_tree *, ntp_conv_info_t *);

	col_set_str(pinfo->cinfo, COL_PROTOCOL, "NTP");

	col_clear(pinfo->cinfo, COL_INFO);

	flags = tvb_get_guint8(tvb, 0);
	switch (flags & NTP_MODE_MASK) {
	default:
		dissector = dissect_ntp_std;
		break;
	case NTP_MODE_CTRL:
		dissector = dissect_ntp_ctrl;
		break;
	case NTP_MODE_PRIV:
		dissector = dissect_ntp_priv;
		break;
	}

	/* Adding NTP item and subtree */
	ti = proto_tree_add_item(tree, proto_ntp, tvb, 0, -1, ENC_NA);
	ntp_tree = proto_item_add_subtree(ti, ett_ntp);

	/* Show version and mode in info column and NTP root */
	col_add_fstr(pinfo->cinfo, COL_INFO, "%s, %s",
		val_to_str_const((flags & NTP_VN_MASK) >> 3, ver_nums, "Unknown version"),
		val_to_str_const(flags & NTP_MODE_MASK, info_mode_types, "Unknown"));

	proto_item_append_text(ti, " (%s, %s)",
		val_to_str_const((flags & NTP_VN_MASK) >> 3, ver_nums, "Unknown version"),
		val_to_str_const(flags & NTP_MODE_MASK, info_mode_types, "Unknown"));

	conversation = find_or_create_conversation(pinfo);
	ntp_conv = (ntp_conv_info_t *)conversation_get_proto_data(conversation, proto_ntp);
	if (!ntp_conv) {
		ntp_conv = wmem_new(wmem_file_scope(), ntp_conv_info_t);
		ntp_conv->trans = wmem_tree_new(wmem_file_scope());
		conversation_add_proto_data(conversation, proto_ntp, ntp_conv);
	}

	/* Dissect according to mode */
	(*dissector)(tvb, pinfo, ntp_tree, ntp_conv);
	return tvb_captured_length(tvb);
}

void
proto_register_ntp(void)
{
	static hf_register_info hf[] = {
		{ &hf_ntp_flags, {
			"Flags", "ntp.flags", FT_UINT8, BASE_HEX,
			NULL, 0, "Flags (Leap/Version/Mode)", HFILL }},
		{ &hf_ntp_flags_li, {
			"Leap Indicator", "ntp.flags.li", FT_UINT8, BASE_DEC,
			VALS(li_types), NTP_LI_MASK, "Warning of an impending leap second to be inserted or deleted in the last minute of the current month", HFILL }},
		{ &hf_ntp_flags_vn, {
			"Version number", "ntp.flags.vn", FT_UINT8, BASE_DEC,
			VALS(ver_nums), NTP_VN_MASK, NULL, HFILL }},
		{ &hf_ntp_flags_mode, {
			"Mode", "ntp.flags.mode", FT_UINT8, BASE_DEC,
			VALS(mode_types), NTP_MODE_MASK, NULL, HFILL }},
		{ &hf_ntp_stratum, {
			"Peer Clock Stratum", "ntp.stratum", FT_UINT8, BASE_DEC|BASE_RANGE_STRING,
			RVALS(stratum_rvals), 0, NULL, HFILL }},
		{ &hf_ntp_ppoll, {
			"Peer Polling Interval", "ntp.ppoll", FT_INT8, BASE_DEC,
			NULL, 0, "Maximum interval between successive messages", HFILL }},
		{ &hf_ntp_precision, {
			"Peer Clock Precision", "ntp.precision", FT_INT8, BASE_DEC,
			NULL, 0, "The precision of the system clock", HFILL }},
		{ &hf_ntp_rootdelay, {
			"Root Delay", "ntp.rootdelay", FT_UINT32, BASE_DEC,
			NULL, 0, "Total round-trip delay to the reference clock", HFILL }},
		{ &hf_ntp_rootdispersion, {
			"Root Dispersion", "ntp.rootdispersion", FT_UINT32, BASE_DEC,
			NULL, 0, "Total dispersion to the reference clock", HFILL }},
		{ &hf_ntp_refid, {
			"Reference ID", "ntp.refid", FT_BYTES, BASE_NONE,
			NULL, 0, "Particular server or reference clock being used", HFILL }},
		{ &hf_ntp_reftime, {
			"Reference Timestamp", "ntp.reftime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC,
			NULL, 0, "Time when the system clock was last set or corrected", HFILL }},
		{ &hf_ntp_org, {
			"Origin Timestamp", "ntp.org", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC,
			NULL, 0, "Time at the client when the request departed for the server", HFILL }},
		{ &hf_ntp_rec, {
			"Receive Timestamp", "ntp.rec", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC,
			NULL, 0, "Time at the server when the request arrived from the client", HFILL }},
		{ &hf_ntp_xmt, {
			"Transmit Timestamp", "ntp.xmt", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC,
			NULL, 0, "Time at the server when the response left for the client", HFILL }},
		{ &hf_ntp_keyid, {
			"Key ID", "ntp.keyid", FT_BYTES, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntp_mac, {
			"Message Authentication Code", "ntp.mac", FT_BYTES, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntp_padding, {
			"Padding", "ntp.padding", FT_BYTES, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntp_key_type, {
			"Key type", "ntp.key_type", FT_UINT8, BASE_DEC,
			VALS(authentication_types), 0, "Authentication algorithm used", HFILL }},
		{ &hf_ntp_key_index, {
			"KeyIndex", "ntp.key_index", FT_UINT32, BASE_HEX,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntp_key_signature, {
			"Signature", "ntp.key_signature", FT_BYTES, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntp_response_in, {
			"Response In", "ntp.response_in", FT_FRAMENUM, BASE_NONE,
			FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0, NULL, HFILL }},
		{ &hf_ntp_request_in, {
			"Request In", "ntp.request_in", FT_FRAMENUM, BASE_NONE,
			FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0, NULL, HFILL }},
		{ &hf_ntp_delta_time, {
			"Delta Time", "ntp.delta_time", FT_RELATIVE_TIME, BASE_NONE,
			NULL, 0, "Time between request and response", HFILL }},

		{ &hf_ntp_ext, {
			"Extension", "ntp.ext", FT_NONE, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntp_ext_type, {
			"Field Type", "ntp.ext.type", FT_UINT16, BASE_HEX,
			VALS(ntp_ext_field_types), 0, NULL, HFILL }},
		{ &hf_ntp_ext_length, {
			"Length", "ntp.ext.length", FT_UINT16, BASE_DEC,
			NULL, 0, "Entire extension length including padding", HFILL }},
		{ &hf_ntp_ext_value, {
			"Value", "ntp.ext.value", FT_BYTES, BASE_NONE,
			NULL, 0, "Type-specific value", HFILL }},

		{ &hf_ntpctrl_flags2, {
			"Flags 2", "ntp.ctrl.flags2", FT_UINT8, BASE_HEX,
			NULL, 0, "Flags (Response/Error/More/Opcode)", HFILL }},
		{ &hf_ntpctrl_flags2_r, {
			"Response bit", "ntp.ctrl.flags2.r", FT_BOOLEAN, 8,
			TFS(&tfs_response_request), NTPCTRL_R_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_flags2_error, {
			"Error bit", "ntp.ctrl.flags2.error", FT_UINT8, BASE_DEC,
			NULL, NTPCTRL_ERROR_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_flags2_more, {
			"More bit", "ntp.ctrl.flags2.more", FT_UINT8, BASE_DEC,
			NULL, NTPCTRL_MORE_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_flags2_opcode, {
			"Opcode", "ntp.ctrl.flags2.opcode", FT_UINT8, BASE_DEC,
			VALS(ctrl_op_types), NTPCTRL_OP_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_sequence, {
			"Sequence", "ntp.ctrl.sequence", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntpctrl_status, {
			"Status", "ntp.ctrl.status", FT_UINT16, BASE_HEX,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntpctrl_error_status_word, {
			"Error Status Word", "ntp.ctrl.err_status", FT_UINT16, BASE_DEC,
			VALS(ctrl_err_status_types), NTP_CTRL_ERRSTATUS_CODE_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_sys_status_li, {
			"Leap Indicator", "ntp.ctrl.sys_status.li", FT_UINT16, BASE_DEC,
			VALS(li_types), NTPCTRL_SYSSTATUS_LI_MASK, "Warning of an impending leap second to be inserted or deleted in the last minute of the current month", HFILL }},
		{ &hf_ntpctrl_sys_status_clksrc, {
			"Clock Source", "ntp.ctrl.sys_status.clksrc", FT_UINT16, BASE_DEC,
			VALS(ctrl_sys_status_clksource_types), NTPCTRL_SYSSTATUS_CLK_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_sys_status_count, {
			"System Event Counter", "ntp.ctrl.sys_status.count", FT_UINT16, BASE_DEC,
			NULL, NTPCTRL_SYSSTATUS_COUNT_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_sys_status_code, {
			"System Event Code", "ntp.ctrl.sys_status.code", FT_UINT16, BASE_DEC,
			VALS(ctrl_sys_status_event_types), NTPCTRL_SYSSTATUS_CODE_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_peer_status_b0, {
			"Peer Status", "ntp.ctrl.peer_status.config", FT_BOOLEAN, 16,
			TFS(&tfs_ctrl_peer_status_config), NTPCTRL_PEERSTATUS_CONFIG_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_peer_status_b1, {
			"Peer Status", "ntp.ctrl.peer_status.authenable", FT_BOOLEAN, 16,
			TFS(&tfs_ctrl_peer_status_authenable), NTPCTRL_PEERSTATUS_AUTHENABLE_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_peer_status_b2, {
			"Peer Status", "ntp.ctrl.peer_status.authentic", FT_BOOLEAN, 16,
			TFS(&tfs_ctrl_peer_status_authentic), NTPCTRL_PEERSTATUS_AUTHENTIC_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_peer_status_b3, {
			"Peer Status", "ntp.ctrl.peer_status.reach", FT_BOOLEAN, 16,
			TFS(&tfs_ctrl_peer_status_reach), NTPCTRL_PEERSTATUS_REACH_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_peer_status_b4, {
			"Peer Status broadcast association", "ntp.ctrl.peer_status.bcast", FT_BOOLEAN, 16,
			TFS(&tfs_set_notset), NTPCTRL_PEERSTATUS_BCAST_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_peer_status_selection, {
			"Peer Selection", "ntp.ctrl.peer_status.selection", FT_UINT16, BASE_DEC,
			VALS(ctrl_peer_status_selection_types), NTPCTRL_PEERSTATUS_SEL_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_peer_status_count, {
			"Peer Event Counter", "ntp.ctrl.peer_status.count", FT_UINT16, BASE_DEC,
			NULL, NTPCTRL_PEERSTATUS_COUNT_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_peer_status_code, {
			"Peer Event Code", "ntp.ctrl.peer_status.code", FT_UINT16, BASE_DEC,
			VALS(ctrl_peer_status_event_types), NTPCTRL_PEERSTATUS_CODE_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_clk_status, {
			"Clock Status", "ntp.ctrl.clock_status.status", FT_UINT16, BASE_DEC,
			VALS(ctrl_clk_status_types), NTPCTRL_CLKSTATUS_STATUS_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_clk_status_code, {
			"Clock Event Code", "ntp.ctrl.clock_status.code", FT_UINT16, BASE_DEC,
			NULL, NTPCTRL_CLKSTATUS_CODE_MASK, NULL, HFILL }},
		{ &hf_ntpctrl_data, {
			"Data", "ntp.ctrl.data", FT_NONE, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntpctrl_item, {
			"Item", "ntp.ctrl.item", FT_NONE, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntpctrl_associd, {
			"AssociationID", "ntp.ctrl.associd", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntpctrl_offset, {
			"Offset", "ntp.ctrl.offset", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntpctrl_count, {
			"Count", "ntp.ctrl.count", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntpctrl_trapmsg, {
			"Trap message", "ntp.ctrl.trapmsg", FT_STRING, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntpctrl_configuration, {
			"Configuration", "ntp.ctrl.configuration", FT_STRING, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntpctrl_mru, {
			"MRU", "ntp.ctrl.mru", FT_STRING, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntpctrl_ordlist, {
			"Ordered List", "ntp.ctrl.ordlist", FT_STRING, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntpctrl_nonce, {
			"Nonce", "ntp.ctrl.nonce", FT_STRING, BASE_NONE,
			NULL, 0, NULL, HFILL }},

		{ &hf_ntppriv_flags_r, {
			"Response bit", "ntp.priv.flags.r", FT_BOOLEAN, 8,
			TFS(&tfs_response_request), NTPPRIV_R_MASK, NULL, HFILL }},
		{ &hf_ntppriv_flags_more, {
			"More bit", "ntp.priv.flags.more", FT_UINT8, BASE_DEC,
			NULL, NTPPRIV_MORE_MASK, NULL, HFILL }},
		{ &hf_ntppriv_auth_seq, {
			"Auth, sequence", "ntp.priv.auth_seq", FT_UINT8, BASE_DEC,
			NULL, 0, "Auth bit, sequence number", HFILL }},
		{ &hf_ntppriv_auth, {
			"Auth bit", "ntp.priv.auth", FT_UINT8, BASE_DEC,
			NULL, NTPPRIV_AUTH_MASK, NULL, HFILL }},
		{ &hf_ntppriv_seq, {
			"Sequence number", "ntp.priv.seq", FT_UINT8, BASE_DEC,
			NULL, NTPPRIV_SEQ_MASK, NULL, HFILL }},
		{ &hf_ntppriv_impl, {
			"Implementation", "ntp.priv.impl", FT_UINT8, BASE_DEC,
			VALS(priv_impl_types), 0, NULL, HFILL }},
		{ &hf_ntppriv_reqcode, {
			"Request code", "ntp.priv.reqcode", FT_UINT8, BASE_DEC | BASE_EXT_STRING,
			&priv_rc_types_ext, 0, NULL, HFILL }},
		{ &hf_ntppriv_errcode, {
			"Err", "ntp.priv.err", FT_UINT8, BASE_HEX,
			VALS(err_values_types), 0, NULL, HFILL }},
		{ &hf_ntppriv_numitems, {
			"Number of data items", "ntp.priv.numitems", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mbz, {
			"Reserved", "ntp.priv.reserved", FT_UINT8, BASE_HEX,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_item, {
			"Mode7 item", "ntp.priv.mode7.item",
			FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL }},
		{ &hf_ntppriv_itemsize, {
			"Size of data item", "ntp.priv.itemsize", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_avgint, {
			"avgint", "ntp.priv.monlist.avgint", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_lsint, {
			"lsint", "ntp.priv.monlist.lsint", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_restr, {
			"restr", "ntp.priv.monlist.restr", FT_UINT32, BASE_HEX,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_count, {
			"count", "ntp.priv.monlist.count", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_addr, {
			"remote address", "ntp.priv.monlist.remote_address", FT_IPv4, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_daddr, {
			"local address", "ntp.priv.monlist.local_address", FT_IPv4, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_flags, {
			"flags", "ntp.priv.monlist.flags", FT_UINT32, BASE_HEX,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_port, {
			"port", "ntp.priv.monlist.port", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode, {
			"mode", "ntp.priv.monlist.mode", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_version, {
			"version", "ntp.priv.monlist.version", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_v6_flag, {
			"ipv6", "ntp.priv.monlist.ipv6", FT_UINT32, BASE_HEX,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_unused, {
			"unused", "ntp.priv.monlist.unused", FT_UINT32, BASE_HEX,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_addr6, {
			"ipv6 remote addr", "ntp.priv.monlist.addr6", FT_IPv6, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_daddr6, {
			"ipv6 local addr", "ntp.priv.monlist.daddr6", FT_IPv6, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_tstamp, {
			"Authentication timestamp", "ntp.priv.tstamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_addr, {
			"Address", "ntp.priv.mode7.address", FT_IPv4, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_mask, {
			"Mask", "ntp.priv.mode7.mask", FT_IPv4, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_bcast, {
			"Bcast", "ntp.priv.mode7.bcast", FT_IPv4, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_port, {
			"Port", "ntp.priv.mode7.port", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_hmode, {
			"HMode", "ntp.priv.mode7.hmode", FT_UINT8, BASE_DEC,
			VALS(mode_types), 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_peer_flags, {
			"Flags", "ntp.priv.mode7.peer.flags", FT_UINT8, BASE_HEX,
			NULL, 0xFF, NULL, HFILL }},
		{ &hf_ntppriv_mode7_v6_flag, {
			"IPv6 Flag", "ntp.priv.mode7.ipv6_flag", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_unused, {
			"Unused", "ntp.priv.mode7.unused", FT_BYTES, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_addr6, {
			"IPv6 addr", "ntp.priv.mode7.address6", FT_IPv6, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_mask6, {
			"IPv6 mask", "ntp.priv.mode7.mask6", FT_IPv6, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_bcast6, {
			"IPv6 bcast", "ntp.priv.mode7.bcast6", FT_IPv6, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_peer_flags_config, {
			"Config", "ntp.priv.mode7.peer.flags.config", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_INFO_FLAG_CONFIG, NULL, HFILL }},
		{ &hf_ntppriv_mode7_peer_flags_syspeer, {
			"Syspeer", "ntp.priv.mode7.peer.flags.syspeer", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_INFO_FLAG_SYSPEER, NULL, HFILL }},
		{ &hf_ntppriv_mode7_peer_flags_burst, {
			"Burst", "ntp.priv.mode7.peer.flags.burst", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_INFO_FLAG_BURST, NULL, HFILL }},
		{ &hf_ntppriv_mode7_peer_flags_refclock, {
			"Refclock", "ntp.priv.mode7.peer.flags.refclock", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_INFO_FLAG_REFCLOCK, NULL, HFILL }},
		{ &hf_ntppriv_mode7_peer_flags_prefer, {
			"Prefer", "ntp.priv.mode7.peer.flags.prefer", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_INFO_FLAG_PREFER, NULL, HFILL }},
		{ &hf_ntppriv_mode7_peer_flags_authenable, {
			"Auth enable", "ntp.priv.mode7.peer.flags.authenable", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_INFO_FLAG_AUTHENABLE, NULL, HFILL }},
		{ &hf_ntppriv_mode7_peer_flags_sel_candidate, {
			"Sel Candidate", "ntp.priv.mode7.peer.flags.sel_candidate", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_INFO_FLAG_SEL_CANDIDATE, NULL, HFILL }},
		{ &hf_ntppriv_mode7_peer_flags_shortlist, {
			"Shortlist", "ntp.priv.mode7.peer.flags.shortlist", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_INFO_FLAG_SHORTLIST, NULL, HFILL }},
		{ &hf_ntppriv_mode7_dstaddr, {
			"Destination address", "ntp.priv.mode7.dstaddress", FT_IPv4, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_srcaddr, {
			"Source address", "ntp.priv.mode7.srcaddress", FT_IPv4, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_srcport, {
			"Source port", "ntp.priv.mode7.srcport", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_count, {
			"Count", "ntp.priv.mode7.count", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_hpoll, {
			"Host polling interval", "ntp.priv.mode7.hpoll", FT_INT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_reach, {
			"Reach", "ntp.priv.mode7.reach", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_delay, {
			"Delay", "ntp.priv.mode7.delay", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_offset, {
			"Offset", "ntp.priv.mode7.offset", FT_UINT64, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_dispersion, {
			"Dispersion", "ntp.priv.mode7.dispersion", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_dstaddr6, {
			"IPv6 destination addr", "ntp.priv.mode7.dstaddress6", FT_IPv6, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_srcaddr6, {
			"IPv6 source addr", "ntp.priv.mode7.srcaddress6", FT_IPv6, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_leap, {
			"Leap", "ntp.priv.mode7.leap", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_pmode, {
			"Peer mode", "ntp.priv.mode7.pmode", FT_UINT8, BASE_DEC,
			VALS(mode_types), 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_version, {
			"Version", "ntp.priv.mode7.version", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_unreach, {
			"Unreach", "ntp.priv.mode7.unreach", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_flash, {
			"Flash", "ntp.priv.mode7.flash", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_ttl, {
			"TTL", "ntp.priv.mode7.ttl", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_flash2, {
			"Flash new", "ntp.priv.mode7.flash2", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_associd, {
			"Association ID", "ntp.priv.mode7.associd", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_pkeyid, {
			"Peer Key ID", "ntp.priv.mode7.pkeyid", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_timer, {
			"Timer", "ntp.priv.mode7.timer", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_filtdelay, {
			"Filt delay", "ntp.priv.mode7.filtdelay", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_filtoffset, {
			"Filt offset", "ntp.priv.mode7.filtoffset", FT_INT64, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_order, {
			"Order", "ntp.priv.mode7.order", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_selectdis, {
			"Selectdis", "ntp.priv.mode7.selectdis", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_estbdelay, {
			"Estbdelay", "ntp.priv.mode7.estbdelay", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_bdelay, {
			"Bdelay", "ntp.priv.mode7.bdelay", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_authdelay, {
			"Auth delay", "ntp.priv.mode7.authdelay", FT_INT64, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_minpoll, {
			"Minpoll", "ntp.priv.mode7.minpoll", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_maxpoll, {
			"Maxpoll", "ntp.priv.mode7.maxpoll", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_config_flags, {
			"Flags", "ntp.priv.config.flags", FT_UINT8, BASE_HEX,
			NULL, 0xFF, NULL, HFILL }},
		{ &hf_ntppriv_mode7_config_flags_auth, {
			"Authenable", "ntp.priv.mode7.config.flags.authenable", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_CONF_FLAG_AUTHENABLE, NULL, HFILL }},
		{ &hf_ntppriv_mode7_config_flags_prefer, {
			"Prefer", "ntp.priv.mode7.config.flags.prefer", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_CONF_FLAG_PREFER, NULL, HFILL }},
		{ &hf_ntppriv_mode7_config_flags_burst, {
			"Burst", "ntp.priv.mode7.config.flags.burst", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_CONF_FLAG_BURST, NULL, HFILL }},
		{ &hf_ntppriv_mode7_config_flags_iburst, {
			"IBurst", "ntp.priv.mode7.config.flags.iburst", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_CONF_FLAG_IBURST, NULL, HFILL }},
		{ &hf_ntppriv_mode7_config_flags_noselect, {
			"No Select", "ntp.priv.mode7.config.flags.no_select", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_CONF_FLAG_NOSELECT, NULL, HFILL }},
		{ &hf_ntppriv_mode7_config_flags_skey, {
			"Skey", "ntp.priv.mode7.config.flags.skey", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_CONF_FLAG_SKEY, NULL, HFILL }},
		{ &hf_ntppriv_mode7_key_file, {
			"Key file name", "ntp.priv.mode7.key_file", FT_STRING, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_sys_flags, {
			"Flags", "ntp.priv.mode7.sys.flags", FT_UINT32, BASE_HEX,
			NULL, 0xFF, NULL, HFILL }},
		{ &hf_ntppriv_mode7_sys_flags_bclient, {
			"Bclient", "ntp.priv.mode7.sys.flags.bclient", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_SYS_FLAG_BCLIENT, NULL, HFILL }},
		{ &hf_ntppriv_mode7_sys_flags_pps, {
			"PPS", "ntp.priv.mode7.sys.flags.pps", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_SYS_FLAG_PPS, NULL, HFILL }},
		{ &hf_ntppriv_mode7_sys_flags_ntp, {
			"NTP", "ntp.priv.mode7.sys.flags.ntp", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_SYS_FLAG_NTP, NULL, HFILL }},
		{ &hf_ntppriv_mode7_sys_flags_kernel, {
			"Kernel", "ntp.priv.mode7.sys.flags.kernel", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_SYS_FLAG_KERNEL, NULL, HFILL }},
		{ &hf_ntppriv_mode7_sys_flags_monitor, {
			"Monitor", "ntp.priv.mode7.sys.flags.monitor", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_SYS_FLAG_MONITOR, NULL, HFILL }},
		{ &hf_ntppriv_mode7_sys_flags_filegen, {
			"Filegen", "ntp.priv.mode7.sys.flags.filegen", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_SYS_FLAG_FILEGEN, NULL, HFILL }},
		{ &hf_ntppriv_mode7_sys_flags_auth, {
			"Auth", "ntp.priv.mode7.sys.flags.auth", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_SYS_FLAG_AUTH, NULL, HFILL }},
		{ &hf_ntppriv_mode7_sys_flags_cal, {
			"Cal", "ntp.priv.mode7.sys.flags.cal", FT_BOOLEAN, 8,
			TFS(&tfs_set_notset), PRIV_SYS_FLAG_CAL, NULL, HFILL }},
		{ &hf_ntppriv_mode7_reset_stats_flags, {
			"Flags", "ntp.priv.mode7.reset_stats.flags", FT_UINT32, BASE_HEX,
			NULL, 0xFF, NULL, HFILL }},
		{ &hf_ntppriv_mode7_reset_stats_flags_allpeers, {
			"All Peers", "ntp.priv.mode7.reset_stats.flags.allpeers", FT_BOOLEAN, 32,
			TFS(&tfs_set_notset), PRIV_RESET_FLAG_ALLPEERS, NULL, HFILL }},
		{ &hf_ntppriv_mode7_reset_stats_flags_io, {
			"IO", "ntp.priv.mode7.reset_stats.flags.io", FT_BOOLEAN, 32,
			TFS(&tfs_set_notset), PRIV_RESET_FLAG_IO, NULL, HFILL }},
		{ &hf_ntppriv_mode7_reset_stats_flags_sys, {
			"Sys", "ntp.priv.mode7.reset_stats.flags.sys", FT_BOOLEAN, 32,
			TFS(&tfs_set_notset), PRIV_RESET_FLAG_SYS, NULL, HFILL }},
		{ &hf_ntppriv_mode7_reset_stats_flags_mem, {
			"Mem", "ntp.priv.mode7.reset_stats.flags.mem", FT_BOOLEAN, 32,
			TFS(&tfs_set_notset), PRIV_RESET_FLAG_MEM, NULL, HFILL }},
		{ &hf_ntppriv_mode7_reset_stats_flags_timer, {
			"Timer", "ntp.priv.mode7.reset_stats.flags.timer", FT_BOOLEAN, 32,
			TFS(&tfs_set_notset), PRIV_RESET_FLAG_TIMER, NULL, HFILL }},
		{ &hf_ntppriv_mode7_reset_stats_flags_auth, {
			"Auth", "ntp.priv.mode7.reset_stats.flags.auth", FT_BOOLEAN, 32,
			TFS(&tfs_set_notset), PRIV_RESET_FLAG_AUTH, NULL, HFILL }},
		{ &hf_ntppriv_mode7_reset_stats_flags_ctl, {
			"Ctl", "ntp.priv.mode7.reset_stats.flags.ctl", FT_BOOLEAN, 32,
			TFS(&tfs_set_notset), PRIV_RESET_FLAG_CTL, NULL, HFILL }},
		{ &hf_ntppriv_mode7_key, {
			"Key", "ntp.priv.mode7.key", FT_UINT64, BASE_HEX,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_timeup, {
			"Time up", "ntp.priv.mode7.timeup", FT_UINT32, BASE_DEC,
			NULL, 0, "time counters were reset", HFILL }},
		{ &hf_ntppriv_mode7_timereset, {
			"Time reset", "ntp.priv.mode7.timereset", FT_UINT32, BASE_DEC,
			NULL, 0, "time counters were reset", HFILL }},
		{ &hf_ntppriv_mode7_timereceived, {
			"Time received", "ntp.priv.mode7.timereceived", FT_UINT32, BASE_DEC,
			NULL, 0, "time since a packet received", HFILL }},
		{ &hf_ntppriv_mode7_timetosend, {
			"Time to send", "ntp.priv.mode7.timetosend", FT_UINT32, BASE_DEC,
			NULL, 0, "time until a packet sent", HFILL }},
		{ &hf_ntppriv_mode7_timereachable, {
			"Time reachable", "ntp.priv.mode7.timereachable", FT_UINT32, BASE_DEC,
			NULL, 0, "time peer has been reachable", HFILL }},
		{ &hf_ntppriv_mode7_sent, {
			"Sent", "ntp.priv.mode7.sent", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_processed, {
			"Processed", "ntp.priv.mode7.processed", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_badauth, {
			"Bad authentication", "ntp.priv.mode7.badauth", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_bogusorg, {
			"Bogus origin", "ntp.priv.mode7.bogusorg", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_oldpkt, {
			"Old packet", "ntp.priv.mode7.oldpkt", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_seldisp, {
			"Bad dispersion", "ntp.priv.mode7.seldisp", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_selbroken, {
			"Bad reference time", "ntp.priv.mode7.selbroken", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_candidate, {
			"Candidate", "ntp.priv.mode7.candidate", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_numkeys, {
			"Num keys", "ntp.priv.mode7.numkeys", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_numfreekeys, {
			"Num free keys", "ntp.priv.mode7.numfreekeys", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_keylookups, {
			"Keylookups", "ntp.priv.mode7.keylookups", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_keynotfound, {
			"Key not found", "ntp.priv.mode7.keynotfound", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_encryptions, {
			"Encryptions", "ntp.priv.mode7.encryptions", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_decryptions, {
			"Decryptions", "ntp.priv.mode7.decryptions", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_expired, {
			"Expired", "ntp.priv.mode7.expired", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_keyuncached, {
			"Key uncached", "ntp.priv.mode7.keyuncached", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_local_addr, {
			"Local address", "ntp.priv.mode7.local_address", FT_IPv4, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_trap_addr, {
			"Trap address", "ntp.priv.mode7.trap_address", FT_IPv4, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_trap_port, {
			"Trap port", "ntp.priv.mode7.trap_port", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_sequence, {
			"Sequence number", "ntp.priv.mode7.sequence", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_settime, {
			"Trap set time", "ntp.priv.mode7.settime", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_origtime, {
			"Trap originally time", "ntp.priv.mode7.origtime", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_resets, {
			"Resets", "ntp.priv.mode7.resets", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_traps_flags, {
			"Flags", "ntp.priv.traps.flags", FT_UINT32, BASE_HEX,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_local_addr6, {
			"IPv6 local addr", "ntp.priv.mode7.local_address6", FT_IPv6, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_trap_addr6, {
			"IPv6 trap addr", "ntp.priv.mode7.trap_address6", FT_IPv6, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_req, {
			"Requests", "ntp.priv.mode7.requests", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_badpkts, {
			"Bad packets", "ntp.priv.mode7.bad_packets", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_responses, {
			"Responses", "ntp.priv.mode7.responses", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_frags, {
			"Fragments", "ntp.priv.mode7.fragments", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_errors, {
			"Errors", "ntp.priv.mode7.errors", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_tooshort, {
			"Too short packets", "ntp.priv.mode7.too_short", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_inputresp, {
			"Responses on input", "ntp.priv.mode7.input_responses", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_inputfrag, {
			"Fragments on input", "ntp.priv.mode7.input_fragments", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_inputerr, {
			"Errors on input", "ntp.priv.mode7.input_errors", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_badoffset, {
			"Non zero offset packets", "ntp.priv.mode7.bad_offset", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_badversion, {
			"Unknown version packets", "ntp.priv.mode7.bad_version", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_datatooshort, {
			"Data too short", "ntp.priv.mode7.data_too_short", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_badop, {
			"Bad op code found", "ntp.priv.mode7.badop", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_asyncmsgs, {
			"Async messages", "ntp.priv.mode7.async_messages", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_type, {
			"Type", "ntp.priv.mode7.type", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_clock_flags, {
			"Clock Flags", "ntp.priv.mode7.clock_flags", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_lastevent, {
			"Last event", "ntp.priv.mode7.lastevent", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_currentstatus, {
			"Current status", "ntp.priv.mode7.currentstatus", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_polls, {
			"Polls", "ntp.priv.mode7.polls", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_noresponse, {
			"Noresponse", "ntp.priv.mode7.noresponse", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_badformat, {
			"Bad format", "ntp.priv.mode7.badformat", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_baddata, {
			"Bad data", "ntp.priv.mode7.baddata", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_timestarted, {
			"Time started", "ntp.priv.mode7.timestarted", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_fudgetime1, {
			"Fudge time 1", "ntp.priv.mode7.fudgetime1", FT_UINT64, BASE_HEX,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_fudgetime2, {
			"Fudge time 2", "ntp.priv.mode7.fudgetime2", FT_UINT64, BASE_HEX,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_fudgeval1, {
			"Fudge val 1", "ntp.priv.mode7.fudgeval1", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_fudgeval2, {
			"Fudge val 2", "ntp.priv.mode7.fudgeval2", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_kernel_offset, {
			"Offset", "ntp.priv.mode7.kernel_offset", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_freq, {
			"Freq", "ntp.priv.mode7.freq", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_stability, {
			"Stability (ppm)", "ntp.priv.mode7.stability", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_maxerror, {
			"Max error", "ntp.priv.mode7.maxerror", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_esterror, {
			"Est error", "ntp.priv.mode7.esterror", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_status, {
			"Status", "ntp.priv.mode7.status", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_shift, {
			"Shift", "ntp.priv.mode7.shift", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_constant, {
			"Constant", "ntp.priv.mode7.constant", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_precision, {
			"Precision", "ntp.priv.mode7.precision", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_tolerance, {
			"tolerance", "ntp.priv.mode7.tolerance", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_ppsfreq, {
			"ppsfreq", "ntp.priv.mode7.ppsfreq", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_jitter, {
			"jitter", "ntp.priv.mode7.jitter", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_stabil, {
			"stabil", "ntp.priv.mode7.stabil", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_jitcnt, {
			"jitcnt", "ntp.priv.mode7.jitcnt", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_calcnt, {
			"calcnt", "ntp.priv.mode7.calcnt", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_errcnt, {
			"errcnt", "ntp.priv.mode7.errcnt", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_stbcnt, {
			"stbcnt", "ntp.priv.mode7.stbcnt", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_last_offset, {
			"Last offset", "ntp.priv.mode7.last_offset", FT_INT64, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_drift_comp, {
			"Drift comp", "ntp.priv.mode7.drift_comp", FT_INT64, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_compliance, {
			"Compliance", "ntp.priv.mode7.compliance", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_watchdog_timer, {
			"Watchdog timer", "ntp.priv.mode7.watchdog_timer", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_poll32, {
			"Poll", "ntp.priv.mode7.poll", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_sys_flags8, {
			"Flags", "ntp.priv.mode7.sys.flags8", FT_UINT8, BASE_HEX,
			NULL, 0xFF, NULL, HFILL }},
		{ &hf_ntppriv_mode7_denied, {
			"Denied", "ntp.priv.mode7.denied", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_oldversion, {
			"Old version", "ntp.priv.mode7.oldversion", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_newversion, {
			"New version", "ntp.priv.mode7.newversion", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_badlength, {
			"Bad length", "ntp.priv.mode7.badlength", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_limitrejected, {
			"Limit rejected", "ntp.priv.mode7.limitrejected", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_lamport, {
			"Lamport violation", "ntp.priv.mode7.lamport", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_tsrounding, {
			"Timestamp rounding error", "ntp.priv.mode7.tsrounding", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_totalmem, {
			"Total memory", "ntp.priv.mode7.totalmem", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_freemem, {
			"Free memory", "ntp.priv.mode7.freemem", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_findpeer_calls, {
			"Find peer calls", "ntp.priv.mode7.findpeer_calls", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_allocations, {
			"Allocations", "ntp.priv.mode7.allocations", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_demobilizations, {
			"Demobilizations", "ntp.priv.mode7.demobilizations", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_hashcount, {
			"Hashcount", "ntp.priv.mode7.hashcount", FT_BYTES, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_totalrecvbufs, {
			"Toal receive buffer", "ntp.priv.mode7.totalrecvbufs", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_freerecvbufs, {
			"Free receive buffer", "ntp.priv.mode7.freerecvbufs", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_fullrecvbufs, {
			"Full receive buffer", "ntp.priv.mode7.fullrecvbufs", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_lowwater, {
			"Low water", "ntp.priv.mode7.lowwater", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_dropped, {
			"Dropped packets", "ntp.priv.mode7.dropped", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_ignored, {
			"Ignored packets", "ntp.priv.mode7.ignored", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_received, {
			"Received packets", "ntp.priv.mode7.received", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_notsent, {
			"Not sent packets", "ntp.priv.mode7.notsent", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_interrupts, {
			"Interrupts", "ntp.priv.mode7.interrupts", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_int_received, {
			"Received by interrupt handler", "ntp.priv.mode7.int_received", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_alarms, {
			"Alarms", "ntp.priv.mode7.alarms", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_overflows, {
			"Overflows", "ntp.priv.mode7.overflows", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_xmtcalls, {
			"Transmitted calls", "ntp.priv.mode7.xmtcalls", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_rflags, {
			"Rflags", "ntp.priv.mode7.rflags", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_mflags, {
			"Mflags", "ntp.priv.mode7.mflags", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_int_name, {
			"Interface name", "ntp.priv.mode7.int_name", FT_STRING, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_int_flags, {
			"Interface flags", "ntp.priv.mode7.int_flags", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_last_ttl, {
			"Last TTL specified", "ntp.priv.mode7.last_ttl", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_num_mcast, {
			"Numer multicast sockets", "ntp.priv.mode7.num_mcast", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_uptime, {
			"Uptime", "ntp.priv.mode7.uptime", FT_INT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_scopeid, {
			"Scopeid", "ntp.priv.mode7.scopeid", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_ifindex, {
			"Ifindex", "ntp.priv.mode7.ifindex", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_ifnum, {
			"Ifnum", "ntp.priv.mode7.ifnum", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_peercnt, {
			"Peer count", "ntp.priv.mode7.peercnt", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_family, {
			"Address family", "ntp.priv.mode7.family", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_ignore_pkt, {
			"Ignore packets", "ntp.priv.mode7.ignore_pkts", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_action, {
			"Action", "ntp.priv.mode7.action", FT_UINT8, BASE_DEC,
			VALS(priv_mode7_int_action), 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_nvalues, {
			"Nvalues", "ntp.priv.mode7.nvalues", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_ntimes, {
			"Ntimes", "ntp.priv.mode7.ntimes", FT_UINT8, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_svalues, {
			"Svalues", "ntp.priv.mode7.svalues", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_stimes, {
			"Stimes", "ntp.priv.mode7.stimes", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_values, {
			"Values", "ntp.priv.mode7.values", FT_BYTES, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_times, {
			"Times", "ntp.priv.mode7.times", FT_BYTES, BASE_NONE,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_which, {
			"Which", "ntp.priv.mode7.which", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_fudgetime, {
			"Fudgetime", "ntp.priv.mode7.fudgetime", FT_UINT64, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_fudgeval_flags, {
			"Fudgeval flags", "ntp.priv.mode7.fudgeval_flags", FT_UINT32, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_ippeerlimit, {
			"IP peer limit", "ntp.priv.mode7.ippeerlimit", FT_INT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		{ &hf_ntppriv_mode7_restrict_flags, {
			"Restrict flags", "ntp.priv.mode7.restrict_flags", FT_UINT16, BASE_DEC,
			NULL, 0, NULL, HFILL }},
		/* Todo */
	};

	static gint *ett[] = {
		&ett_ntp,
		&ett_ntp_flags,
		&ett_ntp_ext,
		&ett_ntp_ext_flags,
		&ett_ntpctrl_flags2,
		&ett_ntpctrl_status,
		&ett_ntpctrl_data,
		&ett_ntpctrl_item,
		&ett_ntppriv_auth_seq,
		&ett_mode7_item,
		&ett_ntppriv_peer_list_flags,
		&ett_ntppriv_config_flags,
		&ett_ntppriv_sys_flag_flags,
		&ett_ntppriv_reset_stats_flags,
		&ett_ntp_authenticator
	};

	static ei_register_info ei[] = {
		{ &ei_ntp_ext, { "ntp.ext.invalid_length", PI_PROTOCOL, PI_WARN, "Extension invalid length", EXPFILL }},
	};

	expert_module_t* expert_ntp;

	proto_ntp = proto_register_protocol("Network Time Protocol", "NTP", "ntp");
	proto_register_field_array(proto_ntp, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));
	expert_ntp = expert_register_protocol(proto_ntp);
	expert_register_field_array(expert_ntp, ei, array_length(ei));

	ntp_handle = register_dissector("ntp", dissect_ntp, proto_ntp);

	init_parser();
}

void
proto_reg_handoff_ntp(void)
{
	dissector_add_uint_with_preference("udp.port", UDP_PORT_NTP, ntp_handle);
	dissector_add_uint_with_preference("tcp.port", TCP_PORT_NTP, ntp_handle);
}

/*
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 8
 * tab-width: 8
 * indent-tabs-mode: t
 * End:
 *
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
 * :indentSize=8:tabSize=8:noTabs=false:
 */