api: clean up use of deprecated flag
[vpp.git] / src / plugins / nat / nat64_cli.c
index 5b46fed..6fc047f 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <nat/nat64.h>
 #include <nat/nat.h>
+#include <nat/nat_inlines.h>
 #include <vnet/fib/fib_table.h>
 
 static clib_error_t *
@@ -72,7 +73,7 @@ nat64_add_del_pool_addr_command_fn (vlib_main_t * vm,
 
   for (i = 0; i < count; i++)
     {
-      rv = nat64_add_del_pool_addr (&this_addr, vrf_id, is_add);
+      rv = nat64_add_del_pool_addr (0, &this_addr, vrf_id, is_add);
 
       switch (rv)
        {
@@ -118,7 +119,7 @@ nat64_cli_pool_walk (snat_address_t * ap, void *ctx)
 
 #define _(N, i, n, s) \
   vlib_cli_output (vm, "  %d busy %s ports", ap->busy_##n##_ports, s);
-  foreach_snat_protocol
+  foreach_nat_protocol
 #undef _
     return 0;
 }
@@ -287,7 +288,7 @@ nat64_add_del_static_bib_command_fn (vlib_main_t *
   u32 in_port = 0;
   u32 out_port = 0;
   u32 vrf_id = 0, protocol;
-  snat_protocol_t proto = 0;
+  nat_protocol_t proto = 0;
   u8 p = 0;
   int rv;
 
@@ -304,7 +305,7 @@ nat64_add_del_static_bib_command_fn (vlib_main_t *
        ;
       else if (unformat (line_input, "vrf %u", &vrf_id))
        ;
-      else if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
+      else if (unformat (line_input, "%U", unformat_nat_protocol, &proto))
        ;
       else
        if (unformat
@@ -337,7 +338,7 @@ nat64_add_del_static_bib_command_fn (vlib_main_t *
          goto done;
        }
 
-      p = snat_proto_to_ip_proto (proto);
+      p = nat_proto_to_ip_proto (proto);
     }
 
   rv =
@@ -357,7 +358,8 @@ nat64_add_del_static_bib_command_fn (vlib_main_t *
       goto done;
     case VNET_API_ERROR_INVALID_VALUE:
       error =
-       clib_error_return (0, "Outside addres %U and port %u already in use.",
+       clib_error_return (0,
+                          "Outside address %U and port %u already in use.",
                           format_ip4_address, &out_addr, out_port);
       goto done;
     case VNET_API_ERROR_INVALID_VALUE_2:
@@ -392,8 +394,8 @@ nat64_cli_bib_walk (nat64_db_bib_entry_t * bibe, void *ctx)
                       clib_net_to_host_u16 (bibe->in_port),
                       format_ip4_address, &bibe->out_addr,
                       clib_net_to_host_u16 (bibe->out_port),
-                      format_snat_protocol,
-                      ip_proto_to_snat_proto (bibe->proto), fib->ft_table_id,
+                      format_nat_protocol,
+                      ip_proto_to_nat_proto (bibe->proto), fib->ft_table_id,
                       bibe->is_static ? "static" : "dynamic", bibe->ses_num);
       break;
     default:
@@ -413,15 +415,15 @@ nat64_show_bib_command_fn (vlib_main_t * vm,
   nat64_main_t *nm = &nat64_main;
   unformat_input_t _line_input, *line_input = &_line_input;
   clib_error_t *error = 0;
-  u32 proto = ~0;
+  u32 proto = NAT_PROTOCOL_OTHER;
   u8 p = 255;
   nat64_db_t *db;
 
   if (!unformat_user (input, unformat_line_input, line_input))
     return 0;
 
-  if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
-    p = snat_proto_to_ip_proto (proto);
+  if (unformat (line_input, "%U", unformat_nat_protocol, &proto))
+    p = nat_proto_to_ip_proto (proto);
   else if (unformat (line_input, "unknown"))
     p = 0;
   else if (unformat (line_input, "all"))
@@ -436,8 +438,7 @@ nat64_show_bib_command_fn (vlib_main_t * vm,
   if (p == 255)
     vlib_cli_output (vm, "NAT64 BIB entries:");
   else
-    vlib_cli_output (vm, "NAT64 %U BIB entries:", format_snat_protocol,
-                    proto);
+    vlib_cli_output (vm, "NAT64 %U BIB entries:", format_nat_protocol, proto);
 
   /* *INDENT-OFF* */
   vec_foreach (db, nm->db)
@@ -450,107 +451,6 @@ done:
   return error;
 }
 
-static clib_error_t *
-nat64_set_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
-                              vlib_cli_command_t * cmd)
-{
-  unformat_input_t _line_input, *line_input = &_line_input;
-  clib_error_t *error = 0;
-  u32 timeout, tcp_trans, tcp_est, tcp_incoming_syn;
-
-  tcp_trans = nat64_get_tcp_trans_timeout ();
-  tcp_est = nat64_get_tcp_est_timeout ();
-  tcp_incoming_syn = nat64_get_tcp_incoming_syn_timeout ();
-
-  if (!unformat_user (input, unformat_line_input, line_input))
-    return 0;
-
-  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
-    {
-      if (unformat (line_input, "udp %u", &timeout))
-       {
-         if (nat64_set_udp_timeout (timeout))
-           {
-             error = clib_error_return (0, "Invalid UDP timeout value");
-             goto done;
-           }
-       }
-      else if (unformat (line_input, "icmp %u", &timeout))
-       {
-         if (nat64_set_icmp_timeout (timeout))
-           {
-             error = clib_error_return (0, "Invalid ICMP timeout value");
-             goto done;
-           }
-       }
-      else if (unformat (line_input, "tcp-trans %u", &tcp_trans))
-       {
-         if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
-           {
-             error =
-               clib_error_return (0,
-                                  "Invalid TCP transitory timeouts value");
-             goto done;
-           }
-       }
-      else if (unformat (line_input, "tcp-est %u", &tcp_est))
-       {
-         if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
-           {
-             error =
-               clib_error_return (0,
-                                  "Invalid TCP established timeouts value");
-             goto done;
-           }
-       }
-      else
-       if (unformat (line_input, "tcp-incoming-syn %u", &tcp_incoming_syn))
-       {
-         if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
-           {
-             error =
-               clib_error_return (0,
-                                  "Invalid TCP incoming SYN timeouts value");
-             goto done;
-           }
-       }
-      else if (unformat (line_input, "reset"))
-       {
-         nat64_set_udp_timeout (0);
-         nat64_set_icmp_timeout (0);
-         nat64_set_tcp_timeouts (0, 0, 0);
-       }
-      else
-       {
-         error = clib_error_return (0, "unknown input '%U'",
-                                    format_unformat_error, line_input);
-         goto done;
-       }
-    }
-
-done:
-  unformat_free (line_input);
-
-  return error;
-}
-
-static clib_error_t *
-nat64_show_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
-                               vlib_cli_command_t * cmd)
-{
-  vlib_cli_output (vm, "NAT64 session timeouts:");
-  vlib_cli_output (vm, " UDP %usec", nat64_get_udp_timeout ());
-  vlib_cli_output (vm, " ICMP %usec", nat64_get_icmp_timeout ());
-  vlib_cli_output (vm, " TCP transitory %usec",
-                  nat64_get_tcp_trans_timeout ());
-  vlib_cli_output (vm, " TCP established %usec",
-                  nat64_get_tcp_est_timeout ());
-  vlib_cli_output (vm, " TCP incoming SYN %usec",
-                  nat64_get_tcp_incoming_syn_timeout ());
-
-  return 0;
-}
-
 typedef struct nat64_cli_st_walk_ctx_t_
 {
   vlib_main_t *vm;
@@ -583,8 +483,8 @@ nat64_cli_st_walk (nat64_db_st_entry_t * ste, void *arg)
                     format_ip4_address, &bibe->out_addr,
                     format_ip4_address, &ste->out_r_addr,
                     clib_net_to_host_u16 (bibe->out_port),
-                    format_snat_protocol,
-                    ip_proto_to_snat_proto (bibe->proto), vrf_id);
+                    format_nat_protocol,
+                    ip_proto_to_nat_proto (bibe->proto), vrf_id);
   else if (ste->proto == IP_PROTOCOL_TCP || ste->proto == IP_PROTOCOL_UDP)
     vlib_cli_output (vm, " %U %u %U %u %U %u %U %u protcol %U vrf %u",
                     format_ip6_address, &bibe->in_addr,
@@ -595,8 +495,8 @@ nat64_cli_st_walk (nat64_db_st_entry_t * ste, void *arg)
                     clib_net_to_host_u16 (bibe->out_port),
                     format_ip4_address, &ste->out_r_addr,
                     clib_net_to_host_u16 (ste->r_port),
-                    format_snat_protocol,
-                    ip_proto_to_snat_proto (bibe->proto), vrf_id);
+                    format_nat_protocol,
+                    ip_proto_to_nat_proto (bibe->proto), vrf_id);
   else
     vlib_cli_output (vm, " %U %U %U %U protocol %u vrf %u",
                     format_ip6_address, &bibe->in_addr,
@@ -615,7 +515,7 @@ nat64_show_st_command_fn (vlib_main_t * vm,
   nat64_main_t *nm = &nat64_main;
   unformat_input_t _line_input, *line_input = &_line_input;
   clib_error_t *error = 0;
-  u32 proto = ~0;
+  u32 proto = NAT_PROTOCOL_OTHER;
   u8 p = 255;
   nat64_db_t *db;
   nat64_cli_st_walk_ctx_t ctx = {
@@ -625,8 +525,8 @@ nat64_show_st_command_fn (vlib_main_t * vm,
   if (!unformat_user (input, unformat_line_input, line_input))
     return 0;
 
-  if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
-    p = snat_proto_to_ip_proto (proto);
+  if (unformat (line_input, "%U", unformat_nat_protocol, &proto))
+    p = nat_proto_to_ip_proto (proto);
   else if (unformat (line_input, "unknown"))
     p = 0;
   else if (unformat (line_input, "all"))
@@ -641,7 +541,7 @@ nat64_show_st_command_fn (vlib_main_t * vm,
   if (p == 255)
     vlib_cli_output (vm, "NAT64 sessions:");
   else
-    vlib_cli_output (vm, "NAT64 %U sessions:", format_snat_protocol, proto);
+    vlib_cli_output (vm, "NAT64 %U sessions:", format_nat_protocol, proto);
   /* *INDENT-OFF* */
   vec_foreach (db, nm->db)
     {
@@ -732,9 +632,9 @@ nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
        {
          fib_index =
            fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP6,
-                                              vrf_id, FIB_SOURCE_PLUGIN_HI);
+                                              vrf_id, nat_fib_src_hi);
          fib_table_entry_update_one_path (fib_index, &fibpfx,
-                                          FIB_SOURCE_PLUGIN_HI,
+                                          nat_fib_src_hi,
                                           FIB_ENTRY_FLAG_NONE,
                                           DPO_PROTO_IP6, NULL,
                                           sw_if_index, ~0, 0,
@@ -744,12 +644,11 @@ nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
        {
          fib_index = fib_table_find (FIB_PROTOCOL_IP6, vrf_id);
          fib_table_entry_path_remove (fib_index, &fibpfx,
-                                      FIB_SOURCE_PLUGIN_HI,
+                                      nat_fib_src_hi,
                                       DPO_PROTO_IP6, NULL,
                                       sw_if_index, ~0, 1,
                                       FIB_ROUTE_PATH_INTF_RX);
-         fib_table_unlock (fib_index, FIB_PROTOCOL_IP6,
-                           FIB_SOURCE_PLUGIN_HI);
+         fib_table_unlock (fib_index, FIB_PROTOCOL_IP6, nat_fib_src_hi);
        }
     }
 
@@ -943,42 +842,6 @@ VLIB_CLI_COMMAND (show_nat64_bib_command, static) = {
   .function = nat64_show_bib_command_fn,
 };
 
-/*?
- * @cliexpar
- * @cliexstart{set nat64 timeouts}
- * Set NAT64 session timeouts (in seconds).
- * To set NAT64 session timeoutes use use:
- *  vpp# set nat64 timeouts udp 200 icmp 30 tcp-trans 250 tcp-est 7450
- * To reset NAT64 session timeoutes to default values use:
- *  vpp# set nat64 timeouts reset
- * @cliexend
-?*/
-VLIB_CLI_COMMAND (set_nat64_timeouts_command, static) = {
-  .path = "set nat64 timeouts",
-  .short_help = "set nat64 timeouts udp <sec> icmp <sec> tcp-trans <sec> "
-                "tcp-est <sec> tcp-incoming-syn <sec> | reset",
-  .function = nat64_set_timeouts_command_fn,
-};
-
-/*?
- * @cliexpar
- * @cliexstart{show nat64 timeoutss}
- * Show NAT64 session timeouts:
- *  vpp# show nat64 timeouts
- *  NAT64 session timeouts:
- *   UDP 300sec
- *   ICMP 60sec
- *   TCP transitory 240sec
- *   TCP established 7440sec
- *   TCP incoming SYN 6sec
- * @cliexend
-?*/
-VLIB_CLI_COMMAND (show_nat64_timeouts_command, static) = {
-  .path = "show nat64 timeouts",
-  .short_help = "show nat64 timeouts",
-  .function = nat64_show_timeouts_command_fn,
-};
-
 /*?
  * @cliexpar
  * @cliexstart{show nat64 session table}