summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/pg/cli.c4
-rw-r--r--src/vnet/pg/pg.api26
-rw-r--r--src/vnet/pg/pg.h4
-rw-r--r--src/vnet/pg/pg_api.c12
4 files changed, 21 insertions, 25 deletions
diff --git a/src/vnet/pg/cli.c b/src/vnet/pg/cli.c
index f78bb37bf61..9336ca406d7 100644
--- a/src/vnet/pg/cli.c
+++ b/src/vnet/pg/cli.c
@@ -86,7 +86,7 @@ pg_capture (pg_capture_args_t * a)
if (a->is_enabled == 1)
{
struct stat sb;
- if (stat ((char *) a->pcap_file_name, &sb) != -1)
+ if (stat (a->pcap_file_name, &sb) != -1)
return clib_error_return (0, "pcap file '%s' already exists.",
a->pcap_file_name);
}
@@ -632,7 +632,7 @@ pg_capture_cmd_fn (vlib_main_t * vm,
a->hw_if_index = hw_if_index;
a->dev_instance = hi->dev_instance;
a->is_enabled = !is_disable;
- a->pcap_file_name = pcap_file_name;
+ a->pcap_file_name = (char *) pcap_file_name;
a->count = count;
error = pg_capture (a);
diff --git a/src/vnet/pg/pg.api b/src/vnet/pg/pg.api
index 6a421e45d7d..ad44beeedfa 100644
--- a/src/vnet/pg/pg.api
+++ b/src/vnet/pg/pg.api
@@ -18,7 +18,9 @@
This file defines packet-generator interface APIs.
*/
-option version = "1.1.0";
+option version = "2.0.0";
+
+import "vnet/interface_types.api";
/** \brief PacketGenerator create interface request
@param client_index - opaque cookie to identify the sender
@@ -31,8 +33,8 @@ define pg_create_interface
{
u32 client_index;
u32 context;
- u32 interface_id;
- u8 gso_enabled;
+ vl_api_interface_index_t interface_id;
+ bool gso_enabled;
u32 gso_size;
};
@@ -44,7 +46,7 @@ define pg_create_interface_reply
{
u32 context;
i32 retval;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
/** \brief PacketGenerator capture packets on given interface request
@@ -53,32 +55,30 @@ define pg_create_interface_reply
@param interface_id - pg interface index
@param is_enabled - 1 if enabling streams, 0 if disabling
@param count - number of packets to be captured
- @param pcap_file - pacp file name to store captured packets
+ @param pcap_file_name - pacp file name to store captured packets
*/
autoreply define pg_capture
{
u32 client_index;
u32 context;
- u32 interface_id;
- u8 is_enabled;
+ vl_api_interface_index_t interface_id;
+ bool is_enabled [default=true];
u32 count;
- u32 pcap_name_length;
- u8 pcap_file_name[pcap_name_length];
+ string pcap_file_name[];
};
/** \brief Enable / disable packet generator request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param is_enabled - 1 if enabling streams, 0 if disabling
- @param stream - stream name to be enable/disabled, if not specified handle all streams
+ @param stream_name - stream name to be enable/disabled, if not specified handle all streams
*/
autoreply define pg_enable_disable
{
u32 client_index;
u32 context;
- u8 is_enabled;
- u32 stream_name_length;
- u8 stream_name[stream_name_length];
+ bool is_enabled [default=true];
+ string stream_name[];
};
/*
diff --git a/src/vnet/pg/pg.h b/src/vnet/pg/pg.h
index c73634f3125..55bc75dc282 100644
--- a/src/vnet/pg/pg.h
+++ b/src/vnet/pg/pg.h
@@ -305,7 +305,7 @@ typedef struct
u8 gso_enabled;
u32 gso_size;
pcap_main_t pcap_main;
- u8 *pcap_file_name;
+ char *pcap_file_name;
} pg_interface_t;
/* Per VLIB node data. */
@@ -379,7 +379,7 @@ typedef struct
u32 hw_if_index;
u32 dev_instance;
u8 is_enabled;
- u8 *pcap_file_name;
+ char *pcap_file_name;
u32 count;
} pg_capture_args_t;
diff --git a/src/vnet/pg/pg_api.c b/src/vnet/pg/pg_api.c
index 5b64a77c0fc..18de1e9e8c4 100644
--- a/src/vnet/pg/pg_api.c
+++ b/src/vnet/pg/pg_api.c
@@ -87,10 +87,8 @@ vl_api_pg_capture_t_handler (vl_api_pg_capture_t * mp)
if (hw_if_index != ~0)
{
pg_capture_args_t _a, *a = &_a;
-
- u32 len = ntohl (mp->pcap_name_length);
- u8 *pcap_file_name = vec_new (u8, len);
- clib_memcpy (pcap_file_name, mp->pcap_file_name, len);
+ char *pcap_file_name =
+ vl_api_from_api_to_new_c_string (&mp->pcap_file_name);
hi = vnet_get_sup_hw_interface (vnm, hw_if_index);
a->hw_if_index = hw_if_index;
@@ -121,12 +119,10 @@ vl_api_pg_enable_disable_t_handler (vl_api_pg_enable_disable_t * mp)
u32 stream_index = ~0;
int is_enable = mp->is_enabled != 0;
- u32 len = ntohl (mp->stream_name_length) - 1;
- if (len > 0)
+ if (vl_api_string_len (&mp->stream_name) > 0)
{
- u8 *stream_name = vec_new (u8, len);
- clib_memcpy (stream_name, mp->stream_name, len);
+ u8 *stream_name = vl_api_from_api_to_new_vec (&mp->stream_name);
uword *p = hash_get_mem (pg->stream_index_by_name, stream_name);
if (p)
stream_index = *p;