FD.io VPP  v21.01.1
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
221  vl_api_registration_t * reg, u32 context)
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);
280  rv = det44_plugin_enable (c);
281  }
282  else
283  {
284  rv = det44_plugin_disable ();
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;
298  rv = det44_interface_add_del (sw_if_index, mp->is_inside, !mp->is_add);
300  REPLY_MACRO (VL_API_DET44_INTERFACE_ADD_DEL_FEATURE_REPLY);
301 }
302 
303 static void
305  vl_api_registration_t * reg, u32 context)
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
567  vl_api_registration_t * reg, u32 context)
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  */
static void vl_api_det44_set_timeouts_t_handler(vl_api_det44_set_timeouts_t *mp)
Definition: det44_api.c:340
static void sent_nat_det_map_details(snat_det_map_t *m, vl_api_registration_t *reg, u32 context)
Definition: det44_api.c:455
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_ip4_address_t ext_addr
Definition: det44.api:433
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
static void vl_api_det44_get_timeouts_t_handler(vl_api_det44_get_timeouts_t *mp)
Definition: det44_api.c:355
u16 ext_host_port
Definition: det44.h:91
int det44_plugin_enable(det44_config_t c)
Definition: det44.c:358
static void send_nat_det_session_details(snat_det_session_t *s, vl_api_registration_t *reg, u32 context)
Definition: det44_api.c:566
vl_api_ip4_address_t out_addr
Definition: det44.api:340
static void vl_api_det44_plugin_enable_disable_t_handler(vl_api_det44_plugin_enable_disable_t *mp)
Definition: det44_api.c:270
struct nat_timeouts_t::@86 tcp
int det44_plugin_disable()
Definition: det44.c:385
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
#define ntohs(x)
Definition: af_xdp.bpf.c:29
u32 inside_vrf_id
Definition: det44.h:137
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:527
vl_api_ip4_address_t out_addr
Definition: det44.api:311
static void vl_api_det44_reverse_t_handler(vl_api_det44_reverse_t *mp)
Definition: det44_api.c:81
vl_api_ip4_address_t ext_addr
Definition: det44.api:240
static void vl_api_nat_det_reverse_t_handler(vl_api_nat_det_reverse_t *mp)
Definition: det44_api.c:426
#define REPLY_MACRO2(t, body)
vl_api_ip4_address_t in_addr
Definition: det44.api:174
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
NAT users response.
Definition: det44.api:390
Get outside address and port range from inside address.
Definition: det44.api:321
Deterministic NAT (CGN) definitions.
Get inside address from outside address and port reply.
Definition: det44.api:363
Get values of timeouts for DET44 sessions reply.
Definition: det44.api:282
vlib_main_t * vm
Definition: in2out_ed.c:1580
vl_api_ip4_address_t out_addr
Definition: det44.api:99
vl_api_ip4_address_t in_addr
Definition: det44.api:211
vl_api_ip4_address_t out_addr
Definition: det44.api:176
DET44 sessions reply.
Definition: det44.api:237
static void vl_api_det44_interface_dump_t_handler(vl_api_det44_interface_dump_t *mp)
Definition: det44_api.c:321
void * vl_msg_api_alloc(int nbytes)
static void vl_api_nat_det_session_dump_t_handler(vl_api_nat_det_session_dump_t *mp)
Definition: det44_api.c:587
u32 established
Definition: lib.h:80
unsigned char u8
Definition: types.h:56
vl_api_ip4_address_t ext_addr
Definition: det44.api:196
vl_api_ip4_address_t out_addr
Definition: det44.api:354
#define clib_memcpy(d, s, n)
Definition: string.h:180
static_always_inline u32 snat_det_user_ses_offset(ip4_address_t *addr, u8 plen)
Definition: det44.h:337
Dump interfaces with DET44 feature.
Definition: det44.api:65
static void vl_api_det44_forward_t_handler(vl_api_det44_forward_t *mp)
Definition: det44_api.c:48
vl_api_ip4_address_t in_addr
Definition: det44.api:150
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
Get values of timeouts for DET44 sessions (seconds)
Definition: det44.api:269
static void vl_api_det44_session_dump_t_handler(vl_api_det44_session_dump_t *mp)
Definition: det44_api.c:241
ip4_address_t ext_host_addr
Definition: det44.h:90
nat_timeouts_t det44_get_timeouts()
Definition: det44.c:181
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
static_always_inline snat_det_map_t * snat_det_map_by_out(ip4_address_t *out_addr)
Definition: det44.h:292
static void vl_api_nat_det_forward_t_handler(vl_api_nat_det_forward_t *mp)
Definition: det44_api.c:393
u16 msg_id_base
Definition: det44.h:177
unsigned int u32
Definition: types.h:88
vl_api_interface_index_t sw_if_index
Definition: det44.api:57
vl_api_ip4_address_t ext_addr
Definition: det44.api:462
u32 outside_vrf_id
Definition: det44.h:136
vl_api_ip4_address_t ext_addr
Definition: det44.api:213
u32 transitory
Definition: lib.h:81
Dump DET44 mappings.
Definition: det44.api:157
snat_det_session_t * sessions
Definition: det44.h:125
Close deterministic NAT session by outside address and port.
Definition: det44.api:410
unsigned short u16
Definition: types.h:57
#define REPLY_MACRO(t)
det44_main_t det44_main
Definition: det44.c:30
Get inside address from outside address and port.
Definition: det44.api:135
Get outside address and port range from inside address.
Definition: det44.api:121
vl_api_ip4_address_t in_addr
Definition: det44.api:111
DET44 interface details response.
Definition: det44.api:76
vl_api_ip4_address_t out_addr
Definition: det44.api:194
vl_api_ip4_address_t in_addr
Definition: det44.api:431
snat_det_map_t * det_maps
Definition: det44.h:163
vl_api_interface_index_t sw_if_index
Definition: det44.api:80
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
static void setup_message_id_table(api_main_t *am)
Definition: bfd_api.c:409
#define BAD_SW_IF_INDEX_LABEL
Add/delete NAT deterministic mapping.
Definition: det44.api:305
vl_api_ip4_address_t ext_addr
Definition: det44.api:415
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
svmdb_client_t * c
Add/delete DET44 mapping.
Definition: det44.api:93
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
static void vl_api_det44_map_dump_t_handler(vl_api_det44_map_dump_t *mp)
Definition: det44_api.c:132
vl_api_ip4_address_t out_addr
Definition: det44.api:126
DET44 users response.
Definition: det44.api:172
u32 sharing_ratio
Definition: det44.h:119
vl_api_ip4_address_t out_addr
Definition: det44.api:413
Close DET44 session by inside address and port.
Definition: det44.api:208
ip4_address_t out_addr
Definition: det44.h:116
static void vl_api_det44_close_session_out_t_handler(vl_api_det44_close_session_out_t *mp)
Definition: det44_api.c:149
clib_error_t * det44_api_hookup(vlib_main_t *vm)
Definition: det44_api.c:620
static_always_inline void snat_det_ses_close(snat_det_map_t *dm, snat_det_session_t *ses)
Definition: det44.h:414
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
Close DET44 session by outside address and port.
Definition: det44.api:191
vl_api_ip4_address_t in_addr
Definition: det44.api:324
int det44_set_timeouts(nat_timeouts_t *timeouts)
Definition: det44.c:166
static void send_det44_session_details(snat_det_session_t *s, vl_api_registration_t *reg, u32 context)
Definition: det44_api.c:220
static void sent_det44_map_details(snat_det_map_t *m, vl_api_registration_t *reg, u32 context)
Definition: det44_api.c:110
#define DET44_SES_PER_USER
Definition: det44.h:64
Get inside address from outside address and port reply.
Definition: det44.api:147
vl_api_ip4_address_t in_addr
Definition: det44.api:392
Close deterministic NAT session by inside address and port.
Definition: det44.api:428
ip4_address_t in_addr
Definition: det44.h:113
Dump determinstic NAT sessions.
Definition: det44.api:443
#define det44_interface_is_inside(i)
Check if Deterministic NAT interface is inside.
Definition: det44.h:213
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
static void vl_api_nat_det_map_dump_t_handler(vl_api_nat_det_map_dump_t *mp)
Definition: det44_api.c:477
static void vl_api_det44_close_session_in_t_handler(vl_api_det44_close_session_in_t *mp)
Definition: det44_api.c:186
Enable/disable DET44 feature on the interface.
Definition: det44.api:52
typedef key
Definition: ipsec_types.api:86
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
Dump DET44 sessions.
Definition: det44.api:222
det44_interface_t * interfaces
Definition: det44.h:182
Dump NAT deterministic mappings.
Definition: det44.api:374
Get outside address and port range from inside address.
Definition: det44.api:335
u16 ports_per_host
Definition: det44.h:121
Deterministic NAT sessions reply.
Definition: det44.api:459
snat_det_out_key_t out
Definition: det44.h:103
#define det44_interface_is_outside(i)
Check if Deterministic NAT interface is outside.
Definition: det44.h:219
static void det44_send_interface_details(det44_interface_t *i, vl_api_registration_t *reg, u32 context)
Definition: det44_api.c:304
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
u32 udp
Definition: lib.h:84
vl_api_ip4_address_t in_addr
Definition: det44.api:97
int det44_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
Definition: det44.c:195
vl_api_ip4_address_t out_addr
Definition: det44.api:139
#define vec_foreach(var, vec)
Vector iterator.
static void vl_api_det44_add_del_map_t_handler(vl_api_det44_add_del_map_t *mp)
Definition: det44_api.c:34
u32 ses_num
Definition: det44.h:123
static_always_inline snat_det_map_t * snat_det_map_by_user(ip4_address_t *user_addr)
Definition: det44.h:277
Get inside address from outside address and port.
Definition: det44.api:350
vl_api_ip4_address_t user_addr
Definition: det44.api:446
vl_api_ip4_address_t in_addr
Definition: det44.api:366
vl_api_ip4_address_t in_addr
Definition: det44.api:309
vl_api_ip4_address_t out_addr
Definition: det44.api:394
Set values of timeouts for DET44 sessions (seconds)
Definition: det44.api:255
Get outside address and port range from inside address.
Definition: det44.api:108
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
Enable/disable DET44 plugin.
Definition: det44.api:36
u32 icmp
Definition: lib.h:85
vl_api_ip4_address_t user_addr
Definition: det44.api:225
#define VALIDATE_SW_IF_INDEX(mp)