API: Cleanup APIs interface.api
[vpp.git] / src / vpp / api / custom_dump.c
index cf01600..fa7091d 100644 (file)
@@ -20,6 +20,7 @@
 #include <vnet/vnet.h>
 #include <vnet/ip/ip.h>
 #include <vnet/ip/ip_neighbor.h>
+#include <vnet/ip/ip_types_api.h>
 #include <vnet/unix/tuntap.h>
 #include <vnet/mpls/mpls.h>
 #include <vnet/dhcp/dhcp_proxy.h>
@@ -35,6 +36,7 @@
 #include <vnet/policer/policer.h>
 #include <vnet/classify/flow_classify.h>
 #include <vlib/vlib.h>
+#include <vlib/pci/pci.h>
 #include <vlib/unix/unix.h>
 #include <vlibapi/api.h>
 #include <vlibmemory/api.h>
@@ -43,6 +45,7 @@
 #include <vpp/oam/oam.h>
 
 #include <vnet/ethernet/ethernet.h>
+#include <vnet/ethernet/ethernet_types_api.h>
 #include <vnet/l2/l2_vtr.h>
 
 #include <vpp/api/vpe_msg_enum.h>
@@ -109,7 +112,7 @@ static void *vl_api_sw_interface_set_flags_t_print
 
   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
 
-  if (mp->admin_up_down)
+  if (ntohl (mp->flags) & IF_STATUS_API_FLAG_ADMIN_UP)
     s = format (s, "admin-up ");
   else
     s = format (s, "admin-down ");
@@ -156,12 +159,12 @@ static void *vl_api_sw_interface_event_t_print
 
   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
 
-  if (mp->admin_up_down)
+  if (ntohl (mp->flags) & IF_STATUS_API_FLAG_ADMIN_UP)
     s = format (s, "admin-up ");
   else
     s = format (s, "admin-down ");
 
-  if (mp->link_up_down)
+  if (ntohl (mp->flags) & IF_STATUS_API_FLAG_LINK_UP)
     s = format (s, "link-up");
   else
     s = format (s, "link-down");
@@ -176,17 +179,18 @@ static void *vl_api_sw_interface_add_del_address_t_print
   (vl_api_sw_interface_add_del_address_t * mp, void *handle)
 {
   u8 *s;
+  ip46_address_t address;
 
   s = format (0, "SCRIPT: sw_interface_add_del_address ");
 
   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
 
-  if (mp->is_ipv6)
+  if (ip_address_decode (&mp->prefix.address, &address) == IP46_TYPE_IP6)
     s = format (s, "%U/%d ", format_ip6_address,
-               (ip6_address_t *) mp->address, mp->address_length);
+               (ip6_address_t *) & address.ip6, mp->prefix.address_length);
   else
     s = format (s, "%U/%d ", format_ip4_address,
-               (ip4_address_t *) mp->address, mp->address_length);
+               (ip4_address_t *) & address.ip4, mp->prefix.address_length);
 
   if (mp->is_add == 0)
     s = format (s, "del ");
@@ -536,72 +540,6 @@ static void *vl_api_bd_ip_mac_dump_t_print
   FINISH;
 }
 
-static void *vl_api_tap_connect_t_print
-  (vl_api_tap_connect_t * mp, void *handle)
-{
-  u8 *s;
-  u8 null_mac[6];
-
-  clib_memset (null_mac, 0, sizeof (null_mac));
-
-  s = format (0, "SCRIPT: tap_connect ");
-  s = format (s, "tapname %s ", mp->tap_name);
-  if (mp->use_random_mac)
-    s = format (s, "random-mac ");
-  if (mp->tag[0])
-    s = format (s, "tag %s ", mp->tag);
-  if (memcmp (mp->mac_address, null_mac, 6))
-    s = format (s, "mac %U ", format_ethernet_address, mp->mac_address);
-  if (mp->ip4_address_set)
-    s = format (s, "address %U/%d ", format_ip4_address, mp->ip4_address,
-               mp->ip4_mask_width);
-  if (mp->ip6_address_set)
-    s = format (s, "address %U/%d ", format_ip6_address, mp->ip6_address,
-               mp->ip6_mask_width);
-  FINISH;
-}
-
-static void *vl_api_tap_modify_t_print
-  (vl_api_tap_modify_t * mp, void *handle)
-{
-  u8 *s;
-  u8 null_mac[6];
-
-  clib_memset (null_mac, 0, sizeof (null_mac));
-
-  s = format (0, "SCRIPT: tap_modify ");
-  s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
-  s = format (s, "tapname %s ", mp->tap_name);
-  if (mp->use_random_mac)
-    s = format (s, "random-mac ");
-
-  if (memcmp (mp->mac_address, null_mac, 6))
-    s = format (s, "mac %U ", format_ethernet_address, mp->mac_address);
-
-  FINISH;
-}
-
-static void *vl_api_tap_delete_t_print
-  (vl_api_tap_delete_t * mp, void *handle)
-{
-  u8 *s;
-
-  s = format (0, "SCRIPT: tap_delete ");
-  s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
-
-  FINISH;
-}
-
-static void *vl_api_sw_interface_tap_dump_t_print
-  (vl_api_sw_interface_tap_dump_t * mp, void *handle)
-{
-  u8 *s;
-
-  s = format (0, "SCRIPT: sw_interface_tap_dump ");
-
-  FINISH;
-}
-
 static void *vl_api_tap_create_v2_t_print
   (vl_api_tap_create_v2_t * mp, void *handle)
 {
@@ -662,6 +600,49 @@ static void *vl_api_sw_interface_tap_v2_dump_t_print
   FINISH;
 }
 
+static void *vl_api_virtio_pci_create_t_print
+  (vl_api_virtio_pci_create_t * mp, void *handle)
+{
+  u8 *s;
+  u8 null_mac[6];
+
+  clib_memset (null_mac, 0, sizeof (null_mac));
+
+  s = format (0, "SCRIPT: virtio_pci_create ");
+  s = format (s, "pci_addr %U ", format_vlib_pci_addr, ntohl (mp->pci_addr));
+  if (memcmp (mp->mac_address, null_mac, 6))
+    s = format (s, "mac-address %U ",
+               format_ethernet_address, mp->mac_address);
+  if (mp->tx_ring_sz)
+    s = format (s, "tx-ring-size %u ", ntohs (mp->tx_ring_sz));
+  if (mp->rx_ring_sz)
+    s = format (s, "rx-ring-size %u ", ntohs (mp->rx_ring_sz));
+  if (mp->features)
+    s = format (s, "features 0x%llx ", clib_net_to_host_u64 (mp->features));
+  FINISH;
+}
+
+static void *vl_api_virtio_pci_delete_t_print
+  (vl_api_virtio_pci_delete_t * mp, void *handle)
+{
+  u8 *s;
+
+  s = format (0, "SCRIPT: virtio_pci_delete ");
+  s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
+
+  FINISH;
+}
+
+static void *vl_api_sw_interface_virtio_pci_dump_t_print
+  (vl_api_sw_interface_virtio_pci_dump_t * mp, void *handle)
+{
+  u8 *s;
+
+  s = format (0, "SCRIPT: sw_interface_virtio_pci_dump ");
+
+  FINISH;
+}
+
 static void *vl_api_bond_create_t_print
   (vl_api_bond_create_t * mp, void *handle)
 {
@@ -675,9 +656,11 @@ static void *vl_api_bond_create_t_print
     s = format (s, "mac-address %U ",
                format_ethernet_address, mp->mac_address);
   if (mp->mode)
-    s = format (s, "mode %U", format_bond_mode, mp->mode);
+    s = format (s, "mode %U ", format_bond_mode, mp->mode);
   if (mp->lb)
-    s = format (s, "lb %U", format_bond_load_balance, mp->lb);
+    s = format (s, "lb %U ", format_bond_load_balance, mp->lb);
+  if (mp->id != ~0)
+    s = format (s, "id %u ", ntohl (mp->id));
   FINISH;
 }
 
@@ -917,11 +900,10 @@ static void *vl_api_proxy_arp_add_del_t_print
   s = format (0, "SCRIPT: proxy_arp_add_del ");
 
   s = format (s, "%U - %U ",
-             format_ip4_address, mp->proxy.low_address,
-             format_ip4_address, mp->proxy.hi_address);
+             format_vl_api_ip4_address, mp->proxy.low,
+             format_vl_api_ip4_address, mp->proxy.hi);
 
-  if (mp->proxy.vrf_id)
-    s = format (s, "vrf %d ", ntohl (mp->proxy.vrf_id));
+  s = format (s, "table %d ", ntohl (mp->proxy.table_id));
 
   if (mp->is_add == 0)
     s = format (s, "del ");
@@ -1040,31 +1022,21 @@ static void *vl_api_ip_neighbor_add_del_t_print
   (vl_api_ip_neighbor_add_del_t * mp, void *handle)
 {
   u8 *s;
-  u8 null_mac[6];
-
-  clib_memset (null_mac, 0, sizeof (null_mac));
 
   s = format (0, "SCRIPT: ip_neighbor_add_del ");
 
-  s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
+  s = format (s, "sw_if_index %d ", ntohl (mp->neighbor.sw_if_index));
 
-  if (mp->is_static)
+  if (IP_API_NEIGHBOR_FLAG_STATIC & ntohl (mp->neighbor.flags))
     s = format (s, "is_static ");
 
-  if (mp->is_no_adj_fib)
+  if (IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY & ntohl (mp->neighbor.flags))
     s = format (s, "is_no_fib_entry ");
 
-  if (memcmp (mp->mac_address, null_mac, 6))
-    s = format (s, "mac %U ", format_ethernet_address, mp->mac_address);
+  s = format (s, "mac %U ", format_vl_api_mac_address,
+             &mp->neighbor.mac_address);
 
-  if (mp->is_ipv6)
-    s =
-      format (s, "dst %U ", format_ip6_address,
-             (ip6_address_t *) mp->dst_address);
-  else
-    s =
-      format (s, "dst %U ", format_ip4_address,
-             (ip4_address_t *) mp->dst_address);
+  s = format (s, "dst %U ", format_vl_api_address, &mp->neighbor.ip_address);
 
   if (mp->is_add == 0)
     s = format (s, "del ");
@@ -1072,6 +1044,7 @@ static void *vl_api_ip_neighbor_add_del_t_print
   FINISH;
 }
 
+
 static void *vl_api_create_vlan_subif_t_print
   (vl_api_create_vlan_subif_t * mp, void *handle)
 {
@@ -1088,15 +1061,15 @@ static void *vl_api_create_vlan_subif_t_print
   FINISH;
 }
 
-#define foreach_create_subif_bit                \
-_(no_tags)                                      \
-_(one_tag)                                      \
-_(two_tags)                                     \
-_(dot1ad)                                       \
-_(exact_match)                                  \
-_(default_sub)                                  \
-_(outer_vlan_id_any)                            \
-_(inner_vlan_id_any)
+#define foreach_create_subif_flag              \
+_(0, "no_tags")                                        \
+_(1, "one_tag")                                        \
+_(2, "two_tags")                               \
+_(3, "dot1ad")                                 \
+_(4, "exact_match")                            \
+_(5, "default_sub")                            \
+_(6, "outer_vlan_id_any")                      \
+_(7, "inner_vlan_id_any")
 
 static void *vl_api_create_subif_t_print
   (vl_api_create_subif_t * mp, void *handle)
@@ -1115,8 +1088,8 @@ static void *vl_api_create_subif_t_print
   if (mp->inner_vlan_id)
     s = format (s, "inner_vlan_id %d ", ntohs (mp->inner_vlan_id));
 
-#define _(a) if (mp->a) s = format (s, "%s ", #a);
-  foreach_create_subif_bit;
+#define _(a,b) if (mp->sub_if_flags & (1 << a)) s = format (s, "%s ", b);
+  foreach_create_subif_flag;
 #undef _
 
   FINISH;
@@ -1289,8 +1262,7 @@ static void *vl_api_sw_interface_ip6nd_ra_prefix_t_print
 
   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
 
-  s = format (s, "%U/%d ", format_ip6_address, mp->address,
-             mp->address_length);
+  s = format (s, "%U ", format_vl_api_prefix, &mp->prefix);
 
   s = format (s, "val_life %d ", ntohl (mp->val_lifetime));
 
@@ -2237,10 +2209,7 @@ static void *vl_api_ip_probe_neighbor_t_print
 
   s = format (0, "SCRIPT: ip_probe_neighbor ");
   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
-  if (mp->is_ipv6)
-    s = format (s, "address %U ", format_ip6_address, &mp->dst_address);
-  else
-    s = format (s, "address %U ", format_ip4_address, &mp->dst_address);
+  s = format (s, "address %U ", format_vl_api_address, &mp->dst);
 
   FINISH;
 }
@@ -2283,7 +2252,7 @@ static void *vl_api_want_ip4_arp_events_t_print
 
   s = format (0, "SCRIPT: want_ip4_arp_events ");
   s = format (s, "pid %d address %U ", ntohl (mp->pid),
-             format_ip4_address, &mp->address);
+             format_ip4_address, mp->ip);
   if (mp->enable_disable == 0)
     s = format (s, "del ");
 
@@ -2297,7 +2266,7 @@ static void *vl_api_want_ip6_nd_events_t_print
 
   s = format (0, "SCRIPT: want_ip6_nd_events ");
   s = format (s, "pid %d address %U ", ntohl (mp->pid),
-             format_ip6_address, mp->address);
+             format_vl_api_ip6_address, mp->ip);
   if (mp->enable_disable == 0)
     s = format (s, "del ");
 
@@ -2887,12 +2856,7 @@ static void *vl_api_ip_source_and_port_range_check_add_del_t_print
   int i;
 
   s = format (0, "SCRIPT: ip_source_and_port_range_check_add_del ");
-  if (mp->is_ipv6)
-    s = format (s, "%U/%d ", format_ip6_address, mp->address,
-               mp->mask_length);
-  else
-    s = format (s, "%U/%d ", format_ip4_address, mp->address,
-               mp->mask_length);
+  s = format (s, "%U ", format_vl_api_prefix, &mp->prefix);
 
   for (i = 0; i < mp->number_of_ranges; i++)
     {
@@ -3682,14 +3646,9 @@ static void *vl_api_ip_container_proxy_add_del_t_print
 {
   u8 *s;
   s = format (0, "SCRIPT: ip_container_proxy_add_del ");
-  if (mp->is_ip4)
-    s = format (s, "is_add %d address %U/%d sw_if_index %d",
-               mp->is_add, format_ip4_address,
-               (ip4_address_t *) mp->ip, mp->plen, mp->sw_if_index);
-  else
-    s = format (s, "is_add %d address %U/%d sw_if_index %d",
-               mp->is_add, format_ip6_address,
-               (ip6_address_t *) mp->ip, mp->plen, mp->sw_if_index);
+  s = format (s, "is_add %d prefix %U sw_if_index %d",
+             mp->is_add, format_vl_api_prefix, mp->sw_if_index);
+
   FINISH;
 }
 
@@ -3700,9 +3659,8 @@ static void *vl_api_qos_record_enable_disable_t_print
 
   s = format (0, "SCRIPT: qos_record_enable_disable ");
   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
-  s =
-    format (s, "input_source %U ", format_qos_source,
-           ntohl (mp->input_source));
+  s = format (s, "input_source %U ", format_qos_source,
+             ntohl (mp->input_source));
 
   if (!mp->enable)
     s = format (s, "disable ");
@@ -3739,10 +3697,6 @@ _(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable)           \
 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath)                       \
 _(SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass)         \
 _(SW_INTERFACE_SET_GENEVE_BYPASS, sw_interface_set_geneve_bypass)       \
-_(TAP_CONNECT, tap_connect)                                             \
-_(TAP_MODIFY, tap_modify)                                               \
-_(TAP_DELETE, tap_delete)                                               \
-_(SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump)                         \
 _(BOND_CREATE, bond_create)                                             \
 _(BOND_DELETE, bond_delete)                                             \
 _(BOND_ENSLAVE, bond_enslave)                                           \