pg: API cleanup
Use consistent API types.
Type: fix
Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Change-Id: Ibf693e4b178d2579bc3afb9653bffc07fbb7dd0a
Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
diff --git a/src/vnet/pg/cli.c b/src/vnet/pg/cli.c
index f78bb37..9336ca4 100644
--- a/src/vnet/pg/cli.c
+++ b/src/vnet/pg/cli.c
@@ -86,7 +86,7 @@
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 @@
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 6a421e4..ad44bee 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 @@
{
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 @@
{
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 @@
@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 c73634f..55bc75d 100644
--- a/src/vnet/pg/pg.h
+++ b/src/vnet/pg/pg.h
@@ -305,7 +305,7 @@
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 @@
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 5b64a77..18de1e9 100644
--- a/src/vnet/pg/pg_api.c
+++ b/src/vnet/pg/pg_api.c
@@ -87,10 +87,8 @@
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 @@
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;