summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2020-01-30 14:14:15 +0100
committerOle Trøan <otroan@employees.org>2020-02-26 11:46:39 +0000
commitdb86329abb4ea164b9061a1d6b47f186c6b9b8fb (patch)
tree669fe5cf65e70fa91449b12610558f2549949ea2
parent00ec4019b399132a72467ed4c3fb039d4f2466b7 (diff)
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>
-rw-r--r--src/vat/api_format.c8
-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
-rw-r--r--src/vpp/api/custom_dump.c6
6 files changed, 27 insertions, 33 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index da64a8151fd..404f9045ea1 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -18593,17 +18593,15 @@ api_pg_capture (vat_main_t * vam)
}
}
- u32 name_len = vec_len (pcap_file);
/* Construct the API message */
M (PG_CAPTURE, mp);
mp->context = 0;
mp->interface_id = ntohl (if_id);
mp->is_enabled = enable;
mp->count = ntohl (count);
- mp->pcap_name_length = ntohl (name_len);
if (pcap_file_set != 0)
{
- clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
+ vl_api_vec_to_api_string (pcap_file, &mp->pcap_file_name);
}
vec_free (pcap_file);
@@ -18641,15 +18639,13 @@ api_pg_enable_disable (vat_main_t * vam)
}
}
- u32 name_len = vec_len (stream_name);
/* Construct the API message */
M (PG_ENABLE_DISABLE, mp);
mp->context = 0;
mp->is_enabled = enable;
if (stream_name_set != 0)
{
- mp->stream_name_length = ntohl (name_len);
- clib_memcpy (mp->stream_name, stream_name, name_len);
+ vl_api_vec_to_api_string (stream_name, &mp->stream_name);
}
vec_free (stream_name);
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;
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 2a660312981..91561048d8f 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -2531,8 +2531,10 @@ static void *vl_api_pg_enable_disable_t_print
u8 *s;
s = format (0, "SCRIPT: pg_enable_disable ");
- if ((mp->stream_name_length) > 0)
- s = format (s, "stream %s", mp->stream_name);
+ if (vl_api_string_len (&mp->stream_name) > 0)
+ s =
+ format (s, "stream %s",
+ vl_api_from_api_to_new_c_string (&mp->stream_name));
if (!mp->is_enabled)
s = format (s, "disable");