summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2019-09-04 09:12:29 +0200
committerDave Barach <openvpp@barachs.net>2019-09-16 12:23:27 +0000
commit33a58171e5995d9e649b414bfc77f2aab26e4c58 (patch)
tree85e072422b46ef44bbefbdf49231da507ec99536 /src/plugins
parent1292d19c79c2fd4f09ffcc43ebf39f5d9d485c35 (diff)
api: autogenerate api trace print/endian
In addition to the external vppapitrace tool, VPP itself supports dumping of API trace files. In two formats, "custom-dump" and "dump". "dump" gives a human friendly list, and "custom-dump" is meant to give a list of commands that can be fed to VAT. This patch only deals with "dump". Prior to this fix, auto-generation was only done for the basic types. This fix adds support for any type, including lists, and supports pretty-printing of enums, strings, IP addresses, MAC addresses and so on. Usage: api trace dump <api-trace-file> For example Change-Id: I4e485680e6dcfce7489299ae6cf31d835071ac40 ---------- trace 48 ----------- vl_api_sw_interface_set_flags_t: _vl_msg_id: 75 client_index: 0 context: 10 sw_if_index: 1 flags: IF_STATUS_API_FLAG_ADMIN_UP ---------- trace 49 ----------- vl_api_sw_interface_add_del_address_t: _vl_msg_id: 88 client_index: 0 context: 11 sw_if_index: 1 is_add: 1 del_all: 0 prefix: 172.16.1.1/24 ---------- trace 51 ----------- vl_api_cli_inband_t: _vl_msg_id: 819 client_index: 0 context: 13 cmd: packet-generator capture pg0 pcap /tmp/vpp-unittest-TestMAP-YhcmDX/pg0_out.pcap disable ---------- trace 58 ----------- vl_api_ip_neighbor_add_del_t: _vl_msg_id: 199 client_index: 0 context: 20 is_add: 1 neighbor: sw_if_index: 2 flags: IP_API_NEIGHBOR_FLAG_NONE mac_address: 0202.0000.ff02 ip_address: fd01:2::2 Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I5556d06008de2762e7c2d35a8b0963ae670b3db1 Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/abf/abf_all_api_h.h5
-rw-r--r--src/plugins/acl/CMakeLists.txt1
-rw-r--r--src/plugins/acl/acl_all_api_h.h2
-rw-r--r--src/plugins/acl/manual_fns.h53
-rw-r--r--src/plugins/gbp/gbp_all_api_h.h5
-rw-r--r--src/plugins/igmp/igmp_all_api_h.h4
-rw-r--r--src/plugins/l3xc/l3xc_all_api_h.h5
-rw-r--r--src/plugins/lb/lb_all_api_h.h5
-rw-r--r--src/plugins/lb/lb_test.c1
-rw-r--r--src/plugins/map/map_all_api_h.h5
-rw-r--r--src/plugins/map/map_api.c1
-rw-r--r--src/plugins/memif/memif_all_api_h.h4
-rw-r--r--src/plugins/nat/nat_all_api_h.h5
-rw-r--r--src/plugins/svs/svs_all_api_h.h4
14 files changed, 99 insertions, 1 deletions
diff --git a/src/plugins/abf/abf_all_api_h.h b/src/plugins/abf/abf_all_api_h.h
index 146896491ee..702c975bce8 100644
--- a/src/plugins/abf/abf_all_api_h.h
+++ b/src/plugins/abf/abf_all_api_h.h
@@ -13,4 +13,9 @@
* limitations under the License.
*/
/* Include the generated file, see BUILT_SOURCES in Makefile.am */
+
+#ifdef vl_printfun
+#include <vnet/format_fns.h>
+#endif
+
#include <abf/abf.api.h>
diff --git a/src/plugins/acl/CMakeLists.txt b/src/plugins/acl/CMakeLists.txt
index 803c8f97eba..0977129bafd 100644
--- a/src/plugins/acl/CMakeLists.txt
+++ b/src/plugins/acl/CMakeLists.txt
@@ -24,6 +24,7 @@ add_vpp_plugin(acl
API_FILES
acl.api
+ acl_types.api
API_TEST_SOURCES
acl_test.c
diff --git a/src/plugins/acl/acl_all_api_h.h b/src/plugins/acl/acl_all_api_h.h
index cb781cfd286..2a9d25d0bce 100644
--- a/src/plugins/acl/acl_all_api_h.h
+++ b/src/plugins/acl/acl_all_api_h.h
@@ -13,9 +13,9 @@
* limitations under the License.
*/
/* Include the generated file, see BUILT_SOURCES in Makefile.am */
-#include <acl/acl.api.h>
#ifdef vl_printfun
#include <acl/manual_fns.h>
#endif
+#include <acl/acl.api.h>
diff --git a/src/plugins/acl/manual_fns.h b/src/plugins/acl/manual_fns.h
index bc0ad92f3f1..c81bd3d3b8d 100644
--- a/src/plugins/acl/manual_fns.h
+++ b/src/plugins/acl/manual_fns.h
@@ -121,6 +121,59 @@ format_acl_action(u8 *s, u8 action)
}
static inline void *
+vl_api_acl_rule_t_print (vl_api_acl_rule_t * a, void *handle)
+{
+ u8 *s;
+
+ s = format (0, " %s ", a->is_ipv6 ? "ipv6" : "ipv4");
+ s = format_acl_action (s, a->is_permit);
+ s = format (s, " \\\n");
+
+ if (a->is_ipv6)
+ s = format (s, " src %U/%d dst %U/%d \\\n",
+ format_ip6_address, a->src_ip_addr, a->src_ip_prefix_len,
+ format_ip6_address, a->dst_ip_addr, a->dst_ip_prefix_len);
+ else
+ s = format (s, " src %U/%d dst %U/%d \\\n",
+ format_ip4_address, a->src_ip_addr, a->src_ip_prefix_len,
+ format_ip4_address, a->dst_ip_addr, a->dst_ip_prefix_len);
+ s = format (s, " proto %d \\\n", a->proto);
+ s = format (s, " sport %d-%d dport %d-%d \\\n",
+ clib_net_to_host_u16 (a->srcport_or_icmptype_first),
+ clib_net_to_host_u16 (a->srcport_or_icmptype_last),
+ clib_net_to_host_u16 (a->dstport_or_icmpcode_first),
+ clib_net_to_host_u16 (a->dstport_or_icmpcode_last));
+
+ s = format (s, " tcpflags %u mask %u, \\",
+ a->tcp_flags_value, a->tcp_flags_mask);
+ PRINT_S;
+ return handle;
+}
+
+static inline void *
+vl_api_macip_acl_rule_t_print (vl_api_macip_acl_rule_t * a, void *handle)
+{
+ u8 *s;
+
+ s = format (0, " %s %s \\\n", a->is_ipv6 ? "ipv6" : "ipv4",
+ a->is_permit ? "permit" : "deny");
+
+ s = format (s, " src mac %U mask %U \\\n",
+ format_ethernet_address, a->src_mac,
+ format_ethernet_address, a->src_mac_mask);
+
+ if (a->is_ipv6)
+ s = format (s, " src ip %U/%d, \\",
+ format_ip6_address, a->src_ip_addr, a->src_ip_prefix_len);
+ else
+ s = format (s, " src ip %U/%d, \\",
+ format_ip4_address, a->src_ip_addr, a->src_ip_prefix_len);
+
+ PRINT_S;
+ return handle;
+}
+
+static inline void *
vl_api_acl_add_replace_t_print (vl_api_acl_add_replace_t * a, void *handle)
{
u8 *s = 0;
diff --git a/src/plugins/gbp/gbp_all_api_h.h b/src/plugins/gbp/gbp_all_api_h.h
index dd78bc1d3ab..f90c36e554e 100644
--- a/src/plugins/gbp/gbp_all_api_h.h
+++ b/src/plugins/gbp/gbp_all_api_h.h
@@ -13,6 +13,11 @@
* limitations under the License.
*/
/* Include the generated file, see BUILT_SOURCES in Makefile.am */
+
+#ifdef vl_printfun
+#include <vnet/format_fns.h>
+#endif
+
#include <gbp/gbp.api.h>
#ifdef vl_printfun
diff --git a/src/plugins/igmp/igmp_all_api_h.h b/src/plugins/igmp/igmp_all_api_h.h
index 4f17a461414..9b552566a27 100644
--- a/src/plugins/igmp/igmp_all_api_h.h
+++ b/src/plugins/igmp/igmp_all_api_h.h
@@ -15,6 +15,10 @@
*------------------------------------------------------------------
*/
+#ifdef vl_printfun
+#include <vnet/format_fns.h>
+#endif
+
#include <igmp/igmp.api.h>
/*
diff --git a/src/plugins/l3xc/l3xc_all_api_h.h b/src/plugins/l3xc/l3xc_all_api_h.h
index ca53dbcde45..5152e2de1c3 100644
--- a/src/plugins/l3xc/l3xc_all_api_h.h
+++ b/src/plugins/l3xc/l3xc_all_api_h.h
@@ -13,4 +13,9 @@
* limitations under the License.
*/
/* Include the generated file, see BUILT_SOURCES in Makefile.am */
+
+#ifdef vl_printfun
+#include <vnet/format_fns.h>
+#endif
+
#include <l3xc/l3xc.api.h>
diff --git a/src/plugins/lb/lb_all_api_h.h b/src/plugins/lb/lb_all_api_h.h
index 6d830d710d2..6afc0f35908 100644
--- a/src/plugins/lb/lb_all_api_h.h
+++ b/src/plugins/lb/lb_all_api_h.h
@@ -16,4 +16,9 @@
* limitations under the License.
*/
/* Include the generated file, see BUILT_SOURCES in Makefile.am */
+
+#ifdef vl_printfun
+#include <vnet/format_fns.h>
+#endif
+
#include <lb/lb.api.h>
diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c
index 1edabb51f86..3da7eb04ffb 100644
--- a/src/plugins/lb/lb_test.c
+++ b/src/plugins/lb/lb_test.c
@@ -84,6 +84,7 @@ typedef enum {
/* instantiate all the print functions we know about */
#define vl_print(handle, ...)
#define vl_printfun
+#include <vnet/format_fns.h>
#include <lb/lb.api.h>
#undef vl_printfun
diff --git a/src/plugins/map/map_all_api_h.h b/src/plugins/map/map_all_api_h.h
index 4fb3e199bb2..c622bec170b 100644
--- a/src/plugins/map/map_all_api_h.h
+++ b/src/plugins/map/map_all_api_h.h
@@ -16,4 +16,9 @@
* limitations under the License.
*/
/* Include the generated file, see BUILT_SOURCES in Makefile.am */
+
+#ifdef vl_printfun
+#include <vnet/format_fns.h>
+#endif
+
#include <map/map.api.h>
diff --git a/src/plugins/map/map_api.c b/src/plugins/map/map_api.c
index 5f2e1f82696..654e1793064 100644
--- a/src/plugins/map/map_api.c
+++ b/src/plugins/map/map_api.c
@@ -17,6 +17,7 @@
*------------------------------------------------------------------
*/
+#include <vnet/ip/ip_types_api.h>
#include <map/map.h>
#include <map/map_msg_enum.h>
#include <vnet/ip/ip.h>
diff --git a/src/plugins/memif/memif_all_api_h.h b/src/plugins/memif/memif_all_api_h.h
index 9729ec16239..b4a93724848 100644
--- a/src/plugins/memif/memif_all_api_h.h
+++ b/src/plugins/memif/memif_all_api_h.h
@@ -15,4 +15,8 @@
* limitations under the License.
*/
/* Include the generated file, see BUILT_SOURCES in Makefile.am */
+
+#ifdef vl_printfun
+#include <vnet/format_fns.h>
+#endif
#include <memif/memif.api.h>
diff --git a/src/plugins/nat/nat_all_api_h.h b/src/plugins/nat/nat_all_api_h.h
index acd9ba1cac9..f011a089b09 100644
--- a/src/plugins/nat/nat_all_api_h.h
+++ b/src/plugins/nat/nat_all_api_h.h
@@ -16,4 +16,9 @@
* limitations under the License.
*/
/* Include the generated file, see BUILT_SOURCES in Makefile.am */
+
+#ifdef vl_printfun
+#include <vnet/format_fns.h>
+#endif
+
#include <nat/nat.api.h>
diff --git a/src/plugins/svs/svs_all_api_h.h b/src/plugins/svs/svs_all_api_h.h
index dff1657468f..cdec36e0e17 100644
--- a/src/plugins/svs/svs_all_api_h.h
+++ b/src/plugins/svs/svs_all_api_h.h
@@ -14,4 +14,8 @@
*/
/* Include the generated file, see BUILT_SOURCES in Makefile.am */
+#ifdef vl_printfun
+#include <vnet/format_fns.h>
+#endif
+
#include <svs/svs.api.h>