cnat: Add calico/k8s src policy
[vpp.git] / src / plugins / cnat / cnat.api
1 /* Hey Emacs use -*- mode: C -*- */
2 /*
3  * Copyright (c) 2016 Cisco and/or its affiliates.
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 /** \file
18     This file defines the vpp control-plane API messages
19     used to control the ABF plugin
20 */
21
22 option version = "0.2.0";
23 import "vnet/ip/ip_types.api";
24 import "vnet/fib/fib_types.api";
25 import "vnet/interface_types.api";
26
27 enum cnat_translation_flags:u8
28 {
29   CNAT_TRANSLATION_ALLOC_PORT = 1,
30 };
31
32 enum cnat_endpoint_tuple_flags:u8
33 {
34   /* Dont translate said endpoint tuple but
35    * still forward */
36   CNAT_EPT_NO_NAT = 1,
37 };
38
39
40 enum cnat_lb_type:u8
41 {
42   CNAT_LB_TYPE_DEFAULT = 0,
43   CNAT_LB_TYPE_MAGLEV = 1,
44 };
45
46 /* An enpoint is either
47  * An IP & a port
48  * An interface, an address familiy and a port */
49 typedef cnat_endpoint
50 {
51   vl_api_address_t addr;
52   vl_api_interface_index_t sw_if_index;
53   vl_api_address_family_t if_af;
54   u16 port;
55 };
56
57 typedef cnat_endpoint_tuple
58 {
59   vl_api_cnat_endpoint_t dst_ep;
60   vl_api_cnat_endpoint_t src_ep;
61   u8 flags;
62 };
63
64 typedef cnat_translation
65 {
66   vl_api_cnat_endpoint_t vip;
67   u32 id;
68   vl_api_ip_proto_t ip_proto;
69   u8 is_real_ip;
70   u8 flags;
71   vl_api_cnat_lb_type_t lb_type;
72   u32 n_paths;
73   vl_api_cnat_endpoint_tuple_t paths[n_paths];
74 };
75
76 define cnat_translation_update
77 {
78   u32 client_index;
79   u32 context;
80   vl_api_cnat_translation_t translation;
81 };
82
83 define cnat_translation_update_reply
84 {
85   u32 context;
86   i32 retval;
87   u32 id;
88 };
89
90 autoreply define cnat_translation_del
91 {
92   u32 client_index;
93   u32 context;
94   u32 id;
95 };
96
97 define cnat_translation_details
98 {
99   u32 context;
100   vl_api_cnat_translation_t translation;
101 };
102
103 define cnat_translation_dump
104 {
105   u32 client_index;
106   u32 context;
107 };
108
109 autoreply define cnat_session_purge
110 {
111   u32 client_index;
112   u32 context;
113 };
114
115 typedef cnat_session
116 {
117   vl_api_cnat_endpoint_t src;
118   vl_api_cnat_endpoint_t dst;
119   vl_api_cnat_endpoint_t new;
120   vl_api_ip_proto_t ip_proto;
121   u8 location;
122   f64 timestamp;
123 };
124
125 define cnat_session_details
126 {
127   u32 context;
128   vl_api_cnat_session_t session;
129 };
130
131 define cnat_session_dump
132 {
133   u32 client_index;
134   u32 context;
135 };
136
137 autoreply define cnat_set_snat_addresses
138 {
139   u32 client_index;
140   u32 context;
141   vl_api_ip4_address_t snat_ip4;
142   vl_api_ip6_address_t snat_ip6;
143   vl_api_interface_index_t sw_if_index;
144 };
145
146 define cnat_get_snat_addresses
147 {
148   u32 client_index;
149   u32 context;
150 };
151
152 define cnat_get_snat_addresses_reply
153 {
154   u32 context;
155   i32 retval;
156   u32 id;
157   vl_api_ip4_address_t snat_ip4;
158   vl_api_ip6_address_t snat_ip6;
159   vl_api_interface_index_t sw_if_index;
160 };
161
162 autoreply define cnat_snat_policy_add_del_exclude_pfx
163 {
164   u32 client_index;
165   u32 context;
166   u8 is_add;
167   vl_api_prefix_t prefix;
168 };
169
170 enum cnat_snat_policy_table:u8
171 {
172   CNAT_POLICY_INCLUDE_V4 = 0,
173   CNAT_POLICY_INCLUDE_V6 = 1,
174   CNAT_POLICY_POD = 2,
175 };
176
177 autoreply define cnat_snat_policy_add_del_if
178 {
179   u32 client_index;
180   u32 context;
181   vl_api_interface_index_t sw_if_index;
182   u8 is_add;
183   vl_api_cnat_snat_policy_table_t table;
184 };
185
186 /* A snat policy controls what traffic is srcNATed */
187 enum cnat_snat_policies:u8
188 {
189   /* No filter applied, srcNAT everything */
190   CNAT_POLICY_NONE = 0,
191   /* Filter by interface list : snat_policy_add_del_if
192    * and prefix list : snat_policy_add_del_if */
193   CNAT_POLICY_IF_PFX = 1,
194   /* Kubernetes specific policy */
195   CNAT_POLICY_K8S = 2,
196 };
197
198 autoreply define cnat_set_snat_policy
199 {
200   u32 client_index;
201   u32 context;
202   vl_api_cnat_snat_policies_t policy;
203 };
204
205 /*
206  * fd.io coding-style-patch-verification: ON
207  *
208  * Local Variables:
209  * eval: (c-set-style "gnu")
210  * End:
211  */