Remove vpp_api_test interface name filter catalog
[vpp.git] / src / plugins / memif / memif_test.c
index c1ba927..9c80cf3 100644 (file)
 #include <vat/vat.h>
 #include <vlibapi/api.h>
 #include <vlibmemory/api.h>
-#include <vlibsocket/api.h>
+
 #include <vppinfra/error.h>
 #include <vnet/ip/ip.h>
 #include <memif/memif.h>
+#include <memif/private.h>
 
 #define __plugin_msg_base memif_test_main.msg_id_base
 #include <vlibapi/vat_helper_macros.h>
@@ -118,8 +119,9 @@ api_memif_create (vat_main_t * vam)
 {
   unformat_input_t *i = vam->input;
   vl_api_memif_create_t *mp;
-  u64 key = 0;
+  u32 id = 0;
   u8 *socket_filename = 0;
+  u8 *secret = 0;
   u8 role = 1;
   u32 ring_size = 0;
   u32 buffer_size = 0;
@@ -127,14 +129,16 @@ api_memif_create (vat_main_t * vam)
   u32 rx_queues = MEMIF_DEFAULT_RX_QUEUES;
   u32 tx_queues = MEMIF_DEFAULT_TX_QUEUES;
   int ret;
-
+  u8 mode = MEMIF_INTERFACE_MODE_ETHERNET;
 
   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
     {
-      if (unformat (i, "key 0x%" PRIx64, &key))
+      if (unformat (i, "id %u", &id))
        ;
       else if (unformat (i, "socket %s", &socket_filename))
        ;
+      else if (unformat (i, "secret %s", &secret))
+       ;
       else if (unformat (i, "ring_size %u", &ring_size))
        ;
       else if (unformat (i, "buffer_size %u", &buffer_size))
@@ -144,6 +148,8 @@ api_memif_create (vat_main_t * vam)
       else if (unformat (i, "slave %U",
                         unformat_memif_queues, &rx_queues, &tx_queues))
        role = 1;
+      else if (unformat (i, "mode ip"))
+       mode = MEMIF_INTERFACE_MODE_IP;
       else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
        ;
       else
@@ -173,7 +179,8 @@ api_memif_create (vat_main_t * vam)
 
   M (MEMIF_CREATE, mp);
 
-  mp->key = clib_host_to_net_u64 (key);
+  mp->mode = mode;
+  mp->id = clib_host_to_net_u32 (id);
   mp->role = role;
   mp->ring_size = clib_host_to_net_u32 (ring_size);
   mp->buffer_size = clib_host_to_net_u16 (buffer_size & 0xffff);
@@ -182,6 +189,11 @@ api_memif_create (vat_main_t * vam)
       strncpy ((char *) mp->socket_filename, (char *) socket_filename, 127);
       vec_free (socket_filename);
     }
+  if (secret != 0)
+    {
+      strncpy ((char *) mp->secret, (char *) secret, 16);
+      vec_free (secret);
+    }
   memcpy (mp->hw_addr, hw_addr, 6);
   mp->rx_queues = rx_queues;
   mp->tx_queues = tx_queues;
@@ -206,6 +218,7 @@ static void vl_api_memif_create_reply_t_handler
 
   vam->retval = retval;
   vam->result_ready = 1;
+  vam->regenerate_interface_table = 1;
 }
 
 /* memif-delete API */
@@ -282,11 +295,11 @@ static void vl_api_memif_details_t_handler (vl_api_memif_details_t * mp)
   vat_main_t *vam = memif_test_main.vat_main;
 
   fformat (vam->ofp, "%s: sw_if_index %u mac %U\n"
-          "   key 0x%" PRIx64 " socket %s role %s\n"
+          "   id %u socket %s role %s\n"
           "   ring_size %u buffer_size %u\n"
           "   state %s link %s\n",
           mp->if_name, ntohl (mp->sw_if_index), format_ethernet_address,
-          mp->hw_addr, clib_net_to_host_u64 (mp->key), mp->socket_filename,
+          mp->hw_addr, clib_net_to_host_u32 (mp->id), mp->socket_filename,
           mp->role ? "slave" : "master",
           ntohl (mp->ring_size), ntohs (mp->buffer_size),
           mp->admin_up_down ? "up" : "down",
@@ -298,9 +311,9 @@ static void vl_api_memif_details_t_handler (vl_api_memif_details_t * mp)
  * and that the data plane plugin processes
  */
 #define foreach_vpe_api_msg                                      \
-_(memif_create, "[key <key>] [socket <path>] [ring_size <size>] " \
+_(memif_create, "[id <id>] [socket <path>] [ring_size <size>] " \
                "[buffer_size <size>] [hw_addr <mac_address>] "   \
-               "<master|slave>")                                 \
+               "[secret <string>] [mode ip] <master|slave>")     \
 _(memif_delete, "<sw_if_index>")                                  \
 _(memif_dump, "")
 
@@ -349,7 +362,7 @@ vat_plugin_register (vat_main_t * vam)
   const char *id ## _CRC __attribute__ ((unused)) = #n "_" #crc;
   foreach_vl_msg_name_crc_vpe;
 #undef _
-  mm->ping_id = vl_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC));
+  mm->ping_id = vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC));
 
   if (mm->msg_id_base != (u16) ~0)
     memif_vat_api_hookup (vam);