FD.io VPP  v21.10.1-2-g0a485f517
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  {
307  rv = nat44_ed_add_address (&this_addr, vrf_id, twice_nat);
308  }
309  else
310  {
311  rv = nat44_ed_del_address (this_addr, 0, twice_nat);
312  }
313 
314  if (rv)
315  goto send_reply;
316 
317  increment_v4_address (&this_addr);
318  }
319 
320 send_reply:
321  REPLY_MACRO (VL_API_NAT44_ADD_DEL_ADDRESS_RANGE_REPLY);
322 }
323 
324 static void
327  u8 twice_nat)
328 {
330  snat_main_t *sm = &snat_main;
331 
332  rmp = vl_msg_api_alloc (sizeof (*rmp));
333  clib_memset (rmp, 0, sizeof (*rmp));
334  rmp->_vl_msg_id = ntohs (VL_API_NAT44_ADDRESS_DETAILS + sm->msg_id_base);
335  clib_memcpy (rmp->ip_address, &(a->addr), 4);
336  if (a->fib_index != ~0)
337  {
338  fib_table_t *fib = fib_table_get (a->fib_index, FIB_PROTOCOL_IP4);
339  rmp->vrf_id = ntohl (fib->ft_table_id);
340  }
341  else
342  rmp->vrf_id = ~0;
343  if (twice_nat)
344  rmp->flags |= NAT_API_IS_TWICE_NAT;
345  rmp->context = context;
346 
347  vl_api_send_msg (reg, (u8 *) rmp);
348 }
349 
350 static void
352 {
354  snat_main_t *sm = &snat_main;
355  snat_address_t *a;
356 
358  if (!reg)
359  return;
360 
361  vec_foreach (a, sm->addresses)
362  send_nat44_address_details (a, reg, mp->context, 0);
364  send_nat44_address_details (a, reg, mp->context, 1);
365 }
366 
367 static void
370 {
371  vl_api_nat44_interface_add_del_feature_reply_t *rmp;
372  snat_main_t *sm = &snat_main;
374  u8 is_inside;
375  int rv = 0;
376 
378 
379  is_inside = mp->flags & NAT_API_IS_INSIDE;
380  sw_if_index = ntohl (mp->sw_if_index);
381 
382  if (mp->is_add)
383  {
384  rv = nat44_ed_add_interface (sw_if_index, is_inside);
385  }
386  else
387  {
388  rv = nat44_ed_del_interface (sw_if_index, is_inside);
389  }
390 
392  REPLY_MACRO (VL_API_NAT44_INTERFACE_ADD_DEL_FEATURE_REPLY);
393 }
394 
395 static void
398 {
400  snat_main_t *sm = &snat_main;
401 
402  rmp = vl_msg_api_alloc (sizeof (*rmp));
403  clib_memset (rmp, 0, sizeof (*rmp));
404  rmp->_vl_msg_id = ntohs (VL_API_NAT44_INTERFACE_DETAILS + sm->msg_id_base);
405  rmp->sw_if_index = ntohl (i->sw_if_index);
406 
408  rmp->flags |= NAT_API_IS_INSIDE;
410  rmp->flags |= NAT_API_IS_OUTSIDE;
411 
412  rmp->context = context;
413 
414  vl_api_send_msg (reg, (u8 *) rmp);
415 }
416 
417 static void
419 {
421  snat_main_t *sm = &snat_main;
423 
425  if (!reg)
426  return;
427 
428  pool_foreach (i, sm->interfaces)
429  {
431  }
432 }
433 
434 static void
437 {
438  vl_api_nat44_interface_add_del_output_feature_reply_t *rmp;
439  snat_main_t *sm = &snat_main;
441  int rv = 0;
442 
444 
445  sw_if_index = ntohl (mp->sw_if_index);
446 
447  if (mp->is_add)
448  {
450  }
451  else
452  {
454  }
455 
457  REPLY_MACRO (VL_API_NAT44_INTERFACE_ADD_DEL_OUTPUT_FEATURE_REPLY);
458 }
459 
460 static void
462  vl_api_registration_t * reg,
463  u32 context)
464 {
466  snat_main_t *sm = &snat_main;
467 
468  rmp = vl_msg_api_alloc (sizeof (*rmp));
469  clib_memset (rmp, 0, sizeof (*rmp));
470  rmp->_vl_msg_id =
471  ntohs (VL_API_NAT44_INTERFACE_OUTPUT_FEATURE_DETAILS + sm->msg_id_base);
472  rmp->sw_if_index = ntohl (i->sw_if_index);
473  rmp->context = context;
474 
476  rmp->flags |= NAT_API_IS_INSIDE;
477 
478  vl_api_send_msg (reg, (u8 *) rmp);
479 }
480 
481 static void
484 {
486  snat_main_t *sm = &snat_main;
488 
490  if (!reg)
491  return;
492 
494  {
496  }
497 }
498 
499 static void
502 {
503  vl_api_nat44_add_del_static_mapping_reply_t *rmp;
504 
505  snat_main_t *sm = &snat_main;
506  int rv = 0;
507 
508  ip4_address_t l_addr, e_addr, pool_addr = { 0 };
509  u32 sw_if_index, flags = 0, vrf_id;
510  u16 l_port = 0, e_port = 0;
511  nat_protocol_t proto = 0;
512  u8 *tag = 0;
513 
514  memcpy (&l_addr.as_u8, mp->local_ip_address, 4);
515 
516  if (mp->flags & NAT_API_IS_ADDR_ONLY)
517  {
519  }
520  else
521  {
522  l_port = mp->local_port;
523  e_port = mp->external_port;
525  }
526 
527  if (mp->flags & NAT_API_IS_TWICE_NAT)
528  {
530  }
531 
532  if (mp->flags & NAT_API_IS_SELF_TWICE_NAT)
533  {
535  }
536 
537  if (mp->flags & NAT_API_IS_OUT2IN_ONLY)
538  {
540  }
541 
542  sw_if_index = clib_net_to_host_u32 (mp->external_sw_if_index);
543  if (sw_if_index != ~0)
544  {
546  }
547  else
548  {
549  memcpy (&e_addr.as_u8, mp->external_ip_address, 4);
550  }
551 
552  vrf_id = clib_net_to_host_u32 (mp->vrf_id);
553 
554  if (mp->is_add)
555  {
556  mp->tag[sizeof (mp->tag) - 1] = 0;
557  tag = format (0, "%s", mp->tag);
559 
560  rv = nat44_ed_add_static_mapping (l_addr, e_addr, l_port, e_port, proto,
561  vrf_id, sw_if_index, flags, pool_addr,
562  tag);
563  vec_free (tag);
564  }
565  else
566  {
567  rv = nat44_ed_del_static_mapping (l_addr, e_addr, l_port, e_port, proto,
569  }
570  REPLY_MACRO (VL_API_NAT44_ADD_DEL_STATIC_MAPPING_REPLY);
571 }
572 
573 static void
576 {
577  vl_api_nat44_add_del_static_mapping_v2_reply_t *rmp;
578 
579  snat_main_t *sm = &snat_main;
580  int rv = 0;
581 
582  ip4_address_t l_addr, e_addr, pool_addr;
583  u32 sw_if_index, flags = 0, vrf_id;
584  u16 l_port = 0, e_port = 0;
586  u8 *tag = 0;
587 
588  memcpy (&l_addr.as_u8, mp->local_ip_address, 4);
589  memcpy (&pool_addr.as_u8, mp->pool_ip_address, 4);
590 
591  if (pool_addr.as_u32 != 0)
592  {
594  }
595 
596  if (mp->flags & NAT_API_IS_ADDR_ONLY)
597  {
599  }
600  else
601  {
602  l_port = mp->local_port;
603  e_port = mp->external_port;
604  }
605 
606  if (mp->flags & NAT_API_IS_TWICE_NAT)
607  {
609  }
610 
611  if (mp->flags & NAT_API_IS_SELF_TWICE_NAT)
612  {
614  }
615 
616  if (mp->flags & NAT_API_IS_OUT2IN_ONLY)
617  {
619  }
620 
621  sw_if_index = clib_net_to_host_u32 (mp->external_sw_if_index);
622  if (sw_if_index)
623  {
625  }
626  else
627  {
628  memcpy (&e_addr.as_u8, mp->external_ip_address, 4);
629  }
630 
632  vrf_id = clib_net_to_host_u32 (mp->vrf_id);
633 
634  if (mp->is_add)
635  {
636  mp->tag[sizeof (mp->tag) - 1] = 0;
637  tag = format (0, "%s", mp->tag);
639 
640  rv = nat44_ed_add_static_mapping (l_addr, e_addr, l_port, e_port, proto,
641  vrf_id, sw_if_index, flags, pool_addr,
642  tag);
643  vec_free (tag);
644  }
645  else
646  {
647  rv = nat44_ed_del_static_mapping (l_addr, e_addr, l_port, e_port, proto,
649  }
650  REPLY_MACRO (VL_API_NAT44_ADD_DEL_STATIC_MAPPING_V2_REPLY);
651 }
652 
653 static void
656 {
658  snat_main_t *sm = &snat_main;
659  u32 len = sizeof (*rmp);
660 
661  rmp = vl_msg_api_alloc (len);
662  clib_memset (rmp, 0, len);
663  rmp->_vl_msg_id =
664  ntohs (VL_API_NAT44_STATIC_MAPPING_DETAILS + sm->msg_id_base);
665 
666  clib_memcpy (rmp->local_ip_address, &(m->local_addr), 4);
668  rmp->external_sw_if_index = ~0;
669  rmp->vrf_id = htonl (m->vrf_id);
670  rmp->context = context;
671 
672  // convert these in new api
673 
674  if (is_sm_self_twice_nat (m->flags))
675  {
676  rmp->flags |= NAT_API_IS_SELF_TWICE_NAT;
677  }
678 
679  if (is_sm_out2in_only (m->flags))
680  {
681  rmp->flags |= NAT_API_IS_OUT2IN_ONLY;
682  }
683 
684  if (is_sm_twice_nat (m->flags))
685  {
686  rmp->flags |= NAT_API_IS_TWICE_NAT;
687  }
688 
689  if (is_sm_addr_only (m->flags))
690  {
691  rmp->flags |= NAT_API_IS_ADDR_ONLY;
692  }
693  else
694  {
696  rmp->external_port = m->external_port;
697  rmp->local_port = m->local_port;
698  }
699 
700  if (m->tag)
701  strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
702 
703  vl_api_send_msg (reg, (u8 *) rmp);
704 }
705 
706 static void
708  vl_api_registration_t * reg,
709  u32 context)
710 {
712  snat_main_t *sm = &snat_main;
713 
714  rmp = vl_msg_api_alloc (sizeof (*rmp));
715  clib_memset (rmp, 0, sizeof (*rmp));
716  rmp->_vl_msg_id =
717  ntohs (VL_API_NAT44_STATIC_MAPPING_DETAILS + sm->msg_id_base);
718  clib_memcpy (rmp->local_ip_address, &(m->l_addr), 4);
719  rmp->external_sw_if_index = htonl (m->sw_if_index);
720  rmp->vrf_id = htonl (m->vrf_id);
721  rmp->context = context;
722 
723  if (m->twice_nat)
724  rmp->flags |= NAT_API_IS_TWICE_NAT;
725 
726  if (m->addr_only)
727  {
728  rmp->flags |= NAT_API_IS_ADDR_ONLY;
729  }
730  else
731  {
733  rmp->external_port = m->e_port;
734  rmp->local_port = m->l_port;
735  }
736  if (m->tag)
737  strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
738 
739  vl_api_send_msg (reg, (u8 *) rmp);
740 }
741 
742 static void
744  * mp)
745 {
747  snat_main_t *sm = &snat_main;
750  int j;
751 
753  if (!reg)
754  return;
755 
757  {
758  if (!is_sm_identity_nat (m->flags) && !is_sm_lb (m->flags))
760  }
761 
762  for (j = 0; j < vec_len (sm->to_resolve); j++)
763  {
764  rp = sm->to_resolve + j;
765  if (!rp->identity_nat)
767  }
768 }
769 
770 static void
773 {
774  vl_api_nat44_add_del_identity_mapping_reply_t *rmp;
775 
776  snat_main_t *sm = &snat_main;
777  int rv = 0;
778 
779  ip4_address_t addr, pool_addr = { 0 };
781  nat_protocol_t proto = 0;
782  u16 port = 0;
783  u8 *tag = 0;
784 
786 
787  if (mp->flags & NAT_API_IS_ADDR_ONLY)
788  {
790  }
791  else
792  {
793  port = mp->port;
795  }
796 
797  sw_if_index = clib_net_to_host_u32 (mp->sw_if_index);
798  if (sw_if_index != ~0)
799  {
801  }
802  else
803  {
804  memcpy (&addr.as_u8, mp->ip_address, 4);
805  }
806 
807  vrf_id = clib_net_to_host_u32 (mp->vrf_id);
808 
809  if (mp->is_add)
810  {
811  mp->tag[sizeof (mp->tag) - 1] = 0;
812  tag = format (0, "%s", mp->tag);
814 
816  sw_if_index, flags, pool_addr, tag);
817  vec_free (tag);
818  }
819  else
820  {
822  sw_if_index, flags);
823  }
824  REPLY_MACRO (VL_API_NAT44_ADD_DEL_IDENTITY_MAPPING_REPLY);
825 }
826 
827 static void
830 {
832  snat_main_t *sm = &snat_main;
834 
835  rmp = vl_msg_api_alloc (sizeof (*rmp));
836  clib_memset (rmp, 0, sizeof (*rmp));
837  rmp->_vl_msg_id =
838  ntohs (VL_API_NAT44_IDENTITY_MAPPING_DETAILS + sm->msg_id_base);
839 
840  if (is_sm_addr_only (m->flags))
841  rmp->flags |= NAT_API_IS_ADDR_ONLY;
842 
843  clib_memcpy (rmp->ip_address, &(m->local_addr), 4);
844  rmp->port = m->local_port;
845  rmp->sw_if_index = ~0;
846  rmp->vrf_id = htonl (local->vrf_id);
848  rmp->context = context;
849  if (m->tag)
850  strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
851 
852  vl_api_send_msg (reg, (u8 *) rmp);
853 }
854 
855 static void
857  vl_api_registration_t * reg,
858  u32 context)
859 {
861  snat_main_t *sm = &snat_main;
862 
863  rmp = vl_msg_api_alloc (sizeof (*rmp));
864  clib_memset (rmp, 0, sizeof (*rmp));
865  rmp->_vl_msg_id =
866  ntohs (VL_API_NAT44_IDENTITY_MAPPING_DETAILS + sm->msg_id_base);
867 
868  if (m->addr_only)
869  rmp->flags = (vl_api_nat_config_flags_t) NAT_API_IS_ADDR_ONLY;
870 
871  rmp->port = m->l_port;
872  rmp->sw_if_index = htonl (m->sw_if_index);
873  rmp->vrf_id = htonl (m->vrf_id);
875  rmp->context = context;
876  if (m->tag)
877  strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
878 
879  vl_api_send_msg (reg, (u8 *) rmp);
880 }
881 
882 static void
885 {
887  snat_main_t *sm = &snat_main;
890  int j;
891 
893  if (!reg)
894  return;
895 
897  {
898  if (is_sm_identity_nat (m->flags) && !is_sm_lb (m->flags))
899  {
900  pool_foreach_index (j, m->locals)
901  {
903  }
904  }
905  }
906 
907  for (j = 0; j < vec_len (sm->to_resolve); j++)
908  {
909  rp = sm->to_resolve + j;
910  if (rp->identity_nat)
912  }
913 }
914 
915 static void
918 {
919  snat_main_t *sm = &snat_main;
920  vl_api_nat44_add_del_interface_addr_reply_t *rmp;
921  u32 sw_if_index = ntohl (mp->sw_if_index);
922  u8 twice_nat;
923  int rv = 0;
924 
925  if (sm->static_mapping_only)
926  {
927  rv = VNET_API_ERROR_FEATURE_DISABLED;
928  goto send_reply;
929  }
930 
932 
933  twice_nat = mp->flags & NAT_API_IS_TWICE_NAT;
934 
935  if (mp->is_add)
936  {
938  }
939  else
940  {
942  }
943 
945 
946 send_reply:
947  REPLY_MACRO (VL_API_NAT44_ADD_DEL_INTERFACE_ADDR_REPLY);
948 }
949 
950 static void
953  u8 twice_nat)
954 {
956  snat_main_t *sm = &snat_main;
957 
958  rmp = vl_msg_api_alloc (sizeof (*rmp));
959  clib_memset (rmp, 0, sizeof (*rmp));
960  rmp->_vl_msg_id =
961  ntohs (VL_API_NAT44_INTERFACE_ADDR_DETAILS + sm->msg_id_base);
962  rmp->sw_if_index = ntohl (sw_if_index);
963 
964  if (twice_nat)
965  rmp->flags = (vl_api_nat_config_flags_t) NAT_API_IS_TWICE_NAT;
966  rmp->context = context;
967 
968  vl_api_send_msg (reg, (u8 *) rmp);
969 }
970 
971 static void
973  * mp)
974 {
976  snat_main_t *sm = &snat_main;
977  u32 *i;
978 
980  if (!reg)
981  return;
982 
984  {
986  }
988  {
990  }
991 }
992 
993 static nat44_lb_addr_port_t *
994 unformat_nat44_lb_addr_port (vl_api_nat44_lb_addr_port_t *addr_port_pairs,
995  u32 addr_port_pair_num)
996 {
997  u8 i;
998  nat44_lb_addr_port_t *lb_addr_port_pairs = 0, lb_addr_port;
999  vl_api_nat44_lb_addr_port_t *ap;
1000 
1001  for (i = 0; i < addr_port_pair_num; i++)
1002  {
1003  ap = &addr_port_pairs[i];
1004  clib_memset (&lb_addr_port, 0, sizeof (lb_addr_port));
1005  clib_memcpy (&lb_addr_port.addr, ap->addr, 4);
1006  lb_addr_port.port = ap->port;
1007  lb_addr_port.probability = ap->probability;
1008  lb_addr_port.vrf_id = clib_net_to_host_u32 (ap->vrf_id);
1009  vec_add1 (lb_addr_port_pairs, lb_addr_port);
1010  }
1011 
1012  return lb_addr_port_pairs;
1013 }
1014 
1015 static void
1018 {
1019  snat_main_t *sm = &snat_main;
1020  vl_api_nat44_add_del_lb_static_mapping_reply_t *rmp;
1021  nat44_lb_addr_port_t *locals = 0;
1022  ip4_address_t e_addr;
1024  u32 flags = 0;
1025  u8 *tag = 0;
1026  int rv = 0;
1027 
1028  locals = unformat_nat44_lb_addr_port (mp->locals,
1029  clib_net_to_host_u32 (mp->local_num));
1030  clib_memcpy (&e_addr, mp->external_addr, 4);
1032 
1033  if (mp->flags & NAT_API_IS_TWICE_NAT)
1034  {
1036  }
1037  else if (mp->flags & NAT_API_IS_SELF_TWICE_NAT)
1038  {
1040  }
1041 
1042  if (mp->flags & NAT_API_IS_OUT2IN_ONLY)
1043  {
1045  }
1046 
1047  if (mp->is_add)
1048  {
1049  mp->tag[sizeof (mp->tag) - 1] = 0;
1050  tag = format (0, "%s", mp->tag);
1051  vec_terminate_c_string (tag);
1052 
1054  e_addr, mp->external_port, proto, locals, flags, tag,
1055  clib_net_to_host_u32 (mp->affinity));
1056  }
1057  else
1058  {
1060  flags);
1061  }
1062 
1063  vec_free (locals);
1064  vec_free (tag);
1065  REPLY_MACRO (VL_API_NAT44_ADD_DEL_LB_STATIC_MAPPING_REPLY);
1066 }
1067 
1068 static void
1071 {
1072  snat_main_t *sm = &snat_main;
1073  vl_api_nat44_lb_static_mapping_add_del_local_reply_t *rmp;
1074  int rv = 0;
1075  ip4_address_t e_addr, l_addr;
1077 
1078  clib_memcpy (&e_addr, mp->external_addr, 4);
1079  clib_memcpy (&l_addr, mp->local.addr, 4);
1081 
1083  e_addr, mp->external_port, l_addr, mp->local.port, proto,
1084  clib_net_to_host_u32 (mp->local.vrf_id), mp->local.probability,
1085  mp->is_add);
1086 
1087  REPLY_MACRO (VL_API_NAT44_LB_STATIC_MAPPING_ADD_DEL_LOCAL_REPLY);
1088 }
1089 
1090 static void
1093 {
1095  snat_main_t *sm = &snat_main;
1097  vl_api_nat44_lb_addr_port_t *locals;
1098  u32 local_num = 0;
1099 
1100  rmp = vl_msg_api_alloc (
1101  sizeof (*rmp) + (pool_elts (m->locals) * sizeof (nat44_lb_addr_port_t)));
1102  clib_memset (rmp, 0, sizeof (*rmp));
1103  rmp->_vl_msg_id =
1104  ntohs (VL_API_NAT44_LB_STATIC_MAPPING_DETAILS + sm->msg_id_base);
1105 
1106  clib_memcpy (rmp->external_addr, &(m->external_addr), 4);
1107  rmp->external_port = m->external_port;
1108  rmp->protocol = nat_proto_to_ip_proto (m->proto);
1109  rmp->context = context;
1110 
1111  if (is_sm_self_twice_nat (m->flags))
1112  {
1113  rmp->flags |= NAT_API_IS_SELF_TWICE_NAT;
1114  }
1115 
1116  if (is_sm_out2in_only (m->flags))
1117  {
1118  rmp->flags |= NAT_API_IS_OUT2IN_ONLY;
1119  }
1120 
1121  if (is_sm_twice_nat (m->flags))
1122  {
1123  rmp->flags |= NAT_API_IS_TWICE_NAT;
1124  }
1125 
1126  if (m->tag)
1127  strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
1128 
1129  locals = (vl_api_nat44_lb_addr_port_t *) rmp->locals;
1130  pool_foreach (ap, m->locals)
1131  {
1132  clib_memcpy (locals->addr, &(ap->addr), 4);
1133  locals->port = ap->port;
1134  locals->probability = ap->probability;
1135  locals->vrf_id = ntohl (ap->vrf_id);
1136  locals++;
1137  local_num++;
1138  }
1139  rmp->local_num = ntohl (local_num);
1140 
1141  vl_api_send_msg (reg, (u8 *) rmp);
1142 }
1143 
1144 static void
1147 {
1148  vl_api_registration_t *reg;
1149  snat_main_t *sm = &snat_main;
1151 
1153  if (!reg)
1154  return;
1155 
1156  pool_foreach (m, sm->static_mappings)
1157  {
1158  if (is_sm_lb (m->flags))
1160  }
1161 }
1162 
1163 static void
1165 {
1166  snat_main_t *sm = &snat_main;
1167  vl_api_nat44_del_session_reply_t *rmp;
1168  ip4_address_t addr, eh_addr;
1169  u16 port, eh_port;
1170  u32 vrf_id;
1171  int rv = 0;
1172  u8 is_in;
1173 
1174  memcpy (&addr.as_u8, mp->address, 4);
1175  port = mp->port;
1176  vrf_id = clib_net_to_host_u32 (mp->vrf_id);
1177  memcpy (&eh_addr.as_u8, mp->ext_host_address, 4);
1178  eh_port = mp->ext_host_port;
1179 
1180  is_in = mp->flags & NAT_API_IS_INSIDE;
1181 
1182  rv = nat44_ed_del_session (sm, &addr, port, &eh_addr, eh_port, mp->protocol,
1183  vrf_id, is_in);
1184 
1185  REPLY_MACRO (VL_API_NAT44_DEL_SESSION_REPLY);
1186 }
1187 
1188 static void
1191 {
1192  vl_api_nat44_forwarding_enable_disable_reply_t *rmp;
1193  snat_main_t *sm = &snat_main;
1194  int rv = 0;
1196  REPLY_MACRO (VL_API_NAT44_FORWARDING_ENABLE_DISABLE_REPLY);
1197 }
1198 
1199 static void
1202 {
1203  vl_api_registration_t *reg;
1204  snat_main_t *sm = &snat_main;
1206 
1208  if (!reg)
1209  return;
1210 
1211  rmp = vl_msg_api_alloc (sizeof (*rmp));
1212  clib_memset (rmp, 0, sizeof (*rmp));
1213  rmp->_vl_msg_id =
1214  ntohs (VL_API_NAT44_FORWARDING_IS_ENABLED_REPLY + sm->msg_id_base);
1215  rmp->context = mp->context;
1216 
1217  rmp->enabled = sm->forwarding_enabled;
1218 
1219  vl_api_send_msg (reg, (u8 *) rmp);
1220 }
1221 
1222 /* Obsolete calls hold back because of deprecation
1223  * should not be used */
1224 
1225 static void
1228 {
1229  snat_main_t *sm = &snat_main;
1230  vl_api_nat_set_addr_and_port_alloc_alg_reply_t *rmp;
1231  int rv = VNET_API_ERROR_UNSUPPORTED;
1232  REPLY_MACRO (VL_API_NAT_SET_ADDR_AND_PORT_ALLOC_ALG_REPLY);
1233 }
1234 
1235 static void
1238 {
1239  snat_main_t *sm = &snat_main;
1241  int rv = VNET_API_ERROR_UNSUPPORTED;
1242  REPLY_MACRO (VL_API_NAT_GET_ADDR_AND_PORT_ALLOC_ALG_REPLY);
1243 }
1244 
1245 static void
1247 {
1248  snat_main_t *sm = &snat_main;
1249  vl_api_nat_ha_set_listener_reply_t *rmp;
1250  int rv = VNET_API_ERROR_UNSUPPORTED;
1251  REPLY_MACRO (VL_API_NAT_HA_SET_LISTENER_REPLY);
1252 }
1253 
1254 static void
1256 {
1257  snat_main_t *sm = &snat_main;
1259  int rv = VNET_API_ERROR_UNSUPPORTED;
1260  REPLY_MACRO (VL_API_NAT_HA_GET_LISTENER_REPLY);
1261 }
1262 
1263 static void
1265 {
1266  snat_main_t *sm = &snat_main;
1267  vl_api_nat_ha_set_failover_reply_t *rmp;
1268  int rv = VNET_API_ERROR_UNSUPPORTED;
1269  REPLY_MACRO (VL_API_NAT_HA_SET_FAILOVER_REPLY);
1270 }
1271 
1272 static void
1274 {
1275  snat_main_t *sm = &snat_main;
1277  int rv = VNET_API_ERROR_UNSUPPORTED;
1278  REPLY_MACRO (VL_API_NAT_HA_GET_FAILOVER_REPLY);
1279 }
1280 
1281 static void
1283 {
1284  snat_main_t *sm = &snat_main;
1285  vl_api_nat_ha_flush_reply_t *rmp;
1286  int rv = VNET_API_ERROR_UNSUPPORTED;
1287  REPLY_MACRO (VL_API_NAT_HA_FLUSH_REPLY);
1288 }
1289 
1290 static void
1292 {
1293  snat_main_t *sm = &snat_main;
1294  vl_api_nat_ha_resync_reply_t *rmp;
1295  int rv = VNET_API_ERROR_UNSUPPORTED;
1296  REPLY_MACRO (VL_API_NAT_HA_RESYNC_REPLY);
1297 }
1298 
1299 static void
1301 {
1302  snat_main_t *sm = &snat_main;
1303  vl_api_nat44_del_user_reply_t *rmp;
1304  int rv = VNET_API_ERROR_UNSUPPORTED;
1305  REPLY_MACRO (VL_API_NAT44_DEL_USER_REPLY);
1306 }
1307 
1308 static void
1310 {
1311  snat_main_t *sm = &snat_main;
1312  vl_api_nat44_session_cleanup_reply_t *rmp;
1313  int rv = VNET_API_ERROR_UNSUPPORTED;
1314  REPLY_MACRO (VL_API_NAT44_SESSION_CLEANUP_REPLY);
1315 }
1316 
1317 static void
1320 {
1321  snat_main_t *sm = &snat_main;
1322  nat44_config_t c = { 0 };
1323  vl_api_nat44_plugin_enable_disable_reply_t *rmp;
1324  int rv = 0;
1325 
1326  if (mp->enable)
1327  {
1328  if (mp->users || mp->user_sessions)
1329  {
1330  rv = VNET_API_ERROR_UNSUPPORTED;
1331  }
1332  else
1333  {
1334  c.static_mapping_only = mp->flags & NAT44_API_IS_STATIC_MAPPING_ONLY;
1335  c.connection_tracking = mp->flags & NAT44_API_IS_CONNECTION_TRACKING;
1336 
1337  c.inside_vrf = ntohl (mp->inside_vrf);
1338  c.outside_vrf = ntohl (mp->outside_vrf);
1339 
1340  c.sessions = ntohl (mp->sessions);
1341 
1342  rv = nat44_plugin_enable (c);
1343  }
1344  }
1345  else
1346  {
1347  rv = nat44_plugin_disable ();
1348  }
1349 
1350  REPLY_MACRO (VL_API_NAT44_PLUGIN_ENABLE_DISABLE_REPLY);
1351 }
1352 
1353 static void
1355 {
1357  snat_main_t *sm = &snat_main;
1358  int rv = 0;
1359 
1360  REPLY_MACRO2 (VL_API_NAT_CONTROL_PING_REPLY,
1361  ({ rmp->vpe_pid = ntohl (getpid ()); }));
1362 }
1363 
1364 static void
1366 {
1368  snat_main_t *sm = &snat_main;
1369  int rv = 0;
1370 
1371  REPLY_MACRO2_ZERO (VL_API_NAT_SHOW_CONFIG_REPLY, ({
1372  rmp->translation_buckets =
1373  htonl (sm->translation_buckets);
1374  rmp->user_buckets = 0;
1375  rmp->max_translations_per_user = 0;
1376  rmp->outside_vrf_id = htonl (sm->outside_vrf_id);
1377  rmp->inside_vrf_id = htonl (sm->inside_vrf_id);
1381  rmp->endpoint_dependent = 1;
1382  rmp->out2in_dpo = 0;
1383  }));
1384 }
1385 
1386 static void
1388 {
1390  snat_main_t *sm = &snat_main;
1391  int rv = 0;
1392 
1394  VL_API_NAT_SHOW_CONFIG_2_REPLY, ({
1395  rmp->translation_buckets = htonl (sm->translation_buckets);
1396  rmp->user_buckets = 0;
1397  rmp->max_translations_per_user = 0;
1398  rmp->outside_vrf_id = htonl (sm->outside_vrf_id);
1399  rmp->inside_vrf_id = htonl (sm->inside_vrf_id);
1403  rmp->endpoint_dependent = 1;
1404  rmp->out2in_dpo = 0;
1406  clib_net_to_host_u32 (sm->max_translations_per_thread);
1407  rmp->max_users_per_thread = 0;
1408  }));
1409 }
1410 
1411 static void
1414 {
1416  snat_main_t *sm = &snat_main;
1417  nat44_config_t *rc = &sm->rconfig;
1418  int rv = 0;
1419 
1421  VL_API_NAT44_SHOW_RUNNING_CONFIG_REPLY, ({
1422  rmp->inside_vrf = htonl (rc->inside_vrf);
1423  rmp->outside_vrf = htonl (rc->outside_vrf);
1424 
1425  rmp->sessions = htonl (rc->sessions);
1426  rmp->translation_buckets = htonl (sm->translation_buckets);
1427 
1428  // OBSOLETE
1429  rmp->users = 0;
1430  rmp->user_buckets = 0;
1431  rmp->user_sessions = 0;
1432 
1433  rmp->timeouts.udp = htonl (sm->timeouts.udp);
1434  rmp->timeouts.tcp_established = htonl (sm->timeouts.tcp.established);
1435  rmp->timeouts.tcp_transitory = htonl (sm->timeouts.tcp.transitory);
1436  rmp->timeouts.icmp = htonl (sm->timeouts.icmp);
1437 
1438  rmp->forwarding_enabled = sm->forwarding_enabled == 1;
1439  // consider how to split functionality between subplugins
1442  if (rc->static_mapping_only)
1444  if (rc->connection_tracking)
1446  }));
1447 }
1448 
1449 /* user (internal host) key */
1450 typedef struct
1451 {
1452  union
1453  {
1454  struct
1455  {
1458  };
1460  };
1461 } snat_user_key_t;
1462 
1463 typedef struct
1464 {
1469 } snat_user_t;
1470 
1471 typedef struct
1472 {
1475  clib_bihash_8_8_t user_hash;
1477 
1478 static void
1480  u32 context)
1481 {
1483  snat_main_t *sm = &snat_main;
1484  ip4_main_t *im = &ip4_main;
1485 
1486  rmp = vl_msg_api_alloc (sizeof (*rmp));
1487  clib_memset (rmp, 0, sizeof (*rmp));
1488  rmp->_vl_msg_id = ntohs (VL_API_NAT44_USER_DETAILS + sm->msg_id_base);
1489 
1490  if (!pool_is_free_index (im->fibs, u->fib_index))
1491  {
1493  rmp->vrf_id = ntohl (fib->ft_table_id);
1494  }
1495 
1496  clib_memcpy (rmp->ip_address, &(u->addr), 4);
1497  rmp->nsessions = ntohl (u->nsessions);
1498  rmp->nstaticsessions = ntohl (u->nstaticsessions);
1499  rmp->context = context;
1500 
1501  vl_api_send_msg (reg, (u8 *) rmp);
1502 }
1503 
1504 static void
1506 {
1507  snat_user_key_t k;
1508  k.addr = s->in2out.addr;
1509  k.fib_index = s->in2out.fib_index;
1511  key.key = k.as_u64;
1512  snat_user_t *u;
1513 
1514  if (clib_bihash_search_8_8 (&uch->user_hash, &key, &value))
1515  {
1516  pool_get (uch->users, u);
1517  u->addr = k.addr;
1518  u->fib_index = k.fib_index;
1519  u->nsessions = 0;
1520  u->nstaticsessions = 0;
1521  key.value = u - uch->users;
1522  clib_bihash_add_del_8_8 (&uch->user_hash, &key, 1);
1523  }
1524  else
1525  {
1526  u = pool_elt_at_index (uch->users, value.value);
1527  }
1529  {
1530  ++u->nstaticsessions;
1531  }
1532  else
1533  {
1534  ++u->nsessions;
1535  }
1536 }
1537 
1538 u8 *
1539 format_user_kvp (u8 *s, va_list *args)
1540 {
1541  clib_bihash_kv_8_8_t *v = va_arg (*args, clib_bihash_kv_8_8_t *);
1542  snat_user_key_t k;
1543  k.as_u64 = v->key;
1544  s = format (s, "%U fib %d user-index %llu", format_ip4_address, &k.addr,
1545  k.fib_index, v->value);
1546  return s;
1547 }
1548 
1549 static void
1551  user_create_helper_t *uch)
1552 {
1553  snat_session_t *s;
1554  clib_bihash_init_8_8 (&uch->user_hash, "users", uch->user_buckets, 0);
1555  clib_bihash_set_kvp_format_fn_8_8 (&uch->user_hash, format_user_kvp);
1556  pool_foreach (s, tsm->sessions)
1557  {
1558  nat_ed_user_create_helper (uch, s);
1559  }
1560 }
1561 
1562 static void
1564 {
1565  pool_free (uch->users);
1566  clib_bihash_free_8_8 (&uch->user_hash);
1567 }
1568 
1569 static void
1571 {
1573  vl_api_registration_t *reg;
1574  snat_main_t *sm = &snat_main;
1576  snat_user_t *u;
1577 
1578  clib_memset (&uch, 0, sizeof (uch));
1579 
1581 
1583  if (!reg)
1584  return;
1585 
1586  vec_foreach (tsm, sm->per_thread_data)
1587  {
1588  nat_ed_users_create (tsm, &uch);
1589  pool_foreach (u, uch.users)
1590  {
1591  send_nat44_user_details (u, reg, mp->context);
1592  }
1593  nat_ed_users_destroy (&uch);
1594  }
1595 }
1596 
1597 static void
1600 {
1602  snat_main_t *sm = &snat_main;
1603 
1604  rmp = vl_msg_api_alloc (sizeof (*rmp));
1605  clib_memset (rmp, 0, sizeof (*rmp));
1606  rmp->_vl_msg_id =
1607  ntohs (VL_API_NAT44_USER_SESSION_DETAILS + sm->msg_id_base);
1608  clib_memcpy (rmp->outside_ip_address, (&s->out2in.addr), 4);
1609  clib_memcpy (rmp->inside_ip_address, (&s->in2out.addr), 4);
1610 
1612  rmp->flags |= NAT_API_IS_STATIC;
1613 
1615  rmp->flags |= NAT_API_IS_TWICE_NAT;
1616 
1617  rmp->flags |= NAT_API_IS_EXT_HOST_VALID;
1618 
1619  rmp->last_heard = clib_host_to_net_u64 ((u64) s->last_heard);
1620  rmp->total_bytes = clib_host_to_net_u64 (s->total_bytes);
1621  rmp->total_pkts = ntohl (s->total_pkts);
1622  rmp->context = context;
1623  if (snat_is_unk_proto_session (s))
1624  {
1625  rmp->outside_port = 0;
1626  rmp->inside_port = 0;
1627  rmp->protocol = ntohs (s->in2out.port);
1628  }
1629  else
1630  {
1631  rmp->outside_port = s->out2in.port;
1632  rmp->inside_port = s->in2out.port;
1633  rmp->protocol = ntohs (nat_proto_to_ip_proto (s->nat_proto));
1634  }
1635  clib_memcpy (rmp->ext_host_address, &s->ext_host_addr, 4);
1636  rmp->ext_host_port = s->ext_host_port;
1638  {
1639  clib_memcpy (rmp->ext_host_nat_address, &s->ext_host_nat_addr, 4);
1640  rmp->ext_host_nat_port = s->ext_host_nat_port;
1641  }
1642 
1643  vl_api_send_msg (reg, (u8 *) rmp);
1644 }
1645 
1646 static void
1648  mp)
1649 {
1651  snat_main_t *sm = &snat_main;
1652  vl_api_registration_t *reg;
1653  snat_user_key_t ukey;
1654  snat_session_t *s;
1655  ip4_header_t ip;
1656 
1658  if (!reg)
1659  return;
1660 
1661  clib_memcpy (&ukey.addr, mp->ip_address, 4);
1662  ip.src_address.as_u32 = ukey.addr.as_u32;
1663  ukey.fib_index = fib_table_find (FIB_PROTOCOL_IP4, ntohl (mp->vrf_id));
1664  if (sm->num_workers > 1)
1665  tsm = vec_elt_at_index (
1666  sm->per_thread_data,
1668  else
1669  tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers);
1670 
1671  pool_foreach (s, tsm->sessions) {
1672  if (s->in2out.addr.as_u32 == ukey.addr.as_u32)
1673  {
1675  }
1676  }
1677 }
1678 
1679 /* API definitions */
1680 #include <vnet/format_fns.h>
1681 #include <nat/nat44-ed/nat44_ed.api.c>
1682 
1683 /* Set up the API message handling tables */
1684 clib_error_t *
1686 {
1687  snat_main_t *sm = &snat_main;
1689  return 0;
1690 }
1691 
1692 /*
1693  * fd.io coding-style-patch-verification: ON
1694  *
1695  * Local Variables:
1696  * eval: (c-set-style "gnu")
1697  * End:
1698  */
nat44_ed_is_interface_outside
static bool nat44_ed_is_interface_outside(snat_interface_t *i)
Check if NAT interface is outside.
Definition: nat44_ed.h:808
snat_main_s::to_resolve
snat_static_map_resolve_t * to_resolve
Definition: nat44_ed.h:572
is_sm_lb
static bool is_sm_lb(u32 f)
Definition: nat44_ed.h:852
tmp
u32 * tmp
Definition: interface_output.c:1096
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
snat_is_unk_proto_session
static bool snat_is_unk_proto_session(snat_session_t *s)
Check if SNAT session for unknown protocol.
Definition: nat44_ed.h:738
vl_api_nat44_interface_output_feature_dump_t::client_index
u32 client_index
Definition: nat44_ed.api:744
nat_timeouts_t::tcp
struct nat_timeouts_t::@742 tcp
snat_set_workers
int snat_set_workers(uword *bitmap)
Definition: nat44_ed.c:2032
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:415
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:1387
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:994
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
nat44_ed_del_static_mapping
int nat44_ed_del_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, nat_protocol_t proto, u32 vrf_id, u32 sw_if_index, u32 flags)
Definition: nat44_ed.c:983
snat_static_mapping_t::locals
nat44_lb_addr_port_t * locals
Definition: nat44_ed.h:437
snat_main_s::outside_vrf_id
u32 outside_vrf_id
Definition: nat44_ed.h:603
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
nat44_ed_add_output_interface
int nat44_ed_add_output_interface(u32 sw_if_index)
Definition: nat44_ed.c:1848
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:325
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:531
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:1550
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:1145
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:1539
snat_main_s::twice_nat_addresses
snat_address_t * twice_nat_addresses
Definition: nat44_ed.h:547
nat_log_info
#define nat_log_info(...)
Definition: nat44_ed.h:888
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:351
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:382
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:501
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:654
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:426
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:1255
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
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:1104
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:1463
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
nat44_ed_add_static_mapping
int nat44_ed_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, nat_protocol_t proto, u32 vrf_id, u32 sw_if_index, u32 flags, ip4_address_t pool_addr, u8 *tag)
Definition: nat44_ed.c:783
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:549
vl_api_nat_get_timeouts_reply_t::icmp
u32 icmp
Definition: nat44_ed.api:414
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:1354
vl_api_nat44_forwarding_enable_disable_t::enable
bool enable
Definition: nat44_ed.api:1181
nat44_ed_del_session
int nat44_ed_del_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:3465
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:1282
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:599
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:541
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:454
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
NAT_SM_FLAG_ADDR_ONLY
#define NAT_SM_FLAG_ADDR_ONLY
Definition: nat44_ed.h:192
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:1466
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:435
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:1236
is_sm_out2in_only
static bool is_sm_out2in_only(u32 f)
Definition: nat44_ed.h:840
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:518
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:1189
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:951
nat44_ed_forwarding_enable_disable
void nat44_ed_forwarding_enable_disable(u8 is_enable)
Definition: nat44_ed.c:2524
vl_api_nat44_del_session_t::ext_host_port
u16 ext_host_port
Definition: nat44_ed.api:1167
nat44_ed_add_lb_static_mapping
int nat44_ed_add_lb_static_mapping(ip4_address_t e_addr, u16 e_port, nat_protocol_t proto, nat44_lb_addr_port_t *locals, u32 flags, u8 *tag, u32 affinity)
Definition: nat44_ed.c:1136
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:429
snat_main_s::timeouts
nat_timeouts_t timeouts
Definition: nat44_ed.h:608
nat44_lb_addr_port_t::port
u16 port
Definition: nat44_ed.h:384
snat_static_mapping_t::local_addr
ip4_address_t local_addr
Definition: nat44_ed.h:418
snat_main_s::addresses
snat_address_t * addresses
Definition: nat44_ed.h:545
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:1318
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:1475
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:396
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
vl_api_nat44_user_details_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:986
nat44_ed_add_interface
int nat44_ed_add_interface(u32 sw_if_index, u8 is_inside)
Definition: nat44_ed.c:1635
snat_static_mapping_t::flags
u32 flags
Definition: nat44_ed.h:441
vl_api_nat_ha_set_failover_t
Set HA failover (remote settings)
Definition: nat44_ed.api:530
NAT_SM_FLAG_OUT2IN_ONLY
#define NAT_SM_FLAG_OUT2IN_ONLY
Definition: nat44_ed.h:194
ip4_header_t
Definition: ip4_packet.h:87
snat_user_t::nstaticsessions
u32 nstaticsessions
Definition: nat44_ed_api.c:1468
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:1226
NAT_SM_FLAG_IDENTITY_NAT
#define NAT_SM_FLAG_IDENTITY_NAT
Definition: nat44_ed.h:191
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:657
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:590
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:884
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:91
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:1016
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:1200
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:1365
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:1570
vl_api_nat_get_timeouts_reply_t::tcp_established
u32 tcp_established
Definition: nat44_ed.api:412
snat_address_t
Definition: nat44_ed.h:355
vl_api_nat44_user_dump_t::context
u32 context
Definition: nat44_ed.api:974
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:743
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
is_sm_twice_nat
static bool is_sm_twice_nat(u32 f)
Definition: nat44_ed.h:870
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:522
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:483
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:707
snat_main_s::rconfig
nat44_config_t rconfig
Definition: nat44_ed.h:586
nat44_ed_del_output_interface
int nat44_ed_del_output_interface(u32 sw_if_index)
Definition: nat44_ed.c:1946
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
nat44_ed_del_interface_address
int nat44_ed_del_interface_address(u32 sw_if_index, u8 twice_nat)
Definition: nat44_ed.c:3401
snat_user_key_t::addr
ip4_address_t addr
Definition: nat44_ed_api.c:1456
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:517
nat44_lb_addr_port_t::probability
u8 probability
Definition: nat44_ed.h:386
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
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:1069
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:1164
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: sr_mpls_api.c:174
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
vl_api_nat44_plugin_enable_disable_t::outside_vrf
u32 outside_vrf
Definition: nat44_ed.api:63
is_sm_addr_only
static bool is_sm_addr_only(u32 f)
Definition: nat44_ed.h:834
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:1091
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:1685
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:1450
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
vlib_worker_thread_t::cpu_id
int cpu_id
Definition: threads.h:106
vl_api_nat44_add_del_static_mapping_t::flags
vl_api_nat_config_flags_t flags
Definition: nat44_ed.api:785
NAT_SM_FLAG_TWICE_NAT
#define NAT_SM_FLAG_TWICE_NAT
Definition: nat44_ed.h:190
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:1273
vl_api_nat44_plugin_enable_disable_t::inside_vrf
u32 inside_vrf
Definition: nat44_ed.api:62
NAT_SM_FLAG_EXACT_ADDRESS
#define NAT_SM_FLAG_EXACT_ADDRESS
Definition: nat44_ed.h:193
nat44_ed_is_session_static
static bool nat44_ed_is_session_static(snat_session_t *s)
Check if SNAT session is created from static mapping.
Definition: nat44_ed.h:728
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
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:3046
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_user_t::addr
ip4_address_t addr
Definition: nat44_ed_api.c:1465
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:379
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:424
user_create_helper_t::users
snat_user_t * users
Definition: nat44_ed_api.c:1474
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:828
snat_static_map_resolve_t::addr_only
int addr_only
Definition: nat44_ed.h:460
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:436
snat_static_map_resolve_t::tag
u8 * tag
Definition: nat44_ed.h:465
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:1300
ip4_address_t
Definition: ip4_packet.h:50
vl_api_nat44_del_session_t::vrf_id
u32 vrf_id
Definition: nat44_ed.api:1164
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
nat44_ed_add_del_lb_static_mapping_local
int nat44_ed_add_del_lb_static_mapping_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:1399
snat_main_s
Definition: nat44_ed.h:513
snat_main_per_thread_data_t::sessions
snat_session_t * sessions
Definition: nat44_ed.h:471
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)
Definition: nat44_ed.c:2364
snat_static_map_resolve_t::twice_nat
int twice_nat
Definition: nat44_ed.h:461
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_add_address
int nat44_ed_add_address(ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
Definition: nat44_ed.c:388
nat44_ed_set_frame_queue_nelts
int nat44_ed_set_frame_queue_nelts(u32 frame_queue_nelts)
Definition: nat44_ed.c:2058
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:1264
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:463
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:1563
snat_user_key_t::fib_index
u32 fib_index
Definition: nat44_ed_api.c:1457
nat44_ed_is_twice_nat_session
static bool nat44_ed_is_twice_nat_session(snat_session_t *s)
Check if NAT session is twice NAT.
Definition: nat44_ed.h:748
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
nat44_ed_del_lb_static_mapping
int nat44_ed_del_lb_static_mapping(ip4_address_t e_addr, u16 e_port, nat_protocol_t proto, u32 flags)
Definition: nat44_ed.c:1279
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:652
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:671
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:572
nat44_config_t
Definition: nat44_ed.h:59
user_create_helper_t
Definition: nat44_ed_api.c:1471
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
nat44_lb_addr_port_t::vrf_id
u32 vrf_id
Definition: nat44_ed.h:389
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
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:1246
vl_api_nat_set_workers_t::worker_mask
u64 worker_mask
Definition: nat44_ed.api:330
is_sm_self_twice_nat
static bool is_sm_self_twice_nat(u32 f)
Definition: nat44_ed.h:864
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
nat44_ed_is_interface_inside
static bool nat44_ed_is_interface_inside(snat_interface_t *i)
Check if NAT interface is inside.
Definition: nat44_ed.h:798
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
is_sm_identity_nat
static bool is_sm_identity_nat(u32 f)
Definition: nat44_ed.h:846
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:917
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:1412
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:550
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:1505
snat_main_s::mss_clamping
u16 mss_clamping
Definition: nat44_ed.h:611
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:1291
vl_api_nat44_user_dump_t::client_index
u32 client_index
Definition: nat44_ed.api:973
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:81
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:600
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:457
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:2757
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:575
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:605
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:369
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
NAT_SM_FLAG_SWITCH_ADDRESS
#define NAT_SM_FLAG_SWITCH_ADDRESS
Definition: nat44_ed.h:196
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:458
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:456
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
NAT_SM_FLAG_SELF_TWICE_NAT
#define NAT_SM_FLAG_SELF_TWICE_NAT
Definition: nat44_ed.h:189
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:461
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
vl_api_nat44_user_session_details_t
NAT44 user's sessions response.
Definition: nat44_ed.api:1026
a
a
Definition: bitmap.h:525
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:516
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:444
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
i
int i
Definition: flowhash_template.h:376
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:420
vlib_worker_thread_t::name
u8 * name
Definition: threads.h:98
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:1479
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
snat_user_key_t::as_u64
u64 as_u64
Definition: nat44_ed_api.c:1459
vl_api_nat44_lb_static_mapping_details_t::tag
string tag[64]
Definition: nat44_ed.api:1139
nat44_plugin_disable
int nat44_plugin_disable()
Definition: nat44_ed.c:2457
snat_user_t::nsessions
u32 nsessions
Definition: nat44_ed_api.c:1467
context
u32 context
Definition: ip.api:852
snat_static_mapping_t
Definition: nat44_ed.h:413
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:450
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:418
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_main_per_thread_data_t
Definition: nat44_ed.h:468
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:772
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:1111
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:856
snat_static_mapping_t::local_port
u16 local_port
Definition: nat44_ed.h:422
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:593
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:455
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
nat44_ed_del_interface
int nat44_ed_del_interface(u32 sw_if_index, u8 is_inside)
Definition: nat44_ed.c:1743
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:1598
nat44_ed_add_interface_address
int nat44_ed_add_interface_address(u32 sw_if_index, u8 twice_nat)
Definition: nat44_ed.c:3362
snat_static_map_resolve_t::l_addr
ip4_address_t l_addr
Definition: nat44_ed.h:452
snat_main_s::static_mapping_connection_tracking
u8 static_mapping_connection_tracking
Definition: nat44_ed.h:594
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:1647
user_create_helper_t::user_buckets
u32 user_buckets
Definition: nat44_ed_api.c:1473
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:972
nat44_ed_del_address
int nat44_ed_del_address(ip4_address_t addr, u8 delete_sm, u8 twice_nat)
Definition: nat44_ed.c:449
snat_main_s::auto_add_sw_if_indices_twice_nat
u32 * auto_add_sw_if_indices_twice_nat
Definition: nat44_ed.h:551
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:1309
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:542
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
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105
vl_api_nat_show_config_reply_t
DEPRECATED: Show NAT plugin startup config reply.
Definition: nat44_ed.api:154