Merge "update userguide alignment"
[samplevnf.git] / VNFs / vFW / pipeline / pipeline_vfw.h
1 /*
2 // Copyright (c) 2017 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #ifndef __INCLUDE_PIPELINE_VFW_H__
18 #define __INCLUDE_PIPELINE_VFW_H__
19
20 /**
21  * @file
22  * Pipeline VFW FE.
23  *
24  * Pipeline VFW Front End (FE).
25  * Runs on the Master pipeline, responsible for CLI commands.
26  *
27  */
28
29 #include "pipeline.h"
30 #include "app.h"
31 #include "pipeline_vfw_be.h"
32
33 #include <civetweb.h>
34 #include <json/json.h>
35
36 /* VFW IPV4 and IPV6 enable flags for debugging (Default both on) */
37 extern int vfw_ipv4_enabled;
38 extern int vfw_ipv6_enabled;
39
40 /* Number of VFW Rules, default 4 * 1024 */
41 extern uint32_t vfw_n_rules;
42 /* VFW Rule Table TRIE - 2 (Active, Standby Global table per ipv4, ipv6 */
43 extern void *vfw_rule_table_ipv4_active;
44 extern void *vfw_rule_table_ipv4_standby;
45 extern void *vfw_rule_table_ipv6_active;
46 extern void *vfw_rule_table_ipv6_standby;
47
48 #define active_rule_table       0
49 #define standby_rule_table       1
50 #define vfw_add_command              0
51 #define vfw_delete_command       1
52 #define IPV6_32BIT_LENGTH       4
53
54 /**
55  * Add VFW rule to the VFW rule table.
56  * Rules are added standby table.
57  * Applyruleset command will activate the change.
58  * Both IPv4 and IPv6 rules can be added.
59  *
60  * @param app
61  *  A pointer to the VFW pipeline parameters.
62  * @param key
63  *  A pointer to the VFW rule to add.
64  * @param priority
65  *  Priority of the VFW rule.
66  * @param port_id
67  *  Port ID of the VFW rule.
68  * @param action_id
69  *  Action ID of the VFW rule. Defined in Action Table.
70  *
71  * @return
72  *  0 on success, negative on error.
73  */
74 int
75 app_pipeline_vfw_add_rule(struct app_params *app,
76                           struct pipeline_vfw_key *key,
77                           uint32_t priority,
78                           uint32_t port_id, uint32_t action_id);
79
80 /**
81  * Delete VFW rule from the VFW rule table.
82  * Rules deleted from standby tables.
83  * Applyruleset command will activate the change.
84  * Both IPv4 and IPv6 rules can be deleted.
85  *
86  * @param app
87  *  A pointer to the VFW pipeline parameters.
88  * @param key
89  *  A pointer to the VFW rule to delete.
90  *
91  * @return
92  *  0 on success, negative on error.
93  */
94 int
95 app_pipeline_vfw_delete_rule(struct app_params *app,
96                             struct pipeline_vfw_key *key);
97
98 /**
99  * Clear all VFW rules from the VFW rule table.
100  * Rules cleared from standby tables.
101  * Applyruleset command will activate the change.
102  * Both IPv4 and IPv6 rules will be cleared.
103  *
104  * @param app
105  *  A pointer to the VFW pipeline parameters.
106  *
107  * @return
108  *  0 on success, negative on error.
109  */
110 int app_pipeline_vfw_clearrules(struct app_params *app);
111
112 /**
113  * Add Action to the Action table.
114  * Actions are added standby table.
115  * Applyruleset command will activate the change.
116  *
117  * @param app
118  *  A pointer to the VFW pipeline parameters.
119  * @param key
120  *  A pointer to the Action to add.
121  *
122  * @return
123  *  0 on success, negative on error.
124  */
125 int
126 app_pipeline_action_add(struct app_params *app,
127                      struct pipeline_action_key *key);
128
129 /**
130  * Delete Action from the Action table.
131  * Actions are deleted from the standby table.
132  * Applyruleset command will activate the change.
133  *
134  * @param app
135  *  A pointer to the VFW pipeline parameters.
136  * @param key
137  *  A pointer to the Action to delete.
138  *
139  * @return
140  *  0 on success, negative on error.
141  */
142 int
143 app_pipeline_action_delete(struct app_params *app,
144                         struct pipeline_action_key *key);
145
146 extern struct pipeline_type pipeline_vfw;
147
148 #ifdef REST_API_SUPPORT
149 /* REST Api's defined here */
150 int vfw_rules_handler(struct mg_connection *conn, void *cbdata);
151 int vfw_load_rules_handler(struct mg_connection *conn, void *cbdata);
152 int vfw_clearrules_handler(struct mg_connection *conn, void *cbdata);
153 int vfw_stats_handler(struct mg_connection *conn, void *cbdata);
154 int vfw_clearstats_handler(__rte_unused struct mg_connection *conn,
155          __rte_unused void *cbdata);
156 int vfw_cmd_ver_handler(struct mg_connection *conn, __rte_unused void *cbdata);
157 void rest_api_vfw_init(struct mg_context *ctx, struct app_params *app);
158 #endif
159
160 #endif