summaryrefslogtreecommitdiffstats
path: root/VNFs/vFW/pipeline/pipeline_vfw.c
blob: 934e442a01eb0091421185aca710f6b407c949f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
/*
// Copyright (c) 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/

/**
 * @file
 * Pipeline VFW FE Implementation.
 *
 * Implementation of the Pipeline VFW Front End (FE).
 * Runs on the Master pipeline, responsible for CLI commands.
 *
 */

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/queue.h>
#include <netinet/in.h>

#include <rte_common.h>
#include <rte_hexdump.h>
#include <rte_malloc.h>
#include <cmdline_rdline.h>
#include <cmdline_parse.h>
#include <cmdline_parse_num.h>
#include <cmdline_parse_string.h>
#include <cmdline_parse_ipaddr.h>
#include <cmdline_parse_etheraddr.h>
#include <cmdline_socket.h>
#include <cmdline.h>
#include <rte_table_acl.h>

#include "app.h"
#include "pipeline_common_fe.h"
#include "pipeline_vfw.h"
#include "pipeline_vfw_be.h"
#include "rte_cnxn_tracking.h"

/**
 * A structure defining the VFW rule for the TAILQ Tables.
 */
struct app_pipeline_vfw_rule {
       struct pipeline_vfw_key key;
       int32_t priority;
       uint32_t port_id;
       uint32_t action_id;
       uint32_t command;
       void *entry_ptr;

        TAILQ_ENTRY(app_pipeline_vfw_rule) node;
};

/**
 * A structure defining the VFW pipeline front end data.
 */
struct app_pipeline_vfw {
       /* parameters */
       uint32_t n_ports_in;
       uint32_t n_ports_out;
};

/*
 * Define a structure to calculate performance measurements for VFW.
 * VFW continually updates counters for total number of packets
 * processed, and total number of bytes processed. Each VFW backend thread
 * i.e.the packet processing instances updates their own copy of these counters.
 * An optional, 1 second periodic timer fires on the master core, which combines
 * those numbers to perform byte and packet per second calculations, without
 * burdening the packet processors.
 */
#define RTE_VFW_PERF_MSR_BUFF_SIZE 8       /* must be power of 2 */
#define RTE_VFW_PERF_MSR_BUFF_SIZE_MASK (RTE_VFW_PERF_MSR_BUFF_SIZE - 1)

/**
 * A structure defining the VFW performance measurements.
 */
struct rte_vfw_performance_measures_t {
       /* two circular buffers */
       uint64_t total_packets[RTE_VFW_PERF_MSR_BUFF_SIZE];
       uint64_t total_bytes[RTE_VFW_PERF_MSR_BUFF_SIZE];
       uint32_t bytes_last_second;
       uint32_t ave_bytes_per_second;
       uint32_t pkts_last_second;
       uint32_t ave_pkts_per_second;
       /* times data has been (over-)written into buffers */
       uint64_t total_entries;
       uint8_t current_index;       /* for circular buffers */
};

struct rte_vfw_performance_measures_t rte_vfw_performance_measures;

/*
 * Active and Standby Tables
 * Active and standby tables exist to allow modifying VFW rules and
 * actions and having no impact on the packet processing running on
 * the multiple VFW threads/pipelines. The packet processing does a
 * lookup on the active tables. Each VFW thread/pipeline runs on
 * a separate core (i.e. 2,3,4, etc).
 *
 * All CLI actions run on the VFW Front End (FE) code on Core 0.
 * All changes, adding/delete rules and action occurs on the standby tables.
 * In activate the changes in the standby table, the CLI command is entered:
 * p vfw applyruleset
 *
 * The standby tables become active. The active table becomes the standby.
 * The new standby table gets updated with the changes that were done.
 *
 * Table descriptions:
 * VFW Rule Tables TAILQ - 2 global tables active/standby per ipv4,ipv6
 * The TAILQ tables are required for the LS CLI command and in order
 * to do a lookup using a rule when adding or deleting a rule.
 * The VFW TRIE tables in DPDK do not allow this type of listing or lookup.
 *
 * VFW Rule Tables TRIE - 2 global tables active/standby per ipv4, ipv6
 * The TRIE tables are the tables used during packet processing.
 * A bulk lookup can be performed by passing in a burst of packets.
 * Unfortunately, the current implementation of the TRIE tables does
 * not allow lookup using a rule. Hence the need for the TAILQ tables.
 *
 * VFW Action Tables ARRAY - 2 global tables active/standby
 * The action tables stores the VFW actions.
 * Every rule has an action id which defines what action to take
 * when a packet matching that rule is received.
 * Actions: accept, drop, fwd, count, nat, dscp, conntrack
 *
 * Command Table TAILQ - 1 table
 * After the active and standby tables are swithover, the new standby
 * table needs to be updated with all the changes that were done.
 * This table stores all the add and delete commands and updates
 * the new standby table when the applyruleset command executes.
 *
 * The active and standby tables can be displayed individually:
 * p vfw ls 0    <== active VFW rules
 * p vfw ls 1    <== standby VFW rules
 * p action ls 0 <== active VFW actions
 * p action ls 1 <== standby VFW actions
 */

/* Only create global VFW tables once */
int vfw_rule_table_created;

/*
 * VFW Rule Tables TAILQ - see description above
 * Two tables/counters are required for active and standby.
 * The A and B tables/counters are the actual instances.
 * The pointers are set to point to these tables/counters.
 * The pointers are updated during the switchover for the applyruleset.
 */

/* Definition of the the TAILQ table */
TAILQ_HEAD(app_pipeline_vfw_rule_type, app_pipeline_vfw_rule);
/* Instances of tables and counters */
struct app_pipeline_vfw_rule_type vfw_tailq_rules_ipv4a;
struct app_pipeline_vfw_rule_type vfw_tailq_rules_ipv4b;
struct app_pipeline_vfw_rule_type vfw_tailq_rules_ipv6a;
struct app_pipeline_vfw_rule_type vfw_tailq_rules_ipv6b;
uint32_t vfw_n_tailq_rules_ipv4a;
uint32_t vfw_n_tailq_rules_ipv6a;
uint32_t vfw_n_tailq_rules_ipv4b;
uint32_t vfw_n_tailq_rules_ipv6b;
/* Pointers to tables and counters for switchover in applyruleset */
struct app_pipeline_vfw_rule_type *vfw_tailq_rules_ipv4_active;
struct app_pipeline_vfw_rule_type *vfw_tailq_rules_ipv4_standby;
struct app_pipeline_vfw_rule_type *vfw_tailq_rules_ipv6_active;
struct app_pipeline_vfw_rule_type *vfw_tailq_rules_ipv6_standby;
struct app_pipeline_vfw_rule_type *vfw_tailq_rules_temp_ptr;
uint32_t *vfw_n_tailq_rules_ipv4_active;
uint32_t *vfw_n_tailq_rules_ipv4_standby;
uint32_t *vfw_n_tailq_rules_ipv6_active;
uint32_t *vfw_n_tailq_rules_ipv6_standby;

/* VFW commands to update new standby tables after switchover */
TAILQ_HEAD(, app_pipeline_vfw_rule) vfw_commands;

/* VFW IPV4 and IPV6 enable flags for debugging (Default both on) */
int vfw_ipv4_enabled = 1;
int vfw_ipv6_enabled = 1;

/* Number of VFW Rules, default 4 * 1024 */
uint32_t vfw_n_rules = 4 * 1024;
/* VFW Rule Table TRIE - 2 (Active, Standby) Global table per ipv4, ipv6 */
void *vfw_rule_table_ipv4_active;
void *vfw_rule_table_ipv4_standby;
void *vfw_rule_table_ipv6_active;
void *vfw_rule_table_ipv6_standby;

/**
 * Reset running averages for performance measurements.
 *
 */
static void rte_vfw_reset_running_averages(void)
{
       memset(&rte_vfw_performance_measures, 0,
              sizeof(rte_vfw_performance_measures));
};

/**
 * Compute performance calculations on master to reduce computing on
 * packet processor.
 *
 * @param total_bytes
 *  Total bytes processed during this interval.
 * @param total_packets
 *  Total packets processed during this interval.
 *
 */
static void rte_vfw_update_performance_measures(uint64_t total_bytes,
                                             uint64_t total_packets)
{
       /* make readable */
       struct rte_vfw_performance_measures_t *pm =
           &rte_vfw_performance_measures;

       if (unlikely(pm->total_entries == 0 && total_packets == 0))
              /* the timer is running, but no traffic started yet,
               * so do nothing */
              return;

       if (likely(pm->total_entries > 0)) {
              uint8_t oldest_index;
              uint8_t divisor;

              pm->bytes_last_second =
                  total_bytes - pm->total_bytes[pm->current_index];
              pm->pkts_last_second =
                  total_packets - pm->total_packets[pm->current_index];

              /* if total_entries zero, current_index must remain as zero */
              pm->current_index =
                  (pm->current_index +
                   1) & RTE_VFW_PERF_MSR_BUFF_SIZE_MASK;

              if (unlikely
                  (pm->total_entries <= RTE_VFW_PERF_MSR_BUFF_SIZE)) {
                     /* oldest value is at element 0 */
                     oldest_index = 0;
                     divisor = pm->total_entries;
                     /* note, prior to incrementing total_entries */
              } else {
                     /* oldest value is at element about to be overwritten */
                     oldest_index = pm->current_index;
                     divisor = RTE_VFW_PERF_MSR_BUFF_SIZE;
              }

              pm->ave_bytes_per_second =
                  (total_bytes - pm->total_bytes[oldest_index]) / divisor;
              pm->ave_pkts_per_second =
                  (total_packets - pm->total_packets[oldest_index]) / divisor;
       }

       pm->total_bytes[pm->current_index] = total_bytes;
       pm->total_packets[pm->current_index] = total_packets;
       pm->total_entries++;
}

/**
 * Combine data from all vfw+connection tracking instances.
 * Calculate various statistics. Dump to console.
 *
 */
static void rte_vfw_sum_and_print_counters(void)
{
       int i;
       struct rte_VFW_counter_block vfw_counter_sums;
       struct rte_CT_counter_block ct_counter_sums;
       /* For ct instance with this fw instance */
       struct rte_CT_counter_block *ct_counters;

       memset(&vfw_counter_sums, 0, sizeof(vfw_counter_sums));
       memset(&ct_counter_sums, 0, sizeof(ct_counter_sums));

       for (i = 0; i <= rte_VFW_hi_counter_block_in_use; i++) {
              struct rte_VFW_counter_block *vfw_ctrs =
                  &rte_vfw_counter_table[i];
              ct_counters = rte_vfw_counter_table[i].ct_counters;

              uint64_t average_internal_time =
                  vfw_ctrs->time_measurements ==
                  0 ? 0 : vfw_ctrs->internal_time_sum /
                  vfw_ctrs->time_measurements;
              uint64_t average_external_time =
                  vfw_ctrs->time_measurements ==
                  0 ? 0 : vfw_ctrs->external_time_sum /
                  vfw_ctrs->time_measurements;
              uint64_t average_pkts_in_batch =
                  vfw_ctrs->num_pkts_measurements ==
                  0 ? 0 : vfw_ctrs->num_batch_pkts_sum /
                  vfw_ctrs->num_pkts_measurements;

              printf("{\"VFW counters\" : {\"id\" : \"%s\",\"packets_processed\" : %"
                     PRIu64 ", \"bytes_processed\" : %"
                     PRIu64 ", \"average_pkts_in_batch\" : %"
                     PRIu64 ", \"average_internal_time_in_clocks\" : %"
                     PRIu64 ", \"average_external_time_in_clocks\" : %"
                     PRIu64 ", \"total_time_measures\" : %"
                     PRIu32 ", \"ct_packets_forwarded\" : %"
                     PRIu64 ", \"ct_packets_dropped\" : %"
                     PRIu64 "}}\n",
                     vfw_ctrs->name,
                     vfw_ctrs->pkts_received,
                     vfw_ctrs->bytes_processed,
                     average_pkts_in_batch,
                     average_internal_time,
                     average_external_time,
                     vfw_ctrs->time_measurements,
                     ct_counters->pkts_forwarded, ct_counters->pkts_drop);

              /* sum VFW counters */
              vfw_counter_sums.bytes_processed +=
                  vfw_ctrs->bytes_processed;
              vfw_counter_sums.pkts_drop_without_rule +=
                  vfw_ctrs->pkts_drop_without_rule;
              vfw_counter_sums.pkts_received += vfw_ctrs->pkts_received;
              vfw_counter_sums.pkts_drop_ttl += vfw_ctrs->pkts_drop_ttl;
              vfw_counter_sums.pkts_drop_bad_size +=
                  vfw_ctrs->pkts_drop_bad_size;
              vfw_counter_sums.pkts_drop_fragmented +=
                  vfw_ctrs->pkts_drop_fragmented;
              vfw_counter_sums.pkts_drop_without_arp_entry +=
                  vfw_ctrs->pkts_drop_without_arp_entry;
              vfw_counter_sums.sum_latencies += vfw_ctrs->sum_latencies;
              vfw_counter_sums.count_latencies +=
                  vfw_ctrs->count_latencies;

              vfw_counter_sums.internal_time_sum +=
                  vfw_ctrs->internal_time_sum;
              vfw_counter_sums.external_time_sum +=
                  vfw_ctrs->external_time_sum;
              vfw_counter_sums.time_measurements +=
                  vfw_ctrs->time_measurements;
              vfw_counter_sums.pkts_drop_unsupported_type +=
                  vfw_ctrs->pkts_drop_unsupported_type;

              /* sum cnxn tracking counters */
              ct_counter_sums.current_active_sessions +=
                  ct_counters->current_active_sessions;
              ct_counter_sums.sessions_activated +=
                  ct_counters->sessions_activated;
              ct_counter_sums.sessions_reactivated +=
                  ct_counters->sessions_reactivated;
              ct_counter_sums.sessions_established +=
                  ct_counters->sessions_established;
              ct_counter_sums.sessions_closed += ct_counters->sessions_closed;
              ct_counter_sums.sessions_timedout +=
                  ct_counters->sessions_timedout;
              ct_counter_sums.pkts_forwarded += ct_counters->pkts_forwarded;
              ct_counter_sums.pkts_drop += ct_counters->pkts_drop;
              ct_counter_sums.pkts_drop_invalid_conn +=
                  ct_counters->pkts_drop_invalid_conn;
              ct_counter_sums.pkts_drop_invalid_state +=
                  ct_counters->pkts_drop_invalid_state;
              ct_counter_sums.pkts_drop_invalid_rst +=
                  ct_counters->pkts_drop_invalid_rst;
              ct_counter_sums.pkts_drop_outof_window +=
                  ct_counters->pkts_drop_outof_window;
       }

       rte_vfw_update_performance_measures(vfw_counter_sums.
                                          bytes_processed,
                                          vfw_counter_sums.
                                          pkts_received);
       uint64_t average_latency =
           vfw_counter_sums.count_latencies ==
           0 ? 0 : vfw_counter_sums.sum_latencies /
           vfw_counter_sums.count_latencies;

       printf("{\"VFW sum counters\" : {"
              "\"packets_last_sec\" : %"
              PRIu32 ", \"average_packets_per_sec\" : %"
              PRIu32 ", \"bytes_last_sec\" : %"
              PRIu32 ", \"average_bytes_per_sec\" : %"
              PRIu32 ", \"pkts_received\" : %"
              PRIu64 ", \"bytes_processed\" : %"
              PRIu64 ", \"average_latency_in_clocks\" : %"
              PRIu64 ", \"ct_packets_forwarded\" : %"
              PRIu64 ", \"ct_packets_dropped\" : %"
              PRIu64 ", \"drops\" : {"
              "\"TTL_zero\" : %" PRIu64 ", \"bad_size\" : %"
              PRIu64 ", \"fragmented_packet\" : %"
              PRIu64 ", \"unsupported_packet_types\" : %"
              PRIu64 ", \"no_arp_entry\" : %"
              PRIu64 "}, \"ct_sessions\" : {"
              "\"active\" : %" PRIu64 ", \"open\" : %"
              PRIu64 ", \"re-open_attempt\" : %"
              PRIu64 ", \"established\" : %"
              PRIu64 ", \"closed\" : %"
              PRIu64 ", \"timeout\" : %"
              PRIu64 "}, \"ct_drops\" : {"
              "\"out_of_window\" : %" PRIu64 ", \"invalid_conn\" : %"
              PRIu64 ", \"invalid_state_transition\" : %"
              PRIu64 " \"RST\" : %"
              PRIu64 "}}}\n",
              rte_vfw_performance_measures.pkts_last_second,
              rte_vfw_performance_measures.ave_pkts_per_second,
              rte_vfw_performance_measures.bytes_last_second,
              rte_vfw_performance_measures.ave_bytes_per_second,
              vfw_counter_sums.pkts_received,
              vfw_counter_sums.bytes_processed,
              average_latency,
              ct_counter_sums.pkts_forwarded,
              ct_counter_sums.pkts_drop,
              vfw_counter_sums.pkts_drop_ttl,
              vfw_counter_sums.pkts_drop_bad_size,
              vfw_counter_sums.pkts_drop_fragmented,
              vfw_counter_sums.pkts_drop_unsupported_type,
              vfw_counter_sums.pkts_drop_without_arp_entry,
              ct_counter_sums.current_active_sessions,
              ct_counter_sums.sessions_activated,
              ct_counter_sums.sessions_reactivated,
              ct_counter_sums.sessions_established,
              ct_counter_sums.sessions_closed,
              ct_counter_sums.sessions_timedout,
              ct_counter_sums.pkts_drop_outof_window,
              ct_counter_sums.pkts_drop_invalid_conn,
              ct_counter_sums.pkts_drop_invalid_state,
              ct_counter_sums.pkts_drop_invalid_rst);

}

/**
 * Callback routine for 1 second, periodic timer.
 *
 * @param rt
 *  A pointer to the rte_timer.
 * @param arg
 *  A pointer to application specific arguments (not used).
 *
 * @return
 *  0 on success and port_id is filled, negative on error.
 */
static void rte_dump_vfw_counters_from_master(
              __rte_unused struct rte_timer *rt, __rte_unused void *arg)
{
       rte_vfw_sum_and_print_counters();
}

int rte_vfw_hertz_computed;       /* only launch timer once */
uint64_t rte_vfw_ticks_in_one_second;
/* TODO: is processor hertz computed/stored elsewhere? */
struct rte_timer rte_vfw_one_second_timer = RTE_TIMER_INITIALIZER;

/**
 * Print IPv4 Rule.
 *
 * @param rule
 *  A pointer to the rule.
 *
 */
static void print_vfw_ipv4_rule(struct app_pipeline_vfw_rule *rule)
{
       printf("Prio = %" PRId32 " (SA = %" PRIu32 ".%" PRIu32
              ".%" PRIu32 ".%" PRIu32 "/%" PRIu32 ", DA = %"
              PRIu32 ".%" PRIu32
              ".%" PRIu32 ".%" PRIu32 "/%" PRIu32 ", SP = %"
              PRIu32 "-%" PRIu32 ", DP = %"
              PRIu32 "-%" PRIu32 ", Proto = %"
              PRIu32 " / 0x%" PRIx32 ") => Action ID = %"
              PRIu32 " (entry ptr = %p)\n",
              rule->priority,
              (rule->key.key.ipv4_5tuple.src_ip >> 24) & 0xFF,
              (rule->key.key.ipv4_5tuple.src_ip >> 16) & 0xFF,
              (rule->key.key.ipv4_5tuple.src_ip >> 8) & 0xFF,
              rule->key.key.ipv4_5tuple.src_ip & 0xFF,
              rule->key.key.ipv4_5tuple.src_ip_mask,
              (rule->key.key.ipv4_5tuple.dst_ip >> 24) & 0xFF,
              (rule->key.key.ipv4_5tuple.dst_ip >> 16) & 0xFF,
              (rule->key.key.ipv4_5tuple.dst_ip >> 8) & 0xFF,
              rule->key.key.ipv4_5tuple.dst_ip & 0xFF,
              rule->key.key.ipv4_5tuple.dst_ip_mask,
              rule->key.key.ipv4_5tuple.src_port_from,
              rule->key.key.ipv4_5tuple.src_port_to,
              rule->key.key.ipv4_5tuple.dst_port_from,
              rule->key.key.ipv4_5tuple.dst_port_to,
              rule->key.key.ipv4_5tuple.proto,
              rule->key.key.ipv4_5tuple.proto_mask,
              rule->action_id, rule->entry_ptr);
}

/**
 * Print IPv6 Rule.
 *
 * @param rule
 *  A pointer to the rule.
 *
 */
static void print_vfw_ipv6_rule(struct app_pipeline_vfw_rule *rule)
{
       printf("Prio = %" PRId32 " (SA = %02" PRIx8 "%02" PRIx8
              ":%02" PRIx8 "%02" PRIx8 ":%02" PRIx8 "%02" PRIx8
              ":%02" PRIx8 "%02" PRIx8 ":%02" PRIx8 "%02" PRIx8
              ":%02" PRIx8 "%02" PRIx8 ":%02" PRIx8 "%02" PRIx8
              ":%02" PRIx8 "%02" PRIx8 "/" "%" PRIu32 ", DA = %02"
              PRIx8 "%02" PRIx8 ":%02" PRIx8
              "%02" PRIx8 ":%02" PRIx8 "%02" PRIx8 ":%02" PRIx8
              "%02" PRIx8 ":%02" PRIx8 "%02" PRIx8 ":%02" PRIx8
              "%02" PRIx8 ":%02" PRIx8 "%02" PRIx8 ":%02" PRIx8
              "%02" PRIx8 "/" "%" PRIu32", " "SP = %" PRIu32 "-%" PRIu32
              ", DP = %" PRIu32 "-%" PRIu32 ", Proto = %"
              PRIu32 " / 0x%" PRIx32 ") => Action ID = %"
              PRIu32 " (entry ptr = %p)\n", rule->priority,
              (rule->key.key.ipv6_5tuple.src_ip[0]),
              (rule->key.key.ipv6_5tuple.src_ip[1]),
              (rule->key.key.ipv6_5tuple.src_ip[2]),
              (rule->key.key.ipv6_5tuple.src_ip[3]),
              (rule->key.key.ipv6_5tuple.src_ip[4]),
              (rule->key.key.ipv6_5tuple.src_ip[5]),
              (rule->key.key.ipv6_5tuple.src_ip[6]),
              (rule->key.key.ipv6_5tuple.src_ip[7]),
              (rule->key.key.ipv6_5tuple.src_ip[8]),
              (rule->key.key.ipv6_5tuple.src_ip[9]),
              (rule->key.key.ipv6_5tuple.src_ip[10]),
              (rule->key.key.ipv6_5tuple.src_ip[11]),
              (rule->key.key.ipv6_5tuple.src_ip[12]),
              (rule->key.key.ipv6_5tuple.src_ip[13]),
              (rule->key.key.ipv6_5tuple.src_ip[14]),
              (rule->key.key.ipv6_5tuple.src_ip[15]),
              rule->key.key.ipv6_5tuple.src_ip_mask,
              (rule->key.key.ipv6_5tuple.dst_ip[0]),
              (rule->key.key.ipv6_5tuple.dst_ip[1]),
              (rule->key.key.ipv6_5tuple.dst_ip[2]),
              (rule->key.key.ipv6_5tuple.dst_ip[3]),
              (rule->key.key.ipv6_5tuple.dst_ip[4]),
              (rule->key.key.ipv6_5tuple.dst_ip[5]),
              (rule->key.key.ipv6_5tuple.dst_ip[6]),
              (rule->key.key.ipv6_5tuple.dst_ip[7]),
              (rule->key.key.ipv6_5tuple.dst_ip[8]),
              (rule->key.key.ipv6_5tuple.dst_ip[9]),
              (rule->key.key.ipv6_5tuple.dst_ip[10]),
              (rule->key.key.ipv6_5tuple.dst_ip[11]),
              (rule->key.key.ipv6_5tuple.dst_ip[12]),
              (rule->key.key.ipv6_5tuple.dst_ip[13]),
              (rule->key.key.ipv6_5tuple.dst_ip[14]),
              (rule->key.key.ipv6_5tuple.dst_ip[15]),
              rule->key.key.ipv6_5tuple.dst_ip_mask,
              rule->key.key.ipv6_5tuple.src_port_from,
              rule->key.key.ipv6_5tuple.src_port_to,
              rule->key.key.ipv6_5tuple.dst_port_from,
              rule->key.key.ipv6_5tuple.dst_port_to,
              rule->key.key.ipv6_5tuple.proto,
              rule->key.key.ipv6_5tuple.proto_mask, rule->action_id,
              rule->entry_ptr);
}

/**
 * Find an VFW rule.
 * This function is used by the add and delete rule functions.
 * Since all updates are done on the standby tables,
 * only search the standby tables.
 * Both IPv4 and IPv6 rules can be searched
 *
 * @param key
 *  A pointer to the rule to be found.
 *
 * @return
 *  - Pointer to the rule found.
 *  - NULL if no rule found.
 */
static struct app_pipeline_vfw_rule *app_pipeline_vfw_rule_find(
              struct pipeline_vfw_key *key)
{
       /*
        * This function is used by the add and delete rule functions.
        * Since all updates are done on the standby tables,
        * only search the standby tables.
        */

       struct app_pipeline_vfw_rule *r;

       if (key->type == PIPELINE_VFW_IPV4_5TUPLE) {
              TAILQ_FOREACH(r, vfw_tailq_rules_ipv4_standby, node)
                  if (memcmp(key,
                            &r->key,
                            sizeof(struct pipeline_vfw_key)) == 0)
                     return r;
       } else {              /* IPV6 */
              TAILQ_FOREACH(r, vfw_tailq_rules_ipv6_standby, node)
                  if (memcmp(key,
                            &r->key,
                            sizeof(struct pipeline_vfw_key)) == 0)
                     return r;
       }

       return NULL;
}


/**
 * Synproxy ON/OFF CLI command.
 *
 * @param app
 *  A pointer to the application parameter.
 * @param pipeline_id
 *  pipeline ID.
 * @param synproxy_flag
 * 0-OFF,1-ON.
 *
 * @return
 *  Response message contains status.
 */

static int
app_pipeline_vfw_synproxy_flag(struct app_params *app,
                              uint32_t pipeline_id, uint8_t synproxy_flag)
{
       struct app_pipeline_acl *p;
       struct pipeline_vfw_synproxy_flag_msg_req *req;
       struct pipeline_vfw_synproxy_flag_msg_rsp *rsp;

       /* Check input arguments */
       if (app == NULL)
              return -1;
       p = app_pipeline_data_fe(app, pipeline_id, &pipeline_vfw);
       if (p == NULL)
              return -1;
       /* Allocate and write request */
       req = app_msg_alloc(app);
       if (req == NULL)
              return -1;
       req->type = PIPELINE_MSG_REQ_CUSTOM;
       req->subtype = PIPELINE_VFW_MSG_REQ_SYNPROXY_FLAGS;
       req->synproxy_flag = synproxy_flag;

       /* Send request and wait for response */
       rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
       if (rsp == NULL) {
              printf("Failed communication with TCP firewall\n");
              return -1;
       }
       /* Read response and write rule */
       if (rsp->status) {
              printf("res status=%d", rsp->status);
              app_msg_free(app, rsp);
              return -1;
       }

       /* Free response */
       app_msg_free(app, rsp);

       return 0;
}

/**
 * Display VFW Rules to the console.
 * Rules from Active and standby tables can be dispayed.
 * Both IPv4 and IPv6 will be displayed.
 *
 * @param app
 *  A pointer to application specific data.
 * @param active_standby_table
 *  Specifies which table to display:
 *    - active_rule_table (0)
 *    - standby_rule_table (1)
 *
 */
static void
app_pipeline_vfw_ls(__attribute__ ((unused)) struct app_params *app,
              uint32_t active_standby_table)
{
       struct app_pipeline_vfw_rule *rule;
       uint32_t n_rules;
       int priority;

       if (active_standby_table == active_rule_table) {
              n_rules = *vfw_n_tailq_rules_ipv4_active;
              if (n_rules > 0)
                     printf("VFW Active Table IPV4 Rules\n");
              for (priority = 0; n_rules; priority++)
                     TAILQ_FOREACH(rule, vfw_tailq_rules_ipv4_active,
                                  node)
                         if (rule->priority == priority) {
                            print_vfw_ipv4_rule(rule);
                            n_rules--;
                     }

              n_rules = *vfw_n_tailq_rules_ipv6_active;
              if (n_rules > 0)
                     printf("VFW Active Table IPV6 Rules\n");
              for (priority = 0; n_rules; priority++)
                     TAILQ_FOREACH(rule, vfw_tailq_rules_ipv6_active,
                                  node)
                         if (rule->priority == priority) {
                            print_vfw_ipv6_rule(rule);
                            n_rules--;
                     }
       } else {
              n_rules = *vfw_n_tailq_rules_ipv4_standby;
              if (n_rules > 0)
                     printf("VFW Standby Table IPV4 Rules\n");
              for (priority = 0; n_rules; priority++)
                     TAILQ_FOREACH(rule, vfw_tailq_rules_ipv4_standby,
                                  node)
                         if (rule->priority == priority) {
                            print_vfw_ipv4_rule(rule);
                            n_rules--;
                     }

              n_rules = *vfw_n_tailq_rules_ipv6_standby;
              if (n_rules > 0)
                     printf("VFW Standby Table IPV6a Rules\n");
              for (priority = 0; n_rules; priority++)
                     TAILQ_FOREACH(rule, vfw_tailq_rules_ipv6_standby,
                                  node)
                         if (rule->priority == priority) {
                            print_vfw_ipv6_rule(rule);
                            n_rules--;
                     }
       }
       printf("\n");
}

/**
 * Initialize VFW pipeline Front End (FE).
 *
 * @param params
 *  A pointer to pipeline parameters
 * @param arg
 *  A pointer to pipeline specific data (not used).
 *
 * @return
 *  - A pointer to the pipeline FE
 *  - NULL if initialization failed.
 */
static void *app_pipeline_vfw_init(struct pipeline_params *params,
                                  __rte_unused void *arg)
{
       struct app_pipeline_vfw *p;
       uint32_t size;

       /* Check input arguments */
       if ((params == NULL) ||
           (params->n_ports_in == 0) || (params->n_ports_out == 0))
              return NULL;

       /* Memory allocation */
       size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct app_pipeline_vfw));
       p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
       if (p == NULL)
              return NULL;

       /* Initialization */
       p->n_ports_in = params->n_ports_in;
       p->n_ports_out = params->n_ports_out;

       if (!vfw_rule_table_created) {
              /* Only create and init once when first VFW pipeline/thread
               * comes up */

              /* Init tailq tables */
              TAILQ_INIT(&vfw_tailq_rules_ipv4a);
              vfw_n_tailq_rules_ipv4a = 0;
              TAILQ_INIT(&vfw_tailq_rules_ipv4b);
              vfw_n_tailq_rules_ipv4b = 0;
              TAILQ_INIT(&vfw_tailq_rules_ipv6a);
              vfw_n_tailq_rules_ipv6a = 0;
              TAILQ_INIT(&vfw_tailq_rules_ipv6b);
              vfw_n_tailq_rules_ipv6b = 0;
              TAILQ_INIT(&vfw_commands);
              vfw_tailq_rules_ipv4_active = &vfw_tailq_rules_ipv4a;
              vfw_tailq_rules_ipv4_standby = &vfw_tailq_rules_ipv4b;
              vfw_tailq_rules_ipv6_active = &vfw_tailq_rules_ipv6a;
              vfw_tailq_rules_ipv6_standby = &vfw_tailq_rules_ipv6b;
              vfw_n_tailq_rules_ipv4_active = &vfw_n_tailq_rules_ipv4a;
              vfw_n_tailq_rules_ipv4_standby = &vfw_n_tailq_rules_ipv4b;
              vfw_n_tailq_rules_ipv6_active = &vfw_n_tailq_rules_ipv6a;
              vfw_n_tailq_rules_ipv6_standby = &vfw_n_tailq_rules_ipv6b;

              /* Both IPV4 and IPV6 enabled by default */
              vfw_ipv4_enabled = 1;
              vfw_ipv6_enabled = 1;

              printf("VFW FE Init Create Tables vfw_n_rules = %i\n",
                   vfw_n_rules);

              /* Init Action Array and Counter Table */
              action_array_size =
                  RTE_CACHE_LINE_ROUNDUP(sizeof(struct pipeline_action_key) *
                                      action_array_max);
              action_array_a =
                  rte_zmalloc(NULL, action_array_size, RTE_CACHE_LINE_SIZE);
              if (action_array_a == NULL)
                     return NULL;
              action_array_b =
                  rte_zmalloc(NULL, action_array_size, RTE_CACHE_LINE_SIZE);
              if (action_array_b == NULL)
                     return NULL;
              memset(action_array_a, 0, action_array_size);
              memset(action_array_b, 0, action_array_size);
              action_array_active = action_array_a;
              action_array_standby = action_array_b;
              memset(&action_counter_table, 0, sizeof(action_counter_table));

              vfw_rule_table_created = 1;
       }

       if (!rte_vfw_hertz_computed) {
              /* all initialization serialized on core 0,
               * so no need for lock */
              rte_vfw_ticks_in_one_second = rte_get_tsc_hz();
              rte_vfw_hertz_computed = 1;
       }

       return (void *)p;
}

/**
 * Free VFW pipeline resources.
 *
 * @param pipeline
 *  A pointer to the pipeline to delete.
 *
 * @return
 *  0 on success, negative on error.
 */
static int app_pipeline_vfw_free(void *pipeline)
{
       struct app_pipeline_vfw *p = pipeline;

       /* Check input arguments */
       if (p == NULL)
              return -1;

       /* Free resources */
       /* Ignore Klockwork infinite loop issues for all while loops */
       while (!TAILQ_EMPTY(&vfw_tailq_rules_ipv4a)) {
              struct app_pipeline_vfw_rule *rule;

              rule = TAILQ_FIRST(&vfw_tailq_rules_ipv4a);
              TAILQ_REMOVE(&vfw_tailq_rules_ipv4a, rule, node);
              rte_free(rule);
       }
       while (!TAILQ_EMPTY(&vfw_tailq_rules_ipv4b)) {
              struct app_pipeline_vfw_rule *rule;

              rule = TAILQ_FIRST(&vfw_tailq_rules_ipv4b);
              TAILQ_REMOVE(&vfw_tailq_rules_ipv4b, rule, node);
              rte_free(rule);
       }
       while (!TAILQ_EMPTY(&vfw_tailq_rules_ipv6a)) {
              struct app_pipeline_vfw_rule *rule;

              rule = TAILQ_FIRST(&vfw_tailq_rules_ipv6a);
              TAILQ_REMOVE(&vfw_tailq_rules_ipv6a, rule, node);
              rte_free(rule);
       }
       while (!TAILQ_EMPTY(&vfw_tailq_rules_ipv6b)) {
              struct app_pipeline_vfw_rule *rule;

              rule = TAILQ_FIRST(&vfw_tailq_rules_ipv6b);
              TAILQ_REMOVE(&vfw_tailq_rules_ipv6b, rule, node);
              rte_free(rule);
       }
       while (!TAILQ_EMPTY(&vfw_commands)) {
              struct app_pipeline_vfw_rule *command;

              command = TAILQ_FIRST(&vfw_commands);
              TAILQ_REMOVE(&vfw_commands, command, node);
              rte_free(command);
       }
       rte_free(action_array_a);
       rte_free(action_array_b);
       rte_free(p);
       return 0;
}

/**
 * Verify that the VFW rule is valid.
 * Both IPv4 and IPv6 rules
 *
 * @param key
 *  A pointer to the VFW rule to verify.
 *
 * @return
 *  0 on success, negative on error.
 */
static int
app_pipeline_vfw_key_check_and_normalize(struct pipeline_vfw_key *key)
{
       switch (key->type) {
       case PIPELINE_VFW_IPV4_5TUPLE:
              {
                     uint32_t src_ip_depth =
                         key->key.ipv4_5tuple.src_ip_mask;
                     uint32_t dst_ip_depth =
                         key->key.ipv4_5tuple.dst_ip_mask;
                     uint16_t src_port_from =
                         key->key.ipv4_5tuple.src_port_from;
                     uint16_t src_port_to = key->key.ipv4_5tuple.src_port_to;
                     uint16_t dst_port_from =
                         key->key.ipv4_5tuple.dst_port_from;
                     uint16_t dst_port_to = key->key.ipv4_5tuple.dst_port_to;

                     uint32_t src_ip_netmask = 0;
                     uint32_t dst_ip_netmask = 0;

                     if ((src_ip_depth > 32) ||
                         (dst_ip_depth > 32) ||
                         (src_port_from > src_port_to) ||
                         (dst_port_from > dst_port_to))
                            return -1;

                     if (src_ip_depth)
                            src_ip_netmask = (~0) << (32 - src_ip_depth);

                     if (dst_ip_depth)
                            dst_ip_netmask = ((~0) << (32 - dst_ip_depth));

                     key->key.ipv4_5tuple.src_ip &= src_ip_netmask;
                     key->key.ipv4_5tuple.dst_ip &= dst_ip_netmask;

                     return 0;
              }
       case PIPELINE_VFW_IPV6_5TUPLE:
              {
                     uint32_t src_ip_depth =
                         key->key.ipv6_5tuple.src_ip_mask;
                     uint32_t dst_ip_depth =
                         key->key.ipv6_5tuple.dst_ip_mask;
                     uint8_t src_ip_netmask[16];
                     uint8_t dst_ip_netmask[16];
                     int i;

                     convert_prefixlen_to_netmask_ipv6(src_ip_depth,
                                                   src_ip_netmask);
                     convert_prefixlen_to_netmask_ipv6(dst_ip_depth,
                                                   dst_ip_netmask);
                     for (i = 0; i < 16; i++) {
                            key->key.ipv6_5tuple.src_ip[i] &=
                                src_ip_netmask[i];
                            key->key.ipv6_5tuple.dst_ip[i] &=
                                dst_ip_netmask[i];
                     }
                     return 0;
              }

       default:
              return -1;
       }
}

/**
 * Add VFW rule to the VFW rule table.
 * Rules are added standby table.
 * Applyruleset command will activate the change.
 * Both IPv4 and IPv6 rules can be added.
 *
 * @param app
 *  A pointer to the VFW pipeline parameters.
 * @param key
 *  A pointer to the VFW rule to add.
 * @param priority
 *  Priority of the VFW rule.
 * @param port_id
 *  Port ID of the VFW rule.
 * @param action_id
 *  Action ID of the VFW rule. Defined in Action Table.
 *
 * @return
 *  0 on success, negative on error.
 */
int
app_pipeline_vfw_add_rule(struct app_params *app,
                          struct pipeline_vfw_key *key,
                          uint32_t priority,
                          uint32_t port_id, uint32_t action_id)
{
       struct app_pipeline_vfw_rule *rule;
       struct pipeline_vfw_add_msg_rsp *rsp;
       int new_rule, src_field_start, dst_field_start, i;
       uint32_t *ip1, *ip2, *ip3, *ip4, src_mask, dest_mask;
       uint32_t src_ip[IPV6_32BIT_LENGTH], dst_ip[IPV6_32BIT_LENGTH];
       const uint32_t nbu32 = sizeof(uint32_t) * CHAR_BIT;

       struct rte_table_acl_rule_add_params params;
       struct lib_acl_table_entry entry = {
              .head = {
                      .action = RTE_PIPELINE_ACTION_PORT,
                      {.port_id = port_id},
                      },
              .action_id = action_id,
       };

       memset(&params, 0, sizeof(params));

       /* Check input arguments */
       if ((app == NULL) ||
           (key == NULL) || !((key->type == PIPELINE_VFW_IPV4_5TUPLE) ||
                            (key->type == PIPELINE_VFW_IPV6_5TUPLE)))
              return -1;

       if (action_id > action_array_max) {
              printf("Action ID greater than max\n");
              return -1;
       }

       if (app_pipeline_vfw_key_check_and_normalize(key) != 0)
              return -1;

       /* Find existing rule or allocate new rule */
       rule = app_pipeline_vfw_rule_find(key);
       new_rule = (rule == NULL);
       if (rule == NULL) {
              rule = rte_malloc(NULL, sizeof(*rule), RTE_CACHE_LINE_SIZE);

              if (rule == NULL)
                     return -1;
       }

       /* Allocate Response */
       rsp = app_msg_alloc(app);
       if (rsp == NULL) {
              if (new_rule)
                     rte_free(rule);
              return -1;
       }

       switch (key->type) {
       case PIPELINE_VFW_IPV4_5TUPLE:
              params.priority = priority;
              params.field_value[0].value.u8 = key->key.ipv4_5tuple.proto;
              params.field_value[0].mask_range.u8 =
                  key->key.ipv4_5tuple.proto_mask;
              params.field_value[1].value.u32 = key->key.ipv4_5tuple.src_ip;
              params.field_value[1].mask_range.u32 =
                  key->key.ipv4_5tuple.src_ip_mask;
              params.field_value[2].value.u32 = key->key.ipv4_5tuple.dst_ip;
              params.field_value[2].mask_range.u32 =
                  key->key.ipv4_5tuple.dst_ip_mask;
              params.field_value[3].value.u16 =
                  key->key.ipv4_5tuple.src_port_from;
              params.field_value[3].mask_range.u16 =
                  key->key.ipv4_5tuple.src_port_to;
              params.field_value[4].value.u16 =
                  key->key.ipv4_5tuple.dst_port_from;
              params.field_value[4].mask_range.u16 =
                  key->key.ipv4_5tuple.dst_port_to;

              rsp->status =
                  rte_table_acl_ops.f_add(vfw_rule_table_ipv4_standby,
                                       &params,
                                       (struct rte_pipeline_table_entry *)
                                       &entry, &rsp->key_found,
                                       (void **)&rsp->entry_ptr);

              if (rsp->status != 0)
                     printf
                         ("IPV4 Add Rule Command failed key_found: %i\n",
                          rsp->key_found);
              else
                     printf
                         ("IPV4 Add Rule Command success key_found: %i\n",
                          rsp->key_found);

              break;

       case PIPELINE_VFW_IPV6_5TUPLE:
              ip1 = (uint32_t *) (key->key.ipv6_5tuple.src_ip);
              ip2 = ip1 + 1;
              ip3 = ip1 + 2;
              ip4 = ip1 + 3;

              params.priority = priority;
              params.field_value[0].value.u8 = key->key.ipv6_5tuple.proto;
              params.field_value[0].mask_range.u8 =
                  key->key.ipv6_5tuple.proto_mask;

              src_ip[0] = rte_bswap32(*ip1);
              src_ip[1] = rte_bswap32(*ip2);
              src_ip[2] = rte_bswap32(*ip3);
              src_ip[3] = rte_bswap32(*ip4);

              src_mask = key->key.ipv6_5tuple.src_ip_mask;

              src_field_start = 1;
              for (i = 0; i != RTE_DIM(src_ip); i++, src_field_start++) {
                     if (src_mask >= (i + 1) * nbu32)
                            params.field_value[src_field_start].mask_range.
                                u32 = nbu32;
                     else
                            params.field_value[src_field_start].mask_range.
                                u32 =
                                src_mask >
                                (i * nbu32) ? src_mask - (i * 32) : 0;
                     params.field_value[src_field_start].value.u32 =
                         src_ip[i];
              }

              ip1 = (uint32_t *) (key->key.ipv6_5tuple.dst_ip);
              ip2 = ip1 + 1;
              ip3 = ip1 + 2;
              ip4 = ip1 + 3;

              dst_ip[0] = rte_bswap32(*ip1);
              dst_ip[1] = rte_bswap32(*ip2);
              dst_ip[2] = rte_bswap32(*ip3);
              dst_ip[3] = rte_bswap32(*ip4);

              dest_mask = key->key.ipv6_5tuple.dst_ip_mask;

              dst_field_start = 5;
              for (i = 0; i != RTE_DIM(dst_ip); i++, dst_field_start++) {
                     if (dest_mask >= (i + 1) * nbu32)
                            params.field_value[dst_field_start].mask_range.
                                u32 = nbu32;
                     else
                            params.field_value[dst_field_start].mask_range.
                                u32 =
                                dest_mask >
                                (i * nbu32) ? dest_mask - (i * 32) : 0;
                     params.field_value[dst_field_start].value.u32 =
                         dst_ip[i];
              }

              params.field_value[9].value.u16 =
                  key->key.ipv6_5tuple.src_port_from;
              params.field_value[9].mask_range.u16 =
                  key->key.ipv6_5tuple.src_port_to;
              params.field_value[10].value.u16 =
                  key->key.ipv6_5tuple.dst_port_from;
              params.field_value[10].mask_range.u16 =
                  key->key.ipv6_5tuple.dst_port_to;

              rsp->status =
                  rte_table_acl_ops.f_add(vfw_rule_table_ipv6_standby,
                                       &params,
                                       (struct rte_pipeline_table_entry *)
                                       &entry, &rsp->key_found,
                                       (void **)&rsp->entry_ptr);

              if (rsp->status != 0)
                     printf
                         ("IPV6 Add Rule Command failed key_found: %i\n",
                          rsp->key_found);
              else
                     printf
                         ("IPV6 Add Rule Command success key_found: %i\n",
                          rsp->key_found);

              break;

       default:
              /* Error */
              app_msg_free(app, rsp);
              if (new_rule)
                     rte_free(rule);
              return -1;
       }

       /* Read response and write rule */
       if (rsp->status ||
           (rsp->entry_ptr == NULL) ||
           ((new_rule == 0) && (rsp->key_found == 0)) ||
           ((new_rule == 1) && (rsp->key_found == 1))) {
              app_msg_free(app, rsp);
              if (new_rule)
                     rte_free(rule);
              return -1;
       }

       memcpy(&rule->key, key, sizeof(*key));
       rule->priority = priority;
       rule->port_id = port_id;
       rule->action_id = action_id;
       rule->entry_ptr = rsp->entry_ptr;

       /* Commit rule */
       if (new_rule) {
              if (key->type == PIPELINE_VFW_IPV4_5TUPLE) {
                     TAILQ_INSERT_TAIL(vfw_tailq_rules_ipv4_standby, rule,
                                     node);
                     (*vfw_n_tailq_rules_ipv4_standby)++;
              } else {       /* IPV6 */
                     TAILQ_INSERT_TAIL(vfw_tailq_rules_ipv6_standby, rule,
                                     node);
                     (*vfw_n_tailq_rules_ipv6_standby)++;
              }
       }

       if (key->type == PIPELINE_VFW_IPV4_5TUPLE)
              print_vfw_ipv4_rule(rule);
       else
              print_vfw_ipv6_rule(rule);

       /* Free response */
       app_msg_free(app, rsp);

       return 0;
}

/**
 * Delete VFW rule from the VFW rule table.
 * Rules deleted from standby tables.
 * Applyruleset command will activate the change.
 * Both IPv4 and IPv6 rules can be deleted.
 *
 * @param app
 *  A pointer to the VFW pipeline parameters.
 * @param key
 *  A pointer to the VFW rule to delete.
 *
 * @return
 *  0 on success, negative on error.
 */
int
app_pipeline_vfw_delete_rule(struct app_params *app,
                            struct pipeline_vfw_key *key)
{
       struct app_pipeline_vfw_rule *rule;
       int status, key_found;
       int  src_field_start, dst_field_start, i;
       uint32_t *ip1, *ip2, *ip3, *ip4, src_mask, dest_mask;
       uint32_t src_ip[IPV6_32BIT_LENGTH], dst_ip[IPV6_32BIT_LENGTH];
       const uint32_t nbu32 = sizeof(uint32_t) * CHAR_BIT;


       struct rte_table_acl_rule_delete_params params;

       memset(&params, 0, sizeof(params));

       /* Check input arguments */
       if ((app == NULL) ||
           (key == NULL) || !((key->type == PIPELINE_VFW_IPV4_5TUPLE) ||
                            (key->type == PIPELINE_VFW_IPV6_5TUPLE)))
              return -1;

       if (app_pipeline_vfw_key_check_and_normalize(key) != 0)
              return -1;

       /* Find rule */
       rule = app_pipeline_vfw_rule_find(key);
       if (rule == NULL) {
              printf("VFW Delete Rule - Rule does not exist\n");
              return 0;
       }

       switch (key->type) {
       case PIPELINE_VFW_IPV4_5TUPLE:
              params.field_value[0].value.u8 = key->key.ipv4_5tuple.proto;
              params.field_value[0].mask_range.u8 =
                  key->key.ipv4_5tuple.proto_mask;
              params.field_value[1].value.u32 = key->key.ipv4_5tuple.src_ip;
              params.field_value[1].mask_range.u32 =
                  key->key.ipv4_5tuple.src_ip_mask;
              params.field_value[2].value.u32 = key->key.ipv4_5tuple.dst_ip;
              params.field_value[2].mask_range.u32 =
                  key->key.ipv4_5tuple.dst_ip_mask;
              params.field_value[3].value.u16 =
                  key->key.ipv4_5tuple.src_port_from;
              params.field_value[3].mask_range.u16 =
                  key->key.ipv4_5tuple.src_port_to;
              params.field_value[4].value.u16 =
                  key->key.ipv4_5tuple.dst_port_from;
              params.field_value[4].mask_range.u16 =
                  key->key.ipv4_5tuple.dst_port_to;

              status =
                  rte_table_acl_ops.f_delete(vfw_rule_table_ipv4_standby,
                                          &params, &key_found, NULL);

              if (status != 0)
                     printf
                         ("IPV4 Del Rule Command failed key_found: %i\n",
                          key_found);
              else
                     printf
                         ("IPV4 Del Rule Command success key_found: %i\n",
                          key_found);

              break;

       case PIPELINE_VFW_IPV6_5TUPLE:
              ip1 = (uint32_t *) (key->key.ipv6_5tuple.src_ip);
              ip2 = ip1 + 1;
              ip3 = ip1 + 2;
              ip4 = ip1 + 3;

              params.field_value[0].value.u8 = key->key.ipv6_5tuple.proto;
              params.field_value[0].mask_range.u8 =
                  key->key.ipv6_5tuple.proto_mask;

              src_ip[0] = rte_bswap32(*ip1);
              src_ip[1] = rte_bswap32(*ip2);
              src_ip[2] = rte_bswap32(*ip3);
              src_ip[3] = rte_bswap32(*ip4);

              src_mask = key->key.ipv6_5tuple.src_ip_mask;

              src_field_start = 1;
              for (i = 0; i != RTE_DIM(src_ip); i++, src_field_start++) {
                     if (src_mask >= (i + 1) * nbu32)
                            params.field_value[src_field_start].mask_range.
                                u32 = nbu32;
                     else
                            params.field_value[src_field_start].mask_range.
                                u32 =
                                src_mask >
                                (i * nbu32) ? src_mask - (i * 32) : 0;
                     params.field_value[src_field_start].value.u32 =
                         src_ip[i];
              }

              ip1 = (uint32_t *) (key->key.ipv6_5tuple.dst_ip);
              ip2 = ip1 + 1;
              ip3 = ip1 + 2;
              ip4 = ip1 + 3;

              dst_ip[0] = rte_bswap32(*ip1);
              dst_ip[1] = rte_bswap32(*ip2);
              dst_ip[2] = rte_bswap32(*ip3);
              dst_ip[3] = rte_bswap32(*ip4);

              dest_mask = key->key.ipv6_5tuple.dst_ip_mask;

              dst_field_start = 5;
              for (i = 0; i != RTE_DIM(dst_ip); i++, dst_field_start++) {
                     if (dest_mask >= (i + 1) * nbu32)
                            params.field_value[dst_field_start].mask_range.
                                u32 = nbu32;
                     else
                            params.field_value[dst_field_start].mask_range.
                                u32 =
                                dest_mask >
                                (i * nbu32) ? dest_mask - (i * 32) : 0;
                     params.field_value[dst_field_start].value.u32 =
                         dst_ip[i];
              }

              params.field_value[9].value.u16 =
                  key->key.ipv6_5tuple.src_port_from;
              params.field_value[9].mask_range.u16 =
                  key->key.ipv6_5tuple.src_port_to;
              params.field_value[10].value.u16 =
                  key->key.ipv6_5tuple.dst_port_from;
              params.field_value[10].mask_range.u16 =
                  key->key.ipv6_5tuple.dst_port_to;


              status =
                  rte_table_acl_ops.f_delete(vfw_rule_table_ipv6_standby,
                                          &params, &key_found, NULL);

              if (status != 0)
                     printf("IPV6 Del Rule Command failed key_found: %i\n",
                          key_found);
              else
                     printf("IPV6 Del Rule Command success key_found: %i\n",
                          key_found);

              break;

       default:
              /* Error */
              return -1;
       }

       /* Read response */
       if (status || !key_found)
              return -1;

       /* Remove rule */
       if (key->type == PIPELINE_VFW_IPV4_5TUPLE) {
              TAILQ_REMOVE(vfw_tailq_rules_ipv4_standby, rule, node);
              (*vfw_n_tailq_rules_ipv4_standby)--;
       } else {              /* IPV6 */
              TAILQ_REMOVE(vfw_tailq_rules_ipv6_standby, rule, node);
              (*vfw_n_tailq_rules_ipv6_standby)--;
       }

       rte_free(rule);

       return 0;
}

/**
 * Clear all VFW rules from the VFW rule table.
 * Rules cleared from standby tables.
 * Applyruleset command will activate the change.
 * Both IPv4 and IPv6 rules will be cleared.
 *
 * @param app
 *  A pointer to the VFW pipeline parameters.
 *
 * @return
 *  0 on success, negative on error.
 */
int app_pipeline_vfw_clearrules(struct app_params *app)
{
       struct app_pipeline_vfw_rule *rule;
       struct app_pipeline_vfw_rule *command;
       uint32_t n_rules;

       int priority;

       /* Check input arguments */
       if (app == NULL)
              return -1;

       n_rules = *vfw_n_tailq_rules_ipv4_standby;
       for (priority = 0; n_rules; priority++) {
              TAILQ_FOREACH(rule, vfw_tailq_rules_ipv4_standby, node) {
                     if (rule->priority == priority) {
                            struct pipeline_vfw_key key = rule->key;

                            /* Store command to update standby tables
                             * after switchover */
                            command =
                                rte_malloc(NULL, sizeof(*command),
                                          RTE_CACHE_LINE_SIZE);
                            if (command == NULL) {
                                   printf("Cannot allocation command\n");
                                   return -1;
                            }
                            memset(command, 0,
                                   sizeof(struct app_pipeline_vfw_rule));
                            memcpy(&command->key, &key, sizeof(key));
                            command->command = vfw_delete_command;
                            TAILQ_INSERT_TAIL(&vfw_commands, command,
                                            node);

                            /* Delete rule */
                            app_pipeline_vfw_delete_rule(app, &key);
                            n_rules--;
                     }
              }
       }

       n_rules = *vfw_n_tailq_rules_ipv6_standby;
       for (priority = 0; n_rules; priority++) {
              TAILQ_FOREACH(rule, vfw_tailq_rules_ipv6_standby, node) {
                     if (rule->priority == priority) {
                            struct pipeline_vfw_key key = rule->key;

                            /* Store command to update standby tables
                             * after switchover */
                            command =
                                rte_malloc(NULL, sizeof(*command),
                                          RTE_CACHE_LINE_SIZE);
                            if (command == NULL) {
                                   printf("Cannot allocation command\n");
                                   return -1;
                            }
                            memset(command, 0,
                                   sizeof(struct app_pipeline_vfw_rule));
                            memcpy(&command->key, &key, sizeof(key));
                            command->command = vfw_delete_command;
                            TAILQ_INSERT_TAIL(&vfw_commands, command,
                                            node);

                            /* Delete rule */
                            app_pipeline_vfw_delete_rule(app, &key);
                            n_rules--;
                     }
              }
       }

       /* Clear Action Array */
       memset(action_array_standby, 0, action_array_size);

       return 0;
}

/*
 * loadrules
 */

/**
 * Open file and process all commands in the file.
 *
 * @param ctx
 *  A pointer to the CLI context
 * @param file_name
 *  A pointer to the file to process.
 *
 */
static void app_loadrules_file(cmdline_parse_ctx_t *ctx, const char *file_name)
{
       struct cmdline *file_cl;
       int fd;

       fd = open(file_name, O_RDONLY);
       if (fd < 0) {
              printf("Cannot open file \"%s\"\n", file_name);
              return;
       }

       file_cl = cmdline_new(ctx, "", fd, 1);
       cmdline_interact(file_cl);
       close(fd);
}

struct cmd_loadrules_file_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t vfw_string;
       cmdline_fixed_string_t loadrules_string;
       char file_name[APP_FILE_NAME_SIZE];
};

/**
 * Parse load rules command.
 * Verify that file exists.
 * Clear existing rules and action.
 * Process commands in command file.
 *
 * @param parsed_result
 *  A pointer to the CLI command parsed result
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data.
 *
 * @return
 *  0 on success, negative on error.
 *
 */
static void
cmd_loadrules_parsed(void *parsed_result, struct cmdline *cl, void *data)
{
       struct cmd_loadrules_file_result *params = parsed_result;
       struct app_params *app = data;
       int status;
       int fd;

       /* Make sure the file exists before clearing rules and actions */
       fd = open(params->file_name, O_RDONLY);
       if (fd < 0) {
              printf("Cannot open file \"%s\"\n", params->file_name);
              return;
       }
       close(fd);

       /* Clear all rules and actions */
       status = app_pipeline_vfw_clearrules(app);

       if (status != 0) {
              printf("Command clearrules failed\n");
              return;
       }

       /* Process commands in script file */
       app_loadrules_file(cl->ctx, params->file_name);
}

cmdline_parse_token_string_t cmd_loadrules_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_loadrules_file_result,
                      p_string, "p");

cmdline_parse_token_string_t cmd_loadrules_vfw_string =
TOKEN_STRING_INITIALIZER(struct cmd_loadrules_file_result,
                      vfw_string, "vfw");

cmdline_parse_token_string_t cmd_loadrules_loadrules_string =
TOKEN_STRING_INITIALIZER(struct cmd_loadrules_file_result, loadrules_string,
                      "loadrules");

cmdline_parse_token_string_t cmd_loadrules_file_name =
TOKEN_STRING_INITIALIZER(struct cmd_loadrules_file_result, file_name, NULL);

cmdline_parse_inst_t cmd_loadrules = {
       .f = cmd_loadrules_parsed,
       .data = NULL,
       .help_str = "VFW Load Rules",
       .tokens = {
                 (void *)&cmd_loadrules_p_string,
                 (void *)&cmd_loadrules_vfw_string,
                 (void *)&cmd_loadrules_loadrules_string,
                 (void *)&cmd_loadrules_file_name,
                 NULL,
                 },
};

/**
 * Add Action to the Action table.
 * Actions are added standby table.
 * Applyruleset command will activate the change.
 *
 * @param app
 *  A pointer to the VFW pipeline parameters.
 * @param key
 *  A pointer to the Action to add.
 *
 * @return
 *  0 on success, negative on error.
 */
int
app_pipeline_action_add(__attribute__ ((unused)) struct app_params *app,
              struct pipeline_action_key *key)
{

       /*
        * This function will update the action IDs on the standby table.
        * Activating the changes is done with the applyruleset command.
        */

       uint32_t action_bitmap = key->action_bitmap;
       uint32_t action_id = key->action_id;

       if (action_id >= action_array_max) {
              if (VFW_DEBUG)
                     printf("Action id: %u out of range\n", action_id);
              return -1;
       }

       action_array_standby[action_id].action_id = action_id;

       if (VFW_DEBUG)
              printf("Adding action id: %u Type: ", action_id);
       if (action_bitmap == lib_acl_action_packet_accept) {
              action_array_standby[action_id].action_bitmap |=
                  lib_acl_action_packet_accept;
              if (VFW_DEBUG)
                     printf("Accept\n");
       }
       if (action_bitmap == lib_acl_action_packet_drop) {
              action_array_standby[action_id].action_bitmap |=
                  lib_acl_action_packet_drop;
              if (VFW_DEBUG)
                     printf("Drop\n");
       }
       if (action_bitmap == lib_acl_action_nat) {
              action_array_standby[action_id].action_bitmap |=
                  lib_acl_action_nat;
              action_array_standby[action_id].nat_port = key->nat_port;
              if (VFW_DEBUG)
                     printf("NAT  Port ID: %u\n", key->nat_port);
       }
       if (action_bitmap == lib_acl_action_fwd) {
              action_array_standby[action_id].action_bitmap |=
                  lib_acl_action_fwd;
              action_array_standby[action_id].fwd_port = key->fwd_port;
              if (VFW_DEBUG)
                     printf("FWD  Port ID: %u\n", key->fwd_port);
       }
       if (action_bitmap == lib_acl_action_count) {
              action_array_standby[action_id].action_bitmap |=
                  lib_acl_action_count;
              if (VFW_DEBUG)
                     printf("Count\n");
       }
       if (action_bitmap == lib_acl_action_conntrack) {
              action_array_standby[action_id].action_bitmap |=
                  lib_acl_action_conntrack;
              if (VFW_DEBUG)
                     printf("Conntrack\n");
       }
       if (action_bitmap == lib_acl_action_connexist) {
              action_array_standby[action_id].action_bitmap |=
                  lib_acl_action_connexist;
              action_array_standby[action_id].private_public =
                  key->private_public;
              if (VFW_DEBUG)
                     printf("Conntrack   prvpub: %i\n", key->private_public);
       }
       if (action_bitmap == lib_acl_action_dscp) {
              action_array_standby[action_id].action_bitmap |=
                  lib_acl_action_dscp;
              action_array_standby[action_id].dscp_priority =
                  key->dscp_priority;
              if (VFW_DEBUG)
                     printf("DSCP  Priority: %u\n", key->dscp_priority);
       }

       if (VFW_DEBUG)
              printf("action_bitmap: %" PRIu32 "\n",
                     action_array_standby[action_id].action_bitmap);

       return 0;
}

/**
 * Delete Action from the Action table.
 * Actions are deleted from the standby table.
 * Applyruleset command will activate the change.
 *
 * @param app
 *  A pointer to the VFW pipeline parameters.
 * @param key
 *  A pointer to the Action to delete.
 *
 * @return
 *  0 on success, negative on error.
 */
int
app_pipeline_action_delete(__attribute__ ((unused)) struct app_params *app,
                        struct pipeline_action_key *key)
{
       /*
        * This function will update the action IDs on the standby table.
        * Activating the changes is done with the applyruleset command.
        */

       uint32_t action_bitmap = key->action_bitmap;
       uint32_t action_id = key->action_id;

       if (action_id >= action_array_max) {
              if (VFW_DEBUG)
                     printf("Action id: %u out of range\n", action_id);
              return -1;
       }

       if (action_array_standby[action_id].action_bitmap & action_bitmap)
              action_array_standby[action_id].action_bitmap &= ~action_bitmap;
       else
              printf("VFW Action Delete - Action not set\n");

       if (VFW_DEBUG) {
              printf("Deleting action id: %u Type: ", key->action_id);
              if (action_bitmap == lib_acl_action_packet_accept)
                     printf("Accept\n");
              if (action_bitmap == lib_acl_action_packet_drop)
                     printf("Drop\n");
              if (action_bitmap == lib_acl_action_nat)
                     printf("NAT\n");
              if (action_bitmap == lib_acl_action_fwd)
                     printf("FWD\n");
              if (action_bitmap == lib_acl_action_count)
                     printf("Count\n");
              if (action_bitmap == lib_acl_action_conntrack)
                     printf("Conntrack\n");
              if (action_bitmap == lib_acl_action_connexist)
                     printf("Connexist\n");
              if (action_bitmap == lib_acl_action_dscp)
                     printf("DSCP\n");

              printf("action_bitmap: %" PRIu32 "\n",
                     action_array_standby[action_id].action_bitmap);
       }

       return 0;
}

/*
 * p vfw add
 */

/**
 * A structure defining the VFW add rule command.
 */
struct cmd_vfw_add_ip_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t vfw_string;
       cmdline_fixed_string_t add_string;
       int32_t priority;
       cmdline_ipaddr_t src_ip;
       uint32_t src_ip_mask;
       cmdline_ipaddr_t dst_ip;
       uint32_t dst_ip_mask;
       uint16_t src_port_from;
       uint16_t src_port_to;
       uint16_t dst_port_from;
       uint16_t dst_port_to;
       uint8_t proto;
       uint8_t proto_mask;
       uint8_t port_id;
       uint32_t action_id;
};

/**
 * Parse VFW add rule CLI command.
 * Add rule to standby table.
 * Store command to update standby table
 * after applyruleset command is invoked.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_vfw_add_ip_parsed(void *parsed_result, __attribute__ ((unused))
                      struct cmdline *cl, void *data)
{
       struct cmd_vfw_add_ip_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_vfw_key key;
       struct app_pipeline_vfw_rule *command;
       int status;

       memset(&key, 0, sizeof(struct pipeline_vfw_key));

       if (params->src_ip.family == AF_INET) {
              key.type = PIPELINE_VFW_IPV4_5TUPLE;
              key.key.ipv4_5tuple.src_ip = rte_bswap32((uint32_t)
                                                  params->src_ip.addr.
                                                  ipv4.s_addr);
              key.key.ipv4_5tuple.src_ip_mask = params->src_ip_mask;
              key.key.ipv4_5tuple.dst_ip = rte_bswap32((uint32_t)
                                                  params->dst_ip.addr.
                                                  ipv4.s_addr);
              key.key.ipv4_5tuple.dst_ip_mask = params->dst_ip_mask;
              key.key.ipv4_5tuple.src_port_from = params->src_port_from;
              key.key.ipv4_5tuple.src_port_to = params->src_port_to;
              key.key.ipv4_5tuple.dst_port_from = params->dst_port_from;
              key.key.ipv4_5tuple.dst_port_to = params->dst_port_to;
              key.key.ipv4_5tuple.proto = params->proto;
              key.key.ipv4_5tuple.proto_mask = params->proto_mask;
       }
       if (params->src_ip.family == AF_INET6) {
              if (VFW_DEBUG)
                     printf("entered IPV6");
              key.type = PIPELINE_VFW_IPV6_5TUPLE;
              memcpy(key.key.ipv6_5tuple.src_ip,
                     params->src_ip.addr.ipv6.s6_addr,
                     sizeof(params->src_ip.addr.ipv6.s6_addr));
              key.key.ipv6_5tuple.src_ip_mask = params->src_ip_mask;
              memcpy(key.key.ipv6_5tuple.dst_ip,
                     params->dst_ip.addr.ipv6.s6_addr,
                     sizeof(params->src_ip.addr.ipv6.s6_addr));
              key.key.ipv6_5tuple.dst_ip_mask = params->dst_ip_mask;
              key.key.ipv6_5tuple.src_port_from = params->src_port_from;
              key.key.ipv6_5tuple.src_port_to = params->src_port_to;
              key.key.ipv6_5tuple.dst_port_from = params->dst_port_from;
              key.key.ipv6_5tuple.dst_port_to = params->dst_port_to;
              key.key.ipv6_5tuple.proto = params->proto;
              key.key.ipv6_5tuple.proto_mask = params->proto_mask;
       }
       /* Set to 1 as default, overwritten by Action FWD/NAT Port */
       status = app_pipeline_vfw_add_rule(app, &key, params->priority, 1,
                                         params->action_id);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }

       /* Store command to update standby tables after switchover */
       command = rte_malloc(NULL, sizeof(*command), RTE_CACHE_LINE_SIZE);
       if (command == NULL) {
              printf("Cannot allocation command\n");
              return;
       }
       memset(command, 0, sizeof(struct app_pipeline_vfw_rule));
       memcpy(&command->key, &key, sizeof(key));
       command->priority = params->priority;
       command->port_id = params->port_id;
       command->action_id = params->action_id;
       command->command = vfw_add_command;
       TAILQ_INSERT_TAIL(&vfw_commands, command, node);
}

cmdline_parse_token_string_t cmd_vfw_add_ip_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_add_ip_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_vfw_add_ip_acl_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_add_ip_result,
                      vfw_string, "vfw");

cmdline_parse_token_string_t cmd_vfw_add_ip_add_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_add_ip_result,
                      add_string, "add");

cmdline_parse_token_num_t cmd_vfw_add_ip_priority =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_add_ip_result, priority,
                    INT32);

cmdline_parse_token_ipaddr_t cmd_vfw_add_ip_src_ip =
TOKEN_IPADDR_INITIALIZER(struct cmd_vfw_add_ip_result, src_ip);

cmdline_parse_token_num_t cmd_vfw_add_ip_src_ip_mask =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_add_ip_result, src_ip_mask,
                    UINT32);

cmdline_parse_token_ipaddr_t cmd_vfw_add_ip_dst_ip =
TOKEN_IPADDR_INITIALIZER(struct cmd_vfw_add_ip_result, dst_ip);

cmdline_parse_token_num_t cmd_vfw_add_ip_dst_ip_mask =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_add_ip_result, dst_ip_mask,
                    UINT32);

cmdline_parse_token_num_t cmd_vfw_add_ip_src_port_from =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_add_ip_result,
                    src_port_from, UINT16);

cmdline_parse_token_num_t cmd_vfw_add_ip_src_port_to =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_add_ip_result,
                    src_port_to, UINT16);

cmdline_parse_token_num_t cmd_vfw_add_ip_dst_port_from =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_add_ip_result,
                    dst_port_from, UINT16);

cmdline_parse_token_num_t cmd_vfw_add_ip_dst_port_to =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_add_ip_result,
                    dst_port_to, UINT16);

cmdline_parse_token_num_t cmd_vfw_add_ip_proto =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_add_ip_result,
                    proto, UINT8);

cmdline_parse_token_num_t cmd_vfw_add_ip_proto_mask =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_add_ip_result,
                    proto_mask, UINT8);

cmdline_parse_token_num_t cmd_vfw_add_ip_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_add_ip_result,
                    port_id, UINT8);

cmdline_parse_token_num_t cmd_vfw_add_ip_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_add_ip_result,
                    action_id, UINT32);

cmdline_parse_inst_t cmd_vfw_add_ip = {
       .f = cmd_vfw_add_ip_parsed,
       .data = NULL,
       .help_str = "VFW rule add",
       .tokens = {
                 (void *)&cmd_vfw_add_ip_p_string,
                 (void *)&cmd_vfw_add_ip_acl_string,
                 (void *)&cmd_vfw_add_ip_add_string,
                 (void *)&cmd_vfw_add_ip_priority,
                 (void *)&cmd_vfw_add_ip_src_ip,
                 (void *)&cmd_vfw_add_ip_src_ip_mask,
                 (void *)&cmd_vfw_add_ip_dst_ip,
                 (void *)&cmd_vfw_add_ip_dst_ip_mask,
                 (void *)&cmd_vfw_add_ip_src_port_from,
                 (void *)&cmd_vfw_add_ip_src_port_to,
                 (void *)&cmd_vfw_add_ip_dst_port_from,
                 (void *)&cmd_vfw_add_ip_dst_port_to,
                 (void *)&cmd_vfw_add_ip_proto,
                 (void *)&cmd_vfw_add_ip_proto_mask,
                 (void *)&cmd_vfw_add_ip_action_id,
                 NULL,
                 },
};

/*
 * p vfw del
 */

/**
 * A structure defining the VFW delete rule command.
 */
struct cmd_vfw_del_ip_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t vfw_string;
       cmdline_fixed_string_t del_string;
       cmdline_ipaddr_t src_ip;
       uint32_t src_ip_mask;
       cmdline_ipaddr_t dst_ip;
       uint32_t dst_ip_mask;
       uint16_t src_port_from;
       uint16_t src_port_to;
       uint16_t dst_port_from;
       uint16_t dst_port_to;
       uint8_t proto;
       uint8_t proto_mask;
};

/**
 * Parse VFW delete rule CLI command.
 * Delete rule from standby table.
 * Store command to update standby table
 * after applyruleset command is invoked.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_vfw_del_ip_parsed(void *parsed_result, __attribute__ ((unused))
                      struct cmdline *cl, void *data)
{
       struct cmd_vfw_del_ip_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_vfw_key key;
       struct app_pipeline_vfw_rule *command;
       int status;

       memset(&key, 0, sizeof(struct pipeline_vfw_key));

       if (params->src_ip.family == AF_INET) {
              key.type = PIPELINE_VFW_IPV4_5TUPLE;
              key.key.ipv4_5tuple.src_ip = rte_bswap32((uint32_t)
                                                  params->src_ip.addr.
                                                  ipv4.s_addr);
              key.key.ipv4_5tuple.src_ip_mask = params->src_ip_mask;
              key.key.ipv4_5tuple.dst_ip = rte_bswap32((uint32_t)
                                                  params->dst_ip.addr.
                                                  ipv4.s_addr);
              key.key.ipv4_5tuple.dst_ip_mask = params->dst_ip_mask;
              key.key.ipv4_5tuple.src_port_from = params->src_port_from;
              key.key.ipv4_5tuple.src_port_to = params->src_port_to;
              key.key.ipv4_5tuple.dst_port_from = params->dst_port_from;
              key.key.ipv4_5tuple.dst_port_to = params->dst_port_to;
              key.key.ipv4_5tuple.proto = params->proto;
              key.key.ipv4_5tuple.proto_mask = params->proto_mask;
       }
       if (params->src_ip.family == AF_INET6) {
              key.type = PIPELINE_VFW_IPV6_5TUPLE;
              memcpy(key.key.ipv6_5tuple.src_ip,
                     params->src_ip.addr.ipv6.s6_addr,
                     sizeof(params->src_ip.addr.ipv6.s6_addr));
              key.key.ipv6_5tuple.src_ip_mask = params->src_ip_mask;
              memcpy(key.key.ipv6_5tuple.dst_ip,
                     params->dst_ip.addr.ipv6.s6_addr,
                     sizeof(params->dst_ip.addr.ipv6.s6_addr));
              key.key.ipv6_5tuple.dst_ip_mask = params->dst_ip_mask;
              key.key.ipv6_5tuple.src_port_from = params->src_port_from;
              key.key.ipv6_5tuple.src_port_to = params->src_port_to;
              key.key.ipv6_5tuple.dst_port_from = params->dst_port_from;
              key.key.ipv6_5tuple.dst_port_to = params->dst_port_to;
              key.key.ipv6_5tuple.proto = params->proto;
              key.key.ipv6_5tuple.proto_mask = params->proto_mask;
       }

       status = app_pipeline_vfw_delete_rule(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }

       /* Store command to update standby tables after switchover */
       command = rte_malloc(NULL, sizeof(*command), RTE_CACHE_LINE_SIZE);
       if (command == NULL) {
              printf("Cannot allocation command\n");
              return;
       }
       memset(command, 0, sizeof(struct app_pipeline_vfw_rule));
       memcpy(&command->key, &key, sizeof(key));
       command->command = vfw_delete_command;
       TAILQ_INSERT_TAIL(&vfw_commands, command, node);
}

cmdline_parse_token_string_t cmd_vfw_del_ip_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_del_ip_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_vfw_del_ip_acl_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_del_ip_result,
                      vfw_string, "vfw");

cmdline_parse_token_string_t cmd_vfw_del_ip_del_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_del_ip_result,
                      del_string, "del");

cmdline_parse_token_ipaddr_t cmd_vfw_del_ip_src_ip =
TOKEN_IPADDR_INITIALIZER(struct cmd_vfw_del_ip_result, src_ip);

cmdline_parse_token_num_t cmd_vfw_del_ip_src_ip_mask =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_del_ip_result, src_ip_mask,
                    UINT32);

cmdline_parse_token_ipaddr_t cmd_vfw_del_ip_dst_ip =
TOKEN_IPADDR_INITIALIZER(struct cmd_vfw_del_ip_result, dst_ip);

cmdline_parse_token_num_t cmd_vfw_del_ip_dst_ip_mask =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_del_ip_result, dst_ip_mask,
                    UINT32);

cmdline_parse_token_num_t cmd_vfw_del_ip_src_port_from =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_del_ip_result,
                    src_port_from, UINT16);

cmdline_parse_token_num_t cmd_vfw_del_ip_src_port_to =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_del_ip_result, src_port_to,
                    UINT16);

cmdline_parse_token_num_t cmd_vfw_del_ip_dst_port_from =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_del_ip_result,
                    dst_port_from, UINT16);

cmdline_parse_token_num_t cmd_vfw_del_ip_dst_port_to =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_del_ip_result,
                    dst_port_to, UINT16);

cmdline_parse_token_num_t cmd_vfw_del_ip_proto =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_del_ip_result,
                    proto, UINT8);

cmdline_parse_token_num_t cmd_vfw_del_ip_proto_mask =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_del_ip_result, proto_mask,
                    UINT8);

cmdline_parse_inst_t cmd_vfw_del_ip = {
       .f = cmd_vfw_del_ip_parsed,
       .data = NULL,
       .help_str = "VFW rule delete",
       .tokens = {
                 (void *)&cmd_vfw_del_ip_p_string,
                 (void *)&cmd_vfw_del_ip_acl_string,
                 (void *)&cmd_vfw_del_ip_del_string,
                 (void *)&cmd_vfw_del_ip_src_ip,
                 (void *)&cmd_vfw_del_ip_src_ip_mask,
                 (void *)&cmd_vfw_del_ip_dst_ip,
                 (void *)&cmd_vfw_del_ip_dst_ip_mask,
                 (void *)&cmd_vfw_del_ip_src_port_from,
                 (void *)&cmd_vfw_del_ip_src_port_to,
                 (void *)&cmd_vfw_del_ip_dst_port_from,
                 (void *)&cmd_vfw_del_ip_dst_port_to,
                 (void *)&cmd_vfw_del_ip_proto,
                 (void *)&cmd_vfw_del_ip_proto_mask,
                 NULL,
                 },
};

/*
 * p vfw stats
 */

/**
 * A structure defining the VFW stats command.
 */
struct cmd_vfw_stats_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t vfw_string;
       cmdline_fixed_string_t stats_string;
};

/**
 * Display VFW and Connection Tracker stats to the console.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_vfw_stats_parsed(__attribute__ ((unused)) void *parsed_result,
              __attribute__ ((unused)) struct cmdline *cl,
              __attribute__ ((unused)) void *data)
{
       int i, j;
       struct rte_VFW_counter_block vfw_counter_sums;
       struct rte_CT_counter_block ct_counter_sums;
       struct rte_CT_counter_block *ct_counters;
       struct action_counter_block action_counter_sum[action_array_max];
       uint64_t sum_pkts_drop_fw = 0;

       memset(&vfw_counter_sums, 0, sizeof(vfw_counter_sums));
       memset(&ct_counter_sums, 0, sizeof(ct_counter_sums));
       memset(&action_counter_sum, 0, sizeof(action_counter_sum));

       printf("VFW Stats\n");
       for (i = 0; i <= rte_VFW_hi_counter_block_in_use; i++) {
              struct rte_VFW_counter_block *vfw_ctrs =
                  &rte_vfw_counter_table[i];
              ct_counters = rte_vfw_counter_table[i].ct_counters;

              uint64_t average_internal_time =
                  vfw_ctrs->time_measurements ==
                  0 ? 0 : vfw_ctrs->internal_time_sum /
                  vfw_ctrs->time_measurements;
              uint64_t average_external_time =
                  vfw_ctrs->time_measurements ==
                  0 ? 0 : vfw_ctrs->external_time_sum /
                  vfw_ctrs->time_measurements;
              uint64_t average_pkts_in_batch =
                  vfw_ctrs->num_pkts_measurements ==
                  0 ? 0 : vfw_ctrs->num_batch_pkts_sum /
                  vfw_ctrs->num_pkts_measurements;
              uint64_t pkts_drop_fw = vfw_ctrs->pkts_drop_ttl +
                                   vfw_ctrs->pkts_drop_bad_size +
                                   vfw_ctrs->pkts_drop_fragmented +
                                   vfw_ctrs->pkts_drop_unsupported_type;

              printf("{\"VFW_counters\" : {\"id\" : \"%s\", \" pkts_received\": %"
                     PRIu64 ", \" pkts_fw_forwarded\": %"
                     PRIu64 ", \" pkts_drop_fw\": %"
                     PRIu64 ", \" pkts_acl_forwarded\": %"
                     PRIu64 ", \"pkts_drop_without_rule\" : %"
                     PRIu64 ", \"average_pkts_in_batch\" : %"
                     PRIu64 ", \"average_internal_time_in_clocks\" : %"
                     PRIu64 ", \"average_external_time_in_clocks\" : %"
                     PRIu64 ", \"total_time_measures\" : %"
                     PRIu32 ", \"ct_packets_forwarded\" : %"
                     PRIu64 ", \"ct_packets_dropped\" : %"
                     PRIu64 ", \"bytes_processed \": %"
                     PRIu64 ", \"ct_sessions\" : {"
                     "\"active\" : %" PRIu64 ", \"open_attempt\" : %"
                     PRIu64 ", \"re-open_attempt\" : %"
                     PRIu64 ", \"established\" : %"
                     PRIu64 ", \"closed\" : %"
                     PRIu64 ", \"timeout\" : %"
                     PRIu64 "}, \"ct_drops\" : {"
                     "\"out_of_window\" : %" PRIu64 ", \"invalid_conn\" : %"
                     PRIu64 ", \"invalid_state_transition\" : %"
                     PRIu64 " \"RST\" : %"
                     PRIu64 "}}\n",
                     vfw_ctrs->name,
                     vfw_ctrs->pkts_received,
                     vfw_ctrs->pkts_fw_forwarded,
                     pkts_drop_fw,
                     vfw_ctrs->pkts_acl_forwarded,
                     vfw_ctrs->pkts_drop_without_rule,
                     average_pkts_in_batch,
                     average_internal_time,
                     average_external_time,
                     vfw_ctrs->time_measurements,
                     ct_counters->pkts_forwarded,
                     ct_counters->pkts_drop,
                     vfw_ctrs->bytes_processed,
                     ct_counters->current_active_sessions,
                     ct_counters->sessions_activated,
                     ct_counters->sessions_reactivated,
                     ct_counters->sessions_established,
                     ct_counters->sessions_closed,
                     ct_counters->sessions_timedout,
                     ct_counters->pkts_drop_outof_window,
                     ct_counters->pkts_drop_invalid_conn,
                     ct_counters->pkts_drop_invalid_state,
                     ct_counters->pkts_drop_invalid_rst);

              vfw_counter_sums.bytes_processed +=
                  vfw_ctrs->bytes_processed;

              vfw_counter_sums.internal_time_sum +=
                  vfw_ctrs->internal_time_sum;
              vfw_counter_sums.external_time_sum +=
                  vfw_ctrs->external_time_sum;
              vfw_counter_sums.time_measurements +=
                  vfw_ctrs->time_measurements;

              vfw_counter_sums.pkts_drop_ttl += vfw_ctrs->pkts_drop_ttl;
              vfw_counter_sums.pkts_drop_bad_size +=
                  vfw_ctrs->pkts_drop_bad_size;
              vfw_counter_sums.pkts_drop_fragmented +=
                  vfw_ctrs->pkts_drop_fragmented;
              vfw_counter_sums.pkts_drop_unsupported_type +=
                  vfw_ctrs->pkts_drop_unsupported_type;
              vfw_counter_sums.pkts_drop_without_arp_entry +=
                  vfw_ctrs->pkts_drop_without_arp_entry;

              vfw_counter_sums.pkts_drop_without_rule +=
                  vfw_ctrs->pkts_drop_without_rule;
              vfw_counter_sums.pkts_received += vfw_ctrs->pkts_received;
              vfw_counter_sums.pkts_fw_forwarded +=
                     vfw_ctrs->pkts_fw_forwarded;
              vfw_counter_sums.pkts_acl_forwarded +=
                     vfw_ctrs->pkts_acl_forwarded;
              sum_pkts_drop_fw += pkts_drop_fw;
              ct_counter_sums.pkts_forwarded += ct_counters->pkts_forwarded;
              ct_counter_sums.pkts_drop += ct_counters->pkts_drop;
              ct_counter_sums.current_active_sessions +=
                  ct_counters->current_active_sessions;
              ct_counter_sums.sessions_activated +=
                  ct_counters->sessions_activated;
              ct_counter_sums.sessions_reactivated +=
                  ct_counters->sessions_reactivated;
              ct_counter_sums.sessions_established +=
                  ct_counters->sessions_established;
              ct_counter_sums.sessions_closed += ct_counters->sessions_closed;
              ct_counter_sums.sessions_timedout +=
                  ct_counters->sessions_timedout;
              ct_counter_sums.pkts_drop_invalid_conn +=
                  ct_counters->pkts_drop_invalid_conn;
              ct_counter_sums.pkts_drop_invalid_state +=
                  ct_counters->pkts_drop_invalid_state;
              ct_counter_sums.pkts_drop_invalid_rst +=
                  ct_counters->pkts_drop_invalid_rst;
              ct_counter_sums.pkts_drop_outof_window +=
                  ct_counters->pkts_drop_outof_window;

       }

       printf("VFW TOTAL: pkts_received: %"
                     PRIu64 ", \"pkts_fw_forwarded\": %"
                     PRIu64 ", \"pkts_drop_fw\": %"
                     PRIu64 ", \"fw_drops\" : {"
                     "\"TTL_zero\" : %" PRIu64 ", \"bad_size\" : %"
                     PRIu64 ", \"fragmented_packet\" : %"
                     PRIu64 ", \"unsupported_packet_types\" : %"
                     PRIu64 ", \"no_arp_entry\" : %"
                     PRIu64 "}, \"pkts_acl_forwarded\": %"
                     PRIu64 ", \"pkts_drop_without_rule\": %"
                     PRIu64 ", \"packets_last_sec\" : %"
                     PRIu32 ", \"average_packets_per_sec\" : %"
                     PRIu32 ", \"bytes_last_sec\" : %"
                     PRIu32 ", \"average_bytes_per_sec\" : %"
                     PRIu32 ", \"bytes_processed \": %"
                     PRIu64 "\n",
                     vfw_counter_sums.pkts_received,
                     vfw_counter_sums.pkts_fw_forwarded,
                     sum_pkts_drop_fw,
                     vfw_counter_sums.pkts_drop_ttl,
                     vfw_counter_sums.pkts_drop_bad_size,
                     vfw_counter_sums.pkts_drop_fragmented,
                     vfw_counter_sums.pkts_drop_unsupported_type,
                     vfw_counter_sums.pkts_drop_without_arp_entry,
                     vfw_counter_sums.pkts_acl_forwarded,
                     vfw_counter_sums.pkts_drop_without_rule,
                     rte_vfw_performance_measures.pkts_last_second,
                     rte_vfw_performance_measures.ave_pkts_per_second,
                     rte_vfw_performance_measures.bytes_last_second,
                     rte_vfw_performance_measures.ave_bytes_per_second,
                     vfw_counter_sums.bytes_processed);

       printf("\"CT TOTAL: ct_packets_forwarded\" : %"
                     PRIu64 ", \" ct_packets_dropped\" : %"
                     PRIu64 ", \"ct_sessions\" : {"
                     "\"active\" : %" PRIu64 ", \"open_attempt\" : %"
                     PRIu64 ", \"re-open_attempt\" : %"
                     PRIu64 ", \"established\" : %"
                     PRIu64 ", \"closed\" : %"
                     PRIu64 ", \"timeout\" : %"
                     PRIu64 "}, \"ct_drops\" : {"
                     "\"out_of_window\" : %" PRIu64 ", \"invalid_conn\" : %"
                     PRIu64 ", \"invalid_state_transition\" : %"
                     PRIu64 " \"RST\" : %"
                     PRIu64 "}\n",
                     ct_counter_sums.pkts_forwarded,
                     ct_counter_sums.pkts_drop,
                     ct_counter_sums.current_active_sessions,
                     ct_counter_sums.sessions_activated,
                     ct_counter_sums.sessions_reactivated,
                     ct_counter_sums.sessions_established,
                     ct_counter_sums.sessions_closed,
                     ct_counter_sums.sessions_timedout,
                     ct_counter_sums.pkts_drop_outof_window,
                     ct_counter_sums.pkts_drop_invalid_conn,
                     ct_counter_sums.pkts_drop_invalid_state,
                     ct_counter_sums.pkts_drop_invalid_rst);

       for (i = 0; i <= rte_VFW_hi_counter_block_in_use; i++) {
              for (j = 0; j < action_array_max; j++) {
                     if (action_array_active[j].
                         action_bitmap & lib_acl_action_count) {
                            action_counter_sum[j].packetCount +=
                                action_counter_table[i][j].packetCount;
                            action_counter_sum[j].byteCount +=
                                action_counter_table[i][j].byteCount;
                     }
              }
       }

       for (j = 0; j < action_array_max; j++) {
              if (action_array_active[j].action_bitmap & lib_acl_action_count)
                     printf("Action ID: %02u, packetCount: %" PRIu64
                            ", byteCount: %" PRIu64 "\n", j,
                            action_counter_sum[j].packetCount,
                            action_counter_sum[j].byteCount);
       }
}

cmdline_parse_token_string_t cmd_vfw_stats_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_stats_result,
                      p_string, "p");

cmdline_parse_token_string_t cmd_vfw_stats_acl_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_stats_result,
                      vfw_string, "vfw");

cmdline_parse_token_string_t cmd_vfw_stats_stats_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_stats_result,
                      stats_string, "stats");

cmdline_parse_inst_t cmd_vfw_stats = {
       .f = cmd_vfw_stats_parsed,
       .data = NULL,
       .help_str = "VFW stats",
       .tokens = {
                 (void *)&cmd_vfw_stats_p_string,
                 (void *)&cmd_vfw_stats_acl_string,
                 (void *)&cmd_vfw_stats_stats_string,
                 NULL,
                 },
};

/*
 * p vfw clearstats
 */

/**
 * A structure defining the VFW clear stats command.
 */
struct cmd_vfw_clearstats_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t vfw_string;
       cmdline_fixed_string_t clearstats_string;
};

/**
 * Clear VFW and Connection Tracker stats.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void cmd_vfw_clearstats_parsed(__attribute__ ((unused))
                                    void *parsed_result,
                                    __attribute__ ((unused))
                                    struct cmdline *cl,
                                    __attribute__ ((unused))
                                    void *data)
{
       int i;
       struct rte_CT_counter_block *ct_counters;

       for (i = 0; i <= rte_VFW_hi_counter_block_in_use; i++) {
              ct_counters = rte_vfw_counter_table[i].ct_counters;
              rte_vfw_counter_table[i].bytes_processed = 0;
              rte_vfw_counter_table[i].pkts_drop_without_rule = 0;
              rte_vfw_counter_table[i].pkts_received = 0;
              rte_vfw_counter_table[i].pkts_drop_ttl = 0;
              rte_vfw_counter_table[i].pkts_drop_bad_size = 0;
              rte_vfw_counter_table[i].pkts_drop_fragmented = 0;
              rte_vfw_counter_table[i].pkts_drop_without_arp_entry = 0;
              rte_vfw_counter_table[i].internal_time_sum = 0;
              rte_vfw_counter_table[i].external_time_sum = 0;
              rte_vfw_counter_table[i].time_measurements = 0;
              rte_vfw_counter_table[i].ct_counters->pkts_forwarded = 0;
              rte_vfw_counter_table[i].ct_counters->pkts_drop = 0;
              rte_vfw_counter_table[i].pkts_fw_forwarded = 0;
              rte_vfw_counter_table[i].pkts_acl_forwarded = 0;
              ct_counters->current_active_sessions = 0;
              ct_counters->sessions_activated = 0;
              ct_counters->sessions_reactivated = 0;
              ct_counters->sessions_established = 0;
              ct_counters->sessions_closed = 0;
              ct_counters->sessions_timedout = 0;
              ct_counters->pkts_drop_invalid_conn = 0;
              ct_counters->pkts_drop_invalid_state = 0;
              ct_counters->pkts_drop_invalid_rst = 0;
              ct_counters->pkts_drop_outof_window = 0;
       }

       memset(&action_counter_table, 0, sizeof(action_counter_table));
       rte_vfw_reset_running_averages();
}

cmdline_parse_token_string_t cmd_vfw_clearstats_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_clearstats_result,
                      p_string, "p");

cmdline_parse_token_string_t cmd_vfw_clearstats_acl_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_clearstats_result,
                      vfw_string, "vfw");

cmdline_parse_token_string_t cmd_vfw_clearstats_clearstats_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_clearstats_result,
                      clearstats_string, "clearstats");

cmdline_parse_inst_t cmd_vfw_clearstats = {
       .f = cmd_vfw_clearstats_parsed,
       .data = NULL,
       .help_str = "VFW clearstats",
       .tokens = {
                 (void *)&cmd_vfw_clearstats_p_string,
                 (void *)&cmd_vfw_clearstats_acl_string,
                 (void *)&cmd_vfw_clearstats_clearstats_string,
                 NULL,
                 },
};

/*
 * p vfw dbg
 */

/**
 * A structure defining the VFW debug command.
 */
struct cmd_vfw_dbg_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t vfw_string;
       cmdline_fixed_string_t dbg_string;
       uint8_t dbg;
};

/**
 * Parse and handle VFW debug command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void cmd_vfw_dbg_parsed(void *parsed_result, __attribute__ ((unused))
                              struct cmdline *cl, __rte_unused void *data)
{

        struct cmd_vfw_dbg_result *params = parsed_result;
       if (params->dbg == 0) {
              printf("DBG turned OFF\n");
              VFW_DEBUG = 0;
       } else if (params->dbg == 1) {
              printf("DBG turned ON\n");
              VFW_DEBUG = 1;
       } else if (params->dbg == 2) {
              printf("VFW IPV4 enabled\n");
              printf("VFW IPV6 enabled\n");
              vfw_ipv4_enabled = 1;
              vfw_ipv6_enabled = 1;
       } else if (params->dbg == 3) {
              printf("VFW IPV4 enabled\n");
              printf("VFW IPV6 disabled\n");
              vfw_ipv4_enabled = 1;
              vfw_ipv6_enabled = 0;
       } else if (params->dbg == 4) {
              printf("VFW IPV4 disabled\n");
              printf("VFW IPV6 enabled\n");
              vfw_ipv4_enabled = 0;
              vfw_ipv6_enabled = 1;
       } else if (params->dbg == 5) {
              printf("VFW Version: 3.03\n");
       } else
              printf("Invalid DBG setting\n");
}

cmdline_parse_token_string_t cmd_vfw_dbg_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_dbg_result,
                      p_string, "p");

cmdline_parse_token_string_t cmd_vfw_dbg_acl_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_dbg_result,
                      vfw_string, "vfw");

cmdline_parse_token_string_t cmd_vfw_dbg_dbg_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_dbg_result,
                      dbg_string, "dbg");

cmdline_parse_token_num_t cmd_vfw_dbg_dbg =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_dbg_result, dbg,
                    UINT8);

cmdline_parse_inst_t cmd_vfw_dbg = {
       .f = cmd_vfw_dbg_parsed,
       .data = NULL,
       .help_str = "VFW dbg",
       .tokens = {
                 (void *)&cmd_vfw_dbg_p_string,
                 (void *)&cmd_vfw_dbg_acl_string,
                 (void *)&cmd_vfw_dbg_dbg_string,
                 (void *)&cmd_vfw_dbg_dbg,
                 NULL,
                 },
};

/*
 * p vfw clearrules
 */

/**
 * A structure defining the VFW clear rules command.
 */
struct cmd_vfw_clearrules_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t vfw_string;
       cmdline_fixed_string_t clearrules_string;
};

/**
 * Parse clear rule command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void cmd_vfw_clearrules_parsed(__attribute__ ((unused))
                                    void *parsed_result,
                                    __attribute__ ((unused))
                                    struct cmdline *cl, void *data)
{
       struct app_params *app = data;
       int status;

       status = app_pipeline_vfw_clearrules(app);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_vfw_clearrules_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_clearrules_result,
                      p_string, "p");

cmdline_parse_token_string_t cmd_vfw_clearrules_acl_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_clearrules_result,
                      vfw_string, "vfw");

cmdline_parse_token_string_t cmd_vfw_clearrules_clearrules_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_clearrules_result,
                      clearrules_string, "clearrules");

cmdline_parse_inst_t cmd_vfw_clearrules = {
       .f = cmd_vfw_clearrules_parsed,
       .data = NULL,
       .help_str = "VFW clearrules",
       .tokens = {
                 (void *)&cmd_vfw_clearrules_p_string,
                 (void *)&cmd_vfw_clearrules_acl_string,
                 (void *)&cmd_vfw_clearrules_clearrules_string,
                 NULL,
                 },
};

/*
 * p vfw ls
 */

/**
 * A structure defining the VFW ls CLI command result.
 */
struct cmd_vfw_ls_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t vfw_string;
       cmdline_fixed_string_t ls_string;
       uint32_t table_instance;
};

/**
 * Parse VFW ls command to display rules to the console.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void cmd_vfw_ls_parsed(__attribute__ ((unused))
                             void *parsed_result, __attribute__ ((unused))
                             struct cmdline *cl, void *data)
{
       struct app_params *app = data;
       struct cmd_vfw_ls_result *params = parsed_result;

       app_pipeline_vfw_ls(app, params->table_instance);
}

cmdline_parse_token_string_t cmd_vfw_ls_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_ls_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_vfw_ls_acl_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_ls_result,
                      vfw_string, "vfw");

cmdline_parse_token_string_t cmd_vfw_ls_ls_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_ls_result, ls_string,
                      "ls");

cmdline_parse_token_num_t cmd_vfw_ls_table_instance =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_ls_result, table_instance,
                    UINT32);

cmdline_parse_inst_t cmd_vfw_ls = {
       .f = cmd_vfw_ls_parsed,
       .data = NULL,
       .help_str = "VFW rule list",
       .tokens = {
                 (void *)&cmd_vfw_ls_p_string,
                 (void *)&cmd_vfw_ls_acl_string,
                 (void *)&cmd_vfw_ls_ls_string,
                 (void *)&cmd_vfw_ls_table_instance,
                 NULL,
                 },
};

/*
 * p vfw applyruleset
 */

/**
 * A structure defining the VFW apply ruleset command.
 */
struct cmd_vfw_applyruleset_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t vfw_string;
       cmdline_fixed_string_t applyruleset_string;
};

/**
 * Parse VFW Apply Ruleset Command.
 * Switchover active and standby tables.
 * Sync newly standby tables to match updated data.
 * Both VFW rule and VFW action tables updated.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void cmd_vfw_applyruleset_parsed(__attribute__ ((unused))
                                      void *parsed_result,
                                      __attribute__ ((unused))
                                      struct cmdline *cl, void *data)
{
       struct app_params *app = data;
       void *temp_ptr;
       uint32_t *temp_count_ptr;
       struct pipeline_action_key *action_array_temp_ptr;
       int status;

       printf("VFW Apply Ruleset\n");

       /* Switchover Active and Standby TRIE rule tables */
       temp_ptr = vfw_rule_table_ipv4_active;
       vfw_rule_table_ipv4_active = vfw_rule_table_ipv4_standby;
       vfw_rule_table_ipv4_standby = temp_ptr;
       temp_ptr = vfw_rule_table_ipv6_active;
       vfw_rule_table_ipv6_active = vfw_rule_table_ipv6_standby;
       vfw_rule_table_ipv6_standby = temp_ptr;

       /* Switchover tailq tables */
       vfw_tailq_rules_temp_ptr = vfw_tailq_rules_ipv4_active;
       vfw_tailq_rules_ipv4_active = vfw_tailq_rules_ipv4_standby;
       vfw_tailq_rules_ipv4_standby = vfw_tailq_rules_temp_ptr;
       vfw_tailq_rules_temp_ptr = vfw_tailq_rules_ipv6_active;
       vfw_tailq_rules_ipv6_active = vfw_tailq_rules_ipv6_standby;
       vfw_tailq_rules_ipv6_standby = vfw_tailq_rules_temp_ptr;
       temp_count_ptr = vfw_n_tailq_rules_ipv4_active;
       vfw_n_tailq_rules_ipv4_active = vfw_n_tailq_rules_ipv4_standby;
       vfw_n_tailq_rules_ipv4_standby = temp_count_ptr;
       temp_count_ptr = vfw_n_tailq_rules_ipv6_active;
       vfw_n_tailq_rules_ipv6_active = vfw_n_tailq_rules_ipv6_standby;
       vfw_n_tailq_rules_ipv6_standby = temp_count_ptr;

       /* Switchover Active and Standby action table */
       action_array_temp_ptr = action_array_active;
       action_array_active = action_array_standby;
       action_array_standby = action_array_temp_ptr;
       /* Update Standby action table with all changes */
       memcpy(action_array_standby, action_array_active, action_array_size);

       /* Update Standby Rule Tables with all changes */
       while (!TAILQ_EMPTY(&vfw_commands)) {
              struct app_pipeline_vfw_rule *command;

              command = TAILQ_FIRST(&vfw_commands);
              TAILQ_REMOVE(&vfw_commands, command, node);

              if (command->command == vfw_add_command) {
                     status = app_pipeline_vfw_add_rule(app,
                                                       &command->key,
                                                       command->priority,
                                                       command->port_id,
                                                       command->
                                                       action_id);
              } else
                     status =
                         app_pipeline_vfw_delete_rule(app, &command->key);

              if (status != 0) {
                     printf("Command applyruleset add rule failed\n");
                     rte_free(command);
                     return;
              }

              rte_free(command);
       }
}

cmdline_parse_token_string_t cmd_vfw_applyruleset_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_applyruleset_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_vfw_applyruleset_acl_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_applyruleset_result,
                      vfw_string, "vfw");

cmdline_parse_token_string_t cmd_vfw_applyruleset_applyruleset_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_applyruleset_result,
                      applyruleset_string,
                      "applyruleset");

cmdline_parse_inst_t cmd_vfw_applyruleset = {
       .f = cmd_vfw_applyruleset_parsed,
       .data = NULL,
       .help_str = "VFW applyruleset",
       .tokens = {
                 (void *)&cmd_vfw_applyruleset_p_string,
                 (void *)&cmd_vfw_applyruleset_acl_string,
                 (void *)&cmd_vfw_applyruleset_applyruleset_string,
                 NULL,
                 },
};
/*
 * p action add accept
 */

/**
 * A structure defining the add accept action command.
 */
struct cmd_action_add_accept_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t add_string;
       int32_t action_id;
       cmdline_fixed_string_t accept_string;
};

/**
 * Parse Accept Action Add Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_add_accept_parsed(void *parsed_result, __attribute__ ((unused))
                          struct cmdline *cl, void *data)
{
       struct cmd_action_add_accept_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_packet_accept;

       status = app_pipeline_action_add(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_add_accept_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_accept_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_add_accept_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_accept_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_add_accept_add_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_accept_result,
                      add_string, "add");

cmdline_parse_token_num_t cmd_action_add_accept_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_add_accept_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_add_accept_accept_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_accept_result,
                      accept_string, "accept");

cmdline_parse_inst_t cmd_action_add_accept = {
       .f = cmd_action_add_accept_parsed,
       .data = NULL,
       .help_str = "VFW action add accept",
       .tokens = {
                 (void *)&cmd_action_add_accept_p_string,
                 (void *)&cmd_action_add_accept_action_string,
                 (void *)&cmd_action_add_accept_add_string,
                 (void *)&cmd_action_add_accept_action_id,
                 (void *)&cmd_action_add_accept_accept_string,
                 NULL,
                 },
};

/*
 * p action del accept
 */

/**
 * A structure defining the delete accept action command.
 */
struct cmd_action_del_accept_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t del_string;
       int32_t action_id;
       cmdline_fixed_string_t accept_string;
};

/**
 * Parse Accept Action Delete Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_del_accept_parsed(void *parsed_result, __attribute__ ((unused))
                          struct cmdline *cl, void *data)
{
       struct cmd_action_del_accept_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_packet_accept;

       status = app_pipeline_action_delete(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_del_accept_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_accept_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_del_accept_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_accept_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_del_accept_del_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_accept_result,
                      del_string, "del");

cmdline_parse_token_num_t cmd_action_del_accept_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_del_accept_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_del_accept_accept_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_accept_result,
                      accept_string, "accept");

cmdline_parse_inst_t cmd_action_del_accept = {
       .f = cmd_action_del_accept_parsed,
       .data = NULL,
       .help_str = "VFW action delete accept",
       .tokens = {
                 (void *)&cmd_action_del_accept_p_string,
                 (void *)&cmd_action_del_accept_action_string,
                 (void *)&cmd_action_del_accept_del_string,
                 (void *)&cmd_action_del_accept_action_id,
                 (void *)&cmd_action_del_accept_accept_string,
                 NULL,
                 },
};

/*
 * p action add drop
 */

/**
 * A structure defining the add drop action command.
 */
struct cmd_action_add_drop_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t add_string;
       int32_t action_id;
       cmdline_fixed_string_t drop_string;
};

/**
 * Parse Drop Action Add Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_add_drop_parsed(void *parsed_result, __attribute__ ((unused))
                        struct cmdline *cl, void *data)
{
       struct cmd_action_add_drop_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_packet_drop;

       status = app_pipeline_action_add(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_add_drop_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_drop_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_add_drop_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_drop_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_add_drop_add_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_drop_result,
                      add_string, "add");

cmdline_parse_token_num_t cmd_action_add_drop_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_add_drop_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_add_drop_drop_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_drop_result,
                      drop_string, "drop");

cmdline_parse_inst_t cmd_action_add_drop = {
       .f = cmd_action_add_drop_parsed,
       .data = NULL,
       .help_str = "VFW action add drop",
       .tokens = {
                 (void *)&cmd_action_add_drop_p_string,
                 (void *)&cmd_action_add_drop_action_string,
                 (void *)&cmd_action_add_drop_add_string,
                 (void *)&cmd_action_add_drop_action_id,
                 (void *)&cmd_action_add_drop_drop_string,
                 NULL,
                 },
};

/*
 * p action del drop
 */

/**
 * A structure defining the delete drop action command.
 */
struct cmd_action_del_drop_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t del_string;
       int32_t action_id;
       cmdline_fixed_string_t drop_string;
};

/**
 * Parse Drop Action Delete Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_del_drop_parsed(void *parsed_result, __attribute__ ((unused))
                        struct cmdline *cl, void *data)
{
       struct cmd_action_del_drop_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_packet_drop;

       status = app_pipeline_action_delete(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_del_drop_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_drop_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_del_drop_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_drop_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_del_drop_del_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_drop_result,
                      del_string, "del");

cmdline_parse_token_num_t cmd_action_del_drop_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_del_drop_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_del_drop_drop_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_drop_result,
                      drop_string, "drop");

cmdline_parse_inst_t cmd_action_del_drop = {
       .f = cmd_action_del_drop_parsed,
       .data = NULL,
       .help_str = "VFW action delete drop",
       .tokens = {
                 (void *)&cmd_action_del_drop_p_string,
                 (void *)&cmd_action_del_drop_action_string,
                 (void *)&cmd_action_del_drop_del_string,
                 (void *)&cmd_action_del_drop_action_id,
                 (void *)&cmd_action_del_drop_drop_string,
                 NULL,
                 },
};

/*
 * p action add fwd
 */

/**
 * A structure defining the add forward action command.
 */
struct cmd_action_add_fwd_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t add_string;
       int32_t action_id;
       cmdline_fixed_string_t fwd_string;
       int32_t port_id;
};

/**
 * Parse Forward Action Add Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_add_fwd_parsed(void *parsed_result, __attribute__ ((unused))
                       struct cmdline *cl, void *data)
{
       struct cmd_action_add_fwd_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_fwd;
       key.fwd_port = params->port_id;

       status = app_pipeline_action_add(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_add_fwd_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_fwd_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_add_fwd_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_fwd_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_add_fwd_add_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_fwd_result,
                      add_string, "add");

cmdline_parse_token_num_t cmd_action_add_fwd_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_add_fwd_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_add_fwd_fwd_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_fwd_result,
                      fwd_string, "fwd");

cmdline_parse_token_num_t cmd_action_add_fwd_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_add_fwd_result, port_id,
                    UINT32);

cmdline_parse_inst_t cmd_action_add_fwd = {
       .f = cmd_action_add_fwd_parsed,
       .data = NULL,
       .help_str = "VFW action add fwd",
       .tokens = {
                 (void *)&cmd_action_add_fwd_p_string,
                 (void *)&cmd_action_add_fwd_action_string,
                 (void *)&cmd_action_add_fwd_add_string,
                 (void *)&cmd_action_add_fwd_action_id,
                 (void *)&cmd_action_add_fwd_fwd_string,
                 (void *)&cmd_action_add_fwd_port_id,
                 NULL,
                 },
};

/*
 * p action del fwd
 */

/**
 * A structure defining the delete forward action command.
 */
struct cmd_action_del_fwd_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t del_string;
       int32_t action_id;
       cmdline_fixed_string_t fwd_string;
};

/**
 * Parse Forward Action Delete Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_del_fwd_parsed(void *parsed_result, __attribute__ ((unused))
                       struct cmdline *cl, void *data)
{
       struct cmd_action_del_fwd_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_fwd;

       status = app_pipeline_action_delete(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_del_fwd_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_fwd_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_del_fwd_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_fwd_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_del_fwd_del_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_fwd_result,
                      del_string, "del");

cmdline_parse_token_num_t cmd_action_del_fwd_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_del_fwd_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_del_fwd_fwd_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_fwd_result,
                      fwd_string, "fwd");

cmdline_parse_inst_t cmd_action_del_fwd = {
       .f = cmd_action_del_fwd_parsed,
       .data = NULL,
       .help_str = "VFW action delete fwd",
       .tokens = {
                 (void *)&cmd_action_del_fwd_p_string,
                 (void *)&cmd_action_del_fwd_action_string,
                 (void *)&cmd_action_del_fwd_del_string,
                 (void *)&cmd_action_del_fwd_action_id,
                 (void *)&cmd_action_del_fwd_fwd_string,
                 NULL,
                 },
};

/*
 * p action add nat
 */

/**
 * A structure defining the add NAT action command.
 */
struct cmd_action_add_nat_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t add_string;
       int32_t action_id;
       cmdline_fixed_string_t nat_string;
       int32_t port_id;
};

/**
 * Parse NAT Action Add Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_add_nat_parsed(void *parsed_result, __attribute__ ((unused))
                       struct cmdline *cl, void *data)
{
       struct cmd_action_add_nat_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_nat;
       key.nat_port = params->port_id;

       status = app_pipeline_action_add(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_add_nat_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_nat_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_add_nat_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_nat_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_add_nat_add_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_nat_result,
                      add_string, "add");

cmdline_parse_token_num_t cmd_action_add_nat_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_add_nat_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_add_nat_nat_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_nat_result,
                      nat_string, "nat");

cmdline_parse_token_num_t cmd_action_add_nat_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_add_nat_result, port_id,
                    UINT32);

cmdline_parse_inst_t cmd_action_add_nat = {
       .f = cmd_action_add_nat_parsed,
       .data = NULL,
       .help_str = "VFW action add nat",
       .tokens = {
                 (void *)&cmd_action_add_nat_p_string,
                 (void *)&cmd_action_add_nat_action_string,
                 (void *)&cmd_action_add_nat_add_string,
                 (void *)&cmd_action_add_nat_action_id,
                 (void *)&cmd_action_add_nat_nat_string,
                 (void *)&cmd_action_add_nat_port_id,
                 NULL,
                 },
};

/*
 * p action del nat
 */

/**
 * A structure defining the delete NAT action command.
 */
struct cmd_action_del_nat_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t del_string;
       int32_t action_id;
       cmdline_fixed_string_t nat_string;
};

/**
 * Parse NAT Action Delete Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_del_nat_parsed(void *parsed_result, __attribute__ ((unused))
                       struct cmdline *cl, void *data)
{
       struct cmd_action_del_nat_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_nat;

       status = app_pipeline_action_delete(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_del_nat_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_nat_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_del_nat_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_nat_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_del_nat_del_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_nat_result,
                      del_string, "del");

cmdline_parse_token_num_t cmd_action_del_nat_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_del_nat_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_del_nat_nat_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_nat_result,
                      nat_string, "nat");

cmdline_parse_inst_t cmd_action_del_nat = {
       .f = cmd_action_del_nat_parsed,
       .data = NULL,
       .help_str = "VFW action delete nat",
       .tokens = {
                 (void *)&cmd_action_del_nat_p_string,
                 (void *)&cmd_action_del_nat_action_string,
                 (void *)&cmd_action_del_nat_del_string,
                 (void *)&cmd_action_del_nat_action_id,
                 (void *)&cmd_action_del_nat_nat_string,
                 NULL,
                 },
};

/*
 * p action add count
 */

/**
 * A structure defining the add count action command.
 */
struct cmd_action_add_count_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t add_string;
       int32_t action_id;
       cmdline_fixed_string_t count_string;
};

/**
 * Parse Count Action Add Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_add_count_parsed(void *parsed_result, __attribute__ ((unused))
                         struct cmdline *cl, void *data)
{
       struct cmd_action_add_count_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_count;

       status = app_pipeline_action_add(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_add_count_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_count_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_add_count_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_count_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_add_count_add_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_count_result,
                      add_string, "add");

cmdline_parse_token_num_t cmd_action_add_count_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_add_count_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_add_count_count_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_count_result,
                      count_string, "count");

cmdline_parse_inst_t cmd_action_add_count = {
       .f = cmd_action_add_count_parsed,
       .data = NULL,
       .help_str = "VFW action add count",
       .tokens = {
                 (void *)&cmd_action_add_count_p_string,
                 (void *)&cmd_action_add_count_action_string,
                 (void *)&cmd_action_add_count_add_string,
                 (void *)&cmd_action_add_count_action_id,
                 (void *)&cmd_action_add_count_count_string,
                 NULL,
                 },
};

/*
 * p action del count
 */

/**
 * A structure defining the delete count action command.
 */
struct cmd_action_del_count_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t del_string;
       int32_t action_id;
       cmdline_fixed_string_t count_string;
};

/**
 * Parse Count Action Delete Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_del_count_parsed(void *parsed_result, __attribute__ ((unused))
                         struct cmdline *cl, void *data)
{
       struct cmd_action_del_count_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_count;

       status = app_pipeline_action_delete(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_del_count_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_count_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_del_count_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_count_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_del_count_del_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_count_result,
                      del_string, "del");

cmdline_parse_token_num_t cmd_action_del_count_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_del_count_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_del_count_count_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_count_result,
                      count_string, "count");

cmdline_parse_inst_t cmd_action_del_count = {
       .f = cmd_action_del_count_parsed,
       .data = NULL,
       .help_str = "VFW action delete count",
       .tokens = {
                 (void *)&cmd_action_del_count_p_string,
                 (void *)&cmd_action_del_count_action_string,
                 (void *)&cmd_action_del_count_del_string,
                 (void *)&cmd_action_del_count_action_id,
                 (void *)&cmd_action_del_count_count_string,
                 NULL,
                 },
};

/*
 * p action add dscp
 */

/**
 * A structure defining the add DSCP action command.
 */
struct cmd_action_add_dscp_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t add_string;
       int32_t action_id;
       cmdline_fixed_string_t dscp_string;
       uint8_t dscp_priority;
};

/**
 * Parse DSCP Action Add Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_add_dscp_parsed(void *parsed_result, __attribute__ ((unused))
                        struct cmdline *cl, void *data)
{
       struct cmd_action_add_dscp_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_dscp;
       key.dscp_priority = params->dscp_priority;

       status = app_pipeline_action_add(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_add_dscp_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_dscp_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_add_dscp_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_dscp_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_add_dscp_add_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_dscp_result,
                      add_string, "add");

cmdline_parse_token_num_t cmd_action_add_dscp_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_add_dscp_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_add_dscp_dscp_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_dscp_result,
                      dscp_string, "dscp");

cmdline_parse_token_num_t cmd_action_add_dscp_dscp_priority =
TOKEN_NUM_INITIALIZER(struct cmd_action_add_dscp_result, dscp_priority,
                    UINT8);

cmdline_parse_inst_t cmd_action_add_dscp = {
       .f = cmd_action_add_dscp_parsed,
       .data = NULL,
       .help_str = "VFW action add dscp",
       .tokens = {
                 (void *)&cmd_action_add_dscp_p_string,
                 (void *)&cmd_action_add_dscp_action_string,
                 (void *)&cmd_action_add_dscp_add_string,
                 (void *)&cmd_action_add_dscp_action_id,
                 (void *)&cmd_action_add_dscp_dscp_string,
                 (void *)&cmd_action_add_dscp_dscp_priority,
                 NULL,
                 },
};

/*
 * p action del dscp
 */

/**
 * A structure defining the delete DSCP action command.
 */
struct cmd_action_del_dscp_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t del_string;
       int32_t action_id;
       cmdline_fixed_string_t dscp_string;
};

/**
 * Parse DSCP Action Delete Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_del_dscp_parsed(void *parsed_result, __attribute__ ((unused))
                        struct cmdline *cl, void *data)
{
       struct cmd_action_del_dscp_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_dscp;

       status = app_pipeline_action_delete(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_del_dscp_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_dscp_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_del_dscp_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_dscp_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_del_dscp_del_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_dscp_result,
                      del_string, "del");

cmdline_parse_token_num_t cmd_action_del_dscp_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_del_dscp_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_del_dscp_dscp_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_dscp_result,
                      dscp_string, "dscp");

cmdline_parse_inst_t cmd_action_del_dscp = {
       .f = cmd_action_del_dscp_parsed,
       .data = NULL,
       .help_str = "VFW action delete dscp",
       .tokens = {
                 (void *)&cmd_action_del_dscp_p_string,
                 (void *)&cmd_action_del_dscp_action_string,
                 (void *)&cmd_action_del_dscp_del_string,
                 (void *)&cmd_action_del_dscp_action_id,
                 (void *)&cmd_action_del_dscp_dscp_string,
                 NULL,
                 },
};

/*
 * p action add conntrack
 */

/**
 * A structure defining the add Connection Tracking action command.
 */
struct cmd_action_add_conntrack_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t add_string;
       int32_t action_id;
       cmdline_fixed_string_t conntrack_string;
};

/**
 * Parse Connection Tracking Action Add Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_add_conntrack_parsed(void *parsed_result, __attribute__ ((unused))
                            struct cmdline *cl, void *data)
{
       struct cmd_action_add_conntrack_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_conntrack;

       status = app_pipeline_action_add(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_add_conntrack_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_conntrack_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_add_conntrack_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_conntrack_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_add_conntrack_add_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_conntrack_result,
                      add_string, "add");

cmdline_parse_token_num_t cmd_action_add_conntrack_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_add_conntrack_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_add_conntrack_conntrack_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_conntrack_result,
                      conntrack_string, "conntrack");

cmdline_parse_inst_t cmd_action_add_conntrack = {
       .f = cmd_action_add_conntrack_parsed,
       .data = NULL,
       .help_str = "VFW action add conntrack",
       .tokens = {
                 (void *)&cmd_action_add_conntrack_p_string,
                 (void *)&cmd_action_add_conntrack_action_string,
                 (void *)&cmd_action_add_conntrack_add_string,
                 (void *)&cmd_action_add_conntrack_action_id,
                 (void *)&cmd_action_add_conntrack_conntrack_string,
                 NULL,
                 },
};

/*
 * p action del conntrack
 */

/**
 * A structure defining the delete Connection Tracking action command.
 */
struct cmd_action_del_conntrack_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t del_string;
       int32_t action_id;
       cmdline_fixed_string_t conntrack_string;
};

/**
 * Parse Connection Tracking Action Delete Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_del_conntrack_parsed(void *parsed_result, __attribute__ ((unused))
                            struct cmdline *cl, void *data)
{
       struct cmd_action_del_conntrack_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_conntrack;

       status = app_pipeline_action_delete(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_del_conntrack_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_conntrack_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_del_conntrack_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_conntrack_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_del_conntrack_del_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_conntrack_result,
                      del_string, "del");

cmdline_parse_token_num_t cmd_action_del_conntrack_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_del_conntrack_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_del_conntrack_conntrack_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_conntrack_result,
                      conntrack_string, "conntrack");

cmdline_parse_inst_t cmd_action_del_conntrack = {
       .f = cmd_action_del_conntrack_parsed,
       .data = NULL,
       .help_str = "VFW action delete conntrack",
       .tokens = {
                 (void *)&cmd_action_del_conntrack_p_string,
                 (void *)&cmd_action_del_conntrack_action_string,
                 (void *)&cmd_action_del_conntrack_del_string,
                 (void *)&cmd_action_del_conntrack_action_id,
                 (void *)&cmd_action_del_conntrack_conntrack_string,
                 NULL,
                 },
};

/*
 * p action add connexist
 */

/**
 * A structure defining the add Connection Exist action command.
 */
struct cmd_action_add_connexist_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t add_string;
       int32_t action_id;
       cmdline_fixed_string_t connexist_string;
       cmdline_fixed_string_t private_public_string;
};

/**
 * Parse Connection Exist Action Add Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_add_connexist_parsed(void *parsed_result, __attribute__ ((unused))
                            struct cmdline *cl, void *data)
{
       struct cmd_action_add_connexist_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       if (VFW_DEBUG)
              printf("public_private: %s\n", params->private_public_string);
       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_connexist;
       if (strcmp(params->private_public_string, "prvpub") == 0)
              key.private_public = lib_acl_private_public;
       else if (strcmp(params->private_public_string, "pubprv") == 0)
              key.private_public = lib_acl_public_private;
       else {
              printf("Command failed - Invalid string: %s\n",
                     params->private_public_string);
              return;
       }

       status = app_pipeline_action_add(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_add_connexist_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_connexist_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_add_connexist_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_connexist_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_add_connexist_add_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_connexist_result,
                      add_string, "add");

cmdline_parse_token_num_t cmd_action_add_connexist_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_add_connexist_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_add_connexist_connexist_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_connexist_result,
                      connexist_string, "connexist");

cmdline_parse_token_string_t cmd_action_add_connexist_private_public =
TOKEN_STRING_INITIALIZER(struct cmd_action_add_connexist_result,
                      private_public_string,
                      NULL);

cmdline_parse_inst_t cmd_action_add_connexist = {
       .f = cmd_action_add_connexist_parsed,
       .data = NULL,
       .help_str = "VFW action add connexist",
       .tokens = {
                 (void *)&cmd_action_add_connexist_p_string,
                 (void *)&cmd_action_add_connexist_action_string,
                 (void *)&cmd_action_add_connexist_add_string,
                 (void *)&cmd_action_add_connexist_action_id,
                 (void *)&cmd_action_add_connexist_connexist_string,
                 (void *)&cmd_action_add_connexist_private_public,
                 NULL,
                 },
};

/*
 * p action del connexist
 */

/**
 * A structure defining the delete Connection Exist action command.
 */
struct cmd_action_del_connexist_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t del_string;
       int32_t action_id;
       cmdline_fixed_string_t connexist_string;
};

/**
 * Parse Connection Exist Action Delete Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_action_del_connexist_parsed(void *parsed_result, __attribute__ ((unused))
                            struct cmdline *cl, void *data)
{
       struct cmd_action_del_connexist_result *params = parsed_result;
       struct app_params *app = data;
       struct pipeline_action_key key;
       int status;

       key.action_id = params->action_id;
       key.action_bitmap = lib_acl_action_connexist;

       status = app_pipeline_action_delete(app, &key);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_action_del_connexist_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_connexist_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_del_connexist_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_connexist_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_del_connexist_add_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_connexist_result,
                      del_string, "del");

cmdline_parse_token_num_t cmd_action_del_connexist_action_id =
TOKEN_NUM_INITIALIZER(struct cmd_action_del_connexist_result, action_id,
                    UINT32);

cmdline_parse_token_string_t cmd_action_del_connexist_connexist_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_del_connexist_result,
                      connexist_string, "connexist");

cmdline_parse_inst_t cmd_action_del_connexist = {
       .f = cmd_action_del_connexist_parsed,
       .data = NULL,
       .help_str = "VFW action del connexist",
       .tokens = {
                 (void *)&cmd_action_del_connexist_p_string,
                 (void *)&cmd_action_del_connexist_action_string,
                 (void *)&cmd_action_del_connexist_add_string,
                 (void *)&cmd_action_del_connexist_action_id,
                 (void *)&cmd_action_del_connexist_connexist_string,
                 NULL,
                 },
};

/*
 * p action ls
 */

/**
 * A structure defining the action ls command.
 */
struct cmd_action_ls_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t action_string;
       cmdline_fixed_string_t ls_string;
       uint32_t table_instance;
};

/**
 * Parse Action LS Command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void cmd_action_ls_parsed(void *parsed_result, __attribute__ ((unused))
              struct cmdline *cl, __attribute__ ((unused)) void *data)
{
       struct cmd_action_ls_result *params = parsed_result;
       uint32_t action_bitmap, i, j;
       uint8_t action_found = 0;
       struct action_counter_block action_counter_sum;

       if (params->table_instance == active_rule_table) {
              printf("Active Action Table:\n");
              printf("Action ID     Action\n");
              printf("=========     ======\n");

              for (i = 0; i < action_array_max; i++) {
                     action_bitmap = action_array_active[i].action_bitmap;
                     if (action_bitmap != 0) {
                            action_found = 1;
                            if (action_bitmap &
                                          lib_acl_action_packet_accept)
                                   printf("  %04u        Accept\n", i);
                            if (action_bitmap & lib_acl_action_packet_drop)
                                   printf("  %04u        Drop\n", i);
                            if (action_bitmap & lib_acl_action_nat)
                                   printf("  %04"PRIu32
                                          "        NAT       NAT Port: %"
                                          PRIu32"\n",
                                          i,
                                 action_array_active[i].nat_port);
                            if (action_bitmap & lib_acl_action_fwd)
                                   printf("  %04"PRIu32
                                          "        FWD       FWD Port: %"
                                          PRIu32"\n",
                                          i,
                                          action_array_active[i].
                                          fwd_port);
                            if (action_bitmap & lib_acl_action_count) {
                                   action_counter_sum.packetCount = 0;
                                   action_counter_sum.byteCount = 0;
                                   for (j = 0; j <= (uint32_t)
                                   rte_VFW_hi_counter_block_in_use;
                                   j++) {
                                          action_counter_sum.
                                              packetCount +=
                                              action_counter_table[j][i].
                                              packetCount;
                                          action_counter_sum.byteCount +=
                                              action_counter_table[j][i].
                                              byteCount;
                                   }
                                   printf("  %04"PRIu32
                                          "       Count    Packet Count:%"
                                          PRIu64 "   Byte Count: %" PRIu64
                                          "\n", i,
                                          action_counter_sum.packetCount,
                                          action_counter_sum.byteCount);
                            }
                            if (action_bitmap & lib_acl_action_conntrack)
                                   printf("  %04u        Conntrack\n", i);
                            if (action_bitmap & lib_acl_action_connexist) {
                                   printf("  %04u        Connexist", i);
                                   if (action_array_active[i].
                                       private_public ==
                                       lib_acl_private_public)
                                          printf(" prvpub\n");
                                   else
                                          printf(" pubprv\n");
                            }
                            if (action_bitmap & lib_acl_action_dscp)
                                   printf
                                       ("  %04"PRIu32
                                        "        DSCP     DSCP Priority: %"
                                        PRIu8"\n",
                                        i,
                                        action_array_active[i].
                                        dscp_priority);
                     }
              }

              if (!action_found)
                     printf("None\n");

       } else {
              action_found = 0;
              printf("Standby Action Table:\n");
              printf("Action ID     Action\n");
              printf("=========     ======\n");

              for (i = 0; i < action_array_max; i++) {
                     action_bitmap = action_array_standby[i].action_bitmap;
                     if (action_bitmap != 0) {
                            action_found = 1;
                            if (action_bitmap &
                                          lib_acl_action_packet_accept)
                                   printf("  %04u        Accept\n", i);
                            if (action_bitmap & lib_acl_action_packet_drop)
                                   printf("  %04u        Drop\n", i);
                            if (action_bitmap & lib_acl_action_nat)
                                   printf
                                          ("  %04"PRIu32
                                           "        NAT       NAT Port: %"
                                           PRIu32"\n", i,
                                           action_array_standby[i].
                                           nat_port);
                            if (action_bitmap & lib_acl_action_fwd)
                                   printf
                                          ("  %04"PRIu32
                                           "        FWD       FWD Port: %"
                                           PRIu32"\n", i,
                                           action_array_standby[i].
                                           fwd_port);
                            if (action_bitmap & lib_acl_action_count)
                                   printf("  %04u        Count\n", i);
                            if (action_bitmap & lib_acl_action_conntrack)
                                   printf("  %04u        Conntrack\n", i);
                            if (action_bitmap & lib_acl_action_connexist) {
                                   printf("  %04u        Connexist", i);
                                   if (action_array_standby[i].
                                       private_public ==
                                       lib_acl_private_public)
                                          printf(" prvpub\n");
                                   else
                                          printf(" pubprv\n");
                            }
                            if (action_bitmap & lib_acl_action_dscp)
                                   printf("  %04"PRIu32
                                    "       DSCP     DSCP Priority: %"
                                    PRIu8"\n", i,
                                    action_array_standby[i].
                                    dscp_priority);
                     }
              }

              if (!action_found)
                     printf("None\n");
       }
}

cmdline_parse_token_string_t cmd_action_ls_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_ls_result, p_string,
                      "p");

cmdline_parse_token_string_t cmd_action_ls_action_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_ls_result,
                      action_string, "action");

cmdline_parse_token_string_t cmd_action_ls_ls_string =
TOKEN_STRING_INITIALIZER(struct cmd_action_ls_result, ls_string,
                      "ls");

cmdline_parse_token_num_t cmd_action_ls_table_instance =
TOKEN_NUM_INITIALIZER(struct cmd_action_ls_result, table_instance,
                    UINT32);

cmdline_parse_inst_t cmd_action_ls = {
       .f = cmd_action_ls_parsed,
       .data = NULL,
       .help_str = "VFW action list",
       .tokens = {
                 (void *)&cmd_action_ls_p_string,
                 (void *)&cmd_action_ls_action_string,
                 (void *)&cmd_action_ls_ls_string,
                 (void *)&cmd_action_ls_table_instance,
                 NULL,
                 },
};

/*
 * p vfw onesectimer start/stop
 */

/**
 * A structure defining the VFW Dump Counter start/stop command.
 */
struct cmd_vfw_per_sec_ctr_dump_result {
       cmdline_fixed_string_t p_string;
       cmdline_fixed_string_t vfw_string;
       cmdline_fixed_string_t per_sec_ctr_dump_string;
       cmdline_fixed_string_t stop_string;
};

/**
 * Parse Dump Counter Start Command.
 * Start timer to display stats to console at regular intervals.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
       cmd_vfw_per_sec_ctr_dump_start_parsed(
                     __attribute__ ((unused)) void *parsed_result,
                     __attribute__ ((unused))
                     struct cmdline *cl, __attribute__ ((unused)) void *data)
{
       rte_vfw_reset_running_averages();
       /* execute timeout on current core */
       uint32_t core_id = rte_lcore_id();
       int success =
           rte_timer_reset(&rte_vfw_one_second_timer,
                         rte_vfw_ticks_in_one_second, PERIODICAL, core_id,
                         rte_dump_vfw_counters_from_master, NULL);
        if (success < 0)
              printf("CNXN_TRACKER: Failed to set connection timer.\n");
}

/**
 * Parse Dump Counter Stop Command.
 * Stop timer that was started to display stats.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
       cmd_vfw_per_sec_ctr_dump_stop_parsed(
                     __attribute__ ((unused)) void *parsed_result,
                     __attribute__ ((unused))
                     struct cmdline *cl, __attribute__ ((unused)) void *data)
{
       rte_timer_stop(&rte_vfw_one_second_timer);
}

cmdline_parse_token_string_t cmd_vfw_per_sec_ctr_dump_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_per_sec_ctr_dump_result,
                      p_string, "p");

cmdline_parse_token_string_t cmd_vfw_per_sec_ctr_dump_acl_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_per_sec_ctr_dump_result,
                      vfw_string, "vfw");

cmdline_parse_token_string_t cmd_vfw_per_sec_ctr_dump_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_per_sec_ctr_dump_result,
                      per_sec_ctr_dump_string, "counterdump");

cmdline_parse_token_string_t cmd_vfw_stop_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_per_sec_ctr_dump_result,
                      stop_string, "stop");

cmdline_parse_token_string_t cmd_vfw_start_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_per_sec_ctr_dump_result,
                      stop_string, "start");

cmdline_parse_inst_t cmd_vfw_per_sec_ctr_dump_stop = {
       .f = cmd_vfw_per_sec_ctr_dump_stop_parsed,
       .data = NULL,
       .help_str = "VFW counterdump stop",
       .tokens = {
                 (void *)&cmd_vfw_per_sec_ctr_dump_p_string,
                 (void *)&cmd_vfw_per_sec_ctr_dump_acl_string,
                 (void *)&cmd_vfw_per_sec_ctr_dump_string,
                 (void *)&cmd_vfw_stop_string,
                 NULL,
                 },
};

cmdline_parse_inst_t cmd_vfw_per_sec_ctr_dump_start = {
       .f = cmd_vfw_per_sec_ctr_dump_start_parsed,
       .data = NULL,
       .help_str = "VFW counterdump start",
       .tokens = {
                 (void *)&cmd_vfw_per_sec_ctr_dump_p_string,
                 (void *)&cmd_vfw_per_sec_ctr_dump_acl_string,
                 (void *)&cmd_vfw_per_sec_ctr_dump_string,
                 (void *)&cmd_vfw_start_string,
                 NULL,
                 },
};

/**
 * A structure defining the VFW firewall ON/OFF command.
 */
struct cmd_vfw_firewall_flag_result {
       cmdline_fixed_string_t p_string;
       uint32_t pipeline_id;
       cmdline_fixed_string_t vfw_string;
       cmdline_fixed_string_t firewall_flag_string;
       uint8_t firewall_flag;
};

/**
 * Parse VFW Firewall ON/OFF CLI command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_vfw_firewall_flag_parsed(void *parsed_result, __attribute__ ((unused))
              struct cmdline *cl, __attribute__ ((unused)) void *data)
{
       struct cmd_vfw_firewall_flag_result *params = parsed_result;

       if (params->firewall_flag == 0) {
              printf("firewall turned OFF\n");
              firewall_flag = 0;
       } else if (params->firewall_flag == 1) {
              printf("firewall turned ON\n");
              firewall_flag = 1;
       } else
              printf("Invalid firewall setting\n");
}

cmdline_parse_token_string_t cmd_vfw_firewall_flag_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_firewall_flag_result,
                      p_string, "p");

cmdline_parse_token_string_t cmd_vfw_firewall_flag_vfw_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_firewall_flag_result,
                      vfw_string, "vfw");

cmdline_parse_token_string_t cmd_vfw_firewall_flag_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_firewall_flag_result,
                      firewall_flag_string, "firewall");

cmdline_parse_token_num_t cmd_vfw_firewall_flag =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_firewall_flag_result, firewall_flag,
                    UINT8);

cmdline_parse_inst_t cmd_vfw_firewall = {
       .f = cmd_vfw_firewall_flag_parsed,
       .data = NULL,
       .help_str = "VFW firewall_flag",
       .tokens = {
                 (void *)&cmd_vfw_firewall_flag_p_string,
                 (void *)&cmd_vfw_firewall_flag_vfw_string,
                 (void *)&cmd_vfw_firewall_flag_string,
                 (void *)&cmd_vfw_firewall_flag,
                 NULL,
                 },
};


/**
 * A structure defining the TCPFW conntrack ON/OFF command.
 */
struct cmd_vfw_fw_conntrack_result {
       cmdline_fixed_string_t p_string;
       uint32_t pipeline_id;
       cmdline_fixed_string_t tcpfw_string;
       cmdline_fixed_string_t conntrack_string;
       uint8_t conntrack_flag;
};

/**
 * Parse VFW_TCPFW conntrack ON/OFF CLI command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void cmd_vfw_fw_conntrack_parsed(
              void *parsed_result,
              __attribute__((unused)) struct cmdline *cl,
              __rte_unused void *data)
{
       struct cmd_vfw_fw_conntrack_result *params = parsed_result;

       if (params->conntrack_flag == 0) {
              printf("firewall conntrack turned OFF\n");
              cnxn_tracking_is_active = 0;
       } else if (params->conntrack_flag == 1) {
              printf("firewall conntrack turned ON\n");
              cnxn_tracking_is_active = 1;
       } else
              printf("Invalid firewall conntrack setting\n");

}
cmdline_parse_token_string_t cmd_vfw_fw_conntrack_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_fw_conntrack_result,
              p_string, "p");

cmdline_parse_token_string_t cmd_vfw_fw_conntrack_fw_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_fw_conntrack_result,
              tcpfw_string, "vfw");

cmdline_parse_token_string_t cmd_vfw_fw_conntrack_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_fw_conntrack_result,
              conntrack_string, "conntrack");

cmdline_parse_token_num_t cmd_vfw_fw_conntrack_flag =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_fw_conntrack_result, conntrack_flag,
              UINT8);
cmdline_parse_inst_t cmd_vfw_fw_conntrack = {
       .f = cmd_vfw_fw_conntrack_parsed,
       .data = NULL,
       .help_str = "VFW FW conntrack",
       .tokens = {
              (void *) &cmd_vfw_fw_conntrack_p_string,
              (void *) &cmd_vfw_fw_conntrack_fw_string,
              (void *) &cmd_vfw_fw_conntrack_string,
              (void *) &cmd_vfw_fw_conntrack_flag,
              NULL,
       },
};

/**
 * A structure defining the VFW synproxy ON/OFFcommand.
 */
struct cmd_vfw_synproxy_flag_result {
       cmdline_fixed_string_t p_string;
       uint32_t pipeline_id;
       cmdline_fixed_string_t vfw_string;
       cmdline_fixed_string_t synproxy_flag_string;
       uint8_t synproxy_flag;
};

/**
 * Parse TCPFW synproxy ON/OFF CLI command.
 *
 * @param parsed_result
 *  A pointer to CLI command parsed result.
 * @param cl
 *  A pointer to command line context.
 * @param data
 *  A pointer to command specific data
 *
 */
static void
cmd_vfw_synproxy_flag_parsed(void *parsed_result, __attribute__ ((unused))
                            struct cmdline *cl, void *data)
{
       struct cmd_vfw_synproxy_flag_result *params = parsed_result;
       struct app_params *app = data;
       int status;

       status = app_pipeline_vfw_synproxy_flag(app,
                                             params->pipeline_id,
                                             params->synproxy_flag);

       if (status != 0) {
              printf("Command failed\n");
              return;
       }
}

cmdline_parse_token_string_t cmd_vfw_synproxy_flag_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_synproxy_flag_result,
                      p_string, "p");

cmdline_parse_token_num_t cmd_vfw_synproxy_flag_pipeline_id =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_synproxy_flag_result,
                    pipeline_id, UINT32);

cmdline_parse_token_string_t cmd_vfw_synproxy_flag_vfw_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_synproxy_flag_result,
                      vfw_string, "vfw");

cmdline_parse_token_string_t cmd_vfw_synproxy_flag_string =
TOKEN_STRING_INITIALIZER(struct cmd_vfw_synproxy_flag_result,
                      synproxy_flag_string, "synproxy");

cmdline_parse_token_num_t cmd_vfw_synproxy_flag =
TOKEN_NUM_INITIALIZER(struct cmd_vfw_synproxy_flag_result, synproxy_flag,
              UINT8);

cmdline_parse_inst_t cmd_vfw_synproxy = {
       .f = cmd_vfw_synproxy_flag_parsed,
       .data = NULL,
       .help_str = "VFW synproxy_flag",
       .tokens = {
              (void *)&cmd_vfw_synproxy_flag_p_string,
              (void *)&cmd_vfw_synproxy_flag_pipeline_id,
              (void *)&cmd_vfw_synproxy_flag_vfw_string,
              (void *)&cmd_vfw_synproxy_flag_string,
              (void *)&cmd_vfw_synproxy_flag,
              NULL,
       },
};

static cmdline_parse_ctx_t pipeline_cmds[] = {
#ifdef ACL_ENABLE
       (cmdline_parse_inst_t *) &cmd_vfw_add_ip,
       (cmdline_parse_inst_t *) &cmd_vfw_del_ip,
       (cmdline_parse_inst_t *) &cmd_vfw_dbg,
       (cmdline_parse_inst_t *) &cmd_vfw_clearrules,
       (cmdline_parse_inst_t *) &cmd_loadrules,
       (cmdline_parse_inst_t *) &cmd_vfw_ls,
       (cmdline_parse_inst_t *) &cmd_action_add_accept,
       (cmdline_parse_inst_t *) &cmd_action_del_accept,
       (cmdline_parse_inst_t *) &cmd_action_add_drop,
       (cmdline_parse_inst_t *) &cmd_action_del_drop,
       (cmdline_parse_inst_t *) &cmd_action_add_fwd,
       (cmdline_parse_inst_t *) &cmd_action_del_fwd,
       (cmdline_parse_inst_t *) &cmd_action_add_nat,
       (cmdline_parse_inst_t *) &cmd_action_del_nat,
       (cmdline_parse_inst_t *) &cmd_action_add_count,
       (cmdline_parse_inst_t *) &cmd_action_del_count,
       (cmdline_parse_inst_t *) &cmd_action_add_dscp,
       (cmdline_parse_inst_t *) &cmd_action_del_dscp,
       (cmdline_parse_inst_t *) &cmd_action_add_conntrack,
       (cmdline_parse_inst_t *) &cmd_action_del_conntrack,
       (cmdline_parse_inst_t *) &cmd_action_add_connexist,
       (cmdline_parse_inst_t *) &cmd_action_del_connexist,
       (cmdline_parse_inst_t *) &cmd_action_ls,
       (cmdline_parse_inst_t *) &cmd_vfw_applyruleset,
#endif
       (cmdline_parse_inst_t *) &cmd_vfw_stats,
       (cmdline_parse_inst_t *) &cmd_vfw_clearstats,
       (cmdline_parse_inst_t *) &cmd_vfw_per_sec_ctr_dump_stop,
       (cmdline_parse_inst_t *) &cmd_vfw_per_sec_ctr_dump_start,
       (cmdline_parse_inst_t *) &cmd_vfw_synproxy,
       (cmdline_parse_inst_t *) &cmd_vfw_firewall,
#ifndef ACL_ENABLE
       (cmdline_parse_inst_t *) &cmd_vfw_fw_conntrack,
#endif
       NULL,
};

static struct pipeline_fe_ops pipeline_vfw_fe_ops = {
       .f_init = app_pipeline_vfw_init,
       .f_free = app_pipeline_vfw_free,
       .cmds = pipeline_cmds,
};

struct pipeline_type pipeline_vfw = {
       .name = "VFW",
       .be_ops = &pipeline_vfw_be_ops,
       .fe_ops = &pipeline_vfw_fe_ops,
};