tap: refactor existing flags
[vpp.git] / src / vpp / api / custom_dump.c
index 2a66031..e0ba9f9 100644 (file)
@@ -582,7 +582,15 @@ static void *vl_api_tap_create_v2_t_print
   if ((mp->tap_flags) & 0x1)
     s = format (s, "gso-enabled ");
   if ((mp->tap_flags) & 0x2)
-    s = format (s, "csum-offload-enabled");
+    s = format (s, "csum-offload-enabled ");
+  if ((mp->tap_flags) & 0x4)
+    s = format (s, "persist ");
+  if ((mp->tap_flags) & 0x8)
+    s = format (s, "attach ");
+  if ((mp->tap_flags) & 0x16)
+    s = format (s, "tun ");
+  if ((mp->tap_flags) & 0x32)
+    s = format (s, "gro-coalesce-enabled ");
   FINISH;
 }
 
@@ -1074,7 +1082,7 @@ static void *vl_api_sr_localsid_add_del_t_print
     {
     case SR_BEHAVIOR_END:
       s = format (s, "Address: %U\nBehavior: End",
-                 format_ip6_address, (ip6_address_t *) mp->localsid.addr);
+                 format_ip6_address, (ip6_address_t *) mp->localsid);
       s = format (s, (mp->end_psp ? "End.PSP: True" : "End.PSP: False"));
       break;
     case SR_BEHAVIOR_X:
@@ -1082,9 +1090,9 @@ static void *vl_api_sr_localsid_add_del_t_print
        format (s,
                "Address: %U\nBehavior: X (Endpoint with Layer-3 cross-connect)"
                "\nIface: %U\nNext hop: %U", format_ip6_address,
-               (ip6_address_t *) mp->localsid.addr,
+               (ip6_address_t *) mp->localsid,
                format_vnet_sw_if_index_name, vnm, (mp->sw_if_index),
-               format_ip6_address, (ip6_address_t *) mp->nh_addr6);
+               format_ip6_address, (ip6_address_t *) mp->nh_addr.un.ip6);
       s = format (s, (mp->end_psp ? "End.PSP: True" : "End.PSP: False"));
       break;
     case SR_BEHAVIOR_DX4:
@@ -1092,25 +1100,25 @@ static void *vl_api_sr_localsid_add_del_t_print
        format (s,
                "Address: %U\nBehavior: DX4 (Endpoint with decapsulation with IPv4 cross-connect)"
                "\nIface: %U\nNext hop: %U", format_ip6_address,
-               (ip6_address_t *) mp->localsid.addr,
+               (ip6_address_t *) mp->localsid,
                format_vnet_sw_if_index_name, vnm, (mp->sw_if_index),
-               format_ip4_address, (ip4_address_t *) mp->nh_addr4);
+               format_ip4_address, (ip4_address_t *) mp->nh_addr.un.ip4);
       break;
     case SR_BEHAVIOR_DX6:
       s =
        format (s,
                "Address: %U\nBehavior: DX6 (Endpoint with decapsulation with IPv6 cross-connect)"
                "\nIface: %UNext hop: %U", format_ip6_address,
-               (ip6_address_t *) mp->localsid.addr,
+               (ip6_address_t *) mp->localsid,
                format_vnet_sw_if_index_name, vnm, (mp->sw_if_index),
-               format_ip6_address, (ip6_address_t *) mp->nh_addr6);
+               format_ip6_address, (ip6_address_t *) mp->nh_addr.un.ip6);
       break;
     case SR_BEHAVIOR_DX2:
       s =
        format (s,
                "Address: %U\nBehavior: DX2 (Endpoint with decapulation and Layer-2 cross-connect)"
                "\nIface: %U", format_ip6_address,
-               (ip6_address_t *) mp->localsid.addr,
+               (ip6_address_t *) mp->localsid,
                format_vnet_sw_if_index_name, vnm, (mp->sw_if_index));
       break;
     case SR_BEHAVIOR_DT6:
@@ -1118,20 +1126,20 @@ static void *vl_api_sr_localsid_add_del_t_print
        format (s,
                "Address: %U\nBehavior: DT6 (Endpoint with decapsulation and specific IPv6 table lookup)"
                "\nTable: %u", format_ip6_address,
-               (ip6_address_t *) mp->localsid.addr, (mp->fib_table));
+               (ip6_address_t *) mp->localsid, (mp->fib_table));
       break;
     case SR_BEHAVIOR_DT4:
       s =
        format (s,
                "Address: %U\nBehavior: DT4 (Endpoint with decapsulation and specific IPv4 table lookup)"
                "\nTable: %u", format_ip6_address,
-               (ip6_address_t *) mp->localsid.addr, (mp->fib_table));
+               (ip6_address_t *) mp->localsid, (mp->fib_table));
       break;
     default:
       if (mp->behavior >= SR_BEHAVIOR_LAST)
        {
          s = format (s, "Address: %U\n Behavior: %u",
-                     format_ip6_address, (ip6_address_t *) mp->localsid.addr,
+                     format_ip6_address, (ip6_address_t *) mp->localsid,
                      mp->behavior);
        }
       else
@@ -1158,11 +1166,13 @@ static void *vl_api_sr_steering_add_del_t_print
       break;
     case SR_STEER_IPV4:
       s = format (s, "Traffic type: IPv4 %U/%u", format_ip4_address,
-                 (ip4_address_t *) mp->prefix_addr, (mp->mask_width));
+                 (ip4_address_t *) mp->prefix.address.un.ip4,
+                 (mp->prefix.len));
       break;
     case SR_STEER_IPV6:
       s = format (s, "Traffic type: IPv6 %U/%u", format_ip6_address,
-                 (ip6_address_t *) mp->prefix_addr, (mp->mask_width));
+                 (ip6_address_t *) mp->prefix.address.un.ip6,
+                 (mp->prefix.len));
       break;
     default:
       s = format (s, "Traffic type: Unknown(%u)", mp->traffic_type);
@@ -1206,7 +1216,7 @@ static void *vl_api_sr_policy_add_t_print
 
   s = format (s, "FIB_table: %u", (mp->fib_table));
 
-  s = format (s, (mp->type ? "Type: Default" : "Type: Spray"));
+  s = format (s, (mp->is_spray ? "Type: Default" : "Type: Spray"));
 
   s = format (s, "SID list weight: %u", (mp->weight));
 
@@ -1480,8 +1490,10 @@ static void *vl_api_vxlan_add_del_tunnel_t_print
   u8 *s;
   s = format (0, "SCRIPT: vxlan_add_del_tunnel ");
 
-  ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
-  ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
+  ip46_address_t src =
+    to_ip46 (mp->src_address.af, (u8 *) & mp->src_address.un);
+  ip46_address_t dst =
+    to_ip46 (mp->dst_address.af, (u8 *) & mp->dst_address.un);
 
   u8 is_grp = ip46_address_is_multicast (&dst);
   char *dst_name = is_grp ? "group" : "dst";
@@ -1726,9 +1738,11 @@ static void *vl_api_create_vhost_user_if_t_print
   if (mp->disable_indirect_desc)
     s = format (s, "disable_indirect_desc ");
   if (mp->tag[0])
-    s = format (s, "tag %s", mp->tag);
+    s = format (s, "tag %s ", mp->tag);
   if (mp->enable_gso)
-    s = format (s, "gso");
+    s = format (s, "gso ");
+  if (mp->enable_packed)
+    s = format (s, "packed");
 
   FINISH;
 }
@@ -1747,7 +1761,9 @@ static void *vl_api_modify_vhost_user_if_t_print
   if (mp->renumber)
     s = format (s, "renumber %d ", (mp->custom_dev_instance));
   if (mp->enable_gso)
-    s = format (s, "gso");
+    s = format (s, "gso ");
+  if (mp->enable_packed)
+    s = format (s, "packed");
 
   FINISH;
 }
@@ -1898,8 +1914,10 @@ static void *vl_api_vxlan_gpe_add_del_tunnel_t_print
 
   s = format (0, "SCRIPT: vxlan_gpe_add_del_tunnel ");
 
-  ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
-  ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
+  ip46_address_t local, remote;
+
+  ip_address_decode (&mp->local, &local);
+  ip_address_decode (&mp->remote, &remote);
 
   u8 is_grp = ip46_address_is_multicast (&remote);
   char *remote_name = is_grp ? "group" : "remote";
@@ -2183,11 +2201,11 @@ static void *vl_api_policer_add_del_t_print
     }
 
   s = format (s, "conform_action %U ", format_policer_action,
-             mp->conform_action_type, mp->conform_dscp);
+             mp->conform_action.type, mp->conform_action.dscp);
   s = format (s, "exceed_action %U ", format_policer_action,
-             mp->exceed_action_type, mp->exceed_dscp);
+             mp->exceed_action.type, mp->exceed_action.dscp);
   s = format (s, "violate_action %U ", format_policer_action,
-             mp->violate_action_type, mp->violate_dscp);
+             mp->violate_action.type, mp->violate_action.dscp);
 
   if (mp->color_aware)
     s = format (s, "color-aware ");
@@ -2531,8 +2549,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");
 
@@ -2595,7 +2615,7 @@ static void *vl_api_lisp_enable_disable_t_print
   u8 *s;
 
   s = format (0, "SCRIPT: lisp_enable_disable %s",
-             mp->is_en ? "enable" : "disable");
+             mp->is_enable ? "enable" : "disable");
 
   FINISH;
 }
@@ -2662,13 +2682,11 @@ static void *vl_api_lisp_add_del_remote_mapping_t_print
   s = format (s, "%s ", mp->is_add ? "add" : "del");
   s = format (s, "vni %d ", (mp->vni));
 
-  s = format (s, "eid %U ", format_lisp_flat_eid,
-             mp->eid_type, mp->eid, mp->eid_len);
+  s = format (s, "eid %U ", format_lisp_flat_eid, mp->deid);
 
   if (mp->is_src_dst)
     {
-      s = format (s, "seid %U ", format_lisp_flat_eid,
-                 mp->eid_type, mp->seid, mp->seid_len);
+      s = format (s, "seid %U ", format_lisp_flat_eid, mp->seid);
     }
   rloc_num = (mp->rloc_num);
 
@@ -2688,8 +2706,7 @@ static void *vl_api_lisp_add_del_adjacency_t_print
   s = format (s, "%s ", mp->is_add ? "add" : "del");
   s = format (s, "vni %d ", (mp->vni));
   s = format (s, "reid %U leid %U ",
-             format_lisp_flat_eid, mp->eid_type, mp->reid, mp->reid_len,
-             format_lisp_flat_eid, mp->eid_type, mp->leid, mp->leid_len);
+             format_lisp_flat_eid, mp->reid, format_lisp_flat_eid, mp->leid);
 
   FINISH;
 }
@@ -2735,14 +2752,13 @@ static void *vl_api_lisp_add_del_local_eid_t_print
     s = format (s, "del ");
 
   s = format (s, "vni %d ", (mp->vni));
-  s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid_type, mp->eid,
-             mp->prefix_len);
+  s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid);
   s = format (s, "locator-set %s ", mp->locator_set_name);
-  if (*mp->key)
+  if (mp->key.id)
     {
-      u32 key_id = mp->key_id;
+      u32 key_id = mp->key.id;
       s = format (s, "key-id %U", format_hmac_key_id, key_id);
-      s = format (s, "secret-key %s", mp->key);
+      s = format (s, "secret-key %s", mp->key.key);
     }
   FINISH;
 }
@@ -2767,10 +2783,10 @@ static void *vl_api_lisp_add_del_map_resolver_t_print
   if (!mp->is_add)
     s = format (s, "del ");
 
-  if (mp->is_ipv6)
-    s = format (s, "%U ", format_ip6_address, mp->ip_address);
+  if (mp->ip_address.af)
+    s = format (s, "%U ", format_ip6_address, mp->ip_address.un.ip6);
   else
-    s = format (s, "%U ", format_ip4_address, mp->ip_address);
+    s = format (s, "%U ", format_ip4_address, mp->ip_address.un.ip4);
 
   FINISH;
 }
@@ -2782,7 +2798,7 @@ static void *vl_api_gpe_enable_disable_t_print
 
   s = format (0, "SCRIPT: gpe_enable_disable ");
 
-  s = format (s, "%s ", mp->is_en ? "enable" : "disable");
+  s = format (s, "%s ", mp->is_enable ? "enable" : "disable");
 
   FINISH;
 }
@@ -2854,16 +2870,7 @@ static void *vl_api_lisp_map_request_mode_t_print
 
   s = format (0, "SCRIPT: lisp_map_request_mode ");
 
-  switch (mp->mode)
-    {
-    case 0:
-      s = format (s, "dst-only");
-      break;
-    case 1:
-      s = format (s, "src-dst");
-    default:
-      break;
-    }
+  s = mp->is_src_dst ? format (s, "src-dst") : format (s, "dst-only");
 
   FINISH;
 }
@@ -2878,8 +2885,7 @@ static void *vl_api_lisp_eid_table_dump_t_print
   if (mp->eid_set)
     {
       s = format (s, "vni %d ", (mp->vni));
-      s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid_type,
-                 mp->eid, mp->prefix_length);
+      s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid);
       switch (mp->filter)
        {
        case 1:
@@ -2888,6 +2894,8 @@ static void *vl_api_lisp_eid_table_dump_t_print
        case 2:
          s = format (s, "remote ");
          break;
+       default:
+         break;
        }
     }
   FINISH;
@@ -2899,7 +2907,7 @@ static void *vl_api_lisp_rloc_probe_enable_disable_t_print
   u8 *s;
 
   s = format (0, "SCRIPT: lisp_rloc_probe_enable_disable ");
-  if (mp->is_enabled)
+  if (mp->is_enable)
     s = format (s, "enable");
   else
     s = format (s, "disable");
@@ -2913,7 +2921,7 @@ static void *vl_api_lisp_map_register_enable_disable_t_print
   u8 *s;
 
   s = format (0, "SCRIPT: lisp_map_register_enable_disable ");
-  if (mp->is_enabled)
+  if (mp->is_enable)
     s = format (s, "enable");
   else
     s = format (s, "disable");
@@ -3374,13 +3382,13 @@ static void *vl_api_app_namespace_add_del_t_print
   (vl_api_app_namespace_add_del_t * mp, void *handle)
 {
   u8 *s;
-  u8 len = clib_min (mp->namespace_id_len,
-                    ARRAY_LEN (mp->namespace_id) - 1);
-  mp->namespace_id[len] = 0;
+
   s = format (0, "SCRIPT: app_namespace_add_del ");
   s = format (s, "ns-id %s secret %lu sw_if_index %d ipv4_fib_id %d "
-             "ipv6_fib_id %d", (char *) mp->namespace_id, mp->secret,
-             (mp->sw_if_index), (mp->ip4_fib_id), (mp->ip6_fib_id));
+             "ipv6_fib_id %d",
+             vl_api_from_api_to_new_c_string (&mp->namespace_id),
+             mp->secret, (mp->sw_if_index), (mp->ip4_fib_id),
+             (mp->ip6_fib_id));
   FINISH;
 }
 
@@ -3395,7 +3403,7 @@ static void *vl_api_sw_interface_set_lldp_t_print
   s = format (0, "SCRIPT: sw_interface_set_lldp ");
   s = format (s, "sw_if_index %d ", (mp->sw_if_index));
 
-  if (memcmp (mp->port_desc, null_data, sizeof (mp->port_desc)))
+  if (memcmp (&mp->port_desc, null_data, sizeof (mp->port_desc)))
     s = format (s, "port_desc %s ", mp->port_desc);
 
   if (memcmp (mp->mgmt_ip4, null_data, sizeof (mp->mgmt_ip4)))
@@ -3429,21 +3437,25 @@ static void *vl_api_session_rule_add_del_t_print
   (vl_api_session_rule_add_del_t * mp, void *handle)
 {
   u8 *s;
+  fib_prefix_t lcl, rmt;
   char *proto = mp->transport_proto == 0 ? "tcp" : "udp";
   s = format (0, "SCRIPT: session_rule_add_del ");
   mp->tag[sizeof (mp->tag) - 1] = 0;
-  if (mp->is_ip4)
+  ip_prefix_decode (&mp->lcl, &lcl);
+  ip_prefix_decode (&mp->rmt, &rmt);
+
+  if (lcl.fp_proto == FIB_PROTOCOL_IP4)
     s = format (s, "appns %d scope %d %s %U/%d %d %U/%d %d action %u tag %s",
                mp->appns_index, mp->scope, proto, format_ip4_address,
-               (ip4_address_t *) mp->lcl_ip, mp->lcl_plen,
-               format_ip4_address, (ip4_address_t *) mp->rmt_ip,
-               mp->rmt_plen, mp->action_index, mp->tag);
+               &lcl.fp_addr.ip4, lcl.fp_len,
+               format_ip4_address, &rmt.fp_addr.ip4,
+               rmt.fp_len, mp->action_index, mp->tag);
   else
     s = format (s, "appns %d scope %d %s %U/%d %d %U/%d %d action %u tag %s",
                mp->appns_index, mp->scope, proto, format_ip6_address,
-               (ip6_address_t *) mp->lcl_ip, mp->lcl_plen,
-               format_ip6_address, (ip6_address_t *) mp->rmt_ip,
-               mp->rmt_plen, mp->action_index, mp->tag);
+               &lcl.fp_addr.ip6, lcl.fp_len,
+               format_ip6_address, &rmt.fp_addr.ip6,
+               rmt.fp_len, mp->action_index, mp->tag);
   FINISH;
 }