FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
det44_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 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 /**
17  * @file
18  * @brief Deterministic NAT (CGN) plugin API implementation
19  */
20 
21 #include <vnet/ip/ip_types_api.h>
22 #include <nat/det44/det44.h>
23 #include <nat/det44/det44.api_enum.h>
24 #include <nat/det44/det44.api_types.h>
25 #include <vnet/fib/fib_table.h>
26 #include <vnet/ip/ip.h>
27 
28 #include <vlibmemory/api.h>
29 
30 #define REPLY_MSG_ID_BASE dm->msg_id_base
32 
33 static void
35 {
36  det44_main_t *dm = &det44_main;
37  vl_api_det44_add_del_map_reply_t *rmp;
38  int rv = 0;
39  ip4_address_t in_addr, out_addr;
40  clib_memcpy (&in_addr, mp->in_addr, 4);
41  clib_memcpy (&out_addr, mp->out_addr, 4);
42  rv = snat_det_add_map (&in_addr, mp->in_plen, &out_addr,
43  mp->out_plen, mp->is_add);
44  REPLY_MACRO (VL_API_DET44_ADD_DEL_MAP_REPLY);
45 }
46 
47 static void
49 {
50  det44_main_t *dm = &det44_main;
52  int rv = 0;
53  u16 lo_port = 0, hi_port = 0;
54  snat_det_map_t *m;
55  ip4_address_t in_addr, out_addr;
56 
57  out_addr.as_u32 = 0;
58  clib_memcpy (&in_addr, mp->in_addr, 4);
59  m = snat_det_map_by_user (&in_addr);
60  if (!m)
61  {
62  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
63  goto send_reply;
64  }
65 
66  snat_det_forward (m, &in_addr, &out_addr, &lo_port);
67  hi_port = lo_port + m->ports_per_host - 1;
68 
69 send_reply:
70  /* *INDENT-OFF* */
71  REPLY_MACRO2 (VL_API_DET44_FORWARD_REPLY,
72  ({
73  rmp->out_port_lo = ntohs (lo_port);
74  rmp->out_port_hi = ntohs (hi_port);
75  clib_memcpy (rmp->out_addr, &out_addr, 4);
76  }))
77  /* *INDENT-ON* */
78 }
79 
80 static void
82 {
83  det44_main_t *dm = &det44_main;
85  int rv = 0;
86  ip4_address_t out_addr, in_addr;
87  snat_det_map_t *m;
88 
89  in_addr.as_u32 = 0;
90  clib_memcpy (&out_addr, mp->out_addr, 4);
91  m = snat_det_map_by_out (&out_addr);
92  if (!m)
93  {
94  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
95  goto send_reply;
96  }
97 
98  snat_det_reverse (m, &out_addr, htons (mp->out_port), &in_addr);
99 
100 send_reply:
101  /* *INDENT-OFF* */
102  REPLY_MACRO2 (VL_API_DET44_REVERSE_REPLY,
103  ({
104  clib_memcpy (rmp->in_addr, &in_addr, 4);
105  }))
106  /* *INDENT-ON* */
107 }
108 
109 static void
111  u32 context)
112 {
113  det44_main_t *dm = &det44_main;
115 
116  rmp = vl_msg_api_alloc (sizeof (*rmp));
117  clib_memset (rmp, 0, sizeof (*rmp));
118  rmp->_vl_msg_id = ntohs (VL_API_DET44_MAP_DETAILS + dm->msg_id_base);
119  clib_memcpy (rmp->in_addr, &m->in_addr, 4);
120  rmp->in_plen = m->in_plen;
121  clib_memcpy (rmp->out_addr, &m->out_addr, 4);
122  rmp->out_plen = m->out_plen;
123  rmp->sharing_ratio = htonl (m->sharing_ratio);
124  rmp->ports_per_host = htons (m->ports_per_host);
125  rmp->ses_num = htonl (m->ses_num);
126  rmp->context = context;
127 
128  vl_api_send_msg (reg, (u8 *) rmp);
129 }
130 
131 static void
133 {
134  det44_main_t *dm = &det44_main;
136  snat_det_map_t *m;
137 
139  if (!reg)
140  return;
141 
142  /* *INDENT-OFF* */
143  vec_foreach(m, dm->det_maps)
144  sent_det44_map_details(m, reg, mp->context);
145  /* *INDENT-ON* */
146 }
147 
148 static void
150  * mp)
151 {
152  det44_main_t *dm = &det44_main;
153  vl_api_det44_close_session_out_reply_t *rmp;
154  ip4_address_t out_addr, ext_addr, in_addr;
156  snat_det_map_t *m;
157  snat_det_session_t *ses;
158  int rv = 0;
159 
160  clib_memcpy (&out_addr, mp->out_addr, 4);
161  clib_memcpy (&ext_addr, mp->ext_addr, 4);
162 
163  m = snat_det_map_by_out (&out_addr);
164  if (!m)
165  {
166  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
167  goto send_reply;
168  }
169  snat_det_reverse (m, &ext_addr, ntohs (mp->out_port), &in_addr);
170  key.ext_host_addr = ext_addr;
171  key.ext_host_port = mp->ext_port;
172  key.out_port = mp->out_port;
173  ses = snat_det_get_ses_by_out (m, &in_addr, key.as_u64);
174  if (!ses)
175  {
176  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
177  goto send_reply;
178  }
179  snat_det_ses_close (m, ses);
180 
181 send_reply:
182  REPLY_MACRO (VL_API_DET44_CLOSE_SESSION_OUT_REPLY);
183 }
184 
185 static void
187 {
188  det44_main_t *dm = &det44_main;
189  vl_api_det44_close_session_in_reply_t *rmp;
190  ip4_address_t in_addr, ext_addr;
192  snat_det_map_t *m;
193  snat_det_session_t *ses;
194  int rv = 0;
195 
196  clib_memcpy (&in_addr, mp->in_addr, 4);
197  clib_memcpy (&ext_addr, mp->ext_addr, 4);
198 
199  m = snat_det_map_by_user (&in_addr);
200  if (!m)
201  {
202  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
203  goto send_reply;
204  }
205  key.ext_host_addr = ext_addr;
206  key.ext_host_port = mp->ext_port;
207  ses = snat_det_find_ses_by_in (m, &in_addr, mp->in_port, key);
208  if (!ses)
209  {
210  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
211  goto send_reply;
212  }
213  snat_det_ses_close (m, ses);
214 
215 send_reply:
216  REPLY_MACRO (VL_API_DET44_CLOSE_SESSION_OUT_REPLY);
217 }
218 
219 static void
222 {
223  det44_main_t *dm = &det44_main;
225 
226  rmp = vl_msg_api_alloc (sizeof (*rmp));
227  clib_memset (rmp, 0, sizeof (*rmp));
228  rmp->_vl_msg_id = ntohs (VL_API_DET44_SESSION_DETAILS + dm->msg_id_base);
229  rmp->in_port = s->in_port;
230  clib_memcpy (rmp->ext_addr, &s->out.ext_host_addr, 4);
231  rmp->ext_port = s->out.ext_host_port;
232  rmp->out_port = s->out.out_port;
233  rmp->state = s->state;
234  rmp->expire = ntohl (s->expire);
235  rmp->context = context;
236 
237  vl_api_send_msg (reg, (u8 *) rmp);
238 }
239 
240 static void
242 {
244  ip4_address_t user_addr;
245  snat_det_map_t *m;
246  snat_det_session_t *s, empty_ses;
247  u16 i;
248 
250  if (!reg)
251  return;
252 
253  clib_memset (&empty_ses, 0, sizeof (empty_ses));
254  clib_memcpy (&user_addr, mp->user_addr, 4);
255  m = snat_det_map_by_user (&user_addr);
256  if (!m)
257  return;
258 
259  s = m->sessions + snat_det_user_ses_offset (&user_addr, m->in_plen);
260  for (i = 0; i < DET44_SES_PER_USER; i++)
261  {
262  if (s->out.as_u64)
263  send_det44_session_details (s, reg, mp->context);
264  s++;
265  }
266 }
267 
268 static void
271 {
272  det44_main_t *dm = &det44_main;
273  vl_api_det44_plugin_enable_disable_reply_t *rmp;
274  det44_config_t c = { 0 };
275  int rv = 0;
276  if (mp->enable)
277  {
278  c.outside_vrf_id = ntohl (mp->outside_vrf);
279  c.inside_vrf_id = ntohl (mp->inside_vrf);
281  }
282  else
283  {
285  }
286  REPLY_MACRO (VL_API_DET44_PLUGIN_ENABLE_DISABLE_REPLY);
287 }
288 
289 static void
292 {
293  det44_main_t *dm = &det44_main;
294  vl_api_det44_interface_add_del_feature_reply_t *rmp;
295  u32 sw_if_index = ntohl (mp->sw_if_index);
296  int rv = 0;
300  REPLY_MACRO (VL_API_DET44_INTERFACE_ADD_DEL_FEATURE_REPLY);
301 }
302 
303 static void
306 {
307  det44_main_t *dm = &det44_main;
309 
310  rmp = vl_msg_api_alloc (sizeof (*rmp));
311  clib_memset (rmp, 0, sizeof (*rmp));
312  rmp->_vl_msg_id = ntohs (VL_API_DET44_INTERFACE_DETAILS + dm->msg_id_base);
313  rmp->sw_if_index = ntohl (i->sw_if_index);
316  rmp->context = context;
317  vl_api_send_msg (reg, (u8 *) rmp);
318 }
319 
320 static void
322 {
323  det44_main_t *dm = &det44_main;
326 
328  if (!reg)
329  return;
330 
331  /* *INDENT-OFF* */
332  pool_foreach (i, dm->interfaces)
333  {
335  }
336  /* *INDENT-ON* */
337 }
338 
339 static void
341 {
342  det44_main_t *dm = &det44_main;
343  vl_api_det44_set_timeouts_reply_t *rmp;
344  nat_timeouts_t timeouts;
345  int rv = 0;
346  timeouts.udp = ntohl (mp->udp);
347  timeouts.tcp.established = ntohl (mp->tcp_established);
348  timeouts.tcp.transitory = ntohl (mp->tcp_transitory);
349  timeouts.icmp = ntohl (mp->icmp);
350  rv = det44_set_timeouts (&timeouts);
351  REPLY_MACRO (VL_API_DET44_SET_TIMEOUTS_REPLY);
352 }
353 
354 static void
356 {
357  det44_main_t *dm = &det44_main;
359  nat_timeouts_t timeouts;
360  int rv = 0;
361  timeouts = det44_get_timeouts ();
362  /* *INDENT-OFF* */
363  REPLY_MACRO2 (VL_API_DET44_GET_TIMEOUTS_REPLY,
364  ({
365  rmp->udp = htonl (timeouts.udp);
366  rmp->tcp_established = htonl (timeouts.tcp.established);
367  rmp->tcp_transitory = htonl (timeouts.tcp.transitory);
368  rmp->icmp = htonl (timeouts.icmp);
369  }))
370  /* *INDENT-ON* */
371 }
372 
373 /*
374  * Obsolete deterministic API to be removed
375  */
376 
377 static void
379 {
380  det44_main_t *dm = &det44_main;
381  vl_api_nat_det_add_del_map_reply_t *rmp;
382  int rv = 0;
383  ip4_address_t in_addr, out_addr;
384 
385  clib_memcpy (&in_addr, mp->in_addr, 4);
386  clib_memcpy (&out_addr, mp->out_addr, 4);
387  rv = snat_det_add_map (&in_addr, mp->in_plen, &out_addr,
388  mp->out_plen, mp->is_add);
389  REPLY_MACRO (VL_API_NAT_DET_ADD_DEL_MAP_REPLY);
390 }
391 
392 static void
394 {
395  det44_main_t *dm = &det44_main;
397  int rv = 0;
398  u16 lo_port = 0, hi_port = 0;
399  snat_det_map_t *m;
400  ip4_address_t in_addr, out_addr;
401 
402  out_addr.as_u32 = 0;
403  clib_memcpy (&in_addr, mp->in_addr, 4);
404  m = snat_det_map_by_user (&in_addr);
405  if (!m)
406  {
407  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
408  goto send_reply;
409  }
410 
411  snat_det_forward (m, &in_addr, &out_addr, &lo_port);
412  hi_port = lo_port + m->ports_per_host - 1;
413 
414 send_reply:
415  /* *INDENT-OFF* */
416  REPLY_MACRO2 (VL_API_NAT_DET_FORWARD_REPLY,
417  ({
418  rmp->out_port_lo = ntohs (lo_port);
419  rmp->out_port_hi = ntohs (hi_port);
420  clib_memcpy (rmp->out_addr, &out_addr, 4);
421  }))
422  /* *INDENT-ON* */
423 }
424 
425 static void
427 {
428  det44_main_t *dm = &det44_main;
430  int rv = 0;
431  ip4_address_t out_addr, in_addr;
432  snat_det_map_t *m;
433 
434  in_addr.as_u32 = 0;
435  clib_memcpy (&out_addr, mp->out_addr, 4);
436  m = snat_det_map_by_out (&out_addr);
437  if (!m)
438  {
439  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
440  goto send_reply;
441  }
442 
443  snat_det_reverse (m, &out_addr, htons (mp->out_port), &in_addr);
444 
445 send_reply:
446  /* *INDENT-OFF* */
447  REPLY_MACRO2 (VL_API_NAT_DET_REVERSE_REPLY,
448  ({
449  clib_memcpy (rmp->in_addr, &in_addr, 4);
450  }))
451  /* *INDENT-ON* */
452 }
453 
454 static void
456  u32 context)
457 {
458  det44_main_t *dm = &det44_main;
460 
461  rmp = vl_msg_api_alloc (sizeof (*rmp));
462  clib_memset (rmp, 0, sizeof (*rmp));
463  rmp->_vl_msg_id = ntohs (VL_API_NAT_DET_MAP_DETAILS + dm->msg_id_base);
464  clib_memcpy (rmp->in_addr, &m->in_addr, 4);
465  rmp->in_plen = m->in_plen;
466  clib_memcpy (rmp->out_addr, &m->out_addr, 4);
467  rmp->out_plen = m->out_plen;
468  rmp->sharing_ratio = htonl (m->sharing_ratio);
469  rmp->ports_per_host = htons (m->ports_per_host);
470  rmp->ses_num = htonl (m->ses_num);
471  rmp->context = context;
472 
473  vl_api_send_msg (reg, (u8 *) rmp);
474 }
475 
476 static void
478 {
479  det44_main_t *dm = &det44_main;
481  snat_det_map_t *m;
482 
484  if (!reg)
485  return;
486 
487  /* *INDENT-OFF* */
488  vec_foreach(m, dm->det_maps)
489  sent_nat_det_map_details(m, reg, mp->context);
490  /* *INDENT-ON* */
491 }
492 
493 static void
495  * mp)
496 {
497  det44_main_t *dm = &det44_main;
498  vl_api_nat_det_close_session_out_reply_t *rmp;
499  ip4_address_t out_addr, ext_addr, in_addr;
501  snat_det_map_t *m;
502  snat_det_session_t *ses;
503  int rv = 0;
504 
505  clib_memcpy (&out_addr, mp->out_addr, 4);
506  clib_memcpy (&ext_addr, mp->ext_addr, 4);
507 
508  m = snat_det_map_by_out (&out_addr);
509  if (!m)
510  {
511  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
512  goto send_reply;
513  }
514  snat_det_reverse (m, &ext_addr, ntohs (mp->out_port), &in_addr);
515  key.ext_host_addr = ext_addr;
516  key.ext_host_port = mp->ext_port;
517  key.out_port = mp->out_port;
518  ses = snat_det_get_ses_by_out (m, &in_addr, key.as_u64);
519  if (!ses)
520  {
521  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
522  goto send_reply;
523  }
524  snat_det_ses_close (m, ses);
525 
526 send_reply:
527  REPLY_MACRO (VL_API_NAT_DET_CLOSE_SESSION_OUT_REPLY);
528 }
529 
530 static void
532  mp)
533 {
534  det44_main_t *dm = &det44_main;
535  vl_api_nat_det_close_session_in_reply_t *rmp;
536  ip4_address_t in_addr, ext_addr;
538  snat_det_map_t *m;
539  snat_det_session_t *ses;
540  int rv = 0;
541 
542  clib_memcpy (&in_addr, mp->in_addr, 4);
543  clib_memcpy (&ext_addr, mp->ext_addr, 4);
544 
545  m = snat_det_map_by_user (&in_addr);
546  if (!m)
547  {
548  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
549  goto send_reply;
550  }
551  key.ext_host_addr = ext_addr;
552  key.ext_host_port = mp->ext_port;
553  ses = snat_det_find_ses_by_in (m, &in_addr, mp->in_port, key);
554  if (!ses)
555  {
556  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
557  goto send_reply;
558  }
559  snat_det_ses_close (m, ses);
560 
561 send_reply:
562  REPLY_MACRO (VL_API_NAT_DET_CLOSE_SESSION_OUT_REPLY);
563 }
564 
565 static void
568 {
569  det44_main_t *dm = &det44_main;
571 
572  rmp = vl_msg_api_alloc (sizeof (*rmp));
573  clib_memset (rmp, 0, sizeof (*rmp));
574  rmp->_vl_msg_id = ntohs (VL_API_NAT_DET_SESSION_DETAILS + dm->msg_id_base);
575  rmp->in_port = s->in_port;
576  clib_memcpy (rmp->ext_addr, &s->out.ext_host_addr, 4);
577  rmp->ext_port = s->out.ext_host_port;
578  rmp->out_port = s->out.out_port;
579  rmp->state = s->state;
580  rmp->expire = ntohl (s->expire);
581  rmp->context = context;
582 
583  vl_api_send_msg (reg, (u8 *) rmp);
584 }
585 
586 static void
588 {
590  ip4_address_t user_addr;
591  snat_det_map_t *m;
592  snat_det_session_t *s, empty_ses;
593  u16 i;
594 
596  if (!reg)
597  return;
598 
599  clib_memset (&empty_ses, 0, sizeof (empty_ses));
600  clib_memcpy (&user_addr, mp->user_addr, 4);
601  m = snat_det_map_by_user (&user_addr);
602  if (!m)
603  return;
604 
605  s = m->sessions + snat_det_user_ses_offset (&user_addr, m->in_plen);
606  for (i = 0; i < DET44_SES_PER_USER; i++)
607  {
608  if (s->out.as_u64)
610  s++;
611  }
612 }
613 
614 /* API definitions */
615 #include <vnet/format_fns.h>
616 #include <nat/det44/det44.api.c>
617 
618 /* Set up the API message handling tables */
619 clib_error_t *
621 {
622  det44_main_t *dm = &det44_main;
624  return 0;
625 }
626 
627 /*
628  * fd.io coding-style-patch-verification: ON
629  *
630  * Local Variables:
631  * eval: (c-set-style "gnu")
632  * End:
633  */
vl_api_nat_det_session_details_t::expire
u32 expire
Definition: det44.api:466
det44_interface_is_inside
#define det44_interface_is_inside(i)
Check if Deterministic NAT interface is inside.
Definition: det44.h:213
vl_api_nat_det_close_session_out_t::ext_port
u16 ext_port
Definition: det44.api:416
vl_api_det44_forward_t_handler
static void vl_api_det44_forward_t_handler(vl_api_det44_forward_t *mp)
Definition: det44_api.c:48
det44.h
Deterministic NAT (CGN) definitions.
vl_api_det44_map_details_t::ports_per_host
u16 ports_per_host
Definition: det44.api:179
nat_timeouts_t::tcp
struct nat_timeouts_t::@742 tcp
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition: api_helper_macros.h:281
vl_api_client_index_to_registration
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
vl_api_det44_add_del_map_t_handler
static void vl_api_det44_add_del_map_t_handler(vl_api_det44_add_del_map_t *mp)
Definition: det44_api.c:34
api.h
vl_api_nat_det_close_session_in_t::ext_port
u16 ext_port
Definition: det44.api:434
nat_timeouts_t::udp
u32 udp
Definition: lib.h:84
nat_timeouts_t::icmp
u32 icmp
Definition: lib.h:85
snat_det_session_t
Definition: det44.h:98
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
vl_api_nat_det_forward_t::in_addr
vl_api_ip4_address_t in_addr
Definition: det44.api:324
vl_api_det44_close_session_in_t_handler
static void vl_api_det44_close_session_in_t_handler(vl_api_det44_close_session_in_t *mp)
Definition: det44_api.c:186
vl_api_det44_interface_add_del_feature_t::is_add
bool is_add
Definition: det44.api:55
vl_api_det44_get_timeouts_reply_t::tcp_transitory
u32 tcp_transitory
Definition: det44.api:287
vl_api_nat_det_forward_reply_t::out_port_lo
u16 out_port_lo
Definition: det44.api:338
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
snat_det_session_t::out
snat_det_out_key_t out
Definition: det44.h:103
vl_api_nat_det_session_details_t
Deterministic NAT sessions reply.
Definition: det44.api:459
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
snat_det_add_map
int snat_det_add_map(ip4_address_t *in_addr, u8 in_plen, ip4_address_t *out_addr, u8 out_plen, int is_add)
Add/delete deterministic NAT mapping.
Definition: det44.c:99
vl_api_det44_close_session_in_t::in_addr
vl_api_ip4_address_t in_addr
Definition: det44.api:211
snat_det_out_key_t::ext_host_port
u16 ext_host_port
Definition: det44.h:91
snat_det_map_t::ses_num
u32 ses_num
Definition: det44.h:123
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
det44_main_s::msg_id_base
u16 msg_id_base
Definition: det44.h:177
det44_get_timeouts
nat_timeouts_t det44_get_timeouts()
Definition: det44.c:181
vl_api_det44_reverse_reply_t::in_addr
vl_api_ip4_address_t in_addr
Definition: det44.api:150
vl_api_det44_interface_details_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: det44.api:80
vl_api_nat_det_session_details_t::in_port
u16 in_port
Definition: det44.api:461
vl_api_det44_plugin_enable_disable_t::outside_vrf
u32 outside_vrf
Definition: det44.api:40
vl_api_nat_det_close_session_in_t
Close deterministic NAT session by inside address and port.
Definition: det44.api:428
vl_api_nat_det_map_details_t::ses_num
u32 ses_num
Definition: det44.api:398
vl_api_det44_map_dump_t::context
u32 context
Definition: det44.api:159
sent_nat_det_map_details
static void sent_nat_det_map_details(snat_det_map_t *m, vl_api_registration_t *reg, u32 context)
Definition: det44_api.c:455
vl_api_det44_plugin_enable_disable_t_handler
static void vl_api_det44_plugin_enable_disable_t_handler(vl_api_det44_plugin_enable_disable_t *mp)
Definition: det44_api.c:270
vl_api_det44_plugin_enable_disable_t::inside_vrf
u32 inside_vrf
Definition: det44.api:39
vl_api_nat_det_close_session_out_t::out_port
u16 out_port
Definition: det44.api:414
snat_det_out_key_t::ext_host_addr
ip4_address_t ext_host_addr
Definition: det44.h:90
vl_api_det44_add_del_map_t::out_plen
u8 out_plen
Definition: det44.api:100
sent_det44_map_details
static void sent_det44_map_details(snat_det_map_t *m, vl_api_registration_t *reg, u32 context)
Definition: det44_api.c:110
vl_api_det44_close_session_in_t::in_port
u16 in_port
Definition: det44.api:212
nat_timeouts_t
Definition: lib.h:76
vl_api_nat_det_add_del_map_t::out_addr
vl_api_ip4_address_t out_addr
Definition: det44.api:311
vl_api_nat_det_add_del_map_t::in_plen
u8 in_plen
Definition: det44.api:310
vl_api_det44_set_timeouts_t::udp
u32 udp
Definition: det44.api:258
vl_api_nat_det_session_details_t::ext_port
u16 ext_port
Definition: det44.api:463
vl_api_nat_det_session_dump_t::context
u32 context
Definition: det44.api:445
vl_api_nat_det_forward_t_handler
static void vl_api_nat_det_forward_t_handler(vl_api_nat_det_forward_t *mp)
Definition: det44_api.c:393
vl_api_det44_close_session_in_t::ext_port
u16 ext_port
Definition: det44.api:214
ip4_address_t::as_u32
u32 as_u32
Definition: ip4_packet.h:57
vl_api_det44_forward_reply_t::out_port_hi
u16 out_port_hi
Definition: det44.api:125
vl_api_det44_get_timeouts_t_handler
static void vl_api_det44_get_timeouts_t_handler(vl_api_det44_get_timeouts_t *mp)
Definition: det44_api.c:355
vl_api_nat_det_close_session_out_t::ext_addr
vl_api_ip4_address_t ext_addr
Definition: det44.api:415
fib_table.h
snat_det_session_t::in_port
u16 in_port
Definition: det44.h:101
vl_api_det44_close_session_in_t::ext_addr
vl_api_ip4_address_t ext_addr
Definition: det44.api:213
vl_api_nat_det_map_dump_t::client_index
u32 client_index
Definition: det44.api:375
vl_api_det44_map_dump_t_handler
static void vl_api_det44_map_dump_t_handler(vl_api_det44_map_dump_t *mp)
Definition: det44_api.c:132
vl_api_det44_map_dump_t
Dump DET44 mappings.
Definition: det44.api:157
det44_config_t
Definition: det44.h:134
snat_det_out_key_t::out_port
u16 out_port
Definition: det44.h:92
u16
unsigned short u16
Definition: types.h:57
vl_api_det44_get_timeouts_reply_t::tcp_established
u32 tcp_established
Definition: det44.api:286
vl_api_det44_session_details_t::in_port
u16 in_port
Definition: det44.api:239
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vl_api_det44_add_del_map_t::in_plen
u8 in_plen
Definition: det44.api:98
vl_api_nat_det_map_details_t::ports_per_host
u16 ports_per_host
Definition: det44.api:397
det44_api_hookup
clib_error_t * det44_api_hookup(vlib_main_t *vm)
Definition: det44_api.c:620
vl_api_nat_det_reverse_reply_t::in_addr
vl_api_ip4_address_t in_addr
Definition: det44.api:366
vl_api_det44_map_details_t::sharing_ratio
u32 sharing_ratio
Definition: det44.api:178
det44_main_s::interfaces
det44_interface_t * interfaces
Definition: det44.h:182
snat_det_session_t::expire
u32 expire
Definition: det44.h:107
snat_det_map_t::in_addr
ip4_address_t in_addr
Definition: det44.h:113
vl_api_det44_interface_add_del_feature_t_handler
static void vl_api_det44_interface_add_del_feature_t_handler(vl_api_det44_interface_add_del_feature_t *mp)
Definition: det44_api.c:291
vl_api_det44_plugin_enable_disable_t
Enable/disable DET44 plugin.
Definition: det44.api:36
nat_timeouts_t::transitory
u32 transitory
Definition: lib.h:81
vl_api_nat_det_reverse_t::out_addr
vl_api_ip4_address_t out_addr
Definition: det44.api:354
vl_api_nat_det_close_session_in_t::in_port
u16 in_port
Definition: det44.api:432
vl_api_nat_det_map_dump_t::context
u32 context
Definition: det44.api:376
snat_det_map_by_user
static_always_inline snat_det_map_t * snat_det_map_by_user(ip4_address_t *user_addr)
Definition: det44.h:277
vl_api_nat_det_add_del_map_t_handler
static void vl_api_nat_det_add_del_map_t_handler(vl_api_nat_det_add_del_map_t *mp)
Definition: det44_api.c:378
det44_plugin_disable
int det44_plugin_disable()
Definition: det44.c:385
vl_api_det44_session_details_t::expire
u32 expire
Definition: det44.api:244
det44_interface_t
Definition: det44.h:128
key
typedef key
Definition: ipsec_types.api:91
send_det44_session_details
static void send_det44_session_details(snat_det_session_t *s, vl_api_registration_t *reg, u32 context)
Definition: det44_api.c:220
vl_api_det44_interface_details_t::is_inside
bool is_inside
Definition: det44.api:78
vl_api_det44_map_details_t::ses_num
u32 ses_num
Definition: det44.api:180
vl_api_det44_reverse_t
Get inside address from outside address and port.
Definition: det44.api:135
vl_api_det44_close_session_out_t::out_addr
vl_api_ip4_address_t out_addr
Definition: det44.api:194
snat_det_map_t::out_addr
ip4_address_t out_addr
Definition: det44.h:116
vl_api_det44_get_timeouts_t
Get values of timeouts for DET44 sessions (seconds)
Definition: det44.api:269
vl_api_nat_det_session_details_t::context
u32 context
Definition: det44.api:460
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
vl_api_nat_det_map_details_t
NAT users response.
Definition: det44.api:390
vl_api_det44_reverse_reply_t
Get inside address from outside address and port reply.
Definition: det44.api:147
vl_api_nat_det_reverse_t::out_port
u16 out_port
Definition: det44.api:353
vl_api_nat_det_forward_reply_t::out_port_hi
u16 out_port_hi
Definition: det44.api:339
snat_det_reverse
static_always_inline void snat_det_reverse(snat_det_map_t *dm, ip4_address_t *out_addr, u16 out_port, ip4_address_t *in_addr)
Definition: det44.h:322
vl_api_nat_det_session_details_t::state
u8 state
Definition: det44.api:465
nat_timeouts_t::established
u32 established
Definition: lib.h:80
vl_api_det44_forward_reply_t::out_port_lo
u16 out_port_lo
Definition: det44.api:124
det44_main_s::det_maps
snat_det_map_t * det_maps
Definition: det44.h:163
det44_plugin_enable
int det44_plugin_enable(det44_config_t c)
Definition: det44.c:358
vl_api_det44_set_timeouts_t::tcp_established
u32 tcp_established
Definition: det44.api:259
vl_api_det44_interface_details_t::context
u32 context
Definition: det44.api:77
vl_api_det44_interface_dump_t_handler
static void vl_api_det44_interface_dump_t_handler(vl_api_det44_interface_dump_t *mp)
Definition: det44_api.c:321
vl_api_det44_interface_add_del_feature_t
Enable/disable DET44 feature on the interface.
Definition: det44.api:52
snat_det_map_t::out_plen
u8 out_plen
Definition: det44.h:117
det44_main
det44_main_t det44_main
Definition: det44.c:30
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_det44_close_session_out_t
Close DET44 session by outside address and port.
Definition: det44.api:191
c
svmdb_client_t * c
Definition: vpp_get_metrics.c:48
snat_det_map_t::sharing_ratio
u32 sharing_ratio
Definition: det44.h:119
vl_api_det44_interface_add_del_feature_t::is_inside
bool is_inside
Definition: det44.api:56
vl_api_det44_interface_details_t
DET44 interface details response.
Definition: det44.api:76
det44_send_interface_details
static void det44_send_interface_details(det44_interface_t *i, vl_api_registration_t *reg, u32 context)
Definition: det44_api.c:304
vl_api_det44_interface_dump_t::client_index
u32 client_index
Definition: det44.api:66
vl_api_det44_plugin_enable_disable_t::enable
bool enable
Definition: det44.api:41
vl_api_det44_set_timeouts_t::tcp_transitory
u32 tcp_transitory
Definition: det44.api:260
vl_api_nat_det_close_session_in_t::in_addr
vl_api_ip4_address_t in_addr
Definition: det44.api:431
vl_api_det44_session_details_t::state
u8 state
Definition: det44.api:243
vl_api_nat_det_session_dump_t::client_index
u32 client_index
Definition: det44.api:444
vl_api_det44_session_details_t::out_port
u16 out_port
Definition: det44.api:242
vl_api_det44_add_del_map_t
Add/delete DET44 mapping.
Definition: det44.api:93
snat_det_session_t::state
u8 state
Definition: det44.h:105
vl_api_det44_session_dump_t_handler
static void vl_api_det44_session_dump_t_handler(vl_api_det44_session_dump_t *mp)
Definition: det44_api.c:241
ip4_address_t
Definition: ip4_packet.h:50
vl_api_det44_map_details_t::context
u32 context
Definition: det44.api:173
vl_api_det44_session_details_t
DET44 sessions reply.
Definition: det44.api:237
vl_api_det44_forward_reply_t::out_addr
vl_api_ip4_address_t out_addr
Definition: det44.api:126
vl_api_det44_session_dump_t
Dump DET44 sessions.
Definition: det44.api:222
vl_api_det44_map_details_t::in_addr
vl_api_ip4_address_t in_addr
Definition: det44.api:174
vl_api_det44_set_timeouts_t::icmp
u32 icmp
Definition: det44.api:261
vl_api_det44_get_timeouts_reply_t::udp
u32 udp
Definition: det44.api:285
vl_api_nat_det_reverse_reply_t
Get inside address from outside address and port reply.
Definition: det44.api:363
vl_api_nat_det_map_details_t::sharing_ratio
u32 sharing_ratio
Definition: det44.api:396
vl_api_det44_interface_dump_t::context
u32 context
Definition: det44.api:67
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition: api_helper_macros.h:289
vl_api_nat_det_map_dump_t_handler
static void vl_api_nat_det_map_dump_t_handler(vl_api_nat_det_map_dump_t *mp)
Definition: det44_api.c:477
vl_api_det44_interface_details_t::is_outside
bool is_outside
Definition: det44.api:79
vl_api_det44_session_details_t::ext_addr
vl_api_ip4_address_t ext_addr
Definition: det44.api:240
vl_api_nat_det_reverse_t_handler
static void vl_api_nat_det_reverse_t_handler(vl_api_nat_det_reverse_t *mp)
Definition: det44_api.c:426
vl_api_nat_det_close_session_out_t
Close deterministic NAT session by outside address and port.
Definition: det44.api:410
vl_api_det44_forward_reply_t
Get outside address and port range from inside address.
Definition: det44.api:121
det44_main_s
Definition: det44.h:146
snat_det_ses_close
static_always_inline void snat_det_ses_close(snat_det_map_t *dm, snat_det_session_t *ses)
Definition: det44.h:414
vl_api_nat_det_map_dump_t
Dump NAT deterministic mappings.
Definition: det44.api:374
vl_api_det44_get_timeouts_reply_t
Get values of timeouts for DET44 sessions reply.
Definition: det44.api:282
vl_api_nat_det_map_details_t::in_addr
vl_api_ip4_address_t in_addr
Definition: det44.api:392
vl_api_nat_det_forward_reply_t
Get outside address and port range from inside address.
Definition: det44.api:335
det44_interface_add_del
int det44_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
Definition: det44.c:195
snat_det_get_ses_by_out
static_always_inline snat_det_session_t * snat_det_get_ses_by_out(snat_det_map_t *dm, ip4_address_t *in_addr, u64 out_key)
Definition: det44.h:344
vl_api_nat_det_reverse_t
Get inside address from outside address and port.
Definition: det44.api:350
vl_api_nat_det_close_session_out_t_handler
static void vl_api_nat_det_close_session_out_t_handler(vl_api_nat_det_close_session_out_t *mp)
Definition: det44_api.c:494
vl_api_nat_det_session_dump_t::user_addr
vl_api_ip4_address_t user_addr
Definition: det44.api:446
snat_det_find_ses_by_in
static_always_inline snat_det_session_t * snat_det_find_ses_by_in(snat_det_map_t *dm, ip4_address_t *in_addr, u16 in_port, snat_det_out_key_t out_key)
Definition: det44.h:361
vl_api_det44_set_timeouts_t_handler
static void vl_api_det44_set_timeouts_t_handler(vl_api_det44_set_timeouts_t *mp)
Definition: det44_api.c:340
snat_det_map_t
Definition: det44.h:110
vl_api_nat_det_close_session_out_t::out_addr
vl_api_ip4_address_t out_addr
Definition: det44.api:413
vl_api_nat_det_map_details_t::in_plen
u8 in_plen
Definition: det44.api:393
vl_api_det44_close_session_out_t::ext_addr
vl_api_ip4_address_t ext_addr
Definition: det44.api:196
format_fns.h
snat_det_out_key_t::as_u64
u64 as_u64
Definition: det44.h:94
vl_api_nat_det_session_dump_t_handler
static void vl_api_nat_det_session_dump_t_handler(vl_api_nat_det_session_dump_t *mp)
Definition: det44_api.c:587
vl_api_det44_session_details_t::ext_port
u16 ext_port
Definition: det44.api:241
vl_api_det44_session_dump_t::user_addr
vl_api_ip4_address_t user_addr
Definition: det44.api:225
snat_det_map_t::in_plen
u8 in_plen
Definition: det44.h:114
vl_api_det44_add_del_map_t::in_addr
vl_api_ip4_address_t in_addr
Definition: det44.api:97
ip.h
u32
unsigned int u32
Definition: types.h:88
vl_api_det44_close_session_out_t_handler
static void vl_api_det44_close_session_out_t_handler(vl_api_det44_close_session_out_t *mp)
Definition: det44_api.c:149
vl_api_det44_session_dump_t::context
u32 context
Definition: det44.api:224
vl_api_det44_close_session_out_t::ext_port
u16 ext_port
Definition: det44.api:197
vl_api_det44_session_details_t::context
u32 context
Definition: det44.api:238
vl_api_nat_det_add_del_map_t::out_plen
u8 out_plen
Definition: det44.api:312
det44_set_timeouts
int det44_set_timeouts(nat_timeouts_t *timeouts)
Definition: det44.c:166
vl_api_det44_interface_dump_t
Dump interfaces with DET44 feature.
Definition: det44.api:65
api_helper_macros.h
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
vl_api_det44_close_session_out_t::out_port
u16 out_port
Definition: det44.api:195
vl_api_det44_map_details_t::out_plen
u8 out_plen
Definition: det44.api:177
vl_api_det44_map_details_t::out_addr
vl_api_ip4_address_t out_addr
Definition: det44.api:176
vl_api_det44_reverse_t::out_addr
vl_api_ip4_address_t out_addr
Definition: det44.api:139
snat_det_map_t::sessions
snat_det_session_t * sessions
Definition: det44.h:125
snat_det_forward
static_always_inline void snat_det_forward(snat_det_map_t *dm, ip4_address_t *in_addr, ip4_address_t *out_addr, u16 *lo_port)
Definition: det44.h:307
vl_api_det44_get_timeouts_reply_t::icmp
u32 icmp
Definition: det44.api:288
vl_api_nat_det_session_dump_t
Dump determinstic NAT sessions.
Definition: det44.api:443
vl_api_nat_det_map_details_t::out_plen
u8 out_plen
Definition: det44.api:395
send_nat_det_session_details
static void send_nat_det_session_details(snat_det_session_t *s, vl_api_registration_t *reg, u32 context)
Definition: det44_api.c:566
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
vl_api_nat_det_forward_t
Get outside address and port range from inside address.
Definition: det44.api:321
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vl_api_det44_set_timeouts_t
Set values of timeouts for DET44 sessions (seconds)
Definition: det44.api:255
vl_api_nat_det_session_details_t::out_port
u16 out_port
Definition: det44.api:464
vl_api_nat_det_close_session_in_t_handler
static void vl_api_nat_det_close_session_in_t_handler(vl_api_nat_det_close_session_in_t *mp)
Definition: det44_api.c:531
vl_api_det44_reverse_t::out_port
u16 out_port
Definition: det44.api:138
i
int i
Definition: flowhash_template.h:376
vl_api_nat_det_session_details_t::ext_addr
vl_api_ip4_address_t ext_addr
Definition: det44.api:462
vl_api_det44_session_dump_t::client_index
u32 client_index
Definition: det44.api:223
vl_api_nat_det_map_details_t::context
u32 context
Definition: det44.api:391
DET44_SES_PER_USER
#define DET44_SES_PER_USER
Definition: det44.h:64
context
u32 context
Definition: ip.api:852
det44_interface_is_outside
#define det44_interface_is_outside(i)
Check if Deterministic NAT interface is outside.
Definition: det44.h:219
rv
int __clib_unused rv
Definition: application.c:491
vl_api_det44_map_dump_t::client_index
u32 client_index
Definition: det44.api:158
snat_det_map_t::ports_per_host
u16 ports_per_host
Definition: det44.h:121
vl_api_det44_interface_add_del_feature_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: det44.api:57
vl_api_det44_reverse_t_handler
static void vl_api_det44_reverse_t_handler(vl_api_det44_reverse_t *mp)
Definition: det44_api.c:81
vl_api_nat_det_add_del_map_t::is_add
bool is_add
Definition: det44.api:308
vl_api_det44_map_details_t::in_plen
u8 in_plen
Definition: det44.api:175
vl_api_nat_det_map_details_t::out_addr
vl_api_ip4_address_t out_addr
Definition: det44.api:394
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
ip_types_api.h
vl_api_det44_close_session_in_t
Close DET44 session by inside address and port.
Definition: det44.api:208
vl_api_det44_add_del_map_t::out_addr
vl_api_ip4_address_t out_addr
Definition: det44.api:99
vl_api_det44_add_del_map_t::is_add
bool is_add
Definition: det44.api:96
vl_api_det44_map_details_t
DET44 users response.
Definition: det44.api:172
snat_det_user_ses_offset
static_always_inline u32 snat_det_user_ses_offset(ip4_address_t *addr, u8 plen)
Definition: det44.h:337
snat_det_out_key_t
Definition: det44.h:84
vl_api_nat_det_add_del_map_t::in_addr
vl_api_ip4_address_t in_addr
Definition: det44.api:309
vl_api_nat_det_add_del_map_t
Add/delete NAT deterministic mapping.
Definition: det44.api:305
snat_det_map_by_out
static_always_inline snat_det_map_t * snat_det_map_by_out(ip4_address_t *out_addr)
Definition: det44.h:292
vl_api_nat_det_close_session_in_t::ext_addr
vl_api_ip4_address_t ext_addr
Definition: det44.api:433
vl_api_nat_det_forward_reply_t::out_addr
vl_api_ip4_address_t out_addr
Definition: det44.api:340
vl_api_det44_forward_t::in_addr
vl_api_ip4_address_t in_addr
Definition: det44.api:111
vl_msg_api_alloc
void * vl_msg_api_alloc(int nbytes)
Definition: memory_shared.c:199
vl_api_det44_forward_t
Get outside address and port range from inside address.
Definition: det44.api:108