summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-zebra.c
blob: 2ab039769a0466aaf0f37ff252485b287211e607 (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
/* packet-zebra.c
 * Routines for zebra packet disassembly
 *
 * Jochen Friedrich <jochen@scram.de>
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

/*
 * The Zebra Protocol is the protocol used between the Zebra routing daemon and
 * other protocol daemons (ones for BGP, OSPF, etc.) within the Zebra, Quagga,
 * and FRRouting open-source routing suites.
 * Zebra itself (https://www.gnu.org/software/zebra) is discontinued,
 * and its successor is Quagga (http://www.nongnu.org/quagga).
 * The successor to Quagga is FRRouting (https://frrouting.org/).
 *
 * All three use the "Zebra Protocol" (or ZAPI), but starting with Quagga v0.99
 * there are different versions, with different header formats and more
 * commands/types.
 *
 * http://www.nongnu.org/quagga/docs/docs-info.html#Zebra-Protocol
 * http://docs.frrouting.org/projects/dev-guide/en/latest/zebra.html
 *
 * Version 0 (implicit): Zebra, Quagga up to version 0.98
 * Version 1: Quagga 0.99.3 through 0.99.20
 * Version 2: Quagga 0.99.21 though 0.99.23
 * Version 3: Quagga 0.99.24 and later
 * Version 4: FRRouting 2.0 through 3.0.3
 * Version 5: FRRouting 4.0 though 5.0.1
 * Version 6: FRRouting 6.0 and later
 *
 * FRRouting versions 4 and 5 have partially incompatible commands.
 * This dissector uses the commands of FRRRouting version 5.
 * FRRouting versions 6 and 7 have partially incompatible commands.
 * This dissector uses the commands of FRRRouting version 7.
 */

#include "config.h"


#include <epan/packet.h>

/*  Function declarations */
void proto_reg_handoff_zebra(void);
void proto_register_zebra(void);

static dissector_handle_t zebra_handle;

static int proto_zebra = -1;
static int hf_zebra_len = -1;
static int hf_zebra_command = -1;
static int hf_zebra_request = -1;
static int hf_zebra_interface = -1;
static int hf_zebra_index = -1;
static int hf_zebra_indexnum = -1;
static int hf_zebra_type_v0 = -1;
static int hf_zebra_type_v1 = -1;
static int hf_zebra_intflags = -1;
static int hf_zebra_rtflags = -1;
static int hf_zebra_distance = -1;
static int hf_zebra_metric = -1;
static int hf_zebra_mtu = -1;
static int hf_zebra_mtu6 = -1;
static int hf_zebra_bandwidth = -1;
static int hf_zebra_family = -1;
static int hf_zebra_flags = -1;
static int hf_zebra_message = -1;
static int hf_zebra_route_safi = -1;
static int hf_zebra_msg_nexthop = -1;
static int hf_zebra_msg_index = -1;
static int hf_zebra_msg_distance = -1;
static int hf_zebra_msg_metric = -1;
static int hf_zebra_nexthopnum = -1;
static int hf_zebra_nexthop4 = -1;
static int hf_zebra_nexthop6 = -1;
static int hf_zebra_dest4 = -1;
static int hf_zebra_dest6 = -1;
static int hf_zebra_prefixlen = -1;
static int hf_zebra_prefix4 = -1;
static int hf_zebra_prefix6 = -1;
static int hf_zebra_version = -1;
static int hf_zebra_marker = -1;
static int hf_zebra_intstatus = -1;
static int hf_zebra_routeridaddress = -1;
static int hf_zebra_routeridmask = -1;
static int hf_zebra_mac = -1;
static int hf_zebra_redist_default = -1;
static int hf_zebra_vrfid = -1;
static int hf_zebra_routeridfamily = -1;
static int hf_zebra_nexthoptype = -1;
static int hf_zebra_msg_mtu = -1;
static int hf_zebra_msg_tag = -1;
static int hf_zebra_tag = -1;
static int hf_zebra_maclen = -1;
static int hf_zebra_haslinkparam = -1;
/* FRRouting, Zebra API v4, v5 and v6 */
static int hf_zebra_command_v4 = -1;
static int hf_zebra_command_v5 = -1;
static int hf_zebra_command_v6 = -1;
static int hf_zebra_type_v4 = -1;
static int hf_zebra_type_v5 = -1;
static int hf_zebra_ptmenable = -1;
static int hf_zebra_ptmstatus = -1;
static int hf_zebra_instance = -1;
static int hf_zebra_rtflags_u32 = -1;
static int hf_zebra_speed = -1;
static int hf_zebra_lltype = -1;
static int hf_zebra_message4 = -1;
static int hf_zebra_message5 = -1;
static int hf_zebra_route_safi_u8 = -1;
static int hf_zebra_rmac = -1;
static int hf_zebra_msg4_tag = -1;
static int hf_zebra_msg4_mtu = -1;
static int hf_zebra_msg4_srcpfx = -1;
static int hf_zebra_msg5_distance = -1;
static int hf_zebra_msg5_metric = -1;
static int hf_zebra_msg5_tag = -1;
static int hf_zebra_msg5_mtu = -1;
static int hf_zebra_msg5_srcpfx = -1;
static int hf_zebra_msg_label = -1;
static int hf_zebra_msg_tableid = -1;
static int hf_zebra_nexthopnum_u16 = -1;
static int hf_zebra_nexthoptype_frr = -1;
static int hf_zebra_bhtype = -1;
static int hf_zebra_srcprefixlen = -1;
static int hf_zebra_srcprefix4 = -1;
static int hf_zebra_srcprefix6 = -1;
static int hf_zebra_tableid = -1;
static int hf_zebra_afi = -1;
static int hf_zebra_pid = -1;
static int hf_zebra_vrf_table_id = -1;
static int hf_zebra_vrf_netns_name = -1;
static int hf_zebra_vrf_name = -1;
static int hf_zebra_proto = -1;
static int hf_zebra_label_chunk_keep = -1;
static int hf_zebra_label_chunk_size = -1;
static int hf_zebra_label_chunk_start = -1;
static int hf_zebra_label_chunk_end = -1;
static int hf_zebra_mpls_enabled = -1;
static int hf_zebra_multipath_num = -1;
static int hf_zebra_labelnum = -1;
static int hf_zebra_label = -1;
static int hf_zebra_receive_notify = -1;

static gint ett_zebra = -1;
static gint ett_zebra_request = -1;
static gint ett_message = -1;

#define TCP_PORT_ZEBRA			2600 /* Not IANA registered */

/* Zebra message types. */
#define ZEBRA_INTERFACE_ADD                1
#define ZEBRA_INTERFACE_DELETE             2
#define ZEBRA_INTERFACE_ADDRESS_ADD        3
#define ZEBRA_INTERFACE_ADDRESS_DELETE     4
#define ZEBRA_INTERFACE_UP                 5
#define ZEBRA_INTERFACE_DOWN               6
#define ZEBRA_IPV4_ROUTE_ADD               7
#define ZEBRA_IPV4_ROUTE_DELETE            8
#define ZEBRA_IPV6_ROUTE_ADD               9
#define ZEBRA_IPV6_ROUTE_DELETE           10
#define ZEBRA_REDISTRIBUTE_ADD            11
#define ZEBRA_REDISTRIBUTE_DELETE         12
#define ZEBRA_REDISTRIBUTE_DEFAULT_ADD    13
#define ZEBRA_REDISTRIBUTE_DEFAULT_DELETE 14
#define ZEBRA_IPV4_NEXTHOP_LOOKUP         15
#define ZEBRA_IPV6_NEXTHOP_LOOKUP         16
#define ZEBRA_IPV4_IMPORT_LOOKUP          17
#define ZEBRA_IPV6_IMPORT_LOOKUP          18
#define ZEBRA_INTERFACE_RENAME            19
#define ZEBRA_ROUTER_ID_ADD               20
#define ZEBRA_ROUTER_ID_DELETE            21
#define ZEBRA_ROUTER_ID_UPDATE            22
#define ZEBRA_HELLO                       23
#define ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB    24
#define ZEBRA_VRF_UNREGISTER              25
#define ZEBRA_INTERFACE_LINK_PARAMS       26
#define ZEBRA_NEXTHOP_REGISTER            27
#define ZEBRA_NEXTHOP_UNREGISTER          28
#define ZEBRA_NEXTHOP_UPDATE              29
#define ZEBRA_MESSAGE_MAX                 30


static const value_string messages[] = {
	{ ZEBRA_INTERFACE_ADD,			"Add Interface" },
	{ ZEBRA_INTERFACE_DELETE,		"Delete Interface" },
	{ ZEBRA_INTERFACE_ADDRESS_ADD,		"Add Interface Address" },
	{ ZEBRA_INTERFACE_ADDRESS_DELETE,	"Delete Interface Address" },
	{ ZEBRA_INTERFACE_UP,			"Interface Up" },
	{ ZEBRA_INTERFACE_DOWN,			"Interface Down" },
	{ ZEBRA_IPV4_ROUTE_ADD,			"Add IPv4 Route" },
	{ ZEBRA_IPV4_ROUTE_DELETE,		"Delete IPv4 Route" },
	{ ZEBRA_IPV6_ROUTE_ADD,			"Add IPv6 Route" },
	{ ZEBRA_IPV6_ROUTE_DELETE,		"Delete IPv6 Route" },
	{ ZEBRA_REDISTRIBUTE_ADD,		"Add Redistribute" },
	{ ZEBRA_REDISTRIBUTE_DELETE,		"Delete Redistribute" },
	{ ZEBRA_REDISTRIBUTE_DEFAULT_ADD,	"Add Default Redistribute" },
	{ ZEBRA_REDISTRIBUTE_DEFAULT_DELETE,	"Delete Default Redistribute" },
	{ ZEBRA_IPV4_NEXTHOP_LOOKUP,		"IPv4 Nexthop Lookup" },
	{ ZEBRA_IPV6_NEXTHOP_LOOKUP,		"IPv6 Nexthop Lookup" },
	{ ZEBRA_IPV4_IMPORT_LOOKUP,		"IPv4 Import Lookup" },
	{ ZEBRA_IPV6_IMPORT_LOOKUP,		"IPv6 Import Lookup" },
	{ ZEBRA_INTERFACE_RENAME,		"Rename Interface" },
	{ ZEBRA_ROUTER_ID_ADD,			"Router ID Add" },
	{ ZEBRA_ROUTER_ID_DELETE,		"Router ID Delete" },
	{ ZEBRA_ROUTER_ID_UPDATE,		"Router ID Update" },
	{ ZEBRA_HELLO,				"Hello" },
	{ ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB,	"IPv4 Nexthop Lookup Multicast RIB" },
	{ ZEBRA_VRF_UNREGISTER,			"VRF Unregister" },
	{ ZEBRA_INTERFACE_LINK_PARAMS,		"Interface Link Parameters" },
	{ ZEBRA_NEXTHOP_REGISTER,		"Nexthop Register" },
	{ ZEBRA_NEXTHOP_UNREGISTER,		"Nexthop Unregister" },
	{ ZEBRA_NEXTHOP_UPDATE,			"Nexthop Update" },
	{ 0,					NULL },
};

/* FRRouting ZAPI v4 message types. */
enum {
	FRR_ZAPI4_INTERFACE_ADD,
	FRR_ZAPI4_INTERFACE_DELETE,
	FRR_ZAPI4_INTERFACE_ADDRESS_ADD,
	FRR_ZAPI4_INTERFACE_ADDRESS_DELETE,
	FRR_ZAPI4_INTERFACE_UP,
	FRR_ZAPI4_INTERFACE_DOWN,
	FRR_ZAPI4_IPV4_ROUTE_ADD,
	FRR_ZAPI4_IPV4_ROUTE_DELETE,
	FRR_ZAPI4_IPV6_ROUTE_ADD,
	FRR_ZAPI4_IPV6_ROUTE_DELETE,
	FRR_ZAPI4_REDISTRIBUTE_ADD,
	FRR_ZAPI4_REDISTRIBUTE_DELETE,
	FRR_ZAPI4_REDISTRIBUTE_DEFAULT_ADD,
	FRR_ZAPI4_REDISTRIBUTE_DEFAULT_DELETE,
	FRR_ZAPI4_ROUTER_ID_ADD,
	FRR_ZAPI4_ROUTER_ID_DELETE,
	FRR_ZAPI4_ROUTER_ID_UPDATE,
	FRR_ZAPI4_HELLO,
	FRR_ZAPI4_NEXTHOP_REGISTER,
	FRR_ZAPI4_NEXTHOP_UNREGISTER,
	FRR_ZAPI4_NEXTHOP_UPDATE,
	FRR_ZAPI4_INTERFACE_NBR_ADDRESS_ADD,
	FRR_ZAPI4_INTERFACE_NBR_ADDRESS_DELETE,
	FRR_ZAPI4_INTERFACE_BFD_DEST_UPDATE,
	FRR_ZAPI4_IMPORT_ROUTE_REGISTER,
	FRR_ZAPI4_IMPORT_ROUTE_UNREGISTER,
	FRR_ZAPI4_IMPORT_CHECK_UPDATE,
	FRR_ZAPI4_IPV4_ROUTE_IPV6_NEXTHOP_ADD,
	FRR_ZAPI4_BFD_DEST_REGISTER,
	FRR_ZAPI4_BFD_DEST_DEREGISTER,
	FRR_ZAPI4_BFD_DEST_UPDATE,
	FRR_ZAPI4_BFD_DEST_REPLAY,
	FRR_ZAPI4_REDISTRIBUTE_IPV4_ADD,
	FRR_ZAPI4_REDISTRIBUTE_IPV4_DEL,
	FRR_ZAPI4_REDISTRIBUTE_IPV6_ADD,
	FRR_ZAPI4_REDISTRIBUTE_IPV6_DEL,
	FRR_ZAPI4_VRF_UNREGISTER,
	FRR_ZAPI4_VRF_ADD,
	FRR_ZAPI4_VRF_DELETE,
	FRR_ZAPI4_INTERFACE_VRF_UPDATE,
	FRR_ZAPI4_BFD_CLIENT_REGISTER,
	FRR_ZAPI4_INTERFACE_ENABLE_RADV,
	FRR_ZAPI4_INTERFACE_DISABLE_RADV,
	FRR_ZAPI4_IPV4_NEXTHOP_LOOKUP_MRIB,
	FRR_ZAPI4_INTERFACE_LINK_PARAMS,
	FRR_ZAPI4_MPLS_LABELS_ADD,
	FRR_ZAPI4_MPLS_LABELS_DELETE,
	FRR_ZAPI4_IPV4_NEXTHOP_ADD,
	FRR_ZAPI4_IPV4_NEXTHOP_DELETE,
	FRR_ZAPI4_IPV6_NEXTHOP_ADD,
	FRR_ZAPI4_IPV6_NEXTHOP_DELETE,
	FRR_ZAPI4_IPMR_ROUTE_STATS,
	FRR_ZAPI4_LABEL_MANAGER_CONNECT,
	FRR_ZAPI4_GET_LABEL_CHUNK,
	FRR_ZAPI4_RELEASE_LABEL_CHUNK,
	FRR_ZAPI4_PW_ADD,
	FRR_ZAPI4_PW_DELETE,
	FRR_ZAPI4_PW_SET,
	FRR_ZAPI4_PW_UNSET,
	FRR_ZAPI4_PW_STATUS_UPDATE,
};

static const value_string frr_zapi4_messages[] = {
	{ FRR_ZAPI4_INTERFACE_ADD,		"Add Interface" },
	{ FRR_ZAPI4_INTERFACE_DELETE,		"Delete Interface" },
	{ FRR_ZAPI4_INTERFACE_ADDRESS_ADD,	"Add Interface Address" },
	{ FRR_ZAPI4_INTERFACE_ADDRESS_DELETE,	"Delete Interface Address" },
	{ FRR_ZAPI4_INTERFACE_UP,		"Interface Up" },
	{ FRR_ZAPI4_INTERFACE_DOWN,		"Interface Down" },
	{ FRR_ZAPI4_IPV4_ROUTE_ADD,		"Add IPv4 Route" },
	{ FRR_ZAPI4_IPV4_ROUTE_DELETE,		"Delete IPv4 Route" },
	{ FRR_ZAPI4_IPV6_ROUTE_ADD,		"Add IPv6 Route" },
	{ FRR_ZAPI4_IPV6_ROUTE_DELETE,		"Delete IPv6 Route" },
	{ FRR_ZAPI4_REDISTRIBUTE_ADD,		"Add Redistribute" },
	{ FRR_ZAPI4_REDISTRIBUTE_DELETE,	"Delete Redistribute" },
	{ FRR_ZAPI4_REDISTRIBUTE_DEFAULT_ADD,	"Add Default Redistribute" },
	{ FRR_ZAPI4_REDISTRIBUTE_DEFAULT_DELETE,"Delete Default Redistribute" },
	{ FRR_ZAPI4_ROUTER_ID_ADD,		"Router ID Add" },
	{ FRR_ZAPI4_ROUTER_ID_DELETE,		"Router ID Delete" },
	{ FRR_ZAPI4_ROUTER_ID_UPDATE,		"Router ID Update" },
	{ FRR_ZAPI4_HELLO,			"Hello" },
	{ FRR_ZAPI4_NEXTHOP_REGISTER,		"Nexthop Register" },
	{ FRR_ZAPI4_NEXTHOP_UNREGISTER,		"Nexthop Unregister" },
	{ FRR_ZAPI4_NEXTHOP_UPDATE,		"Nexthop Update" },
	{ FRR_ZAPI4_INTERFACE_NBR_ADDRESS_ADD,	"Interface Neighbor Address Add" },
	{ FRR_ZAPI4_INTERFACE_NBR_ADDRESS_DELETE, "Interface Neighbor Address Delete" },
	{ FRR_ZAPI4_INTERFACE_BFD_DEST_UPDATE,	"Interface BFD Destination Update" },
	{ FRR_ZAPI4_IMPORT_ROUTE_REGISTER,	"Import Route Register" },
	{ FRR_ZAPI4_IMPORT_ROUTE_UNREGISTER,	"Import Route Unregister" },
	{ FRR_ZAPI4_IMPORT_CHECK_UPDATE,	"Import Check Update" },
	{ FRR_ZAPI4_IPV4_ROUTE_IPV6_NEXTHOP_ADD,"Add IPv6 nexthop for IPv4 Route" },
	{ FRR_ZAPI4_BFD_DEST_REGISTER,		"BFD Destination Register" },
	{ FRR_ZAPI4_BFD_DEST_DEREGISTER,	"BFD Destination Deregister" },
	{ FRR_ZAPI4_BFD_DEST_UPDATE,		"BFD Destination Update" },
	{ FRR_ZAPI4_BFD_DEST_REPLAY,		"BFD Destination Replay" },
	{ FRR_ZAPI4_REDISTRIBUTE_IPV4_ADD,	"Add Redistribute IPv4 Route" },
	{ FRR_ZAPI4_REDISTRIBUTE_IPV4_DEL,	"Delete Redistribute IPv4 Route" },
	{ FRR_ZAPI4_REDISTRIBUTE_IPV6_ADD,	"Add Redistribute IPv6 Route" },
	{ FRR_ZAPI4_REDISTRIBUTE_IPV6_DEL,	"Delete Redistribute IPv6 Route" },
	{ FRR_ZAPI4_VRF_UNREGISTER,		"VRF Unregister" },
	{ FRR_ZAPI4_VRF_ADD,			"VRF Add" },
	{ FRR_ZAPI4_VRF_DELETE,			"VRF Delete" },
	{ FRR_ZAPI4_INTERFACE_VRF_UPDATE,	"Interface VRF Update" },
	{ FRR_ZAPI4_BFD_CLIENT_REGISTER,	"BFD Client Register" },
	{ FRR_ZAPI4_INTERFACE_ENABLE_RADV,	"Interface Enable Router Advertisement" },
	{ FRR_ZAPI4_INTERFACE_DISABLE_RADV,	"Interface Disable Router Advertisement" },
	{ FRR_ZAPI4_IPV4_NEXTHOP_LOOKUP_MRIB,	"IPv4 Nexthop Lookup Multicast RIB" },
	{ FRR_ZAPI4_INTERFACE_LINK_PARAMS,	"Interface Link Parameters" },
	{ FRR_ZAPI4_MPLS_LABELS_ADD,		"MPLS Labels Add" },
	{ FRR_ZAPI4_MPLS_LABELS_DELETE,		"MPLS Labels Delete" },
	{ FRR_ZAPI4_IPV4_NEXTHOP_ADD,		"Add IPv4 Nexthop" },
	{ FRR_ZAPI4_IPV4_NEXTHOP_DELETE,	"Delete IPv4 Nexthop" },
	{ FRR_ZAPI4_IPV6_NEXTHOP_ADD,		"Add IPv6 Nexthop" },
	{ FRR_ZAPI4_IPV6_NEXTHOP_DELETE,	"Delete IPv6 Nexthop" },
	{ FRR_ZAPI4_IPMR_ROUTE_STATS,		"IPMR Route Statics" },
	{ FRR_ZAPI4_LABEL_MANAGER_CONNECT,	"Label Manager Connect" },
	{ FRR_ZAPI4_GET_LABEL_CHUNK,		"Get Label Chunk" },
	{ FRR_ZAPI4_RELEASE_LABEL_CHUNK,	"Release Label Chunk" },
	{ FRR_ZAPI4_PW_ADD,			"PseudoWire Add" },
	{ FRR_ZAPI4_PW_DELETE,			"PseudoWire Delete" },
	{ FRR_ZAPI4_PW_SET,			"PseudoWire Set" },
	{ FRR_ZAPI4_PW_UNSET,			"PseudoWire Unset" },
	{ FRR_ZAPI4_PW_STATUS_UPDATE,		"PseudoWire Status Update" },
	{ 0,					NULL },
};

enum {
	FRR_ZAPI5_INTERFACE_ADD,
	FRR_ZAPI5_INTERFACE_DELETE,
	FRR_ZAPI5_INTERFACE_ADDRESS_ADD,
	FRR_ZAPI5_INTERFACE_ADDRESS_DELETE,
	FRR_ZAPI5_INTERFACE_UP,
	FRR_ZAPI5_INTERFACE_DOWN,
	FRR_ZAPI5_INTERFACE_SET_MASTER,
	FRR_ZAPI5_ROUTE_ADD,
	FRR_ZAPI5_ROUTE_DELETE,
	FRR_ZAPI5_ROUTE_NOTIFY_OWNER,
	FRR_ZAPI5_IPV4_ROUTE_ADD,
	FRR_ZAPI5_IPV4_ROUTE_DELETE,
	FRR_ZAPI5_IPV6_ROUTE_ADD,
	FRR_ZAPI5_IPV6_ROUTE_DELETE,
	FRR_ZAPI5_REDISTRIBUTE_ADD,
	FRR_ZAPI5_REDISTRIBUTE_DELETE,
	FRR_ZAPI5_REDISTRIBUTE_DEFAULT_ADD,
	FRR_ZAPI5_REDISTRIBUTE_DEFAULT_DELETE,
	FRR_ZAPI5_ROUTER_ID_ADD,
	FRR_ZAPI5_ROUTER_ID_DELETE,
	FRR_ZAPI5_ROUTER_ID_UPDATE,
	FRR_ZAPI5_HELLO,
	FRR_ZAPI5_CAPABILITIES,
	FRR_ZAPI5_NEXTHOP_REGISTER,
	FRR_ZAPI5_NEXTHOP_UNREGISTER,
	FRR_ZAPI5_NEXTHOP_UPDATE,
	FRR_ZAPI5_INTERFACE_NBR_ADDRESS_ADD,
	FRR_ZAPI5_INTERFACE_NBR_ADDRESS_DELETE,
	FRR_ZAPI5_INTERFACE_BFD_DEST_UPDATE,
	FRR_ZAPI5_IMPORT_ROUTE_REGISTER,
	FRR_ZAPI5_IMPORT_ROUTE_UNREGISTER,
	FRR_ZAPI5_IMPORT_CHECK_UPDATE,
	FRR_ZAPI5_IPV4_ROUTE_IPV6_NEXTHOP_ADD,
	FRR_ZAPI5_BFD_DEST_REGISTER,
	FRR_ZAPI5_BFD_DEST_DEREGISTER,
	FRR_ZAPI5_BFD_DEST_UPDATE,
	FRR_ZAPI5_BFD_DEST_REPLAY,
	FRR_ZAPI5_REDISTRIBUTE_ROUTE_ADD,
	FRR_ZAPI5_REDISTRIBUTE_ROUTE_DEL,
	FRR_ZAPI5_VRF_UNREGISTER,
	FRR_ZAPI5_VRF_ADD,
	FRR_ZAPI5_VRF_DELETE,
	FRR_ZAPI5_VRF_LABEL,
	FRR_ZAPI5_INTERFACE_VRF_UPDATE,
	FRR_ZAPI5_BFD_CLIENT_REGISTER,
	FRR_ZAPI5_INTERFACE_ENABLE_RADV,
	FRR_ZAPI5_INTERFACE_DISABLE_RADV,
	FRR_ZAPI5_IPV4_NEXTHOP_LOOKUP_MRIB,
	FRR_ZAPI5_INTERFACE_LINK_PARAMS,
	FRR_ZAPI5_MPLS_LABELS_ADD,
	FRR_ZAPI5_MPLS_LABELS_DELETE,
	FRR_ZAPI5_IPMR_ROUTE_STATS,
	FRR_ZAPI5_LABEL_MANAGER_CONNECT,
	FRR_ZAPI5_LABEL_MANAGER_CONNECT_ASYNC,
	FRR_ZAPI5_GET_LABEL_CHUNK,
	FRR_ZAPI5_RELEASE_LABEL_CHUNK,
	FRR_ZAPI5_FEC_REGISTER,
	FRR_ZAPI5_FEC_UNREGISTER,
	FRR_ZAPI5_FEC_UPDATE,
	FRR_ZAPI5_ADVERTISE_DEFAULT_GW,
	FRR_ZAPI5_ADVERTISE_SUBNET,
	FRR_ZAPI5_ADVERTISE_ALL_VNI,
	FRR_ZAPI5_VNI_ADD,
	FRR_ZAPI5_VNI_DEL,
	FRR_ZAPI5_L3VNI_ADD,
	FRR_ZAPI5_L3VNI_DEL,
	FRR_ZAPI5_REMOTE_VTEP_ADD,
	FRR_ZAPI5_REMOTE_VTEP_DEL,
	FRR_ZAPI5_MACIP_ADD,
	FRR_ZAPI5_MACIP_DEL,
	FRR_ZAPI5_IP_PREFIX_ROUTE_ADD,
	FRR_ZAPI5_IP_PREFIX_ROUTE_DEL,
	FRR_ZAPI5_REMOTE_MACIP_ADD,
	FRR_ZAPI5_REMOTE_MACIP_DEL,
	FRR_ZAPI5_PW_ADD,
	FRR_ZAPI5_PW_DELETE,
	FRR_ZAPI5_PW_SET,
	FRR_ZAPI5_PW_UNSET,
	FRR_ZAPI5_PW_STATUS_UPDATE,
	FRR_ZAPI5_RULE_ADD,
	FRR_ZAPI5_RULE_DELETE,
	FRR_ZAPI5_RULE_NOTIFY_OWNER,
	FRR_ZAPI5_TABLE_MANAGER_CONNECT,
	FRR_ZAPI5_GET_TABLE_CHUNK,
	FRR_ZAPI5_RELEASE_TABLE_CHUNK,
	FRR_ZAPI5_IPSET_CREATE,
	FRR_ZAPI5_IPSET_DESTROY,
	FRR_ZAPI5_IPSET_ENTRY_ADD,
	FRR_ZAPI5_IPSET_ENTRY_DELETE,
	FRR_ZAPI5_IPSET_NOTIFY_OWNER,
	FRR_ZAPI5_IPSET_ENTRY_NOTIFY_OWNER,
	FRR_ZAPI5_IPTABLE_ADD,
	FRR_ZAPI5_IPTABLE_DELETE,
	FRR_ZAPI5_IPTABLE_NOTIFY_OWNER,
};

static const value_string frr_zapi5_messages[] = {
	{ FRR_ZAPI5_INTERFACE_ADD,		"Add Interface" },
	{ FRR_ZAPI5_INTERFACE_DELETE,		"Delete Interface" },
	{ FRR_ZAPI5_INTERFACE_ADDRESS_ADD,	"Add Interface Address" },
	{ FRR_ZAPI5_INTERFACE_ADDRESS_DELETE,	"Delete Interface Address" },
	{ FRR_ZAPI5_INTERFACE_UP,		"Interface Up" },
	{ FRR_ZAPI5_INTERFACE_DOWN,		"Interface Down" },
	{ FRR_ZAPI5_ROUTE_ADD,			"Add Route" },
	{ FRR_ZAPI5_ROUTE_DELETE,		"Delete Route" },
	{ FRR_ZAPI5_IPV4_ROUTE_ADD,		"Add IPv4 Route" },
	{ FRR_ZAPI5_IPV4_ROUTE_DELETE,		"Delete IPv4 Route" },
	{ FRR_ZAPI5_IPV6_ROUTE_ADD,		"Add IPv6 Route" },
	{ FRR_ZAPI5_IPV6_ROUTE_DELETE,		"Delete IPv6 Route" },
	{ FRR_ZAPI5_REDISTRIBUTE_ADD,		"Add Redistribute" },
	{ FRR_ZAPI5_REDISTRIBUTE_DELETE,	"Delete Redistribute" },
	{ FRR_ZAPI5_REDISTRIBUTE_DEFAULT_ADD,	"Add Default Redistribute" },
	{ FRR_ZAPI5_REDISTRIBUTE_DEFAULT_DELETE,"Delete Default Redistribute" },
	{ FRR_ZAPI5_ROUTER_ID_ADD,		"Router ID Add" },
	{ FRR_ZAPI5_ROUTER_ID_DELETE,		"Router ID Delete" },
	{ FRR_ZAPI5_ROUTER_ID_UPDATE,		"Router ID Update" },
	{ FRR_ZAPI5_HELLO,			"Hello" },
	{ FRR_ZAPI5_CAPABILITIES,		"Capabilities" },
	{ FRR_ZAPI5_NEXTHOP_REGISTER,		"Nexthop Register" },
	{ FRR_ZAPI5_NEXTHOP_UNREGISTER,		"Nexthop Unregister" },
	{ FRR_ZAPI5_NEXTHOP_UPDATE,		"Nexthop Update" },
	{ FRR_ZAPI5_INTERFACE_NBR_ADDRESS_ADD,	"Interface Neighbor Address Add" },
	{ FRR_ZAPI5_INTERFACE_NBR_ADDRESS_DELETE, "Interface Neighbor Address Delete" },
	{ FRR_ZAPI5_INTERFACE_BFD_DEST_UPDATE,	"Interface BFD Destination Update" },
	{ FRR_ZAPI5_IMPORT_ROUTE_REGISTER,	"Import Route Register" },
	{ FRR_ZAPI5_IMPORT_ROUTE_UNREGISTER,	"Import Route Unregister" },
	{ FRR_ZAPI5_IMPORT_CHECK_UPDATE,	"Import Check Update" },
	{ FRR_ZAPI5_IPV4_ROUTE_IPV6_NEXTHOP_ADD,"Add IPv6 nexthop for IPv4 Route" },
	{ FRR_ZAPI5_BFD_DEST_REGISTER,		"BFD Destination Register" },
	{ FRR_ZAPI5_BFD_DEST_DEREGISTER,	"BFD Destination Deregister" },
	{ FRR_ZAPI5_BFD_DEST_UPDATE,		"BFD Destination Update" },
	{ FRR_ZAPI5_BFD_DEST_REPLAY,		"BFD Destination Replay" },
	{ FRR_ZAPI5_REDISTRIBUTE_ROUTE_ADD,	"Add Redistribute Route" },
	{ FRR_ZAPI5_REDISTRIBUTE_ROUTE_DEL,	"Delete Redistribute Route" },
	{ FRR_ZAPI5_VRF_UNREGISTER,		"VRF Unregister" },
	{ FRR_ZAPI5_VRF_ADD,			"VRF Add" },
	{ FRR_ZAPI5_VRF_DELETE,			"VRF Delete" },
	{ FRR_ZAPI5_VRF_LABEL,			"VRF Label" },
	{ FRR_ZAPI5_INTERFACE_VRF_UPDATE,	"Interface VRF Update" },
	{ FRR_ZAPI5_BFD_CLIENT_REGISTER,	"BFD Client Register" },
	{ FRR_ZAPI5_INTERFACE_ENABLE_RADV,	"Interface Enable Router Advertisement" },
	{ FRR_ZAPI5_INTERFACE_DISABLE_RADV,	"Interface Disable Router Advertisement" },
	{ FRR_ZAPI5_IPV4_NEXTHOP_LOOKUP_MRIB,	"IPv4 Nexthop Lookup Multicast RIB" },
	{ FRR_ZAPI5_INTERFACE_LINK_PARAMS,	"Interface Link Parameters" },
	{ FRR_ZAPI5_MPLS_LABELS_ADD,		"MPLS Labels Add" },
	{ FRR_ZAPI5_MPLS_LABELS_DELETE,		"MPLS Labels Delete" },
	{ FRR_ZAPI5_IPMR_ROUTE_STATS,		"IPMR Route Statics" },
	{ FRR_ZAPI5_LABEL_MANAGER_CONNECT,	"Label Manager Connect" },
	{ FRR_ZAPI5_LABEL_MANAGER_CONNECT_ASYNC,"Label Manager Connect Asynchronous" },
	{ FRR_ZAPI5_GET_LABEL_CHUNK,		"Get Label Chunk" },
	{ FRR_ZAPI5_RELEASE_LABEL_CHUNK,	"Release Label Chunk" },
	{ FRR_ZAPI5_FEC_REGISTER,		"FEC Register" },
	{ FRR_ZAPI5_FEC_UNREGISTER,		"FEC Unregister" },
	{ FRR_ZAPI5_FEC_UPDATE,			"FEC Update" },
	{ FRR_ZAPI5_ADVERTISE_DEFAULT_GW,	"Advertise Default Gateway" },
	{ FRR_ZAPI5_ADVERTISE_SUBNET,		"Advertise Subnet" },
	{ FRR_ZAPI5_ADVERTISE_ALL_VNI,		"Advertise all VNI" },
	{ FRR_ZAPI5_VNI_ADD,			"VNI Add" },
	{ FRR_ZAPI5_VNI_DEL,			"VNI Delete" },
	{ FRR_ZAPI5_L3VNI_ADD,			"L3VNI Add" },
	{ FRR_ZAPI5_L3VNI_DEL,			"L3VNI Delete" },
	{ FRR_ZAPI5_REMOTE_VTEP_ADD,		"Remote VTEP Add" },
	{ FRR_ZAPI5_REMOTE_VTEP_DEL,		"Remote VTEP Delete" },
	{ FRR_ZAPI5_MACIP_ADD,			"MAC/IP Add" },
	{ FRR_ZAPI5_MACIP_DEL,			"MAC/IP Delete" },
	{ FRR_ZAPI5_IP_PREFIX_ROUTE_ADD,	"IP Prefix Route Add" },
	{ FRR_ZAPI5_IP_PREFIX_ROUTE_DEL,	"IP Prefix Route Delete" },
	{ FRR_ZAPI5_REMOTE_MACIP_ADD,		"Remote MAC/IP Add" },
	{ FRR_ZAPI5_REMOTE_MACIP_DEL,		"Remote MAC/IP Delete" },
	{ FRR_ZAPI5_PW_ADD,			"PseudoWire Add" },
	{ FRR_ZAPI5_PW_DELETE,			"PseudoWire Delete" },
	{ FRR_ZAPI5_PW_SET,			"PseudoWire Set" },
	{ FRR_ZAPI5_PW_UNSET,			"PseudoWire Unset" },
	{ FRR_ZAPI5_PW_STATUS_UPDATE,		"PseudoWire Status Update" },
	{ FRR_ZAPI5_RULE_ADD,			"Rule Add" },
	{ FRR_ZAPI5_RULE_DELETE,		"Rule Delete" },
	{ FRR_ZAPI5_RULE_NOTIFY_OWNER,		"Rule Notify Owner" },
	{ FRR_ZAPI5_TABLE_MANAGER_CONNECT,	"Table Manager Connect" },
	{ FRR_ZAPI5_GET_TABLE_CHUNK,		"Get Table Chunk" },
	{ FRR_ZAPI5_RELEASE_TABLE_CHUNK,	"Release Table Chunk" },
	{ FRR_ZAPI5_IPSET_CREATE,		"IPSet Create" },
	{ FRR_ZAPI5_IPSET_DESTROY,		"IPSet Destroy" },
	{ FRR_ZAPI5_IPSET_ENTRY_ADD,		"IPSet Entry Add" },
	{ FRR_ZAPI5_IPSET_ENTRY_DELETE,		"IPSet Entry Delete" },
	{ FRR_ZAPI5_IPSET_NOTIFY_OWNER,		"IPSet Notify Oner" },
	{ FRR_ZAPI5_IPSET_ENTRY_NOTIFY_OWNER,	"IPSet Entry Notify Owner" },
	{ FRR_ZAPI5_IPTABLE_ADD,		"IPTable Add" },
	{ FRR_ZAPI5_IPTABLE_DELETE,		"IPTable Delete" },
	{ FRR_ZAPI5_IPTABLE_NOTIFY_OWNER,	"IPTable Notify Owner" },
	{ 0,					NULL },
};

enum {
	FRR_ZAPI6_INTERFACE_ADD,
	FRR_ZAPI6_INTERFACE_DELETE,
	FRR_ZAPI6_INTERFACE_ADDRESS_ADD,
	FRR_ZAPI6_INTERFACE_ADDRESS_DELETE,
	FRR_ZAPI6_INTERFACE_UP,
	FRR_ZAPI6_INTERFACE_DOWN,
	FRR_ZAPI6_INTERFACE_SET_MASTER,
	FRR_ZAPI6_ROUTE_ADD,
	FRR_ZAPI6_ROUTE_DELETE,
	FRR_ZAPI6_ROUTE_NOTIFY_OWNER,
	FRR_ZAPI6_REDISTRIBUTE_ADD,
	FRR_ZAPI6_REDISTRIBUTE_DELETE,
	FRR_ZAPI6_REDISTRIBUTE_DEFAULT_ADD,
	FRR_ZAPI6_REDISTRIBUTE_DEFAULT_DELETE,
	FRR_ZAPI6_ROUTER_ID_ADD,
	FRR_ZAPI6_ROUTER_ID_DELETE,
	FRR_ZAPI6_ROUTER_ID_UPDATE,
	FRR_ZAPI6_HELLO,
	FRR_ZAPI6_CAPABILITIES,
	FRR_ZAPI6_NEXTHOP_REGISTER,
	FRR_ZAPI6_NEXTHOP_UNREGISTER,
	FRR_ZAPI6_NEXTHOP_UPDATE,
	FRR_ZAPI6_INTERFACE_NBR_ADDRESS_ADD,
	FRR_ZAPI6_INTERFACE_NBR_ADDRESS_DELETE,
	FRR_ZAPI6_INTERFACE_BFD_DEST_UPDATE,
	FRR_ZAPI6_IMPORT_ROUTE_REGISTER,
	FRR_ZAPI6_IMPORT_ROUTE_UNREGISTER,
	FRR_ZAPI6_IMPORT_CHECK_UPDATE,
	//FRR_ZAPI6_IPV4_ROUTE_IPV6_NEXTHOP_ADD,
	FRR_ZAPI6_BFD_DEST_REGISTER,
	FRR_ZAPI6_BFD_DEST_DEREGISTER,
	FRR_ZAPI6_BFD_DEST_UPDATE,
	FRR_ZAPI6_BFD_DEST_REPLAY,
	FRR_ZAPI6_REDISTRIBUTE_ROUTE_ADD,
	FRR_ZAPI6_REDISTRIBUTE_ROUTE_DEL,
	FRR_ZAPI6_VRF_UNREGISTER,
	FRR_ZAPI6_VRF_ADD,
	FRR_ZAPI6_VRF_DELETE,
	FRR_ZAPI6_VRF_LABEL,
	FRR_ZAPI6_INTERFACE_VRF_UPDATE,
	FRR_ZAPI6_BFD_CLIENT_REGISTER,
	FRR_ZAPI6_BFD_CLIENT_DEREGISTER,
	FRR_ZAPI6_INTERFACE_ENABLE_RADV,
	FRR_ZAPI6_INTERFACE_DISABLE_RADV,
	FRR_ZAPI6_IPV4_NEXTHOP_LOOKUP_MRIB,
	FRR_ZAPI6_INTERFACE_LINK_PARAMS,
	FRR_ZAPI6_MPLS_LABELS_ADD,
	FRR_ZAPI6_MPLS_LABELS_DELETE,
	FRR_ZAPI6_IPMR_ROUTE_STATS,
	FRR_ZAPI6_LABEL_MANAGER_CONNECT,
	FRR_ZAPI6_LABEL_MANAGER_CONNECT_ASYNC,
	FRR_ZAPI6_GET_LABEL_CHUNK,
	FRR_ZAPI6_RELEASE_LABEL_CHUNK,
	FRR_ZAPI6_FEC_REGISTER,
	FRR_ZAPI6_FEC_UNREGISTER,
	FRR_ZAPI6_FEC_UPDATE,
	FRR_ZAPI6_ADVERTISE_DEFAULT_GW,
	FRR_ZAPI6_ADVERTISE_SUBNET,
	FRR_ZAPI6_ADVERTISE_ALL_VNI,
	FRR_ZAPI6_LOCAL_ES_ADD,
	FRR_ZAPI6_LOCAL_ES_DEL,
	FRR_ZAPI6_VNI_ADD,
	FRR_ZAPI6_VNI_DEL,
	FRR_ZAPI6_L3VNI_ADD,
	FRR_ZAPI6_L3VNI_DEL,
	FRR_ZAPI6_REMOTE_VTEP_ADD,
	FRR_ZAPI6_REMOTE_VTEP_DEL,
	FRR_ZAPI6_MACIP_ADD,
	FRR_ZAPI6_MACIP_DEL,
	FRR_ZAPI6_IP_PREFIX_ROUTE_ADD,
	FRR_ZAPI6_IP_PREFIX_ROUTE_DEL,
	FRR_ZAPI6_REMOTE_MACIP_ADD,
	FRR_ZAPI6_REMOTE_MACIP_DEL,
	FRR_ZAPI6_DUPLICATE_ADDR_DETECTION,
	FRR_ZAPI6_PW_ADD,
	FRR_ZAPI6_PW_DELETE,
	FRR_ZAPI6_PW_SET,
	FRR_ZAPI6_PW_UNSET,
	FRR_ZAPI6_PW_STATUS_UPDATE,
	FRR_ZAPI6_RULE_ADD,
	FRR_ZAPI6_RULE_DELETE,
	FRR_ZAPI6_RULE_NOTIFY_OWNER,
	FRR_ZAPI6_TABLE_MANAGER_CONNECT,
	FRR_ZAPI6_GET_TABLE_CHUNK,
	FRR_ZAPI6_RELEASE_TABLE_CHUNK,
	FRR_ZAPI6_IPSET_CREATE,
	FRR_ZAPI6_IPSET_DESTROY,
	FRR_ZAPI6_IPSET_ENTRY_ADD,
	FRR_ZAPI6_IPSET_ENTRY_DELETE,
	FRR_ZAPI6_IPSET_NOTIFY_OWNER,
	FRR_ZAPI6_IPSET_ENTRY_NOTIFY_OWNER,
	FRR_ZAPI6_IPTABLE_ADD,
	FRR_ZAPI6_IPTABLE_DELETE,
	FRR_ZAPI6_IPTABLE_NOTIFY_OWNER,
	FRR_ZAPI6_VXLAN_FLOOD_CONTROL,
};

static const value_string frr_zapi6_messages[] = {
	{ FRR_ZAPI6_INTERFACE_ADD,		"Add Interface" },
	{ FRR_ZAPI6_INTERFACE_DELETE,		"Delete Interface" },
	{ FRR_ZAPI6_INTERFACE_ADDRESS_ADD,	"Add Interface Address" },
	{ FRR_ZAPI6_INTERFACE_ADDRESS_DELETE,	"Delete Interface Address" },
	{ FRR_ZAPI6_INTERFACE_UP,		"Interface Up" },
	{ FRR_ZAPI6_INTERFACE_DOWN,		"Interface Down" },
	{ FRR_ZAPI6_ROUTE_ADD,			"Add Route" },
	{ FRR_ZAPI6_ROUTE_DELETE,		"Delete Route" },
	{ FRR_ZAPI6_REDISTRIBUTE_ADD,		"Add Redistribute" },
	{ FRR_ZAPI6_REDISTRIBUTE_DELETE,	"Delete Redistribute" },
	{ FRR_ZAPI6_REDISTRIBUTE_DEFAULT_ADD,	"Add Default Redistribute" },
	{ FRR_ZAPI6_REDISTRIBUTE_DEFAULT_DELETE,"Delete Default Redistribute" },
	{ FRR_ZAPI6_ROUTER_ID_ADD,		"Router ID Add" },
	{ FRR_ZAPI6_ROUTER_ID_DELETE,		"Router ID Delete" },
	{ FRR_ZAPI6_ROUTER_ID_UPDATE,		"Router ID Update" },
	{ FRR_ZAPI6_HELLO,			"Hello" },
	{ FRR_ZAPI6_CAPABILITIES,		"Capabilities" },
	{ FRR_ZAPI6_NEXTHOP_REGISTER,		"Nexthop Register" },
	{ FRR_ZAPI6_NEXTHOP_UNREGISTER,		"Nexthop Unregister" },
	{ FRR_ZAPI6_NEXTHOP_UPDATE,		"Nexthop Update" },
	{ FRR_ZAPI6_INTERFACE_NBR_ADDRESS_ADD,	"Interface Neighbor Address Add" },
	{ FRR_ZAPI6_INTERFACE_NBR_ADDRESS_DELETE, "Interface Neighbor Address Delete" },
	{ FRR_ZAPI6_INTERFACE_BFD_DEST_UPDATE,	"Interface BFD Destination Update" },
	{ FRR_ZAPI6_IMPORT_ROUTE_REGISTER,	"Import Route Register" },
	{ FRR_ZAPI6_IMPORT_ROUTE_UNREGISTER,	"Import Route Unregister" },
	{ FRR_ZAPI6_IMPORT_CHECK_UPDATE,	"Import Check Update" },
	//{ FRR_ZAPI6_IPV4_ROUTE_IPV6_NEXTHOP_ADD,"Add IPv6 nexthop for IPv4 Route" },
	{ FRR_ZAPI6_BFD_DEST_REGISTER,		"BFD Destination Register" },
	{ FRR_ZAPI6_BFD_DEST_DEREGISTER,	"BFD Destination Deregister" },
	{ FRR_ZAPI6_BFD_DEST_UPDATE,		"BFD Destination Update" },
	{ FRR_ZAPI6_BFD_DEST_REPLAY,		"BFD Destination Replay" },
	{ FRR_ZAPI6_REDISTRIBUTE_ROUTE_ADD,	"Add Redistribute Route" },
	{ FRR_ZAPI6_REDISTRIBUTE_ROUTE_DEL,	"Delete Redistribute Route" },
	{ FRR_ZAPI6_VRF_UNREGISTER,		"VRF Unregister" },
	{ FRR_ZAPI6_VRF_ADD,			"VRF Add" },
	{ FRR_ZAPI6_VRF_DELETE,			"VRF Delete" },
	{ FRR_ZAPI6_VRF_LABEL,			"VRF Label" },
	{ FRR_ZAPI6_INTERFACE_VRF_UPDATE,	"Interface VRF Update" },
	{ FRR_ZAPI6_BFD_CLIENT_REGISTER,	"BFD Client Register" },
	{ FRR_ZAPI6_BFD_CLIENT_DEREGISTER,	"BFD Client Deregister" },
	{ FRR_ZAPI6_INTERFACE_ENABLE_RADV,	"Interface Enable Router Advertisement" },
	{ FRR_ZAPI6_INTERFACE_DISABLE_RADV,	"Interface Disable Router Advertisement" },
	{ FRR_ZAPI6_IPV4_NEXTHOP_LOOKUP_MRIB,	"IPv4 Nexthop Lookup Multicast RIB" },
	{ FRR_ZAPI6_INTERFACE_LINK_PARAMS,	"Interface Link Parameters" },
	{ FRR_ZAPI6_MPLS_LABELS_ADD,		"MPLS Labels Add" },
	{ FRR_ZAPI6_MPLS_LABELS_DELETE,		"MPLS Labels Delete" },
	{ FRR_ZAPI6_IPMR_ROUTE_STATS,		"IPMR Route Statics" },
	{ FRR_ZAPI6_LABEL_MANAGER_CONNECT,	"Label Manager Connect" },
	{ FRR_ZAPI6_LABEL_MANAGER_CONNECT_ASYNC,"Label Manager Connect Asynchronous" },
	{ FRR_ZAPI6_GET_LABEL_CHUNK,		"Get Label Chunk" },
	{ FRR_ZAPI6_RELEASE_LABEL_CHUNK,	"Release Label Chunk" },
	{ FRR_ZAPI6_FEC_REGISTER,		"FEC Register" },
	{ FRR_ZAPI6_FEC_UNREGISTER,		"FEC Unregister" },
	{ FRR_ZAPI6_FEC_UPDATE,			"FEC Update" },
	{ FRR_ZAPI6_ADVERTISE_DEFAULT_GW,	"Advertise Default Gateway" },
	{ FRR_ZAPI6_ADVERTISE_SUBNET,		"Advertise Subnet" },
	{ FRR_ZAPI6_ADVERTISE_ALL_VNI,		"Advertise all VNI" },
	{ FRR_ZAPI6_LOCAL_ES_ADD,		"Local Ethernet Segment Add" },
	{ FRR_ZAPI6_LOCAL_ES_DEL,		"Local Ethernet Segment Delete" },
	{ FRR_ZAPI6_VNI_ADD,			"VNI Add" },
	{ FRR_ZAPI6_VNI_DEL,			"VNI Delete" },
	{ FRR_ZAPI6_L3VNI_ADD,			"L3VNI Add" },
	{ FRR_ZAPI6_L3VNI_DEL,			"L3VNI Delete" },
	{ FRR_ZAPI6_REMOTE_VTEP_ADD,		"Remote VTEP Add" },
	{ FRR_ZAPI6_REMOTE_VTEP_DEL,		"Remote VTEP Delete" },
	{ FRR_ZAPI6_MACIP_ADD,			"MAC/IP Add" },
	{ FRR_ZAPI6_MACIP_DEL,			"MAC/IP Delete" },
	{ FRR_ZAPI6_IP_PREFIX_ROUTE_ADD,	"IP Prefix Route Add" },
	{ FRR_ZAPI6_IP_PREFIX_ROUTE_DEL,	"IP Prefix Route Delete" },
	{ FRR_ZAPI6_REMOTE_MACIP_ADD,		"Remote MAC/IP Add" },
	{ FRR_ZAPI6_REMOTE_MACIP_DEL,		"Remote MAC/IP Delete" },
	{ FRR_ZAPI6_DUPLICATE_ADDR_DETECTION,   "Duplicate Address Detection" },
	{ FRR_ZAPI6_PW_ADD,			"PseudoWire Add" },
	{ FRR_ZAPI6_PW_DELETE,			"PseudoWire Delete" },
	{ FRR_ZAPI6_PW_SET,			"PseudoWire Set" },
	{ FRR_ZAPI6_PW_UNSET,			"PseudoWire Unset" },
	{ FRR_ZAPI6_PW_STATUS_UPDATE,		"PseudoWire Status Update" },
	{ FRR_ZAPI6_RULE_ADD,			"Rule Add" },
	{ FRR_ZAPI6_RULE_DELETE,		"Rule Delete" },
	{ FRR_ZAPI6_RULE_NOTIFY_OWNER,		"Rule Notify Owner" },
	{ FRR_ZAPI6_TABLE_MANAGER_CONNECT,	"Table Manager Connect" },
	{ FRR_ZAPI6_GET_TABLE_CHUNK,		"Get Table Chunk" },
	{ FRR_ZAPI6_RELEASE_TABLE_CHUNK,	"Release Table Chunk" },
	{ FRR_ZAPI6_IPSET_CREATE,		"IPSet Create" },
	{ FRR_ZAPI6_IPSET_DESTROY,		"IPSet Destroy" },
	{ FRR_ZAPI6_IPSET_ENTRY_ADD,		"IPSet Entry Add" },
	{ FRR_ZAPI6_IPSET_ENTRY_DELETE,		"IPSet Entry Delete" },
	{ FRR_ZAPI6_IPSET_NOTIFY_OWNER,		"IPSet Notify Oner" },
	{ FRR_ZAPI6_IPSET_ENTRY_NOTIFY_OWNER,	"IPSet Entry Notify Owner" },
	{ FRR_ZAPI6_IPTABLE_ADD,		"IPTable Add" },
	{ FRR_ZAPI6_IPTABLE_DELETE,		"IPTable Delete" },
	{ FRR_ZAPI6_IPTABLE_NOTIFY_OWNER,	"IPTable Notify Owner" },
	{ FRR_ZAPI6_VXLAN_FLOOD_CONTROL,	"VXLAN Flood Control" },
	{ 0,					NULL },
};

/* Zebra route's types. */
#define ZEBRA_ROUTE_SYSTEM               0
#define ZEBRA_ROUTE_KERNEL               1
#define ZEBRA_ROUTE_CONNECT              2
#define ZEBRA_ROUTE_STATIC               3
#define ZEBRA_ROUTE_RIP                  4
#define ZEBRA_ROUTE_RIPNG                5
#define ZEBRA_ROUTE_OSPF                 6
#define ZEBRA_ROUTE_OSPF6                7
#define ZEBRA_ROUTE_BGP                  8

static const value_string routes_v0[] = {
	{ ZEBRA_ROUTE_SYSTEM,			"System Route" },
	{ ZEBRA_ROUTE_KERNEL,			"Kernel Route" },
	{ ZEBRA_ROUTE_CONNECT,			"Connected Route" },
	{ ZEBRA_ROUTE_STATIC,			"Static Route" },
	{ ZEBRA_ROUTE_RIP,			"RIP Route" },
	{ ZEBRA_ROUTE_RIPNG,			"RIPnG Route" },
	{ ZEBRA_ROUTE_OSPF,			"OSPF Route" },
	{ ZEBRA_ROUTE_OSPF6,			"OSPF6 Route" },
	{ ZEBRA_ROUTE_BGP,			"BGP Route" },
	{ 0,					NULL },
};

/*
 * In Quagga, ISIS is type 8 and BGP is type 9, but Zebra didn't have ISIS...
 * so for Zebra BGP is type 8. So we dup the value_string table for quagga.
 */
#define QUAGGA_ROUTE_ISIS                 8
#define QUAGGA_ROUTE_BGP                  9
#define QUAGGA_ROUTE_HSLS                 10
#define QUAGGA_ROUTE_OLSR                 11
#define QUAGGA_ROUTE_BABEL                12

static const value_string routes_v1[] = {
	{ ZEBRA_ROUTE_SYSTEM,			"System Route" },
	{ ZEBRA_ROUTE_KERNEL,			"Kernel Route" },
	{ ZEBRA_ROUTE_CONNECT,			"Connected Route" },
	{ ZEBRA_ROUTE_STATIC,			"Static Route" },
	{ ZEBRA_ROUTE_RIP,			"RIP Route" },
	{ ZEBRA_ROUTE_RIPNG,			"RIPnG Route" },
	{ ZEBRA_ROUTE_OSPF,			"OSPF Route" },
	{ ZEBRA_ROUTE_OSPF6,			"OSPF6 Route" },
	{ QUAGGA_ROUTE_ISIS,			"ISIS Route" },
	{ QUAGGA_ROUTE_BGP,			"BGP Route" },
	{ QUAGGA_ROUTE_HSLS,			"HSLS Route" },
	{ QUAGGA_ROUTE_OLSR,			"OLSR Route" },
	{ QUAGGA_ROUTE_BABEL,			"BABEL Route" },
	{ 0,					NULL },
};

#define FRR_ZAPI4_ROUTE_PIM               10
#define FRR_ZAPI4_ROUTE_NHRP              11
#define FRR_ZAPI4_ROUTE_HSLS              12
#define FRR_ZAPI4_ROUTE_OLSR              13
#define FRR_ZAPI4_ROUTE_TABLE             14
#define FRR_ZAPI4_ROUTE_LDP               15
#define FRR_ZAPI4_ROUTE_VNC               16
#define FRR_ZAPI4_ROUTE_VNC_DIRECT        17
#define FRR_ZAPI4_ROUTE_VNC_DIRECT_RH     18
#define FRR_ZAPI4_ROUTE_BGP_DIRECT        19
#define FRR_ZAPI4_ROUTE_BGP_DIRECT_EXT    20

static const value_string routes_v4[] = {
	{ ZEBRA_ROUTE_SYSTEM,			"System Route" },
	{ ZEBRA_ROUTE_KERNEL,			"Kernel Route" },
	{ ZEBRA_ROUTE_CONNECT,			"Connected Route" },
	{ ZEBRA_ROUTE_STATIC,			"Static Route" },
	{ ZEBRA_ROUTE_RIP,			"RIP Route" },
	{ ZEBRA_ROUTE_RIPNG,			"RIPnG Route" },
	{ ZEBRA_ROUTE_OSPF,			"OSPF Route" },
	{ ZEBRA_ROUTE_OSPF6,			"OSPF6 Route" },
	{ QUAGGA_ROUTE_ISIS,			"ISIS Route" },
	{ QUAGGA_ROUTE_BGP,			"BGP Route" },
	{ FRR_ZAPI4_ROUTE_PIM,			"PIM Route" },
	{ FRR_ZAPI4_ROUTE_NHRP,			"NHRP Route" },
	{ FRR_ZAPI4_ROUTE_HSLS,			"HSLS Route" },
	{ FRR_ZAPI4_ROUTE_OLSR,			"OLSR Route" },
	{ FRR_ZAPI4_ROUTE_TABLE,		"Table Route" },
	{ FRR_ZAPI4_ROUTE_LDP,			"LDP Route" },
	{ FRR_ZAPI4_ROUTE_VNC,			"VNC Route" },
	{ FRR_ZAPI4_ROUTE_VNC_DIRECT,		"VNC Direct Route" },
	{ FRR_ZAPI4_ROUTE_VNC_DIRECT_RH,	"VNC RN Route" },
	{ FRR_ZAPI4_ROUTE_BGP_DIRECT,		"BGP Direct Route" },
	{ FRR_ZAPI4_ROUTE_BGP_DIRECT_EXT,	"BGP Direct to NVE groups Route" },
	{ 0,					NULL},
};

#define FRR_ZAPI5_ROUTE_EIGRP             11
#define FRR_ZAPI5_ROUTE_NHRP              12
#define FRR_ZAPI5_ROUTE_HSLS              13
#define FRR_ZAPI5_ROUTE_OLSR              14
#define FRR_ZAPI5_ROUTE_TABLE             15
#define FRR_ZAPI5_ROUTE_LDP               16
#define FRR_ZAPI5_ROUTE_VNC               17
#define FRR_ZAPI5_ROUTE_VNC_DIRECT        18
#define FRR_ZAPI5_ROUTE_VNC_DIRECT_RH     19
#define FRR_ZAPI5_ROUTE_BGP_DIRECT        20
#define FRR_ZAPI5_ROUTE_BGP_DIRECT_EXT    21
#define FRR_ZAPI5_ROUTE_BABEL             22
#define FRR_ZAPI5_ROUTE_SHARP             23
#define FRR_ZAPI5_ROUTE_PBR               24
#define FRR_ZAPI6_ROUTE_BFD               25
#define FRR_ZAPI6_ROUTE_OPENFABRIC        26

static const value_string routes_v5[] = {
	{ ZEBRA_ROUTE_SYSTEM,			"System Route" },
	{ ZEBRA_ROUTE_KERNEL,			"Kernel Route" },
	{ ZEBRA_ROUTE_CONNECT,			"Connected Route" },
	{ ZEBRA_ROUTE_STATIC,			"Static Route" },
	{ ZEBRA_ROUTE_RIP,			"RIP Route" },
	{ ZEBRA_ROUTE_RIPNG,			"RIPnG Route" },
	{ ZEBRA_ROUTE_OSPF,			"OSPF Route" },
	{ ZEBRA_ROUTE_OSPF6,			"OSPF6 Route" },
	{ QUAGGA_ROUTE_ISIS,			"ISIS Route" },
	{ QUAGGA_ROUTE_BGP,			"BGP Route" },
	{ FRR_ZAPI4_ROUTE_PIM,			"PIM Route" },
	{ FRR_ZAPI5_ROUTE_EIGRP,		"EIGRP Route" },
	{ FRR_ZAPI5_ROUTE_NHRP,			"NHRP Route" },
	{ FRR_ZAPI5_ROUTE_HSLS,			"HSLS Route" },
	{ FRR_ZAPI5_ROUTE_OLSR,			"OLSR Route" },
	{ FRR_ZAPI5_ROUTE_TABLE,		"Table Route" },
	{ FRR_ZAPI5_ROUTE_LDP,			"LDP Route" },
	{ FRR_ZAPI5_ROUTE_VNC,			"VNC Route" },
	{ FRR_ZAPI5_ROUTE_VNC_DIRECT,		"VNC Direct Route" },
	{ FRR_ZAPI5_ROUTE_VNC_DIRECT_RH,	"VNC RN Route" },
	{ FRR_ZAPI5_ROUTE_BGP_DIRECT,		"BGP Direct Route" },
	{ FRR_ZAPI5_ROUTE_BGP_DIRECT_EXT,	"BGP Direct to NVE groups Route" },
	{ FRR_ZAPI5_ROUTE_BABEL,		"BABEL Route" },
	{ FRR_ZAPI5_ROUTE_SHARP,		"SHARPd Route" },
	{ FRR_ZAPI5_ROUTE_PBR,			"PBR Route" },
	{ FRR_ZAPI6_ROUTE_BFD,			"BFD Route" },
	{ FRR_ZAPI6_ROUTE_OPENFABRIC,		"OpenFabric Route" },
	{ 0,					NULL },
};

/* Zebra's family types. */
#define ZEBRA_FAMILY_UNSPEC              0
#define ZEBRA_FAMILY_IPV4                2
#define ZEBRA_FAMILY_IPV6                10

static const value_string families[] = {
	{ ZEBRA_FAMILY_IPV4,			"IPv4" },
	{ ZEBRA_FAMILY_IPV6,			"IPv6" },
	{ 0,					NULL },
};

/* Zebra message flags */
#define ZEBRA_FLAG_INTERNAL              0x01
#define ZEBRA_FLAG_SELFROUTE             0x02
#define ZEBRA_FLAG_BLACKHOLE             0x04
#define ZEBRA_FLAG_IBGP                  0x08
#define ZEBRA_FLAG_SELECTED              0x10
#define ZEBRA_FLAG_FIB_OVERRIDE          0x20
#define ZEBRA_FLAG_STATIC                0x40
#define ZEBRA_FLAG_REJECT                0x80
/* ZAPI v4 (FRRouting v3) message flags */
#define ZEBRA_FLAG_SCOPE_LINK            0x100
#define FRR_FLAG_FIB_OVERRIDE            0x200
/* ZAPI v5 (FRRouting v5) message flags */
#define ZEBRA_FLAG_EVPN_ROUTE            0x400
#define FRR_FLAG_ALLOW_RECURSION         0x01
/* ZAPI v6 (FRRouting v7) message flags */
#define FRR_ZAPI6_FLAG_IBGP              0x04
#define FRR_ZAPI6_FLAG_SELECTED          0x08
#define FRR_ZAPI6_FLAG_FIB_OVERRIDE      0x10
#define FRR_ZAPI6_FLAG_EVPN_ROUTE        0x20
#define FRR_ZAPI6_FLAG_RR_USE_DISTANCE   0x40
#define FRR_ZAPI6_FLAG_ONLINk            0x40


/* Zebra API message flag. */
#define ZEBRA_ZAPI_MESSAGE_NEXTHOP       0x01
#define ZEBRA_ZAPI_MESSAGE_IFINDEX       0x02
#define ZEBRA_ZAPI_MESSAGE_DISTANCE      0x04
#define ZEBRA_ZAPI_MESSAGE_METRIC        0x08
#define ZEBRA_ZAPI_MESSAGE_MTU           0x10
#define ZEBRA_ZAPI_MESSAGE_TAG           0x20
/* ZAPI v4 (FRRouting v3) API message flags */
#define FRR_ZAPI4_MESSAGE_TAG            0x10
#define FRR_ZAPI4_MESSAGE_MTU            0x20
#define FRR_ZAPI4_MESSAGE_SRCPFX         0x40
/* ZAPI v5 (FRRouting v5) API message flags */
#define FRR_ZAPI5_MESSAGE_DISTANCE       0x02
#define FRR_ZAPI5_MESSAGE_METRIC         0x04
#define FRR_ZAPI5_MESSAGE_TAG            0x08
#define FRR_ZAPI5_MESSAGE_MTU            0x10
#define FRR_ZAPI5_MESSAGE_SRCPFX         0x20
#define FRR_ZAPI5_MESSAGE_LABEL          0x40
#define FRR_ZAPI5_MESSAGE_TABLEID        0x80

/* Zebra NextHop Types */
#define ZEBRA_NEXTHOP_TYPE_IFINDEX       0x01
#define ZEBRA_NEXTHOP_TYPE_IFNAME        0x02
#define ZEBRA_NEXTHOP_TYPE_IPV4          0x03
#define ZEBRA_NEXTHOP_TYPE_IPV4_IFINDEX  0x04
#define ZEBRA_NEXTHOP_TYPE_IPV4_IFNAME   0x05
#define ZEBRA_NEXTHOP_TYPE_IPV6          0x06
#define ZEBRA_NEXTHOP_TYPE_IPV6_IFINDEX  0x07
#define ZEBRA_NEXTHOP_TYPE_IPV6_IFNAME   0x08
#define ZEBRA_NEXTHOP_TYPE_BLACKHOLE     0x09

static const value_string zebra_nht[] = {
	{ ZEBRA_NEXTHOP_TYPE_IFINDEX,		"IFIndex" },
	{ ZEBRA_NEXTHOP_TYPE_IFNAME,		"IFName" },
	{ ZEBRA_NEXTHOP_TYPE_IPV4,		"IPv4" },
	{ ZEBRA_NEXTHOP_TYPE_IPV4_IFINDEX,	"IPv4 IFIndex" },
	{ ZEBRA_NEXTHOP_TYPE_IPV4_IFNAME,	"IPv4 IFName" },
	{ ZEBRA_NEXTHOP_TYPE_IPV6,		"IPv6 Nexthop" },
	{ ZEBRA_NEXTHOP_TYPE_IPV6_IFINDEX,	"IPv6 IFIndex" },
	{ ZEBRA_NEXTHOP_TYPE_IPV6_IFNAME,	"IPv6 IFName" },
	{ ZEBRA_NEXTHOP_TYPE_BLACKHOLE,		"Blackhole" },
	{ 0,					NULL },
};

/* FRR NextHop Types */
#define FRR_NEXTHOP_TYPE_IFINDEX         0x01
#define FRR_NEXTHOP_TYPE_IPV4            0x02
#define FRR_NEXTHOP_TYPE_IPV4_IFINDEX    0x03
#define FRR_NEXTHOP_TYPE_IPV6            0x04
#define FRR_NEXTHOP_TYPE_IPV6_IFINDEX    0x05
#define FRR_NEXTHOP_TYPE_BLACKHOLE       0x06
static const value_string frr_nht[] = {
	{ FRR_NEXTHOP_TYPE_IFINDEX,		"IFIndex" },
	{ FRR_NEXTHOP_TYPE_IPV4,		"IPv4" },
	{ FRR_NEXTHOP_TYPE_IPV4_IFINDEX,	"IPv4 IFIndex" },
	{ FRR_NEXTHOP_TYPE_IPV6,		"IPv6" },
	{ FRR_NEXTHOP_TYPE_IPV6_IFINDEX,	"IPv6 IFIndex" },
	{ FRR_NEXTHOP_TYPE_BLACKHOLE,		"Blackhole" },
	{ 0,					NULL },
};

/* Subsequent Address Family Identifier. */
#define ZEBRA_SAFI_UNICAST              1
#define ZEBRA_SAFI_MULTICAST            2
#define ZEBRA_SAFI_RESERVED_3           3
#define ZEBRA_SAFI_MPLS_VPN             4

static const value_string safi[] = {
	{ ZEBRA_SAFI_UNICAST,			"Unicast" },
	{ ZEBRA_SAFI_MULTICAST,			"Multicast" },
	{ ZEBRA_SAFI_RESERVED_3,		"Reserved" },
	{ ZEBRA_SAFI_MPLS_VPN,			"MPLS VPN" },
	{ 0,					NULL },
};

enum blackhole_type {
	BLACKHOLE_UNSPEC = 0,
	BLACKHOLE_NULL,
	BLACKHOLE_REJECT,
	BLACKHOLE_ADMINPROHIB,
};

static const value_string blackhole_type[] = {
	{ BLACKHOLE_UNSPEC,			"Unspec" },
	{ BLACKHOLE_NULL,			"NULL" },
	{ BLACKHOLE_REJECT,			"Reject" },
	{ BLACKHOLE_ADMINPROHIB,		"Administrative Prohibit" },
	{ 0,					NULL},
};

#define INTERFACE_NAMSIZ      20

#define PSIZE(a) (((a) + 7) / (8))

typedef struct _zebra_header_t {
	guint16 len;
	guint16 command;
	guint8  version;

} zebra_header_t;

static int
zebra_route_nexthop(proto_tree *tree, gboolean request, tvbuff_t *tvb,
		    int offset, guint16 len, guint8 family, guint8 version)
{
	guint8 nexthoptype = 0, interfacenamelength;
	guint16 nexthopcount;
	if (version < 5) {
		nexthopcount = tvb_get_guint8(tvb, offset);
		proto_tree_add_uint(tree, hf_zebra_nexthopnum, tvb, offset, 1,
				    nexthopcount);
		offset += 1;
	} else {
		nexthopcount = tvb_get_ntohs(tvb, offset);
		proto_tree_add_uint(tree, hf_zebra_nexthopnum_u16, tvb, offset,
				    2, nexthopcount);
		offset += 2;
	}

	if (nexthopcount > len)
		return offset; /* Sanity */

	while (nexthopcount--) {
		if (version > 4) {
			proto_tree_add_item(tree, hf_zebra_vrfid, tvb, offset,
					    4, ENC_BIG_ENDIAN);
			offset += 4;
		}
		if (version < 4 && request) { /* Quagga */
			nexthoptype = tvb_get_guint8(tvb, offset);
			proto_tree_add_item(tree, hf_zebra_nexthoptype, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			offset += 1;
		} else if (version >= 4) { /* FRR */
			nexthoptype = tvb_get_guint8(tvb, offset);
			proto_tree_add_item(tree, hf_zebra_nexthoptype_frr, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			offset += 1;
		}
		if ((version < 4 &&
		     ((request &&
		       (nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV4 ||
			nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV4_IFINDEX ||
			nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV4_IFNAME)) ||
		      (!request && family == ZEBRA_FAMILY_IPV4))) ||
		    (version >= 4 &&
		     (nexthoptype == FRR_NEXTHOP_TYPE_IPV4 ||
		      nexthoptype == FRR_NEXTHOP_TYPE_IPV4_IFINDEX))) {
			proto_tree_add_item(tree, hf_zebra_nexthop4, tvb,
					    offset, 4, ENC_NA);
			offset += 4;
		}
		if ((version < 4 &&
		     ((request &&
		       (nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV6 ||
			nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV6_IFINDEX ||
			nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV6_IFNAME)) ||
		      (!request && family == ZEBRA_FAMILY_IPV6))) ||
		    (version >= 4 &&
		     (nexthoptype == FRR_NEXTHOP_TYPE_IPV6 ||
		      nexthoptype == FRR_NEXTHOP_TYPE_IPV6_IFINDEX))) {
			proto_tree_add_item(tree, hf_zebra_nexthop6, tvb,
					    offset, 16, ENC_NA);
			offset += 16;
		}
		if (nexthoptype == ZEBRA_NEXTHOP_TYPE_IFINDEX ||
		    (version < 4 &&
		     (nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV4_IFINDEX ||
		      nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV6_IFINDEX)) ||
		    (version >= 4 &&
		     (nexthoptype == FRR_NEXTHOP_TYPE_IPV4_IFINDEX ||
		      nexthoptype == FRR_NEXTHOP_TYPE_IPV6_IFINDEX))) {
			proto_tree_add_item(tree, hf_zebra_index, tvb, offset,
					    4, ENC_BIG_ENDIAN);
			offset += 4;
		}

		if (version < 4 &&
		    (nexthoptype == ZEBRA_NEXTHOP_TYPE_IFNAME ||
		     nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV4_IFNAME ||
		     nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV6_IFNAME)) {
			interfacenamelength = tvb_get_guint8(tvb, offset);
			offset += 1;
			proto_tree_add_item(tree, hf_zebra_interface, tvb,
					    offset, interfacenamelength,
					    ENC_ASCII | ENC_NA);
			offset += interfacenamelength;
		}
		if (version > 4 &&
		    (nexthoptype == FRR_NEXTHOP_TYPE_BLACKHOLE)) {
			proto_tree_add_item(tree, hf_zebra_bhtype, tvb, offset,
					    1, ENC_BIG_ENDIAN);
			offset += 1;
		}
	}
	return offset;
}

static int
zebra_route_ifindex(proto_tree *tree, tvbuff_t *tvb, int offset, guint16 len)
{
	guint16 indexcount = tvb_get_guint8(tvb, offset);
	proto_tree_add_uint(tree, hf_zebra_indexnum,
			    tvb, offset, 1, indexcount);
	offset += 1;
	if (indexcount > len)
		return offset; /* Sanity */

	while (indexcount--) {
		proto_tree_add_item(tree, hf_zebra_index, tvb, offset, 4,
				ENC_BIG_ENDIAN);
		offset += 4;
	}
	return offset;
}

static int
zebra_route_message(proto_tree *tree, tvbuff_t *tvb, int offset, guint8 version)
{
	static int * const flags[] = {
		&hf_zebra_msg_nexthop,
		&hf_zebra_msg_index,
		&hf_zebra_msg_distance,
		&hf_zebra_msg_metric,
		&hf_zebra_msg_mtu,
		&hf_zebra_msg_tag,
		NULL
	};
	static int * const flags4[] = {
		&hf_zebra_msg_nexthop,
		&hf_zebra_msg_index,
		&hf_zebra_msg_distance,
		&hf_zebra_msg_metric,
		&hf_zebra_msg4_tag,
		&hf_zebra_msg4_mtu,
		&hf_zebra_msg4_srcpfx,
		NULL
	};
	static int * const flags5[] = {
		&hf_zebra_msg_nexthop,
		&hf_zebra_msg5_distance,
		&hf_zebra_msg5_metric,
		&hf_zebra_msg5_tag,
		&hf_zebra_msg5_mtu,
		&hf_zebra_msg5_srcpfx,
		&hf_zebra_msg_label,
		&hf_zebra_msg_tableid,
		NULL
	};
	if (version < 4) {
		proto_tree_add_bitmask(tree, tvb, offset, hf_zebra_message,
				       ett_message, flags, ENC_NA);
	} else if (version == 4) {
		proto_tree_add_bitmask(tree, tvb, offset, hf_zebra_message4,
				       ett_message, flags4, ENC_NA);
	} else {
		proto_tree_add_bitmask(tree, tvb, offset, hf_zebra_message5,
				       ett_message, flags5, ENC_NA);
	}

	offset += 1;

	return offset;
}

static int
zebra_route(proto_tree *tree, gboolean request, tvbuff_t *tvb, int offset,
	    guint16 len, guint8 family, guint16 command, guint8 version)
{
	guint32 prefix4, srcprefix4, rtflags = 0;
	guint8  message, prefixlen, buffer6[16], srcprefixlen, srcbuffer6[16];

	if (version == 0) {
		proto_tree_add_item(tree, hf_zebra_type_v0, tvb,
				    offset, 1, ENC_BIG_ENDIAN);
	} else if (version < 4) {
		proto_tree_add_item(tree, hf_zebra_type_v1, tvb,
				    offset, 1, ENC_BIG_ENDIAN);
	} else if (version == 4) {
		proto_tree_add_item(tree, hf_zebra_type_v4, tvb,
				    offset, 1, ENC_BIG_ENDIAN);
	} else {
		proto_tree_add_item(tree, hf_zebra_type_v5, tvb,
				    offset, 1, ENC_BIG_ENDIAN);
	}
	offset += 1;

	if (version > 3) {
		proto_tree_add_item(tree, hf_zebra_instance, tvb, offset, 2,
				    ENC_BIG_ENDIAN);
		offset += 2;
		rtflags = tvb_get_ntohl(tvb, offset);
		proto_tree_add_item(tree, hf_zebra_rtflags_u32, tvb, offset, 4,
				    ENC_BIG_ENDIAN);
		offset += 4;
	} else {
		proto_tree_add_item(tree, hf_zebra_rtflags, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
		offset += 1;
	}

	message = tvb_get_guint8(tvb, offset);
	offset = zebra_route_message(tree, tvb, offset, version);

	if (version > 1 && version < 5) {
		/* version 2 added safi */
		if (((version == 2 || version == 3) && request)||
		    (version == 4 && (command == FRR_ZAPI4_IPV4_ROUTE_ADD ||
				      command == FRR_ZAPI4_IPV4_ROUTE_DELETE ||
				      command == FRR_ZAPI4_IPV6_ROUTE_ADD ||
				      command == FRR_ZAPI4_IPV6_ROUTE_DELETE))) {
			proto_tree_add_item(tree, hf_zebra_route_safi, tvb,
					    offset, 2, ENC_BIG_ENDIAN);
			offset += 2;
		}
	} else if (version >= 5) {
		/* version 5: safi is 1 byte */
		proto_tree_add_item(tree, hf_zebra_route_safi_u8, tvb, offset,
				    1, ENC_BIG_ENDIAN);
		offset += 1;
		if ((version == 5 &&rtflags & ZEBRA_FLAG_EVPN_ROUTE) ||
		    (version > 5 &&rtflags & FRR_ZAPI6_FLAG_EVPN_ROUTE)) {
			proto_tree_add_item(tree, hf_zebra_rmac, tvb, offset, 6,
					    ENC_NA);
			offset += 6;
		}
		family = tvb_get_guint8(tvb, offset);
		proto_tree_add_item(tree, hf_zebra_family, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
		offset += 1;
	}

	prefixlen = tvb_get_guint8(tvb, offset);
	proto_tree_add_uint(tree, hf_zebra_prefixlen, tvb,
			    offset, 1, prefixlen);
	offset += 1;

	if (family == ZEBRA_FAMILY_IPV6) {
		memset(buffer6, '\0', sizeof buffer6);
		tvb_memcpy(tvb, buffer6, offset,
			   MIN((unsigned) PSIZE(prefixlen), sizeof buffer6));
		proto_tree_add_ipv6(tree, hf_zebra_prefix6,
				    tvb, offset, PSIZE(prefixlen), (ws_in6_addr *)buffer6);
	} else if (family == ZEBRA_FAMILY_IPV4) {
		prefix4 = 0;
		tvb_memcpy(tvb, (guint8 *)&prefix4, offset,
			   MIN((unsigned) PSIZE(prefixlen), sizeof prefix4));
		proto_tree_add_ipv4(tree, hf_zebra_prefix4,
				    tvb, offset, PSIZE(prefixlen), prefix4);
	}
	offset += PSIZE(prefixlen);

	if ((version == 4 && family == ZEBRA_FAMILY_IPV6 &&
	     message & FRR_ZAPI4_MESSAGE_SRCPFX) ||
	    (version > 4 && message & FRR_ZAPI5_MESSAGE_SRCPFX)) {
		srcprefixlen = tvb_get_guint8(tvb, offset);
		proto_tree_add_uint(tree, hf_zebra_srcprefixlen, tvb, offset, 1,
				    srcprefixlen);
		offset += 1;

		if (family == ZEBRA_FAMILY_IPV6) {
			memset(srcbuffer6, '\0', sizeof srcbuffer6);
			tvb_memcpy(tvb, srcbuffer6, offset,
				   MIN((unsigned)PSIZE(srcprefixlen),
				       sizeof srcbuffer6));
			proto_tree_add_ipv6(tree, hf_zebra_srcprefix6, tvb,
					    offset, PSIZE(srcprefixlen),
					    (ws_in6_addr *)srcbuffer6);
		} else if (family == ZEBRA_FAMILY_IPV4) {
			prefix4 = 0;
			tvb_memcpy(tvb, (guint8 *)&srcprefix4, offset,
				   MIN((unsigned)PSIZE(srcprefixlen),
				       sizeof srcprefix4));
			proto_tree_add_ipv4(tree, hf_zebra_srcprefix4, tvb,
					    offset, PSIZE(srcprefixlen),
					    srcprefix4);
		}
		offset += PSIZE(srcprefixlen);
	}

	if (message & ZEBRA_ZAPI_MESSAGE_NEXTHOP) {
		if (version == 4 &&
		    (command == FRR_ZAPI4_REDISTRIBUTE_IPV4_ADD ||
		     command == FRR_ZAPI4_REDISTRIBUTE_IPV4_DEL)) {
			proto_tree_add_item(tree, hf_zebra_nexthopnum, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			offset += 1;
			proto_tree_add_item(tree, hf_zebra_nexthop4, tvb,
					    offset, 4, ENC_NA);
			offset += 4;
		} else if (version == 4 &&
			   (command == FRR_ZAPI4_REDISTRIBUTE_IPV6_ADD ||
			    command == FRR_ZAPI4_REDISTRIBUTE_IPV6_DEL)) {
			proto_tree_add_item(tree, hf_zebra_nexthopnum, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			offset += 1;
			proto_tree_add_item(tree, hf_zebra_nexthop6, tvb,
					    offset, 16, ENC_NA);
			offset += 16;
		} else {
			offset = zebra_route_nexthop(tree, request, tvb, offset,
						     len, family, version);
		}
	}
	if (version < 5 && message & ZEBRA_ZAPI_MESSAGE_IFINDEX) {
		offset = zebra_route_ifindex(tree, tvb, offset, len);
	}
	if ((version < 5 && message & ZEBRA_ZAPI_MESSAGE_DISTANCE) ||
	    (version >= 5 && message & FRR_ZAPI5_MESSAGE_DISTANCE)) {
		proto_tree_add_item(tree, hf_zebra_distance,
				    tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;
	}
	if ((version < 5 && message & ZEBRA_ZAPI_MESSAGE_METRIC) ||
	    (version >= 5 && message & FRR_ZAPI5_MESSAGE_METRIC)) {
		proto_tree_add_item(tree, hf_zebra_metric,
				    tvb, offset, 4, ENC_BIG_ENDIAN);
		offset += 4;
	}
	if ((version < 4 && message & ZEBRA_ZAPI_MESSAGE_MTU) ||
	    (version == 4 && message & FRR_ZAPI4_MESSAGE_MTU) ||
	    (version > 4 && message & FRR_ZAPI5_MESSAGE_MTU)) {
		proto_tree_add_item(tree, hf_zebra_mtu,
				    tvb, offset, 4, ENC_BIG_ENDIAN);
		offset += 4;
	}
	if ((version < 4 && message & ZEBRA_ZAPI_MESSAGE_TAG) ||
	    (version == 4 && message & FRR_ZAPI4_MESSAGE_TAG) ||
	    (version > 4 && message & FRR_ZAPI5_MESSAGE_TAG)) {
		proto_tree_add_item(tree, hf_zebra_tag,
				    tvb, offset, 4, ENC_BIG_ENDIAN);
		offset += 4;
	}
	if (version > 4 && message & FRR_ZAPI5_MESSAGE_TABLEID) {
		proto_tree_add_item(tree, hf_zebra_tableid,
				    tvb, offset, 4, ENC_BIG_ENDIAN);
		offset += 4;
	}
	return offset;
}

static int
zebra_interface_address(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	guint8 family;
	proto_tree_add_item(tree, hf_zebra_index, tvb,
			    offset, 4, ENC_BIG_ENDIAN);
	offset += 4;
	proto_tree_add_item(tree, hf_zebra_flags, tvb,
			    offset, 1, ENC_BIG_ENDIAN);
	offset += 1;
	proto_tree_add_item(tree, hf_zebra_family, tvb,
			    offset, 1, ENC_BIG_ENDIAN);
	family = tvb_get_guint8(tvb, offset);
	offset += 1;
	if (family == ZEBRA_FAMILY_IPV4) {
		proto_tree_add_item(tree, hf_zebra_prefix4,
				    tvb, offset, 4, ENC_BIG_ENDIAN);
		offset += 4;
	}
	else if (family == ZEBRA_FAMILY_IPV6) {
		proto_tree_add_item(tree, hf_zebra_prefix6,
				    tvb, offset, 16, ENC_NA);
		offset += 16;
	}
	else
		return offset;

	proto_tree_add_item(tree, hf_zebra_prefixlen, tvb,
			    offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	if (family == ZEBRA_FAMILY_IPV4) {
		proto_tree_add_item(tree, hf_zebra_dest4,
				    tvb, offset, 4, ENC_BIG_ENDIAN);
		offset += 4;
	}
	else if (family == ZEBRA_FAMILY_IPV6) {
		proto_tree_add_item(tree, hf_zebra_dest6,
				    tvb, offset, 16, ENC_NA);
		offset += 16;
	}
	return offset;
}

static int zebra_hello(proto_tree *tree, tvbuff_t *tvb, int offset, int left,
		       guint8 version)
{
	proto_tree_add_item(tree, hf_zebra_redist_default, tvb, offset, 1,
			    ENC_BIG_ENDIAN);
	offset += 1;
	if (version > 3) {
		proto_tree_add_item(tree, hf_zebra_instance, tvb, offset, 2,
				    ENC_BIG_ENDIAN);
		offset += 2;
	}

	if (version > 4 && left > offset) {
		proto_tree_add_item(tree, hf_zebra_receive_notify, tvb, offset,
				    1, ENC_BIG_ENDIAN);
		offset += 1;
	}
	return offset;
}

static int zebra_redistribute(proto_tree *tree, tvbuff_t *tvb, int offset,
			      guint8 version)
{
	if (version > 3) {
		proto_tree_add_item(tree, hf_zebra_afi, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
		offset += 1;
	}
	if (version == 0) {
		proto_tree_add_item(tree, hf_zebra_type_v0, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
	} else if (version < 4) {
		proto_tree_add_item(tree, hf_zebra_type_v1, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
	} else if (version == 4) {
		proto_tree_add_item(tree, hf_zebra_type_v4, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
	} else {
		proto_tree_add_item(tree, hf_zebra_type_v5, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
	}
	offset += 1;
	if (version > 3) {
		proto_tree_add_item(tree, hf_zebra_instance, tvb, offset, 2,
				    ENC_BIG_ENDIAN);
		offset += 2;
	}

	return offset;
}

static int zebra_vrf(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	proto_tree_add_item(tree, hf_zebra_vrf_table_id, tvb, offset, 4,
			    ENC_BIG_ENDIAN);
	offset += 4;
	proto_tree_add_item(tree, hf_zebra_vrf_netns_name, tvb, offset, 16,
			    ENC_ASCII | ENC_NA);
	offset += 16;
	proto_tree_add_item(tree, hf_zebra_vrf_name, tvb, offset, 36,
			    ENC_ASCII | ENC_NA);
	offset += 36;
	return offset;
}

static int zebra_label_manager_connect(proto_tree *tree, tvbuff_t *tvb,
				       int offset)
{
	proto_tree_add_item(tree, hf_zebra_proto, tvb, offset, 1,
			    ENC_BIG_ENDIAN);
	offset += 1;
	proto_tree_add_item(tree, hf_zebra_instance, tvb, offset, 2,
			    ENC_BIG_ENDIAN);
	offset += 2;
	return offset;
}

static int zebra_get_label_chunk(proto_tree *tree, gboolean request,
				 tvbuff_t *tvb, int offset)
{
	proto_tree_add_item(tree, hf_zebra_proto, tvb, offset, 1,
			    ENC_BIG_ENDIAN);
	offset += 1;
	proto_tree_add_item(tree, hf_zebra_instance, tvb, offset, 2,
			    ENC_BIG_ENDIAN);
	offset += 2;
	proto_tree_add_item(tree, hf_zebra_label_chunk_keep, tvb, offset, 1,
			    ENC_BIG_ENDIAN);
	offset += 1;
	if (request) {
		proto_tree_add_item(tree, hf_zebra_label_chunk_size, tvb,
				    offset, 4, ENC_BIG_ENDIAN);
		offset += 4;
	} else {
		proto_tree_add_item(tree, hf_zebra_label_chunk_start, tvb,
				    offset, 4, ENC_BIG_ENDIAN);
		offset += 4;
		proto_tree_add_item(tree, hf_zebra_label_chunk_end, tvb, offset,
				    4, ENC_BIG_ENDIAN);
		offset += 4;
	}

	return offset;
}

static int zebra_capabilties(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	proto_tree_add_item(tree, hf_zebra_mpls_enabled, tvb, offset, 1,
			    ENC_BIG_ENDIAN);
	offset += 1;
	proto_tree_add_item(tree, hf_zebra_multipath_num, tvb, offset, 4,
			    ENC_BIG_ENDIAN);
	offset += 4;
	return offset;
}

static int zebra_nexthop_register(proto_tree *tree, tvbuff_t *tvb, int offset,
				  guint16 len, int msg_offset)
{
	int     init_offset = offset, rest = (int)len - msg_offset;
	guint16 family = ZEBRA_FAMILY_UNSPEC;
	while (rest > offset - init_offset) {
		proto_tree_add_item(tree, hf_zebra_flags, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
		offset += 1;
		family = tvb_get_ntohs(tvb, offset);
		proto_tree_add_item(tree, hf_zebra_family, tvb, offset, 2,
				    ENC_BIG_ENDIAN);
		offset += 2;
		proto_tree_add_item(tree, hf_zebra_prefixlen, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
		offset += 1;
		if (family == ZEBRA_FAMILY_IPV6) {
			proto_tree_add_item(tree, hf_zebra_prefix6, tvb, offset,
					    16, ENC_NA);
			offset += 16;
		} else if (family == ZEBRA_FAMILY_IPV4) {
			proto_tree_add_item(tree, hf_zebra_prefix4, tvb, offset,
					    4, ENC_BIG_ENDIAN);
			offset += 4;
		}
	}
	return offset;
}

static int
zebra_interface(proto_tree *tree, tvbuff_t *tvb, int offset,
		guint16 command, guint8 version)
{
	gint maclen;
	proto_tree_add_item(tree, hf_zebra_interface,
			    tvb, offset, INTERFACE_NAMSIZ, ENC_ASCII);
	offset += INTERFACE_NAMSIZ;
	proto_tree_add_item(tree, hf_zebra_index, tvb,
			    offset, 4, ENC_BIG_ENDIAN);
	offset += 4;
	proto_tree_add_item(tree, hf_zebra_intstatus, tvb,
			    offset, 1, ENC_BIG_ENDIAN);
	offset += 1;
	if (version != 0) {
		proto_tree_add_item(tree, hf_zebra_intflags, tvb,
				    offset, 8, ENC_BIG_ENDIAN);
		offset += 8;
	} else {
		proto_tree_add_item(tree, hf_zebra_intflags, tvb,
				    offset, 4, ENC_BIG_ENDIAN);
		offset += 4;
	}
	if (version >= 4) {
		proto_tree_add_item(tree, hf_zebra_ptmenable, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
		offset += 1;
		proto_tree_add_item(tree, hf_zebra_ptmstatus, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
		offset += 1;
	}
	proto_tree_add_item(tree, hf_zebra_metric, tvb, offset, 4,
			    ENC_BIG_ENDIAN);
	offset += 4;
	if (version >= 4) {
		proto_tree_add_item(tree, hf_zebra_speed, tvb, offset, 4,
				    ENC_BIG_ENDIAN);
		offset += 4;
	}
	proto_tree_add_item(tree, hf_zebra_mtu, tvb,
			    offset, 4, ENC_BIG_ENDIAN);
	offset += 4;
	if (version != 0) {
		proto_tree_add_item(tree, hf_zebra_mtu6, tvb,
				    offset, 4, ENC_BIG_ENDIAN);
		offset += 4;
	}
	proto_tree_add_item(tree, hf_zebra_bandwidth, tvb,
			    offset, 4, ENC_BIG_ENDIAN);
	offset += 4;
	if (version > 2 || (version <= 2 && command == ZEBRA_INTERFACE_ADD)) {
		if (version > 2) {
			proto_tree_add_item(tree, hf_zebra_lltype, tvb,
					    offset, 4, ENC_BIG_ENDIAN);
			offset += 4;
		}
		if (version != 0) {
			maclen = (gint)tvb_get_ntohl(tvb, offset);
			proto_tree_add_item(tree, hf_zebra_maclen, tvb,
					    offset, 4, ENC_BIG_ENDIAN);
			offset += 4;
			if (maclen > 0)
				proto_tree_add_item(tree, hf_zebra_mac, tvb,
						    offset, maclen, ENC_NA);
			offset += maclen;
		}
		if (version > 2) {
			proto_tree_add_item(tree, hf_zebra_haslinkparam, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			offset += 1;
		}
	}
	return offset;
}

static int
zebra_nexthop_lookup(proto_tree *tree, gboolean request, tvbuff_t *tvb,
		     int offset, guint16 len, guint8 family, guint8 version)
{
	if (family == ZEBRA_FAMILY_IPV6) {
		proto_tree_add_item(tree, hf_zebra_dest6, tvb, offset, 16,
				    ENC_NA);
		offset += 16;
	}else {
		proto_tree_add_item(tree, hf_zebra_dest4, tvb, offset, 4,
				    ENC_BIG_ENDIAN);
		offset += 4;
	}
	if (!request) {
		proto_tree_add_item(tree, hf_zebra_metric,tvb, offset, 4,
				    ENC_BIG_ENDIAN);
		offset += 4;
		offset = zebra_route_nexthop(tree, request, tvb, offset, len,
					     family, version);
	}
	return offset;
}

static int
zerba_router_update(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	proto_tree_add_item(tree, hf_zebra_routeridfamily, tvb, offset, 1,
			    ENC_BIG_ENDIAN);
	offset += 1;
	proto_tree_add_item(tree, hf_zebra_routeridaddress, tvb,
			    offset, 4, ENC_BIG_ENDIAN);
	offset += 4;
	proto_tree_add_item(tree, hf_zebra_routeridmask, tvb,
			    offset, 1, ENC_BIG_ENDIAN);
	offset += 1;
	return offset;
}

static int
zebra_nexthop_update(proto_tree *tree, tvbuff_t *tvb, int offset,
		     guint8 version)
{
	guint16 family = tvb_get_ntohs(tvb, offset);
	guint8  prefixlen, nexthopcount, nexthoptype, labelnum;
	proto_tree_add_item(tree, hf_zebra_family, tvb, offset, 2,
			    ENC_BIG_ENDIAN);
	offset += 2;
	prefixlen = tvb_get_guint8(tvb, offset);
	proto_tree_add_uint(tree, hf_zebra_prefixlen, tvb, offset, 1,
			    prefixlen);
	offset += 1;
	if (family == ZEBRA_FAMILY_IPV6) {
		proto_tree_add_item(tree, hf_zebra_prefix6, tvb, offset, 16,
				    ENC_NA);
		offset += 16;
	} else if (family == ZEBRA_FAMILY_IPV4) {
		proto_tree_add_item(tree, hf_zebra_prefix4, tvb, offset, 4,
				    ENC_BIG_ENDIAN);
		offset += 4;
	}

	if (version > 4) {
		proto_tree_add_item(tree, hf_zebra_type_v5, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
		offset += 1;
	}

	if (version > 4) {
		proto_tree_add_item(tree, hf_zebra_instance, tvb, offset, 2,
				    ENC_BIG_ENDIAN);
		offset += 2;
	}
	if (version > 3) {
		proto_tree_add_item(tree, hf_zebra_distance, tvb, offset, 1,
				    ENC_BIG_ENDIAN);
		offset += 1;
	}

	proto_tree_add_item(tree, hf_zebra_metric, tvb, offset, 4,
			    ENC_BIG_ENDIAN);
	offset += 4;

	nexthopcount = tvb_get_guint8(tvb, offset);
	proto_tree_add_uint(tree, hf_zebra_nexthopnum, tvb, offset, 1,
			    nexthopcount);
	offset += 1;

	while (nexthopcount--) {
		nexthoptype = tvb_get_guint8(tvb, offset);
		if (version > 3) {
			proto_tree_add_item(tree, hf_zebra_nexthoptype_frr, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
		} else {
			proto_tree_add_item(tree, hf_zebra_nexthoptype, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
		}
		offset += 1;

		if ((version < 4 &&
		     (nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV6 ||
		      nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV6_IFINDEX ||
		      nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV6_IFNAME)) ||
		    (version >= 4 &&
		     (nexthoptype == FRR_NEXTHOP_TYPE_IPV6 ||
		      nexthoptype == FRR_NEXTHOP_TYPE_IPV6_IFINDEX))) {
			proto_tree_add_item(tree, hf_zebra_nexthop6, tvb,
					    offset, 16, ENC_NA);
			offset += 16;
		}
		if ((version < 4 &&
		     (nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV4 ||
		      nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV4_IFINDEX ||
		      nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV4_IFNAME)) ||
		    (version >= 4 &&
		     (nexthoptype == FRR_NEXTHOP_TYPE_IPV4 ||
		      nexthoptype == FRR_NEXTHOP_TYPE_IPV4_IFINDEX))) {
			proto_tree_add_item(tree, hf_zebra_nexthop4, tvb,
					    offset, 4, ENC_NA);
			offset += 4;
		}
		if (nexthoptype == ZEBRA_NEXTHOP_TYPE_IFINDEX ||
		    (version < 4 &&
		     (nexthoptype == ZEBRA_NEXTHOP_TYPE_IFNAME ||
		      nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV4_IFINDEX ||
		      nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV4_IFNAME ||
		      nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV6_IFINDEX ||
		      nexthoptype == ZEBRA_NEXTHOP_TYPE_IPV6_IFNAME)) ||
		    (version >= 4 &&
		     (nexthoptype == FRR_NEXTHOP_TYPE_IPV4 ||
		      nexthoptype == FRR_NEXTHOP_TYPE_IPV4_IFINDEX ||
		      nexthoptype == FRR_NEXTHOP_TYPE_IPV6 ||
		      nexthoptype == FRR_NEXTHOP_TYPE_IPV6_IFINDEX))) {
			proto_tree_add_item(tree, hf_zebra_index, tvb, offset,
					    4, ENC_BIG_ENDIAN);
			offset += 4;
		}
		if (version > 4) {
			labelnum = tvb_get_guint8(tvb, offset);
			proto_tree_add_uint(tree, hf_zebra_labelnum, tvb,
					    offset, 1, labelnum);
			offset += 1;
			while (labelnum--) {
				proto_tree_add_item(tree, hf_zebra_label, tvb,
						    offset, 4, ENC_BIG_ENDIAN);
				offset += 4;
			}
		}
	}
	return offset;
}

static int
dissect_zebra_request(proto_tree *tree, gboolean request, tvbuff_t *tvb,
		      int offset, int left, guint16 len, guint16 command,
		      guint8 version)
{
	int init_offset = offset;
	proto_tree_add_uint(tree, hf_zebra_len, tvb, offset, 2, len);
	offset += 2;
	if (version != 0) {
		proto_tree_add_item(tree, hf_zebra_marker, tvb, offset, 1, ENC_NA);
		offset += 1;
		proto_tree_add_uint(tree, hf_zebra_version, tvb, offset, 1,
				    version);
		offset += 1;
		if (version == 3 || version == 4) {
			proto_tree_add_item(tree, hf_zebra_vrfid, tvb, offset,
					    2, ENC_BIG_ENDIAN);
			offset += 2;
		} else if (version > 4) {
			proto_tree_add_item(tree, hf_zebra_vrfid, tvb, offset,
					    4, ENC_BIG_ENDIAN);
			offset += 4;
		}
		if (version < 4) {
			proto_tree_add_uint(tree, hf_zebra_command, tvb, offset,
					    2, command);
		} else if (version == 4) {
			proto_tree_add_uint(tree, hf_zebra_command_v4, tvb,
					    offset, 2, command);
		} else if (version == 5) {
			proto_tree_add_uint(tree, hf_zebra_command_v5, tvb,
					    offset, 2, command);
		} else {
			proto_tree_add_uint(tree, hf_zebra_command_v6, tvb,
					    offset, 2, command);
		}
		offset += 2;
	} else {
		proto_tree_add_uint(tree, hf_zebra_command, tvb, offset, 1,
				    command);
		offset += 1;
	}

	if (version < 4) {
		switch (command) {
		case ZEBRA_INTERFACE_ADD:
		case ZEBRA_INTERFACE_DELETE:
		case ZEBRA_INTERFACE_UP:
		case ZEBRA_INTERFACE_DOWN:
			if (request)
				break; /* Request just subscribes to messages */
			offset = zebra_interface(tree, tvb, offset, command,
						 version);
			break;
		case ZEBRA_INTERFACE_ADDRESS_ADD:
		case ZEBRA_INTERFACE_ADDRESS_DELETE:
			offset = zebra_interface_address(tree, tvb, offset);
			break;
		case ZEBRA_IPV4_ROUTE_ADD:
		case ZEBRA_IPV4_ROUTE_DELETE:
			offset = zebra_route(tree, request, tvb, offset, len,
					     ZEBRA_FAMILY_IPV4, command, version);
			break;
		case ZEBRA_IPV6_ROUTE_ADD:
		case ZEBRA_IPV6_ROUTE_DELETE:
			offset = zebra_route(tree, request, tvb, offset, len,
					     ZEBRA_FAMILY_IPV6, command, version);
			break;
		case ZEBRA_REDISTRIBUTE_ADD:
		case ZEBRA_REDISTRIBUTE_DEFAULT_ADD:
			offset = zebra_redistribute(tree, tvb, offset, version);
			break;
		case ZEBRA_IPV4_IMPORT_LOOKUP:
		case ZEBRA_IPV4_NEXTHOP_LOOKUP:
			offset = zebra_nexthop_lookup(tree, request, tvb,
						      offset, len,
						      ZEBRA_FAMILY_IPV4,
						      version);
			break;
		case ZEBRA_IPV6_IMPORT_LOOKUP:
		case ZEBRA_IPV6_NEXTHOP_LOOKUP:
			offset = zebra_nexthop_lookup(tree, request, tvb,
						      offset, len,
						      ZEBRA_FAMILY_IPV6,
						      version);
			break;
		case ZEBRA_ROUTER_ID_UPDATE:
			offset = zerba_router_update(tree, tvb, offset);
			break;
		case ZEBRA_ROUTER_ID_ADD:
		case ZEBRA_ROUTER_ID_DELETE:
		case ZEBRA_REDISTRIBUTE_DEFAULT_DELETE:
			/* nothing to do */
			break;
		case ZEBRA_REDISTRIBUTE_DELETE:
			/* in version 1+, there's a route type field */
			if (version > 0) {
				proto_tree_add_item(tree, hf_zebra_type_v1, tvb,
						    offset, 1, ENC_BIG_ENDIAN);
			}
			break;
		case ZEBRA_HELLO:
			offset = zebra_hello(tree, tvb, offset, left, version);
			break;
		case ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB:
		case ZEBRA_VRF_UNREGISTER:
		case ZEBRA_INTERFACE_LINK_PARAMS:
			break;
		case ZEBRA_NEXTHOP_REGISTER:
		case ZEBRA_NEXTHOP_UNREGISTER:
			offset = zebra_nexthop_register(tree, tvb, offset, len,
							offset - init_offset);
			break;
		case ZEBRA_NEXTHOP_UPDATE:
			offset = zebra_nexthop_update(tree, tvb, offset, version);
			break;
		}
	} else if (version == 4) {
		switch (command) {
		case FRR_ZAPI4_INTERFACE_ADD:
		case FRR_ZAPI4_INTERFACE_UP:
		case FRR_ZAPI4_INTERFACE_DOWN:
		case FRR_ZAPI4_INTERFACE_DELETE:
			if (request)
				break; /* Request just subscribes to messages */
			offset = zebra_interface(tree, tvb, offset, command,
						 version);
			break;
		case FRR_ZAPI4_INTERFACE_ADDRESS_ADD:
		case FRR_ZAPI4_INTERFACE_ADDRESS_DELETE:
			offset = zebra_interface_address(tree, tvb, offset);
			break;
		case FRR_ZAPI4_IPV4_ROUTE_ADD:
		case FRR_ZAPI4_IPV4_ROUTE_DELETE:
		case FRR_ZAPI4_REDISTRIBUTE_IPV4_ADD:
		case FRR_ZAPI4_REDISTRIBUTE_IPV4_DEL:
			offset = zebra_route(tree, request, tvb, offset, len,
					     ZEBRA_FAMILY_IPV4, command,
					     version);
			break;
		case FRR_ZAPI4_IPV6_ROUTE_ADD:
		case FRR_ZAPI4_IPV6_ROUTE_DELETE:
		case FRR_ZAPI4_REDISTRIBUTE_IPV6_ADD:
		case FRR_ZAPI4_REDISTRIBUTE_IPV6_DEL:
			offset = zebra_route(tree, request, tvb, offset, len,
					     ZEBRA_FAMILY_IPV6, command,
					     version);
			break;
		case FRR_ZAPI4_REDISTRIBUTE_ADD:
		case FRR_ZAPI4_REDISTRIBUTE_DEFAULT_ADD:
			offset = zebra_redistribute(tree, tvb, offset, version);
			break;
		case FRR_ZAPI4_ROUTER_ID_UPDATE:
			offset = zerba_router_update(tree, tvb, offset);
			break;
		case FRR_ZAPI4_ROUTER_ID_ADD:
		case FRR_ZAPI4_ROUTER_ID_DELETE:
		case FRR_ZAPI4_REDISTRIBUTE_DEFAULT_DELETE:
			/* nothing to do */
			break;
		case FRR_ZAPI4_REDISTRIBUTE_DELETE:
			proto_tree_add_item(tree, hf_zebra_type_v4, tvb, offset,
					    1, ENC_BIG_ENDIAN);
			offset += 1;
			break;
		case FRR_ZAPI4_HELLO:
			offset = zebra_hello(tree, tvb, offset, left, version);
			break;
		case FRR_ZAPI4_NEXTHOP_REGISTER:
		case FRR_ZAPI4_NEXTHOP_UNREGISTER:
			offset = zebra_nexthop_register(tree, tvb, offset, len,
							offset - init_offset);
			break;
		case FRR_ZAPI4_NEXTHOP_UPDATE:
			offset = zebra_nexthop_update(tree, tvb, offset,
						      version);
			break;
		case FRR_ZAPI4_INTERFACE_NBR_ADDRESS_ADD:
		case FRR_ZAPI4_INTERFACE_NBR_ADDRESS_DELETE:
		case FRR_ZAPI4_INTERFACE_BFD_DEST_UPDATE:
		case FRR_ZAPI4_IMPORT_ROUTE_REGISTER:
		case FRR_ZAPI4_IMPORT_ROUTE_UNREGISTER:
		case FRR_ZAPI4_IMPORT_CHECK_UPDATE:
		case FRR_ZAPI4_IPV4_ROUTE_IPV6_NEXTHOP_ADD:
		case FRR_ZAPI4_BFD_DEST_REGISTER:
		case FRR_ZAPI4_BFD_DEST_DEREGISTER:
		case FRR_ZAPI4_BFD_DEST_UPDATE:
		case FRR_ZAPI4_BFD_DEST_REPLAY:
		case FRR_ZAPI4_VRF_UNREGISTER:
		case FRR_ZAPI4_VRF_ADD:
		case FRR_ZAPI4_VRF_DELETE:
		case FRR_ZAPI4_INTERFACE_VRF_UPDATE:
			break;
		case FRR_ZAPI4_BFD_CLIENT_REGISTER:
			proto_tree_add_item(tree, hf_zebra_pid, tvb, offset, 4,
					    ENC_BIG_ENDIAN);
			offset += 4;
			break;
		case FRR_ZAPI4_INTERFACE_ENABLE_RADV:
		case FRR_ZAPI4_INTERFACE_DISABLE_RADV:
		case FRR_ZAPI4_IPV4_NEXTHOP_LOOKUP_MRIB:
		case FRR_ZAPI4_INTERFACE_LINK_PARAMS:
		case FRR_ZAPI4_MPLS_LABELS_ADD:
		case FRR_ZAPI4_MPLS_LABELS_DELETE:
		case FRR_ZAPI4_IPV4_NEXTHOP_ADD:
		case FRR_ZAPI4_IPV4_NEXTHOP_DELETE:
		case FRR_ZAPI4_IPV6_NEXTHOP_ADD:
		case FRR_ZAPI4_IPV6_NEXTHOP_DELETE:
		case FRR_ZAPI4_IPMR_ROUTE_STATS:
		case FRR_ZAPI4_LABEL_MANAGER_CONNECT:
		case FRR_ZAPI4_GET_LABEL_CHUNK:
		case FRR_ZAPI4_RELEASE_LABEL_CHUNK:
		case FRR_ZAPI4_PW_ADD:
		case FRR_ZAPI4_PW_DELETE:
		case FRR_ZAPI4_PW_SET:
		case FRR_ZAPI4_PW_UNSET:
		case FRR_ZAPI4_PW_STATUS_UPDATE:
			break;
		}
	} else if (version == 5) {
		switch (command) {
		case FRR_ZAPI5_INTERFACE_ADD:
		case FRR_ZAPI5_INTERFACE_UP:
		case FRR_ZAPI5_INTERFACE_DOWN:
		case FRR_ZAPI5_INTERFACE_DELETE:
			if (request)
				break; /* Request just subscribes to messages */
			offset = zebra_interface(tree, tvb, offset, command,
						 version);
			break;
		case FRR_ZAPI5_INTERFACE_ADDRESS_ADD:
		case FRR_ZAPI5_INTERFACE_ADDRESS_DELETE:
			offset = zebra_interface_address(tree, tvb, offset);
			break;
		case FRR_ZAPI5_IPV4_ROUTE_ADD:
		case FRR_ZAPI5_IPV4_ROUTE_DELETE:
			offset = zebra_route(tree, request, tvb, offset, len,
					     ZEBRA_FAMILY_IPV4, command,
					     version);
			break;
		case FRR_ZAPI5_IPV6_ROUTE_ADD:
		case FRR_ZAPI5_IPV6_ROUTE_DELETE:
			offset = zebra_route(tree, request, tvb, offset, len,
					     ZEBRA_FAMILY_IPV6, command,
					     version);
			break;
		case FRR_ZAPI5_ROUTE_ADD:
		case FRR_ZAPI5_ROUTE_DELETE:
		case FRR_ZAPI5_REDISTRIBUTE_ROUTE_ADD:
		case FRR_ZAPI5_REDISTRIBUTE_ROUTE_DEL:
			offset = zebra_route(tree, request, tvb, offset, len,
					     ZEBRA_FAMILY_UNSPEC, command,
					     version);
			break;
		case FRR_ZAPI5_REDISTRIBUTE_ADD:
		case FRR_ZAPI5_REDISTRIBUTE_DEFAULT_ADD:
			offset = zebra_redistribute(tree, tvb, offset, version);
			break;
		case FRR_ZAPI5_ROUTER_ID_UPDATE:
			offset = zerba_router_update(tree, tvb, offset);
			break;
		case FRR_ZAPI5_ROUTER_ID_ADD:
		case FRR_ZAPI5_ROUTER_ID_DELETE:
		case FRR_ZAPI5_REDISTRIBUTE_DEFAULT_DELETE:
			/* nothing to do */
			break;
		case FRR_ZAPI5_REDISTRIBUTE_DELETE:
			proto_tree_add_item(tree, hf_zebra_type_v5, tvb, offset,
					    1, ENC_BIG_ENDIAN);
			offset += 1;
			break;
		case FRR_ZAPI5_HELLO:
			offset = zebra_hello(tree, tvb, offset, left, version);
			break;
		case FRR_ZAPI5_CAPABILITIES:
			offset = zebra_capabilties(tree, tvb, offset);
			break;
		case FRR_ZAPI5_NEXTHOP_REGISTER:
		case FRR_ZAPI5_NEXTHOP_UNREGISTER:
			offset = zebra_nexthop_register(tree, tvb, offset, len,
							offset - init_offset);
			break;
		case FRR_ZAPI5_NEXTHOP_UPDATE:
			offset = zebra_nexthop_update(tree, tvb, offset,
						      version);
			break;
		case FRR_ZAPI5_INTERFACE_NBR_ADDRESS_ADD:
		case FRR_ZAPI5_INTERFACE_NBR_ADDRESS_DELETE:
		case FRR_ZAPI5_INTERFACE_BFD_DEST_UPDATE:
		case FRR_ZAPI5_IMPORT_ROUTE_REGISTER:
		case FRR_ZAPI5_IMPORT_ROUTE_UNREGISTER:
		case FRR_ZAPI5_IMPORT_CHECK_UPDATE:
		case FRR_ZAPI5_IPV4_ROUTE_IPV6_NEXTHOP_ADD:
		case FRR_ZAPI5_BFD_DEST_REGISTER:
		case FRR_ZAPI5_BFD_DEST_DEREGISTER:
		case FRR_ZAPI5_BFD_DEST_UPDATE:
		case FRR_ZAPI5_BFD_DEST_REPLAY:
		case FRR_ZAPI5_VRF_UNREGISTER:
			break;
		case FRR_ZAPI5_VRF_ADD:
			offset = zebra_vrf(tree, tvb, offset);
			break;
		case FRR_ZAPI5_VRF_DELETE:
		case FRR_ZAPI5_VRF_LABEL:
		case FRR_ZAPI5_INTERFACE_VRF_UPDATE:
			break;
		case FRR_ZAPI5_BFD_CLIENT_REGISTER:
			proto_tree_add_item(tree, hf_zebra_pid, tvb, offset, 4,
					    ENC_BIG_ENDIAN);
			offset += 4;
			break;
		case FRR_ZAPI5_INTERFACE_ENABLE_RADV:
		case FRR_ZAPI5_INTERFACE_DISABLE_RADV:
		case FRR_ZAPI5_IPV4_NEXTHOP_LOOKUP_MRIB:
		case FRR_ZAPI5_INTERFACE_LINK_PARAMS:
		case FRR_ZAPI5_MPLS_LABELS_ADD:
		case FRR_ZAPI5_MPLS_LABELS_DELETE:
		case FRR_ZAPI5_IPMR_ROUTE_STATS:
			break;
		case FRR_ZAPI5_LABEL_MANAGER_CONNECT:
		case FRR_ZAPI5_LABEL_MANAGER_CONNECT_ASYNC:
			offset = zebra_label_manager_connect(tree, tvb, offset);
			break;
		case FRR_ZAPI5_GET_LABEL_CHUNK:
			offset =
			    zebra_get_label_chunk(tree, request, tvb, offset);
			break;
		case FRR_ZAPI5_RELEASE_LABEL_CHUNK:
		case FRR_ZAPI5_FEC_REGISTER:
		case FRR_ZAPI5_FEC_UNREGISTER:
		case FRR_ZAPI5_FEC_UPDATE:
		case FRR_ZAPI5_ADVERTISE_DEFAULT_GW:
		case FRR_ZAPI5_ADVERTISE_SUBNET:
		case FRR_ZAPI5_ADVERTISE_ALL_VNI:
		case FRR_ZAPI5_VNI_ADD:
		case FRR_ZAPI5_VNI_DEL:
		case FRR_ZAPI5_L3VNI_ADD:
		case FRR_ZAPI5_L3VNI_DEL:
		case FRR_ZAPI5_REMOTE_VTEP_ADD:
		case FRR_ZAPI5_REMOTE_VTEP_DEL:
		case FRR_ZAPI5_MACIP_ADD:
		case FRR_ZAPI5_MACIP_DEL:
		case FRR_ZAPI5_IP_PREFIX_ROUTE_ADD:
		case FRR_ZAPI5_IP_PREFIX_ROUTE_DEL:
		case FRR_ZAPI5_REMOTE_MACIP_ADD:
		case FRR_ZAPI5_REMOTE_MACIP_DEL:
		case FRR_ZAPI5_PW_ADD:
		case FRR_ZAPI5_PW_DELETE:
		case FRR_ZAPI5_PW_SET:
		case FRR_ZAPI5_PW_UNSET:
		case FRR_ZAPI5_PW_STATUS_UPDATE:
		case FRR_ZAPI5_RULE_ADD:
		case FRR_ZAPI5_RULE_DELETE:
		case FRR_ZAPI5_RULE_NOTIFY_OWNER:
		case FRR_ZAPI5_TABLE_MANAGER_CONNECT:
		case FRR_ZAPI5_GET_TABLE_CHUNK:
		case FRR_ZAPI5_RELEASE_TABLE_CHUNK:
		case FRR_ZAPI5_IPSET_CREATE:
		case FRR_ZAPI5_IPSET_DESTROY:
		case FRR_ZAPI5_IPSET_ENTRY_ADD:
		case FRR_ZAPI5_IPSET_ENTRY_DELETE:
		case FRR_ZAPI5_IPSET_NOTIFY_OWNER:
		case FRR_ZAPI5_IPSET_ENTRY_NOTIFY_OWNER:
		case FRR_ZAPI5_IPTABLE_ADD:
		case FRR_ZAPI5_IPTABLE_DELETE:
		case FRR_ZAPI5_IPTABLE_NOTIFY_OWNER:
			break;
		}
	} else { /* version 6 */
		switch (command) {
		case FRR_ZAPI6_INTERFACE_ADD:
		case FRR_ZAPI6_INTERFACE_UP:
		case FRR_ZAPI6_INTERFACE_DOWN:
		case FRR_ZAPI6_INTERFACE_DELETE:
			if (request)
				break; /* Request just subscribes to messages */
			offset = zebra_interface(tree, tvb, offset, command,
						 version);
			break;
		case FRR_ZAPI6_INTERFACE_ADDRESS_ADD:
		case FRR_ZAPI6_INTERFACE_ADDRESS_DELETE:
			offset = zebra_interface_address(tree, tvb, offset);
			break;
		case FRR_ZAPI6_ROUTE_ADD:
		case FRR_ZAPI6_ROUTE_DELETE:
		case FRR_ZAPI6_REDISTRIBUTE_ROUTE_ADD:
		case FRR_ZAPI6_REDISTRIBUTE_ROUTE_DEL:
			offset = zebra_route(tree, request, tvb, offset, len,
					     ZEBRA_FAMILY_UNSPEC, command,
					     version);
			break;
		case FRR_ZAPI6_REDISTRIBUTE_ADD:
		case FRR_ZAPI6_REDISTRIBUTE_DEFAULT_ADD:
			offset = zebra_redistribute(tree, tvb, offset, version);
			break;
		case FRR_ZAPI6_ROUTER_ID_UPDATE:
			offset = zerba_router_update(tree, tvb, offset);
			break;
		case FRR_ZAPI6_ROUTER_ID_ADD:
		case FRR_ZAPI6_ROUTER_ID_DELETE:
		case FRR_ZAPI6_REDISTRIBUTE_DEFAULT_DELETE:
			/* nothing to do */
			break;
		case FRR_ZAPI6_REDISTRIBUTE_DELETE:
			proto_tree_add_item(tree, hf_zebra_type_v5, tvb, offset,
					    1, ENC_BIG_ENDIAN);
			offset += 1;
			break;
		case FRR_ZAPI6_HELLO:
			offset = zebra_hello(tree, tvb, offset, left, version);
			break;
		case FRR_ZAPI6_CAPABILITIES:
			offset = zebra_capabilties(tree, tvb, offset);
			break;
		case FRR_ZAPI6_NEXTHOP_REGISTER:
		case FRR_ZAPI6_NEXTHOP_UNREGISTER:
			offset = zebra_nexthop_register(tree, tvb, offset, len,
							offset - init_offset);
			break;
		case FRR_ZAPI6_NEXTHOP_UPDATE:
			offset = zebra_nexthop_update(tree, tvb, offset,
						      version);
			break;
		case FRR_ZAPI6_INTERFACE_NBR_ADDRESS_ADD:
		case FRR_ZAPI6_INTERFACE_NBR_ADDRESS_DELETE:
		case FRR_ZAPI6_INTERFACE_BFD_DEST_UPDATE:
		case FRR_ZAPI6_IMPORT_ROUTE_REGISTER:
		case FRR_ZAPI6_IMPORT_ROUTE_UNREGISTER:
		case FRR_ZAPI6_IMPORT_CHECK_UPDATE:
		//case FRR_ZAPI6_IPV4_ROUTE_IPV6_NEXTHOP_ADD:
		case FRR_ZAPI6_BFD_DEST_REGISTER:
		case FRR_ZAPI6_BFD_DEST_DEREGISTER:
		case FRR_ZAPI6_BFD_DEST_UPDATE:
		case FRR_ZAPI6_BFD_DEST_REPLAY:
		case FRR_ZAPI6_VRF_UNREGISTER:
			break;
		case FRR_ZAPI6_VRF_ADD:
			offset = zebra_vrf(tree, tvb, offset);
			break;
		case FRR_ZAPI6_VRF_DELETE:
		case FRR_ZAPI6_VRF_LABEL:
		case FRR_ZAPI6_INTERFACE_VRF_UPDATE:
			break;
		case FRR_ZAPI6_BFD_CLIENT_REGISTER:
			proto_tree_add_item(tree, hf_zebra_pid, tvb, offset, 4,
					    ENC_BIG_ENDIAN);
			offset += 4;
			break;
		case FRR_ZAPI6_BFD_CLIENT_DEREGISTER:
		case FRR_ZAPI6_INTERFACE_ENABLE_RADV:
		case FRR_ZAPI6_INTERFACE_DISABLE_RADV:
		case FRR_ZAPI6_IPV4_NEXTHOP_LOOKUP_MRIB:
		case FRR_ZAPI6_INTERFACE_LINK_PARAMS:
		case FRR_ZAPI6_MPLS_LABELS_ADD:
		case FRR_ZAPI6_MPLS_LABELS_DELETE:
		case FRR_ZAPI6_IPMR_ROUTE_STATS:
			break;
		case FRR_ZAPI6_LABEL_MANAGER_CONNECT:
		case FRR_ZAPI6_LABEL_MANAGER_CONNECT_ASYNC:
			offset = zebra_label_manager_connect(tree, tvb, offset);
			break;
		case FRR_ZAPI6_GET_LABEL_CHUNK:
			offset =
			    zebra_get_label_chunk(tree, request, tvb, offset);
			break;
		case FRR_ZAPI6_RELEASE_LABEL_CHUNK:
		case FRR_ZAPI6_FEC_REGISTER:
		case FRR_ZAPI6_FEC_UNREGISTER:
		case FRR_ZAPI6_FEC_UPDATE:
		case FRR_ZAPI6_ADVERTISE_DEFAULT_GW:
		case FRR_ZAPI6_ADVERTISE_SUBNET:
		case FRR_ZAPI6_ADVERTISE_ALL_VNI:
		case FRR_ZAPI6_LOCAL_ES_ADD:
		case FRR_ZAPI6_LOCAL_ES_DEL:
		case FRR_ZAPI6_VNI_ADD:
		case FRR_ZAPI6_VNI_DEL:
		case FRR_ZAPI6_L3VNI_ADD:
		case FRR_ZAPI6_L3VNI_DEL:
		case FRR_ZAPI6_REMOTE_VTEP_ADD:
		case FRR_ZAPI6_REMOTE_VTEP_DEL:
		case FRR_ZAPI6_MACIP_ADD:
		case FRR_ZAPI6_MACIP_DEL:
		case FRR_ZAPI6_IP_PREFIX_ROUTE_ADD:
		case FRR_ZAPI6_IP_PREFIX_ROUTE_DEL:
		case FRR_ZAPI6_REMOTE_MACIP_ADD:
		case FRR_ZAPI6_REMOTE_MACIP_DEL:
		case FRR_ZAPI6_PW_ADD:
		case FRR_ZAPI6_PW_DELETE:
		case FRR_ZAPI6_PW_SET:
		case FRR_ZAPI6_PW_UNSET:
		case FRR_ZAPI6_PW_STATUS_UPDATE:
		case FRR_ZAPI6_RULE_ADD:
		case FRR_ZAPI6_RULE_DELETE:
		case FRR_ZAPI6_RULE_NOTIFY_OWNER:
		case FRR_ZAPI6_TABLE_MANAGER_CONNECT:
		case FRR_ZAPI6_GET_TABLE_CHUNK:
		case FRR_ZAPI6_RELEASE_TABLE_CHUNK:
		case FRR_ZAPI6_IPSET_CREATE:
		case FRR_ZAPI6_IPSET_DESTROY:
		case FRR_ZAPI6_IPSET_ENTRY_ADD:
		case FRR_ZAPI6_IPSET_ENTRY_DELETE:
		case FRR_ZAPI6_IPSET_NOTIFY_OWNER:
		case FRR_ZAPI6_IPSET_ENTRY_NOTIFY_OWNER:
		case FRR_ZAPI6_IPTABLE_ADD:
		case FRR_ZAPI6_IPTABLE_DELETE:
		case FRR_ZAPI6_IPTABLE_NOTIFY_OWNER:
		case FRR_ZAPI6_VXLAN_FLOOD_CONTROL:
			break;
		}
	}
	return offset;
}

/*
 Zebra Protocol header version 0:
	0                   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
	+-------------------------------+---------------+
	|           Length (2)          |   Command (1) |
	+-------------------------------+---------------+

 Zebra Protocol header version 1, 2:
	0                   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
	+-------------------------------+---------------+-------------+
	|           Length (2)          |   Marker (1)  | Version (1) |
	+-------------------------------+---------------+-------------+
	|          Command (2)          |
	+-------------------------------+

 Version 3, 4:

	 0                   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
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	|             Length            |     Marker    |    Version    |
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	|             VRF ID            |            Command            |
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

 Version 5, 6:

	 0                   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
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	|             Length            |     Marker    |    Version    |
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	|                             VRF ID                            |
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	|            Command            |
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

 The Marker byte in later versions uses reserved command values 0xFF (version
 1-3, Quagga) or 0xFE (version 4-6, FRR) to distinguish later protocol versions
 from version 0.
 */

static gboolean
zebra_get_header(tvbuff_t *tvb, int offset, zebra_header_t *header)
{
	guint16 len, command;
	guint8  version;

	if (tvb_captured_length_remaining(tvb, offset) < 3) {
		return FALSE;
	}

	len = tvb_get_ntohs(tvb, offset);
	if (len < 3) {
		return FALSE;
	}

	offset += 2;
	command = tvb_get_guint8(tvb, offset);
	if (command < 0xFE) { // version 0
		version = 0;
	} else { // not version 0
		offset++;
		if (tvb_captured_length_remaining(tvb, offset) < 3) {
			return FALSE;
		}
		version = tvb_get_guint8(tvb, offset);
		if (version == 1 || version == 2) {
			offset++;
		} else if (version == 3 || version == 4) {
			offset += 3;
		} else if (version < 9) {
			/* The current highest version is 6. Give room
			 * to invent a few more. */
			offset += 5;
		} else {
			return FALSE;
		}
		if (tvb_captured_length_remaining(tvb, offset) < 2) {
			return FALSE;
		}
		command = tvb_get_ntohs(tvb, offset);
	}
	if (header) {
		header->len = len;
		header->command = command;
		header->version = version;
	}
	return TRUE;
}

static gboolean
test_zebra(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
	zebra_header_t header;

	if (!zebra_get_header(tvb, offset, &header)) {
		return FALSE;
	}

	if (header.len > 1024) {
		/* There can be multiple PDUs in a segment, but PDUs themselves
		 * are small. Even 1024 is a generous overestimate.
		 */
		return FALSE;
	}

	if (header.version < 4) {
		if (!try_val_to_str(header.command, messages)) {
			return FALSE;
		}
	} else if (header.version == 4) {
		if (!try_val_to_str(header.command, frr_zapi4_messages)) {
			return FALSE;
		}
	} else if (header.version == 5) {
		if (!try_val_to_str(header.command, frr_zapi5_messages)) {
			return FALSE;
		}
	} else {
		if (!try_val_to_str(header.command, frr_zapi6_messages)) {
			return FALSE;
		}
	}

	return TRUE;
}

static int
dissect_zebra(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
	proto_item	*ti;
	proto_tree	*zebra_tree;
	gboolean	request;
	int		left, offset = 0;

	if (!test_zebra(pinfo, tvb, offset, data)) {
		return 0;
	}

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

	request = (pinfo->destport == pinfo->match_uint);
	left = tvb_reported_length(tvb);

	col_set_str(pinfo->cinfo, COL_INFO,
		    request? "Zebra Request" : "Zebra Reply");

	/* if (tree) */ {
		ti = proto_tree_add_item(tree, proto_zebra, tvb, offset, -1,
					 ENC_NA);
		zebra_tree = proto_item_add_subtree(ti, ett_zebra);
		ti = proto_tree_add_boolean(zebra_tree, hf_zebra_request,
					    tvb, offset, 0, request);
		proto_item_set_hidden(ti);

		for (;;) {
			zebra_header_t header;
			proto_tree	*zebra_request_tree;

			if (!zebra_get_header(tvb, offset, &header)) {
				break;
			}

			if (header.version < 4) {
				col_append_fstr(pinfo->cinfo, COL_INFO, ": %s",
						val_to_str(header.command, messages,
							   "Command Type 0x%02d"));
				ti = proto_tree_add_uint(zebra_tree, hf_zebra_command,
							 tvb, offset, header.len,
							 header.command);
			} else if (header.version == 4) {
				ti = proto_tree_add_uint(zebra_tree, hf_zebra_command_v4,
							 tvb, offset, header.len,
							 header.command);
				col_append_fstr(pinfo->cinfo, COL_INFO, ": %s",
						val_to_str(header.command, frr_zapi4_messages,
							   "Command Type 0x%02d"));
			} else if (header.version == 5) {
				ti = proto_tree_add_uint(zebra_tree, hf_zebra_command_v5,
							 tvb, offset, header.len,
							 header.command);
				col_append_fstr(pinfo->cinfo, COL_INFO, ": %s",
						val_to_str(header.command, frr_zapi5_messages,
							   "Command Type 0x%02d"));
			} else {
				ti = proto_tree_add_uint(zebra_tree, hf_zebra_command_v6,
							 tvb, offset, header.len,
							 header.command);
				col_append_fstr(pinfo->cinfo, COL_INFO, ": %s",
						val_to_str(header.command, frr_zapi6_messages,
							   "Command Type 0x%02d"));
			}
			zebra_request_tree = proto_item_add_subtree(ti,
							ett_zebra_request);
			dissect_zebra_request(zebra_request_tree, request, tvb,
					      offset, left, header.len,
					      header.command, header.version);
			offset += header.len;
			left -= header.len;
		}
	}

	return tvb_captured_length(tvb);
}

void
proto_register_zebra(void)
{

	static hf_register_info hf[] = {
		{ &hf_zebra_len,
		  { "Length",		"zebra.len",
		    FT_UINT16, BASE_DEC, NULL, 0x0,
		    "Length of Zebra request", HFILL }},
		{ &hf_zebra_version,
		  { "Version", 		"zebra.version",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Zebra srv version", HFILL }},
		{ &hf_zebra_marker,
		  { "Marker", 		"zebra.marker",
		    FT_UINT8, BASE_HEX, NULL, 0x0,
		    "Zebra srv marker", HFILL }},
		{ &hf_zebra_request,
		  { "Request",		"zebra.request",
		    FT_BOOLEAN, BASE_NONE, NULL, 0x0,
		    "TRUE if Zebra request", HFILL }},
		{ &hf_zebra_command,
		  { "Command",		"zebra.command",
		    FT_UINT16, BASE_DEC, VALS(messages), 0x0,
		    "Zebra command", HFILL }},
		{ &hf_zebra_interface,
		  { "Interface",		"zebra.interface",
		    FT_STRING, BASE_NONE, NULL, 0x0,
		    "Interface name of Zebra request", HFILL }},
		{ &hf_zebra_index,
		  { "Index",		"zebra.index",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Index of interface", HFILL }},
		{ &hf_zebra_intstatus,
		  { "Status",		"zebra.intstatus",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Status of interface", HFILL}},
		{ &hf_zebra_indexnum,
		  { "Index Number",		"zebra.indexnum",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Number of indices for route", HFILL }},
		{ &hf_zebra_intflags,
		  { "Flags",		"zebra.intflags",
		    FT_UINT64, BASE_DEC, NULL, 0x0,
		    "Flags of interface", HFILL }},
		{ &hf_zebra_rtflags,
		  { "Flags",		"zebra.rtflags",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Flags of route", HFILL }},
		{ &hf_zebra_message,
		  { "Message",		"zebra.message",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Message type of route", HFILL }},
		{ &hf_zebra_route_safi,
		  { "SAFI",		"zebra.safi",
		    FT_UINT16, BASE_DEC, VALS(safi), 0x0,
		    "Subsequent Address Family Identifier", HFILL }},
		{ &hf_zebra_msg_nexthop,
		  { "Message Nexthop",	"zebra.message.nexthop",
		    FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_NEXTHOP,
		    "Message contains nexthop", HFILL }},
		{ &hf_zebra_msg_index,
		  { "Message Index",	"zebra.message.index",
		    FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_IFINDEX,
		    "Message contains index", HFILL }},
		{ &hf_zebra_msg_distance,
		  { "Message Distance",	"zebra.message.distance",
		    FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_DISTANCE,
		    "Message contains distance", HFILL }},
		{ &hf_zebra_msg_metric,
		  { "Message Metric",	"zebra.message.metric",
		    FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_METRIC,
		    "Message contains metric", HFILL }},
		{ &hf_zebra_type_v0,
		  { "Type",			"zebra.type",
		    FT_UINT8, BASE_DEC, VALS(routes_v0), 0x0,
		    "Type of route", HFILL }},
		{ &hf_zebra_type_v1,
		  { "Type",			"zebra.type",
		    FT_UINT8, BASE_DEC, VALS(routes_v1), 0x0,
		    "Type of route", HFILL }},
		{ &hf_zebra_distance,
		  { "Distance",		"zebra.distance",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Distance of route", HFILL }},
		{ &hf_zebra_metric,
		  { "Metric",		"zebra.metric",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Metric of interface or route", HFILL }},
		{ &hf_zebra_mtu,
		  { "MTU",			"zebra.mtu",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "MTU of interface", HFILL }},
		{ &hf_zebra_mtu6,
		  { "MTUv6",		"zebra.mtu6",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "MTUv6 of interface", HFILL }},
		{ &hf_zebra_bandwidth,
		  { "Bandwidth",		"zebra.bandwidth",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Bandwidth of interface", HFILL }},
		{ &hf_zebra_family,
		  { "Family",		"zebra.family",
		    FT_UINT16, BASE_DEC, VALS(families), 0x0,
		    "Family of IP address", HFILL }},
		{ &hf_zebra_flags,
		  { "Flags",		"zebra.flags",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Flags of Address Info", HFILL }},
		{ &hf_zebra_dest4,
		  { "Destination",		"zebra.dest4",
		    FT_IPv4, BASE_NONE, NULL, 0x0,
		    "Destination IPv4 field", HFILL }},
		{ &hf_zebra_dest6,
		  { "Destination",		"zebra.dest6",
		    FT_IPv6, BASE_NONE, NULL, 0x0,
		    "Destination IPv6 field", HFILL }},
		{ &hf_zebra_nexthopnum,
		  { "Nexthop Number",	"zebra.nexthopnum",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Number of nexthops in route", HFILL }},
		{ &hf_zebra_nexthop4,
		  { "Nexthop",		"zebra.nexthop4",
		    FT_IPv4, BASE_NONE, NULL, 0x0,
		    "Nethop IPv4 field of route", HFILL }},
		{ &hf_zebra_nexthop6,
		  { "Nexthop",		"zebra.nexthop6",
		    FT_IPv6, BASE_NONE, NULL, 0x0,
		    "Nethop IPv6 field of route", HFILL }},
		{ &hf_zebra_prefixlen,
		  { "Prefix length",	"zebra.prefixlen",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    NULL, HFILL }},
		{ &hf_zebra_prefix4,
		  { "Prefix",		"zebra.prefix4",
		    FT_IPv4, BASE_NONE, NULL, 0x0,
		    "Prefix IPv4", HFILL }},
		{ &hf_zebra_prefix6,
		  { "Prefix",		"zebra.prefix6",
		    FT_IPv6, BASE_NONE, NULL, 0x0,
		    "Prefix IPv6", HFILL }},
		{ &hf_zebra_routeridaddress,
		  { "Router ID address",	"zebra.routerIDAddress",
		    FT_IPv4, BASE_NONE, NULL, 0x0,
		    "Router ID", HFILL }},
		{ &hf_zebra_routeridmask,
		  { "Router ID mask",	"zebra.routerIDMask",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "netmask of Router ID", HFILL }},
		{ &hf_zebra_mac,
		  { "MAC address",	"zebra.macaddress",
		    FT_ETHER, BASE_NONE, NULL, 0x0,
		    "MAC address of interface", HFILL }},
		{ &hf_zebra_redist_default,
		  { "Redistribute default",		"zebra.redist_default",
		    FT_BOOLEAN,  BASE_NONE, NULL, 0x0,
		    "TRUE if redistribute default", HFILL }},
		{ &hf_zebra_vrfid,
		  { "VRF-ID",		"zebra.vrfid",
		    FT_UINT32, BASE_HEX, NULL, 0x0,
		    "VRF ID", HFILL }},
		{ &hf_zebra_routeridfamily,
		  { "Router ID Family",	"zebra.routeridfamily",
		    FT_UINT8, BASE_DEC, VALS(families), 0x0,
		    "Family of Router ID", HFILL }},
		{ &hf_zebra_nexthoptype,
		  { "Nexthop Type",	"zebra.nexthoptype",
		    FT_UINT8, BASE_DEC, VALS(zebra_nht), 0x0,
		    "Type of Nexthop", HFILL }},
		{ &hf_zebra_msg_mtu,
		  { "Message MTU",	"zebra.message.mtu",
		    FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_MTU,
		    "Message contains MTU", HFILL }},
		{ &hf_zebra_msg_tag,
		  { "Message TAG",	"zebra.message.tag",
		    FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_TAG,
		    "Message contains TAG", HFILL }},
		{ &hf_zebra_tag,
		  { "Tag",		"zebra.tag",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Route Tag", HFILL }},
		{ &hf_zebra_maclen,
		  { "MAC address length", "zebra.maclen",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Length of MAC address of interface", HFILL }},
		{ &hf_zebra_haslinkparam,
		  { "Message has link parameters", "zebra.haslinkparam",
		    FT_BOOLEAN, BASE_NONE, NULL, 0x0,
		    "Interface message has link parameters", HFILL }},
		/* FRRouting, Zebra API v4, v5 and v6 */
		{ &hf_zebra_command_v4,
		  { "Command",		"zebra.command",
		    FT_UINT16, BASE_DEC, VALS(frr_zapi4_messages), 0x0,
		    "Zebra command", HFILL }},
		{ &hf_zebra_command_v5,
		  { "Command",		"zebra.command",
		    FT_UINT16, BASE_DEC, VALS(frr_zapi5_messages), 0x0,
		    "Zebra command", HFILL }},
		{ &hf_zebra_command_v6,
		  { "Command",		"zebra.command",
		    FT_UINT16, BASE_DEC, VALS(frr_zapi6_messages), 0x0,
		    "Zebra command", HFILL }},
		{ &hf_zebra_type_v4,
		  { "Type",		"zebra.type",
		    FT_UINT8, BASE_DEC, VALS(routes_v4), 0x0,
		    "Type of route", HFILL }},
		{ &hf_zebra_type_v5,
		  { "Type",		"zebra.type",
		    FT_UINT8, BASE_DEC, VALS(routes_v5), 0x0,
		    "Type of route", HFILL }},
		{ &hf_zebra_ptmenable,
		  { "PTM Enable",	"zebra.ptmenable",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "PTM (Prescriptive Topology Manager) Enable", HFILL }},
		{ &hf_zebra_ptmstatus,
		  { "PTM Status",	"zebra.ptmstatus",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "PTM (Prescriptive Topology Manager) Status", HFILL }},
		{ &hf_zebra_instance,
		  { "Instance",		"zebra.instance",
		    FT_UINT16, BASE_DEC, NULL, 0x0,
		    "Routing Instance", HFILL }},
		{ &hf_zebra_rtflags_u32,
		  { "Flags",		"zebra.rtflags",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Flags of route", HFILL }},
		{ &hf_zebra_speed,
		  { "Speed",		"zebra.speed",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Speed of interface", HFILL }},
		{ &hf_zebra_lltype,
		  { "LLType",		"zebra.lltype",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Link Layer Type", HFILL }},
		{ &hf_zebra_message4,
		  { "Message",		"zebra.message",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Message type of route", HFILL }},
		{ &hf_zebra_message5,
		  { "Message",		"zebra.message",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Message type of route", HFILL }},
		{ &hf_zebra_route_safi_u8,
		  { "SAFI",		"zebra.safi",
		    FT_UINT8, BASE_DEC, VALS(safi), 0x0,
		    "Subsequent Address Family Identifier", HFILL }},
		{ &hf_zebra_rmac,
		  { "RMAC",		"zebra.rmac",
		    FT_ETHER, BASE_NONE, NULL, 0x0,
		    "Remote MAC", HFILL }},
		{ &hf_zebra_msg4_tag,
		  { "Message TAG",	"zebra.message.tag",
		    FT_BOOLEAN, 8, NULL, FRR_ZAPI4_MESSAGE_TAG,
		    "Message contains TAG", HFILL }},
		{ &hf_zebra_msg4_mtu,
		  { "Message MTU",	"zebra.message.mtu",
		    FT_BOOLEAN, 8, NULL, FRR_ZAPI4_MESSAGE_MTU,
		    "Message contains MTU", HFILL }},
		{ &hf_zebra_msg4_srcpfx,
		  { "Message Source Prefix", "zebra.message.srcpfx",
		    FT_BOOLEAN, 8, NULL, FRR_ZAPI4_MESSAGE_SRCPFX,
		    "Message contains Source Prefix",
		    HFILL }},
		{ &hf_zebra_msg5_distance,
		  { "Message Distance",	"zebra.message.distance",
		    FT_BOOLEAN, 8, NULL, FRR_ZAPI5_MESSAGE_DISTANCE,
		    "Message contains distance", HFILL }},
		{ &hf_zebra_msg5_metric,
		  { "Message Metric",	"zebra.message.metric",
		    FT_BOOLEAN, 8, NULL, FRR_ZAPI5_MESSAGE_METRIC,
		    "Message contains metric", HFILL }},
		{ &hf_zebra_msg5_tag,
		  { "Message TAG",	"zebra.message.tag",
		    FT_BOOLEAN, 8, NULL, FRR_ZAPI5_MESSAGE_TAG,
		    "Message contains TAG", HFILL }},
		{ &hf_zebra_msg5_mtu,
		  { "Message MTU",	"zebra.message.mtu",
		    FT_BOOLEAN, 8, NULL, FRR_ZAPI5_MESSAGE_MTU,
		    "Message contains MTU", HFILL }},
		{ &hf_zebra_msg5_srcpfx,
		  { "Message Source Prefix", "zebra.message.srcpfx",
		    FT_BOOLEAN, 8, NULL, FRR_ZAPI5_MESSAGE_SRCPFX,
		    "Message contains Source Prefix", HFILL }},
		{ &hf_zebra_msg_label,
		  { "Message Label",	"zebra.message.label",
		    FT_BOOLEAN, 8, NULL, FRR_ZAPI5_MESSAGE_LABEL,
		    "Message contains Label", HFILL }},
		{ &hf_zebra_msg_tableid,
		  { "Message Table ID",	"zebra.message.tableid",
		    FT_BOOLEAN, 8, NULL, FRR_ZAPI5_MESSAGE_TABLEID,
		    "Message contains Table ID", HFILL }},
		{ &hf_zebra_nexthopnum_u16,
		  { "Nexthop Number",	"zebra.nexthopnum",
		    FT_UINT16, BASE_DEC, NULL, 0x0,
		    "Number of nexthops in route", HFILL }},
		{ &hf_zebra_nexthoptype_frr,
		  { "Nexthop Type",	"zebra.nexthoptype",
		    FT_UINT8, BASE_DEC, VALS(frr_nht), 0x0,
		    "Type of Nexthop", HFILL }},
		{ &hf_zebra_bhtype,
		  { "BHType",		"zebra.bhtype",
		    FT_UINT8, BASE_DEC, VALS(blackhole_type), 0x0,
		    "Blackhole Type", HFILL }},
		{ &hf_zebra_srcprefixlen,
		  { "Source Prefix length", "zebra.srcprefixlen",
		    FT_UINT32, BASE_DEC,
		    NULL, 0x0, NULL, HFILL }},
		{ &hf_zebra_srcprefix4,
		  { "Source Prefix",	"zebra.srcprefix4",
		    FT_IPv4, BASE_NONE, NULL, 0x0,
		    "Source Prefix IPv4", HFILL }},
		{ &hf_zebra_srcprefix6,
		  { "Source Prefix",	"zebra.srcprefix6",
		    FT_IPv6, BASE_NONE, NULL, 0x0,
		    "Source Prefix IPv6", HFILL }},
		{ &hf_zebra_tableid,
		  { "Table ID",		"zebra.tableid",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Routing Table ID", HFILL }},
		{ &hf_zebra_afi,
		  { "AFI",		"zebra.afi",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "AFI (Address Family Identifiers)", HFILL }},
		{ &hf_zebra_pid,
		  { "PID",		"zebra.pid",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Process ID", HFILL }},
		{ &hf_zebra_vrf_table_id,
		  { "VRF Table ID",	"zebra.vrftableid",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "VRF Routing Table ID", HFILL }},
		{ &hf_zebra_vrf_netns_name,
		  { "VRF NETNS Name",	"zebra.vrfnetnsname",
		    FT_STRING, BASE_NONE, NULL, 0x0,
		    "VRF (Virtual Routing and Forwarding) Network Namespace Name",
		    HFILL }},
		{ &hf_zebra_vrf_name,
		  { "VRF Name",		"zebra.vrfname",
		    FT_STRING, BASE_NONE, NULL, 0x0,
		    "VRF (Virtual Routing and Forwarding) Name", HFILL }},
		{ &hf_zebra_proto,
		  { "Protocol",		"zebra.proto",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Protocol of client", HFILL }},
		{ &hf_zebra_label_chunk_keep,
		  { "Label Chunk Keep",	"zebra.label_chunk_keep",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Keep of Label Chunk", HFILL }},
		{ &hf_zebra_label_chunk_size,
		  { "Label Chunk Size",	"zebra.label_chunk_size",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Size of Label Chunk", HFILL }},
		{ &hf_zebra_label_chunk_start,
		  { "Label Chunk Start","zebra.label_chunk_start",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Start of Label Chunk", HFILL }},
		{ &hf_zebra_label_chunk_end,
		  { "Label Chunk End",	"zebra.label_chunk_end",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "End of Label Chunk", HFILL }},
		{ &hf_zebra_mpls_enabled,
		  { "MPLS Enabled",	"zebra.mpls_enabled",
		    FT_BOOLEAN, BASE_NONE, NULL, 0x0,
		    "MPLS enabled capability", HFILL }},
		{ &hf_zebra_multipath_num,
		  { "Multipath Number",	"zebra.multipath_num",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Number of Multipath", HFILL }},
		{ &hf_zebra_labelnum,
		  { "Label Number",	"zebra.labelnum",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Number of Labels", HFILL }},
		{ &hf_zebra_label,
		  { "Label",		"zebra.label",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "MPLS Label", HFILL }},
		{ &hf_zebra_receive_notify,
		  { "Receive Notify",	"zebra.receive_notify",
		    FT_BOOLEAN, BASE_NONE, NULL, 0x0,
		    "TRUE if receive notify", HFILL }}
	};

	static gint *ett[] = {
		&ett_zebra,
		&ett_zebra_request,
		&ett_message,
	};

	proto_zebra = proto_register_protocol("Zebra Protocol", "ZEBRA", "zebra");
	proto_register_field_array(proto_zebra, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));
	zebra_handle = register_dissector("zebra", dissect_zebra, proto_zebra);
}

void
proto_reg_handoff_zebra(void)
{
	dissector_add_uint_with_preference("tcp.port", TCP_PORT_ZEBRA, zebra_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:
 */