Fixed issue with json output in vpp_api_test.
[vpp.git] / vpp-api-test / vat / api_format.c
index 13b2c0d..b6f0902 100644 (file)
@@ -587,6 +587,7 @@ static void vl_api_sw_interface_details_t_handler_json
     vat_json_object_add_uint(node, "link_up_down", mp->link_up_down);
     vat_json_object_add_uint(node, "link_duplex", mp->link_duplex);
     vat_json_object_add_uint(node, "link_speed", mp->link_speed);
+    vat_json_object_add_uint(node, "mtu", ntohs(mp->link_mtu));
     vat_json_object_add_uint(node, "sub_id", ntohl(mp->sub_id));
     vat_json_object_add_uint(node, "sub_dot1ad", mp->sub_dot1ad);
     vat_json_object_add_uint(node, "sub_number_of_tags", mp->sub_number_of_tags);
@@ -2427,7 +2428,8 @@ int exec (vat_main_t * vam)
     while (vat_time_now (vam) < timeout) {
         if (vam->result_ready == 1) {
             u8 * free_me;
-            fformat (vam->ofp, "%s", vam->shmem_result);
+            if (vam->shmem_result != NULL)
+                fformat (vam->ofp, "%s", vam->shmem_result);
             pthread_mutex_lock (&am->vlib_rp->mutex);
             oldheap = svm_push_data_heap (am->vlib_rp);
             
@@ -6893,6 +6895,8 @@ static int api_create_vhost_user_if (vat_main_t * vam)
     u8 is_server = 0;
     u8 file_name_set = 0;
     u32 custom_dev_instance = ~0;
+    u8 hwaddr[6];
+    u8 use_custom_mac = 0;
 
     while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
       if (unformat (i, "socket %s", &file_name)) {
@@ -6900,6 +6904,8 @@ static int api_create_vhost_user_if (vat_main_t * vam)
       }
       else if (unformat (i, "renumber %"PRIu32, &custom_dev_instance))
         ;
+      else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
+        use_custom_mac = 1;
       else if (unformat (i, "server"))
         is_server = 1;
       else
@@ -6926,6 +6932,8 @@ static int api_create_vhost_user_if (vat_main_t * vam)
         mp->renumber = 1;
         mp->custom_dev_instance = ntohl(custom_dev_instance);
     }
+    mp->use_custom_mac = use_custom_mac;
+    memcpy(mp->mac_address, hwaddr, 6);
 
     S; W;
     /* NOTREACHED */
@@ -8993,7 +9001,8 @@ _(l2_interface_vlan_tag_rewrite,                                        \
   "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n"              \
   "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>")             \
 _(create_vhost_user_if,                                                 \
-        "socket <filename> [server] [renumber <dev_instance>]")         \
+        "socket <filename> [server] [renumber <dev_instance>] "         \
+        "[mac <mac_address>]")                                          \
 _(modify_vhost_user_if,                                                 \
         "<intfc> | sw_if_index <nn> socket <filename>\n"                \
         "[server] [renumber <dev_instance>]")                           \