FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
cnat_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <stddef.h>
17 
18 #include <vnet/vnet.h>
19 #include <vnet/plugin/plugin.h>
20 #include <cnat/cnat_translation.h>
21 #include <cnat/cnat_session.h>
22 #include <cnat/cnat_client.h>
23 #include <cnat/cnat_snat_policy.h>
24 
25 #include <vnet/ip/ip_types_api.h>
26 
27 #include <vpp/app/version.h>
28 
29 #include <vlibapi/api.h>
30 #include <vlibmemory/api.h>
31 
32 /* define message IDs */
33 #include <vnet/format_fns.h>
34 #include <cnat/cnat.api_enum.h>
35 #include <cnat/cnat.api_types.h>
36 
37 /**
38  * Base message ID fot the plugin
39  */
41 
42 #define REPLY_MSG_ID_BASE cnat_base_msg_id
43 
45 
46 static int
47 cnat_endpoint_decode (const vl_api_cnat_endpoint_t * in,
48  cnat_endpoint_t * out)
49 {
50  int rv = 0;
51  out->ce_port = clib_net_to_host_u16 (in->port);
52  out->ce_sw_if_index = clib_net_to_host_u32 (in->sw_if_index);
53  out->ce_flags = 0;
54  if (out->ce_sw_if_index == INDEX_INVALID)
55  ip_address_decode2 (&in->addr, &out->ce_ip);
56  else
57  rv = ip_address_family_decode (in->if_af, &out->ce_ip.version);
58  return rv;
59 }
60 
61 static int
62 cnat_endpoint_tuple_decode (const vl_api_cnat_endpoint_tuple_t * in,
64 {
65  int rv = 0;
66  rv = cnat_endpoint_decode (&in->src_ep, &out->src_ep);
67  if (rv)
68  return rv;
69  rv = cnat_endpoint_decode (&in->dst_ep, &out->dst_ep);
70  out->ep_flags = in->flags;
71  return rv;
72 }
73 
74 static void
76  vl_api_cnat_endpoint_t * out)
77 {
78  out->port = clib_net_to_host_u16 (in->ce_port);
79  out->sw_if_index = clib_net_to_host_u32 (in->ce_sw_if_index);
80  out->if_af = ip_address_family_encode (in->ce_ip.version);
82  ip_address_encode2 (&in->ce_ip, &out->addr);
83  else
84  clib_memset ((void *) &in->ce_ip, 0, sizeof (in->ce_ip));
85 }
86 
87 static void
89  * mp)
90 {
92  cnat_endpoint_t vip;
95  u32 id = ~0;
96  u8 flags;
97  int rv = 0;
98  u32 pi, n_paths;
100 
101  rv = ip_proto_decode (mp->translation.ip_proto, &ip_proto);
102 
103  if (rv)
104  goto done;
105 
106  n_paths = clib_net_to_host_u32 (mp->translation.n_paths);
107  vec_validate (paths, n_paths - 1);
108 
109  for (pi = 0; pi < n_paths; pi++)
110  {
111  path = &paths[pi];
112  rv = cnat_endpoint_tuple_decode (&mp->translation.paths[pi], path);
113  if (rv)
114  goto done;
115  }
116 
117  rv = cnat_endpoint_decode (&mp->translation.vip, &vip);
118  if (rv)
119  goto done;
120 
121  flags = mp->translation.flags;
122  if (!mp->translation.is_real_ip)
124 
125  lb_type = (cnat_lb_type_t) mp->translation.lb_type;
127 
128  vec_free (paths);
129 
130 done:
131  REPLY_MACRO2 (VL_API_CNAT_TRANSLATION_UPDATE_REPLY,
132  ({
133  rmp->id = htonl (id);
134  }));
135 }
136 
137 static void
139 {
140  vl_api_cnat_translation_del_reply_t *rmp;
141  int rv;
142 
143  rv = cnat_translation_delete (ntohl (mp->id));
144 
145  REPLY_MACRO (VL_API_CNAT_TRANSLATION_DEL_REPLY);
146 }
147 
148 typedef struct cnat_dump_walk_ctx_t_
149 {
153 
154 static walk_rc_t
156 {
159  cnat_ep_trk_t *trk;
160  vl_api_cnat_endpoint_tuple_t *path;
161  size_t msg_size;
162  cnat_translation_t *ct;
163  u32 n_paths;
164 
165  ctx = args;
166  ct = cnat_translation_get (cti);
167  n_paths = vec_len (ct->ct_paths);
168  msg_size = sizeof (*mp) + sizeof (mp->translation.paths[0]) * n_paths;
169 
170  mp = vl_msg_api_alloc_zero (msg_size);
171  mp->_vl_msg_id = ntohs (VL_API_CNAT_TRANSLATION_DETAILS + cnat_base_msg_id);
172 
173  /* fill in the message */
174  mp->context = ctx->context;
175  mp->translation.n_paths = clib_host_to_net_u32 (n_paths);
176  mp->translation.id = clib_host_to_net_u32 (cti);
177  cnat_endpoint_encode (&ct->ct_vip, &mp->translation.vip);
178  mp->translation.ip_proto = ip_proto_encode (ct->ct_proto);
179  mp->translation.lb_type = (vl_api_cnat_lb_type_t) ct->lb_type;
180 
181  path = mp->translation.paths;
182  vec_foreach (trk, ct->ct_paths)
183  {
184  cnat_endpoint_encode (&trk->ct_ep[VLIB_TX], &path->dst_ep);
185  cnat_endpoint_encode (&trk->ct_ep[VLIB_RX], &path->src_ep);
186  path->flags = trk->ct_flags;
187  path++;
188  }
189 
190  vl_api_send_msg (ctx->rp, (u8 *) mp);
191 
192  return (WALK_CONTINUE);
193 }
194 
195 static void
197 {
199 
201  if (rp == 0)
202  return;
203 
205  .rp = rp,
206  .context = mp->context,
207  };
208 
210 }
211 
212 static void
213 ip_address2_from_46 (const ip46_address_t * nh,
215 {
216  ip_addr_46 (ip) = *nh;
217  ip_addr_version (ip) = af;
218 }
219 
220 static walk_rc_t
221 cnat_session_send_details (const cnat_session_t * session, void *args)
222 {
225  cnat_endpoint_t ep;
226 
227  ctx = args;
228 
229  mp = vl_msg_api_alloc_zero (sizeof (*mp));
230  mp->_vl_msg_id = ntohs (VL_API_CNAT_SESSION_DETAILS + cnat_base_msg_id);
231 
232  /* fill in the message */
233  mp->context = ctx->context;
234 
237  ip_address2_from_46 (&session->value.cs_ip[VLIB_TX], session->key.cs_af,
238  &ep.ce_ip);
239  ep.ce_port = clib_host_to_net_u16 (session->value.cs_port[VLIB_TX]);
240  cnat_endpoint_encode (&ep, &mp->session.new);
241 
242  ip_address2_from_46 (&session->key.cs_ip[VLIB_RX], session->key.cs_af,
243  &ep.ce_ip);
244  ep.ce_port = clib_host_to_net_u16 (session->key.cs_port[VLIB_RX]);
245  cnat_endpoint_encode (&ep, &mp->session.src);
246 
247  ip_address2_from_46 (&session->key.cs_ip[VLIB_TX], session->key.cs_af,
248  &ep.ce_ip);
249  ep.ce_port = clib_host_to_net_u16 (session->key.cs_port[VLIB_TX]);
250  cnat_endpoint_encode (&ep, &mp->session.dst);
251 
252  mp->session.ip_proto = ip_proto_encode (session->key.cs_proto);
253  mp->session.location = session->key.cs_loc;
254 
255  vl_api_send_msg (ctx->rp, (u8 *) mp);
256 
257  return (WALK_CONTINUE);
258 }
259 
260 static void
262 {
264 
266  if (rp == 0)
267  return;
268 
270  .rp = rp,
271  .context = mp->context,
272  };
273 
275 }
276 
277 static void
279 {
280  vl_api_cnat_session_purge_reply_t *rmp;
281  int rv;
282 
284  rv = cnat_session_purge ();
286 
287  REPLY_MACRO (VL_API_CNAT_SESSION_PURGE_REPLY);
288 }
289 
290 static void
292  * mp)
293 {
296  int rv = 0;
297 
298  REPLY_MACRO2 (
299  VL_API_CNAT_GET_SNAT_ADDRESSES_REPLY, ({
302  rmp->sw_if_index = clib_host_to_net_u32 (cpm->snat_ip6.ce_sw_if_index);
303  }));
304 }
305 
306 static void
308  * mp)
309 {
310  vl_api_cnat_set_snat_addresses_reply_t *rmp;
311  u32 sw_if_index = clib_net_to_host_u32 (mp->sw_if_index);
313  ip6_address_t ip6;
314  int rv = 0;
315 
318 
320 
321  REPLY_MACRO (VL_API_CNAT_SET_SNAT_ADDRESSES_REPLY);
322 }
323 
324 static void
326 {
327  vl_api_cnat_set_snat_policy_reply_t *rmp;
328  int rv = 0;
330 
332 
333  REPLY_MACRO (VL_API_CNAT_SET_SNAT_POLICY_REPLY);
334 }
335 
336 static void
339 {
340  vl_api_cnat_snat_policy_add_del_exclude_pfx_reply_t *rmp;
341  ip_prefix_t pfx;
342  int rv;
343 
344  ip_prefix_decode2 (&mp->prefix, &pfx);
345  if (mp->is_add)
346  rv = cnat_snat_policy_add_pfx (&pfx);
347  else
348  rv = cnat_snat_policy_del_pfx (&pfx);
349 
350  REPLY_MACRO (VL_API_CNAT_SNAT_POLICY_ADD_DEL_EXCLUDE_PFX_REPLY);
351 }
352 
353 static void
356 {
357  vl_api_cnat_snat_policy_add_del_if_reply_t *rmp;
358  u32 sw_if_index = ntohl (mp->sw_if_index);
359  int rv = 0;
360 
362 
365 
367 
369 
370  REPLY_MACRO (VL_API_CNAT_SNAT_POLICY_ADD_DEL_IF_REPLY);
371 }
372 
373 #include <cnat/cnat.api.c>
374 
375 static clib_error_t *
377 {
378  /* Ask for a correctly-sized block of API message decode slots */
380 
381  return 0;
382 }
383 
385 
387  .version = VPP_BUILD_VER,
388  .description = "CNat Translate",
389 };
390 
391 /*
392  * fd.io coding-style-patch-verification: ON
393  *
394  * Local Variables:
395  * eval: (c-set-style "gnu")
396  * End:
397  */
cnat_base_msg_id
static u32 cnat_base_msg_id
Base message ID fot the plugin.
Definition: cnat_api.c:40
ip_address
Definition: ip_types.h:79
cnat_dump_walk_ctx_t_
Definition: cnat_api.c:148
cnat_snat_policy_add_pfx
int cnat_snat_policy_add_pfx(ip_prefix_t *pfx)
Definition: cnat_snat_policy.c:148
vl_api_cnat_get_snat_addresses_reply_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: cnat.api:159
ip_addr_46
#define ip_addr_46(_a)
Definition: ip_types.h:90
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition: api_helper_macros.h:281
cnat_translation.h
vl_api_client_index_to_registration
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
CNAT_EP_FLAG_RESOLVED
@ CNAT_EP_FLAG_RESOLVED
Definition: cnat_types.h:70
api.h
vl_api_cnat_snat_policy_add_del_exclude_pfx_t_handler
static void vl_api_cnat_snat_policy_add_del_exclude_pfx_t_handler(vl_api_cnat_snat_policy_add_del_exclude_pfx_t *mp)
Definition: cnat_api.c:337
cnat_translation_delete
int cnat_translation_delete(u32 id)
Delete a translation.
Definition: cnat_translation.c:342
cnat_session_t_::cs_ip
ip46_address_t cs_ip[VLIB_N_DIR]
IP 4/6 address in the rx/tx direction.
Definition: cnat_session.h:47
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
WALK_CONTINUE
@ WALK_CONTINUE
Definition: interface_funcs.h:174
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
ip4_address_decode
void ip4_address_decode(const vl_api_ip4_address_t in, ip4_address_t *out)
Definition: ip_types_api.c:141
cnat_translation_t_::ct_proto
ip_protocol_t ct_proto
The ip protocol for the translation.
Definition: cnat_translation.h:147
cnat_ep_trk_t_::ct_ep
cnat_endpoint_t ct_ep[VLIB_N_DIR]
The EP being tracked.
Definition: cnat_translation.h:37
ip_proto
ip_proto
Definition: ip_types.api:75
ip4
vl_api_ip4_address_t ip4
Definition: one.api:376
ip_prefix
Definition: ip_types.h:116
cnat_client_throttle_pool_process
void cnat_client_throttle_pool_process()
Definition: cnat_client.c:69
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
vl_api_cnat_translation_dump_t::client_index
u32 client_index
Definition: cnat.api:105
CNAT_FLAG_EXCLUSIVE
@ CNAT_FLAG_EXCLUSIVE
Definition: cnat_client.h:124
policy
vl_api_ipsec_spd_action_t policy
Definition: ipsec.api:99
vl_api_cnat_set_snat_addresses_t::snat_ip4
vl_api_ip4_address_t snat_ip4
Definition: cnat.api:141
cnat_session.h
path
vl_api_fib_path_t path
Definition: mfib_types.api:44
cnat_dump_walk_ctx_t_::context
u32 context
Definition: cnat_api.c:151
cnat_endpoint_t_::ce_sw_if_index
u32 ce_sw_if_index
Definition: cnat_types.h:76
vl_api_cnat_snat_policy_add_del_if_t_handler
static void vl_api_cnat_snat_policy_add_del_if_t_handler(vl_api_cnat_snat_policy_add_del_if_t *mp)
Definition: cnat_api.c:354
vl_api_cnat_translation_del_t_handler
static void vl_api_cnat_translation_del_t_handler(vl_api_cnat_translation_del_t *mp)
Definition: cnat_api.c:138
ip6_address_decode
void ip6_address_decode(const vl_api_ip6_address_t in, ip6_address_t *out)
Definition: ip_types_api.c:129
vl_api_cnat_set_snat_addresses_t
Definition: cnat.api:137
vl_api_cnat_snat_policy_add_del_if_t::table
vl_api_cnat_snat_policy_table_t table
Definition: cnat.api:183
cnat_translation_purge
int cnat_translation_purge(void)
Purge all the trahslations.
Definition: cnat_translation.c:557
cnat_endpoint_tuple_decode
static int cnat_endpoint_tuple_decode(const vl_api_cnat_endpoint_tuple_t *in, cnat_endpoint_tuple_t *out)
Definition: cnat_api.c:62
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
api.h
vl_api_cnat_translation_update_t_handler
static void vl_api_cnat_translation_update_t_handler(vl_api_cnat_translation_update_t *mp)
Definition: cnat_api.c:88
vl_api_cnat_session_details_t::session
vl_api_cnat_session_t session
Definition: cnat.api:128
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
cnat_translation_send_details
static walk_rc_t cnat_translation_send_details(u32 cti, void *args)
Definition: cnat_api.c:155
ip_proto_encode
vl_api_ip_proto_t ip_proto_encode(ip_protocol_t ipp)
Definition: ip_types_api.c:69
cnat_session_purge
int cnat_session_purge(void)
Purge all the sessions.
Definition: cnat_session.c:159
vl_api_cnat_session_purge_t_handler
static void vl_api_cnat_session_purge_t_handler(vl_api_cnat_session_purge_t *mp)
Definition: cnat_api.c:278
vl_api_cnat_translation_del_t
Definition: cnat.api:90
cnat_session_t_
A session represents the memory of a translation.
Definition: cnat_session.h:37
vl_msg_api_alloc_zero
void * vl_msg_api_alloc_zero(int nbytes)
Definition: memory_shared.c:214
cnat_session_t_::key
struct cnat_session_t_::@645 key
this key sits in the same memory location a 'key' in the bihash kvp
cnat_session_send_details
static walk_rc_t cnat_session_send_details(const cnat_session_t *session, void *args)
Definition: cnat_api.c:221
vl_api_cnat_snat_policy_add_del_exclude_pfx_t
Definition: cnat.api:162
cnat_session_t_::cs_af
u8 cs_af
The address family describing the IP addresses.
Definition: cnat_session.h:62
cnat_endpoint_t_
Definition: cnat_types.h:73
cnat_snat_interface_map_type_t
enum cnat_snat_interface_map_type_t_ cnat_snat_interface_map_type_t
vl_api_cnat_session_dump_t::client_index
u32 client_index
Definition: cnat.api:133
cnat_snat_policy_main_t_::snat_ip4
cnat_endpoint_t snat_ip4
Definition: cnat_snat_policy.h:70
vl_api_cnat_snat_policy_add_del_exclude_pfx_t::prefix
vl_api_prefix_t prefix
Definition: cnat.api:167
vl_api_cnat_session_dump_t::context
u32 context
Definition: cnat.api:134
cnat_endpoint_tuple_t_
Definition: cnat_types.h:81
cnat_api_init
static clib_error_t * cnat_api_init(vlib_main_t *vm)
Definition: cnat_api.c:376
ip_address_encode2
void ip_address_encode2(const ip_address_t *in, vl_api_address_t *out)
Definition: ip_types_api.c:228
cnat_snat_policy_add_del_if
int cnat_snat_policy_add_del_if(u32 sw_if_index, u8 is_add, cnat_snat_interface_map_type_t table)
Definition: cnat_snat_policy.c:89
cnat_translation_update
u32 cnat_translation_update(cnat_endpoint_t *vip, ip_protocol_t proto, cnat_endpoint_tuple_t *paths, u8 flags, cnat_lb_type_t lb_type)
create or update a translation
Definition: cnat_translation.c:366
VLIB_PLUGIN_REGISTER
VLIB_PLUGIN_REGISTER()
ip_addr_version
#define ip_addr_version(_a)
Definition: ip_types.h:93
cnat_set_snat
void cnat_set_snat(ip4_address_t *ip4, ip6_address_t *ip6, u32 sw_if_index)
Definition: cnat_snat_policy.c:331
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
cnat_translation_t_::ct_vip
cnat_endpoint_t ct_vip
The Virtual end point.
Definition: cnat_translation.h:132
cnat_translation_t_::ct_paths
cnat_ep_trk_t * ct_paths
The vector of tracked back-ends.
Definition: cnat_translation.h:137
ip_address_family_decode
int ip_address_family_decode(vl_api_address_family_t af, ip_address_family_t *out)
Conversion functions to/from (decode/encode) API types to VPP internal types.
Definition: ip_types_api.c:20
ip_address2_from_46
static void ip_address2_from_46(const ip46_address_t *nh, ip_address_family_t af, ip_address_t *ip)
Definition: cnat_api.c:213
cnat_translation_t_::lb_type
cnat_lb_type_t lb_type
Type of load balancing.
Definition: cnat_translation.h:168
ip6_address_encode
void ip6_address_encode(const ip6_address_t *in, vl_api_ip6_address_t out)
Definition: ip_types_api.c:123
ip_address::version
ip_address_family_t version
Definition: ip_types.h:82
vl_api_cnat_snat_policy_add_del_if_t::is_add
u8 is_add
Definition: cnat.api:182
cnat_ep_trk_t_::ct_flags
u8 ct_flags
Allows to disable if not resolved yet.
Definition: cnat_translation.h:57
ip_addr_v6
#define ip_addr_v6(_a)
Definition: ip_types.h:92
lb_type
vl_api_cnat_lb_type_t lb_type
Definition: cnat.api:71
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: sr_mpls_api.c:174
vl_api_cnat_set_snat_policy_t::policy
vl_api_cnat_snat_policies_t policy
Definition: cnat.api:202
vl_api_cnat_snat_policy_add_del_exclude_pfx_t::is_add
u8 is_add
Definition: cnat.api:166
vl_api_cnat_set_snat_addresses_t_handler
static void vl_api_cnat_set_snat_addresses_t_handler(vl_api_cnat_set_snat_addresses_t *mp)
Definition: cnat_api.c:307
cnat_dump_walk_ctx_t
struct cnat_dump_walk_ctx_t_ cnat_dump_walk_ctx_t
ip_addr_v4
#define ip_addr_v4(_a)
Definition: ip_types.h:91
vl_api_cnat_set_snat_addresses_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: cnat.api:143
vl_api_cnat_translation_update_reply_t
Definition: cnat.api:83
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
nh
vl_api_fib_path_nh_t nh
Definition: fib_types.api:126
vl_api_cnat_get_snat_addresses_t
Definition: cnat.api:146
cnat_endpoint_decode
static int cnat_endpoint_decode(const vl_api_cnat_endpoint_t *in, cnat_endpoint_t *out)
Definition: cnat_api.c:47
ip4_address_t
Definition: ip4_packet.h:50
cnat_set_snat_policy
int cnat_set_snat_policy(cnat_snat_policy_type_t policy)
Definition: cnat_snat_policy.c:473
ip_address_family_encode
vl_api_address_family_t ip_address_family_encode(ip_address_family_t af)
Definition: ip_types_api.c:36
cnat_endpoint_tuple_t_::dst_ep
cnat_endpoint_t dst_ep
Definition: cnat_types.h:83
cnat_endpoint_encode
static void cnat_endpoint_encode(const cnat_endpoint_t *in, vl_api_cnat_endpoint_t *out)
Definition: cnat_api.c:75
cnat_session_t_::cs_proto
ip_protocol_t cs_proto
The IP protocol TCP or UDP only supported.
Definition: cnat_session.h:57
cnat_endpoint_tuple_t_::src_ep
cnat_endpoint_t src_ep
Definition: cnat_types.h:84
ip_address_decode2
void ip_address_decode2(const vl_api_address_t *in, ip_address_t *out)
Definition: ip_types_api.c:178
vl_api_cnat_translation_dump_t_handler
static void vl_api_cnat_translation_dump_t_handler(vl_api_cnat_translation_dump_t *mp)
Definition: cnat_api.c:196
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition: api_helper_macros.h:289
n_paths
u8 n_paths
Definition: ip.api:176
plugin.h
vl_api_cnat_translation_details_t::translation
vl_api_cnat_translation_t translation
Definition: cnat.api:100
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vl_api_cnat_set_snat_policy_t_handler
static void vl_api_cnat_set_snat_policy_t_handler(vl_api_cnat_set_snat_policy_t *mp)
Definition: cnat_api.c:325
vl_api_cnat_session_dump_t
Definition: cnat.api:131
vl_api_cnat_translation_details_t
Definition: cnat.api:97
paths
paths
Definition: map.api:460
cnat_snat_policy_del_pfx
int cnat_snat_policy_del_pfx(ip_prefix_t *pfx)
Definition: cnat_snat_policy.c:179
cnat_endpoint_tuple_t_::ep_flags
u8 ep_flags
Definition: cnat_types.h:85
vl_api_cnat_session_details_t
Definition: cnat.api:125
cnat_session_t_::cs_loc
u8 cs_loc
input / output / fib session
Definition: cnat_session.h:67
format_fns.h
vl_api_cnat_set_snat_policy_t
Definition: cnat.api:198
ip_prefix_decode2
int ip_prefix_decode2(const vl_api_prefix_t *in, ip_prefix_t *out)
Definition: ip_types_api.c:262
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
af
vl_api_address_family_t af
Definition: ip.api:619
ip6
vl_api_ip6_address_t ip6
Definition: one.api:424
cnat_lb_type_t
cnat_lb_type_t
Definition: cnat_translation.h:79
vl_api_cnat_translation_del_t::id
u32 id
Definition: cnat.api:94
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
cnat_client.h
api_helper_macros.h
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
vl_api_cnat_translation_update_t::translation
vl_api_cnat_translation_t translation
Definition: cnat.api:80
ip4_address_encode
void ip4_address_encode(const ip4_address_t *in, vl_api_ip4_address_t out)
Definition: ip_types_api.c:135
vl_api_cnat_translation_update_reply_t::id
u32 id
Definition: cnat.api:87
cnat_dump_walk_ctx_t_::rp
vl_api_registration_t * rp
Definition: cnat_api.c:150
cnat_snat_policy_main_t_
Definition: cnat_snat_policy.h:58
ip_protocol_t
enum ip_protocol ip_protocol_t
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
cnat_endpoint_t_::ce_port
u16 ce_port
Definition: cnat_types.h:77
vl_api_cnat_translation_dump_t::context
u32 context
Definition: cnat.api:106
vlib_main_t
Definition: main.h:102
vl_api_cnat_session_purge_t
Definition: cnat.api:109
cnat_translation_walk
void cnat_translation_walk(cnat_translation_walk_cb_t cb, void *ctx)
Walk/visit each of the translations.
Definition: cnat_translation.c:451
cnat_snat_policy_main_t_::snat_ip6
cnat_endpoint_t snat_ip6
Definition: cnat_snat_policy.h:73
cnat_endpoint_t_::ce_ip
ip_address_t ce_ip
Definition: cnat_types.h:75
u8
unsigned char u8
Definition: types.h:56
vl_api_cnat_get_snat_addresses_t_handler
static void vl_api_cnat_get_snat_addresses_t_handler(vl_api_cnat_get_snat_addresses_t *mp)
Definition: cnat_api.c:291
clib_error_t
Definition: clib_error.h:21
ip
vl_api_address_t ip
Definition: l2.api:558
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
vl_api_cnat_translation_details_t::context
u32 context
Definition: cnat.api:99
ip_proto_decode
int ip_proto_decode(vl_api_ip_proto_t ipp, ip_protocol_t *out)
Definition: ip_types_api.c:51
rv
int __clib_unused rv
Definition: application.c:491
vl_api_cnat_translation_dump_t
Definition: cnat.api:103
cnat_session_t_::value
struct cnat_session_t_::@646 value
this value sits in the same memory location a 'value' in the bihash kvp
cnat_snat_policy_type_t
enum cnat_snat_policy_type_t_ cnat_snat_policy_type_t
vl_api_cnat_translation_update_t
Definition: cnat.api:76
vnet.h
cnat_endpoint_t_::ce_flags
u8 ce_flags
Definition: cnat_types.h:78
cnat_snat_policy_main
cnat_snat_policy_main_t cnat_snat_policy_main
Definition: cnat_snat_policy.c:20
vl_api_cnat_session_details_t::context
u32 context
Definition: cnat.api:127
vl_api_cnat_set_snat_addresses_t::snat_ip6
vl_api_ip6_address_t snat_ip6
Definition: cnat.api:142
INDEX_INVALID
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:49
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
vl_api_cnat_get_snat_addresses_reply_t
Definition: cnat.api:152
ip_types_api.h
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
vl_api_cnat_snat_policy_add_del_if_t
Definition: cnat.api:177
cnat_session_walk
void cnat_session_walk(cnat_session_walk_cb_t cb, void *ctx)
Walk/visit each of the cnat session.
Definition: cnat_session.c:44
walk_rc_t
enum walk_rc_t_ walk_rc_t
Walk return code.
vl_api_cnat_get_snat_addresses_reply_t::snat_ip6
vl_api_ip6_address_t snat_ip6
Definition: cnat.api:158
vl_api_cnat_snat_policy_add_del_if_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: cnat.api:181
vl_api_cnat_get_snat_addresses_reply_t::snat_ip4
vl_api_ip4_address_t snat_ip4
Definition: cnat.api:157
cnat_translation_get
static_always_inline cnat_translation_t * cnat_translation_get(index_t cti)
Definition: cnat_translation.h:244
cnat_snat_policy.h
vl_api_cnat_session_dump_t_handler
static void vl_api_cnat_session_dump_t_handler(vl_api_cnat_session_dump_t *mp)
Definition: cnat_api.c:261
cnat_translation_t_
A Translation represents the translation of a VEP to one of a set of real server addresses.
Definition: cnat_translation.h:117
cnat_ep_trk_t_
Data used to track an EP in the FIB.
Definition: cnat_translation.h:32
ip_address_family_t
enum ip_address_family_t_ ip_address_family_t
cnat_session_t_::cs_port
u16 cs_port[VLIB_N_DIR]
ports in rx/tx
Definition: cnat_session.h:52
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105