Revert "nat: static mappings in flow hash"
[vpp.git] / src / plugins / ct6 / ct6.c
index dc2b735..205cd3f 100644 (file)
 #include <vpp/app/version.h>
 
 /* define message IDs */
-#include <ct6/ct6_msg_enum.h>
-
-/* define message structures */
-#define vl_typedefs
-#include <ct6/ct6_all_api_h.h>
-#undef vl_typedefs
-
-/* define generated endian-swappers */
-#define vl_endianfun
-#include <ct6/ct6_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
-#define vl_printfun
-#include <ct6/ct6_all_api_h.h>
-#undef vl_printfun
-
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <ct6/ct6_all_api_h.h>
-#undef vl_api_version
+#include <ct6/ct6.api_enum.h>
+#include <ct6/ct6.api_types.h>
 
 #define REPLY_MSG_ID_BASE cmp->msg_id_base
 #include <vlibapi/api_helper_macros.h>
 
 ct6_main_t ct6_main;
 
-/* List of message types that this plugin understands */
-
-#define foreach_ct6_plugin_api_msg                           \
-_(CT6_ENABLE_DISABLE, ct6_enable_disable)
-
 /* Action function shared between message handler and debug CLI */
 
 static void
@@ -196,6 +171,8 @@ static void vl_api_ct6_enable_disable_t_handler
   ct6_main_t *cmp = &ct6_main;
   int rv;
 
+  VALIDATE_SW_IF_INDEX (mp);
+
   if (mp->is_inside)
     rv = ct6_in2out_enable_disable (cmp, ntohl (mp->sw_if_index),
                                    (int) (mp->enable_disable));
@@ -203,62 +180,22 @@ static void vl_api_ct6_enable_disable_t_handler
     rv = ct6_out2in_enable_disable (cmp, ntohl (mp->sw_if_index),
                                    (int) (mp->enable_disable));
 
+  BAD_SW_IF_INDEX_LABEL;
   REPLY_MACRO (VL_API_CT6_ENABLE_DISABLE_REPLY);
 }
 
-/* Set up the API message handling tables */
-static clib_error_t *
-ct6_plugin_api_hookup (vlib_main_t * vm)
-{
-  ct6_main_t *cmp = &ct6_main;
-#define _(N,n)                                                  \
-    vl_msg_api_set_handlers((VL_API_##N + cmp->msg_id_base),     \
-                           #n,                                 \
-                           vl_api_##n##_t_handler,              \
-                           vl_noop_handler,                     \
-                           vl_api_##n##_t_endian,               \
-                           vl_api_##n##_t_print,                \
-                           sizeof(vl_api_##n##_t), 1);
-  foreach_ct6_plugin_api_msg;
-#undef _
-
-  return 0;
-}
-
-#define vl_msg_name_crc_list
-#include <ct6/ct6_all_api_h.h>
-#undef vl_msg_name_crc_list
-
-static void
-setup_message_id_table (ct6_main_t * cmp, api_main_t * am)
-{
-#define _(id,n,crc)   vl_msg_api_add_msg_name_crc (am, #n  #crc, id + cmp->msg_id_base);
-  foreach_vl_msg_name_crc_ct6;
-#undef _
-}
-
+#include <ct6/ct6.api.c>
 static clib_error_t *
 ct6_init (vlib_main_t * vm)
 {
   ct6_main_t *cmp = &ct6_main;
   clib_error_t *error = 0;
-  u8 *name;
 
   cmp->vlib_main = vm;
   cmp->vnet_main = vnet_get_main ();
 
-  name = format (0, "ct6_%08x%c", api_version, 0);
-
   /* Ask for a correctly-sized block of API message decode slots */
-  cmp->msg_id_base = vl_msg_api_get_msg_ids
-    ((char *) name, VL_MSG_FIRST_AVAILABLE);
-
-  error = ct6_plugin_api_hookup (vm);
-
-  /* Add our API messages to the global name_crc hash table */
-  setup_message_id_table (cmp, &api_main);
-
-  vec_free (name);
+  cmp->msg_id_base = setup_message_id_table ();
 
   /*
    * Set default parameters...
@@ -289,11 +226,10 @@ VNET_FEATURE_INIT (ct6out2in, static) =
 /* *INDENT-ON */
 
 /* *INDENT-OFF* */
-VNET_FEATURE_INIT (ct6in2out, static) =
-{
+VNET_FEATURE_INIT (ct6in2out, static) = {
   .arc_name = "interface-output",
   .node_name = "ct6-in2out",
-  .runs_before = VNET_FEATURES ("interface-tx"),
+  .runs_before = VNET_FEATURES ("interface-output-arc-end"),
 };
 /* *INDENT-ON */
 
@@ -301,7 +237,7 @@ VNET_FEATURE_INIT (ct6in2out, static) =
 VLIB_PLUGIN_REGISTER () =
 {
   .version = VPP_BUILD_VER,
-  .description = "ipv6 connection tracker",
+  .description = "IPv6 Connection Tracker",
 };
 /* *INDENT-ON* */
 
@@ -385,10 +321,10 @@ show_ct6_command_fn_command_fn (vlib_main_t * vm,
                0 /* pool */ , 0 /* header */ , verbose);
 
       /* *INDENT-OFF* */
-      pool_foreach (s0, cmp->sessions[i],
-      ({
+      pool_foreach (s0, cmp->sessions[i])
+       {
         s = format (s, "%U", format_ct6_session, cmp, i, s0, verbose);
-      }));
+      }
       /* *INDENT-ON* */
     }
   vlib_cli_output (cmp->vlib_main, "%v", s);
@@ -494,10 +430,10 @@ test_ct6_command_fn_command_fn (vlib_main_t * vm,
     }
 
   /* *INDENT-OFF* */
-  pool_foreach (s0, cmp->sessions[0],
-  ({
+  pool_foreach (s0, cmp->sessions[0])
+   {
     s = format (s, "%U", format_ct6_session, cmp, 0, s0, 1 /* verbose */);
-  }));
+  }
   /* *INDENT-ON* */
 
   vlib_cli_output (vm, "\nEnd state: first index %d last index %d\n%v",
@@ -514,10 +450,10 @@ test_ct6_command_fn_command_fn (vlib_main_t * vm,
   ct6_update_session_hit (cmp, s0, 234.0);
 
   /* *INDENT-OFF* */
-  pool_foreach (s0, cmp->sessions[0],
-  ({
+  pool_foreach (s0, cmp->sessions[0])
+   {
     s = format (s, "%U", format_ct6_session, cmp, 0, s0, 1 /* verbose */);
-  }));
+  }
   /* *INDENT-ON* */
 
   vlib_cli_output (vm, "\nEnd state: first index %d last index %d\n%v",