X-Git-Url: https://gerrit.fd.io/r/gitweb?p=vpp.git;a=blobdiff_plain;f=src%2Fvat%2Fapi_format.c;h=009a0a47301e9bfb520d3eddfca60c93bb98abf5;hp=da64a8151fd6a01febb58e48daa4aeecfa9a96d8;hb=7c0eb56f4;hpb=00ec4019b399132a72467ed4c3fb039d4f2466b7 diff --git a/src/vat/api_format.c b/src/vat/api_format.c index da64a8151fd..009a0a47301 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -264,6 +264,26 @@ unformat_ethernet_type_host_byte_order (unformat_input_t * input, return 0; } +/* Parse an IP46 address. */ +uword +unformat_ip46_address (unformat_input_t * input, va_list * args) +{ + ip46_address_t *ip46 = va_arg (*args, ip46_address_t *); + ip46_type_t type = va_arg (*args, ip46_type_t); + if ((type != IP46_TYPE_IP6) && + unformat (input, "%U", unformat_ip4_address, &ip46->ip4)) + { + ip46_address_mask_ip4 (ip46); + return 1; + } + else if ((type != IP46_TYPE_IP4) && + unformat (input, "%U", unformat_ip6_address, &ip46->ip6)) + { + return 1; + } + return 0; +} + /* Parse an IP6 address. */ uword unformat_ip6_address (unformat_input_t * input, va_list * args) @@ -759,6 +779,16 @@ set_ip4_address (vl_api_address_t * a, u32 v) } } +void +ip_set (ip46_address_t * dst, void *src, u8 is_ip4) +{ + if (is_ip4) + dst->ip4.as_u32 = ((ip4_address_t *) src)->as_u32; + else + clib_memcpy_fast (&dst->ip6, (ip6_address_t *) src, + sizeof (ip6_address_t)); +} + static void increment_mac_address (u8 * mac) { @@ -4525,18 +4555,18 @@ vl_api_policer_details_t_handler (vl_api_policer_details_t * mp) vat_main_t *vam = &vat_main; u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str; - if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) - conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp); + if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT) + conform_dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp); else conform_dscp_str = format (0, ""); - if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) - exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp); + if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT) + exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp); else exceed_dscp_str = format (0, ""); - if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) - violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp); + if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT) + violate_dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp); else violate_dscp_str = format (0, ""); @@ -4563,11 +4593,11 @@ vl_api_policer_details_t_handler (vl_api_policer_details_t * mp) ntohl (mp->extended_limit), ntohl (mp->extended_bucket), clib_net_to_host_u64 (mp->last_update_time), - format_policer_action_type, mp->conform_action_type, + format_policer_action_type, mp->conform_action.type, conform_dscp_str, - format_policer_action_type, mp->exceed_action_type, + format_policer_action_type, mp->exceed_action.type, exceed_dscp_str, - format_policer_action_type, mp->violate_action_type, + format_policer_action_type, mp->violate_action.type, violate_dscp_str); vec_free (conform_dscp_str); @@ -4588,11 +4618,11 @@ static void vl_api_policer_details_t_handler_json format (0, "%U", format_policer_round_type, mp->round_type); type_str = format (0, "%U", format_policer_type, mp->type); conform_action_str = format (0, "%U", format_policer_action_type, - mp->conform_action_type); + mp->conform_action.type); exceed_action_str = format (0, "%U", format_policer_action_type, - mp->exceed_action_type); + mp->exceed_action.type); violate_action_str = format (0, "%U", format_policer_action_type, - mp->violate_action_type); + mp->violate_action.type); if (VAT_JSON_ARRAY != vam->json_tree.type) { @@ -4628,24 +4658,24 @@ static void vl_api_policer_details_t_handler_json ntohl (mp->last_update_time)); vat_json_object_add_string_copy (node, "conform_action", conform_action_str); - if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) + if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT) { - u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp); + u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp); vat_json_object_add_string_copy (node, "conform_dscp", dscp_str); vec_free (dscp_str); } vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str); - if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) + if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT) { - u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp); + u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp); vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str); vec_free (dscp_str); } vat_json_object_add_string_copy (node, "violate_action", violate_action_str); - if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) + if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT) { - u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp); + u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp); vat_json_object_add_string_copy (node, "violate_dscp", dscp_str); vec_free (dscp_str); } @@ -7341,6 +7371,10 @@ api_tap_create_v2 (vat_main_t * vam) tap_flags |= TAP_FLAG_GSO; else if (unformat (i, "csum-offload")) tap_flags |= TAP_FLAG_CSUM_OFFLOAD; + else if (unformat (i, "persist")) + tap_flags |= TAP_FLAG_PERSIST; + else if (unformat (i, "attach")) + tap_flags |= TAP_FLAG_ATTACH; else break; } @@ -11699,14 +11733,16 @@ api_vxlan_add_del_tunnel (vat_main_t * vam) if (ipv6_set) { - clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6)); - clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6)); + clib_memcpy (mp->src_address.un.ip6, &src.ip6, sizeof (src.ip6)); + clib_memcpy (mp->dst_address.un.ip6, &dst.ip6, sizeof (dst.ip6)); } else { - clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4)); - clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4)); + clib_memcpy (mp->src_address.un.ip4, &src.ip4, sizeof (src.ip4)); + clib_memcpy (mp->dst_address.un.ip4, &dst.ip4, sizeof (dst.ip4)); } + mp->src_address.af = ipv6_set; + mp->dst_address.af = ipv6_set; mp->instance = htonl (instance); mp->encap_vrf_id = ntohl (encap_vrf_id); @@ -11714,7 +11750,6 @@ api_vxlan_add_del_tunnel (vat_main_t * vam) mp->mcast_sw_if_index = ntohl (mcast_sw_if_index); mp->vni = ntohl (vni); mp->is_add = is_add; - mp->is_ipv6 = ipv6_set; S (mp); W (ret); @@ -11725,8 +11760,10 @@ static void vl_api_vxlan_tunnel_details_t_handler (vl_api_vxlan_tunnel_details_t * mp) { vat_main_t *vam = &vat_main; - ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address); - ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address); + ip46_address_t src = + to_ip46 (mp->dst_address.af, (u8 *) & mp->dst_address.un); + ip46_address_t dst = + to_ip46 (mp->dst_address.af, (u8 *) & mp->src_address.un); print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d", ntohl (mp->sw_if_index), @@ -11756,29 +11793,28 @@ static void vl_api_vxlan_tunnel_details_t_handler_json vat_json_object_add_uint (node, "instance", ntohl (mp->instance)); - if (mp->is_ipv6) + if (mp->src_address.af) { struct in6_addr ip6; - clib_memcpy (&ip6, mp->src_address, sizeof (ip6)); + clib_memcpy (&ip6, mp->src_address.un.ip6, sizeof (ip6)); vat_json_object_add_ip6 (node, "src_address", ip6); - clib_memcpy (&ip6, mp->dst_address, sizeof (ip6)); + clib_memcpy (&ip6, mp->dst_address.un.ip6, sizeof (ip6)); vat_json_object_add_ip6 (node, "dst_address", ip6); } else { struct in_addr ip4; - clib_memcpy (&ip4, mp->src_address, sizeof (ip4)); + clib_memcpy (&ip4, mp->src_address.un.ip4, sizeof (ip4)); vat_json_object_add_ip4 (node, "src_address", ip4); - clib_memcpy (&ip4, mp->dst_address, sizeof (ip4)); + clib_memcpy (&ip4, mp->dst_address.un.ip4, sizeof (ip4)); vat_json_object_add_ip4 (node, "dst_address", ip4); } vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id)); vat_json_object_add_uint (node, "decap_next_index", ntohl (mp->decap_next_index)); vat_json_object_add_uint (node, "vni", ntohl (mp->vni)); - vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0); vat_json_object_add_uint (node, "mcast_sw_if_index", ntohl (mp->mcast_sw_if_index)); } @@ -12676,10 +12712,8 @@ api_vxlan_gpe_add_del_tunnel (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_vxlan_gpe_add_del_tunnel_t *mp; - ip4_address_t local4, remote4; - ip6_address_t local6, remote6; + ip46_address_t local, remote; u8 is_add = 1; - u8 ipv4_set = 0, ipv6_set = 0; u8 local_set = 0; u8 remote_set = 0; u8 grp_set = 0; @@ -12691,65 +12725,30 @@ api_vxlan_gpe_add_del_tunnel (vat_main_t * vam) u8 vni_set = 0; int ret; - /* Can't "universally zero init" (={0}) due to GCC bug 53119 */ - clib_memset (&local4, 0, sizeof local4); - clib_memset (&remote4, 0, sizeof remote4); - clib_memset (&local6, 0, sizeof local6); - clib_memset (&remote6, 0, sizeof remote6); - while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { if (unformat (line_input, "del")) is_add = 0; else if (unformat (line_input, "local %U", - unformat_ip4_address, &local4)) - { - local_set = 1; - ipv4_set = 1; - } - else if (unformat (line_input, "remote %U", - unformat_ip4_address, &remote4)) - { - remote_set = 1; - ipv4_set = 1; - } - else if (unformat (line_input, "local %U", - unformat_ip6_address, &local6)) + unformat_ip46_address, &local)) { local_set = 1; - ipv6_set = 1; } else if (unformat (line_input, "remote %U", - unformat_ip6_address, &remote6)) + unformat_ip46_address, &remote)) { remote_set = 1; - ipv6_set = 1; - } - else if (unformat (line_input, "group %U %U", - unformat_ip4_address, &remote4, - api_unformat_sw_if_index, vam, &mcast_sw_if_index)) - { - grp_set = remote_set = 1; - ipv4_set = 1; - } - else if (unformat (line_input, "group %U", - unformat_ip4_address, &remote4)) - { - grp_set = remote_set = 1; - ipv4_set = 1; } else if (unformat (line_input, "group %U %U", - unformat_ip6_address, &remote6, + unformat_ip46_address, &remote, api_unformat_sw_if_index, vam, &mcast_sw_if_index)) { grp_set = remote_set = 1; - ipv6_set = 1; } else if (unformat (line_input, "group %U", - unformat_ip6_address, &remote6)) + unformat_ip46_address, &remote)) { grp_set = remote_set = 1; - ipv6_set = 1; } else if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index)) @@ -12790,7 +12789,7 @@ api_vxlan_gpe_add_del_tunnel (vat_main_t * vam) errmsg ("tunnel nonexistent multicast device"); return -99; } - if (ipv4_set && ipv6_set) + if (ip46_address_is_ip4 (&local) != ip46_address_is_ip4 (&remote)) { errmsg ("both IPv4 and IPv6 addresses specified"); return -99; @@ -12804,17 +12803,12 @@ api_vxlan_gpe_add_del_tunnel (vat_main_t * vam) M (VXLAN_GPE_ADD_DEL_TUNNEL, mp); - - if (ipv6_set) - { - clib_memcpy (&mp->local, &local6, sizeof (local6)); - clib_memcpy (&mp->remote, &remote6, sizeof (remote6)); - } - else - { - clib_memcpy (&mp->local, &local4, sizeof (local4)); - clib_memcpy (&mp->remote, &remote4, sizeof (remote4)); - } + ip_address_encode (&local, + ip46_address_is_ip4 (&local) ? IP46_TYPE_IP4 : + IP46_TYPE_IP6, &mp->local); + ip_address_encode (&remote, + ip46_address_is_ip4 (&remote) ? IP46_TYPE_IP4 : + IP46_TYPE_IP6, &mp->remote); mp->mcast_sw_if_index = ntohl (mcast_sw_if_index); mp->encap_vrf_id = ntohl (encap_vrf_id); @@ -12822,7 +12816,6 @@ api_vxlan_gpe_add_del_tunnel (vat_main_t * vam) mp->protocol = protocol; mp->vni = ntohl (vni); mp->is_add = is_add; - mp->is_ipv6 = ipv6_set; S (mp); W (ret); @@ -12833,8 +12826,10 @@ static void vl_api_vxlan_gpe_tunnel_details_t_handler (vl_api_vxlan_gpe_tunnel_details_t * mp) { vat_main_t *vam = &vat_main; - 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); print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d", ntohl (mp->sw_if_index), @@ -12853,6 +12848,10 @@ static void vl_api_vxlan_gpe_tunnel_details_t_handler_json vat_json_node_t *node = NULL; struct in_addr ip4; struct in6_addr ip6; + ip46_address_t local, remote; + + ip_address_decode (&mp->local, &local); + ip_address_decode (&mp->remote, &remote); if (VAT_JSON_ARRAY != vam->json_tree.type) { @@ -12863,19 +12862,19 @@ static void vl_api_vxlan_gpe_tunnel_details_t_handler_json vat_json_init_object (node); vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); - if (mp->is_ipv6) + if (ip46_address_is_ip4 (&local)) { - clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6)); - vat_json_object_add_ip6 (node, "local", ip6); - clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6)); - vat_json_object_add_ip6 (node, "remote", ip6); + clib_memcpy (&ip4, &local.ip4, sizeof (ip4)); + vat_json_object_add_ip4 (node, "local", ip4); + clib_memcpy (&ip4, &remote.ip4, sizeof (ip4)); + vat_json_object_add_ip4 (node, "remote", ip4); } else { - clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4)); - vat_json_object_add_ip4 (node, "local", ip4); - clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4)); - vat_json_object_add_ip4 (node, "remote", ip4); + clib_memcpy (&ip6, &local.ip6, sizeof (ip6)); + vat_json_object_add_ip6 (node, "local", ip6); + clib_memcpy (&ip6, &remote.ip6, sizeof (ip6)); + vat_json_object_add_ip6 (node, "remote", ip6); } vat_json_object_add_uint (node, "vni", ntohl (mp->vni)); vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol)); @@ -17385,12 +17384,12 @@ api_policer_add_del (vat_main_t * vam) mp->rate_type = rate_type; mp->round_type = round_type; mp->type = type; - mp->conform_action_type = conform_action.action_type; - mp->conform_dscp = conform_action.dscp; - mp->exceed_action_type = exceed_action.action_type; - mp->exceed_dscp = exceed_action.dscp; - mp->violate_action_type = violate_action.action_type; - mp->violate_dscp = violate_action.dscp; + mp->conform_action.type = conform_action.action_type; + mp->conform_action.dscp = conform_action.dscp; + mp->exceed_action.type = exceed_action.action_type; + mp->exceed_action.dscp = exceed_action.dscp; + mp->violate_action.type = violate_action.action_type; + mp->violate_action.dscp = violate_action.dscp; mp->color_aware = color_aware; S (mp); @@ -18593,17 +18592,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 +18638,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); @@ -19520,7 +19515,7 @@ api_lldp_config (vat_main_t * vam) M (LLDP_CONFIG, mp); mp->tx_hold = htonl (tx_hold); mp->tx_interval = htonl (tx_interval); - clib_memcpy (mp->system_name, sys_name, vec_len (sys_name)); + vl_api_vec_to_api_string (sys_name, &mp->system_name); vec_free (sys_name); S (mp); @@ -19576,7 +19571,7 @@ api_sw_interface_set_lldp (vat_main_t * vam) M (SW_INTERFACE_SET_LLDP, mp); mp->sw_if_index = ntohl (sw_if_index); mp->enable = enable; - clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc)); + vl_api_vec_to_api_string (port_desc, &mp->port_desc); clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid)); clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr)); clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr)); @@ -19706,8 +19701,7 @@ api_app_namespace_add_del (vat_main_t * vam) } M (APP_NAMESPACE_ADD_DEL, mp); - clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id)); - mp->namespace_id_len = vec_len (ns_id); + vl_api_vec_to_api_string (ns_id, &mp->namespace_id); mp->secret = clib_host_to_net_u64 (secret); mp->sw_if_index = clib_host_to_net_u32 (sw_if_index); mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id); @@ -19781,15 +19775,20 @@ static void vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp) { vat_main_t *vam = &vat_main; + fib_prefix_t lcl, rmt; - if (mp->is_ip4) + ip_prefix_decode (&mp->lcl, &lcl); + ip_prefix_decode (&mp->rmt, &rmt); + + if (lcl.fp_proto == FIB_PROTOCOL_IP4) { print (vam->ofp, "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s", clib_net_to_host_u32 (mp->appns_index), mp->transport_proto, - mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen, + mp->scope, format_ip4_address, &lcl.fp_addr.ip4, lcl.fp_len, clib_net_to_host_u16 (mp->lcl_port), format_ip4_address, - &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port), + &rmt.fp_addr.ip4, rmt.fp_len, + clib_net_to_host_u16 (mp->rmt_port), clib_net_to_host_u32 (mp->action_index), mp->tag); } else @@ -19797,9 +19796,10 @@ vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp) print (vam->ofp, "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s", clib_net_to_host_u32 (mp->appns_index), mp->transport_proto, - mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen, + mp->scope, format_ip6_address, &lcl.fp_addr.ip6, lcl.fp_len, clib_net_to_host_u16 (mp->lcl_port), format_ip6_address, - &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port), + &rmt.fp_addr.ip6, rmt.fp_len, + clib_net_to_host_u16 (mp->rmt_port), clib_net_to_host_u32 (mp->action_index), mp->tag); } } @@ -19813,6 +19813,11 @@ vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t * struct in6_addr ip6; struct in_addr ip4; + fib_prefix_t lcl, rmt; + + ip_prefix_decode (&mp->lcl, &lcl); + ip_prefix_decode (&mp->rmt, &rmt); + if (VAT_JSON_ARRAY != vam->json_tree.type) { ASSERT (VAT_JSON_NONE == vam->json_tree.type); @@ -19821,7 +19826,6 @@ vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t * node = vat_json_array_add (&vam->json_tree); vat_json_init_object (node); - vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0); vat_json_object_add_uint (node, "appns_index", clib_net_to_host_u32 (mp->appns_index)); vat_json_object_add_uint (node, "transport_proto", mp->transport_proto); @@ -19832,21 +19836,21 @@ vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t * clib_net_to_host_u16 (mp->lcl_port)); vat_json_object_add_uint (node, "rmt_port", clib_net_to_host_u16 (mp->rmt_port)); - vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen); - vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen); + vat_json_object_add_uint (node, "lcl_plen", lcl.fp_len); + vat_json_object_add_uint (node, "rmt_plen", rmt.fp_len); vat_json_object_add_string_copy (node, "tag", mp->tag); - if (mp->is_ip4) + if (lcl.fp_proto == FIB_PROTOCOL_IP4) { - clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4)); + clib_memcpy (&ip4, &lcl.fp_addr.ip4, sizeof (ip4)); vat_json_object_add_ip4 (node, "lcl_ip", ip4); - clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4)); + clib_memcpy (&ip4, &rmt.fp_addr.ip4, sizeof (ip4)); vat_json_object_add_ip4 (node, "rmt_ip", ip4); } else { - clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6)); + clib_memcpy (&ip6, &lcl.fp_addr.ip6, sizeof (ip6)); vat_json_object_add_ip6 (node, "lcl_ip", ip6); - clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6)); + clib_memcpy (&ip6, &rmt.fp_addr.ip6, sizeof (ip6)); vat_json_object_add_ip6 (node, "rmt_ip", ip6); } } @@ -19863,6 +19867,7 @@ api_session_rule_add_del (vat_main_t * vam) u8 is_ip4 = 1, conn_set = 0; u8 is_add = 1, *tag = 0; int ret; + fib_prefix_t lcl, rmt; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -19917,26 +19922,34 @@ api_session_rule_add_del (vat_main_t * vam) M (SESSION_RULE_ADD_DEL, mp); - mp->is_ip4 = is_ip4; - mp->transport_proto = proto; - mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port); - mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port); - mp->lcl_plen = lcl_plen; - mp->rmt_plen = rmt_plen; - mp->action_index = clib_host_to_net_u32 (action); - mp->appns_index = clib_host_to_net_u32 (appns_index); - mp->scope = scope; - mp->is_add = is_add; + clib_memset (&lcl, 0, sizeof (lcl)); + clib_memset (&rmt, 0, sizeof (rmt)); if (is_ip4) { - clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4)); - clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4)); + ip_set (&lcl.fp_addr, &lcl_ip4, 1); + ip_set (&rmt.fp_addr, &rmt_ip4, 1); + lcl.fp_len = lcl_plen; + rmt.fp_len = rmt_plen; } else { - clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6)); - clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6)); + ip_set (&lcl.fp_addr, &lcl_ip6, 0); + ip_set (&rmt.fp_addr, &rmt_ip6, 0); + lcl.fp_len = lcl_plen; + rmt.fp_len = rmt_plen; } + + + ip_prefix_encode (&lcl, &mp->lcl); + ip_prefix_encode (&rmt, &mp->rmt); + mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port); + mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port); + mp->transport_proto = + proto ? TRANSPORT_PROTO_API_UDP : TRANSPORT_PROTO_API_TCP; + mp->action_index = clib_host_to_net_u32 (action); + mp->appns_index = clib_host_to_net_u32 (appns_index); + mp->scope = scope; + mp->is_add = is_add; if (tag) { clib_memcpy (mp->tag, tag, vec_len (tag)); @@ -20637,7 +20650,7 @@ _(l2_flags, \ _(bridge_flags, \ "bd_id [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \ _(tap_create_v2, \ - "id [hw-addr ] [host-if-name ] [host-ns ] [num-rx-queues ] [rx-ring-size ] [tx-ring-size ] [host-bridge ] [host-mac-addr ] [host-ip4-addr ] [host-ip6-addr ] [host-mtu-size ] [gso | no-gso | csum-offload]") \ + "id [hw-addr ] [host-if-name ] [host-ns ] [num-rx-queues ] [rx-ring-size ] [tx-ring-size ] [host-bridge ] [host-mac-addr ] [host-ip4-addr ] [host-ip6-addr ] [host-mtu-size ] [gso | no-gso | csum-offload] [persist] [attach]") \ _(tap_delete_v2, \ " | sw_if_index ") \ _(sw_interface_tap_v2_dump, "") \