devices: vhost API cleanup
[vpp.git] / src / vat / api_format.c
index e362672..e4ef0b4 100644 (file)
@@ -1100,7 +1100,7 @@ vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
 {
   vat_main_t *vam = &vat_main;
   vat_json_node_t node;
-  api_main_t *am = &api_main;
+  api_main_t *am = vlibapi_get_main ();
   void *oldheap;
   u8 *reply;
 
@@ -2710,7 +2710,7 @@ static void vl_api_get_node_graph_reply_t_handler
   (vl_api_get_node_graph_reply_t * mp)
 {
   vat_main_t *vam = &vat_main;
-  api_main_t *am = &api_main;
+  api_main_t *am = vlibapi_get_main ();
   i32 retval = ntohl (mp->retval);
   u8 *pvt_copy, *reply;
   void *oldheap;
@@ -2773,7 +2773,7 @@ static void vl_api_get_node_graph_reply_t_handler_json
   (vl_api_get_node_graph_reply_t * mp)
 {
   vat_main_t *vam = &vat_main;
-  api_main_t *am = &api_main;
+  api_main_t *am = vlibapi_get_main ();
   void *oldheap;
   vat_json_node_t node;
   u8 *reply;
@@ -7474,8 +7474,8 @@ api_tap_create_v2 (vat_main_t * vam)
   mp->id = ntohl (id);
   mp->host_namespace_set = host_ns != 0;
   mp->host_bridge_set = host_bridge != 0;
-  mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
-  mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
+  mp->host_ip4_prefix_set = host_ip4_prefix_len != 0;
+  mp->host_ip6_prefix_set = host_ip6_prefix_len != 0;
   mp->rx_ring_sz = ntohs (rx_ring_sz);
   mp->tx_ring_sz = ntohs (tx_ring_sz);
   mp->host_mtu_set = host_mtu_set;
@@ -7493,9 +7493,9 @@ api_tap_create_v2 (vat_main_t * vam)
   if (host_bridge)
     clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
   if (host_ip4_prefix_len)
-    clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
+    clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
   if (host_ip6_prefix_len)
-    clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
+    clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
   if (host_ip4_gw_set)
     clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
   if (host_ip6_gw_set)
@@ -11859,10 +11859,12 @@ static void vl_api_sw_interface_tap_v2_details_t_handler
 {
   vat_main_t *vam = &vat_main;
 
-  u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
-                   mp->host_ip4_prefix_len);
-  u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
-                   mp->host_ip6_prefix_len);
+  u8 *ip4 =
+    format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
+           mp->host_ip4_prefix.len);
+  u8 *ip6 =
+    format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
+           mp->host_ip6_prefix.len);
 
   print (vam->ofp,
         "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
@@ -11903,12 +11905,12 @@ static void vl_api_sw_interface_tap_v2_details_t_handler_json
   vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
   vat_json_object_add_string_copy (node, "host_ip4_addr",
                                   format (0, "%U/%d", format_ip4_address,
-                                          mp->host_ip4_addr,
-                                          mp->host_ip4_prefix_len));
-  vat_json_object_add_string_copy (node, "host_ip6_addr",
+                                          mp->host_ip4_prefix.address,
+                                          mp->host_ip4_prefix.len));
+  vat_json_object_add_string_copy (node, "host_ip6_prefix",
                                   format (0, "%U/%d", format_ip6_address,
-                                          mp->host_ip6_addr,
-                                          mp->host_ip6_prefix_len));
+                                          mp->host_ip6_prefix.address,
+                                          mp->host_ip6_prefix.len));
 
 }
 
@@ -13114,11 +13116,18 @@ static void vl_api_sw_interface_vhost_user_details_t_handler
   (vl_api_sw_interface_vhost_user_details_t * mp)
 {
   vat_main_t *vam = &vat_main;
+  u64 features;
+
+  features =
+    clib_net_to_host_u32 (mp->features_first_32) | ((u64)
+                                                   clib_net_to_host_u32
+                                                   (mp->features_last_32) <<
+                                                   32);
 
   print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
         (char *) mp->interface_name,
         ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
-        clib_net_to_host_u64 (mp->features), mp->is_server,
+        features, mp->is_server,
         ntohl (mp->num_regions), (char *) mp->sock_filename);
   print (vam->ofp, "    Status: '%s'", strerror (ntohl (mp->sock_errno)));
 }
@@ -13142,8 +13151,10 @@ static void vl_api_sw_interface_vhost_user_details_t_handler_json
                                   mp->interface_name);
   vat_json_object_add_uint (node, "virtio_net_hdr_sz",
                            ntohl (mp->virtio_net_hdr_sz));
-  vat_json_object_add_uint (node, "features",
-                           clib_net_to_host_u64 (mp->features));
+  vat_json_object_add_uint (node, "features_first_32",
+                           clib_net_to_host_u32 (mp->features_first_32));
+  vat_json_object_add_uint (node, "features_last_32",
+                           clib_net_to_host_u32 (mp->features_last_32));
   vat_json_object_add_uint (node, "is_server", mp->is_server);
   vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
   vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
@@ -21333,7 +21344,7 @@ value_sort_cmp (void *a1, void *a2)
 static int
 dump_msg_api_table (vat_main_t * vam)
 {
-  api_main_t *am = &api_main;
+  api_main_t *am = vlibapi_get_main ();
   name_sort_t *nses = 0, *ns;
   hash_pair_t *hp;
   int i;