FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
nat44_ed_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Cisco and/or its affiliates.
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  * @file
18  * @brief NAT44 plugin API implementation
19  */
20 
21 #include <vnet/ip/ip_types_api.h>
22 #include <vlibmemory/api.h>
23 
24 #include <vnet/fib/fib_table.h>
25 
26 #include <nat/lib/nat_inlines.h>
27 #include <nat/lib/ipfix_logging.h>
28 
29 #include <nat/nat44-ed/nat44_ed.h>
30 
31 #include <nat/nat44-ed/nat44_ed.api_enum.h>
32 #include <nat/nat44-ed/nat44_ed.api_types.h>
33 
34 #define REPLY_MSG_ID_BASE sm->msg_id_base
36 
37 /* New API calls */
38 
39 static void
42 {
43  snat_main_t *sm = &snat_main;
44  nat44_config_t c = { 0 };
45  vl_api_nat44_ed_plugin_enable_disable_reply_t *rmp;
46  int rv = 0;
47 
48  if (mp->enable)
49  {
50  c.static_mapping_only = mp->flags & NAT44_API_IS_STATIC_MAPPING_ONLY;
51  c.connection_tracking = mp->flags & NAT44_API_IS_CONNECTION_TRACKING;
52 
53  c.inside_vrf = ntohl (mp->inside_vrf);
54  c.outside_vrf = ntohl (mp->outside_vrf);
55 
56  c.sessions = ntohl (mp->sessions);
57 
59  }
60  else
61  {
63  }
64 
65  REPLY_MACRO (VL_API_NAT44_ED_PLUGIN_ENABLE_DISABLE_REPLY);
66 }
67 
68 static void
70 {
71  snat_main_t *sm = &snat_main;
72  vl_api_nat44_ed_set_fq_options_reply_t *rmp;
73  int rv = 0;
74  u32 frame_queue_nelts = ntohl (mp->frame_queue_nelts);
75  rv = nat44_ed_set_frame_queue_nelts (frame_queue_nelts);
76  REPLY_MACRO (VL_API_NAT44_ED_SET_FQ_OPTIONS_REPLY);
77 }
78 
79 static void
82 {
83  snat_main_t *sm = &snat_main;
85  int rv = 0;
86  /* clang-format off */
87  REPLY_MACRO2_ZERO (VL_API_NAT44_ED_SHOW_FQ_OPTIONS_REPLY,
88  ({
89  rmp->frame_queue_nelts = htonl (sm->frame_queue_nelts);
90  }));
91  /* clang-format on */
92 }
93 
94 /* Old API calls hold back because of deprecation
95  * nat44_ed replacement should be used */
96 
97 static void
99 {
100  snat_main_t *sm = &snat_main;
101  vl_api_nat_set_workers_reply_t *rmp;
102  int rv = 0;
103  uword *bitmap = 0;
104  u64 mask;
105 
106  mask = clib_net_to_host_u64 (mp->worker_mask);
107 
108  if (sm->num_workers < 2)
109  {
110  rv = VNET_API_ERROR_FEATURE_DISABLED;
111  goto send_reply;
112  }
113 
114  bitmap = clib_bitmap_set_multiple (bitmap, 0, mask, BITS (mask));
115  rv = snat_set_workers (bitmap);
116  clib_bitmap_free (bitmap);
117 
118 send_reply:
119  REPLY_MACRO (VL_API_NAT_SET_WORKERS_REPLY);
120 }
121 
122 static void
124  u32 context)
125 {
127  snat_main_t *sm = &snat_main;
129  vlib_worker_threads + worker_index + sm->first_worker_index;
130 
131  rmp = vl_msg_api_alloc (sizeof (*rmp));
132  clib_memset (rmp, 0, sizeof (*rmp));
133  rmp->_vl_msg_id = ntohs (VL_API_NAT_WORKER_DETAILS + sm->msg_id_base);
134  rmp->context = context;
135  rmp->worker_index = htonl (worker_index);
136  rmp->lcore_id = htonl (w->cpu_id);
137  strncpy ((char *) rmp->name, (char *) w->name, ARRAY_LEN (rmp->name) - 1);
138 
139  vl_api_send_msg (reg, (u8 *) rmp);
140 }
141 
142 static void
144 {
146  snat_main_t *sm = &snat_main;
147  u32 *worker_index;
148 
150  if (!reg)
151  return;
152 
153  vec_foreach (worker_index, sm->workers)
154  {
155  send_nat_worker_details (*worker_index, reg, mp->context);
156  }
157 }
158 
159 static void
161  mp)
162 {
163  snat_main_t *sm = &snat_main;
164  vl_api_nat44_set_session_limit_reply_t *rmp;
165  int rv = 0;
166 
168  (ntohl (mp->session_limit), ntohl (mp->vrf_id));
169 
170  REPLY_MACRO (VL_API_NAT44_SET_SESSION_LIMIT_REPLY);
171 }
172 
173 static void
175 {
176  snat_main_t *sm = &snat_main;
177  vl_api_nat_set_log_level_reply_t *rmp;
178  int rv = 0;
179 
180  if (sm->log_level > NAT_LOG_DEBUG)
181  rv = VNET_API_ERROR_UNSUPPORTED;
182  else
183  sm->log_level = mp->log_level;
184 
185  REPLY_MACRO (VL_API_NAT_SET_WORKERS_REPLY);
186 }
187 
188 static void
190  mp)
191 {
192  snat_main_t *sm = &snat_main;
193  vl_api_nat_ipfix_enable_disable_reply_t *rmp;
194  int rv = 0;
195 
197  clib_host_to_net_u32
198  (mp->domain_id),
199  clib_host_to_net_u16 (mp->src_port));
200 
201  REPLY_MACRO (VL_API_NAT_IPFIX_ENABLE_DISABLE_REPLY);
202 }
203 
204 static void
206 {
207  snat_main_t *sm = &snat_main;
208  vl_api_nat_set_timeouts_reply_t *rmp;
209  int rv = 0;
210 
211  sm->timeouts.udp = ntohl (mp->udp);
212  sm->timeouts.tcp.established = ntohl (mp->tcp_established);
213  sm->timeouts.tcp.transitory = ntohl (mp->tcp_transitory);
214  sm->timeouts.icmp = ntohl (mp->icmp);
215 
216  REPLY_MACRO (VL_API_NAT_SET_TIMEOUTS_REPLY);
217 }
218 
219 static void
221 {
222  snat_main_t *sm = &snat_main;
224  int rv = 0;
225 
226  REPLY_MACRO2 (VL_API_NAT_GET_TIMEOUTS_REPLY,
227  ({
228  rmp->udp = htonl (sm->timeouts.udp);
229  rmp->tcp_established = htonl (sm->timeouts.tcp.established);
230  rmp->tcp_transitory = htonl (sm->timeouts.tcp.transitory);
231  rmp->icmp = htonl (sm->timeouts.icmp);
232  }))
233 }
234 
235 static void
237 {
238  snat_main_t *sm = &snat_main;
239  vl_api_nat_set_mss_clamping_reply_t *rmp;
240  int rv = 0;
241 
242  if (mp->enable)
243  sm->mss_clamping = ntohs (mp->mss_value);
244  else
245  sm->mss_clamping = 0;
246 
247  REPLY_MACRO (VL_API_NAT_SET_MSS_CLAMPING_REPLY);
248 }
249 
250 static void
252 {
253  snat_main_t *sm = &snat_main;
255  int rv = 0;
256 
257  REPLY_MACRO2 (VL_API_NAT_GET_MSS_CLAMPING_REPLY,
258  ({
259  rmp->enable = sm->mss_clamping ? 1 : 0;
260  rmp->mss_value = htons (sm->mss_clamping);
261  }))
262 }
263 
264 static void
267 {
268  snat_main_t *sm = &snat_main;
269  vl_api_nat44_add_del_address_range_reply_t *rmp;
270  ip4_address_t this_addr;
271  u8 is_add, twice_nat;
272  u32 start_host_order, end_host_order;
273  u32 vrf_id;
274  int i, count;
275  int rv = 0;
276  u32 *tmp;
277 
278  if (sm->static_mapping_only)
279  {
280  rv = VNET_API_ERROR_FEATURE_DISABLED;
281  goto send_reply;
282  }
283 
284  is_add = mp->is_add;
285  twice_nat = mp->flags & NAT_API_IS_TWICE_NAT;
286 
287  tmp = (u32 *) mp->first_ip_address;
288  start_host_order = clib_host_to_net_u32 (tmp[0]);
289  tmp = (u32 *) mp->last_ip_address;
290  end_host_order = clib_host_to_net_u32 (tmp[0]);
291 
292  count = (end_host_order - start_host_order) + 1;
293 
294  vrf_id = clib_host_to_net_u32 (mp->vrf_id);
295 
296  if (count > 1024)
297  nat_log_info ("%U - %U, %d addresses...",
300 
301  memcpy (&this_addr.as_u8, mp->first_ip_address, 4);
302 
303  for (i = 0; i < count; i++)
304  {
305  if (is_add)
306  rv = snat_add_address (sm, &this_addr, vrf_id, twice_nat);
307  else
308  rv = snat_del_address (sm, this_addr, 0, twice_nat);
309 
310  if (rv)
311  goto send_reply;
312 
313  increment_v4_address (&this_addr);
314  }
315 
316 send_reply:
317  REPLY_MACRO (VL_API_NAT44_ADD_DEL_ADDRESS_RANGE_REPLY);
318 }
319 
320 static void
323  u8 twice_nat)
324 {
326  snat_main_t *sm = &snat_main;
327 
328  rmp = vl_msg_api_alloc (sizeof (*rmp));
329  clib_memset (rmp, 0, sizeof (*rmp));
330  rmp->_vl_msg_id = ntohs (VL_API_NAT44_ADDRESS_DETAILS + sm->msg_id_base);
331  clib_memcpy (rmp->ip_address, &(a->addr), 4);
332  if (a->fib_index != ~0)
333  {
334  fib_table_t *fib = fib_table_get (a->fib_index, FIB_PROTOCOL_IP4);
335  rmp->vrf_id = ntohl (fib->ft_table_id);
336  }
337  else
338  rmp->vrf_id = ~0;
339  if (twice_nat)
340  rmp->flags |= NAT_API_IS_TWICE_NAT;
341  rmp->context = context;
342 
343  vl_api_send_msg (reg, (u8 *) rmp);
344 }
345 
346 static void
348 {
350  snat_main_t *sm = &snat_main;
351  snat_address_t *a;
352 
354  if (!reg)
355  return;
356 
357  vec_foreach (a, sm->addresses)
358  send_nat44_address_details (a, reg, mp->context, 0);
360  send_nat44_address_details (a, reg, mp->context, 1);
361 }
362 
363 static void
366 {
367  snat_main_t *sm = &snat_main;
368  vl_api_nat44_interface_add_del_feature_reply_t *rmp;
369  u32 sw_if_index = ntohl (mp->sw_if_index);
370  u8 is_del;
371  int rv = 0;
372 
373  is_del = !mp->is_add;
374 
376 
377  rv =
378  snat_interface_add_del (sw_if_index, mp->flags & NAT_API_IS_INSIDE,
379  is_del);
380 
382 
383  REPLY_MACRO (VL_API_NAT44_INTERFACE_ADD_DEL_FEATURE_REPLY);
384 }
385 
386 static void
389 {
391  snat_main_t *sm = &snat_main;
392 
393  rmp = vl_msg_api_alloc (sizeof (*rmp));
394  clib_memset (rmp, 0, sizeof (*rmp));
395  rmp->_vl_msg_id = ntohs (VL_API_NAT44_INTERFACE_DETAILS + sm->msg_id_base);
396  rmp->sw_if_index = ntohl (i->sw_if_index);
397 
399  rmp->flags |= NAT_API_IS_INSIDE;
401  rmp->flags |= NAT_API_IS_OUTSIDE;
402 
403  rmp->context = context;
404 
405  vl_api_send_msg (reg, (u8 *) rmp);
406 }
407 
408 static void
410 {
412  snat_main_t *sm = &snat_main;
414 
416  if (!reg)
417  return;
418 
419  pool_foreach (i, sm->interfaces)
420  {
422  }
423 }
424 
425 static void
428 {
429  snat_main_t *sm = &snat_main;
430  vl_api_nat44_interface_add_del_output_feature_reply_t *rmp;
431  u32 sw_if_index = ntohl (mp->sw_if_index);
432  int rv = 0;
433 
435 
437  mp->flags & NAT_API_IS_INSIDE,
438  !mp->is_add);
439 
441  REPLY_MACRO (VL_API_NAT44_INTERFACE_ADD_DEL_OUTPUT_FEATURE_REPLY);
442 }
443 
444 static void
446  vl_api_registration_t * reg,
447  u32 context)
448 {
450  snat_main_t *sm = &snat_main;
451 
452  rmp = vl_msg_api_alloc (sizeof (*rmp));
453  clib_memset (rmp, 0, sizeof (*rmp));
454  rmp->_vl_msg_id =
455  ntohs (VL_API_NAT44_INTERFACE_OUTPUT_FEATURE_DETAILS + sm->msg_id_base);
456  rmp->sw_if_index = ntohl (i->sw_if_index);
457  rmp->context = context;
458 
460  rmp->flags |= NAT_API_IS_INSIDE;
461 
462  vl_api_send_msg (reg, (u8 *) rmp);
463 }
464 
465 static void
468 {
470  snat_main_t *sm = &snat_main;
472 
474  if (!reg)
475  return;
476 
478  {
480  }
481 }
482 
483 static void
486 {
487  snat_main_t *sm = &snat_main;
488  vl_api_nat44_add_del_static_mapping_reply_t *rmp;
489  ip4_address_t local_addr, external_addr, pool_addr = { 0 };
490  u16 local_port = 0, external_port = 0;
491  u32 vrf_id, external_sw_if_index;
493  int rv = 0;
495  u8 *tag = 0;
496 
497  memcpy (&local_addr.as_u8, mp->local_ip_address, 4);
498  memcpy (&external_addr.as_u8, mp->external_ip_address, 4);
499 
500  if (!(mp->flags & NAT_API_IS_ADDR_ONLY))
501  {
502  local_port = mp->local_port;
503  external_port = mp->external_port;
504  }
505 
506  vrf_id = clib_net_to_host_u32 (mp->vrf_id);
507  external_sw_if_index = clib_net_to_host_u32 (mp->external_sw_if_index);
509 
510  if (mp->flags & NAT_API_IS_TWICE_NAT)
511  twice_nat = TWICE_NAT;
512  else if (mp->flags & NAT_API_IS_SELF_TWICE_NAT)
513  twice_nat = TWICE_NAT_SELF;
514  mp->tag[sizeof (mp->tag) - 1] = 0;
515  tag = format (0, "%s", mp->tag);
517 
519  local_addr, external_addr, local_port, external_port, vrf_id,
520  mp->flags & NAT_API_IS_ADDR_ONLY, external_sw_if_index, proto, mp->is_add,
521  twice_nat, mp->flags & NAT_API_IS_OUT2IN_ONLY, tag, 0, pool_addr, 0);
522  vec_free (tag);
523 
524  REPLY_MACRO (VL_API_NAT44_ADD_DEL_STATIC_MAPPING_REPLY);
525 }
526 
527 static void
530 {
531  snat_main_t *sm = &snat_main;
532  vl_api_nat44_add_del_static_mapping_v2_reply_t *rmp;
533  ip4_address_t local_addr, external_addr, pool_addr;
534  u16 local_port = 0, external_port = 0;
535  u32 vrf_id, external_sw_if_index;
537  int rv = 0;
539  u8 *tag = 0;
540 
541  memcpy (&pool_addr.as_u8, mp->pool_ip_address, 4);
542  memcpy (&local_addr.as_u8, mp->local_ip_address, 4);
543  memcpy (&external_addr.as_u8, mp->external_ip_address, 4);
544 
545  if (!(mp->flags & NAT_API_IS_ADDR_ONLY))
546  {
547  local_port = mp->local_port;
548  external_port = mp->external_port;
549  }
550 
551  vrf_id = clib_net_to_host_u32 (mp->vrf_id);
552  external_sw_if_index = clib_net_to_host_u32 (mp->external_sw_if_index);
554 
555  if (mp->flags & NAT_API_IS_TWICE_NAT)
556  twice_nat = TWICE_NAT;
557  else if (mp->flags & NAT_API_IS_SELF_TWICE_NAT)
558  twice_nat = TWICE_NAT_SELF;
559  mp->tag[sizeof (mp->tag) - 1] = 0;
560  tag = format (0, "%s", mp->tag);
562 
563  rv = snat_add_static_mapping (local_addr, external_addr, local_port,
564  external_port, vrf_id,
565  mp->flags & NAT_API_IS_ADDR_ONLY,
566  external_sw_if_index, proto,
567  mp->is_add, twice_nat,
568  mp->flags & NAT_API_IS_OUT2IN_ONLY, tag, 0,
569  pool_addr, mp->match_pool);
570  vec_free (tag);
571 
572  REPLY_MACRO (VL_API_NAT44_ADD_DEL_STATIC_MAPPING_V2_REPLY);
573 }
574 
575 static void
578 {
580  snat_main_t *sm = &snat_main;
581  u32 len = sizeof (*rmp);
582 
583  rmp = vl_msg_api_alloc (len);
584  clib_memset (rmp, 0, len);
585  rmp->_vl_msg_id =
586  ntohs (VL_API_NAT44_STATIC_MAPPING_DETAILS + sm->msg_id_base);
587 
588  clib_memcpy (rmp->local_ip_address, &(m->local_addr), 4);
590  rmp->external_sw_if_index = ~0;
591  rmp->vrf_id = htonl (m->vrf_id);
592  rmp->context = context;
593 
594  if (m->twice_nat == TWICE_NAT)
595  rmp->flags |= NAT_API_IS_TWICE_NAT;
596  else if (m->twice_nat == TWICE_NAT_SELF)
597  rmp->flags |= NAT_API_IS_SELF_TWICE_NAT;
598 
600  rmp->flags |= NAT_API_IS_OUT2IN_ONLY;
601 
603  {
604  rmp->flags |= NAT_API_IS_ADDR_ONLY;
605  }
606  else
607  {
609  rmp->external_port = m->external_port;
610  rmp->local_port = m->local_port;
611  }
612 
613  if (m->tag)
614  strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
615 
616  vl_api_send_msg (reg, (u8 *) rmp);
617 }
618 
619 static void
621  vl_api_registration_t * reg,
622  u32 context)
623 {
625  snat_main_t *sm = &snat_main;
626 
627  rmp = vl_msg_api_alloc (sizeof (*rmp));
628  clib_memset (rmp, 0, sizeof (*rmp));
629  rmp->_vl_msg_id =
630  ntohs (VL_API_NAT44_STATIC_MAPPING_DETAILS + sm->msg_id_base);
631  clib_memcpy (rmp->local_ip_address, &(m->l_addr), 4);
632  rmp->external_sw_if_index = htonl (m->sw_if_index);
633  rmp->vrf_id = htonl (m->vrf_id);
634  rmp->context = context;
635 
636  if (m->twice_nat)
637  rmp->flags |= NAT_API_IS_TWICE_NAT;
638 
639  if (m->addr_only)
640  {
641  rmp->flags |= NAT_API_IS_ADDR_ONLY;
642  }
643  else
644  {
646  rmp->external_port = m->e_port;
647  rmp->local_port = m->l_port;
648  }
649  if (m->tag)
650  strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
651 
652  vl_api_send_msg (reg, (u8 *) rmp);
653 }
654 
655 static void
657  * mp)
658 {
660  snat_main_t *sm = &snat_main;
663  int j;
664 
666  if (!reg)
667  return;
668 
670  {
673  }
674 
675  for (j = 0; j < vec_len (sm->to_resolve); j++)
676  {
677  rp = sm->to_resolve + j;
678  if (!rp->identity_nat)
680  }
681 }
682 
683 static void
686 {
687  snat_main_t *sm = &snat_main;
688  vl_api_nat44_add_del_identity_mapping_reply_t *rmp;
689  ip4_address_t addr, pool_addr = { 0 };
690  u16 port = 0;
692  int rv = 0;
693  nat_protocol_t proto = NAT_PROTOCOL_OTHER;
694  u8 *tag = 0;
695 
696  if (!(mp->flags & NAT_API_IS_ADDR_ONLY))
697  {
698  port = mp->port;
700  }
701  vrf_id = clib_net_to_host_u32 (mp->vrf_id);
702  sw_if_index = clib_net_to_host_u32 (mp->sw_if_index);
703  if (sw_if_index != ~0)
704  addr.as_u32 = 0;
705  else
706  memcpy (&addr.as_u8, mp->ip_address, 4);
707  mp->tag[sizeof (mp->tag) - 1] = 0;
708  tag = format (0, "%s", mp->tag);
710 
711  rv =
713  mp->flags & NAT_API_IS_ADDR_ONLY, sw_if_index,
714  proto, mp->is_add, 0, 0, tag, 1, pool_addr, 0);
715  vec_free (tag);
716 
717  REPLY_MACRO (VL_API_NAT44_ADD_DEL_IDENTITY_MAPPING_REPLY);
718 }
719 
720 static void
723 {
725  snat_main_t *sm = &snat_main;
727 
728  rmp = vl_msg_api_alloc (sizeof (*rmp));
729  clib_memset (rmp, 0, sizeof (*rmp));
730  rmp->_vl_msg_id =
731  ntohs (VL_API_NAT44_IDENTITY_MAPPING_DETAILS + sm->msg_id_base);
732 
734  rmp->flags |= NAT_API_IS_ADDR_ONLY;
735 
736  clib_memcpy (rmp->ip_address, &(m->local_addr), 4);
737  rmp->port = m->local_port;
738  rmp->sw_if_index = ~0;
739  rmp->vrf_id = htonl (local->vrf_id);
741  rmp->context = context;
742  if (m->tag)
743  strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
744 
745  vl_api_send_msg (reg, (u8 *) rmp);
746 }
747 
748 static void
750  vl_api_registration_t * reg,
751  u32 context)
752 {
754  snat_main_t *sm = &snat_main;
755 
756  rmp = vl_msg_api_alloc (sizeof (*rmp));
757  clib_memset (rmp, 0, sizeof (*rmp));
758  rmp->_vl_msg_id =
759  ntohs (VL_API_NAT44_IDENTITY_MAPPING_DETAILS + sm->msg_id_base);
760 
761  if (m->addr_only)
762  rmp->flags = (vl_api_nat_config_flags_t) NAT_API_IS_ADDR_ONLY;
763 
764  rmp->port = m->l_port;
765  rmp->sw_if_index = htonl (m->sw_if_index);
766  rmp->vrf_id = htonl (m->vrf_id);
768  rmp->context = context;
769  if (m->tag)
770  strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
771 
772  vl_api_send_msg (reg, (u8 *) rmp);
773 }
774 
775 static void
778 {
780  snat_main_t *sm = &snat_main;
783  int j;
784 
786  if (!reg)
787  return;
788 
790  {
792  {
793  pool_foreach_index (j, m->locals)
794  {
796  }
797  }
798  }
799 
800  for (j = 0; j < vec_len (sm->to_resolve); j++)
801  {
802  rp = sm->to_resolve + j;
803  if (rp->identity_nat)
805  }
806 }
807 
808 static void
811 {
812  snat_main_t *sm = &snat_main;
813  vl_api_nat44_add_del_interface_addr_reply_t *rmp;
814  u32 sw_if_index = ntohl (mp->sw_if_index);
815  int rv = 0;
816  u8 is_del;
817 
818  if (sm->static_mapping_only)
819  {
820  rv = VNET_API_ERROR_FEATURE_DISABLED;
821  goto send_reply;
822  }
823 
824  is_del = !mp->is_add;
825 
827 
829  mp->flags & NAT_API_IS_TWICE_NAT);
830 
832 
833 send_reply:
834  REPLY_MACRO (VL_API_NAT44_ADD_DEL_INTERFACE_ADDR_REPLY);
835 }
836 
837 static void
840  u8 twice_nat)
841 {
843  snat_main_t *sm = &snat_main;
844 
845  rmp = vl_msg_api_alloc (sizeof (*rmp));
846  clib_memset (rmp, 0, sizeof (*rmp));
847  rmp->_vl_msg_id =
848  ntohs (VL_API_NAT44_INTERFACE_ADDR_DETAILS + sm->msg_id_base);
849  rmp->sw_if_index = ntohl (sw_if_index);
850 
851  if (twice_nat)
852  rmp->flags = (vl_api_nat_config_flags_t) NAT_API_IS_TWICE_NAT;
853  rmp->context = context;
854 
855  vl_api_send_msg (reg, (u8 *) rmp);
856 }
857 
858 static void
860  * mp)
861 {
863  snat_main_t *sm = &snat_main;
864  u32 *i;
865 
867  if (!reg)
868  return;
869 
871  {
873  }
875  {
877  }
878 }
879 
880 static nat44_lb_addr_port_t *
881 unformat_nat44_lb_addr_port (vl_api_nat44_lb_addr_port_t *addr_port_pairs,
882  u32 addr_port_pair_num)
883 {
884  u8 i;
885  nat44_lb_addr_port_t *lb_addr_port_pairs = 0, lb_addr_port;
886  vl_api_nat44_lb_addr_port_t *ap;
887 
888  for (i = 0; i < addr_port_pair_num; i++)
889  {
890  ap = &addr_port_pairs[i];
891  clib_memset (&lb_addr_port, 0, sizeof (lb_addr_port));
892  clib_memcpy (&lb_addr_port.addr, ap->addr, 4);
893  lb_addr_port.port = ap->port;
894  lb_addr_port.probability = ap->probability;
895  lb_addr_port.vrf_id = clib_net_to_host_u32 (ap->vrf_id);
896  vec_add1 (lb_addr_port_pairs, lb_addr_port);
897  }
898 
899  return lb_addr_port_pairs;
900 }
901 
902 static void
905 {
906  snat_main_t *sm = &snat_main;
907  vl_api_nat44_add_del_lb_static_mapping_reply_t *rmp;
909  int rv = 0;
910  nat44_lb_addr_port_t *locals = 0;
911  ip4_address_t e_addr;
913  u8 *tag = 0;
914 
915  locals = unformat_nat44_lb_addr_port (mp->locals,
916  clib_net_to_host_u32 (mp->local_num));
917  clib_memcpy (&e_addr, mp->external_addr, 4);
919 
920  if (mp->flags & NAT_API_IS_TWICE_NAT)
921  twice_nat = TWICE_NAT;
922  else if (mp->flags & NAT_API_IS_SELF_TWICE_NAT)
923  twice_nat = TWICE_NAT_SELF;
924  mp->tag[sizeof (mp->tag) - 1] = 0;
925  tag = format (0, "%s", mp->tag);
927 
929  e_addr, mp->external_port, proto, locals, mp->is_add, twice_nat,
930  mp->flags & NAT_API_IS_OUT2IN_ONLY, tag,
931  clib_net_to_host_u32 (mp->affinity));
932 
933  vec_free (locals);
934  vec_free (tag);
935  REPLY_MACRO (VL_API_NAT44_ADD_DEL_LB_STATIC_MAPPING_REPLY);
936 }
937 
938 static void
941 {
942  snat_main_t *sm = &snat_main;
943  vl_api_nat44_lb_static_mapping_add_del_local_reply_t *rmp;
944  int rv = 0;
945  ip4_address_t e_addr, l_addr;
947 
948  clib_memcpy (&e_addr, mp->external_addr, 4);
949  clib_memcpy (&l_addr, mp->local.addr, 4);
951 
953  e_addr, mp->external_port, l_addr, mp->local.port, proto,
954  clib_net_to_host_u32 (mp->local.vrf_id), mp->local.probability,
955  mp->is_add);
956 
957  REPLY_MACRO (VL_API_NAT44_LB_STATIC_MAPPING_ADD_DEL_LOCAL_REPLY);
958 }
959 
960 static void
963 {
965  snat_main_t *sm = &snat_main;
967  vl_api_nat44_lb_addr_port_t *locals;
968  u32 local_num = 0;
969 
970  rmp = vl_msg_api_alloc (
971  sizeof (*rmp) + (pool_elts (m->locals) * sizeof (nat44_lb_addr_port_t)));
972  clib_memset (rmp, 0, sizeof (*rmp));
973  rmp->_vl_msg_id =
974  ntohs (VL_API_NAT44_LB_STATIC_MAPPING_DETAILS + sm->msg_id_base);
975 
976  clib_memcpy (rmp->external_addr, &(m->external_addr), 4);
977  rmp->external_port = m->external_port;
979  rmp->context = context;
980 
981  if (m->twice_nat == TWICE_NAT)
982  rmp->flags |= NAT_API_IS_TWICE_NAT;
983  else if (m->twice_nat == TWICE_NAT_SELF)
984  rmp->flags |= NAT_API_IS_SELF_TWICE_NAT;
986  rmp->flags |= NAT_API_IS_OUT2IN_ONLY;
987  if (m->tag)
988  strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
989 
990  locals = (vl_api_nat44_lb_addr_port_t *) rmp->locals;
991  pool_foreach (ap, m->locals)
992  {
993  clib_memcpy (locals->addr, &(ap->addr), 4);
994  locals->port = ap->port;
995  locals->probability = ap->probability;
996  locals->vrf_id = ntohl (ap->vrf_id);
997  locals++;
998  local_num++;
999  }
1000  rmp->local_num = ntohl (local_num);
1001 
1002  vl_api_send_msg (reg, (u8 *) rmp);
1003 }
1004 
1005 static void
1008 {
1009  vl_api_registration_t *reg;
1010  snat_main_t *sm = &snat_main;
1012 
1014  if (!reg)
1015  return;
1016 
1017  pool_foreach (m, sm->static_mappings)
1018  {
1019  if (is_lb_static_mapping (m))
1021  }
1022 }
1023 
1024 static void
1026 {
1027  snat_main_t *sm = &snat_main;
1028  vl_api_nat44_del_session_reply_t *rmp;
1029  ip4_address_t addr, eh_addr;
1030  u16 port, eh_port;
1031  u32 vrf_id;
1032  int rv = 0;
1033  u8 is_in;
1034 
1035  memcpy (&addr.as_u8, mp->address, 4);
1036  port = mp->port;
1037  vrf_id = clib_net_to_host_u32 (mp->vrf_id);
1038  memcpy (&eh_addr.as_u8, mp->ext_host_address, 4);
1039  eh_port = mp->ext_host_port;
1040 
1041  is_in = mp->flags & NAT_API_IS_INSIDE;
1042 
1043  rv = nat44_del_ed_session (sm, &addr, port, &eh_addr, eh_port, mp->protocol,
1044  vrf_id, is_in);
1045 
1046  REPLY_MACRO (VL_API_NAT44_DEL_SESSION_REPLY);
1047 }
1048 
1049 static void
1052 {
1053  vl_api_nat44_forwarding_enable_disable_reply_t *rmp;
1054  snat_main_t *sm = &snat_main;
1055  int rv = 0;
1057  REPLY_MACRO (VL_API_NAT44_FORWARDING_ENABLE_DISABLE_REPLY);
1058 }
1059 
1060 static void
1063 {
1064  vl_api_registration_t *reg;
1065  snat_main_t *sm = &snat_main;
1067 
1069  if (!reg)
1070  return;
1071 
1072  rmp = vl_msg_api_alloc (sizeof (*rmp));
1073  clib_memset (rmp, 0, sizeof (*rmp));
1074  rmp->_vl_msg_id =
1075  ntohs (VL_API_NAT44_FORWARDING_IS_ENABLED_REPLY + sm->msg_id_base);
1076  rmp->context = mp->context;
1077 
1078  rmp->enabled = sm->forwarding_enabled;
1079 
1080  vl_api_send_msg (reg, (u8 *) rmp);
1081 }
1082 
1083 /* Obsolete calls hold back because of deprecation
1084  * should not be used */
1085 
1086 static void
1089 {
1090  snat_main_t *sm = &snat_main;
1091  vl_api_nat_set_addr_and_port_alloc_alg_reply_t *rmp;
1092  int rv = VNET_API_ERROR_UNSUPPORTED;
1093  REPLY_MACRO (VL_API_NAT_SET_ADDR_AND_PORT_ALLOC_ALG_REPLY);
1094 }
1095 
1096 static void
1099 {
1100  snat_main_t *sm = &snat_main;
1102  int rv = VNET_API_ERROR_UNSUPPORTED;
1103  REPLY_MACRO (VL_API_NAT_GET_ADDR_AND_PORT_ALLOC_ALG_REPLY);
1104 }
1105 
1106 static void
1108 {
1109  snat_main_t *sm = &snat_main;
1110  vl_api_nat_ha_set_listener_reply_t *rmp;
1111  int rv = VNET_API_ERROR_UNSUPPORTED;
1112  REPLY_MACRO (VL_API_NAT_HA_SET_LISTENER_REPLY);
1113 }
1114 
1115 static void
1117 {
1118  snat_main_t *sm = &snat_main;
1120  int rv = VNET_API_ERROR_UNSUPPORTED;
1121  REPLY_MACRO (VL_API_NAT_HA_GET_LISTENER_REPLY);
1122 }
1123 
1124 static void
1126 {
1127  snat_main_t *sm = &snat_main;
1128  vl_api_nat_ha_set_failover_reply_t *rmp;
1129  int rv = VNET_API_ERROR_UNSUPPORTED;
1130  REPLY_MACRO (VL_API_NAT_HA_SET_FAILOVER_REPLY);
1131 }
1132 
1133 static void
1135 {
1136  snat_main_t *sm = &snat_main;
1138  int rv = VNET_API_ERROR_UNSUPPORTED;
1139  REPLY_MACRO (VL_API_NAT_HA_GET_FAILOVER_REPLY);
1140 }
1141 
1142 static void
1144 {
1145  snat_main_t *sm = &snat_main;
1146  vl_api_nat_ha_flush_reply_t *rmp;
1147  int rv = VNET_API_ERROR_UNSUPPORTED;
1148  REPLY_MACRO (VL_API_NAT_HA_FLUSH_REPLY);
1149 }
1150 
1151 static void
1153 {
1154  snat_main_t *sm = &snat_main;
1155  vl_api_nat_ha_resync_reply_t *rmp;
1156  int rv = VNET_API_ERROR_UNSUPPORTED;
1157  REPLY_MACRO (VL_API_NAT_HA_RESYNC_REPLY);
1158 }
1159 
1160 static void
1162 {
1163  snat_main_t *sm = &snat_main;
1164  vl_api_nat44_del_user_reply_t *rmp;
1165  int rv = VNET_API_ERROR_UNSUPPORTED;
1166  REPLY_MACRO (VL_API_NAT44_DEL_USER_REPLY);
1167 }
1168 
1169 static void
1171 {
1172  snat_main_t *sm = &snat_main;
1173  vl_api_nat44_session_cleanup_reply_t *rmp;
1174  int rv = VNET_API_ERROR_UNSUPPORTED;
1175  REPLY_MACRO (VL_API_NAT44_SESSION_CLEANUP_REPLY);
1176 }
1177 
1178 static void
1181 {
1182  snat_main_t *sm = &snat_main;
1183  nat44_config_t c = { 0 };
1184  vl_api_nat44_plugin_enable_disable_reply_t *rmp;
1185  int rv = 0;
1186 
1187  if (mp->enable)
1188  {
1189  if (!(mp->flags & NAT44_API_IS_ENDPOINT_DEPENDENT) ||
1190  (mp->flags & NAT44_API_IS_OUT2IN_DPO) || mp->users ||
1191  mp->user_sessions)
1192  {
1193  rv = VNET_API_ERROR_UNSUPPORTED;
1194  }
1195  else
1196  {
1197  c.static_mapping_only = mp->flags & NAT44_API_IS_STATIC_MAPPING_ONLY;
1198  c.connection_tracking = mp->flags & NAT44_API_IS_CONNECTION_TRACKING;
1199 
1200  c.inside_vrf = ntohl (mp->inside_vrf);
1201  c.outside_vrf = ntohl (mp->outside_vrf);
1202 
1203  c.sessions = ntohl (mp->sessions);
1204 
1205  rv = nat44_plugin_enable (c);
1206  }
1207  }
1208  else
1209  {
1210  rv = nat44_plugin_disable ();
1211  }
1212 
1213  REPLY_MACRO (VL_API_NAT44_PLUGIN_ENABLE_DISABLE_REPLY);
1214 }
1215 
1216 static void
1218 {
1220  snat_main_t *sm = &snat_main;
1221  int rv = 0;
1222 
1223  REPLY_MACRO2 (VL_API_NAT_CONTROL_PING_REPLY,
1224  ({ rmp->vpe_pid = ntohl (getpid ()); }));
1225 }
1226 
1227 static void
1229 {
1231  snat_main_t *sm = &snat_main;
1232  int rv = 0;
1233 
1234  REPLY_MACRO2_ZERO (VL_API_NAT_SHOW_CONFIG_REPLY, ({
1235  rmp->translation_buckets =
1236  htonl (sm->translation_buckets);
1237  rmp->user_buckets = 0;
1238  rmp->max_translations_per_user = 0;
1239  rmp->outside_vrf_id = htonl (sm->outside_vrf_id);
1240  rmp->inside_vrf_id = htonl (sm->inside_vrf_id);
1244  rmp->endpoint_dependent = 1;
1245  rmp->out2in_dpo = 0;
1246  }));
1247 }
1248 
1249 static void
1251 {
1253  snat_main_t *sm = &snat_main;
1254  int rv = 0;
1255 
1257  VL_API_NAT_SHOW_CONFIG_2_REPLY, ({
1258  rmp->translation_buckets = htonl (sm->translation_buckets);
1259  rmp->user_buckets = 0;
1260  rmp->max_translations_per_user = 0;
1261  rmp->outside_vrf_id = htonl (sm->outside_vrf_id);
1262  rmp->inside_vrf_id = htonl (sm->inside_vrf_id);
1266  rmp->endpoint_dependent = 1;
1267  rmp->out2in_dpo = 0;
1269  clib_net_to_host_u32 (sm->max_translations_per_thread);
1270  rmp->max_users_per_thread = 0;
1271  }));
1272 }
1273 
1274 static void
1277 {
1279  snat_main_t *sm = &snat_main;
1280  nat44_config_t *rc = &sm->rconfig;
1281  int rv = 0;
1282 
1284  VL_API_NAT44_SHOW_RUNNING_CONFIG_REPLY, ({
1285  rmp->inside_vrf = htonl (rc->inside_vrf);
1286  rmp->outside_vrf = htonl (rc->outside_vrf);
1287 
1288  rmp->sessions = htonl (rc->sessions);
1289  rmp->translation_buckets = htonl (sm->translation_buckets);
1290 
1291  // OBSOLETE
1292  rmp->users = 0;
1293  rmp->user_buckets = 0;
1294  rmp->user_sessions = 0;
1295 
1296  rmp->timeouts.udp = htonl (sm->timeouts.udp);
1297  rmp->timeouts.tcp_established = htonl (sm->timeouts.tcp.established);
1298  rmp->timeouts.tcp_transitory = htonl (sm->timeouts.tcp.transitory);
1299  rmp->timeouts.icmp = htonl (sm->timeouts.icmp);
1300 
1301  rmp->forwarding_enabled = sm->forwarding_enabled == 1;
1302  // consider how to split functionality between subplugins
1305  if (rc->static_mapping_only)
1307  if (rc->connection_tracking)
1309  }));
1310 }
1311 
1312 /* user (internal host) key */
1313 typedef struct
1314 {
1315  union
1316  {
1317  struct
1318  {
1321  };
1323  };
1324 } snat_user_key_t;
1325 
1326 typedef struct
1327 {
1332 } snat_user_t;
1333 
1334 typedef struct
1335 {
1338  clib_bihash_8_8_t user_hash;
1340 
1341 static void
1343  u32 context)
1344 {
1346  snat_main_t *sm = &snat_main;
1347  ip4_main_t *im = &ip4_main;
1348 
1349  rmp = vl_msg_api_alloc (sizeof (*rmp));
1350  clib_memset (rmp, 0, sizeof (*rmp));
1351  rmp->_vl_msg_id = ntohs (VL_API_NAT44_USER_DETAILS + sm->msg_id_base);
1352 
1353  if (!pool_is_free_index (im->fibs, u->fib_index))
1354  {
1356  rmp->vrf_id = ntohl (fib->ft_table_id);
1357  }
1358 
1359  clib_memcpy (rmp->ip_address, &(u->addr), 4);
1360  rmp->nsessions = ntohl (u->nsessions);
1361  rmp->nstaticsessions = ntohl (u->nstaticsessions);
1362  rmp->context = context;
1363 
1364  vl_api_send_msg (reg, (u8 *) rmp);
1365 }
1366 
1367 static void
1369 {
1370  snat_user_key_t k;
1371  k.addr = s->in2out.addr;
1372  k.fib_index = s->in2out.fib_index;
1374  key.key = k.as_u64;
1375  snat_user_t *u;
1376 
1377  if (clib_bihash_search_8_8 (&uch->user_hash, &key, &value))
1378  {
1379  pool_get (uch->users, u);
1380  u->addr = k.addr;
1381  u->fib_index = k.fib_index;
1382  u->nsessions = 0;
1383  u->nstaticsessions = 0;
1384  key.value = u - uch->users;
1385  clib_bihash_add_del_8_8 (&uch->user_hash, &key, 1);
1386  }
1387  else
1388  {
1389  u = pool_elt_at_index (uch->users, value.value);
1390  }
1391  if (snat_is_session_static (s))
1392  {
1393  ++u->nstaticsessions;
1394  }
1395  else
1396  {
1397  ++u->nsessions;
1398  }
1399 }
1400 
1401 u8 *
1402 format_user_kvp (u8 *s, va_list *args)
1403 {
1404  clib_bihash_kv_8_8_t *v = va_arg (*args, clib_bihash_kv_8_8_t *);
1405  snat_user_key_t k;
1406  k.as_u64 = v->key;
1407  s = format (s, "%U fib %d user-index %llu", format_ip4_address, &k.addr,
1408  k.fib_index, v->value);
1409  return s;
1410 }
1411 
1412 static void
1414  user_create_helper_t *uch)
1415 {
1416  snat_session_t *s;
1417  clib_bihash_init_8_8 (&uch->user_hash, "users", uch->user_buckets, 0);
1418  clib_bihash_set_kvp_format_fn_8_8 (&uch->user_hash, format_user_kvp);
1419  pool_foreach (s, tsm->sessions)
1420  {
1421  nat_ed_user_create_helper (uch, s);
1422  }
1423 }
1424 
1425 static void
1427 {
1428  pool_free (uch->users);
1429  clib_bihash_free_8_8 (&uch->user_hash);
1430 }
1431 
1432 static void
1434 {
1436  vl_api_registration_t *reg;
1437  snat_main_t *sm = &snat_main;
1439  snat_user_t *u;
1440 
1441  clib_memset (&uch, 0, sizeof (uch));
1442 
1444 
1446  if (!reg)
1447  return;
1448 
1449  vec_foreach (tsm, sm->per_thread_data)
1450  {
1451  nat_ed_users_create (tsm, &uch);
1452  pool_foreach (u, uch.users)
1453  {
1454  send_nat44_user_details (u, reg, mp->context);
1455  }
1456  nat_ed_users_destroy (&uch);
1457  }
1458 }
1459 
1460 static void
1463 {
1465  snat_main_t *sm = &snat_main;
1466 
1467  rmp = vl_msg_api_alloc (sizeof (*rmp));
1468  clib_memset (rmp, 0, sizeof (*rmp));
1469  rmp->_vl_msg_id =
1470  ntohs (VL_API_NAT44_USER_SESSION_DETAILS + sm->msg_id_base);
1471  clib_memcpy (rmp->outside_ip_address, (&s->out2in.addr), 4);
1472  clib_memcpy (rmp->inside_ip_address, (&s->in2out.addr), 4);
1473 
1474  if (snat_is_session_static (s))
1475  rmp->flags |= NAT_API_IS_STATIC;
1476 
1477  if (is_twice_nat_session (s))
1478  rmp->flags |= NAT_API_IS_TWICE_NAT;
1479 
1480  if (is_ed_session (s) || is_fwd_bypass_session (s))
1481  rmp->flags |= NAT_API_IS_EXT_HOST_VALID;
1482 
1483  rmp->last_heard = clib_host_to_net_u64 ((u64) s->last_heard);
1484  rmp->total_bytes = clib_host_to_net_u64 (s->total_bytes);
1485  rmp->total_pkts = ntohl (s->total_pkts);
1486  rmp->context = context;
1487  if (snat_is_unk_proto_session (s))
1488  {
1489  rmp->outside_port = 0;
1490  rmp->inside_port = 0;
1491  rmp->protocol = ntohs (s->in2out.port);
1492  }
1493  else
1494  {
1495  rmp->outside_port = s->out2in.port;
1496  rmp->inside_port = s->in2out.port;
1497  rmp->protocol = ntohs (nat_proto_to_ip_proto (s->nat_proto));
1498  }
1499  if (is_ed_session (s) || is_fwd_bypass_session (s))
1500  {
1501  clib_memcpy (rmp->ext_host_address, &s->ext_host_addr, 4);
1502  rmp->ext_host_port = s->ext_host_port;
1503  if (is_twice_nat_session (s))
1504  {
1505  clib_memcpy (rmp->ext_host_nat_address, &s->ext_host_nat_addr, 4);
1506  rmp->ext_host_nat_port = s->ext_host_nat_port;
1507  }
1508  }
1509 
1510  vl_api_send_msg (reg, (u8 *) rmp);
1511 }
1512 
1513 static void
1515  mp)
1516 {
1518  snat_main_t *sm = &snat_main;
1519  vl_api_registration_t *reg;
1520  snat_user_key_t ukey;
1521  snat_session_t *s;
1522  ip4_header_t ip;
1523 
1525  if (!reg)
1526  return;
1527 
1528  clib_memcpy (&ukey.addr, mp->ip_address, 4);
1529  ip.src_address.as_u32 = ukey.addr.as_u32;
1530  ukey.fib_index = fib_table_find (FIB_PROTOCOL_IP4, ntohl (mp->vrf_id));
1531  if (sm->num_workers > 1)
1532  tsm = vec_elt_at_index (
1533  sm->per_thread_data,
1535  else
1536  tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers);
1537 
1538  pool_foreach (s, tsm->sessions) {
1539  if (s->in2out.addr.as_u32 == ukey.addr.as_u32)
1540  {
1542  }
1543  }
1544 }
1545 
1546 /* API definitions */
1547 #include <vnet/format_fns.h>
1548 #include <nat/nat44-ed/nat44_ed.api.c>
1549 
1550 /* Set up the API message handling tables */
1551 clib_error_t *
1553 {
1554  snat_main_t *sm = &snat_main;
1556  return 0;
1557 }
1558 
1559 /*
1560  * fd.io coding-style-patch-verification: ON
1561  *
1562  * Local Variables:
1563  * eval: (c-set-style "gnu")
1564  * End:
1565  */
snat_main_s::to_resolve
snat_static_map_resolve_t * to_resolve
Definition: nat44_ed.h:569
tmp
u32 * tmp
Definition: interface_output.c:1078
vl_api_nat44_add_del_interface_addr_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:944
nat_ipfix_logging_enabled
int nat_ipfix_logging_enabled()
Definition: ipfix_logging.c:1269
vl_api_nat44_show_running_config_reply_t::timeouts
vl_api_nat_timeouts_t timeouts
Definition: nat44_ed.api:282
vl_api_nat44_user_session_dump_t::context
u32 context
Definition: nat44_ed.api:1000
vl_api_nat44_interface_add_del_output_feature_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:735
vl_api_nat44_interface_output_feature_dump_t::client_index
u32 client_index
Definition: nat44_ed.api:744
snat_set_workers
int snat_set_workers(uword *bitmap)
Set NAT plugin workers.
Definition: nat44_ed.c:1759
vl_api_nat44_lb_static_mapping_details_t::local_num
u32 local_num
Definition: nat44_ed.api:1140
im
vnet_interface_main_t * im
Definition: interface_output.c:395
vl_api_nat_show_config_2_t_handler
static void vl_api_nat_show_config_2_t_handler(vl_api_nat_show_config_2_t *mp)
Definition: nat44_ed_api.c:1250
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition: api_helper_macros.h:281
vl_api_nat44_user_session_dump_t::client_index
u32 client_index
Definition: nat44_ed.api:999
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_nat44_add_del_identity_mapping_t::protocol
u8 protocol
Definition: nat44_ed.api:895
api.h
unformat_nat44_lb_addr_port
static nat44_lb_addr_port_t * unformat_nat44_lb_addr_port(vl_api_nat44_lb_addr_port_t *addr_port_pairs, u32 addr_port_pair_num)
Definition: nat44_ed_api.c:881
nat_timeouts_t::udp
u32 udp
Definition: lib.h:84
vl_api_nat_show_config_reply_t::inside_vrf_id
u32 inside_vrf_id
Definition: nat44_ed.api:171
vl_api_nat44_ed_plugin_enable_disable_t::sessions
u32 sessions
Definition: nat44_ed.api:90
snat_static_mapping_t::locals
nat44_lb_addr_port_t * locals
Definition: nat44_ed.h:434
snat_main_s::outside_vrf_id
u32 outside_vrf_id
Definition: nat44_ed.h:600
vl_api_nat_control_ping_reply_t::vpe_pid
u32 vpe_pid
Definition: nat44_ed.api:119
nat_timeouts_t::icmp
u32 icmp
Definition: lib.h:85
send_nat44_address_details
static void send_nat44_address_details(snat_address_t *a, vl_api_registration_t *reg, u32 context, u8 twice_nat)
Definition: nat44_ed_api.c:321
vl_api_nat44_user_details_t::context
u32 context
Definition: nat44_ed.api:985
snat_main_s::static_mappings
snat_static_mapping_t * static_mappings
Definition: nat44_ed.h:528
vl_api_nat44_interface_details_t::context
u32 context
Definition: nat44_ed.api:717
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
vl_api_nat44_lb_static_mapping_details_t::protocol
u8 protocol
Definition: nat44_ed.api:1136
vl_api_nat44_set_session_limit_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:307
nat_ed_users_create
static void nat_ed_users_create(snat_main_per_thread_data_t *tsm, user_create_helper_t *uch)
Definition: nat44_ed_api.c:1413
vl_api_nat44_lb_static_mapping_dump_t_handler
static void vl_api_nat44_lb_static_mapping_dump_t_handler(vl_api_nat44_lb_static_mapping_dump_t *mp)
Definition: nat44_ed_api.c:1006
vl_api_nat44_identity_mapping_details_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:928
format_user_kvp
u8 * format_user_kvp(u8 *s, va_list *args)
Definition: nat44_ed_api.c:1402
snat_main_s::twice_nat_addresses
snat_address_t * twice_nat_addresses
Definition: nat44_ed.h:562
nat_log_info
#define nat_log_info(...)
Definition: nat44_ed.h:833
vl_api_nat44_address_dump_t_handler
static void vl_api_nat44_address_dump_t_handler(vl_api_nat44_address_dump_t *mp)
Definition: nat44_ed_api.c:347
nat44_config_t::sessions
u32 sessions
Definition: nat44_ed.h:69
vl_api_nat44_ed_show_fq_options_reply_t
Show NAT handoff frame queue options reply.
Definition: nat44_ed.api:1232
nat44_lb_addr_port_t::addr
ip4_address_t addr
Definition: nat44_ed.h:377
vl_api_nat44_interface_details_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: nat44_ed.api:719
vl_api_nat_worker_details_t::worker_index
u32 worker_index
Definition: nat44_ed.api:350
vl_api_nat_set_timeouts_t::udp
u32 udp
Definition: nat44_ed.api:383
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
vl_api_nat44_add_del_static_mapping_t_handler
static void vl_api_nat44_add_del_static_mapping_t_handler(vl_api_nat44_add_del_static_mapping_t *mp)
Definition: nat44_ed_api.c:485
send_nat44_static_mapping_details
static void send_nat44_static_mapping_details(snat_static_mapping_t *m, vl_api_registration_t *reg, u32 context)
Definition: nat44_ed_api.c:576
format_ip4_address
format_function_t format_ip4_address
Definition: format.h:73
snat_static_mapping_t::vrf_id
u32 vrf_id
Definition: nat44_ed.h:423
vl_api_nat44_session_cleanup_t
Run nat44 garbage collection.
Definition: nat44_ed.api:291
vl_api_nat_ha_get_listener_t_handler
static void vl_api_nat_ha_get_listener_t_handler(vl_api_nat_ha_get_listener_t *mp)
Definition: nat44_ed_api.c:1116
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
vl_api_nat44_show_running_config_reply_t
Show NAT44 plugin running config reply.
Definition: nat44_ed.api:268
nat_timeouts_t::tcp
struct nat_timeouts_t::@732 tcp
vl_api_nat44_add_del_static_mapping_v2_t::tag
string tag[64]
Definition: nat44_ed.api:834
vl_api_nat44_lb_static_mapping_add_del_local_t::external_addr
vl_api_ip4_address_t external_addr
Definition: nat44_ed.api:1101
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1105
nat_inlines.h
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
vl_api_nat44_ed_plugin_enable_disable_t::inside_vrf
u32 inside_vrf
Definition: nat44_ed.api:88
snat_user_t
Definition: nat44_ed_api.c:1326
vl_api_nat44_show_running_config_reply_t::flags
vl_api_nat44_config_flags_t flags
Definition: nat44_ed.api:284
vl_api_nat44_interface_output_feature_details_t::context
u32 context
Definition: nat44_ed.api:755
vl_api_nat_get_timeouts_t
Get values of timeouts for NAT sessions (seconds)
Definition: nat44_ed.api:393
vl_api_nat44_show_running_config_reply_t::ipfix_logging_enabled
bool ipfix_logging_enabled
Definition: nat44_ed.api:281
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
is_out2in_only_static_mapping
#define is_out2in_only_static_mapping(sm)
Check if NAT static mapping match only out2in direction.
Definition: nat44_ed.h:796
vl_api_nat_get_timeouts_reply_t::icmp
u32 icmp
Definition: nat44_ed.api:414
nat_interface_is_inside
#define nat_interface_is_inside(i)
Check if NAT interface is inside.
Definition: nat44_ed.h:772
is_ed_session
#define is_ed_session(s)
Check if NAT session is endpoint dependent.
Definition: nat44_ed.h:754
vl_api_nat44_interface_addr_details_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: nat44_ed.api:964
vl_api_nat44_static_mapping_details_t::protocol
u8 protocol
Definition: nat44_ed.api:868
vl_api_nat44_lb_static_mapping_add_del_local_t
Add/delete NAT44 load-balancing static mapping rule backend.
Definition: nat44_ed.api:1097
vl_api_nat44_identity_mapping_details_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:923
vl_api_nat_control_ping_t_handler
static void vl_api_nat_control_ping_t_handler(vl_api_nat_control_ping_t *mp)
Definition: nat44_ed_api.c:1217
vl_api_nat44_forwarding_enable_disable_t::enable
bool enable
Definition: nat44_ed.api:1181
vl_api_nat44_add_del_static_mapping_v2_t::protocol
u8 protocol
Definition: nat44_ed.api:829
vl_api_nat_ha_flush_t_handler
static void vl_api_nat_ha_flush_t_handler(vl_api_nat_ha_flush_t *mp)
Definition: nat44_ed_api.c:1143
vl_api_nat44_address_dump_t::context
u32 context
Definition: nat44_ed.api:667
vl_api_nat_show_config_reply_t::max_translations_per_user
u32 max_translations_per_user
Definition: nat44_ed.api:169
vl_api_nat44_interface_add_del_output_feature_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: nat44_ed.api:736
ip_proto_to_nat_proto
static nat_protocol_t ip_proto_to_nat_proto(u8 ip_proto)
Common NAT inline functions.
Definition: inlines.h:24
snat_main_s::translation_buckets
u32 translation_buckets
Definition: nat44_ed.h:596
vl_api_nat44_add_del_static_mapping_t::external_ip_address
vl_api_ip4_address_t external_ip_address
Definition: nat44_ed.api:787
vl_api_nat44_identity_mapping_dump_t::context
u32 context
Definition: nat44_ed.api:908
vl_api_nat44_interface_details_t
NAT44 interface details response.
Definition: nat44_ed.api:716
vl_api_nat44_identity_mapping_details_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: nat44_ed.api:927
vl_api_nat_ha_get_failover_t
Get HA failover/remote settings.
Definition: nat44_ed.api:566
vl_api_nat44_add_del_static_mapping_v2_t::external_port
u16 external_port
Definition: nat44_ed.api:831
nat_protocol_t
nat_protocol_t
Definition: lib.h:63
vl_api_nat_show_config_2_t
Show NAT plugin startup config.
Definition: nat44_ed.api:182
REPLY_MACRO2_ZERO
#define REPLY_MACRO2_ZERO(t, body)
Definition: api_helper_macros.h:101
vl_api_nat44_add_del_static_mapping_v2_t::external_ip_address
vl_api_ip4_address_t external_ip_address
Definition: nat44_ed.api:828
snat_main_s::interfaces
snat_interface_t * interfaces
Definition: nat44_ed.h:538
vl_api_nat44_interface_output_feature_details_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: nat44_ed.api:757
vl_api_nat44_set_session_limit_t::session_limit
u32 session_limit
Definition: nat44_ed.api:306
vl_api_nat44_add_del_static_mapping_t::external_port
u16 external_port
Definition: nat44_ed.api:790
clib_bihash_kv_8_8_t::value
u64 value
the value
Definition: bihash_8_8.h:44
snat_static_map_resolve_t::l_port
u16 l_port
Definition: nat44_ed.h:451
ip4_address_t::as_u32
u32 as_u32
Definition: ip4_packet.h:57
vl_api_nat44_lb_static_mapping_add_del_local_t::external_port
u16 external_port
Definition: nat44_ed.api:1102
clib_bihash_kv_8_8_t::key
u64 key
the key
Definition: bihash_8_8.h:43
vl_api_nat44_static_mapping_details_t::external_port
u16 external_port
Definition: nat44_ed.api:870
vl_api_nat44_add_del_address_range_t::is_add
bool is_add
Definition: nat44_ed.api:657
fib_table.h
vl_api_nat44_ed_plugin_enable_disable_t::enable
bool enable
Definition: nat44_ed.api:92
vl_api_nat44_address_details_t::context
u32 context
Definition: nat44_ed.api:677
vl_api_nat44_user_session_details_t::protocol
u16 protocol
Definition: nat44_ed.api:1032
vl_api_nat44_interface_output_feature_details_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:756
vl_api_nat_ha_get_listener_reply_t
Get HA listener/local configuration reply.
Definition: nat44_ed.api:554
vl_api_nat_set_timeouts_t
Set values of timeouts for NAT sessions (seconds)
Definition: nat44_ed.api:379
snat_user_t::fib_index
u32 fib_index
Definition: nat44_ed_api.c:1329
vl_api_nat44_add_del_address_range_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:658
u16
unsigned short u16
Definition: types.h:57
vl_api_nat44_user_session_details_t::ext_host_nat_port
u16 ext_host_nat_port
Definition: nat44_ed.api:1040
vl_api_nat44_show_running_config_reply_t::outside_vrf
u32 outside_vrf
Definition: nat44_ed.api:274
vl_api_nat44_static_mapping_dump_t
Dump NAT44 static mappings.
Definition: nat44_ed.api:841
vl_api_nat44_user_session_dump_t::ip_address
vl_api_ip4_address_t ip_address
Definition: nat44_ed.api:1001
vl_api_nat44_interface_add_del_feature_t::is_add
bool is_add
Definition: nat44_ed.api:694
snat_static_mapping_t::tag
u8 * tag
Definition: nat44_ed.h:432
vl_api_nat_set_workers_t
Set NAT workers.
Definition: nat44_ed.api:327
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vl_api_nat44_add_del_interface_addr_t::is_add
bool is_add
Definition: nat44_ed.api:942
vl_api_nat_get_addr_and_port_alloc_alg_t_handler
static void vl_api_nat_get_addr_and_port_alloc_alg_t_handler(vl_api_nat_get_addr_and_port_alloc_alg_t *mp)
Definition: nat44_ed_api.c:1097
vl_api_nat_show_config_2_reply_t::max_users_per_thread
u32 max_users_per_thread
Definition: nat44_ed.api:235
snat_main_s::workers
u32 * workers
Definition: nat44_ed.h:515
vl_api_nat_ha_resync_t
Resync HA (resend existing sessions to new failover)
Definition: nat44_ed.api:604
vl_api_nat44_ed_plugin_enable_disable_t
Enable/disable NAT44ED plugin.
Definition: nat44_ed.api:84
vl_api_nat44_forwarding_enable_disable_t_handler
static void vl_api_nat44_forwarding_enable_disable_t_handler(vl_api_nat44_forwarding_enable_disable_t *mp)
Definition: nat44_ed_api.c:1050
vl_api_nat44_lb_static_mapping_details_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:1137
vl_api_nat44_del_session_t
Delete NAT44 session.
Definition: nat44_ed.api:1158
vl_api_nat44_static_mapping_details_t::tag
string tag[64]
Definition: nat44_ed.api:873
port
u16 port
Definition: lb_types.api:73
vl_api_nat44_add_del_static_mapping_t::is_add
bool is_add
Definition: nat44_ed.api:784
vl_api_nat44_user_session_details_t::ext_host_nat_address
vl_api_ip4_address_t ext_host_nat_address
Definition: nat44_ed.api:1039
vl_api_nat_set_mss_clamping_t
Set TCP MSS rewriting configuration.
Definition: nat44_ed.api:478
vl_api_nat44_user_session_details_t::outside_ip_address
vl_api_ip4_address_t outside_ip_address
Definition: nat44_ed.api:1028
send_nat44_interface_addr_details
static void send_nat44_interface_addr_details(u32 sw_if_index, vl_api_registration_t *reg, u32 context, u8 twice_nat)
Definition: nat44_ed_api.c:838
nat44_ed_forwarding_enable_disable
void nat44_ed_forwarding_enable_disable(u8 is_enable)
Definition: nat44_ed.c:2246
vl_api_nat44_del_session_t::ext_host_port
u16 ext_host_port
Definition: nat44_ed.api:1167
vl_api_nat_control_ping_reply_t
Control ping from the client to the server response.
Definition: nat44_ed.api:113
vl_api_nat_show_config_reply_t::endpoint_dependent
bool endpoint_dependent
Definition: nat44_ed.api:162
snat_static_mapping_t::proto
nat_protocol_t proto
Definition: nat44_ed.h:426
snat_main_s::timeouts
nat_timeouts_t timeouts
Definition: nat44_ed.h:605
nat44_lb_addr_port_t::port
u16 port
Definition: nat44_ed.h:379
snat_static_mapping_t::local_addr
ip4_address_t local_addr
Definition: nat44_ed.h:413
snat_main_s::addresses
snat_address_t * addresses
Definition: nat44_ed.h:542
nat_timeouts_t::transitory
u32 transitory
Definition: lib.h:81
NAT44_IS_STATIC_MAPPING_ONLY
@ NAT44_IS_STATIC_MAPPING_ONLY
Definition: nat44_ed.api:33
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
vl_api_nat44_static_mapping_details_t::local_ip_address
vl_api_ip4_address_t local_ip_address
Definition: nat44_ed.api:866
vl_api_nat44_ed_plugin_enable_disable_t::outside_vrf
u32 outside_vrf
Definition: nat44_ed.api:89
vl_api_nat44_plugin_enable_disable_t_handler
static void vl_api_nat44_plugin_enable_disable_t_handler(vl_api_nat44_plugin_enable_disable_t *mp)
Definition: nat44_ed_api.c:1179
is_lb_static_mapping
#define is_lb_static_mapping(sm)
Check if NAT static mapping is load-balancing.
Definition: nat44_ed.h:808
vl_api_nat44_add_del_static_mapping_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:792
vlib_worker_threads
vlib_worker_thread_t * vlib_worker_threads
Definition: threads.c:35
user_create_helper_t::user_hash
clib_bihash_8_8_t user_hash
Definition: nat44_ed_api.c:1338
snat_is_session_static
#define snat_is_session_static(s)
Check if SNAT session is created from static mapping.
Definition: nat44_ed.h:724
vl_api_nat44_add_del_identity_mapping_t::tag
string tag[64]
Definition: nat44_ed.api:899
vl_api_nat44_forwarding_is_enabled_reply_t
Response to check if forwarding is enabled or disabled.
Definition: nat44_ed.api:1198
vl_api_nat44_show_running_config_reply_t::users
u32 users
Definition: nat44_ed.api:275
send_nat44_interface_details
static void send_nat44_interface_details(snat_interface_t *i, vl_api_registration_t *reg, u32 context)
Definition: nat44_ed_api.c:387
vl_api_nat44_add_del_lb_static_mapping_t::tag
string tag[64]
Definition: nat44_ed.api:1083
vl_api_nat44_add_del_static_mapping_v2_t::is_add
bool is_add
Definition: nat44_ed.api:823
vl_api_nat44_del_session_t::port
u16 port
Definition: nat44_ed.api:1163
TWICE_NAT_DISABLED
@ TWICE_NAT_DISABLED
Definition: nat44_ed.h:391
vl_api_nat44_user_details_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:986
vl_api_nat_ha_set_failover_t
Set HA failover (remote settings)
Definition: nat44_ed.api:530
ip4_header_t
Definition: ip4_packet.h:87
snat_user_t::nstaticsessions
u32 nstaticsessions
Definition: nat44_ed_api.c:1331
vl_api_nat44_static_mapping_details_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:872
vl_api_nat44_ed_set_fq_options_t::frame_queue_nelts
u32 frame_queue_nelts
Definition: nat44_ed.api:1213
vl_api_nat_set_addr_and_port_alloc_alg_t_handler
static void vl_api_nat_set_addr_and_port_alloc_alg_t_handler(vl_api_nat_set_addr_and_port_alloc_alg_t *mp)
Definition: nat44_ed_api.c:1087
vl_api_nat44_add_del_identity_mapping_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: nat44_ed.api:897
vl_api_nat_set_timeouts_t::icmp
u32 icmp
Definition: nat44_ed.api:386
snat_main_s::log_level
u8 log_level
Definition: nat44_ed.h:654
vl_api_nat44_add_del_lb_static_mapping_t::external_addr
vl_api_ip4_address_t external_addr
Definition: nat44_ed.api:1079
vl_api_nat44_interface_add_del_feature_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:695
vl_api_nat44_lb_static_mapping_details_t
NAT44 load-balancing static mapping rule details response.
Definition: nat44_ed.api:1132
snat_main_s::forwarding_enabled
u8 forwarding_enabled
Definition: nat44_ed.h:587
vl_api_nat44_plugin_enable_disable_t::flags
vl_api_nat44_config_flags_t flags
Definition: nat44_ed.api:70
vl_api_nat44_identity_mapping_dump_t_handler
static void vl_api_nat44_identity_mapping_dump_t_handler(vl_api_nat44_identity_mapping_dump_t *mp)
Definition: nat44_ed_api.c:777
vl_api_nat44_add_del_static_mapping_v2_t::pool_ip_address
vl_api_ip4_address_t pool_ip_address
Definition: nat44_ed.api:826
key
typedef key
Definition: ipsec_types.api:88
vl_api_nat44_add_del_lb_static_mapping_t_handler
static void vl_api_nat44_add_del_lb_static_mapping_t_handler(vl_api_nat44_add_del_lb_static_mapping_t *mp)
Definition: nat44_ed_api.c:903
vl_api_nat_show_config_2_reply_t::out2in_dpo
bool out2in_dpo
Definition: nat44_ed.api:221
vl_api_nat_ipfix_enable_disable_t::enable
bool enable
Definition: nat44_ed.api:368
vl_api_nat44_lb_static_mapping_dump_t::context
u32 context
Definition: nat44_ed.api:1113
vl_api_nat_get_mss_clamping_reply_t::enable
bool enable
Definition: nat44_ed.api:504
vl_api_nat44_forwarding_is_enabled_reply_t::context
u32 context
Definition: nat44_ed.api:1200
vl_api_nat_get_mss_clamping_t_handler
static void vl_api_nat_get_mss_clamping_t_handler(vl_api_nat_get_mss_clamping_t *mp)
Definition: nat44_ed_api.c:251
pool_is_free_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:302
vl_api_nat44_set_session_limit_t_handler
static void vl_api_nat44_set_session_limit_t_handler(vl_api_nat44_set_session_limit_t *mp)
Definition: nat44_ed_api.c:160
vl_api_nat44_forwarding_is_enabled_t_handler
static void vl_api_nat44_forwarding_is_enabled_t_handler(vl_api_nat44_forwarding_is_enabled_t *mp)
Definition: nat44_ed_api.c:1061
vl_api_nat_show_config_t_handler
static void vl_api_nat_show_config_t_handler(vl_api_nat_show_config_t *mp)
Definition: nat44_ed_api.c:1228
vl_api_nat_get_addr_and_port_alloc_alg_t
Get address and port assignment algorithm.
Definition: nat44_ed.api:444
vl_api_nat44_user_dump_t_handler
static void vl_api_nat44_user_dump_t_handler(vl_api_nat44_user_dump_t *mp)
Definition: nat44_ed_api.c:1433
vl_api_nat_get_timeouts_reply_t::tcp_established
u32 tcp_established
Definition: nat44_ed.api:412
snat_address_t
Definition: nat44_ed.h:350
vl_api_nat44_user_dump_t::context
u32 context
Definition: nat44_ed.api:974
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: bfd_api.c:451
vl_api_nat44_show_running_config_reply_t::user_sessions
u32 user_sessions
Definition: nat44_ed.api:277
vl_api_nat44_static_mapping_dump_t_handler
static void vl_api_nat44_static_mapping_dump_t_handler(vl_api_nat44_static_mapping_dump_t *mp)
Definition: nat44_ed_api.c:656
vl_api_nat44_lb_static_mapping_add_del_local_t::is_add
bool is_add
Definition: nat44_ed.api:1100
fib_table_t_
A protocol Independent FIB table.
Definition: fib_table.h:71
vl_api_nat_get_timeouts_reply_t
Get values of timeouts for NAT sessions reply.
Definition: nat44_ed.api:407
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
vl_api_nat44_user_session_details_t::total_bytes
u64 total_bytes
Definition: nat44_ed.api:1035
vl_api_nat44_add_del_static_mapping_t::protocol
u8 protocol
Definition: nat44_ed.api:788
vl_api_nat44_plugin_enable_disable_t::sessions
u32 sessions
Definition: nat44_ed.api:66
vl_api_nat44_lb_static_mapping_details_t::external_addr
vl_api_ip4_address_t external_addr
Definition: nat44_ed.api:1134
count
u8 count
Definition: dhcp.api:208
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vl_api_nat44_lb_static_mapping_details_t::external_port
u16 external_port
Definition: nat44_ed.api:1135
snat_main_s::per_thread_data
snat_main_per_thread_data_t * per_thread_data
Definition: nat44_ed.h:519
vl_api_nat44_add_del_lb_static_mapping_t::affinity
u32 affinity
Definition: nat44_ed.api:1082
len
u8 len
Definition: ip_types.api:103
nat_timeouts_t::established
u32 established
Definition: lib.h:80
vl_api_nat44_interface_output_feature_dump_t_handler
static void vl_api_nat44_interface_output_feature_dump_t_handler(vl_api_nat44_interface_output_feature_dump_t *mp)
Definition: nat44_ed_api.c:467
vl_api_nat44_user_session_details_t::inside_port
u16 inside_port
Definition: nat44_ed.api:1031
send_nat44_static_map_resolve_details
static void send_nat44_static_map_resolve_details(snat_static_map_resolve_t *m, vl_api_registration_t *reg, u32 context)
Definition: nat44_ed_api.c:620
snat_main_s::rconfig
nat44_config_t rconfig
Definition: nat44_ed.h:583
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
vl_api_nat44_add_del_static_mapping_t::tag
string tag[64]
Definition: nat44_ed.api:793
vl_api_nat44_show_running_config_reply_t::forwarding_enabled
bool forwarding_enabled
Definition: nat44_ed.api:280
vl_api_nat44_show_running_config_reply_t::user_buckets
u32 user_buckets
Definition: nat44_ed.api:278
vl_api_nat44_static_mapping_dump_t::context
u32 context
Definition: nat44_ed.api:843
vl_api_nat_get_timeouts_reply_t::tcp_transitory
u32 tcp_transitory
Definition: nat44_ed.api:413
snat_user_key_t::addr
ip4_address_t addr
Definition: nat44_ed_api.c:1319
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
snat_main_s::first_worker_index
u32 first_worker_index
Definition: nat44_ed.h:514
nat44_lb_addr_port_t::probability
u8 probability
Definition: nat44_ed.h:381
fib_table_t_::ft_table_id
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:92
vl_api_nat_show_config_2_reply_t::max_translations_per_user
u32 max_translations_per_user
Definition: nat44_ed.api:227
vl_api_nat44_interface_addr_dump_t::context
u32 context
Definition: nat44_ed.api:953
vl_api_nat44_interface_dump_t
Dump interfaces with NAT44 feature.
Definition: nat44_ed.api:703
twice_nat_type_t
twice_nat_type_t
Definition: nat44_ed.h:388
vl_api_nat44_lb_static_mapping_add_del_local_t_handler
static void vl_api_nat44_lb_static_mapping_add_del_local_t_handler(vl_api_nat44_lb_static_mapping_add_del_local_t *mp)
Definition: nat44_ed_api.c:939
vl_api_nat44_del_session_t_handler
static void vl_api_nat44_del_session_t_handler(vl_api_nat44_del_session_t *mp)
Definition: nat44_ed_api.c:1025
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
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
BITS
#define BITS(x)
Definition: clib.h:69
nat44_config_t::inside_vrf
u32 inside_vrf
Definition: nat44_ed.h:65
vl_api_nat_ipfix_enable_disable_t
Enable/disable NAT IPFIX logging.
Definition: nat44_ed.api:362
vl_api_nat_show_config_2_reply_t::user_buckets
u32 user_buckets
Definition: nat44_ed.api:225
vl_api_nat44_add_del_static_mapping_v2_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:825
nat_proto_to_ip_proto
static_always_inline u8 nat_proto_to_ip_proto(nat_protocol_t nat_proto)
Definition: inlines.h:37
vl_api_nat44_add_del_identity_mapping_t::port
u16 port
Definition: nat44_ed.api:896
vl_api_nat_set_mss_clamping_t::mss_value
u16 mss_value
Definition: nat44_ed.api:481
nat44_lb_static_mapping_add_del_local
int nat44_lb_static_mapping_add_del_local(ip4_address_t e_addr, u16 e_port, ip4_address_t l_addr, u16 l_port, nat_protocol_t proto, u32 vrf_id, u8 probability, u8 is_add)
Definition: nat44_ed.c:1084
vl_api_nat44_plugin_enable_disable_t::outside_vrf
u32 outside_vrf
Definition: nat44_ed.api:63
vl_api_nat44_address_dump_t
Dump NAT44 addresses.
Definition: nat44_ed.api:665
vl_api_nat44_add_del_static_mapping_t::local_ip_address
vl_api_ip4_address_t local_ip_address
Definition: nat44_ed.api:786
send_nat44_lb_static_mapping_details
static void send_nat44_lb_static_mapping_details(snat_static_mapping_t *m, vl_api_registration_t *reg, u32 context)
Definition: nat44_ed_api.c:961
vl_api_nat_ipfix_enable_disable_t::domain_id
u32 domain_id
Definition: nat44_ed.api:366
vl_api_nat_ha_set_listener_t
Set HA listener (local settings)
Definition: nat44_ed.api:514
c
svmdb_client_t * c
Definition: vpp_get_metrics.c:48
nat44_api_hookup
clib_error_t * nat44_api_hookup(vlib_main_t *vm)
Definition: nat44_ed_api.c:1552
vl_api_nat_worker_dump_t
Dump NAT workers.
Definition: nat44_ed.api:337
vl_api_nat44_static_mapping_details_t
NAT44 static mapping details response.
Definition: nat44_ed.api:863
vl_api_nat44_add_del_lb_static_mapping_t::local_num
u32 local_num
Definition: nat44_ed.api:1084
vl_api_nat_ha_flush_t
Flush the current HA data (for testing)
Definition: nat44_ed.api:591
vl_api_nat44_interface_addr_details_t
NAT44 pool addresses interfaces details response.
Definition: nat44_ed.api:962
vl_api_nat_show_config_2_reply_t::inside_vrf_id
u32 inside_vrf_id
Definition: nat44_ed.api:229
nat_calc_bihash_buckets
static_always_inline u32 nat_calc_bihash_buckets(u32 n_elts)
Definition: lib.h:122
vl_api_nat44_interface_dump_t::context
u32 context
Definition: nat44_ed.api:705
snat_user_key_t
Definition: nat44_ed_api.c:1313
vl_api_nat44_user_dump_t
Dump NAT44 users.
Definition: nat44_ed.api:972
vl_api_nat44_set_session_limit_t
NAT44 set session limit.
Definition: nat44_ed.api:303
vl_api_nat44_ed_set_fq_options_t
Set NAT handoff frame queue options.
Definition: nat44_ed.api:1209
clib_bitmap_free
#define clib_bitmap_free(v)
Free a bitmap.
Definition: bitmap.h:92
uword
u64 uword
Definition: types.h:112
snat_add_interface_address
int snat_add_interface_address(snat_main_t *sm, u32 sw_if_index, int is_del, u8 twice_nat)
Add/delete NAT44 pool address from specific interface.
Definition: nat44_ed.c:3076
vlib_worker_thread_t::cpu_id
int cpu_id
Definition: threads.h:110
vl_api_nat44_add_del_static_mapping_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:785
TWICE_NAT_SELF
@ TWICE_NAT_SELF
Definition: nat44_ed.h:395
vl_api_nat_ha_get_failover_t_handler
static void vl_api_nat_ha_get_failover_t_handler(vl_api_nat_ha_get_failover_t *mp)
Definition: nat44_ed_api.c:1134
vl_api_nat44_plugin_enable_disable_t::inside_vrf
u32 inside_vrf
Definition: nat44_ed.api:62
nat44_del_ed_session
int nat44_del_ed_session(snat_main_t *sm, ip4_address_t *addr, u16 port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 vrf_id, int is_in)
Delete NAT44 endpoint-dependent session.
Definition: nat44_ed.c:3144
vl_api_nat_show_config_reply_t::static_mapping_connection_tracking
bool static_mapping_connection_tracking
Definition: nat44_ed.api:160
ipfix_logging.h
vl_api_nat44_interface_add_del_output_feature_t::is_add
bool is_add
Definition: nat44_ed.api:734
vl_api_nat44_add_del_lb_static_mapping_t::external_port
u16 external_port
Definition: nat44_ed.api:1080
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
vl_api_nat44_static_mapping_details_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:865
vl_api_nat44_add_del_address_range_t::last_ip_address
vl_api_ip4_address_t last_ip_address
Definition: nat44_ed.api:655
vl_api_nat44_add_del_identity_mapping_t::is_add
bool is_add
Definition: nat44_ed.api:892
vl_api_nat_ipfix_enable_disable_t_handler
static void vl_api_nat_ipfix_enable_disable_t_handler(vl_api_nat_ipfix_enable_disable_t *mp)
Definition: nat44_ed_api.c:189
mask
vl_api_pnat_mask_t mask
Definition: pnat.api:45
send_nat_worker_details
static void send_nat_worker_details(u32 worker_index, vl_api_registration_t *reg, u32 context)
Definition: nat44_ed_api.c:123
vl_api_nat44_plugin_enable_disable_t::enable
bool enable
Definition: nat44_ed.api:69
vl_api_nat44_user_details_t
NAT44 users response.
Definition: nat44_ed.api:984
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
vl_api_nat_set_addr_and_port_alloc_alg_t
Set address and port assignment algorithm.
Definition: nat44_ed.api:429
vl_api_nat44_interface_add_del_feature_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: nat44_ed.api:696
vl_api_nat44_show_running_config_reply_t::translation_buckets
u32 translation_buckets
Definition: nat44_ed.api:279
nat44_set_session_limit
int nat44_set_session_limit(u32 session_limit, u32 vrf_id)
Set NAT44 session limit (session limit, vrf id)
Definition: nat44_ed.c:2770
vl_api_nat44_interface_addr_dump_t
Dump NAT44 pool addresses interfaces.
Definition: nat44_ed.api:951
vl_api_nat44_add_del_static_mapping_v2_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:833
snat_is_unk_proto_session
#define snat_is_unk_proto_session(s)
Check if SNAT session for unknown protocol.
Definition: nat44_ed.h:730
snat_user_t::addr
ip4_address_t addr
Definition: nat44_ed_api.c:1328
vl_api_nat44_lb_static_mapping_dump_t
Dump NAT44 load-balancing static mapping rules.
Definition: nat44_ed.api:1111
nat44_lb_addr_port_t
Definition: nat44_ed.h:374
vl_api_nat44_del_session_t::address
vl_api_ip4_address_t address
Definition: nat44_ed.api:1161
snat_static_mapping_t::external_port
u16 external_port
Definition: nat44_ed.h:419
user_create_helper_t::users
snat_user_t * users
Definition: nat44_ed_api.c:1337
vl_api_nat_show_config_t
Show NAT plugin startup config.
Definition: nat44_ed.api:126
vl_api_nat44_user_details_t::ip_address
vl_api_ip4_address_t ip_address
Definition: nat44_ed.api:987
send_nat44_identity_mapping_details
static void send_nat44_identity_mapping_details(snat_static_mapping_t *m, int index, vl_api_registration_t *reg, u32 context)
Definition: nat44_ed_api.c:721
snat_static_map_resolve_t::addr_only
int addr_only
Definition: nat44_ed.h:457
vl_api_nat44_interface_add_del_output_feature_t_handler
static void vl_api_nat44_interface_add_del_output_feature_t_handler(vl_api_nat44_interface_add_del_output_feature_t *mp)
Definition: nat44_ed_api.c:427
snat_static_map_resolve_t::tag
u8 * tag
Definition: nat44_ed.h:462
vl_api_nat44_del_user_t_handler
static void vl_api_nat44_del_user_t_handler(vl_api_nat44_del_user_t *mp)
Definition: nat44_ed_api.c:1161
snat_interface_add_del
int snat_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
Enable/disable NAT44 feature on the interface.
Definition: nat44_ed.c:1397
ip4_address_t
Definition: ip4_packet.h:50
vl_api_nat44_del_session_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:1164
snat_static_mapping_t::twice_nat
twice_nat_type_t twice_nat
Definition: nat44_ed.h:421
vl_api_nat_set_timeouts_t::tcp_transitory
u32 tcp_transitory
Definition: nat44_ed.api:385
NAT_LOG_DEBUG
@ NAT_LOG_DEBUG
Definition: nat_types.api:33
vl_api_nat44_identity_mapping_details_t::tag
string tag[64]
Definition: nat44_ed.api:929
vl_api_nat_get_timeouts_reply_t::udp
u32 udp
Definition: nat44_ed.api:411
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
vl_api_nat44_address_details_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:680
snat_main_s
Definition: nat44_ed.h:510
snat_main_per_thread_data_t::sessions
snat_session_t * sessions
Definition: nat44_ed.h:468
vl_api_nat44_add_del_identity_mapping_t
Add/delete NAT44 identity mapping.
Definition: nat44_ed.api:889
vl_api_nat44_forwarding_is_enabled_t::client_index
u32 client_index
Definition: nat44_ed.api:1190
nat44_plugin_enable
int nat44_plugin_enable(nat44_config_t c)
Enable NAT44 plugin.
Definition: nat44_ed.c:2099
snat_static_map_resolve_t::twice_nat
int twice_nat
Definition: nat44_ed.h:458
vl_api_nat44_add_del_static_mapping_v2_t::local_ip_address
vl_api_ip4_address_t local_ip_address
Definition: nat44_ed.api:827
nat44_ed_set_frame_queue_nelts
int nat44_ed_set_frame_queue_nelts(u32 frame_queue_nelts)
Definition: nat44_ed.c:1785
vl_api_nat44_static_mapping_dump_t::client_index
u32 client_index
Definition: nat44_ed.api:842
vl_api_nat_ha_set_failover_t_handler
static void vl_api_nat_ha_set_failover_t_handler(vl_api_nat_ha_set_failover_t *mp)
Definition: nat44_ed_api.c:1125
vl_api_nat44_add_del_lb_static_mapping_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:1078
vl_api_nat44_user_session_details_t::context
u32 context
Definition: nat44_ed.api:1027
vl_api_nat44_interface_details_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:718
vl_api_nat_show_config_2_reply_t
Show NAT plugin startup config reply.
Definition: nat44_ed.api:212
vl_api_nat44_identity_mapping_details_t::protocol
u8 protocol
Definition: nat44_ed.api:925
vl_api_nat44_lb_static_mapping_details_t::locals
vl_api_nat44_lb_addr_port_t locals[local_num]
Definition: nat44_ed.api:1141
snat_static_map_resolve_t::identity_nat
int identity_nat
Definition: nat44_ed.h:460
vl_api_nat44_add_del_interface_addr_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: nat44_ed.api:943
vl_api_nat44_show_running_config_reply_t::inside_vrf
u32 inside_vrf
Definition: nat44_ed.api:273
vl_api_nat44_ed_show_fq_options_reply_t::frame_queue_nelts
u32 frame_queue_nelts
Definition: nat44_ed.api:1237
increment_v4_address
static void increment_v4_address(ip4_address_t *a)
Definition: nat_inlines.h:23
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition: api_helper_macros.h:289
vl_api_nat44_add_del_identity_mapping_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:898
vl_api_nat44_interface_dump_t::client_index
u32 client_index
Definition: nat44_ed.api:704
vl_api_nat44_address_dump_t::client_index
u32 client_index
Definition: nat44_ed.api:666
nat_ed_users_destroy
static void nat_ed_users_destroy(user_create_helper_t *uch)
Definition: nat44_ed_api.c:1426
snat_user_key_t::fib_index
u32 fib_index
Definition: nat44_ed_api.c:1320
vl_api_nat44_del_session_t::ext_host_address
vl_api_ip4_address_t ext_host_address
Definition: nat44_ed.api:1166
NAT44_IS_ENDPOINT_DEPENDENT
@ NAT44_IS_ENDPOINT_DEPENDENT
Definition: nat44_ed.api:32
vl_api_nat44_add_del_lb_static_mapping_t
Add/delete NAT44 load-balancing static mapping rule.
Definition: nat44_ed.api:1074
vl_api_nat44_add_del_lb_static_mapping_t::is_add
bool is_add
Definition: nat44_ed.api:1077
ip4_address_t::as_u8
u8 as_u8[4]
Definition: ip4_packet.h:55
vl_api_nat_show_config_2_reply_t::outside_vrf_id
u32 outside_vrf_id
Definition: nat44_ed.api:228
vl_api_nat44_interface_addr_details_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:965
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vl_api_nat_show_config_reply_t::out2in_dpo
bool out2in_dpo
Definition: nat44_ed.api:163
snat_main_s::msg_id_base
u16 msg_id_base
Definition: nat44_ed.h:649
vl_api_nat44_user_session_details_t::outside_port
u16 outside_port
Definition: nat44_ed.api:1029
vl_api_nat44_del_session_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:1165
index
u32 index
Definition: flow_types.api:221
vl_api_nat_show_config_2_reply_t::translation_buckets
u32 translation_buckets
Definition: nat44_ed.api:223
snat_main_s::frame_queue_nelts
u32 frame_queue_nelts
Definition: nat44_ed.h:668
vl_api_nat44_address_details_t::ip_address
vl_api_ip4_address_t ip_address
Definition: nat44_ed.api:678
vl_api_nat44_static_mapping_details_t::context
u32 context
Definition: nat44_ed.api:864
nat_ipfix_logging_enable_disable
int nat_ipfix_logging_enable_disable(int enable, u32 domain_id, u16 src_port)
Enable/disable NAT plugin IPFIX logging.
Definition: ipfix_logging.c:1524
vl_api_nat44_identity_mapping_details_t::context
u32 context
Definition: nat44_ed.api:922
pool_foreach_index
#define pool_foreach_index(i, v)
Definition: pool.h:576
nat44_config_t
Definition: nat44_ed.h:59
user_create_helper_t
Definition: nat44_ed_api.c:1334
vl_api_nat_set_mss_clamping_t_handler
static void vl_api_nat_set_mss_clamping_t_handler(vl_api_nat_set_mss_clamping_t *mp)
Definition: nat44_ed_api.c:236
format_fns.h
vl_api_nat44_add_del_identity_mapping_t::ip_address
vl_api_ip4_address_t ip_address
Definition: nat44_ed.api:894
vl_api_nat_set_log_level_t_handler
static void vl_api_nat_set_log_level_t_handler(vl_api_nat_set_log_level_t *mp)
Definition: nat44_ed_api.c:174
snat_add_static_mapping
int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, u32 vrf_id, int addr_only, u32 sw_if_index, nat_protocol_t proto, int is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u8 identity_nat, ip4_address_t pool_addr, int exact)
Add/delete NAT44 static mapping.
Definition: nat44_ed.c:484
nat44_lb_addr_port_t::vrf_id
u32 vrf_id
Definition: nat44_ed.h:384
u64
unsigned long u64
Definition: types.h:89
format
description fragment has unexpected format
Definition: map.api:433
vl_api_nat44_interface_output_feature_dump_t
Dump interfaces with NAT44 output feature.
Definition: nat44_ed.api:743
TWICE_NAT
@ TWICE_NAT
Definition: nat44_ed.h:393
vl_api_nat44_interface_output_feature_details_t
NAT44 interface with output feature details response.
Definition: nat44_ed.api:754
vl_api_nat_ha_set_listener_t_handler
static void vl_api_nat_ha_set_listener_t_handler(vl_api_nat_ha_set_listener_t *mp)
Definition: nat44_ed_api.c:1107
vl_api_nat_set_workers_t::worker_mask
u64 worker_mask
Definition: nat44_ed.api:330
fib_table_get
fib_table_t * fib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
Definition: fib_table.c:29
vl_api_nat44_del_session_t::protocol
u8 protocol
Definition: nat44_ed.api:1162
vl_api_nat44_static_mapping_details_t::local_port
u16 local_port
Definition: nat44_ed.api:869
vl_api_nat44_user_session_details_t::ext_host_port
u16 ext_host_port
Definition: nat44_ed.api:1038
vl_api_nat44_identity_mapping_details_t::port
u16 port
Definition: nat44_ed.api:926
u32
unsigned int u32
Definition: types.h:88
vl_api_nat_set_mss_clamping_t::enable
bool enable
Definition: nat44_ed.api:482
vl_api_nat44_add_del_interface_addr_t
Add/delete NAT44 pool address from specific interfce.
Definition: nat44_ed.api:939
vl_api_nat44_add_del_interface_addr_t_handler
static void vl_api_nat44_add_del_interface_addr_t_handler(vl_api_nat44_add_del_interface_addr_t *mp)
Definition: nat44_ed_api.c:810
vl_api_nat_set_timeouts_t::tcp_established
u32 tcp_established
Definition: nat44_ed.api:384
vl_api_nat44_show_running_config_t_handler
static void vl_api_nat44_show_running_config_t_handler(vl_api_nat44_show_running_config_t *mp)
Definition: nat44_ed_api.c:1275
snat_del_address
int snat_del_address(snat_main_t *sm, ip4_address_t addr, u8 delete_sm, u8 twice_nat)
Delete external address from NAT44 pool.
Definition: nat44_ed.c:1224
vl_api_nat44_add_del_address_range_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:656
vl_api_nat44_lb_static_mapping_add_del_local_t::protocol
u8 protocol
Definition: nat44_ed.api:1103
vl_api_nat44_lb_static_mapping_dump_t::client_index
u32 client_index
Definition: nat44_ed.api:1112
nat44_config_t::static_mapping_only
u8 static_mapping_only
Definition: nat44_ed.h:62
vl_api_nat44_forwarding_is_enabled_t
Check if forwarding is enabled or disabled.
Definition: nat44_ed.api:1188
snat_main_s::auto_add_sw_if_indices
u32 * auto_add_sw_if_indices
Definition: nat44_ed.h:565
vl_api_nat44_plugin_enable_disable_t
Enable/disable NAT44 plugin.
Definition: nat44_ed.api:58
nat_ed_user_create_helper
static void nat_ed_user_create_helper(user_create_helper_t *uch, snat_session_t *s)
Definition: nat44_ed_api.c:1368
is_identity_static_mapping
#define is_identity_static_mapping(sm)
Check if NAT static mapping is identity NAT.
Definition: nat44_ed.h:802
snat_main_s::mss_clamping
u16 mss_clamping
Definition: nat44_ed.h:608
vl_api_nat_ha_resync_t_handler
static void vl_api_nat_ha_resync_t_handler(vl_api_nat_ha_resync_t *mp)
Definition: nat44_ed_api.c:1152
vl_api_nat44_user_dump_t::client_index
u32 client_index
Definition: nat44_ed.api:973
snat_interface_add_del_output_feature
int snat_interface_add_del_output_feature(u32 sw_if_index, u8 is_inside, int is_del)
Enable/disable NAT44 output feature on the interface (postrouting NAT)
Definition: nat44_ed.c:1595
is_addr_only_static_mapping
#define is_addr_only_static_mapping(sm)
Check if NAT static mapping is address only (1:1NAT).
Definition: nat44_ed.h:790
vl_api_nat44_static_mapping_details_t::external_ip_address
vl_api_ip4_address_t external_ip_address
Definition: nat44_ed.api:867
api_helper_macros.h
vl_api_nat44_user_session_details_t::total_pkts
u32 total_pkts
Definition: nat44_ed.api:1036
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
vl_api_nat_ha_get_failover_reply_t
Get HA failover/remote settings reply.
Definition: nat44_ed.api:579
vl_api_nat_show_config_reply_t::outside_vrf_id
u32 outside_vrf_id
Definition: nat44_ed.api:170
nat44_ed.h
vl_api_nat_get_timeouts_t_handler
static void vl_api_nat_get_timeouts_t_handler(vl_api_nat_get_timeouts_t *mp)
Definition: nat44_ed_api.c:220
clib_bihash_kv_8_8_t
8 octet key, 8 octet key value pair
Definition: bihash_8_8.h:41
vl_api_nat_show_config_reply_t::user_buckets
u32 user_buckets
Definition: nat44_ed.api:167
vlib_worker_thread_t
Definition: threads.h:85
vl_api_nat_set_timeouts_t_handler
static void vl_api_nat_set_timeouts_t_handler(vl_api_nat_set_timeouts_t *mp)
Definition: nat44_ed_api.c:205
snat_main_s::max_translations_per_thread
u32 max_translations_per_thread
Definition: nat44_ed.h:597
vl_api_nat44_add_del_address_range_t
Add/del NAT44 address range.
Definition: nat44_ed.api:651
snat_static_map_resolve_t::vrf_id
u32 vrf_id
Definition: nat44_ed.h:454
pool_elts
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127
vl_api_nat44_add_del_static_mapping_v2_t::local_port
u16 local_port
Definition: nat44_ed.api:830
nat44_ed_get_in2out_worker_index
u32 nat44_ed_get_in2out_worker_index(vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u8 is_output)
Definition: nat44_ed.c:2503
vl_api_nat_ha_get_listener_t
Get HA listener/local configuration.
Definition: nat44_ed.api:542
vl_api_nat44_add_del_identity_mapping_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:893
vl_api_nat44_add_del_static_mapping_t::local_port
u16 local_port
Definition: nat44_ed.api:789
vl_api_nat44_add_del_static_mapping_v2_t_handler
static void vl_api_nat44_add_del_static_mapping_v2_t_handler(vl_api_nat44_add_del_static_mapping_v2_t *mp)
Definition: nat44_ed_api.c:529
vl_api_nat_set_log_level_t::log_level
vl_api_nat_log_level_t log_level
Definition: nat44_ed.api:319
vl_api_nat44_add_del_static_mapping_v2_t
Add/delete NAT44 static mapping.
Definition: nat44_ed.api:819
snat_main_s::inside_vrf_id
u32 inside_vrf_id
Definition: nat44_ed.h:602
value
u8 value
Definition: qos.api:54
vl_api_nat44_interface_add_del_output_feature_t
Enable/disbale NAT44 as an interface output feature (postrouting in2out translation)
Definition: nat44_ed.api:731
vl_api_nat_show_config_2_reply_t::static_mapping_connection_tracking
bool static_mapping_connection_tracking
Definition: nat44_ed.api:218
vl_api_nat44_interface_add_del_feature_t_handler
static void vl_api_nat44_interface_add_del_feature_t_handler(vl_api_nat44_interface_add_del_feature_t *mp)
Definition: nat44_ed_api.c:365
vl_api_nat_get_mss_clamping_reply_t::mss_value
u16 mss_value
Definition: nat44_ed.api:503
vl_api_nat_show_config_reply_t::translation_buckets
u32 translation_buckets
Definition: nat44_ed.api:165
vl_api_nat44_ed_plugin_enable_disable_t::flags
vl_api_nat44_config_flags_t flags
Definition: nat44_ed.api:93
vl_api_nat44_del_user_t
Del NAT44 user.
Definition: nat44_ed.api:634
vl_api_nat44_add_del_static_mapping_v2_t::external_sw_if_index
vl_api_interface_index_t external_sw_if_index
Definition: nat44_ed.api:832
vl_api_nat_worker_details_t::lcore_id
u32 lcore_id
Definition: nat44_ed.api:351
vl_api_nat44_lb_static_mapping_add_del_local_t::local
vl_api_nat44_lb_addr_port_t local
Definition: nat44_ed.api:1104
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
snat_static_map_resolve_t::proto
nat_protocol_t proto
Definition: nat44_ed.h:455
vl_api_nat44_interface_addr_dump_t::client_index
u32 client_index
Definition: nat44_ed.api:952
snat_main
snat_main_t snat_main
Definition: nat44_ed.c:41
vl_api_nat44_interface_addr_details_t::context
u32 context
Definition: nat44_ed.api:963
snat_static_map_resolve_t::sw_if_index
u32 sw_if_index
Definition: nat44_ed.h:453
vl_api_nat44_add_del_static_mapping_v2_t::match_pool
bool match_pool
Definition: nat44_ed.api:824
vl_api_nat44_plugin_enable_disable_t::users
u32 users
Definition: nat44_ed.api:64
vl_api_nat44_static_mapping_details_t::external_sw_if_index
vl_api_interface_index_t external_sw_if_index
Definition: nat44_ed.api:871
vl_api_nat44_identity_mapping_details_t
NAT44 identity mapping details response.
Definition: nat44_ed.api:921
vl_api_nat44_add_del_lb_static_mapping_t::protocol
u8 protocol
Definition: nat44_ed.api:1081
vl_api_nat_worker_dump_t::client_index
u32 client_index
Definition: nat44_ed.api:338
send_nat44_interface_output_feature_details
static void send_nat44_interface_output_feature_details(snat_interface_t *i, vl_api_registration_t *reg, u32 context)
Definition: nat44_ed_api.c:445
u8
unsigned char u8
Definition: types.h:56
vl_api_nat44_user_details_t::nsessions
u32 nsessions
Definition: nat44_ed.api:988
clib_error_t
Definition: clib_error.h:21
vl_api_nat44_address_details_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:679
is_twice_nat_session
#define is_twice_nat_session(s)
Check if NAT session is twice NAT.
Definition: nat44_ed.h:736
vl_api_nat44_user_session_details_t
NAT44 user's sessions response.
Definition: nat44_ed.api:1026
a
a
Definition: bitmap.h:544
ip
vl_api_address_t ip
Definition: l2.api:558
vl_api_nat_show_config_2_reply_t::max_translations_per_thread
u32 max_translations_per_thread
Definition: nat44_ed.api:234
snat_main_s::num_workers
u32 num_workers
Definition: nat44_ed.h:513
vec_terminate_c_string
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
Definition: vec.h:1132
vl_api_nat44_show_running_config_reply_t::sessions
u32 sessions
Definition: nat44_ed.api:276
vl_api_nat44_interface_output_feature_dump_t::context
u32 context
Definition: nat44_ed.api:745
snat_interface_t
Definition: nat44_ed.h:441
vl_api_nat44_add_del_static_mapping_t::external_sw_if_index
vl_api_interface_index_t external_sw_if_index
Definition: nat44_ed.api:791
vl_api_nat_set_log_level_t
Set NAT logging level.
Definition: nat44_ed.api:315
vl_api_nat_get_mss_clamping_reply_t
Get TCP MSS rewriting configuration reply.
Definition: nat44_ed.api:500
pool_free
#define pool_free(p)
Free a pool.
Definition: pool.h:447
vl_api_nat44_forwarding_is_enabled_t::context
u32 context
Definition: nat44_ed.api:1191
snat_static_mapping_t::external_addr
ip4_address_t external_addr
Definition: nat44_ed.h:415
vlib_worker_thread_t::name
u8 * name
Definition: threads.h:102
vl_api_nat_worker_dump_t_handler
static void vl_api_nat_worker_dump_t_handler(vl_api_nat_worker_dump_t *mp)
Definition: nat44_ed_api.c:143
nat44_config_t::connection_tracking
u8 connection_tracking
Definition: nat44_ed.h:63
vl_api_nat44_identity_mapping_details_t::ip_address
vl_api_ip4_address_t ip_address
Definition: nat44_ed.api:924
send_nat44_user_details
static void send_nat44_user_details(snat_user_t *u, vl_api_registration_t *reg, u32 context)
Definition: nat44_ed_api.c:1342
is_fwd_bypass_session
#define is_fwd_bypass_session(s)
Check if NAT session is forwarding bypass.
Definition: nat44_ed.h:748
vl_api_nat_set_workers_t_handler
static void vl_api_nat_set_workers_t_handler(vl_api_nat_set_workers_t *mp)
Definition: nat44_ed_api.c:98
nat_interface_is_outside
#define nat_interface_is_outside(i)
Check if NAT interface is outside.
Definition: nat44_ed.h:778
snat_user_key_t::as_u64
u64 as_u64
Definition: nat44_ed_api.c:1322
vl_api_nat44_lb_static_mapping_details_t::tag
string tag[64]
Definition: nat44_ed.api:1139
nat44_plugin_disable
int nat44_plugin_disable()
Disable NAT44 plugin.
Definition: nat44_ed.c:2179
snat_user_t::nsessions
u32 nsessions
Definition: nat44_ed_api.c:1330
context
u32 context
Definition: ip.api:780
snat_static_mapping_t
Definition: nat44_ed.h:408
vl_api_nat44_interface_add_del_feature_t
Enable/disable NAT44 feature on the interface.
Definition: nat44_ed.api:691
rv
int __clib_unused rv
Definition: application.c:491
vl_api_nat44_lb_static_mapping_details_t::context
u32 context
Definition: nat44_ed.api:1133
vl_api_nat44_ed_show_fq_options_t_handler
static void vl_api_nat44_ed_show_fq_options_t_handler(vl_api_nat44_ed_show_fq_options_t *mp)
Definition: nat44_ed_api.c:80
vl_api_nat44_forwarding_enable_disable_t
Enable/disable forwarding for NAT44 Forward packets which don't match existing translation or static ...
Definition: nat44_ed.api:1177
vrf_id
u32 vrf_id
Definition: nat44_ed.api:1053
vl_api_nat_worker_details_t::name
string name[64]
Definition: nat44_ed.api:352
vl_api_nat44_add_del_static_mapping_t
Add/delete NAT44 static mapping.
Definition: nat44_ed.api:781
vl_api_nat44_user_session_dump_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:1002
nat44_config_t::outside_vrf
u32 outside_vrf
Definition: nat44_ed.h:66
vl_api_nat44_add_del_address_range_t::first_ip_address
vl_api_ip4_address_t first_ip_address
Definition: nat44_ed.api:654
snat_static_map_resolve_t
Definition: nat44_ed.h:447
vl_api_nat44_interface_dump_t_handler
static void vl_api_nat44_interface_dump_t_handler(vl_api_nat44_interface_dump_t *mp)
Definition: nat44_ed_api.c:409
vl_api_nat44_user_session_dump_t
NAT44 user's sessions.
Definition: nat44_ed.api:998
vl_api_nat_show_config_2_reply_t::endpoint_dependent
bool endpoint_dependent
Definition: nat44_ed.api:220
snat_add_address
int snat_add_address(snat_main_t *sm, ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
Add external address to NAT44 pool.
Definition: nat44_ed.c:320
snat_main_per_thread_data_t
Definition: nat44_ed.h:465
nat44_add_del_lb_static_mapping
int nat44_add_del_lb_static_mapping(ip4_address_t e_addr, u16 e_port, nat_protocol_t proto, nat44_lb_addr_port_t *locals, u8 is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u32 affinity)
Add/delete static mapping with load-balancing (multiple backends)
Definition: nat44_ed.c:856
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
vl_api_nat44_identity_mapping_dump_t::client_index
u32 client_index
Definition: nat44_ed.api:907
vl_api_nat44_add_del_lb_static_mapping_t::locals
vl_api_nat44_lb_addr_port_t locals[local_num]
Definition: nat44_ed.api:1085
vl_api_nat_show_config_reply_t::static_mapping_only
bool static_mapping_only
Definition: nat44_ed.api:159
vl_api_nat_get_mss_clamping_t
Get TCP MSS rewriting configuration.
Definition: nat44_ed.api:489
NAT44_IS_CONNECTION_TRACKING
@ NAT44_IS_CONNECTION_TRACKING
Definition: nat44_ed.api:34
vl_api_nat44_ed_show_fq_options_t
Show NAT handoff frame queue options.
Definition: nat44_ed.api:1220
vl_api_nat44_user_session_details_t::ext_host_address
vl_api_ip4_address_t ext_host_address
Definition: nat44_ed.api:1037
vl_api_nat44_add_del_identity_mapping_t_handler
static void vl_api_nat44_add_del_identity_mapping_t_handler(vl_api_nat44_add_del_identity_mapping_t *mp)
Definition: nat44_ed_api.c:685
vl_api_nat44_ed_set_fq_options_t_handler
static void vl_api_nat44_ed_set_fq_options_t_handler(vl_api_nat44_ed_set_fq_options_t *mp)
Definition: nat44_ed_api.c:69
vl_api_nat44_address_details_t
NAT44 address details response.
Definition: nat44_ed.api:676
ip4_main_t
IPv4 main type.
Definition: ip4.h:107
fib_table_find
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1106
send_nat44_identity_map_resolve_details
static void send_nat44_identity_map_resolve_details(snat_static_map_resolve_t *m, vl_api_registration_t *reg, u32 context)
Definition: nat44_ed_api.c:749
snat_static_mapping_t::local_port
u16 local_port
Definition: nat44_ed.h:417
vl_api_nat44_show_running_config_t
Show NAT44 plugin running config.
Definition: nat44_ed.api:242
snat_main_s::static_mapping_only
u8 static_mapping_only
Definition: nat44_ed.h:590
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
vl_api_nat_worker_details_t
NAT workers details response.
Definition: nat44_ed.api:348
vl_api_nat44_user_session_details_t::last_heard
u64 last_heard
Definition: nat44_ed.api:1034
snat_static_map_resolve_t::e_port
u16 e_port
Definition: nat44_ed.h:452
vl_api_nat44_ed_plugin_enable_disable_t_handler
static void vl_api_nat44_ed_plugin_enable_disable_t_handler(vl_api_nat44_ed_plugin_enable_disable_t *mp)
Definition: nat44_ed_api.c:40
vl_api_nat44_user_session_details_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:1033
vl_api_nat_control_ping_t
Control ping from client to api server request.
Definition: nat44_ed.api:100
vl_api_nat_ipfix_enable_disable_t::src_port
u16 src_port
Definition: nat44_ed.api:367
vl_api_nat_get_addr_and_port_alloc_alg_reply_t
Get address and port assignment algorithm reply.
Definition: nat44_ed.api:461
ip_types_api.h
send_nat44_user_session_details
static void send_nat44_user_session_details(snat_session_t *s, vl_api_registration_t *reg, u32 context)
Definition: nat44_ed_api.c:1461
snat_static_map_resolve_t::l_addr
ip4_address_t l_addr
Definition: nat44_ed.h:449
snat_main_s::static_mapping_connection_tracking
u8 static_mapping_connection_tracking
Definition: nat44_ed.h:591
vl_api_nat44_user_session_dump_t_handler
static void vl_api_nat44_user_session_dump_t_handler(vl_api_nat44_user_session_dump_t *mp)
Definition: nat44_ed_api.c:1514
user_create_helper_t::user_buckets
u32 user_buckets
Definition: nat44_ed_api.c:1336
vl_api_nat44_interface_addr_dump_t_handler
static void vl_api_nat44_interface_addr_dump_t_handler(vl_api_nat44_interface_addr_dump_t *mp)
Definition: nat44_ed_api.c:859
snat_main_s::auto_add_sw_if_indices_twice_nat
u32 * auto_add_sw_if_indices_twice_nat
Definition: nat44_ed.h:566
vl_api_nat44_session_cleanup_t_handler
static void vl_api_nat44_session_cleanup_t_handler(vl_api_nat44_session_cleanup_t *mp)
Definition: nat44_ed_api.c:1170
clib_bitmap_set_multiple
static uword * clib_bitmap_set_multiple(uword *bitmap, uword i, uword value, uword n_bits)
sets the ith through ith + n_bits bits in a bitmap
Definition: bitmap.h:275
vl_api_nat44_plugin_enable_disable_t::user_sessions
u32 user_sessions
Definition: nat44_ed.api:68
vl_api_nat44_identity_mapping_dump_t
Dump NAT44 identity mappings.
Definition: nat44_ed.api:906
vl_api_nat44_user_details_t::nstaticsessions
u32 nstaticsessions
Definition: nat44_ed.api:989
vl_api_nat_show_config_2_reply_t::static_mapping_only
bool static_mapping_only
Definition: nat44_ed.api:217
vl_api_nat44_add_del_address_range_t_handler
static void vl_api_nat44_add_del_address_range_t_handler(vl_api_nat44_add_del_address_range_t *mp)
Definition: nat44_ed_api.c:266
vl_api_nat_worker_dump_t::context
u32 context
Definition: nat44_ed.api:339
vl_api_nat_worker_details_t::context
u32 context
Definition: nat44_ed.api:349
vl_msg_api_alloc
void * vl_msg_api_alloc(int nbytes)
Definition: memory_shared.c:199
snat_main_s::output_feature_interfaces
snat_interface_t * output_feature_interfaces
Definition: nat44_ed.h:539
vl_api_nat44_forwarding_is_enabled_reply_t::enabled
bool enabled
Definition: nat44_ed.api:1201
vl_api_nat44_user_session_details_t::inside_ip_address
vl_api_ip4_address_t inside_ip_address
Definition: nat44_ed.api:1030
vl_api_nat_show_config_reply_t
DEPRECATED: Show NAT plugin startup config reply.
Definition: nat44_ed.api:154