lacp: custom dump for sw_interface_lacp_dump 73/20373/2
authorSteven Luong <sluong@cisco.com>
Wed, 26 Jun 2019 22:32:43 +0000 (15:32 -0700)
committerNeale Ranns <nranns@cisco.com>
Thu, 27 Jun 2019 08:10:22 +0000 (08:10 +0000)
Add custom dump code for sw_interface_lacp_dump

Type: fix

Change-Id: Ifa76192ec65f596391c07b151d2a7fceed502665
Signed-off-by: Steven Luong <sluong@cisco.com>
src/plugins/lacp/lacp_api.c

index d23bf21..ed3ead6 100644 (file)
 
 /* instantiate all the print functions we know about */
 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
-#define vl_printfun
-#include <lacp/lacp_all_api_h.h>
-#undef vl_printfun
 
 /* Get the API version number */
 #define vl_api_version(n,v) static u32 api_version=(v);
 #include <lacp/lacp_all_api_h.h>
 #undef vl_api_version
 
+/* Macro to finish up custom dump fns */
+#define FINISH                                  \
+    vec_add1 (s, 0);                            \
+    vl_print (handle, (char *)s);               \
+    vec_free (s);                               \
+    return handle;
+
 #define REPLY_MSG_ID_BASE lm->msg_id_base
 #include <vlibapi/api_helper_macros.h>
 
@@ -126,6 +130,17 @@ vl_api_sw_interface_lacp_dump_t_handler (vl_api_sw_interface_lacp_dump_t * mp)
   vec_free (lacpifs);
 }
 
+static void *
+vl_api_sw_interface_lacp_dump_t_print (vl_api_sw_interface_lacp_dump_t * mp,
+                                      void *handle)
+{
+  u8 *s;
+
+  s = format (0, "SCRIPT: sw_interface_lacp_dump ");
+
+  FINISH;
+}
+
 #define vl_msg_name_crc_list
 #include <lacp/lacp_all_api_h.h>
 #undef vl_msg_name_crc_list
@@ -139,6 +154,16 @@ setup_message_id_table (lacp_main_t * lm, api_main_t * am)
 #undef _
 }
 
+static void
+plugin_custom_dump_configure (lacp_main_t * lm)
+{
+#define _(n,f) api_main.msg_print_handlers \
+  [VL_API_##n + lm->msg_id_base]                \
+    = (void *) vl_api_##f##_t_print;
+  foreach_lacp_plugin_api_msg;
+#undef _
+}
+
 /* Set up the API message handling tables */
 clib_error_t *
 lacp_plugin_api_hookup (vlib_main_t * vm)
@@ -170,6 +195,8 @@ lacp_plugin_api_hookup (vlib_main_t * vm)
    */
   setup_message_id_table (lm, am);
 
+  plugin_custom_dump_configure (lm);
+
   vec_free (name);
   return 0;
 }