misc: move to new pool_foreach macros
[vpp.git] / src / plugins / nat / in2out.c
index 3995725..309329f 100644 (file)
 
 #include <vlib/vlib.h>
 #include <vnet/vnet.h>
-#include <vnet/pg/pg.h>
 
 #include <vnet/ip/ip.h>
 #include <vnet/ethernet/ethernet.h>
 #include <vnet/fib/ip4_fib.h>
-#include <vnet/udp/udp.h>
+#include <vnet/udp/udp_local.h>
 #include <nat/nat.h>
-#include <nat/nat_ipfix_logging.h>
+#include <nat/lib/ipfix_logging.h>
 #include <nat/nat_inlines.h>
 #include <nat/nat44/inlines.h>
-#include <nat/nat_syslog.h>
+#include <nat/lib/nat_syslog.h>
 #include <nat/nat_ha.h>
 
 #include <vppinfra/hash.h>
@@ -135,7 +134,7 @@ snat_not_translate (snat_main_t * sm, vlib_node_runtime_t * node,
       if (!snat_static_mapping_match
          (sm, ip0->dst_address, udp0->dst_port, sm->outside_fib_index,
           proto0, &placeholder_addr, &placeholder_port,
-          &placeholder_fib_index, 1, 0, 0, 0, 0, 0))
+          &placeholder_fib_index, 1, 0, 0, 0, 0, 0, 0))
        return 0;
     }
   else
@@ -172,11 +171,11 @@ nat_not_translate_output_feature (snat_main_t * sm, ip4_header_t * ip0,
     {
       /* hairpinning */
     /* *INDENT-OFF* */
-    pool_foreach (i, sm->output_feature_interfaces,
-    ({
+    pool_foreach (i, sm->output_feature_interfaces)
+     {
       if ((nat_interface_is_inside(i)) && (sw_if_index == i->sw_if_index))
         return 0;
-    }));
+    }
     /* *INDENT-ON* */
       return 1;
     }
@@ -204,13 +203,13 @@ nat44_i2o_is_idle_session_cb (clib_bihash_kv_8_8_t * kv, void *arg)
       if (clib_bihash_add_del_8_8 (&tsm->out2in, &s_kv, 0))
        nat_elog_warn ("out2in key del failed");
 
-      snat_ipfix_logging_nat44_ses_delete (ctx->thread_index,
-                                          s->in2out.addr.as_u32,
-                                          s->out2in.addr.as_u32,
-                                          s->nat_proto,
-                                          s->in2out.port,
-                                          s->out2in.port,
-                                          s->in2out.fib_index);
+      nat_ipfix_logging_nat44_ses_delete (ctx->thread_index,
+                                         s->in2out.addr.as_u32,
+                                         s->out2in.addr.as_u32,
+                                         s->nat_proto,
+                                         s->in2out.port,
+                                         s->out2in.port,
+                                         s->in2out.fib_index);
 
       nat_syslog_nat44_apmdel (s->user_index, s->in2out.fib_index,
                               &s->in2out.addr, s->in2out.port,
@@ -274,7 +273,7 @@ slow_path (snat_main_t * sm, vlib_buffer_t * b0,
   /* First try to match static mapping by local address and port */
   if (snat_static_mapping_match
       (sm, i2o_addr, i2o_port, rx_fib_index0, nat_proto, &sm_addr,
-       &sm_port, &sm_fib_index, 0, 0, 0, 0, 0, &identity_nat))
+       &sm_port, &sm_fib_index, 0, 0, 0, 0, 0, &identity_nat, 0))
     {
       /* Try to create dynamic translation */
       if (snat_alloc_outside_address_and_port (sm->addresses, rx_fib_index0,
@@ -371,12 +370,12 @@ slow_path (snat_main_t * sm, vlib_buffer_t * b0,
     nat_elog_notice ("out2in key add failed");
 
   /* log NAT event */
-  snat_ipfix_logging_nat44_ses_create (thread_index,
-                                      s->in2out.addr.as_u32,
-                                      s->out2in.addr.as_u32,
-                                      s->nat_proto,
-                                      s->in2out.port,
-                                      s->out2in.port, s->in2out.fib_index);
+  nat_ipfix_logging_nat44_ses_create (thread_index,
+                                     s->in2out.addr.as_u32,
+                                     s->out2in.addr.as_u32,
+                                     s->nat_proto,
+                                     s->in2out.port,
+                                     s->out2in.port, s->in2out.fib_index);
 
   nat_syslog_nat44_apmadd (s->user_index, s->in2out.fib_index,
                           &s->in2out.addr, s->in2out.port, &s->out2in.addr,
@@ -599,7 +598,7 @@ icmp_match_in2out_fast (snat_main_t * sm, vlib_node_runtime_t * node,
 
   if (snat_static_mapping_match
       (sm, *addr, *port, *fib_index, *proto, &sm_addr, &sm_port,
-       &sm_fib_index, 0, &is_addr_only, 0, 0, 0, 0))
+       &sm_fib_index, 0, &is_addr_only, 0, 0, 0, 0, 0))
     {
       if (PREDICT_FALSE (snat_not_translate_fast (sm, node, sw_if_index0, ip0,
                                                  IP_PROTOCOL_ICMP,
@@ -1842,7 +1841,7 @@ VLIB_NODE_FN (snat_in2out_fast_node) (vlib_main_t * vm,
 
          if (snat_static_mapping_match
              (sm, ip0->src_address, udp0->src_port, rx_fib_index0, proto0,
-              &sm0_addr, &sm0_port, &sm0_fib_index, 0, 0, 0, 0, 0, 0))
+              &sm0_addr, &sm0_port, &sm0_fib_index, 0, 0, 0, 0, 0, 0, 0))
            {
              b0->error = node->errors[SNAT_IN2OUT_ERROR_NO_TRANSLATION];
              next0 = SNAT_IN2OUT_NEXT_DROP;
@@ -1912,9 +1911,9 @@ VLIB_NODE_FN (snat_in2out_fast_node) (vlib_main_t * vm,
            }
 
          /* Hairpinning */
-         snat_hairpinning (vm, node, sm, b0, ip0, udp0, tcp0, proto0, 0,
-                           0 /* do_trace */ );
-         is_hairpinning = 1;
+         is_hairpinning =
+           snat_hairpinning (vm, node, sm, b0, ip0, udp0, tcp0, proto0, 0,
+                             0 /* do_trace */ );
 
        trace0:
          if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)