api: clean up use of deprecated flag
[vpp.git] / src / plugins / nat / nat_format.c
index 33e9655..f0e7a5d 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <nat/nat.h>
 #include <nat/nat_inlines.h>
-#include <nat/nat_det.h>
 
 uword
 unformat_nat_protocol (unformat_input_t * input, va_list * args)
@@ -76,23 +75,19 @@ format_nat_addr_and_port_alloc_alg (u8 * s, va_list * args)
 u8 *
 format_snat_key (u8 * s, va_list * args)
 {
-  snat_session_key_t *key = va_arg (*args, snat_session_key_t *);
+  u64 key = va_arg (*args, u64);
 
-  s = format (s, "%U proto %U port %d fib %d",
-             format_ip4_address, &key->addr,
-             format_nat_protocol, key->protocol,
-             clib_net_to_host_u16 (key->port), key->fib_index);
-  return s;
-}
+  ip4_address_t addr;
+  u16 port;
+  nat_protocol_t protocol;
+  u32 fib_index;
 
-u8 *
-format_static_mapping_key (u8 * s, va_list * args)
-{
-  snat_session_key_t *key = va_arg (*args, snat_session_key_t *);
+  split_nat_key (key, &addr, &port, &fib_index, &protocol);
 
   s = format (s, "%U proto %U port %d fib %d",
-             format_ip4_address, &key->addr,
-             format_nat_protocol, key->protocol, key->port, key->fib_index);
+             format_ip4_address, &addr,
+             format_nat_protocol, protocol,
+             clib_net_to_host_u16 (port), fib_index);
   return s;
 }
 
@@ -126,14 +121,22 @@ format_snat_session (u8 * s, va_list * args)
       s = format (s, "  i2o %U proto %u fib %u\n",
                  format_ip4_address, &sess->in2out.addr,
                  sess->in2out.port, sess->in2out.fib_index);
-      s = format (s, "    o2i %U proto %u fib %u\n",
+      s = format (s, "  o2i %U proto %u fib %u\n",
                  format_ip4_address, &sess->out2in.addr,
                  sess->out2in.port, sess->out2in.fib_index);
     }
   else
     {
-      s = format (s, "  i2o %U\n", format_snat_key, &sess->in2out);
-      s = format (s, "    o2i %U\n", format_snat_key, &sess->out2in);
+      s = format (s, "  i2o %U proto %U port %d fib %d\n",
+                 format_ip4_address, &sess->in2out.addr,
+                 format_nat_protocol, sess->nat_proto,
+                 clib_net_to_host_u16 (sess->in2out.port),
+                 sess->in2out.fib_index);
+      s = format (s, "  o2i %U proto %U port %d fib %d\n",
+                 format_ip4_address, &sess->out2in.addr,
+                 format_nat_protocol, sess->nat_proto,
+                 clib_net_to_host_u16 (sess->out2in.port),
+                 sess->out2in.fib_index);
     }
   if (is_ed_session (sess) || is_fwd_bypass_session (sess))
     {
@@ -227,7 +230,8 @@ format_snat_static_mapping (u8 * s, va_list * args)
       else
        s = format (s, "identity mapping %U %U:%d",
                    format_nat_protocol, m->proto,
-                   format_ip4_address, &m->local_addr, m->local_port);
+                   format_ip4_address, &m->local_addr,
+                   clib_net_to_host_u16 (m->local_port));
 
       /* *INDENT-OFF* */
       pool_foreach (local, m->locals,
@@ -253,7 +257,8 @@ format_snat_static_mapping (u8 * s, va_list * args)
        {
          s = format (s, "%U external %U:%d %s %s",
                      format_nat_protocol, m->proto,
-                     format_ip4_address, &m->external_addr, m->external_port,
+                     format_ip4_address, &m->external_addr,
+                     clib_net_to_host_u16 (m->external_port),
                      m->twice_nat == TWICE_NAT ? "twice-nat" :
                      m->twice_nat == TWICE_NAT_SELF ? "self-twice-nat" : "",
                      is_out2in_only_static_mapping (m) ? "out2in-only" : "");
@@ -262,7 +267,8 @@ format_snat_static_mapping (u8 * s, va_list * args)
           pool_foreach (local, m->locals,
           ({
            s = format (s, "\n  local %U:%d vrf %d probability %d\%",
-                       format_ip4_address, &local->addr, local->port,
+                       format_ip4_address, &local->addr,
+                        clib_net_to_host_u16 (local->port),
                        local->vrf_id, local->probability);
           }));
           /* *INDENT-ON* */
@@ -271,8 +277,10 @@ format_snat_static_mapping (u8 * s, va_list * args)
       else
        s = format (s, "%U local %U:%d external %U:%d vrf %d %s %s",
                    format_nat_protocol, m->proto,
-                   format_ip4_address, &m->local_addr, m->local_port,
-                   format_ip4_address, &m->external_addr, m->external_port,
+                   format_ip4_address, &m->local_addr,
+                   clib_net_to_host_u16 (m->local_port),
+                   format_ip4_address, &m->external_addr,
+                   clib_net_to_host_u16 (m->external_port),
                    m->vrf_id,
                    m->twice_nat == TWICE_NAT ? "twice-nat" :
                    m->twice_nat == TWICE_NAT_SELF ? "self-twice-nat" : "",
@@ -294,42 +302,10 @@ format_snat_static_map_to_resolve (u8 * s, va_list * args)
   else
     s = format (s, "%U local %U:%d external %U:%d vrf %d",
                format_nat_protocol, m->proto,
-               format_ip4_address, &m->l_addr, m->l_port,
+               format_ip4_address, &m->l_addr,
+               clib_net_to_host_u16 (m->l_port),
                format_vnet_sw_if_index_name, vnm, m->sw_if_index,
-               m->e_port, m->vrf_id);
-
-  return s;
-}
-
-u8 *
-format_det_map_ses (u8 * s, va_list * args)
-{
-  snat_det_map_t *det_map = va_arg (*args, snat_det_map_t *);
-  ip4_address_t in_addr, out_addr;
-  u32 in_offset, out_offset;
-  snat_det_session_t *ses = va_arg (*args, snat_det_session_t *);
-  u32 *i = va_arg (*args, u32 *);
-
-  u32 user_index = *i / SNAT_DET_SES_PER_USER;
-  in_addr.as_u32 =
-    clib_host_to_net_u32 (clib_net_to_host_u32 (det_map->in_addr.as_u32) +
-                         user_index);
-  in_offset =
-    clib_net_to_host_u32 (in_addr.as_u32) -
-    clib_net_to_host_u32 (det_map->in_addr.as_u32);
-  out_offset = in_offset / det_map->sharing_ratio;
-  out_addr.as_u32 =
-    clib_host_to_net_u32 (clib_net_to_host_u32 (det_map->out_addr.as_u32) +
-                         out_offset);
-  s =
-    format (s,
-           "in %U:%d out %U:%d external host %U:%d state: %U expire: %d\n",
-           format_ip4_address, &in_addr, clib_net_to_host_u16 (ses->in_port),
-           format_ip4_address, &out_addr,
-           clib_net_to_host_u16 (ses->out.out_port), format_ip4_address,
-           &ses->out.ext_host_addr,
-           clib_net_to_host_u16 (ses->out.ext_host_port),
-           format_snat_session_state, ses->state, ses->expire);
+               clib_net_to_host_u16 (m->e_port), m->vrf_id);
 
   return s;
 }