1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
|
/* Prefix list functions.
* Copyright (C) 1999 Kunihiro Ishiguro
*
* 24-Nov-2009 -- substantially re-cast to speed up the handling of very
* large prefix-lists (10,000+ entries).
* Copyright (C) 2009 Chris Hall (GMCH), Highwayman
*
* This file is part of GNU Zebra.
*
* GNU Zebra is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2, or (at your
* option) any later version.
*
* GNU Zebra is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Zebra; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <zebra.h>
#include "prefix.h"
#include "command.h"
#include "memory.h"
#include "plist.h"
#include "sockunion.h"
#include "buffer.h"
#include "stream.h"
#include "log.h"
#include "symtab.h"
#include "vector.h"
/* This implements ip prefix-list functions.
*
* A prefix-list is referred to by name, where a name is an arbitrary string,
* case-sensitive. When showing prefix-lists the names are sorted
* "alphabetically", except for any digit sections, which sort numerically.
* Note that leading zeros are significant... "01" is not the same as "1",
* and sorts after it.
*/
enum prefix_flags {
PREFIX_ANY = 0x01, /* prefix declared as 'any' */
PREFIX_LE = 0x02, /* explicit 'le' */
PREFIX_GE = 0x04, /* explicit 'ge' */
PREFIX_SEQ = 0x10, /* explicit sequence number */
} ;
struct prefix_list ;
struct prefix_list_entry ;
/* Master structure of prefix_list.
*
* Each address family has it's own distinct set of prefix lists. (Including
* the fake AFI_ORF_PREFIX "family".)
*
* This means that a prefix_list name is local to an address family, but
* global wrt router instances.
* */
struct prefix_master
{
struct symbol_table table ; /* table of prefix_list by name. */
int seqnum_flag ; /* ip prefix-list sequence-number state. */
struct prefix_list *recent ; /* the latest update. */
struct prefix_list *cache_owner ;
/* prefix_list that owns the dup_cache */
struct vector dup_cache ; /* the dup_cache vector */
void (*add_hook) (struct prefix_list *);
/* executed when new prefix_list is added. */
void (*delete_hook) (struct prefix_list *);
/* executed when a prefix_list is deleted. */
};
/* Each prefix_list is described by one of these.*/
struct prefix_list
{
struct prefix_master *master ; /* parent table: scope of this list. */
struct symbol* sym ; /* symbol in parent's symbol table */
char *desc ; /* ip prefix-list description */
afi_t afi ; /* address family for all prefixes */
/* this is the *real* address family, so */
/* not "AFI_ORF_PREFIX" or similar. */
struct vector list ; /* the actual list of prefix matches */
int (*cmp)(struct prefix_list_entry** p_a, struct prefix_list_entry** p_b) ;
/* used when searching for duplicates */
int rangecount; /* XXX TODO: discover what this is for ?? */
/* Is not changed anywhere !! */
} ;
/* Each prefix-list's entry. */
struct prefix_list_entry
{
int seq;
enum prefix_list_type type;
int flags ; /* zero or more of PREFIX_ANY, PREFIX_LE and PREFIX_GE */
int le ; /* for exact match, set to prefix length */
int ge ; /* ditto */
struct prefix prefix;
u_int32_t mask ; /* for IPv4 -- host order. */
/* for last significant word of IPv6 -- network order */
int last ; /* for IPv4 -- not used. */
/* for IPv6 -- word to apply mask to. */
unsigned long refcnt;
unsigned long hitcnt;
};
/* Static structure of IPv4 prefix_list's master. */
static struct prefix_master prefix_master_ipv4 ;
#ifdef HAVE_IPV6
/* Static structure of IPv6 prefix-list's master. */
static struct prefix_master prefix_master_ipv6 ;
#endif /* HAVE_IPV6*/
/* Static structure of BGP ORF prefix_list's master. */
static struct prefix_master prefix_master_orf ;
/* For real afi, the choice is strictly limited, and includes IPv6
* only if HAVE_IPV6 ! */
#ifdef HAVE_IPV6
#define assert_afi_real(a) assert(((a) == AFI_IP) || ((a) == AFI_IP6))
#else
#define assert_afi_real(a) assert((a) == AFI_IP)
#endif
/* Map afi to prefix_master.
*
* Note: there is no ipv6 master if not HAVE_IPV6.
*
* Returns address of prefix_master, or NULL if unknown afi.
*/
static inline struct prefix_master *
prefix_master_get(afi_t afi)
{
switch (afi)
{
case AFI_IP:
return &prefix_master_ipv4;
#ifdef HAVE_IPV6
case AFI_IP6:
return &prefix_master_ipv6;
#endif /* HAVE_IPV6 */
case AFI_ORF_PREFIX:
return &prefix_master_orf;
default:
return NULL;
} ;
} ;
/* Map afi to maximum prefix length. Implied assert_afi_real(). */
static int
prefix_max_length(afi_t afi)
{
switch (afi)
{
case AFI_IP:
return IPV4_MAX_BITLEN ;
#ifdef HAVE_IPV6
case AFI_IP6:
return IPV6_MAX_BITLEN ;
#endif
default:
zabort("invalid address family") ;
return 0 ;
} ;
} ;
/* Compare prefix list entries, taking into account:
*
* -- prefix value -- assumes is masked down correctly
* -- prefix length
* -- ge
* -- le
* -- type
*
* ... everything *except* the sequence number.
*/
#define PREFIX_LIST_CMP_RET(f) \
if ((*p_a)->f != (*p_b)->f) \
return ( (*p_a)->f < (*p_b)->f) ? -1 : +1
#define PREFIX_LIST_CMP_RET_NL(f) \
if ((*p_a)->f != (*p_b)->f) \
return (ntohl((*p_a)->f) < ntohl((*p_b)->f)) ? -1 : +1
#define PREFIX_LIST_CMP_REST \
PREFIX_LIST_CMP_RET(prefix.prefixlen) ; \
PREFIX_LIST_CMP_RET(ge) ; \
PREFIX_LIST_CMP_RET(le) ; \
PREFIX_LIST_CMP_RET(type)
static int
prefix_list_ipv4_cmp(struct prefix_list_entry** p_a,
struct prefix_list_entry** p_b)
{
PREFIX_LIST_CMP_RET_NL(prefix.u.prefix4.s_addr) ;
PREFIX_LIST_CMP_REST ;
return 0 ;
} ;
#ifdef HAVE_IPV6 /*----------------------------------------------------*/
static int
prefix_list_ipv6_cmp(struct prefix_list_entry** p_a,
struct prefix_list_entry** p_b)
{
#ifdef s6_addr32
PREFIX_LIST_CMP_RET_NL(prefix.u.prefix6.s6_addr32[0]) ;
PREFIX_LIST_CMP_RET_NL(prefix.u.prefix6.s6_addr32[1]) ;
PREFIX_LIST_CMP_RET_NL(prefix.u.prefix6.s6_addr32[2]) ;
PREFIX_LIST_CMP_RET_NL(prefix.u.prefix6.s6_addr32[3]) ;
#else
int c ;
if ((c = memcmp(&(*p_a)->prefix.u.prefix6.s6_addr,
&(*p_b)->prefix.u.prefix6.s6_addr, 16)) != 0)
return c ;
#endif
PREFIX_LIST_CMP_REST ;
return 0 ;
} ;
#endif /*----------------------------------------------------*/
/*==============================================================================
* Operations on prefix_master.
*/
static void prefix_list_delete (struct prefix_list* plist) ;
static void prefix_dup_cache_free(struct prefix_master* pm) ;
/* Initialise given prefix_master. */
static void
prefix_master_init(struct prefix_master * pm)
{
memset(pm, 0, sizeof(struct prefix_master)) ;
symbol_table_init_new(&pm->table, pm, 20, 200, NULL, NULL) ;
pm->seqnum_flag = 1 ; /* Default is to generate sequence numbers. */
} ;
/* Reset given prefix_master.
*
* Frees all prefix lists and empties the symbol table. Any references to
* prefix lists are the responsibility of the reference owners.
*
* Resets to the default sequence numbering state.
*
* Retains current add_hook and delete_hook functions.
*/
static void
prefix_master_reset(struct prefix_master * pm)
{
struct prefix_list* plist ;
while ((plist = symbol_table_ream(&(pm->table), keep_it)))
prefix_list_delete(plist) ;
pm->seqnum_flag = 1 ; /* Default is to generate sequence numbers. */
pm->recent = NULL ;
prefix_dup_cache_free(pm) ;
} ;
/* Add hook function. */
void
prefix_list_add_hook (void (*func)(struct prefix_list *plist))
{
prefix_master_ipv4.add_hook = func;
#ifdef HAVE_IPV6
prefix_master_ipv6.add_hook = func;
#endif /* HAVE_IPV6 */
}
/* Delete hook function. */
void
prefix_list_delete_hook (void (*func)(struct prefix_list *plist))
{
prefix_master_ipv4.delete_hook = func;
#ifdef HAVE_IPV6
prefix_master_ipv6.delete_hook = func;
#endif /* HAVE_IPVt6 */
}
/*==============================================================================
* Prefix List Use.
*
* The prefix_list_ref type is a struct symbol_ref*, so we can operate on
* prefix_list_ref* arguments, keeping the stored reference values up to date.
*/
const char*
prefix_list_get_name(struct prefix_list* plist)
{
return symbol_get_name(plist->sym) ;
} ;
/* Set reference to prefix_list, by name.
* Replaces any existing reference.
*
* Returns the new value of the prefix_list_ref.
*
* NB: if reference existed, the parent and tag fields are preserved.
* Otherwise they are set to 0.
*/
prefix_list_ref
prefix_list_set_ref(prefix_list_ref* p_ref, afi_t afi, const char* name)
{
struct prefix_master* pm = prefix_master_get(afi) ;
if (pm == NULL)
return NULL ;
return *p_ref = symbol_set_ref(*p_ref,
symbol_lookup(&(pm->table), name, add)) ;
} ;
/* Copy reference to prefix_list.
* Replaces any existing reference (by NULL if reference is NULL).
*
* Returns the new value of the prefix_list_ref.
*
* NB: if reference existed, the parent and tag fields are preserved.
* Otherwise they are set to 0.
*/
prefix_list_ref
prefix_list_copy_ref(prefix_list_ref* p_dst, prefix_list_ref src)
{
return *p_dst = symbol_set_ref(*p_dst, sym_ref_symbol(src)) ;
} ;
/* Unset reference to prefix_list (does nothing if reference is NULL).
*
* Returns the new value of the prefix_list_ref -- ie NULL.
*/
prefix_list_ref
prefix_list_unset_ref(prefix_list_ref* p_ref)
{
return *p_ref = symbol_unset_ref(*p_ref, 1) ;
} ;
/* Get name of prefix_list to which given reference (if any) refers.
*
* Returns NULL if the reference is NULL.
*/
const char*
prefix_list_ref_name(prefix_list_ref ref)
{
return sym_ref_name(ref) ;
} ;
/* Return "identity" of prefix_list referred to by the given reference.
* Will be NULL if the reference is NULL.
*
* Two references to the same prefix_list will have the same "identity".
*/
void* prefix_list_ref_ident(prefix_list_ref ref)
{
return (void*)sym_ref_symbol(ref) ;
} ;
/* Return prefix_list referred to by the given reference.
* Will be NULL If the reference is NULL *OR* if the prefix_list is undefined.
*/
struct prefix_list* prefix_list_ref_plist(prefix_list_ref ref)
{
return (struct prefix_list*)sym_ref_value(ref) ;
} ;
/* Apply a prefix_list to the given prefix. */
enum prefix_list_type
prefix_list_apply (struct prefix_list *plist, void *object)
{
struct prefix *p ;
int plen ;
struct prefix_list_entry* pe ;
vector_index_t i ;
in_addr_t ip ;
#ifdef s6_addr32
u_int32_t* pp ;
u_int32_t* pep ;
#else
unsigned char* pp ;
unsigned char* pep ;
#endif
/* Deny if prefix_list is undefined or empty */
if ((plist == NULL) || (vector_end(&plist->list) == 0))
return PREFIX_DENY;
p = object ;
plen = p->prefixlen ;
/* For maximum performance we have separate loops for IPv4 and IPv6 */
assert_afi_real(plist->afi) ;
switch (plist->afi)
{
case AFI_IP:
ip = p->u.prefix4.s_addr ;
for (VECTOR_ITEMS(&plist->list, pe, i))
{
++pe->refcnt ;
if ((plen < pe->ge) || (plen > pe->le))
continue ;
if (((pe->prefix.u.prefix4.s_addr ^ ip) & pe->mask) == 0)
{
++pe->hitcnt;
return pe->type ;
} ;
}
break ;
case AFI_IP6:
#ifdef s6_addr32
pp = p->u.prefix6.s6_addr32 ;
#else
pp = p->u.prefix6.s6_addr ;
#endif
for (VECTOR_ITEMS(&plist->list, pe, i))
{
int j, l ;
++pe->refcnt ;
if ((plen < pe->ge) || (plen > pe->le))
continue ;
#ifdef s6_addr32
pep = pe->prefix.u.prefix6.s6_addr32 ;
#else
pep = pe->prefix.u.prefix6.s6_addr ;
#endif
l = pe->last ;
for (j = 0 ; j < l ; j++)
if (pep[j] != pp[j])
goto NEXT ;
if (((pep[l] ^ pp[l]) & pe->mask) == 0)
{
++pe->hitcnt;
return pe->type ;
} ;
NEXT: ;
}
break ;
default:
zabort("invalid address family") ;
} ;
return PREFIX_DENY;
}
/*==============================================================================
* Basic constructors and destructors.
*/
/* Construct a new prefix_list and set the the associated symbol's value.
*
* Implied assert_afi_real().
*/
static struct prefix_list *
prefix_list_new(struct prefix_master* pm, struct symbol* sym, afi_t afi)
{
struct prefix_list* new ;
new = XCALLOC (MTYPE_PREFIX_LIST, sizeof (struct prefix_list));
/* NB: implicitly sets the list empty. */
new->sym = symbol_inc_ref(sym) ;
new->master = pm ;
new->afi = afi ;
switch (afi)
{
case AFI_IP:
new->cmp = prefix_list_ipv4_cmp ;
break ;
#ifdef HAVE_IPV6
case AFI_IP6:
new->cmp = prefix_list_ipv6_cmp ;
break ;
#endif
default:
zabort("invalid address family") ;
} ;
symbol_set_value(sym, new) ;
return new ;
} ;
/* Initialise prefix_list entry -- cleared to zeros. */
static struct prefix_list_entry *
prefix_list_entry_init(struct prefix_list_entry * pe)
{
return memset(pe, 0, sizeof(struct prefix_list_entry));
}
/* Allocate new prefix_list entry -- cleared to zeros. */
static struct prefix_list_entry *
prefix_list_entry_new (void)
{
return XCALLOC (MTYPE_PREFIX_LIST_ENTRY, sizeof (struct prefix_list_entry));
}
/* Free given prefix list entry. */
static void
prefix_list_entry_free (struct prefix_list_entry* pe)
{
XFREE (MTYPE_PREFIX_LIST_ENTRY, pe);
}
/* Set cache owned by nobody, and free the contents of the cache (if any). */
static void
prefix_dup_cache_free(struct prefix_master* pm)
{
pm->cache_owner = NULL ;
vector_reset(&pm->dup_cache, 0) ;
}
/* Delete prefix_list from prefix_list_master and free it and its contents. */
/* The prefix_list's symbol is set undefined. */
static void
prefix_list_delete (struct prefix_list* plist)
{
struct prefix_master* pm = plist->master ;
unsigned int i ;
struct prefix_list_entry* pe ;
/* Free all the prefix_list_entries, then free the vector they live in. */
for (VECTOR_ITEMS(&plist->list, pe, i))
prefix_list_entry_free(pe) ;
vector_reset(&plist->list, 0) ;
/* If there is a description, release that now. */
if (plist->desc)
XFREE (MTYPE_TMP, plist->desc);
/* Can no longer own the dup_cache. */
if (pm->cache_owner == plist)
prefix_dup_cache_free(pm) ;
/* Symbol no longer has a value & drop reference. */
symbol_unset_value(plist->sym) ;
plist->sym = symbol_dec_ref(plist->sym) ;
/* Finally, release the prefix_list structure. */
XFREE (MTYPE_PREFIX_LIST, plist) ;
/* No longer have a recently changed prefix-list */
pm->recent = NULL ;
/* Tell the world. */
if (pm->delete_hook)
(*pm->delete_hook) (NULL);
} ;
/*==============================================================================
* Operations on prefix_lists
*/
/* Seek prefix_list by name in give prefix master. Does NOT create. */
static struct prefix_list *
prefix_list_seek (struct prefix_master* pm, const char *name)
{
return symbol_get_value(symbol_lookup(&(pm->table), name, no_add)) ;
} ;
/* Lookup prefix_list by afi and name -- if afi is known, and name not NULL.
*
* Returns NULL if no prefix_list by that afi and name. Tolerates unknown afi
* and allows "fake" afi (eg. AFI_ORF_PREFIX).
*/
struct prefix_list *
prefix_list_lookup (afi_t afi, const char *name)
{
struct prefix_master* pm = prefix_master_get(afi) ;
if ((name == NULL) || (pm == NULL))
return NULL;
return prefix_list_seek(pm, name) ;
} ;
/* Get prefix_list -- creating empty one if required. */
static struct prefix_list *
prefix_list_get (struct prefix_master* pm, const char *name, afi_t afi)
{
struct symbol* sym ;
struct prefix_list* plist ;
assert((pm != NULL) && (name != NULL)) ;
sym = symbol_lookup(&(pm->table), name, add) ; /* creates if required */
plist = symbol_get_value(sym) ;
return plist ? plist : prefix_list_new(pm, sym, afi) ;
} ;
/*==============================================================================
* Operations on prefix_list_entry
*/
/* Sequence comparison function -- used in prefix_list_entry_lookup_seq */
static int
prefix_seq_cmp(const int** seq, const struct prefix_list_entry** pe)
{
if (**seq != (*pe)->seq)
return (**seq < (*pe)->seq) ? -1 : + 1 ;
return 0 ;
} ;
/* Check any ge and le settings -- set defaults as required.
*
* -- sets the implied le for "any" or ge, if no explicit le set
*
* -- checks le & ge and updates as required the filter.
*
* Note that filter requires le = ge = prefix-length for an exact match.
*
* Returns: CMD_SUCCESS -- it's OK
* CMD_WARNING -- something amiss with the ge and/or le setting
*
* Cisco say:
*
* If ge: must be <= maximum prefix length and > actual prefix length
* else: set to prefix length
*
* If le: must be <= maximum prefix length and > actual prefix length
* else: if ge or any set to maximum prefix length
* else: set to prefix length
*
* If both ge and le: must have length < ge < le <= maximum
*
* But Cisco will apparently allow: length < ge <= le <= maximum
*
* We allow: length <= ge <= le <= maximum
*
* GMCH TODO: check on wisdom of all this.
*/
static int
prefix_list_entry_ge_le_check(struct prefix_list_entry* pe, afi_t afi)
{
int pl_max = prefix_max_length(afi) ;
int pl = pe->prefix.prefixlen ;
/* If we had ge, check in range, otherwise set to prefixlen. */
if (pe->flags & PREFIX_GE)
{
if ( !( (pl <= pe->ge) && (pe->ge <= pl_max) ) )
return CMD_WARNING ;
}
else
pe->ge = pl ;
/* If we had le, check in range, otherwise set as required.
*
* Note that if had ge, then we've checked that already, otherwise
* we have set ge = pl -- so can check ge <= le.
*/
if (pe->flags & PREFIX_LE)
{
if ( !( (pe->ge <= pe->le) && (pe->le <= pl_max) ) )
return CMD_WARNING ;
}
else
pe->le = (pe->flags & (PREFIX_ANY | PREFIX_GE)) ? pl_max : pl ;
return CMD_SUCCESS ;
} ;
/* Lookup prefix_list_entry by its sequence number. Returns index of an entry
* in the prefix_list, and sets:
*
* result < 0 -- not found. index returned is of first entry in the
* prefix list, and this sequence number comes
* before it. (Or list is empty.)
* result == 0 -- found. index is of the entry found.
* result > 0 -- not found. index returned is of the entry with the largest
* sequence number smaller than the given one.
*/
static vector_index_t
prefix_list_entry_lookup_seq(struct prefix_list *plist, int seq, int* result)
{
return vector_bsearch(&plist->list, (vector_bsearch_cmp*)prefix_seq_cmp,
&seq, result) ;
} ;
/* Lookup prefix_list_entry by its contents.
*
* For large prefix_lists this uses the "dup_cache", which is an auxiliary
* vector, sorted by prefix value. Each prefix_master has a dup_cache,
* which is co-opted by the last prefix_list to use it.
*
* Returns index of an entry in the prefix_list or the dup_cache, and sets:
*
* cache -- NULL if not using dup_cache for this prefix_list.
* The index and result values refer to the main prefix_list.
*
* result < 0 -- not found. prefix list is empty, index == 0
* result == 0 -- found. index is of the prefix list entry
* result > 0 -- not found. prefix is not empty, index == last
*
* -- address of the cache (a vector).
* The index and result values refer to the *cache*. << NB
*
* result < 0 -- not found. index == 0, prefix value given is
* less than first entry in the *cache*
* result == 0 -- found. index is of the *cache* entry
* result > 0 -- not found. index is of entry in the *cache*
* with the largest prefix value less
* than the given prefix value.
*
* Note that the cache is never empty.
*/
static vector_index_t
prefix_list_entry_lookup_val(struct prefix_list *plist,
struct prefix_list_entry* temp,
vector* cache,
int* result)
{
/* See if we already have an entry like this one. */
if (vector_end(&plist->list) > 10)
{
struct prefix_master* pm = plist->master ;
if (pm->cache_owner != plist)
{
/* Create new cache by copying vector. Releases any old cache. */
vector_copy_here(&pm->dup_cache, &plist->list) ;
/* Sort the result so can binary chop it. */
vector_sort(&pm->dup_cache, (vector_sort_cmp*)plist->cmp) ;
/* Now we own the cache. */
pm->cache_owner = plist ;
} ;
*cache = &pm->dup_cache ;
return vector_bsearch(*cache, (vector_bsearch_cmp*)plist->cmp, temp,
result) ;
}
else
{
struct prefix_list_entry* pe ;
vector_index_t i ;
*cache = NULL ; /* Not found in cache. */
*result = 0 ; /* Assume found ! */
for (VECTOR_ITEMS(&plist->list, pe, i))
{
if (plist->cmp(&pe, &temp) == 0)
return i ; /* Found ! */
} ;
*result = (vector_end(&plist->list) == 0) ? -1 : +1 ;
/* Not found. */
return i ;
} ;
} ;
/* Look up prefix_list_entry looking for an exact match.
*
* If we have an explicit sequence number, then we look that up and then
* see if that prefix_list_entry is identical.
*
* Otherwise, look for entry whose value is identical, if any.
*
* Returns an index of a prefix_list entry and sets:
*
* -- result == 0 found -- index is of entry found
* -- result != 0 not found -- index is immaterial
*
* */
static vector_index_t
prefix_list_entry_lookup (struct prefix_list* plist,
struct prefix_list_entry* pe_seek, int* result)
{
struct prefix_list_entry* pe_found ;
vector_index_t i ;
if (pe_seek->flags & PREFIX_SEQ)
{
/* Lookup by sequence number. */
i = prefix_list_entry_lookup_seq(plist, pe_seek->seq, result) ;
if (*result == 0)
{
/* found by sequence number, now see if value matches. */
pe_found = vector_get_item(&plist->list, i) ;
*result = plist->cmp(&pe_seek, &pe_found) ;
} ;
}
else
{
/* Lookup by value. */
vector cache ;
i = prefix_list_entry_lookup_val(plist, pe_seek, &cache, result) ;
if ((*result == 0) && cache)
{
/* Found in the cache. We need it's position in prefix_list */
pe_found = vector_get_item(cache, i) ;
i = prefix_list_entry_lookup_seq(plist, pe_found->seq, result) ;
assert(*result == 0) ; /* MUST Find it !! */
} ;
}
return i ;
} ;
/* Insert prefix_list_entry or replace an existing one, if we can.
*
* May NOT insert or replace if an entry already exists with the same value,
* (where the value excludes the sequence number).
*
* Except that, if a sequence number is given, it is (trivially) possible to
* "replace" an entry with the same sequence number and the same value.
*
* Then, if no sequence number is given, one is allocated. The allocation
* rounds the last sequence number up to a multiple of 5 and adds 5.
*
* The prefix_list_entry is then put in the list by sequence number, replacing
* any existing entry.
*
* Returns: CMD_SUCCESS -- OK
* CMD_WARNING -- Nope, and NB: temp->seq set to sequence number
* of existing prefix_list_entry.
*/
static int
prefix_list_entry_insert(struct prefix_list *plist,
struct prefix_list_entry *temp)
{
struct prefix_list_entry* pe ;
vector cache ;
vector_index_t i, ic ;
int ret, retc ;
u_int32_t mask ;
int pl, sh ;
/* See if we have an entry like this one, if we do:
*
* OK if sequence number is the same too -- nothing more to do !
* Fail if sequence number differs or was not set.
*
* If not found, and we own the cache, ic and retc tell us where in the
* cache the new entry belongs.
*/
ic = prefix_list_entry_lookup_val(plist, temp, &cache, &retc) ;
if (retc == 0)
{
pe = vector_get_item(cache ? cache : &plist->list, ic) ;
if ((temp->flags & PREFIX_SEQ) && (pe->seq == temp->seq))
return CMD_SUCCESS ;
temp->seq = pe->seq ; /* capture clashing sequence number */
return CMD_WARNING ;
} ;
/* Now we need to find where to insert in the list. */
/* If required, we set implied sequence number, and insert at end. */
if (temp->flags & PREFIX_SEQ)
i = prefix_list_entry_lookup_seq(plist, temp->seq, &ret) ;
else
{
int last_seq ;
i = vector_end(&plist->list) ;
if (i == 0)
{
last_seq = 0 ; /* initial value for empty list */
ret = -1 ; /* insert before first item of empty list */
}
else
{
--i ; /* step back to last entry */
pe = vector_get_item(&plist->list, i) ;
last_seq = pe->seq ;
ret = 1 ; /* insert after last entry */
} ;
temp->seq = (((last_seq + 5 - 1) / 5) * 5) + 5 ;
} ;
/* If we found it with same sequence number, then replace entry,
* otherwise we need to create a new entry and insert it. i & ret show
* where we need to put the value in the list.
*
* If a dup cache exists, that must be kept up to date. ic & retc show
* where need to put the new value in the cache.
*/
if (ret == 0)
{
/* We are going to replace an existing list entry. */
pe = vector_get_item(&plist->list, i) ; /* address of current entry */
/* If we have a cache, need to move the entry to it's new place */
if (cache)
{
/* We need to know where the old value was. */
vector_index_t io ;
int reto ;
io = vector_bsearch(cache, (vector_bsearch_cmp*)plist->cmp, pe,
&reto) ;
assert(reto == 0) ; /* MUST find it !! */
vector_move_item_here(cache, ic, retc, io) ;
} ;
}
else
{
/* We are going to insert a new list entry item. */
pe = prefix_list_entry_new() ;
vector_insert_item_here(&plist->list, i, ret, pe) ;
/* If we have a cache, need to insert the entry to it's place */
if (cache)
vector_insert_item_here(cache, ic, retc, pe) ;
} ;
/* Now we can set the value of the entry. */
*pe = *temp ;
/* Set mask and last ready to apply the filter.
*
* pl sh mask last
* 0 0 0x00000000 0 case sh == 0 && pl == 0
* 1 1 0x80000000 0
* .. .. .
* 31 31 0xFFFFFFFE 0
* 32 0 0xFFFFFFFF 0 case sh == 0
* 33 1 0x80000000 1
* .. .. .
* 64 0 0xFFFFFFFF 1 case sh == 0
* 65 1 0x80000000 2
* .. .. .
* 128 0 0xFFFFFFFF 3 case sh == 0
*
* Note: if we don't have s6_addr32, we must handle IPv6 byte-wise !
*/
pl = pe->prefix.prefixlen ;
sh = pl & 0x1F ;
if (sh == 0)
mask = (pl == 0) ? 0x00000000 : 0xFFFFFFFF ;
else
mask = (0xFFFFFFFF >> sh) ^ 0xFFFFFFFF ;
switch (plist->afi)
{
case AFI_IP:
pe->mask = htonl(mask) ;
pe->last = 0 ;
break ;
case AFI_IP6:
#ifdef s6_addr32
pe->mask = htonl(mask) ;
pe->last = (pl == 0) ? 0 : (pl - 1) >> 5 ;
#else
/* Need to shift 32 bit mask to 8 bit mask
*
* For pl == 0 mask == 0, otherwise:
*
* (pl - 1) & 0x18 -> 0 for pl = 1.. 8, 33..40, 65..72, 97..104
* 8 for pl = 9..16, etc
* (0x10) 16 for pl = 17..24, etc
* (0x18) 24 for pl = 25..32, etc
*
* So need to shift down by 24 - that, and then mask to byte.
*/
if (pl != 0)
mask >>= (24 - ((pl - 1) & 0x18)) ;
pe->mask = mask & 0xFF ;
pe->last = (pl == 0) ? 0 : (pl - 1) >> 3 ;
#endif
break ;
default:
zabort("invalid address family") ;
} ;
/* Run hook function. */
if (plist->master->add_hook)
(*plist->master->add_hook) (plist);
plist->master->recent = plist;
return CMD_SUCCESS ;
}
/* Delete prefix_list_entry, if we can.
*
* To delete an entry the caller must specify the exact value of an existing
* entry. If a sequence number is specified, that entry must exist, and its
* value must exactly match the given value. If no sequence number is
* specified, an entry must exist with exactly the given value.
*
* Returns: CMD_SUCCESS -- OK
* CMD_WARNING -- entry not found.
*/
static int
prefix_list_entry_delete (struct prefix_list *plist,
struct prefix_list_entry *pe_seek)
{
struct prefix_list_entry* pe ;
vector_index_t i ;
int ret ;
i = prefix_list_entry_lookup (plist, pe_seek, &ret) ;
if (ret)
return CMD_WARNING ;
pe = vector_delete_item(&plist->list, i) ;
assert(pe != NULL) ;
prefix_list_entry_free(pe) ; /* now release memory */
if (plist->master->delete_hook)
(*plist->master->delete_hook) (plist);
if ((vector_end(&plist->list) == 0) && (plist->desc == NULL))
prefix_list_delete (plist);
else
plist->master->recent = plist;
return CMD_SUCCESS ;
} ;
/*==============================================================================
* Common printing operations
*/
/* Return string of prefix_list_type. */
static const char *
prefix_list_type_str (struct prefix_list_entry *pentry)
{
switch (pentry->type)
{
case PREFIX_PERMIT:
return "permit";
case PREFIX_DENY:
return "deny";
default:
return "";
}
}
/* Map afi to name of same: "ip" or "ipv6". Implied assert_afi_real(). */
static const char*
prefix_afi_name_str(afi_t afi)
{
switch (afi)
{
case AFI_IP:
return "ip" ;
#ifdef HAVE_IPV6
case AFI_IP6:
return "ipv6" ;
#endif
default:
zabort("invalid address family") ;
return "?" ;
} ;
} ;
/* Print: "(ip|ipv6) prefix-list NAME" <post> */
static void
vty_prefix_list_name_print(struct vty* vty, struct prefix_list* plist,
const char* post)
{
vty_out(vty, "%s prefix-list %s%s", prefix_afi_name_str(plist->afi),
(const char*)symbol_get_name(plist->sym), post) ;
} ;
/* Print: "(ip|ipv6) prefix-list NAME: 99 entries" <post> */
static void
vty_prefix_list_name_count_print(struct vty* vty, struct prefix_list* plist,
const char* post)
{
vty_prefix_list_name_print(vty, plist, "") ;
vty_out(vty, ": %d entries%s", vector_end(&plist->list), post);
} ;
/* Print: "(ip|ipv6) prefix-list NAME" UNDEFINED<post> */
static void
vty_prefix_list_undefined_print(struct vty* vty, afi_t afi, struct symbol* sym,
const char* post)
{
vty_out(vty, "%s prefix-list %s UNDEFINED%s", prefix_afi_name_str(afi),
(const char*)symbol_get_name(sym), post) ;
} ;
/* Print: <indent>"Description: xxxx"<post>, if there is a description */
static void
vty_prefix_list_desc_print(struct vty* vty, struct prefix_list* plist,
int indent, const char* post)
{
if (plist->desc)
vty_out (vty, "%sDescription: %s%s", VTY_SPACES(indent), plist->desc,
VTY_NEWLINE) ;
}
/* Size of buffer to hold either IPv4 or IPv6 string. */
#ifndef INETX_ADDRSTRLEN
# if INET_ADDRSTRLEN < INET6_ADDRSTRLEN
# define INETX_ADDRSTRLEN INET6_ADDRSTRLEN
# else
# define INETX_ADDRSTRLEN INET_ADDRSTLEN
# endif
#endif
/* Print value of given prefix_list_entry:
*
* "[seq 999 ](permit|deny) (any|XXXXX/999)[ ge 99][ le 99]"
* "[ '('hit count: 999, refcount: 999')']" <post>
*
* where: sequence number is included if "with_seq" specified
* ge and/or le are included if explicitly set
* the hit count and refcount are included if "with_stats" specified
*/
static void
vty_prefix_list_value_print(struct vty* vty, struct prefix_list_entry* pe,
const char* post, int with_seq, int with_stats)
{
if (with_seq)
vty_out(vty, "seq %d ", pe->seq) ;
vty_out(vty, "%s ", prefix_list_type_str(pe)) ;
if (pe->flags & PREFIX_ANY)
vty_out(vty, "any");
else
{
struct prefix *p = &pe->prefix ;
char buf[INETX_ADDRSTRLEN];
vty_out(vty, "%s/%d",
inet_ntop (p->family, &p->u.prefix, buf, INETX_ADDRSTRLEN),
p->prefixlen);
} ;
if (pe->flags & PREFIX_GE)
vty_out(vty, " ge %d", pe->ge);
if (pe->flags & PREFIX_LE)
vty_out(vty, " le %d", pe->le);
if (with_stats)
vty_out (vty, " (hit count: %lu, refcount: %lu)", pe->hitcnt, pe->refcnt);
vty_out(vty, post) ;
}
static void __attribute__ ((unused))
prefix_list_print (struct prefix_list *plist)
{
struct prefix_list_entry* pe ;
vector_index_t i ;
struct vty* vty = NULL ;
if (plist == NULL)
return;
vty_prefix_list_name_count_print(vty, plist, VTY_NEWLINE) ;
for (VECTOR_ITEMS(&plist->list, pe, i))
{
vty_out_indent(vty, 2) ;
vty_prefix_list_value_print(vty, pe, VTY_NEWLINE, 1, 1) ;
}
}
/*==============================================================================
* vty prefix_list operations.
*/
/* Look up given prefix_list -- complain if not found. */
static struct prefix_list*
vty_prefix_list_lookup(struct vty *vty, afi_t afi, const char* name)
{
struct prefix_list* plist = prefix_list_lookup(afi, name);
if (plist == NULL)
vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE);
return plist ;
} ;
/* Process parameters for (ip|ipv6) prefix-list and no (ip|ipv6) prefix-list
*
* Fills in the given prefix_list_entry structure, ready for looking up,
* inserting or deleting prefix_list_entry.
*
* Checks parameters for validity/legality.
*
* Returns a CMD_xxxx return code. CMD_SUCCESS => OK !
*/
static int
vty_prefix_list_process(struct vty *vty, struct prefix_list_entry* pe,
struct prefix_list* plist,
afi_t afi, const char *seq_str, const char *type_str,
const char *prefix_str,
const char *ge_str, const char *le_str)
{
int ret ;
assert_afi_real(afi) ; /* require real (and supported) afi */
prefix_list_entry_init(pe) ; /* clears everything, including flags */
/* Sequence number. */
if (seq_str)
{
pe->flags |= PREFIX_SEQ ;
pe->seq = atoi(seq_str) ;
} ;
/* Check filter type. */
if (strncmp ("permit", type_str, 1) == 0)
pe->type = PREFIX_PERMIT;
else if (strncmp ("deny", type_str, 1) == 0)
pe->type = PREFIX_DENY;
else
{
vty_out (vty, "%% prefix type must be permit or deny%s", VTY_NEWLINE);
return CMD_WARNING;
}
/* Watch out for "any" */
if (strncmp ("any", prefix_str, strlen (prefix_str)) == 0)
pe->flags |= PREFIX_ANY ;
/* Process the prefix. */
if (afi == AFI_IP)
{
if (pe->flags & PREFIX_ANY)
prefix_str = "0.0.0.0/0" ;
ret = str2prefix_ipv4 (prefix_str, (struct prefix_ipv4 *)&pe->prefix);
if (ret <= 0)
{
vty_out (vty, "%% Malformed IPv4 prefix%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
#ifdef HAVE_IPV6
else if (afi == AFI_IP6)
{
if (pe->flags & PREFIX_ANY)
prefix_str = "::/0" ;
ret = str2prefix_ipv6 (prefix_str, (struct prefix_ipv6 *)&pe->prefix);
if (ret <= 0)
{
vty_out (vty, "%% Malformed IPv6 prefix%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
#endif /* HAVE_IPV6 */
/* ge and le number */
if (ge_str)
{
pe->ge = atoi (ge_str) ;
pe->flags |= PREFIX_GE ;
}
if (le_str)
{
pe->le = atoi (le_str);
pe->flags |= PREFIX_LE ;
} ;
/* Complete the entry we've constructed, and check ge and le. */
ret = prefix_list_entry_ge_le_check(pe, afi) ;
if (ret != CMD_SUCCESS)
vty_out (vty, "%% Invalid prefix range for %s, make sure: "
"len <= ge-value <= le-value%s",
prefix_str, VTY_NEWLINE);
return ret ;
} ;
/* Install a prefix_list_entry.
*
* Deals with all of ip prefix-list and ipv6 prefix-list commands.
*
* Note:
*
*/
static int
vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
const char *seq_str, const char *type_str,
const char *prefix_str,
const char *ge_str, const char *le_str)
{
struct prefix_master* pm ;
struct prefix_list *plist;
struct prefix_list_entry temp ;
int ret;
assert_afi_real(afi) ; /* UI stuff should ensure this */
pm = prefix_master_get(afi) ;
/* Get prefix_list with name. Make new list if required. */
plist = prefix_list_get(pm, name, afi) ;
/* Do the grunt work on the parameters.
* Completely fill in the temp prefix_list_entry structure.
*/
ret = vty_prefix_list_process(vty, &temp, plist, afi, seq_str, type_str,
prefix_str, ge_str, le_str) ;
if (ret != CMD_SUCCESS)
return ret ;
/* Insert into the list, unless list contains an entry which is the same
* apart from the sequence number.
* If fails, sets the sequence no. in temp to the sequence number found.
*/
ret = prefix_list_entry_insert(plist, &temp);
if (ret != CMD_SUCCESS)
{
vty_out (vty, "%% Insertion failed - prefix-list entry exists:%s",
VTY_NEWLINE);
vty_out_indent(vty, 2) ;
vty_prefix_list_value_print(vty, &temp, VTY_NEWLINE, 1, 0) ;
}
return CMD_SUCCESS;
}
/* Remove a prefix_list_entry. */
static int
vty_prefix_list_uninstall(struct vty *vty, afi_t afi, const char *name,
const char *seq_str, const char *type_str,
const char *prefix_str,
const char *ge_str, const char *le_str)
{
struct prefix_list *plist;
struct prefix_list_entry temp ;
int ret;
assert_afi_real(afi) ; /* UI should guarantee this. */
/* Seek prefix_list with name -- error if not found. */
plist = vty_prefix_list_lookup(vty, afi, name);
if (plist == NULL)
return CMD_WARNING ;
/* Only prefix-list name specified, delete the entire prefix-list. */
if (seq_str == NULL && type_str == NULL && prefix_str == NULL &&
ge_str == NULL && le_str == NULL)
{
prefix_list_delete (plist);
return CMD_SUCCESS;
}
/* We must have, at a minimum, both the type and prefix here */
if ((type_str == NULL) || (prefix_str == NULL))
{
vty_out (vty, "%% Both prefix and type required%s", VTY_NEWLINE);
return CMD_WARNING;
}
/* Do the grunt work on the parameters.
* Completely fill in the temp prefix_list_entry structure.
*/
ret = vty_prefix_list_process(vty, &temp, plist, afi, seq_str, type_str,
prefix_str, ge_str, le_str) ;
if (ret != CMD_SUCCESS)
return ret ;
/* Remove prefix_list_entry if we can. */
ret = prefix_list_entry_delete (plist, &temp);
if (ret != CMD_SUCCESS)
vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE);
return ret;
}
static int
vty_prefix_list_desc_set (struct vty *vty, afi_t afi, const char *name,
char* desc)
{
struct prefix_master* pm ;
struct prefix_list *plist;
assert_afi_real(afi) ; /* UI stuff should ensure this */
pm = prefix_master_get(afi) ;
/* Get prefix_list with name. Make new list if required. */
plist = prefix_list_get(pm, name, afi) ;
if (plist->desc)
XFREE (MTYPE_TMP, plist->desc) ; /* Discard any existing value */
plist->desc = desc ;
return CMD_SUCCESS;
}
static int
vty_prefix_list_desc_unset (struct vty *vty, afi_t afi, const char *name)
{
struct prefix_list *plist;
plist = vty_prefix_list_lookup(vty, afi, name);
if (plist == NULL)
return CMD_WARNING ;
if (plist->desc)
XFREE (MTYPE_TMP, plist->desc) ; /* sets plist->dec to NULL */
if (vector_end(&plist->list) == 0)
prefix_list_delete(plist) ; /* delete list if all gone now */
return CMD_SUCCESS;
}
enum display_type
{
normal_display,
summary_display,
detail_display,
sequential_display,
longer_display,
first_match_display,
};
/* Show given prefix_list */
static void
vty_show_prefix_entry (struct vty *vty, struct prefix_list *plist,
struct prefix_master* pm, enum display_type dtype,
int seqnum)
{
/* Print the name of the protocol */
if (zlog_default)
vty_out (vty, "%s: ", zlog_get_proto_name(NULL));
if (dtype == normal_display)
{
vty_prefix_list_name_count_print(vty, plist, VTY_NEWLINE) ;
vty_prefix_list_desc_print(vty, plist, 3, VTY_NEWLINE) ;
}
else if (dtype == summary_display || dtype == detail_display)
{
struct prefix_list_entry* p_f = vector_get_first_item(&plist->list) ;
struct prefix_list_entry* p_l = vector_get_last_item(&plist->list) ;
vty_prefix_list_name_print(vty, plist, ":") ;
vty_out(vty, VTY_NEWLINE) ;
vty_prefix_list_desc_print(vty, plist, 3, VTY_NEWLINE) ;
vty_out (vty, " count: %d, range entries: %d, sequences: %d - %d%s",
vector_end(&plist->list), plist->rangecount,
p_f ? p_f->seq : 0,
p_l ? p_l->seq : 0,
VTY_NEWLINE);
} ;
if (dtype != summary_display)
{
struct prefix_list_entry* pe ;
vector_index_t i ;
int with_seq = pm->seqnum_flag ;
int with_stats = (dtype == detail_display)
||(dtype == sequential_display) ;
for (VECTOR_ITEMS(&plist->list, pe, i))
{
if ((dtype == sequential_display) && (pe->seq != seqnum))
continue;
vty_out_indent(vty, 3);
vty_prefix_list_value_print(vty, pe, VTY_NEWLINE,
with_seq, with_stats) ;
}
}
}
/* Show given prefix list in given afi, or all prefix lists in given afi. */
static int
vty_show_prefix_list (struct vty *vty, afi_t afi, const char *name,
const char *seq_str, enum display_type dtype)
{
struct prefix_list *plist;
struct prefix_master *pm;
int seq = 0;
pm = prefix_master_get(afi) ;
if (pm == NULL)
return CMD_WARNING;
if (seq_str)
seq = atoi (seq_str);
if (name)
{
/* Note that asking after an undefined prefix_list is an error. */
/* Does not mention references to an undefined prefix_list. */
plist = vty_prefix_list_lookup(vty, afi, name);
if (plist == NULL)
return CMD_WARNING;
vty_show_prefix_entry (vty, plist, pm, dtype, seq);
}
else
{
vector extract ;
vector_index_t i ;
struct symbol* sym ;
if (dtype == detail_display || dtype == summary_display)
{
if (pm->recent)
vty_out (vty, "Prefix-list with the last deletion/insertion: %s%s",
(const char*)symbol_get_name(pm->recent->sym), VTY_NEWLINE) ;
}
/* Extract a vector of all prefix_list symbols, in name order. */
extract = symbol_table_extract(&pm->table, NULL, NULL, 0,
symbol_mixed_name_cmp) ;
for (VECTOR_ITEMS(extract, sym, i))
{
plist = symbol_get_value(sym) ;
if (plist != NULL)
vty_show_prefix_entry(vty, plist, pm, dtype, seq);
else
vty_prefix_list_undefined_print(vty, afi, sym, VTY_NEWLINE) ;
}
vector_free(extract) ; /* throw away temporary vector */
}
return CMD_SUCCESS;
}
static int
vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, const char *name,
const char *prefix, enum display_type type)
{
struct prefix_list *plist;
struct prefix_list_entry* pe ;
vector_index_t i ;
struct prefix p;
int ret;
int match;
int with_stats ;
/* Error if cannot find prefix list. */
plist = vty_prefix_list_lookup(vty, afi, name);
if (plist == NULL)
return CMD_WARNING;
ret = str2prefix (prefix, &p);
if (ret <= 0)
{
vty_out (vty, "%% prefix is malformed%s", VTY_NEWLINE);
return CMD_WARNING;
}
with_stats = (type == normal_display) || (type == first_match_display) ;
for (VECTOR_ITEMS(&plist->list, pe, i))
{
match = 0;
if ((type == normal_display || type == first_match_display))
match = prefix_same(&p, &pe->prefix) ;
else if (type == longer_display)
match = (prefix_match (&p, &pe->prefix)) ;
if (match)
{
vty_out_indent(vty, 3);
vty_prefix_list_value_print(vty, pe, VTY_NEWLINE, 1, with_stats) ;
if (type == first_match_display)
break ;
}
}
return CMD_SUCCESS;
}
/* Clear hit counters in all prefix_list_entries:
*
* a) in all prefix_lists -- name NULL
* b) in given prefix list -- prefix NULL
* c) that match given prefix, in given prefix_list
*/
static int
vty_clear_prefix_list (struct vty *vty, afi_t afi, const char *name,
const char *prefix)
{
struct prefix_master *pm;
struct prefix_list *plist;
int ret;
struct prefix p;
struct prefix_list_entry* pe ;
vector_index_t i ;
pm = prefix_master_get (afi);
if (pm == NULL)
return CMD_WARNING;
if (name == NULL)
{
struct symbol_walker walker ;
symbol_walk_start(&pm->table, &walker) ;
while ((plist = symbol_get_value(symbol_walk_next(&walker))))
{
if (plist == NULL)
continue ;
for (VECTOR_ITEMS(&plist->list, pe, i))
pe->hitcnt = 0 ;
} ;
}
else
{
/* Error if cannot find prefix list. */
plist = vty_prefix_list_lookup(vty, afi, name);
if (plist == NULL)
return CMD_WARNING;
if (prefix != NULL)
{
ret = str2prefix (prefix, &p);
if (ret <= 0)
{
vty_out (vty, "%% prefix is malformed%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
for (VECTOR_ITEMS(&plist->list, pe, i))
if ((prefix == NULL) || prefix_match(&pe->prefix, &p))
pe->hitcnt = 0;
} ;
return CMD_SUCCESS;
}
DEFUN (ip_prefix_list,
ip_prefix_list_cmd,
"ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
{
return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL,
argv[1], argv[2], NULL, NULL);
}
DEFUN (ip_prefix_list_ge,
ip_prefix_list_ge_cmd,
"ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1],
argv[2], argv[3], NULL);
}
DEFUN (ip_prefix_list_ge_le,
ip_prefix_list_ge_le_cmd,
"ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1],
argv[2], argv[3], argv[4]);
}
DEFUN (ip_prefix_list_le,
ip_prefix_list_le_cmd,
"ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1],
argv[2], NULL, argv[3]);
}
DEFUN (ip_prefix_list_le_ge,
ip_prefix_list_le_ge_cmd,
"ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1],
argv[2], argv[4], argv[3]);
}
DEFUN (ip_prefix_list_seq,
ip_prefix_list_seq_cmd,
"ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
{
return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2],
argv[3], NULL, NULL);
}
DEFUN (ip_prefix_list_seq_ge,
ip_prefix_list_seq_ge_cmd,
"ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2],
argv[3], argv[4], NULL);
}
DEFUN (ip_prefix_list_seq_ge_le,
ip_prefix_list_seq_ge_le_cmd,
"ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2],
argv[3], argv[4], argv[5]);
}
DEFUN (ip_prefix_list_seq_le,
ip_prefix_list_seq_le_cmd,
"ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2],
argv[3], NULL, argv[4]);
}
DEFUN (ip_prefix_list_seq_le_ge,
ip_prefix_list_seq_le_ge_cmd,
"ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2],
argv[3], argv[5], argv[4]);
}
DEFUN (no_ip_prefix_list,
no_ip_prefix_list_cmd,
"no ip prefix-list WORD",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, NULL,
NULL, NULL, NULL);
}
DEFUN (no_ip_prefix_list_prefix,
no_ip_prefix_list_prefix_cmd,
"no ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1],
argv[2], NULL, NULL);
}
DEFUN (no_ip_prefix_list_ge,
no_ip_prefix_list_ge_cmd,
"no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1],
argv[2], argv[3], NULL);
}
DEFUN (no_ip_prefix_list_ge_le,
no_ip_prefix_list_ge_le_cmd,
"no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1],
argv[2], argv[3], argv[4]);
}
DEFUN (no_ip_prefix_list_le,
no_ip_prefix_list_le_cmd,
"no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1],
argv[2], NULL, argv[3]);
}
DEFUN (no_ip_prefix_list_le_ge,
no_ip_prefix_list_le_ge_cmd,
"no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1],
argv[2], argv[4], argv[3]);
}
DEFUN (no_ip_prefix_list_seq,
no_ip_prefix_list_seq_cmd,
"no ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2],
argv[3], NULL, NULL);
}
DEFUN (no_ip_prefix_list_seq_ge,
no_ip_prefix_list_seq_ge_cmd,
"no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2],
argv[3], argv[4], NULL);
}
DEFUN (no_ip_prefix_list_seq_ge_le,
no_ip_prefix_list_seq_ge_le_cmd,
"no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2],
argv[3], argv[4], argv[5]);
}
DEFUN (no_ip_prefix_list_seq_le,
no_ip_prefix_list_seq_le_cmd,
"no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2],
argv[3], NULL, argv[4]);
}
DEFUN (no_ip_prefix_list_seq_le_ge,
no_ip_prefix_list_seq_le_ge_cmd,
"no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2],
argv[3], argv[5], argv[4]);
}
DEFUN (ip_prefix_list_sequence_number,
ip_prefix_list_sequence_number_cmd,
"ip prefix-list sequence-number",
IP_STR
PREFIX_LIST_STR
"Include/exclude sequence numbers in NVGEN\n")
{
prefix_master_ipv4.seqnum_flag = 1;
return CMD_SUCCESS;
}
DEFUN (no_ip_prefix_list_sequence_number,
no_ip_prefix_list_sequence_number_cmd,
"no ip prefix-list sequence-number",
NO_STR
IP_STR
PREFIX_LIST_STR
"Include/exclude sequence numbers in NVGEN\n")
{
prefix_master_ipv4.seqnum_flag = 0;
return CMD_SUCCESS;
}
DEFUN (ip_prefix_list_description,
ip_prefix_list_description_cmd,
"ip prefix-list WORD description .LINE",
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Prefix-list specific description\n"
"Up to 80 characters describing this prefix-list\n")
{
return vty_prefix_list_desc_set (vty, AFI_IP, argv[0],
argv_concat(argv, argc, 1));
} ;
DEFUN (no_ip_prefix_list_description,
no_ip_prefix_list_description_cmd,
"no ip prefix-list WORD description",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Prefix-list specific description\n")
{
return vty_prefix_list_desc_unset (vty, AFI_IP, argv[0]);
}
ALIAS (no_ip_prefix_list_description,
no_ip_prefix_list_description_arg_cmd,
"no ip prefix-list WORD description .LINE",
NO_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Prefix-list specific description\n"
"Up to 80 characters describing this prefix-list\n")
DEFUN (show_ip_prefix_list,
show_ip_prefix_list_cmd,
"show ip prefix-list",
SHOW_STR
IP_STR
PREFIX_LIST_STR)
{
return vty_show_prefix_list (vty, AFI_IP, NULL, NULL, normal_display);
}
DEFUN (show_ip_prefix_list_name,
show_ip_prefix_list_name_cmd,
"show ip prefix-list WORD",
SHOW_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n")
{
return vty_show_prefix_list (vty, AFI_IP, argv[0], NULL, normal_display);
}
DEFUN (show_ip_prefix_list_name_seq,
show_ip_prefix_list_name_seq_cmd,
"show ip prefix-list WORD seq <1-4294967295>",
SHOW_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n")
{
return vty_show_prefix_list (vty, AFI_IP, argv[0], argv[1], sequential_display);
}
DEFUN (show_ip_prefix_list_prefix,
show_ip_prefix_list_prefix_cmd,
"show ip prefix-list WORD A.B.C.D/M",
SHOW_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
{
return vty_show_prefix_list_prefix (vty, AFI_IP, argv[0], argv[1], normal_display);
}
DEFUN (show_ip_prefix_list_prefix_longer,
show_ip_prefix_list_prefix_longer_cmd,
"show ip prefix-list WORD A.B.C.D/M longer",
SHOW_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Lookup longer prefix\n")
{
return vty_show_prefix_list_prefix (vty, AFI_IP, argv[0], argv[1], longer_display);
}
DEFUN (show_ip_prefix_list_prefix_first_match,
show_ip_prefix_list_prefix_first_match_cmd,
"show ip prefix-list WORD A.B.C.D/M first-match",
SHOW_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"First matched prefix\n")
{
return vty_show_prefix_list_prefix (vty, AFI_IP, argv[0], argv[1], first_match_display);
}
DEFUN (show_ip_prefix_list_summary,
show_ip_prefix_list_summary_cmd,
"show ip prefix-list summary",
SHOW_STR
IP_STR
PREFIX_LIST_STR
"Summary of prefix lists\n")
{
return vty_show_prefix_list (vty, AFI_IP, NULL, NULL, summary_display);
}
DEFUN (show_ip_prefix_list_summary_name,
show_ip_prefix_list_summary_name_cmd,
"show ip prefix-list summary WORD",
SHOW_STR
IP_STR
PREFIX_LIST_STR
"Summary of prefix lists\n"
"Name of a prefix list\n")
{
return vty_show_prefix_list (vty, AFI_IP, argv[0], NULL, summary_display);
}
DEFUN (show_ip_prefix_list_detail,
show_ip_prefix_list_detail_cmd,
"show ip prefix-list detail",
SHOW_STR
IP_STR
PREFIX_LIST_STR
"Detail of prefix lists\n")
{
return vty_show_prefix_list (vty, AFI_IP, NULL, NULL, detail_display);
}
DEFUN (show_ip_prefix_list_detail_name,
show_ip_prefix_list_detail_name_cmd,
"show ip prefix-list detail WORD",
SHOW_STR
IP_STR
PREFIX_LIST_STR
"Detail of prefix lists\n"
"Name of a prefix list\n")
{
return vty_show_prefix_list (vty, AFI_IP, argv[0], NULL, detail_display);
}
DEFUN (clear_ip_prefix_list,
clear_ip_prefix_list_cmd,
"clear ip prefix-list",
CLEAR_STR
IP_STR
PREFIX_LIST_STR)
{
return vty_clear_prefix_list (vty, AFI_IP, NULL, NULL);
}
DEFUN (clear_ip_prefix_list_name,
clear_ip_prefix_list_name_cmd,
"clear ip prefix-list WORD",
CLEAR_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n")
{
return vty_clear_prefix_list (vty, AFI_IP, argv[0], NULL);
}
DEFUN (clear_ip_prefix_list_name_prefix,
clear_ip_prefix_list_name_prefix_cmd,
"clear ip prefix-list WORD A.B.C.D/M",
CLEAR_STR
IP_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
{
return vty_clear_prefix_list (vty, AFI_IP, argv[0], argv[1]);
}
#ifdef HAVE_IPV6
DEFUN (ipv6_prefix_list,
ipv6_prefix_list_cmd,
"ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Any prefix match. Same as \"::0/0 le 128\"\n")
{
return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL,
argv[1], argv[2], NULL, NULL);
}
DEFUN (ipv6_prefix_list_ge,
ipv6_prefix_list_ge_cmd,
"ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, argv[1],
argv[2], argv[3], NULL);
}
DEFUN (ipv6_prefix_list_ge_le,
ipv6_prefix_list_ge_le_cmd,
"ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, argv[1],
argv[2], argv[3], argv[4]);
}
DEFUN (ipv6_prefix_list_le,
ipv6_prefix_list_le_cmd,
"ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, argv[1],
argv[2], NULL, argv[3]);
}
DEFUN (ipv6_prefix_list_le_ge,
ipv6_prefix_list_le_ge_cmd,
"ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, argv[1],
argv[2], argv[4], argv[3]);
}
DEFUN (ipv6_prefix_list_seq,
ipv6_prefix_list_seq_cmd,
"ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Any prefix match. Same as \"::0/0 le 128\"\n")
{
return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2],
argv[3], NULL, NULL);
}
DEFUN (ipv6_prefix_list_seq_ge,
ipv6_prefix_list_seq_ge_cmd,
"ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2],
argv[3], argv[4], NULL);
}
DEFUN (ipv6_prefix_list_seq_ge_le,
ipv6_prefix_list_seq_ge_le_cmd,
"ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2],
argv[3], argv[4], argv[5]);
}
DEFUN (ipv6_prefix_list_seq_le,
ipv6_prefix_list_seq_le_cmd,
"ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2],
argv[3], NULL, argv[4]);
}
DEFUN (ipv6_prefix_list_seq_le_ge,
ipv6_prefix_list_seq_le_ge_cmd,
"ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2],
argv[3], argv[5], argv[4]);
}
DEFUN (no_ipv6_prefix_list,
no_ipv6_prefix_list_cmd,
"no ipv6 prefix-list WORD",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, NULL,
NULL, NULL, NULL);
}
DEFUN (no_ipv6_prefix_list_prefix,
no_ipv6_prefix_list_prefix_cmd,
"no ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Any prefix match. Same as \"::0/0 le 128\"\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1],
argv[2], NULL, NULL);
}
DEFUN (no_ipv6_prefix_list_ge,
no_ipv6_prefix_list_ge_cmd,
"no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1],
argv[2], argv[3], NULL);
}
DEFUN (no_ipv6_prefix_list_ge_le,
no_ipv6_prefix_list_ge_le_cmd,
"no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1],
argv[2], argv[3], argv[4]);
}
DEFUN (no_ipv6_prefix_list_le,
no_ipv6_prefix_list_le_cmd,
"no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1],
argv[2], NULL, argv[3]);
}
DEFUN (no_ipv6_prefix_list_le_ge,
no_ipv6_prefix_list_le_ge_cmd,
"no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1],
argv[2], argv[4], argv[3]);
}
DEFUN (no_ipv6_prefix_list_seq,
no_ipv6_prefix_list_seq_cmd,
"no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Any prefix match. Same as \"::0/0 le 128\"\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2],
argv[3], NULL, NULL);
}
DEFUN (no_ipv6_prefix_list_seq_ge,
no_ipv6_prefix_list_seq_ge_cmd,
"no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2],
argv[3], argv[4], NULL);
}
DEFUN (no_ipv6_prefix_list_seq_ge_le,
no_ipv6_prefix_list_seq_ge_le_cmd,
"no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2],
argv[3], argv[4], argv[5]);
}
DEFUN (no_ipv6_prefix_list_seq_le,
no_ipv6_prefix_list_seq_le_cmd,
"no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2],
argv[3], NULL, argv[4]);
}
DEFUN (no_ipv6_prefix_list_seq_le_ge,
no_ipv6_prefix_list_seq_le_ge_cmd,
"no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Maximum prefix length to be matched\n"
"Maximum prefix length\n"
"Minimum prefix length to be matched\n"
"Minimum prefix length\n")
{
return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2],
argv[3], argv[5], argv[4]);
}
DEFUN (ipv6_prefix_list_sequence_number,
ipv6_prefix_list_sequence_number_cmd,
"ipv6 prefix-list sequence-number",
IPV6_STR
PREFIX_LIST_STR
"Include/exclude sequence numbers in NVGEN\n")
{
prefix_master_ipv6.seqnum_flag = 1;
return CMD_SUCCESS;
}
DEFUN (no_ipv6_prefix_list_sequence_number,
no_ipv6_prefix_list_sequence_number_cmd,
"no ipv6 prefix-list sequence-number",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Include/exclude sequence numbers in NVGEN\n")
{
prefix_master_ipv6.seqnum_flag = 0;
return CMD_SUCCESS;
}
DEFUN (ipv6_prefix_list_description,
ipv6_prefix_list_description_cmd,
"ipv6 prefix-list WORD description .LINE",
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Prefix-list specific description\n"
"Up to 80 characters describing this prefix-list\n")
{
return vty_prefix_list_desc_set (vty, AFI_IP6, argv[0],
argv_concat(argv, argc, 1));
}
DEFUN (no_ipv6_prefix_list_description,
no_ipv6_prefix_list_description_cmd,
"no ipv6 prefix-list WORD description",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Prefix-list specific description\n")
{
return vty_prefix_list_desc_unset (vty, AFI_IP6, argv[0]);
}
ALIAS (no_ipv6_prefix_list_description,
no_ipv6_prefix_list_description_arg_cmd,
"no ipv6 prefix-list WORD description .LINE",
NO_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"Prefix-list specific description\n"
"Up to 80 characters describing this prefix-list\n")
DEFUN (show_ipv6_prefix_list,
show_ipv6_prefix_list_cmd,
"show ipv6 prefix-list",
SHOW_STR
IPV6_STR
PREFIX_LIST_STR)
{
return vty_show_prefix_list (vty, AFI_IP6, NULL, NULL, normal_display);
}
DEFUN (show_ipv6_prefix_list_name,
show_ipv6_prefix_list_name_cmd,
"show ipv6 prefix-list WORD",
SHOW_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n")
{
return vty_show_prefix_list (vty, AFI_IP6, argv[0], NULL, normal_display);
}
DEFUN (show_ipv6_prefix_list_name_seq,
show_ipv6_prefix_list_name_seq_cmd,
"show ipv6 prefix-list WORD seq <1-4294967295>",
SHOW_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"sequence number of an entry\n"
"Sequence number\n")
{
return vty_show_prefix_list (vty, AFI_IP6, argv[0], argv[1], sequential_display);
}
DEFUN (show_ipv6_prefix_list_prefix,
show_ipv6_prefix_list_prefix_cmd,
"show ipv6 prefix-list WORD X:X::X:X/M",
SHOW_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
{
return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[0], argv[1], normal_display);
}
DEFUN (show_ipv6_prefix_list_prefix_longer,
show_ipv6_prefix_list_prefix_longer_cmd,
"show ipv6 prefix-list WORD X:X::X:X/M longer",
SHOW_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Lookup longer prefix\n")
{
return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[0], argv[1], longer_display);
}
DEFUN (show_ipv6_prefix_list_prefix_first_match,
show_ipv6_prefix_list_prefix_first_match_cmd,
"show ipv6 prefix-list WORD X:X::X:X/M first-match",
SHOW_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"First matched prefix\n")
{
return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[0], argv[1], first_match_display);
}
DEFUN (show_ipv6_prefix_list_summary,
show_ipv6_prefix_list_summary_cmd,
"show ipv6 prefix-list summary",
SHOW_STR
IPV6_STR
PREFIX_LIST_STR
"Summary of prefix lists\n")
{
return vty_show_prefix_list (vty, AFI_IP6, NULL, NULL, summary_display);
}
DEFUN (show_ipv6_prefix_list_summary_name,
show_ipv6_prefix_list_summary_name_cmd,
"show ipv6 prefix-list summary WORD",
SHOW_STR
IPV6_STR
PREFIX_LIST_STR
"Summary of prefix lists\n"
"Name of a prefix list\n")
{
return vty_show_prefix_list (vty, AFI_IP6, argv[0], NULL, summary_display);
}
DEFUN (show_ipv6_prefix_list_detail,
show_ipv6_prefix_list_detail_cmd,
"show ipv6 prefix-list detail",
SHOW_STR
IPV6_STR
PREFIX_LIST_STR
"Detail of prefix lists\n")
{
return vty_show_prefix_list (vty, AFI_IP6, NULL, NULL, detail_display);
}
DEFUN (show_ipv6_prefix_list_detail_name,
show_ipv6_prefix_list_detail_name_cmd,
"show ipv6 prefix-list detail WORD",
SHOW_STR
IPV6_STR
PREFIX_LIST_STR
"Detail of prefix lists\n"
"Name of a prefix list\n")
{
return vty_show_prefix_list (vty, AFI_IP6, argv[0], NULL, detail_display);
}
DEFUN (clear_ipv6_prefix_list,
clear_ipv6_prefix_list_cmd,
"clear ipv6 prefix-list",
CLEAR_STR
IPV6_STR
PREFIX_LIST_STR)
{
return vty_clear_prefix_list (vty, AFI_IP6, NULL, NULL);
}
DEFUN (clear_ipv6_prefix_list_name,
clear_ipv6_prefix_list_name_cmd,
"clear ipv6 prefix-list WORD",
CLEAR_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n")
{
return vty_clear_prefix_list (vty, AFI_IP6, argv[0], NULL);
}
DEFUN (clear_ipv6_prefix_list_name_prefix,
clear_ipv6_prefix_list_name_prefix_cmd,
"clear ipv6 prefix-list WORD X:X::X:X/M",
CLEAR_STR
IPV6_STR
PREFIX_LIST_STR
"Name of a prefix list\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
{
return vty_clear_prefix_list (vty, AFI_IP6, argv[0], argv[1]);
}
#endif /* HAVE_IPV6 */
/* Configuration write function. */
static int
config_write_prefix_afi (afi_t afi, struct vty *vty)
{
struct prefix_list *plist;
struct prefix_list_entry *pe;
struct prefix_master *pm;
int write = 0;
vector extract ;
vector_index_t i, ipe ;
struct symbol* sym ;
pm = prefix_master_get (afi);
if (pm == NULL)
return 0;
if (! pm->seqnum_flag)
{
vty_out (vty, "no ip%s prefix-list sequence-number%s",
afi == AFI_IP ? "" : "v6", VTY_NEWLINE);
vty_out (vty, "!%s", VTY_NEWLINE);
}
/* Extract a vector of all prefix_list symbols, in name order. */
extract = symbol_table_extract(&pm->table, NULL, NULL, 0,
symbol_mixed_name_cmp) ;
for (VECTOR_ITEMS(extract, sym, i))
{
plist = symbol_get_value(sym) ;
if (plist)
{
if (plist->desc)
{
vty_prefix_list_name_print(vty, plist, "") ;
vty_out (vty, " description %s%s", plist->desc, VTY_NEWLINE) ;
write++ ;
}
for (VECTOR_ITEMS(&plist->list, pe, ipe))
{
vty_prefix_list_name_print(vty, plist, " ") ;
vty_prefix_list_value_print(vty, pe, VTY_NEWLINE,
pm->seqnum_flag, 0) ;
write++ ;
}
}
else
{
vty_out(vty, "!! ") ;
vty_prefix_list_undefined_print(vty, afi, sym, VTY_NEWLINE) ;
write++ ;
} ;
} ;
vector_free(extract) ; /* discard temporary vector */
return write;
}
struct stream *
prefix_bgp_orf_entry (struct stream *s, prefix_list_ref ref,
u_char init_flag, u_char permit_flag, u_char deny_flag)
{
struct prefix_list_entry *pe;
vector_index_t i ;
struct prefix_list *plist = prefix_list_ref_plist(ref) ;
if (! plist)
return s;
for (VECTOR_ITEMS(&plist->list, pe, i))
{
stream_putc (s, init_flag | (pe->type == PREFIX_PERMIT ? permit_flag
: deny_flag));
stream_putl (s, (u_int32_t)pe->seq);
stream_putc (s, (u_char)pe->ge);
stream_putc (s, (u_char)pe->le);
stream_put_prefix (s, &pe->prefix);
}
return s;
}
/* Get the i'th BGP ORF prefix from the given list.
* return 1 - got ORF prefix.
* return 0 - no such entry
*/
int
prefix_bgp_orf_get(struct prefix_list *plist, vector_index_t i,
struct orf_prefix *orfpe, enum prefix_list_type *pe_type)
{
struct prefix_list_entry *pe = NULL;
if (!plist || i >= plist->list.end)
return 0;
pe = vector_slot(&plist->list, i);
orfpe->seq = pe->seq;
orfpe->ge = pe->ge;
orfpe->le = pe->le;
orfpe->p = pe->prefix;
*pe_type = pe->type;
return 1;
}
/* Set or Unset a BGP ORF entry. */
int
prefix_bgp_orf_set (char *name, afi_t afi, struct orf_prefix *orfp,
int permit, int set)
{
struct prefix_list *plist ;
struct prefix_list_entry temp ;
int ret ;
assert_afi_real(afi) ;
/* Transfer the values from the orf_prefix */
prefix_list_entry_init(&temp) ;
temp.type = permit ? PREFIX_PERMIT : PREFIX_DENY ;
temp.prefix = orfp->p ;
temp.seq = orfp->seq ; /* NB: U32 and may be zero */
if (orfp->ge)
{
temp.flags |= PREFIX_GE ;
temp.ge = orfp->ge ;
}
if (orfp->le)
{
temp.flags |= PREFIX_LE ;
temp.le = orfp->le ;
}
/* Make sure ge & le are acceptable and set as required */
ret = prefix_list_entry_ge_le_check(&temp, afi) ;
if (ret != CMD_SUCCESS)
return ret ;
/* Now insert or delete */
if (set)
{
plist = prefix_list_get(&prefix_master_orf, name, afi);
return prefix_list_entry_insert(plist, &temp) ;
}
else
{
plist = prefix_list_seek(&prefix_master_orf, name) ;
if (plist == NULL)
return CMD_WARNING ;
return prefix_list_entry_delete(plist, &temp) ;
}
}
void
prefix_bgp_orf_remove_all (char *name)
{
struct prefix_list *plist;
plist = prefix_list_lookup (AFI_ORF_PREFIX, name);
if (plist)
prefix_list_delete (plist);
}
/* return prefix count */
int
prefix_bgp_show_prefix_list (struct vty *vty, afi_t afi, char *name)
{
struct prefix_list *plist ;
plist = prefix_list_lookup (AFI_ORF_PREFIX, name);
if (! plist)
return 0;
if (vty)
{
struct prefix_list_entry* pe ;
vector_index_t i ;
vty_prefix_list_name_count_print(vty, plist, VTY_NEWLINE) ;
for (VECTOR_ITEMS(&plist->list, pe, i))
{
vty_out_indent(vty, 3) ;
vty_prefix_list_value_print(vty, pe, VTY_NEWLINE, 1, 1) ;
}
}
return vector_end(&plist->list);
}
static void
prefix_list_reset_orf (void)
{
prefix_master_reset(&prefix_master_orf) ;
}
/* Prefix-list node. */
static struct cmd_node prefix_node =
{
PREFIX_NODE,
"", /* Prefix list has no interface. */
1
};
static int
config_write_prefix_ipv4 (struct vty *vty)
{
return config_write_prefix_afi (AFI_IP, vty);
}
static void
prefix_list_reset_ipv4 (void)
{
prefix_master_reset(&prefix_master_ipv4) ;
}
static void
prefix_list_init_ipv4 (void)
{
prefix_master_init(&prefix_master_ipv4) ;
install_node (&prefix_node, config_write_prefix_ipv4);
install_element (CONFIG_NODE, &ip_prefix_list_cmd);
install_element (CONFIG_NODE, &ip_prefix_list_ge_cmd);
install_element (CONFIG_NODE, &ip_prefix_list_ge_le_cmd);
install_element (CONFIG_NODE, &ip_prefix_list_le_cmd);
install_element (CONFIG_NODE, &ip_prefix_list_le_ge_cmd);
install_element (CONFIG_NODE, &ip_prefix_list_seq_cmd);
install_element (CONFIG_NODE, &ip_prefix_list_seq_ge_cmd);
install_element (CONFIG_NODE, &ip_prefix_list_seq_ge_le_cmd);
install_element (CONFIG_NODE, &ip_prefix_list_seq_le_cmd);
install_element (CONFIG_NODE, &ip_prefix_list_seq_le_ge_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_prefix_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_ge_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_ge_le_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_le_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_le_ge_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_seq_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_seq_ge_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_seq_ge_le_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_seq_le_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_seq_le_ge_cmd);
install_element (CONFIG_NODE, &ip_prefix_list_description_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_description_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_description_arg_cmd);
install_element (CONFIG_NODE, &ip_prefix_list_sequence_number_cmd);
install_element (CONFIG_NODE, &no_ip_prefix_list_sequence_number_cmd);
install_element (VIEW_NODE, &show_ip_prefix_list_cmd);
install_element (VIEW_NODE, &show_ip_prefix_list_name_cmd);
install_element (VIEW_NODE, &show_ip_prefix_list_name_seq_cmd);
install_element (VIEW_NODE, &show_ip_prefix_list_prefix_cmd);
install_element (VIEW_NODE, &show_ip_prefix_list_prefix_longer_cmd);
install_element (VIEW_NODE, &show_ip_prefix_list_prefix_first_match_cmd);
install_element (VIEW_NODE, &show_ip_prefix_list_summary_cmd);
install_element (VIEW_NODE, &show_ip_prefix_list_summary_name_cmd);
install_element (VIEW_NODE, &show_ip_prefix_list_detail_cmd);
install_element (VIEW_NODE, &show_ip_prefix_list_detail_name_cmd);
install_element (ENABLE_NODE, &show_ip_prefix_list_cmd);
install_element (ENABLE_NODE, &show_ip_prefix_list_name_cmd);
install_element (ENABLE_NODE, &show_ip_prefix_list_name_seq_cmd);
install_element (ENABLE_NODE, &show_ip_prefix_list_prefix_cmd);
install_element (ENABLE_NODE, &show_ip_prefix_list_prefix_longer_cmd);
install_element (ENABLE_NODE, &show_ip_prefix_list_prefix_first_match_cmd);
install_element (ENABLE_NODE, &show_ip_prefix_list_summary_cmd);
install_element (ENABLE_NODE, &show_ip_prefix_list_summary_name_cmd);
install_element (ENABLE_NODE, &show_ip_prefix_list_detail_cmd);
install_element (ENABLE_NODE, &show_ip_prefix_list_detail_name_cmd);
install_element (ENABLE_NODE, &clear_ip_prefix_list_cmd);
install_element (ENABLE_NODE, &clear_ip_prefix_list_name_cmd);
install_element (ENABLE_NODE, &clear_ip_prefix_list_name_prefix_cmd);
}
#ifdef HAVE_IPV6
/* Prefix-list node. */
static struct cmd_node prefix_ipv6_node =
{
PREFIX_IPV6_NODE,
"", /* Prefix list has no interface. */
1
};
static int
config_write_prefix_ipv6 (struct vty *vty)
{
return config_write_prefix_afi (AFI_IP6, vty);
}
static void
prefix_list_reset_ipv6 (void)
{
#ifdef HAVE_IPV6
prefix_master_reset(&prefix_master_ipv6) ;
#endif
} ;
static void
prefix_list_init_ipv6 (void)
{
prefix_master_init(&prefix_master_ipv6) ;
install_node (&prefix_ipv6_node, config_write_prefix_ipv6);
install_element (CONFIG_NODE, &ipv6_prefix_list_cmd);
install_element (CONFIG_NODE, &ipv6_prefix_list_ge_cmd);
install_element (CONFIG_NODE, &ipv6_prefix_list_ge_le_cmd);
install_element (CONFIG_NODE, &ipv6_prefix_list_le_cmd);
install_element (CONFIG_NODE, &ipv6_prefix_list_le_ge_cmd);
install_element (CONFIG_NODE, &ipv6_prefix_list_seq_cmd);
install_element (CONFIG_NODE, &ipv6_prefix_list_seq_ge_cmd);
install_element (CONFIG_NODE, &ipv6_prefix_list_seq_ge_le_cmd);
install_element (CONFIG_NODE, &ipv6_prefix_list_seq_le_cmd);
install_element (CONFIG_NODE, &ipv6_prefix_list_seq_le_ge_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_prefix_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_ge_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_ge_le_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_le_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_le_ge_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_ge_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_ge_le_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_le_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_le_ge_cmd);
install_element (CONFIG_NODE, &ipv6_prefix_list_description_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_description_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_description_arg_cmd);
install_element (CONFIG_NODE, &ipv6_prefix_list_sequence_number_cmd);
install_element (CONFIG_NODE, &no_ipv6_prefix_list_sequence_number_cmd);
install_element (VIEW_NODE, &show_ipv6_prefix_list_cmd);
install_element (VIEW_NODE, &show_ipv6_prefix_list_name_cmd);
install_element (VIEW_NODE, &show_ipv6_prefix_list_name_seq_cmd);
install_element (VIEW_NODE, &show_ipv6_prefix_list_prefix_cmd);
install_element (VIEW_NODE, &show_ipv6_prefix_list_prefix_longer_cmd);
install_element (VIEW_NODE, &show_ipv6_prefix_list_prefix_first_match_cmd);
install_element (VIEW_NODE, &show_ipv6_prefix_list_summary_cmd);
install_element (VIEW_NODE, &show_ipv6_prefix_list_summary_name_cmd);
install_element (VIEW_NODE, &show_ipv6_prefix_list_detail_cmd);
install_element (VIEW_NODE, &show_ipv6_prefix_list_detail_name_cmd);
install_element (ENABLE_NODE, &show_ipv6_prefix_list_cmd);
install_element (ENABLE_NODE, &show_ipv6_prefix_list_name_cmd);
install_element (ENABLE_NODE, &show_ipv6_prefix_list_name_seq_cmd);
install_element (ENABLE_NODE, &show_ipv6_prefix_list_prefix_cmd);
install_element (ENABLE_NODE, &show_ipv6_prefix_list_prefix_longer_cmd);
install_element (ENABLE_NODE, &show_ipv6_prefix_list_prefix_first_match_cmd);
install_element (ENABLE_NODE, &show_ipv6_prefix_list_summary_cmd);
install_element (ENABLE_NODE, &show_ipv6_prefix_list_summary_name_cmd);
install_element (ENABLE_NODE, &show_ipv6_prefix_list_detail_cmd);
install_element (ENABLE_NODE, &show_ipv6_prefix_list_detail_name_cmd);
install_element (ENABLE_NODE, &clear_ipv6_prefix_list_cmd);
install_element (ENABLE_NODE, &clear_ipv6_prefix_list_name_cmd);
install_element (ENABLE_NODE, &clear_ipv6_prefix_list_name_prefix_cmd);
}
#endif /* HAVE_IPV6 */
void
prefix_list_init ()
{
prefix_list_init_ipv4 ();
#ifdef HAVE_IPV6
prefix_list_init_ipv6 ();
#endif /* HAVE_IPV6 */
prefix_master_init(&prefix_master_orf) ;
}
void
prefix_list_reset ()
{
prefix_list_reset_ipv4 ();
#ifdef HAVE_IPV6
prefix_list_reset_ipv6 ();
#endif /* HAVE_IPV6 */
prefix_list_reset_orf ();
}
|