VPP-328: Add dump call for listing LISP VNIs
[vpp.git] / vpp-api-test / vat / api_format.c
index c12b247..7f0f9fa 100644 (file)
@@ -1555,6 +1555,40 @@ static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
   vam->result_ready = 1;
 }
 
+
+static void vl_api_lisp_add_del_locator_set_reply_t_handler
+  (vl_api_lisp_add_del_locator_set_reply_t * mp)
+{
+  vat_main_t *vam = &vat_main;
+  i32 retval = ntohl (mp->retval);
+  if (vam->async_mode)
+    {
+      vam->async_errors += (retval < 0);
+    }
+  else
+    {
+      vam->retval = retval;
+      vam->result_ready = 1;
+    }
+}
+
+static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
+  (vl_api_lisp_add_del_locator_set_reply_t * mp)
+{
+  vat_main_t *vam = &vat_main;
+  vat_json_node_t node;
+
+  vat_json_init_object (&node);
+  vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
+  vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
+
+  vat_json_print (vam->ofp, &node);
+  vat_json_free (&node);
+
+  vam->retval = ntohl (mp->retval);
+  vam->result_ready = 1;
+}
+
 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
   (vl_api_vxlan_add_del_tunnel_reply_t * mp)
 {
@@ -2394,7 +2428,33 @@ static void
   vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
 }
 
+static void
+  vl_api_lisp_eid_table_vni_details_t_handler
+  (vl_api_lisp_eid_table_vni_details_t * mp)
+{
+  vat_main_t *vam = &vat_main;
 
+  u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
+  fformat (vam->ofp, "%v\n", line);
+  vec_free (line);
+}
+
+static void
+  vl_api_lisp_eid_table_vni_details_t_handler_json
+  (vl_api_lisp_eid_table_vni_details_t * mp)
+{
+  vat_main_t *vam = &vat_main;
+  vat_json_node_t *node = NULL;
+
+  if (VAT_JSON_ARRAY != vam->json_tree.type)
+    {
+      ASSERT (VAT_JSON_NONE == vam->json_tree.type);
+      vat_json_init_array (&vam->json_tree);
+    }
+  node = vat_json_array_add (&vam->json_tree);
+  vat_json_init_object (node);
+  vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
+}
 
 static u8 *
 format_decap_next (u8 * s, va_list * args)
@@ -3306,7 +3366,6 @@ _(sw_interface_clear_stats_reply)                       \
 _(trace_profile_add_reply)                              \
 _(trace_profile_apply_reply)                            \
 _(trace_profile_del_reply)                              \
-_(lisp_add_del_locator_set_reply)                       \
 _(lisp_add_del_locator_reply)                           \
 _(lisp_add_del_local_eid_reply)                         \
 _(lisp_add_del_remote_mapping_reply)                    \
@@ -3511,6 +3570,7 @@ _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details)                   \
 _(LISP_LOCATOR_DETAILS, lisp_locator_details)                           \
 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details)                       \
 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details)               \
+_(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details)               \
 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details)                     \
 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details)                 \
 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply)                       \
@@ -11130,7 +11190,7 @@ api_map_add_domain (vat_main_t * vam)
     0, psid_length = 0;
   u8 is_translation = 0;
   u32 mtu = 0;
-  u8 ip6_src_len = 128;
+  u32 ip6_src_len = 128;
 
   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
     {
@@ -13083,6 +13143,35 @@ api_lisp_eid_table_map_dump (vat_main_t * vam)
   return 0;
 }
 
+static int
+api_lisp_eid_table_vni_dump (vat_main_t * vam)
+{
+  vl_api_lisp_eid_table_vni_dump_t *mp;
+  f64 timeout = ~0;
+
+  if (!vam->json_output)
+    {
+      fformat (vam->ofp, "VNI\n");
+    }
+
+  M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
+
+  /* send it... */
+  S;
+
+  /* Use a control ping for synchronization */
+  {
+    vl_api_control_ping_t *mp;
+    M (CONTROL_PING, control_ping);
+    S;
+  }
+  /* Wait for a reply... */
+  W;
+
+  /* NOTREACHED */
+  return 0;
+}
+
 static int
 get_locator_set (vat_main_t * vam)
 {
@@ -15619,6 +15708,7 @@ _(lisp_locator_set_dump, "[locator-set-index <ls-index> | "             \
 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] "      \
                        "[local] | [remote]")                            \
 _(lisp_eid_table_map_dump, "")                                          \
+_(lisp_eid_table_vni_dump, "")                                          \
 _(lisp_gpe_tunnel_dump, "")                                             \
 _(lisp_map_resolver_dump, "")                                           \
 _(show_lisp_status, "")                                                 \