misc: api move continued
[vpp.git] / src / plugins / vrrp / vrrp_test.c
index 89ad712..194e6ad 100644 (file)
@@ -19,8 +19,7 @@ uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
 #include <vnet/format_fns.h>
 #include <vrrp/vrrp.api_enum.h>
 #include <vrrp/vrrp.api_types.h>
-#include <vpp/api/vpe.api_types.h>
-
+#include <vlibmemory/vlib.api_types.h>
 
 typedef struct
 {
@@ -227,12 +226,19 @@ vl_api_vrrp_vr_details_t_handler (vl_api_vrrp_vr_details_t * mp)
   vat_main_t *vam = vrrp_test_main.vat_main;
   u32 api_flags = ntohl (mp->config.flags);
   int i;
+  u32 state;
   char *states[] = {
     "VRRP_API_VR_STATE_INIT",
     "VRRP_API_VR_STATE_BACKUP",
     "VRRP_API_VR_STATE_MASTER",
+    "BAD STATE!",
   };
 
+  state = ntohl (mp->runtime.state);
+
+  if (state > ARRAY_LEN (states) - 2)
+    state = ARRAY_LEN (states) - 1;
+
   fformat (vam->ofp, "sw_if_index %u vr_id %u IPv%d: "
           "priority %u interval %u preempt %s accept %s unicast %s "
           "state %s master_adv_interval %u skew %u master_down_interval %u "
@@ -243,7 +249,7 @@ vl_api_vrrp_vr_details_t_handler (vl_api_vrrp_vr_details_t * mp)
           (api_flags & VRRP_API_VR_PREEMPT) ? "yes" : "no",
           (api_flags & VRRP_API_VR_ACCEPT) ? "yes" : "no",
           (api_flags & VRRP_API_VR_UNICAST) ? "yes" : "no",
-          states[ntohl (mp->runtime.state)],
+          states[state],
           ntohs (mp->runtime.master_adv_int), ntohs (mp->runtime.skew),
           ntohs (mp->runtime.master_down_int),
           format_ethernet_address, &mp->runtime.mac);
@@ -683,6 +689,38 @@ vl_api_vrrp_vr_peer_details_t_handler (vl_api_vrrp_vr_peer_details_t * mp)
   fformat (vam->ofp, "\n");
 }
 
+static int
+api_want_vrrp_vr_events (vat_main_t * vam)
+{
+  unformat_input_t *i = vam->input;
+  vl_api_want_vrrp_vr_events_t *mp;
+  int enable = -1;
+  int ret;
+
+  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+    {
+      if (unformat (i, "enable"))
+       enable = 1;
+      else if (unformat (i, "disable"))
+       enable = 0;
+      else
+       break;
+    }
+
+  if (enable == -1)
+    {
+      errmsg ("missing enable|disable");
+      return -99;
+    }
+
+  M (WANT_VRRP_VR_EVENTS, mp);
+  mp->enable_disable = enable;
+  S (mp);
+  W (ret);
+
+  return ret;
+}
+
 #include <vrrp/vrrp.api_test.c>
 /*
  * fd.io coding-style-patch-verification: ON