X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvat%2Fapi_format.c;h=d8f72090ef72dd2163ade004265fea76fc82a75b;hb=refs%2Fchanges%2F94%2F8794%2F5;hp=35b46f49fb0f90dc70af749ecf6771237c6e2bd6;hpb=75d856096f644837e0da9fda011f0c419fa9414e;p=vpp.git diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 35b46f49fb0..d8f72090ef7 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -2137,6 +2137,7 @@ static void vl_api_memfd_segment_create_reply_t_handler vam->client_index_invalid = 1; + /* Note: this closes memfd.fd */ retval = memfd_slave_init (&memfd); if (retval) clib_warning ("WARNING: segment map returned %d", retval); @@ -2152,8 +2153,6 @@ static void vl_api_memfd_segment_create_reply_t_handler vl_client_connect_to_vlib_no_map ("pvt", "vpp_api_test(p)", 32 /* input_queue_length */ ); - if (close (my_fd) < 0) - clib_unix_warning ("close memfd fd pivot"); vam->vl_input_queue = am->shmem_hdr->vl_input_queue; vl_socket_client_enable_disable (&vam->socket_client_main, @@ -2210,9 +2209,39 @@ static void vl_api_dns_resolve_name_reply_t_handler static void vl_api_dns_resolve_name_reply_t_handler_json (vl_api_dns_resolve_name_reply_t * mp) { - clib_warning ("no"); + clib_warning ("not implemented"); } +static void vl_api_dns_resolve_ip_reply_t_handler + (vl_api_dns_resolve_ip_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->result_ready = 1; + + if (retval == 0) + { + clib_warning ("canonical name %s", mp->name); + } + else + clib_warning ("retval %d", retval); + } +} + +static void vl_api_dns_resolve_ip_reply_t_handler_json + (vl_api_dns_resolve_ip_reply_t * mp) +{ + clib_warning ("not implemented"); +} + + static void vl_api_ip_address_details_t_handler (vl_api_ip_address_details_t * mp) { @@ -5078,6 +5107,7 @@ _(ipsec_sad_add_del_entry_reply) \ _(ipsec_sa_set_key_reply) \ _(ipsec_tunnel_if_add_del_reply) \ _(ipsec_tunnel_if_set_key_reply) \ +_(ipsec_tunnel_if_set_sa_reply) \ _(ikev2_profile_add_del_reply) \ _(ikev2_profile_set_auth_reply) \ _(ikev2_profile_set_id_reply) \ @@ -5312,6 +5342,7 @@ _(IPSEC_SA_DETAILS, ipsec_sa_details) \ _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \ _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \ _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \ +_(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \ _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \ _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \ _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \ @@ -5462,7 +5493,8 @@ _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \ _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \ _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \ _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \ -_(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) +_(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \ +_(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) #define foreach_standalone_reply_msg \ _(SW_INTERFACE_EVENT, sw_interface_event) \ @@ -5885,7 +5917,7 @@ exec_inband (vat_main_t * vam) W (ret); /* json responses may or may not include a useful reply... */ if (vec_len (vam->cmd_reply)) - print (vam->ofp, (char *) (vam->cmd_reply)); + print (vam->ofp, "%v", (char *) (vam->cmd_reply)); return ret; } @@ -7562,9 +7594,9 @@ api_ip_add_del_route (vat_main_t * vam) u8 is_ipv6 = 0; u8 is_local = 0, is_drop = 0; u8 is_unreach = 0, is_prohibit = 0; + u8 create_vrf_if_needed = 0; u8 is_add = 1; u32 next_hop_weight = 1; - u8 not_last = 0; u8 is_multipath = 0; u8 address_set = 0; u8 address_length_set = 0; @@ -7648,8 +7680,6 @@ api_ip_add_del_route (vat_main_t * vam) is_add = 0; else if (unformat (i, "add")) is_add = 1; - else if (unformat (i, "not-last")) - not_last = 1; else if (unformat (i, "resolve-via-host")) resolve_host = 1; else if (unformat (i, "resolve-via-attached")) @@ -7658,6 +7688,8 @@ api_ip_add_del_route (vat_main_t * vam) is_multipath = 1; else if (unformat (i, "vrf %d", &vrf_id)) ; + else if (unformat (i, "create-vrf")) + create_vrf_if_needed = 1; else if (unformat (i, "count %d", &count)) ; else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id)) @@ -7744,6 +7776,7 @@ api_ip_add_del_route (vat_main_t * vam) mp->next_hop_sw_if_index = ntohl (sw_if_index); mp->table_id = ntohl (vrf_id); + mp->create_vrf_if_needed = create_vrf_if_needed; mp->is_add = is_add; mp->is_drop = is_drop; @@ -7755,7 +7788,6 @@ api_ip_add_del_route (vat_main_t * vam) mp->is_multipath = is_multipath; mp->is_resolve_host = resolve_host; mp->is_resolve_attached = resolve_attached; - mp->not_last = not_last; mp->next_hop_weight = next_hop_weight; mp->dst_address_length = dst_address_length; mp->next_hop_table_id = ntohl (next_hop_table_id); @@ -7857,6 +7889,7 @@ api_ip_mroute_add_del (vat_main_t * vam) u32 sw_if_index = ~0, vrf_id = 0; u8 is_ipv6 = 0; u8 is_local = 0; + u8 create_vrf_if_needed = 0; u8 is_add = 1; u8 address_set = 0; u32 grp_address_length = 0; @@ -7913,6 +7946,8 @@ api_ip_mroute_add_del (vat_main_t * vam) is_add = 1; else if (unformat (i, "vrf %d", &vrf_id)) ; + else if (unformat (i, "create-vrf")) + create_vrf_if_needed = 1; else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags)) ; else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags)) @@ -7935,6 +7970,7 @@ api_ip_mroute_add_del (vat_main_t * vam) mp->next_hop_sw_if_index = ntohl (sw_if_index); mp->table_id = ntohl (vrf_id); + mp->create_vrf_if_needed = create_vrf_if_needed; mp->is_add = is_add; mp->is_ipv6 = is_ipv6; @@ -7975,12 +8011,12 @@ api_mpls_table_add_del (vat_main_t * vam) /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { - if (unformat (i, "del")) + if (unformat (i, "table %d", &table_id)) + ; + else if (unformat (i, "del")) is_add = 0; else if (unformat (i, "add")) is_add = 1; - else if (unformat (i, "table-id %d", &table_id)) - ; else { clib_warning ("parse error '%U'", format_unformat_error, i); @@ -8015,6 +8051,7 @@ api_mpls_route_add_del (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_mpls_route_add_del_t *mp; u32 sw_if_index = ~0, table_id = 0; + u8 create_table_if_needed = 0; u8 is_add = 1; u32 next_hop_weight = 1; u8 is_multipath = 0; @@ -8064,6 +8101,8 @@ api_mpls_route_add_del (vat_main_t * vam) } else if (unformat (i, "weight %d", &next_hop_weight)) ; + else if (unformat (i, "create-table")) + create_table_if_needed = 1; else if (unformat (i, "classify %d", &classify_table_index)) { is_classify = 1; @@ -8131,6 +8170,7 @@ api_mpls_route_add_del (vat_main_t * vam) mp->mr_next_hop_sw_if_index = ntohl (sw_if_index); mp->mr_table_id = ntohl (table_id); + mp->mr_create_table_if_needed = create_table_if_needed; mp->mr_is_add = is_add; mp->mr_next_hop_proto = next_hop_proto; @@ -8236,6 +8276,7 @@ api_mpls_ip_bind_unbind (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_mpls_ip_bind_unbind_t *mp; u32 ip_table_id = 0; + u8 create_table_if_needed = 0; u8 is_bind = 1; u8 is_ip4 = 1; ip4_address_t v4_address; @@ -8262,6 +8303,8 @@ api_mpls_ip_bind_unbind (vat_main_t * vam) } else if (unformat (i, "%d", &local_label)) ; + else if (unformat (i, "create-table")) + create_table_if_needed = 1; else if (unformat (i, "table-id %d", &ip_table_id)) ; else if (unformat (i, "unbind")) @@ -8290,6 +8333,7 @@ api_mpls_ip_bind_unbind (vat_main_t * vam) /* Construct the API message */ M (MPLS_IP_BIND_UNBIND, mp); + mp->mb_create_table_if_needed = create_table_if_needed; mp->mb_is_bind = is_bind; mp->mb_is_ip4 = is_ip4; mp->mb_ip_table_id = ntohl (ip_table_id); @@ -14359,6 +14403,57 @@ api_ipsec_tunnel_if_set_key (vat_main_t * vam) return ret; } +static int +api_ipsec_tunnel_if_set_sa (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ipsec_tunnel_if_set_sa_t *mp; + u32 sw_if_index = ~0; + u32 sa_id = ~0; + u8 is_outbound = (u8) ~ 0; + int ret; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (i, "sa_id %d", &sa_id)) + ; + else if (unformat (i, "outbound")) + is_outbound = 1; + else if (unformat (i, "inbound")) + is_outbound = 0; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index == ~0) + { + errmsg ("interface must be specified"); + return -99; + } + + if (sa_id == ~0) + { + errmsg ("SA ID must be specified"); + return -99; + } + + M (IPSEC_TUNNEL_IF_SET_SA, mp); + + mp->sw_if_index = htonl (sw_if_index); + mp->sa_id = htonl (sa_id); + mp->is_outbound = is_outbound; + + S (mp); + W (ret); + + return ret; +} + static int api_ikev2_profile_add_del (vat_main_t * vam) { @@ -20902,16 +20997,12 @@ api_app_namespace_add_del (vat_main_t * vam) static int api_memfd_segment_create (vat_main_t * vam) { +#if VPP_API_TEST_BUILTIN == 0 unformat_input_t *i = vam->input; vl_api_memfd_segment_create_t *mp; u64 size = 64 << 20; int ret; -#if VPP_API_TEST_BUILTIN == 1 - errmsg ("memfd_segment_create (builtin) not supported"); - return -99; -#endif - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { if (unformat (i, "size %U", unformat_memory_size, &size)) @@ -20925,6 +21016,11 @@ api_memfd_segment_create (vat_main_t * vam) S (mp); W (ret); return ret; + +#else + errmsg ("memfd_segment_create (builtin) not supported"); + return -99; +#endif } static int @@ -20990,6 +21086,47 @@ api_dns_resolve_name (vat_main_t * vam) return ret; } +static int +api_dns_resolve_ip (vat_main_t * vam) +{ + unformat_input_t *line_input = vam->input; + vl_api_dns_resolve_ip_t *mp; + int is_ip6 = -1; + ip4_address_t addr4; + ip6_address_t addr6; + int ret; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "%U", unformat_ip6_address, &addr6)) + is_ip6 = 1; + else if (unformat (line_input, "%U", unformat_ip4_address, &addr4)) + is_ip6 = 0; + else + break; + } + + if (is_ip6 == -1) + { + errmsg ("missing address"); + return -99; + } + + /* Construct the API message */ + M (DNS_RESOLVE_IP, mp); + mp->is_ip6 = is_ip6; + if (is_ip6) + memcpy (mp->address, &addr6, sizeof (addr6)); + else + memcpy (mp->address, &addr4, sizeof (addr4)); + + /* send it... */ + S (mp); + /* Wait for the reply */ + W (ret); + return ret; +} + static int api_dns_name_server_add_del (vat_main_t * vam) { @@ -21624,6 +21761,7 @@ _(ipsec_tunnel_if_add_del, "local_spi remote_spi \n" \ _(ipsec_sa_dump, "[sa_id ]") \ _(ipsec_tunnel_if_set_key, " \n" \ " \n") \ +_(ipsec_tunnel_if_set_sa, " sa_id \n") \ _(ikev2_profile_add_del, "name [del]") \ _(ikev2_profile_set_auth, "name auth_method \n" \ "(auth_data 0x | auth_data )") \ @@ -21848,7 +21986,8 @@ _(memfd_segment_create,"size ") \ _(app_namespace_add_del, "[add] id secret sw_if_index ")\ _(dns_enable_disable, "[enable][disable]") \ _(dns_name_server_add_del, " [del]") \ -_(dns_resolve_name, "") +_(dns_resolve_name, "") \ +_(dns_resolve_ip, "") /* List of command functions, CLI names map directly to functions */ #define foreach_cli_function \