diff options
Diffstat (limited to 'src/vat/api_format.c')
-rw-r--r-- | src/vat/api_format.c | 5028 |
1 files changed, 0 insertions, 5028 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 926f65dcd86..d24a406ce01 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -30,7 +30,6 @@ #include <vnet/vxlan/vxlan.h> #include <vnet/gre/gre.h> #include <vnet/vxlan-gpe/vxlan_gpe.h> -#include <vnet/lisp-gpe/lisp_gpe.h> #include <vpp/api/vpe_msg_enum.h> #include <vnet/l2/l2_classify.h> @@ -2295,131 +2294,6 @@ static void vl_api_mpls_tunnel_add_del_reply_t_handler_json vam->result_ready = 1; } -static void vl_api_gpe_add_del_fwd_entry_reply_t_handler - (vl_api_gpe_add_del_fwd_entry_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; - } -} - -static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json - (vl_api_gpe_add_del_fwd_entry_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - - vat_json_init_object (&node); - vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); - vat_json_object_add_uint (&node, "fwd_entry_index", - clib_net_to_host_u32 (mp->fwd_entry_index)); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -u8 * -format_lisp_transport_protocol (u8 * s, va_list * args) -{ - u32 proto = va_arg (*args, u32); - - switch (proto) - { - case 1: - return format (s, "udp"); - case 2: - return format (s, "api"); - default: - return 0; - } - return 0; -} - -static void vl_api_one_get_transport_protocol_reply_t_handler - (vl_api_one_get_transport_protocol_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - if (vam->async_mode) - { - vam->async_errors += (retval < 0); - } - else - { - u32 proto = mp->protocol; - print (vam->ofp, "Transport protocol: %U", - format_lisp_transport_protocol, proto); - vam->retval = retval; - vam->result_ready = 1; - } -} - -static void vl_api_one_get_transport_protocol_reply_t_handler_json - (vl_api_one_get_transport_protocol_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - u8 *s; - - s = format (0, "%U", format_lisp_transport_protocol, mp->protocol); - vec_add1 (s, 0); - - vat_json_init_object (&node); - vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); - vat_json_object_add_string_copy (&node, "transport-protocol", s); - - vec_free (s); - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void vl_api_one_add_del_locator_set_reply_t_handler - (vl_api_one_add_del_locator_set_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; - } -} - -static void vl_api_one_add_del_locator_set_reply_t_handler_json - (vl_api_one_add_del_locator_set_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - - vat_json_init_object (&node); - vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); - vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index)); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - static void vl_api_vxlan_add_del_tunnel_reply_t_handler (vl_api_vxlan_add_del_tunnel_reply_t * mp) { @@ -2802,1676 +2676,6 @@ static void vl_api_get_node_graph_reply_t_handler_json vam->result_ready = 1; } -static void -vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp) -{ - vat_main_t *vam = &vat_main; - u8 *s = 0; - - if (mp->local) - { - s = format (s, "%=16d%=16d%=16d", - ntohl (mp->sw_if_index), mp->priority, mp->weight); - } - else - { - s = format (s, "%=16U%=16d%=16d", - format_ip46_address, - mp->ip_address, mp->priority, mp->weight); - } - - print (vam->ofp, "%v", s); - vec_free (s); -} - -static void -vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = NULL; - struct in6_addr ip6; - struct in_addr ip4; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - vat_json_init_object (node); - - vat_json_object_add_uint (node, "local", mp->local ? 1 : 0); - vat_json_object_add_uint (node, "priority", mp->priority); - vat_json_object_add_uint (node, "weight", mp->weight); - - if (mp->local) - vat_json_object_add_uint (node, "sw_if_index", - clib_net_to_host_u32 (mp->sw_if_index)); - else - { - if (mp->ip_address.af) - { - clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6)); - vat_json_object_add_ip6 (node, "address", ip6); - } - else - { - clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4)); - vat_json_object_add_ip4 (node, "address", ip4); - } - } -} - -static void -vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t * - mp) -{ - vat_main_t *vam = &vat_main; - u8 *ls_name = 0; - - ls_name = format (0, "%s", mp->ls_name); - - print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index), - ls_name); - vec_free (ls_name); -} - -static void - vl_api_one_locator_set_details_t_handler_json - (vl_api_one_locator_set_details_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = 0; - u8 *ls_name = 0; - - ls_name = format (0, "%s", mp->ls_name); - vec_add1 (ls_name, 0); - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - - vat_json_init_object (node); - vat_json_object_add_string_copy (node, "ls_name", ls_name); - vat_json_object_add_uint (node, "ls_index", - clib_net_to_host_u32 (mp->ls_index)); - vec_free (ls_name); -} - -typedef struct -{ - u32 spi; - u8 si; -} __attribute__ ((__packed__)) lisp_nsh_api_t; - -uword -unformat_nsh_address (unformat_input_t * input, va_list * args) -{ - lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *); - return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si); -} - -static u8 * -format_nsh_address_vat (u8 * s, va_list * args) -{ - nsh_t *a = va_arg (*args, nsh_t *); - return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si); -} - -static u8 * -format_lisp_flat_eid (u8 * s, va_list * args) -{ - vl_api_eid_t *eid = va_arg (*args, vl_api_eid_t *); - - switch (eid->type) - { - case EID_TYPE_API_PREFIX: - if (eid->address.prefix.address.af) - return format (s, "%U/%d", format_ip6_address, - eid->address.prefix.address.un.ip6, - eid->address.prefix.len); - return format (s, "%U/%d", format_ip4_address, - eid->address.prefix.address.un.ip4, - eid->address.prefix.len); - case EID_TYPE_API_MAC: - return format (s, "%U", format_ethernet_address, eid->address.mac); - case EID_TYPE_API_NSH: - return format (s, "%U", format_nsh_address_vat, eid->address.nsh); - } - return 0; -} - -static u8 * -format_lisp_eid_vat (u8 * s, va_list * args) -{ - vl_api_eid_t *deid = va_arg (*args, vl_api_eid_t *); - vl_api_eid_t *seid = va_arg (*args, vl_api_eid_t *); - u8 is_src_dst = (u8) va_arg (*args, int); - - if (is_src_dst) - s = format (s, "%U|", format_lisp_flat_eid, seid); - - s = format (s, "%U", format_lisp_flat_eid, deid); - - return s; -} - -static void -vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp) -{ - vat_main_t *vam = &vat_main; - u8 *s = 0, *eid = 0; - - if (~0 == mp->locator_set_index) - s = format (0, "action: %d", mp->action); - else - s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index)); - - eid = format (0, "%U", format_lisp_eid_vat, - &mp->deid, &mp->seid, mp->is_src_dst); - vec_add1 (eid, 0); - - print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s", - clib_net_to_host_u32 (mp->vni), - eid, - mp->is_local ? "local" : "remote", - s, clib_net_to_host_u32 (mp->ttl), mp->authoritative, - clib_net_to_host_u16 (mp->key.id), mp->key.key); - - vec_free (s); - vec_free (eid); -} - -static void -vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t - * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = 0; - u8 *eid = 0; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - - vat_json_init_object (node); - if (~0 == mp->locator_set_index) - vat_json_object_add_uint (node, "action", mp->action); - else - vat_json_object_add_uint (node, "locator_set_index", - clib_net_to_host_u32 (mp->locator_set_index)); - - vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0); - if (mp->deid.type == 3) - { - vat_json_node_t *nsh_json = vat_json_object_add (node, "eid"); - vat_json_init_object (nsh_json); - lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) & mp->deid.address.nsh; - vat_json_object_add_uint (nsh_json, "spi", - clib_net_to_host_u32 (nsh->spi)); - vat_json_object_add_uint (nsh_json, "si", nsh->si); - } - else - { - eid = format (0, "%U", format_lisp_eid_vat, - &mp->deid, &mp->seid, mp->is_src_dst); - vec_add1 (eid, 0); - vat_json_object_add_string_copy (node, "eid", eid); - vec_free (eid); - } - vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni)); - vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl)); - vat_json_object_add_uint (node, "authoritative", (mp->authoritative)); - - if (mp->key.id) - { - vat_json_object_add_uint (node, "key_id", - clib_net_to_host_u16 (mp->key.id)); - vat_json_object_add_string_copy (node, "key", mp->key.key); - } -} - -static void -vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp) -{ - vat_main_t *vam = &vat_main; - u8 *seid = 0, *deid = 0; - ip46_address_t lloc, rloc; - - deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0); - - seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0); - - vec_add1 (deid, 0); - vec_add1 (seid, 0); - - if (mp->lloc.af) - { - clib_memcpy (&lloc.ip6, mp->lloc.un.ip6, 16); - clib_memcpy (&rloc.ip6, mp->rloc.un.ip6, 16); - } - else - { - clib_memcpy (&lloc.ip4, mp->lloc.un.ip4, 4); - clib_memcpy (&rloc.ip4, mp->rloc.un.ip4, 4); - } - - - print (vam->ofp, "([%d] %s %s) (%U %U) %u %u", - clib_net_to_host_u32 (mp->vni), - seid, deid, - format_ip46_address, lloc, - format_ip46_address, rloc, - clib_net_to_host_u32 (mp->pkt_count), - clib_net_to_host_u32 (mp->bytes)); - - vec_free (deid); - vec_free (seid); -} - -static void -vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp) -{ - struct in6_addr ip6; - struct in_addr ip4; - vat_main_t *vam = &vat_main; - vat_json_node_t *node = 0; - u8 *deid = 0, *seid = 0; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - - vat_json_init_object (node); - deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0); - - seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0); - - vec_add1 (deid, 0); - vec_add1 (seid, 0); - - vat_json_object_add_string_copy (node, "seid", seid); - vat_json_object_add_string_copy (node, "deid", deid); - vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni)); - - if (mp->lloc.af) - { - clib_memcpy (&ip6, mp->lloc.un.ip6, sizeof (ip6)); - vat_json_object_add_ip6 (node, "lloc", ip6); - clib_memcpy (&ip6, mp->rloc.un.ip6, sizeof (ip6)); - vat_json_object_add_ip6 (node, "rloc", ip6); - - } - else - { - clib_memcpy (&ip4, mp->lloc.un.ip4, sizeof (ip4)); - vat_json_object_add_ip4 (node, "lloc", ip4); - clib_memcpy (&ip4, mp->rloc.un.ip4, sizeof (ip4)); - vat_json_object_add_ip4 (node, "rloc", ip4); - } - vat_json_object_add_uint (node, "pkt_count", - clib_net_to_host_u32 (mp->pkt_count)); - vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes)); - - vec_free (deid); - vec_free (seid); -} - -static void - vl_api_one_eid_table_map_details_t_handler - (vl_api_one_eid_table_map_details_t * mp) -{ - vat_main_t *vam = &vat_main; - - u8 *line = format (0, "%=10d%=10d", - clib_net_to_host_u32 (mp->vni), - clib_net_to_host_u32 (mp->dp_table)); - print (vam->ofp, "%v", line); - vec_free (line); -} - -static void - vl_api_one_eid_table_map_details_t_handler_json - (vl_api_one_eid_table_map_details_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = NULL; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - vat_json_init_object (node); - vat_json_object_add_uint (node, "dp_table", - clib_net_to_host_u32 (mp->dp_table)); - vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni)); -} - -static void - vl_api_one_eid_table_vni_details_t_handler - (vl_api_one_eid_table_vni_details_t * mp) -{ - vat_main_t *vam = &vat_main; - - u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni)); - print (vam->ofp, "%v", line); - vec_free (line); -} - -static void - vl_api_one_eid_table_vni_details_t_handler_json - (vl_api_one_eid_table_vni_details_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = NULL; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - vat_json_init_object (node); - vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni)); -} - -static void - vl_api_show_one_map_register_fallback_threshold_reply_t_handler - (vl_api_show_one_map_register_fallback_threshold_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - int retval = clib_net_to_host_u32 (mp->retval); - - vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp); - print (vam->ofp, "fallback threshold value: %d", mp->value); - - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json - (vl_api_show_one_map_register_fallback_threshold_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t _node, *node = &_node; - int retval = clib_net_to_host_u32 (mp->retval); - - vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp); - vat_json_init_object (node); - vat_json_object_add_uint (node, "value", mp->value); - - vat_json_print (vam->ofp, node); - vat_json_free (node); - - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_show_one_map_register_state_reply_t_handler - (vl_api_show_one_map_register_state_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - int retval = clib_net_to_host_u32 (mp->retval); - - print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled"); - - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_show_one_map_register_state_reply_t_handler_json - (vl_api_show_one_map_register_state_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t _node, *node = &_node; - int retval = clib_net_to_host_u32 (mp->retval); - - u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled"); - - vat_json_init_object (node); - vat_json_object_add_string_copy (node, "state", s); - - vat_json_print (vam->ofp, node); - vat_json_free (node); - - vam->retval = retval; - vam->result_ready = 1; - vec_free (s); -} - -static void - vl_api_show_one_rloc_probe_state_reply_t_handler - (vl_api_show_one_rloc_probe_state_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - int retval = clib_net_to_host_u32 (mp->retval); - - if (retval) - goto end; - - print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled"); -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_show_one_rloc_probe_state_reply_t_handler_json - (vl_api_show_one_rloc_probe_state_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t _node, *node = &_node; - int retval = clib_net_to_host_u32 (mp->retval); - - u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled"); - vat_json_init_object (node); - vat_json_object_add_string_copy (node, "state", s); - - vat_json_print (vam->ofp, node); - vat_json_free (node); - - vam->retval = retval; - vam->result_ready = 1; - vec_free (s); -} - -static void - vl_api_show_one_stats_enable_disable_reply_t_handler - (vl_api_show_one_stats_enable_disable_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - int retval = clib_net_to_host_u32 (mp->retval); - - if (retval) - goto end; - - print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled"); -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_show_one_stats_enable_disable_reply_t_handler_json - (vl_api_show_one_stats_enable_disable_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t _node, *node = &_node; - int retval = clib_net_to_host_u32 (mp->retval); - - u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled"); - vat_json_init_object (node); - vat_json_object_add_string_copy (node, "state", s); - - vat_json_print (vam->ofp, node); - vat_json_free (node); - - vam->retval = retval; - vam->result_ready = 1; - vec_free (s); -} - -static void -api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e) -{ - e->dp_table = clib_net_to_host_u32 (e->dp_table); - e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index); - e->vni = clib_net_to_host_u32 (e->vni); -} - -static void - gpe_fwd_entries_get_reply_t_net_to_host - (vl_api_gpe_fwd_entries_get_reply_t * mp) -{ - u32 i; - - mp->count = clib_net_to_host_u32 (mp->count); - for (i = 0; i < mp->count; i++) - { - api_gpe_fwd_entry_net_to_host (&mp->entries[i]); - } -} - -static u8 * -format_gpe_encap_mode (u8 * s, va_list * args) -{ - u32 mode = va_arg (*args, u32); - - switch (mode) - { - case 0: - return format (s, "lisp"); - case 1: - return format (s, "vxlan"); - } - return 0; -} - -static void - vl_api_gpe_get_encap_mode_reply_t_handler - (vl_api_gpe_get_encap_mode_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - - print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode); - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void - vl_api_gpe_get_encap_mode_reply_t_handler_json - (vl_api_gpe_get_encap_mode_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - - u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode); - vec_add1 (encap_mode, 0); - - vat_json_init_object (&node); - vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode); - - vec_free (encap_mode); - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void - vl_api_gpe_fwd_entry_path_details_t_handler - (vl_api_gpe_fwd_entry_path_details_t * mp) -{ - vat_main_t *vam = &vat_main; - u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0; - - if (mp->lcl_loc.addr.af) - format_ip_address_fcn = format_ip6_address; - else - format_ip_address_fcn = format_ip4_address; - - print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight, - format_ip_address_fcn, &mp->lcl_loc.addr.un, - format_ip_address_fcn, &mp->rmt_loc.addr.un); -} - -static void -lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc) -{ - struct in6_addr ip6; - struct in_addr ip4; - - if (loc->addr.af) - { - clib_memcpy (&ip6, loc->addr.un.ip6, sizeof (ip6)); - vat_json_object_add_ip6 (n, "address", ip6); - } - else - { - clib_memcpy (&ip4, loc->addr.un.ip4, sizeof (ip4)); - vat_json_object_add_ip4 (n, "address", ip4); - } - vat_json_object_add_uint (n, "weight", loc->weight); -} - -static void - vl_api_gpe_fwd_entry_path_details_t_handler_json - (vl_api_gpe_fwd_entry_path_details_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = NULL; - vat_json_node_t *loc_node; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - vat_json_init_object (node); - - loc_node = vat_json_object_add (node, "local_locator"); - vat_json_init_object (loc_node); - lisp_fill_locator_node (loc_node, &mp->lcl_loc); - - loc_node = vat_json_object_add (node, "remote_locator"); - vat_json_init_object (loc_node); - lisp_fill_locator_node (loc_node, &mp->rmt_loc); -} - -static void - vl_api_gpe_fwd_entries_get_reply_t_handler - (vl_api_gpe_fwd_entries_get_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - u32 i; - int retval = clib_net_to_host_u32 (mp->retval); - vl_api_gpe_fwd_entry_t *e; - - if (retval) - goto end; - - gpe_fwd_entries_get_reply_t_net_to_host (mp); - - for (i = 0; i < mp->count; i++) - { - e = &mp->entries[i]; - print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table, - format_lisp_flat_eid, e->leid, format_lisp_flat_eid, e->reid); - } - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_gpe_fwd_entries_get_reply_t_handler_json - (vl_api_gpe_fwd_entries_get_reply_t * mp) -{ - u8 *s = 0; - vat_main_t *vam = &vat_main; - vat_json_node_t *e = 0, root; - u32 i; - int retval = clib_net_to_host_u32 (mp->retval); - vl_api_gpe_fwd_entry_t *fwd; - - if (retval) - goto end; - - gpe_fwd_entries_get_reply_t_net_to_host (mp); - vat_json_init_array (&root); - - for (i = 0; i < mp->count; i++) - { - e = vat_json_array_add (&root); - fwd = &mp->entries[i]; - - vat_json_init_object (e); - vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index); - vat_json_object_add_int (e, "dp_table", fwd->dp_table); - vat_json_object_add_int (e, "vni", fwd->vni); - vat_json_object_add_int (e, "action", fwd->action); - - s = format (0, "%U", format_lisp_flat_eid, fwd->leid); - vec_add1 (s, 0); - vat_json_object_add_string_copy (e, "leid", s); - vec_free (s); - - s = format (0, "%U", format_lisp_flat_eid, fwd->reid); - vec_add1 (s, 0); - vat_json_object_add_string_copy (e, "reid", s); - vec_free (s); - } - - vat_json_print (vam->ofp, &root); - vat_json_free (&root); - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_gpe_native_fwd_rpaths_get_reply_t_handler - (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - vl_api_gpe_native_fwd_rpath_t *r; - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - - for (i = 0; i < n; i++) - { - r = &mp->entries[i]; - print (vam->ofp, "fib_index: %d sw_if_index %d nh %U", - clib_net_to_host_u32 (r->fib_index), - clib_net_to_host_u32 (r->nh_sw_if_index), - r->nh_addr.af ? format_ip6_address : format_ip4_address, - r->nh_addr.un); - } - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json - (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t root, *e; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - vl_api_gpe_native_fwd_rpath_t *r; - u8 *s; - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - vat_json_init_array (&root); - - for (i = 0; i < n; i++) - { - e = vat_json_array_add (&root); - vat_json_init_object (e); - r = &mp->entries[i]; - s = - format (0, "%U", - r->nh_addr.af ? format_ip6_address : format_ip4_address, - r->nh_addr.un); - vec_add1 (s, 0); - vat_json_object_add_string_copy (e, "ip4", s); - vec_free (s); - - vat_json_object_add_uint (e, "fib_index", - clib_net_to_host_u32 (r->fib_index)); - vat_json_object_add_uint (e, "nh_sw_if_index", - clib_net_to_host_u32 (r->nh_sw_if_index)); - } - - vat_json_print (vam->ofp, &root); - vat_json_free (&root); - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_gpe_fwd_entry_vnis_get_reply_t_handler - (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - - for (i = 0; i < n; i++) - print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i])); - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json - (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t root; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - vat_json_init_array (&root); - - for (i = 0; i < n; i++) - vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i])); - - vat_json_print (vam->ofp, &root); - vat_json_free (&root); - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_ndp_entries_get_reply_t_handler - (vl_api_one_ndp_entries_get_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - - for (i = 0; i < n; i++) - print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6, - format_ethernet_address, mp->entries[i].mac); - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_ndp_entries_get_reply_t_handler_json - (vl_api_one_ndp_entries_get_reply_t * mp) -{ - u8 *s = 0; - vat_main_t *vam = &vat_main; - vat_json_node_t *e = 0, root; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - vl_api_one_ndp_entry_t *arp_entry; - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - vat_json_init_array (&root); - - for (i = 0; i < n; i++) - { - e = vat_json_array_add (&root); - arp_entry = &mp->entries[i]; - - vat_json_init_object (e); - s = format (0, "%U", format_ethernet_address, arp_entry->mac); - vec_add1 (s, 0); - - vat_json_object_add_string_copy (e, "mac", s); - vec_free (s); - - s = format (0, "%U", format_ip6_address, &arp_entry->ip6); - vec_add1 (s, 0); - vat_json_object_add_string_copy (e, "ip6", s); - vec_free (s); - } - - vat_json_print (vam->ofp, &root); - vat_json_free (&root); - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_l2_arp_entries_get_reply_t_handler - (vl_api_one_l2_arp_entries_get_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - - for (i = 0; i < n; i++) - print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4, - format_ethernet_address, mp->entries[i].mac); - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_l2_arp_entries_get_reply_t_handler_json - (vl_api_one_l2_arp_entries_get_reply_t * mp) -{ - u8 *s = 0; - vat_main_t *vam = &vat_main; - vat_json_node_t *e = 0, root; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - vl_api_one_l2_arp_entry_t *arp_entry; - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - vat_json_init_array (&root); - - for (i = 0; i < n; i++) - { - e = vat_json_array_add (&root); - arp_entry = &mp->entries[i]; - - vat_json_init_object (e); - s = format (0, "%U", format_ethernet_address, arp_entry->mac); - vec_add1 (s, 0); - - vat_json_object_add_string_copy (e, "mac", s); - vec_free (s); - - s = format (0, "%U", format_ip4_address, &arp_entry->ip4); - vec_add1 (s, 0); - vat_json_object_add_string_copy (e, "ip4", s); - vec_free (s); - } - - vat_json_print (vam->ofp, &root); - vat_json_free (&root); - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void -vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - - for (i = 0; i < n; i++) - { - print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i])); - } - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_ndp_bd_get_reply_t_handler_json - (vl_api_one_ndp_bd_get_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t root; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - vat_json_init_array (&root); - - for (i = 0; i < n; i++) - { - vat_json_array_add_uint (&root, - clib_net_to_host_u32 (mp->bridge_domains[i])); - } - - vat_json_print (vam->ofp, &root); - vat_json_free (&root); - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_l2_arp_bd_get_reply_t_handler - (vl_api_one_l2_arp_bd_get_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - - for (i = 0; i < n; i++) - { - print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i])); - } - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_l2_arp_bd_get_reply_t_handler_json - (vl_api_one_l2_arp_bd_get_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t root; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - vat_json_init_array (&root); - - for (i = 0; i < n; i++) - { - vat_json_array_add_uint (&root, - clib_net_to_host_u32 (mp->bridge_domains[i])); - } - - vat_json_print (vam->ofp, &root); - vat_json_free (&root); - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_adjacencies_get_reply_t_handler - (vl_api_one_adjacencies_get_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - vl_api_one_adjacency_t *a; - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - - for (i = 0; i < n; i++) - { - a = &mp->adjacencies[i]; - print (vam->ofp, "%U %40U", - format_lisp_flat_eid, a->leid, format_lisp_flat_eid, a->reid); - } - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_adjacencies_get_reply_t_handler_json - (vl_api_one_adjacencies_get_reply_t * mp) -{ - u8 *s = 0; - vat_main_t *vam = &vat_main; - vat_json_node_t *e = 0, root; - u32 i, n; - int retval = clib_net_to_host_u32 (mp->retval); - vl_api_one_adjacency_t *a; - - if (retval) - goto end; - - n = clib_net_to_host_u32 (mp->count); - vat_json_init_array (&root); - - for (i = 0; i < n; i++) - { - e = vat_json_array_add (&root); - a = &mp->adjacencies[i]; - - vat_json_init_object (e); - s = format (0, "%U", format_lisp_flat_eid, a->leid); - vec_add1 (s, 0); - vat_json_object_add_string_copy (e, "leid", s); - vec_free (s); - - s = format (0, "%U", format_lisp_flat_eid, a->reid); - vec_add1 (s, 0); - vat_json_object_add_string_copy (e, "reid", s); - vec_free (s); - } - - vat_json_print (vam->ofp, &root); - vat_json_free (&root); - -end: - vam->retval = retval; - vam->result_ready = 1; -} - -static void -vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp) -{ - vat_main_t *vam = &vat_main; - - print (vam->ofp, "%=20U", - mp->ip_address.af ? format_ip6_address : format_ip4_address, - mp->ip_address.un); -} - -static void - vl_api_one_map_server_details_t_handler_json - (vl_api_one_map_server_details_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = NULL; - struct in6_addr ip6; - struct in_addr ip4; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - - vat_json_init_object (node); - if (mp->ip_address.af) - { - clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6)); - vat_json_object_add_ip6 (node, "map-server", ip6); - } - else - { - clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4)); - vat_json_object_add_ip4 (node, "map-server", ip4); - } -} - -static void -vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t - * mp) -{ - vat_main_t *vam = &vat_main; - - print (vam->ofp, "%=20U", - mp->ip_address.af ? format_ip6_address : format_ip4_address, - mp->ip_address.un); -} - -static void - vl_api_one_map_resolver_details_t_handler_json - (vl_api_one_map_resolver_details_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = NULL; - struct in6_addr ip6; - struct in_addr ip4; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - - vat_json_init_object (node); - if (mp->ip_address.af) - { - clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6)); - vat_json_object_add_ip6 (node, "map resolver", ip6); - } - else - { - clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4)); - vat_json_object_add_ip4 (node, "map resolver", ip4); - } -} - -static void -vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (0 <= retval) - { - print (vam->ofp, "feature: %s\ngpe: %s", - mp->feature_status ? "enabled" : "disabled", - mp->gpe_status ? "enabled" : "disabled"); - } - - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_show_one_status_reply_t_handler_json - (vl_api_show_one_status_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - u8 *gpe_status = NULL; - u8 *feature_status = NULL; - - gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled"); - feature_status = format (0, "%s", - mp->feature_status ? "enabled" : "disabled"); - vec_add1 (gpe_status, 0); - vec_add1 (feature_status, 0); - - vat_json_init_object (&node); - vat_json_object_add_string_copy (&node, "gpe_status", gpe_status); - vat_json_object_add_string_copy (&node, "feature_status", feature_status); - - vec_free (gpe_status); - vec_free (feature_status); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void - vl_api_one_get_map_request_itr_rlocs_reply_t_handler - (vl_api_one_get_map_request_itr_rlocs_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (retval >= 0) - { - print (vam->ofp, "%=20s", mp->locator_set_name); - } - - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json - (vl_api_one_get_map_request_itr_rlocs_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = NULL; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - - vat_json_init_object (node); - vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name); - - vat_json_print (vam->ofp, node); - vat_json_free (node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static u8 * -format_lisp_map_request_mode (u8 * s, va_list * args) -{ - u32 mode = va_arg (*args, u32); - - switch (mode) - { - case 0: - return format (0, "dst-only"); - case 1: - return format (0, "src-dst"); - } - return 0; -} - -static void - vl_api_show_one_map_request_mode_reply_t_handler - (vl_api_show_one_map_request_mode_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (0 <= retval) - { - u32 mode = mp->mode; - print (vam->ofp, "map_request_mode: %U", - format_lisp_map_request_mode, mode); - } - - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_show_one_map_request_mode_reply_t_handler_json - (vl_api_show_one_map_request_mode_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - u8 *s = 0; - u32 mode; - - mode = mp->mode; - s = format (0, "%U", format_lisp_map_request_mode, mode); - vec_add1 (s, 0); - - vat_json_init_object (&node); - vat_json_object_add_string_copy (&node, "map_request_mode", s); - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vec_free (s); - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void - vl_api_one_show_xtr_mode_reply_t_handler - (vl_api_one_show_xtr_mode_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (0 <= retval) - { - print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled"); - } - - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_show_xtr_mode_reply_t_handler_json - (vl_api_one_show_xtr_mode_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - u8 *status = 0; - - status = format (0, "%s", mp->is_enable ? "enabled" : "disabled"); - vec_add1 (status, 0); - - vat_json_init_object (&node); - vat_json_object_add_string_copy (&node, "status", status); - - vec_free (status); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void - vl_api_one_show_pitr_mode_reply_t_handler - (vl_api_one_show_pitr_mode_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (0 <= retval) - { - print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled"); - } - - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_show_pitr_mode_reply_t_handler_json - (vl_api_one_show_pitr_mode_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - u8 *status = 0; - - status = format (0, "%s", mp->is_enable ? "enabled" : "disabled"); - vec_add1 (status, 0); - - vat_json_init_object (&node); - vat_json_object_add_string_copy (&node, "status", status); - - vec_free (status); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void - vl_api_one_show_petr_mode_reply_t_handler - (vl_api_one_show_petr_mode_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (0 <= retval) - { - print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled"); - } - - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_one_show_petr_mode_reply_t_handler_json - (vl_api_one_show_petr_mode_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - u8 *status = 0; - - status = format (0, "%s", mp->is_enable ? "enabled" : "disabled"); - vec_add1 (status, 0); - - vat_json_init_object (&node); - vat_json_object_add_string_copy (&node, "status", status); - - vec_free (status); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void - vl_api_show_one_use_petr_reply_t_handler - (vl_api_show_one_use_petr_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (0 <= retval) - { - print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled"); - if (mp->status) - { - print (vam->ofp, "Proxy-ETR address; %U", - mp->ip_address.af ? format_ip6_address : format_ip4_address, - mp->ip_address.un); - } - } - - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_show_one_use_petr_reply_t_handler_json - (vl_api_show_one_use_petr_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - u8 *status = 0; - struct in_addr ip4; - struct in6_addr ip6; - - status = format (0, "%s", mp->status ? "enabled" : "disabled"); - vec_add1 (status, 0); - - vat_json_init_object (&node); - vat_json_object_add_string_copy (&node, "status", status); - if (mp->status) - { - if (mp->ip_address.af) - { - clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6)); - vat_json_object_add_ip6 (&node, "address", ip6); - } - else - { - clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4)); - vat_json_object_add_ip4 (&node, "address", ip4); - } - } - - vec_free (status); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void - vl_api_show_one_nsh_mapping_reply_t_handler - (vl_api_show_one_nsh_mapping_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (0 <= retval) - { - print (vam->ofp, "%-20s%-16s", - mp->is_set ? "set" : "not-set", - mp->is_set ? (char *) mp->locator_set_name : ""); - } - - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_show_one_nsh_mapping_reply_t_handler_json - (vl_api_show_one_nsh_mapping_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - u8 *status = 0; - - status = format (0, "%s", mp->is_set ? "yes" : "no"); - vec_add1 (status, 0); - - vat_json_init_object (&node); - vat_json_object_add_string_copy (&node, "is_set", status); - if (mp->is_set) - { - vat_json_object_add_string_copy (&node, "locator_set", - mp->locator_set_name); - } - - vec_free (status); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void - vl_api_show_one_map_register_ttl_reply_t_handler - (vl_api_show_one_map_register_ttl_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - vl_api_show_one_map_register_ttl_reply_t_endian (mp); - - if (0 <= retval) - { - print (vam->ofp, "ttl: %u", mp->ttl); - } - - vam->retval = retval; - vam->result_ready = 1; -} - -static void - vl_api_show_one_map_register_ttl_reply_t_handler_json - (vl_api_show_one_map_register_ttl_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - - vl_api_show_one_map_register_ttl_reply_t_endian (mp); - vat_json_init_object (&node); - vat_json_object_add_uint (&node, "ttl", mp->ttl); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void -vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - - if (0 <= retval) - { - print (vam->ofp, "%-20s%-16s", - mp->status ? "enabled" : "disabled", - mp->status ? (char *) mp->locator_set_name : ""); - } - - vam->retval = retval; - vam->result_ready = 1; -} - -static void -vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - u8 *status = 0; - - status = format (0, "%s", mp->status ? "enabled" : "disabled"); - vec_add1 (status, 0); - - vat_json_init_object (&node); - vat_json_object_add_string_copy (&node, "status", status); - if (mp->status) - { - vat_json_object_add_string_copy (&node, "locator_set", - mp->locator_set_name); - } - - vec_free (status); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - static u8 * format_policer_type (u8 * s, va_list * va) { @@ -5023,17 +3227,6 @@ static void vl_api_flow_classify_details_t_handler_json vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index)); } -#define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler -#define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler -#define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler -#define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler -#define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler -#define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler -#define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler -#define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler -#define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler -#define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler - /* * Generate boilerplate reply handlers, which * dig the return value out of the xxx_reply_t API message, @@ -5108,34 +3301,6 @@ _(cop_whitelist_enable_disable_reply) \ _(sw_interface_clear_stats_reply) \ _(ioam_enable_reply) \ _(ioam_disable_reply) \ -_(one_add_del_locator_reply) \ -_(one_add_del_local_eid_reply) \ -_(one_add_del_remote_mapping_reply) \ -_(one_add_del_adjacency_reply) \ -_(one_add_del_map_resolver_reply) \ -_(one_add_del_map_server_reply) \ -_(one_enable_disable_reply) \ -_(one_rloc_probe_enable_disable_reply) \ -_(one_map_register_enable_disable_reply) \ -_(one_map_register_set_ttl_reply) \ -_(one_set_transport_protocol_reply) \ -_(one_map_register_fallback_threshold_reply) \ -_(one_pitr_set_locator_set_reply) \ -_(one_map_request_mode_reply) \ -_(one_add_del_map_request_itr_rlocs_reply) \ -_(one_eid_table_add_del_map_reply) \ -_(one_use_petr_reply) \ -_(one_stats_enable_disable_reply) \ -_(one_add_del_l2_arp_entry_reply) \ -_(one_add_del_ndp_entry_reply) \ -_(one_stats_flush_reply) \ -_(one_enable_disable_xtr_mode_reply) \ -_(one_enable_disable_pitr_mode_reply) \ -_(one_enable_disable_petr_mode_reply) \ -_(gpe_enable_disable_reply) \ -_(gpe_set_encap_mode_reply) \ -_(gpe_add_del_iface_reply) \ -_(gpe_add_del_native_fwd_rpath_reply) \ _(af_packet_delete_reply) \ _(policer_classify_set_interface_reply) \ _(set_ipfix_exporter_reply) \ @@ -5324,81 +3489,6 @@ _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \ _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \ _(IOAM_ENABLE_REPLY, ioam_enable_reply) \ _(IOAM_DISABLE_REPLY, ioam_disable_reply) \ -_(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \ -_(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \ -_(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \ -_(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \ -_(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \ -_(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \ -_(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \ -_(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \ -_(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \ - one_map_register_enable_disable_reply) \ -_(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \ -_(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \ -_(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \ -_(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \ - one_map_register_fallback_threshold_reply) \ -_(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \ - one_rloc_probe_enable_disable_reply) \ -_(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \ -_(ONE_USE_PETR_REPLY, one_use_petr_reply) \ -_(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \ -_(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \ -_(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \ -_(ONE_LOCATOR_DETAILS, one_locator_details) \ -_(ONE_EID_TABLE_DETAILS, one_eid_table_details) \ -_(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \ -_(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \ -_(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \ -_(ONE_MAP_SERVER_DETAILS, one_map_server_details) \ -_(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \ -_(ONE_STATS_DETAILS, one_stats_details) \ -_(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \ -_(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \ -_(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \ - show_one_stats_enable_disable_reply) \ -_(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \ -_(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \ -_(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \ -_(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \ -_(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \ -_(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \ -_(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \ -_(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \ - one_enable_disable_pitr_mode_reply) \ -_(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \ - one_enable_disable_petr_mode_reply) \ -_(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \ -_(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \ -_(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \ -_(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \ -_(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \ -_(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \ -_(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \ -_(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \ -_(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \ -_(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \ -_(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \ -_(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \ - gpe_add_del_native_fwd_rpath_reply) \ -_(GPE_FWD_ENTRY_PATH_DETAILS, \ - gpe_fwd_entry_path_details) \ -_(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \ -_(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \ - one_add_del_map_request_itr_rlocs_reply) \ -_(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \ - one_get_map_request_itr_rlocs_reply) \ -_(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \ -_(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \ -_(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \ -_(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \ -_(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \ -_(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \ - show_one_map_register_state_reply) \ -_(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \ -_(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \ - show_one_map_register_fallback_threshold_reply) \ _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \ _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \ _(AF_PACKET_DETAILS, af_packet_details) \ @@ -13589,3002 +11679,6 @@ api_get_node_graph (vat_main_t * vam) return ret; } -/* *INDENT-OFF* */ -/** Used for parsing LISP eids */ -typedef CLIB_PACKED(struct{ - union { - ip46_address_t ip; - mac_address_t mac; - lisp_nsh_api_t nsh; - } addr; - u32 len; /**< prefix length if IP */ - u8 type; /**< type of eid */ -}) lisp_eid_vat_t; -/* *INDENT-ON* */ - -static uword -unformat_lisp_eid_vat (unformat_input_t * input, va_list * args) -{ - lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *); - - clib_memset (a, 0, sizeof (a[0])); - - if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len)) - { - a->type = 0; /* ip prefix type */ - } - else if (unformat (input, "%U", unformat_ethernet_address, &a->addr.mac)) - { - a->type = 1; /* mac type */ - } - else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh)) - { - a->type = 2; /* NSH type */ - a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi); - } - else - { - return 0; - } - - if (a->type == 0) - { - if (ip46_address_is_ip4 (&a->addr.ip)) - return a->len > 32 ? 1 : 0; - else - return a->len > 128 ? 1 : 0; - } - - return 1; -} - -static void -lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid) -{ - eid->type = vat_eid->type; - switch (eid->type) - { - case EID_TYPE_API_PREFIX: - if (ip46_address_is_ip4 (&vat_eid->addr.ip)) - { - clib_memcpy (&eid->address.prefix.address.un.ip4, - &vat_eid->addr.ip.ip4, 4); - eid->address.prefix.address.af = ADDRESS_IP4; - eid->address.prefix.len = vat_eid->len; - } - else - { - clib_memcpy (&eid->address.prefix.address.un.ip6, - &vat_eid->addr.ip.ip6, 16); - eid->address.prefix.address.af = ADDRESS_IP6; - eid->address.prefix.len = vat_eid->len; - } - return; - case EID_TYPE_API_MAC: - clib_memcpy (&eid->address.mac, &vat_eid->addr.mac, - sizeof (eid->address.mac)); - return; - case EID_TYPE_API_NSH: - clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh, - sizeof (eid->address.nsh)); - return; - default: - ASSERT (0); - return; - } -} - -static int -api_one_add_del_locator_set (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_add_del_locator_set_t *mp; - u8 is_add = 1; - u8 *locator_set_name = NULL; - u8 locator_set_name_set = 0; - vl_api_local_locator_t locator, *locators = 0; - u32 sw_if_index, priority, weight; - u32 data_len = 0; - - int ret; - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - { - is_add = 0; - } - else if (unformat (input, "locator-set %s", &locator_set_name)) - { - locator_set_name_set = 1; - } - else if (unformat (input, "sw_if_index %u p %u w %u", - &sw_if_index, &priority, &weight)) - { - locator.sw_if_index = htonl (sw_if_index); - locator.priority = priority; - locator.weight = weight; - vec_add1 (locators, locator); - } - else - if (unformat - (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam, - &sw_if_index, &priority, &weight)) - { - locator.sw_if_index = htonl (sw_if_index); - locator.priority = priority; - locator.weight = weight; - vec_add1 (locators, locator); - } - else - break; - } - - if (locator_set_name_set == 0) - { - errmsg ("missing locator-set name"); - vec_free (locators); - return -99; - } - - if (vec_len (locator_set_name) > 64) - { - errmsg ("locator-set name too long"); - vec_free (locator_set_name); - vec_free (locators); - return -99; - } - vec_add1 (locator_set_name, 0); - - data_len = sizeof (vl_api_local_locator_t) * vec_len (locators); - - /* Construct the API message */ - M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len); - - mp->is_add = is_add; - clib_memcpy (mp->locator_set_name, locator_set_name, - vec_len (locator_set_name)); - vec_free (locator_set_name); - - mp->locator_num = clib_host_to_net_u32 (vec_len (locators)); - if (locators) - clib_memcpy (mp->locators, locators, data_len); - vec_free (locators); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_add_del_locator_set api_one_add_del_locator_set - -static int -api_one_add_del_locator (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_add_del_locator_t *mp; - u32 tmp_if_index = ~0; - u32 sw_if_index = ~0; - u8 sw_if_index_set = 0; - u8 sw_if_index_if_name_set = 0; - u32 priority = ~0; - u8 priority_set = 0; - u32 weight = ~0; - u8 weight_set = 0; - u8 is_add = 1; - u8 *locator_set_name = NULL; - u8 locator_set_name_set = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - { - is_add = 0; - } - else if (unformat (input, "locator-set %s", &locator_set_name)) - { - locator_set_name_set = 1; - } - else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam, - &tmp_if_index)) - { - sw_if_index_if_name_set = 1; - sw_if_index = tmp_if_index; - } - else if (unformat (input, "sw_if_index %d", &tmp_if_index)) - { - sw_if_index_set = 1; - sw_if_index = tmp_if_index; - } - else if (unformat (input, "p %d", &priority)) - { - priority_set = 1; - } - else if (unformat (input, "w %d", &weight)) - { - weight_set = 1; - } - else - break; - } - - if (locator_set_name_set == 0) - { - errmsg ("missing locator-set name"); - return -99; - } - - if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0) - { - errmsg ("missing sw_if_index"); - vec_free (locator_set_name); - return -99; - } - - if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0) - { - errmsg ("cannot use both params interface name and sw_if_index"); - vec_free (locator_set_name); - return -99; - } - - if (priority_set == 0) - { - errmsg ("missing locator-set priority"); - vec_free (locator_set_name); - return -99; - } - - if (weight_set == 0) - { - errmsg ("missing locator-set weight"); - vec_free (locator_set_name); - return -99; - } - - if (vec_len (locator_set_name) > 64) - { - errmsg ("locator-set name too long"); - vec_free (locator_set_name); - return -99; - } - vec_add1 (locator_set_name, 0); - - /* Construct the API message */ - M (ONE_ADD_DEL_LOCATOR, mp); - - mp->is_add = is_add; - mp->sw_if_index = ntohl (sw_if_index); - mp->priority = priority; - mp->weight = weight; - clib_memcpy (mp->locator_set_name, locator_set_name, - vec_len (locator_set_name)); - vec_free (locator_set_name); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_add_del_locator api_one_add_del_locator - -uword -unformat_hmac_key_id (unformat_input_t * input, va_list * args) -{ - u32 *key_id = va_arg (*args, u32 *); - u8 *s = 0; - - if (unformat (input, "%s", &s)) - { - if (!strcmp ((char *) s, "sha1")) - key_id[0] = HMAC_SHA_1_96; - else if (!strcmp ((char *) s, "sha256")) - key_id[0] = HMAC_SHA_256_128; - else - { - clib_warning ("invalid key_id: '%s'", s); - key_id[0] = HMAC_NO_KEY; - } - } - else - return 0; - - vec_free (s); - return 1; -} - -static int -api_one_add_del_local_eid (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_add_del_local_eid_t *mp; - u8 is_add = 1; - u8 eid_set = 0; - lisp_eid_vat_t _eid, *eid = &_eid; - u8 *locator_set_name = 0; - u8 locator_set_name_set = 0; - u32 vni = 0; - u16 key_id = 0; - u8 *key = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - { - is_add = 0; - } - else if (unformat (input, "vni %d", &vni)) - { - ; - } - else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid)) - { - eid_set = 1; - } - else if (unformat (input, "locator-set %s", &locator_set_name)) - { - locator_set_name_set = 1; - } - else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id)) - ; - else if (unformat (input, "secret-key %_%v%_", &key)) - ; - else - break; - } - - if (locator_set_name_set == 0) - { - errmsg ("missing locator-set name"); - return -99; - } - - if (0 == eid_set) - { - errmsg ("EID address not set!"); - vec_free (locator_set_name); - return -99; - } - - if (key && (0 == key_id)) - { - errmsg ("invalid key_id!"); - return -99; - } - - if (vec_len (key) > 64) - { - errmsg ("key too long"); - vec_free (key); - return -99; - } - - if (vec_len (locator_set_name) > 64) - { - errmsg ("locator-set name too long"); - vec_free (locator_set_name); - return -99; - } - vec_add1 (locator_set_name, 0); - - /* Construct the API message */ - M (ONE_ADD_DEL_LOCAL_EID, mp); - - mp->is_add = is_add; - lisp_eid_put_vat (&mp->eid, eid); - mp->vni = clib_host_to_net_u32 (vni); - mp->key.id = key_id; - clib_memcpy (mp->locator_set_name, locator_set_name, - vec_len (locator_set_name)); - clib_memcpy (mp->key.key, key, vec_len (key)); - - vec_free (locator_set_name); - vec_free (key); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_add_del_local_eid api_one_add_del_local_eid - -static int -api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam) -{ - u32 dp_table = 0, vni = 0;; - unformat_input_t *input = vam->input; - vl_api_gpe_add_del_fwd_entry_t *mp; - u8 is_add = 1; - lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid; - lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid; - u8 rmt_eid_set = 0, lcl_eid_set = 0; - u32 action = ~0, w; - ip4_address_t rmt_rloc4, lcl_rloc4; - ip6_address_t rmt_rloc6, lcl_rloc6; - vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0; - int ret; - - clib_memset (&rloc, 0, sizeof (rloc)); - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - is_add = 0; - else if (unformat (input, "add")) - is_add = 1; - else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid)) - { - rmt_eid_set = 1; - } - else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid)) - { - lcl_eid_set = 1; - } - else if (unformat (input, "vrf %d", &dp_table)) - ; - else if (unformat (input, "bd %d", &dp_table)) - ; - else if (unformat (input, "vni %d", &vni)) - ; - else if (unformat (input, "w %d", &w)) - { - if (!curr_rloc) - { - errmsg ("No RLOC configured for setting priority/weight!"); - return -99; - } - curr_rloc->weight = w; - } - else if (unformat (input, "loc-pair %U %U", unformat_ip4_address, - &lcl_rloc4, unformat_ip4_address, &rmt_rloc4)) - { - rloc.addr.af = 0; - clib_memcpy (&rloc.addr.un.ip4, &lcl_rloc4, sizeof (lcl_rloc4)); - rloc.weight = 0; - vec_add1 (lcl_locs, rloc); - - clib_memcpy (&rloc.addr.un.ip4, &rmt_rloc4, sizeof (rmt_rloc4)); - vec_add1 (rmt_locs, rloc); - /* weight saved in rmt loc */ - curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1]; - } - else if (unformat (input, "loc-pair %U %U", unformat_ip6_address, - &lcl_rloc6, unformat_ip6_address, &rmt_rloc6)) - { - rloc.addr.af = 1; - clib_memcpy (&rloc.addr.un.ip6, &lcl_rloc6, sizeof (lcl_rloc6)); - rloc.weight = 0; - vec_add1 (lcl_locs, rloc); - - clib_memcpy (&rloc.addr.un.ip6, &rmt_rloc6, sizeof (rmt_rloc6)); - vec_add1 (rmt_locs, rloc); - /* weight saved in rmt loc */ - curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1]; - } - else if (unformat (input, "action %d", &action)) - { - ; - } - else - { - clib_warning ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!rmt_eid_set) - { - errmsg ("remote eid addresses not set"); - return -99; - } - - if (lcl_eid_set && rmt_eid->type != lcl_eid->type) - { - errmsg ("eid types don't match"); - return -99; - } - - if (0 == rmt_locs && (u32) ~ 0 == action) - { - errmsg ("action not set for negative mapping"); - return -99; - } - - /* Construct the API message */ - M2 (GPE_ADD_DEL_FWD_ENTRY, mp, - sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2); - - mp->is_add = is_add; - lisp_eid_put_vat (&mp->rmt_eid, rmt_eid); - lisp_eid_put_vat (&mp->lcl_eid, lcl_eid); - mp->dp_table = clib_host_to_net_u32 (dp_table); - mp->vni = clib_host_to_net_u32 (vni); - mp->action = action; - - if (0 != rmt_locs && 0 != lcl_locs) - { - mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2); - clib_memcpy (mp->locs, lcl_locs, - (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs))); - - u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs); - clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs, - (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs))); - } - vec_free (lcl_locs); - vec_free (rmt_locs); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_one_add_del_map_server (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_add_del_map_server_t *mp; - u8 is_add = 1; - u8 ipv4_set = 0; - u8 ipv6_set = 0; - ip4_address_t ipv4; - ip6_address_t ipv6; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - { - is_add = 0; - } - else if (unformat (input, "%U", unformat_ip4_address, &ipv4)) - { - ipv4_set = 1; - } - else if (unformat (input, "%U", unformat_ip6_address, &ipv6)) - { - ipv6_set = 1; - } - else - break; - } - - if (ipv4_set && ipv6_set) - { - errmsg ("both eid v4 and v6 addresses set"); - return -99; - } - - if (!ipv4_set && !ipv6_set) - { - errmsg ("eid addresses not set"); - return -99; - } - - /* Construct the API message */ - M (ONE_ADD_DEL_MAP_SERVER, mp); - - mp->is_add = is_add; - if (ipv6_set) - { - mp->ip_address.af = 1; - clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6)); - } - else - { - mp->ip_address.af = 0; - clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4)); - } - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_add_del_map_server api_one_add_del_map_server - -static int -api_one_add_del_map_resolver (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_add_del_map_resolver_t *mp; - u8 is_add = 1; - u8 ipv4_set = 0; - u8 ipv6_set = 0; - ip4_address_t ipv4; - ip6_address_t ipv6; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - { - is_add = 0; - } - else if (unformat (input, "%U", unformat_ip4_address, &ipv4)) - { - ipv4_set = 1; - } - else if (unformat (input, "%U", unformat_ip6_address, &ipv6)) - { - ipv6_set = 1; - } - else - break; - } - - if (ipv4_set && ipv6_set) - { - errmsg ("both eid v4 and v6 addresses set"); - return -99; - } - - if (!ipv4_set && !ipv6_set) - { - errmsg ("eid addresses not set"); - return -99; - } - - /* Construct the API message */ - M (ONE_ADD_DEL_MAP_RESOLVER, mp); - - mp->is_add = is_add; - if (ipv6_set) - { - mp->ip_address.af = 1; - clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6)); - } - else - { - mp->ip_address.af = 0; - clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4)); - } - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_add_del_map_resolver api_one_add_del_map_resolver - -static int -api_lisp_gpe_enable_disable (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_gpe_enable_disable_t *mp; - u8 is_set = 0; - u8 is_enable = 1; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "enable")) - { - is_set = 1; - is_enable = 1; - } - else if (unformat (input, "disable")) - { - is_set = 1; - is_enable = 0; - } - else - break; - } - - if (is_set == 0) - { - errmsg ("Value not set"); - return -99; - } - - /* Construct the API message */ - M (GPE_ENABLE_DISABLE, mp); - - mp->is_enable = is_enable; - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_one_rloc_probe_enable_disable (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_rloc_probe_enable_disable_t *mp; - u8 is_set = 0; - u8 is_enable = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "enable")) - { - is_set = 1; - is_enable = 1; - } - else if (unformat (input, "disable")) - is_set = 1; - else - break; - } - - if (!is_set) - { - errmsg ("Value not set"); - return -99; - } - - /* Construct the API message */ - M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp); - - mp->is_enable = is_enable; - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable - -static int -api_one_map_register_enable_disable (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_map_register_enable_disable_t *mp; - u8 is_set = 0; - u8 is_enable = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "enable")) - { - is_set = 1; - is_enable = 1; - } - else if (unformat (input, "disable")) - is_set = 1; - else - break; - } - - if (!is_set) - { - errmsg ("Value not set"); - return -99; - } - - /* Construct the API message */ - M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp); - - mp->is_enable = is_enable; - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_map_register_enable_disable api_one_map_register_enable_disable - -static int -api_one_enable_disable (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_enable_disable_t *mp; - u8 is_set = 0; - u8 is_enable = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "enable")) - { - is_set = 1; - is_enable = 1; - } - else if (unformat (input, "disable")) - { - is_set = 1; - } - else - break; - } - - if (!is_set) - { - errmsg ("Value not set"); - return -99; - } - - /* Construct the API message */ - M (ONE_ENABLE_DISABLE, mp); - - mp->is_enable = is_enable; - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_enable_disable api_one_enable_disable - -static int -api_one_enable_disable_xtr_mode (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_enable_disable_xtr_mode_t *mp; - u8 is_set = 0; - u8 is_enable = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "enable")) - { - is_set = 1; - is_enable = 1; - } - else if (unformat (input, "disable")) - { - is_set = 1; - } - else - break; - } - - if (!is_set) - { - errmsg ("Value not set"); - return -99; - } - - /* Construct the API message */ - M (ONE_ENABLE_DISABLE_XTR_MODE, mp); - - mp->is_enable = is_enable; - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_one_show_xtr_mode (vat_main_t * vam) -{ - vl_api_one_show_xtr_mode_t *mp; - int ret; - - /* Construct the API message */ - M (ONE_SHOW_XTR_MODE, mp); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_one_enable_disable_pitr_mode (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_enable_disable_pitr_mode_t *mp; - u8 is_set = 0; - u8 is_enable = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "enable")) - { - is_set = 1; - is_enable = 1; - } - else if (unformat (input, "disable")) - { - is_set = 1; - } - else - break; - } - - if (!is_set) - { - errmsg ("Value not set"); - return -99; - } - - /* Construct the API message */ - M (ONE_ENABLE_DISABLE_PITR_MODE, mp); - - mp->is_enable = is_enable; - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_one_show_pitr_mode (vat_main_t * vam) -{ - vl_api_one_show_pitr_mode_t *mp; - int ret; - - /* Construct the API message */ - M (ONE_SHOW_PITR_MODE, mp); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_one_enable_disable_petr_mode (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_enable_disable_petr_mode_t *mp; - u8 is_set = 0; - u8 is_enable = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "enable")) - { - is_set = 1; - is_enable = 1; - } - else if (unformat (input, "disable")) - { - is_set = 1; - } - else - break; - } - - if (!is_set) - { - errmsg ("Value not set"); - return -99; - } - - /* Construct the API message */ - M (ONE_ENABLE_DISABLE_PETR_MODE, mp); - - mp->is_enable = is_enable; - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_one_show_petr_mode (vat_main_t * vam) -{ - vl_api_one_show_petr_mode_t *mp; - int ret; - - /* Construct the API message */ - M (ONE_SHOW_PETR_MODE, mp); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_show_one_map_register_state (vat_main_t * vam) -{ - vl_api_show_one_map_register_state_t *mp; - int ret; - - M (SHOW_ONE_MAP_REGISTER_STATE, mp); - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -#define api_show_lisp_map_register_state api_show_one_map_register_state - -static int -api_show_one_rloc_probe_state (vat_main_t * vam) -{ - vl_api_show_one_rloc_probe_state_t *mp; - int ret; - - M (SHOW_ONE_RLOC_PROBE_STATE, mp); - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -#define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state - -static int -api_one_add_del_ndp_entry (vat_main_t * vam) -{ - vl_api_one_add_del_ndp_entry_t *mp; - unformat_input_t *input = vam->input; - u8 is_add = 1; - u8 mac_set = 0; - u8 bd_set = 0; - u8 ip_set = 0; - u8 mac[6] = { 0, }; - u8 ip6[16] = { 0, }; - u32 bd = ~0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - is_add = 0; - else if (unformat (input, "mac %U", unformat_ethernet_address, mac)) - mac_set = 1; - else if (unformat (input, "ip %U", unformat_ip6_address, ip6)) - ip_set = 1; - else if (unformat (input, "bd %d", &bd)) - bd_set = 1; - else - { - errmsg ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!bd_set || !ip_set || (!mac_set && is_add)) - { - errmsg ("Missing BD, IP or MAC!"); - return -99; - } - - M (ONE_ADD_DEL_NDP_ENTRY, mp); - mp->is_add = is_add; - clib_memcpy (&mp->entry.mac, mac, 6); - mp->bd = clib_host_to_net_u32 (bd); - clib_memcpy (&mp->entry.ip6, ip6, sizeof (mp->entry.ip6)); - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -static int -api_one_add_del_l2_arp_entry (vat_main_t * vam) -{ - vl_api_one_add_del_l2_arp_entry_t *mp; - unformat_input_t *input = vam->input; - u8 is_add = 1; - u8 mac_set = 0; - u8 bd_set = 0; - u8 ip_set = 0; - u8 mac[6] = { 0, }; - u32 ip4 = 0, bd = ~0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - is_add = 0; - else if (unformat (input, "mac %U", unformat_ethernet_address, mac)) - mac_set = 1; - else if (unformat (input, "ip %U", unformat_ip4_address, &ip4)) - ip_set = 1; - else if (unformat (input, "bd %d", &bd)) - bd_set = 1; - else - { - errmsg ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!bd_set || !ip_set || (!mac_set && is_add)) - { - errmsg ("Missing BD, IP or MAC!"); - return -99; - } - - M (ONE_ADD_DEL_L2_ARP_ENTRY, mp); - mp->is_add = is_add; - clib_memcpy (&mp->entry.mac, mac, 6); - mp->bd = clib_host_to_net_u32 (bd); - clib_memcpy (mp->entry.ip4, &ip4, sizeof (mp->entry.ip4)); - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -static int -api_one_ndp_bd_get (vat_main_t * vam) -{ - vl_api_one_ndp_bd_get_t *mp; - int ret; - - M (ONE_NDP_BD_GET, mp); - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -static int -api_one_ndp_entries_get (vat_main_t * vam) -{ - vl_api_one_ndp_entries_get_t *mp; - unformat_input_t *input = vam->input; - u8 bd_set = 0; - u32 bd = ~0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "bd %d", &bd)) - bd_set = 1; - else - { - errmsg ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!bd_set) - { - errmsg ("Expected bridge domain!"); - return -99; - } - - M (ONE_NDP_ENTRIES_GET, mp); - mp->bd = clib_host_to_net_u32 (bd); - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -static int -api_one_l2_arp_bd_get (vat_main_t * vam) -{ - vl_api_one_l2_arp_bd_get_t *mp; - int ret; - - M (ONE_L2_ARP_BD_GET, mp); - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -static int -api_one_l2_arp_entries_get (vat_main_t * vam) -{ - vl_api_one_l2_arp_entries_get_t *mp; - unformat_input_t *input = vam->input; - u8 bd_set = 0; - u32 bd = ~0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "bd %d", &bd)) - bd_set = 1; - else - { - errmsg ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!bd_set) - { - errmsg ("Expected bridge domain!"); - return -99; - } - - M (ONE_L2_ARP_ENTRIES_GET, mp); - mp->bd = clib_host_to_net_u32 (bd); - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -static int -api_one_stats_enable_disable (vat_main_t * vam) -{ - vl_api_one_stats_enable_disable_t *mp; - unformat_input_t *input = vam->input; - u8 is_set = 0; - u8 is_enable = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "enable")) - { - is_set = 1; - is_enable = 1; - } - else if (unformat (input, "disable")) - { - is_set = 1; - } - else - break; - } - - if (!is_set) - { - errmsg ("Value not set"); - return -99; - } - - M (ONE_STATS_ENABLE_DISABLE, mp); - mp->is_enable = is_enable; - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -static int -api_show_one_stats_enable_disable (vat_main_t * vam) -{ - vl_api_show_one_stats_enable_disable_t *mp; - int ret; - - M (SHOW_ONE_STATS_ENABLE_DISABLE, mp); - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -static int -api_show_one_map_request_mode (vat_main_t * vam) -{ - vl_api_show_one_map_request_mode_t *mp; - int ret; - - M (SHOW_ONE_MAP_REQUEST_MODE, mp); - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -#define api_show_lisp_map_request_mode api_show_one_map_request_mode - -static int -api_one_map_request_mode (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_map_request_mode_t *mp; - u8 mode = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "dst-only")) - mode = 0; - else if (unformat (input, "src-dst")) - mode = 1; - else - { - errmsg ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - M (ONE_MAP_REQUEST_MODE, mp); - - mp->mode = mode; - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -#define api_lisp_map_request_mode api_one_map_request_mode - -/** - * Enable/disable ONE proxy ITR. - * - * @param vam vpp API test context - * @return return code - */ -static int -api_one_pitr_set_locator_set (vat_main_t * vam) -{ - u8 ls_name_set = 0; - unformat_input_t *input = vam->input; - vl_api_one_pitr_set_locator_set_t *mp; - u8 is_add = 1; - u8 *ls_name = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - is_add = 0; - else if (unformat (input, "locator-set %s", &ls_name)) - ls_name_set = 1; - else - { - errmsg ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!ls_name_set) - { - errmsg ("locator-set name not set!"); - return -99; - } - - M (ONE_PITR_SET_LOCATOR_SET, mp); - - mp->is_add = is_add; - clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name)); - vec_free (ls_name); - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -#define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set - -static int -api_one_nsh_set_locator_set (vat_main_t * vam) -{ - u8 ls_name_set = 0; - unformat_input_t *input = vam->input; - vl_api_one_nsh_set_locator_set_t *mp; - u8 is_add = 1; - u8 *ls_name = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - is_add = 0; - else if (unformat (input, "ls %s", &ls_name)) - ls_name_set = 1; - else - { - errmsg ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!ls_name_set && is_add) - { - errmsg ("locator-set name not set!"); - return -99; - } - - M (ONE_NSH_SET_LOCATOR_SET, mp); - - mp->is_add = is_add; - clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name)); - vec_free (ls_name); - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -static int -api_show_one_pitr (vat_main_t * vam) -{ - vl_api_show_one_pitr_t *mp; - int ret; - - if (!vam->json_output) - { - print (vam->ofp, "%=20s", "lisp status:"); - } - - M (SHOW_ONE_PITR, mp); - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_show_lisp_pitr api_show_one_pitr - -static int -api_one_use_petr (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_use_petr_t *mp; - u8 is_add = 0; - ip_address_t ip; - int ret; - - clib_memset (&ip, 0, sizeof (ip)); - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "disable")) - is_add = 0; - else - if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip))) - { - is_add = 1; - ip_addr_version (&ip) = AF_IP4; - } - else - if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip))) - { - is_add = 1; - ip_addr_version (&ip) = AF_IP6; - } - else - { - errmsg ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - M (ONE_USE_PETR, mp); - - mp->is_add = is_add; - if (is_add) - { - mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1; - if (mp->ip_address.af) - clib_memcpy (mp->ip_address.un.ip6, &ip, 16); - else - clib_memcpy (mp->ip_address.un.ip4, &ip, 4); - } - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -#define api_lisp_use_petr api_one_use_petr - -static int -api_show_one_nsh_mapping (vat_main_t * vam) -{ - vl_api_show_one_use_petr_t *mp; - int ret; - - if (!vam->json_output) - { - print (vam->ofp, "%=20s", "local ONE NSH mapping:"); - } - - M (SHOW_ONE_NSH_MAPPING, mp); - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_show_one_use_petr (vat_main_t * vam) -{ - vl_api_show_one_use_petr_t *mp; - int ret; - - if (!vam->json_output) - { - print (vam->ofp, "%=20s", "Proxy-ETR status:"); - } - - M (SHOW_ONE_USE_PETR, mp); - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_show_lisp_use_petr api_show_one_use_petr - -/** - * Add/delete mapping between vni and vrf - */ -static int -api_one_eid_table_add_del_map (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_eid_table_add_del_map_t *mp; - u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0; - u32 vni, vrf, bd_index; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - is_add = 0; - else if (unformat (input, "vrf %d", &vrf)) - vrf_set = 1; - else if (unformat (input, "bd_index %d", &bd_index)) - bd_index_set = 1; - else if (unformat (input, "vni %d", &vni)) - vni_set = 1; - else - break; - } - - if (!vni_set || (!vrf_set && !bd_index_set)) - { - errmsg ("missing arguments!"); - return -99; - } - - if (vrf_set && bd_index_set) - { - errmsg ("error: both vrf and bd entered!"); - return -99; - } - - M (ONE_EID_TABLE_ADD_DEL_MAP, mp); - - mp->is_add = is_add; - mp->vni = htonl (vni); - mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index); - mp->is_l2 = bd_index_set; - - /* send */ - S (mp); - - /* wait for reply */ - W (ret); - return ret; -} - -#define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map - -uword -unformat_negative_mapping_action (unformat_input_t * input, va_list * args) -{ - u32 *action = va_arg (*args, u32 *); - u8 *s = 0; - - if (unformat (input, "%s", &s)) - { - if (!strcmp ((char *) s, "no-action")) - action[0] = 0; - else if (!strcmp ((char *) s, "natively-forward")) - action[0] = 1; - else if (!strcmp ((char *) s, "send-map-request")) - action[0] = 2; - else if (!strcmp ((char *) s, "drop")) - action[0] = 3; - else - { - clib_warning ("invalid action: '%s'", s); - action[0] = 3; - } - } - else - return 0; - - vec_free (s); - return 1; -} - -/** - * Add/del remote mapping to/from ONE control plane - * - * @param vam vpp API test context - * @return return code - */ -static int -api_one_add_del_remote_mapping (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_add_del_remote_mapping_t *mp; - u32 vni = 0; - lisp_eid_vat_t _eid, *eid = &_eid; - lisp_eid_vat_t _seid, *seid = &_seid; - u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0; - u32 action = ~0, p, w, data_len; - ip4_address_t rloc4; - ip6_address_t rloc6; - vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0; - int ret; - - clib_memset (&rloc, 0, sizeof (rloc)); - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del-all")) - { - del_all = 1; - } - else if (unformat (input, "del")) - { - is_add = 0; - } - else if (unformat (input, "add")) - { - is_add = 1; - } - else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid)) - { - eid_set = 1; - } - else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid)) - { - seid_set = 1; - } - else if (unformat (input, "vni %d", &vni)) - { - ; - } - else if (unformat (input, "p %d w %d", &p, &w)) - { - if (!curr_rloc) - { - errmsg ("No RLOC configured for setting priority/weight!"); - return -99; - } - curr_rloc->priority = p; - curr_rloc->weight = w; - } - else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4)) - { - rloc.ip_address.af = 0; - clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6)); - vec_add1 (rlocs, rloc); - curr_rloc = &rlocs[vec_len (rlocs) - 1]; - } - else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6)) - { - rloc.ip_address.af = 1; - clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4)); - vec_add1 (rlocs, rloc); - curr_rloc = &rlocs[vec_len (rlocs) - 1]; - } - else if (unformat (input, "action %U", - unformat_negative_mapping_action, &action)) - { - ; - } - else - { - clib_warning ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (0 == eid_set) - { - errmsg ("missing params!"); - return -99; - } - - if (is_add && (~0 == action) && 0 == vec_len (rlocs)) - { - errmsg ("no action set for negative map-reply!"); - return -99; - } - - data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t); - - M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len); - mp->is_add = is_add; - mp->vni = htonl (vni); - mp->action = (u8) action; - mp->is_src_dst = seid_set; - mp->del_all = del_all; - lisp_eid_put_vat (&mp->deid, eid); - lisp_eid_put_vat (&mp->seid, seid); - - mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs)); - clib_memcpy (mp->rlocs, rlocs, data_len); - vec_free (rlocs); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping - -/** - * Add/del ONE adjacency. Saves mapping in ONE control plane and updates - * forwarding entries in data-plane accordingly. - * - * @param vam vpp API test context - * @return return code - */ -static int -api_one_add_del_adjacency (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_add_del_adjacency_t *mp; - u32 vni = 0; - u8 is_add = 1; - int ret; - lisp_eid_vat_t leid, reid; - - leid.type = reid.type = (u8) ~ 0; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - { - is_add = 0; - } - else if (unformat (input, "add")) - { - is_add = 1; - } - else if (unformat (input, "reid %U/%d", unformat_ip46_address, - &reid.addr.ip, &reid.len)) - { - reid.type = 0; /* ipv4 */ - } - else if (unformat (input, "reid %U", unformat_ethernet_address, - &reid.addr.mac)) - { - reid.type = 1; /* mac */ - } - else if (unformat (input, "leid %U/%d", unformat_ip46_address, - &leid.addr.ip, &leid.len)) - { - leid.type = 0; /* ipv4 */ - } - else if (unformat (input, "leid %U", unformat_ethernet_address, - &leid.addr.mac)) - { - leid.type = 1; /* mac */ - } - else if (unformat (input, "vni %d", &vni)) - { - ; - } - else - { - errmsg ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if ((u8) ~ 0 == reid.type) - { - errmsg ("missing params!"); - return -99; - } - - if (leid.type != reid.type) - { - errmsg ("remote and local EIDs are of different types!"); - return -99; - } - - M (ONE_ADD_DEL_ADJACENCY, mp); - mp->is_add = is_add; - mp->vni = htonl (vni); - lisp_eid_put_vat (&mp->leid, &leid); - lisp_eid_put_vat (&mp->reid, &reid); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_add_del_adjacency api_one_add_del_adjacency - -uword -unformat_gpe_encap_mode (unformat_input_t * input, va_list * args) -{ - u32 *mode = va_arg (*args, u32 *); - - if (unformat (input, "lisp")) - *mode = 0; - else if (unformat (input, "vxlan")) - *mode = 1; - else - return 0; - - return 1; -} - -static int -api_gpe_get_encap_mode (vat_main_t * vam) -{ - vl_api_gpe_get_encap_mode_t *mp; - int ret; - - /* Construct the API message */ - M (GPE_GET_ENCAP_MODE, mp); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_gpe_set_encap_mode (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_gpe_set_encap_mode_t *mp; - int ret; - u32 mode = 0; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "%U", unformat_gpe_encap_mode, &mode)) - ; - else - break; - } - - /* Construct the API message */ - M (GPE_SET_ENCAP_MODE, mp); - - mp->is_vxlan = mode; - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_lisp_gpe_add_del_iface (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_gpe_add_del_iface_t *mp; - u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0; - u32 dp_table = 0, vni = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "up")) - { - action_set = 1; - is_add = 1; - } - else if (unformat (input, "down")) - { - action_set = 1; - is_add = 0; - } - else if (unformat (input, "table_id %d", &dp_table)) - { - dp_table_set = 1; - } - else if (unformat (input, "bd_id %d", &dp_table)) - { - dp_table_set = 1; - is_l2 = 1; - } - else if (unformat (input, "vni %d", &vni)) - { - vni_set = 1; - } - else - break; - } - - if (action_set == 0) - { - errmsg ("Action not set"); - return -99; - } - if (dp_table_set == 0 || vni_set == 0) - { - errmsg ("vni and dp_table must be set"); - return -99; - } - - /* Construct the API message */ - M (GPE_ADD_DEL_IFACE, mp); - - mp->is_add = is_add; - mp->dp_table = clib_host_to_net_u32 (dp_table); - mp->is_l2 = is_l2; - mp->vni = clib_host_to_net_u32 (vni); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_one_map_register_fallback_threshold (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_map_register_fallback_threshold_t *mp; - u32 value = 0; - u8 is_set = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "%u", &value)) - is_set = 1; - else - { - clib_warning ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!is_set) - { - errmsg ("fallback threshold value is missing!"); - return -99; - } - - M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp); - mp->value = clib_host_to_net_u32 (value); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_show_one_map_register_fallback_threshold (vat_main_t * vam) -{ - vl_api_show_one_map_register_fallback_threshold_t *mp; - int ret; - - M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -uword -unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args) -{ - u32 *proto = va_arg (*args, u32 *); - - if (unformat (input, "udp")) - *proto = 1; - else if (unformat (input, "api")) - *proto = 2; - else - return 0; - - return 1; -} - -static int -api_one_set_transport_protocol (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_set_transport_protocol_t *mp; - u8 is_set = 0; - u32 protocol = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol)) - is_set = 1; - else - { - clib_warning ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!is_set) - { - errmsg ("Transport protocol missing!"); - return -99; - } - - M (ONE_SET_TRANSPORT_PROTOCOL, mp); - mp->protocol = (u8) protocol; - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_one_get_transport_protocol (vat_main_t * vam) -{ - vl_api_one_get_transport_protocol_t *mp; - int ret; - - M (ONE_GET_TRANSPORT_PROTOCOL, mp); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_one_map_register_set_ttl (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_map_register_set_ttl_t *mp; - u32 ttl = 0; - u8 is_set = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "%u", &ttl)) - is_set = 1; - else - { - clib_warning ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!is_set) - { - errmsg ("TTL value missing!"); - return -99; - } - - M (ONE_MAP_REGISTER_SET_TTL, mp); - mp->ttl = clib_host_to_net_u32 (ttl); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_show_one_map_register_ttl (vat_main_t * vam) -{ - vl_api_show_one_map_register_ttl_t *mp; - int ret; - - M (SHOW_ONE_MAP_REGISTER_TTL, mp); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -/** - * Add/del map request itr rlocs from ONE control plane and updates - * - * @param vam vpp API test context - * @return return code - */ -static int -api_one_add_del_map_request_itr_rlocs (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_add_del_map_request_itr_rlocs_t *mp; - u8 *locator_set_name = 0; - u8 locator_set_name_set = 0; - u8 is_add = 1; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "del")) - { - is_add = 0; - } - else if (unformat (input, "%_%v%_", &locator_set_name)) - { - locator_set_name_set = 1; - } - else - { - clib_warning ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (is_add && !locator_set_name_set) - { - errmsg ("itr-rloc is not set!"); - return -99; - } - - if (is_add && vec_len (locator_set_name) > 64) - { - errmsg ("itr-rloc locator-set name too long"); - vec_free (locator_set_name); - return -99; - } - - M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp); - mp->is_add = is_add; - if (is_add) - { - clib_memcpy (mp->locator_set_name, locator_set_name, - vec_len (locator_set_name)); - } - else - { - clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name)); - } - vec_free (locator_set_name); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs - -static int -api_one_locator_dump (vat_main_t * vam) -{ - unformat_input_t *input = vam->input; - vl_api_one_locator_dump_t *mp; - vl_api_control_ping_t *mp_ping; - u8 is_index_set = 0, is_name_set = 0; - u8 *ls_name = 0; - u32 ls_index = ~0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "ls_name %_%v%_", &ls_name)) - { - is_name_set = 1; - } - else if (unformat (input, "ls_index %d", &ls_index)) - { - is_index_set = 1; - } - else - { - errmsg ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!is_index_set && !is_name_set) - { - errmsg ("error: expected one of index or name!"); - return -99; - } - - if (is_index_set && is_name_set) - { - errmsg ("error: only one param expected!"); - return -99; - } - - if (vec_len (ls_name) > 62) - { - errmsg ("error: locator set name too long!"); - return -99; - } - - if (!vam->json_output) - { - print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight"); - } - - M (ONE_LOCATOR_DUMP, mp); - mp->is_index_set = is_index_set; - - if (is_index_set) - mp->ls_index = clib_host_to_net_u32 (ls_index); - else - { - vec_add1 (ls_name, 0); - strncpy ((char *) mp->ls_name, (char *) ls_name, - sizeof (mp->ls_name) - 1); - } - - /* send it... */ - S (mp); - - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_locator_dump api_one_locator_dump - -static int -api_one_locator_set_dump (vat_main_t * vam) -{ - vl_api_one_locator_set_dump_t *mp; - vl_api_control_ping_t *mp_ping; - unformat_input_t *input = vam->input; - u8 filter = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "local")) - { - filter = 1; - } - else if (unformat (input, "remote")) - { - filter = 2; - } - else - { - errmsg ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!vam->json_output) - { - print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name"); - } - - M (ONE_LOCATOR_SET_DUMP, mp); - - mp->filter = filter; - - /* send it... */ - S (mp); - - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_locator_set_dump api_one_locator_set_dump - -static int -api_one_eid_table_map_dump (vat_main_t * vam) -{ - u8 is_l2 = 0; - u8 mode_set = 0; - unformat_input_t *input = vam->input; - vl_api_one_eid_table_map_dump_t *mp; - vl_api_control_ping_t *mp_ping; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "l2")) - { - is_l2 = 1; - mode_set = 1; - } - else if (unformat (input, "l3")) - { - is_l2 = 0; - mode_set = 1; - } - else - { - errmsg ("parse error '%U'", format_unformat_error, input); - return -99; - } - } - - if (!mode_set) - { - errmsg ("expected one of 'l2' or 'l3' parameter!"); - return -99; - } - - if (!vam->json_output) - { - print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF"); - } - - M (ONE_EID_TABLE_MAP_DUMP, mp); - mp->is_l2 = is_l2; - - /* send it... */ - S (mp); - - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_eid_table_map_dump api_one_eid_table_map_dump - -static int -api_one_eid_table_vni_dump (vat_main_t * vam) -{ - vl_api_one_eid_table_vni_dump_t *mp; - vl_api_control_ping_t *mp_ping; - int ret; - - if (!vam->json_output) - { - print (vam->ofp, "VNI"); - } - - M (ONE_EID_TABLE_VNI_DUMP, mp); - - /* send it... */ - S (mp); - - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump - -static int -api_one_eid_table_dump (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_one_eid_table_dump_t *mp; - vl_api_control_ping_t *mp_ping; - u8 filter = 0; - int ret; - u32 vni, t = 0; - lisp_eid_vat_t eid; - u8 eid_set = 0; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat - (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len)) - { - eid_set = 1; - eid.type = 0; - } - else - if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac)) - { - eid_set = 1; - eid.type = 1; - } - else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh)) - { - eid_set = 1; - eid.type = 2; - } - else if (unformat (i, "vni %d", &t)) - { - vni = t; - } - else if (unformat (i, "local")) - { - filter = 1; - } - else if (unformat (i, "remote")) - { - filter = 2; - } - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - if (!vam->json_output) - { - print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID", - "type", "ls_index", "ttl", "authoritative", "key_id", "key"); - } - - M (ONE_EID_TABLE_DUMP, mp); - - mp->filter = filter; - if (eid_set) - { - mp->eid_set = 1; - mp->vni = htonl (vni); - lisp_eid_put_vat (&mp->eid, &eid); - } - - /* send it... */ - S (mp); - - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_eid_table_dump api_one_eid_table_dump - -static int -api_lisp_gpe_fwd_entries_get (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_gpe_fwd_entries_get_t *mp; - u8 vni_set = 0; - u32 vni = ~0; - int ret; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "vni %d", &vni)) - { - vni_set = 1; - } - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - if (!vni_set) - { - errmsg ("vni not set!"); - return -99; - } - - if (!vam->json_output) - { - print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table", - "leid", "reid"); - } - - M (GPE_FWD_ENTRIES_GET, mp); - mp->vni = clib_host_to_net_u32 (vni); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler -#define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler -#define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler -#define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler -#define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler -#define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler -#define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler -#define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler - -static int -api_one_adjacencies_get (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_one_adjacencies_get_t *mp; - u8 vni_set = 0; - u32 vni = ~0; - int ret; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "vni %d", &vni)) - { - vni_set = 1; - } - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - if (!vni_set) - { - errmsg ("vni not set!"); - return -99; - } - - if (!vam->json_output) - { - print (vam->ofp, "%s %40s", "leid", "reid"); - } - - M (ONE_ADJACENCIES_GET, mp); - mp->vni = clib_host_to_net_u32 (vni); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_adjacencies_get api_one_adjacencies_get - -static int -api_gpe_native_fwd_rpaths_get (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_gpe_native_fwd_rpaths_get_t *mp; - int ret; - u8 ip_family_set = 0, is_ip4 = 1; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "ip4")) - { - ip_family_set = 1; - is_ip4 = 1; - } - else if (unformat (i, "ip6")) - { - ip_family_set = 1; - is_ip4 = 0; - } - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - if (!ip_family_set) - { - errmsg ("ip family not set!"); - return -99; - } - - M (GPE_NATIVE_FWD_RPATHS_GET, mp); - mp->is_ip4 = is_ip4; - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_gpe_fwd_entry_vnis_get (vat_main_t * vam) -{ - vl_api_gpe_fwd_entry_vnis_get_t *mp; - int ret; - - if (!vam->json_output) - { - print (vam->ofp, "VNIs"); - } - - M (GPE_FWD_ENTRY_VNIS_GET, mp); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_gpe_add_del_native_fwd_rpath (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_gpe_add_del_native_fwd_rpath_t *mp; - int ret = 0; - u8 is_add = 1, ip_set = 0, is_ip4 = 1; - struct in_addr ip4; - struct in6_addr ip6; - u32 table_id = 0, nh_sw_if_index = ~0; - - clib_memset (&ip4, 0, sizeof (ip4)); - clib_memset (&ip6, 0, sizeof (ip6)); - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "del")) - is_add = 0; - else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4, - api_unformat_sw_if_index, vam, &nh_sw_if_index)) - { - ip_set = 1; - is_ip4 = 1; - } - else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6, - api_unformat_sw_if_index, vam, &nh_sw_if_index)) - { - ip_set = 1; - is_ip4 = 0; - } - else if (unformat (i, "via %U", unformat_ip4_address, &ip4)) - { - ip_set = 1; - is_ip4 = 1; - nh_sw_if_index = ~0; - } - else if (unformat (i, "via %U", unformat_ip6_address, &ip6)) - { - ip_set = 1; - is_ip4 = 0; - nh_sw_if_index = ~0; - } - else if (unformat (i, "table %d", &table_id)) - ; - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - if (!ip_set) - { - errmsg ("nh addr not set!"); - return -99; - } - - M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp); - mp->is_add = is_add; - mp->table_id = clib_host_to_net_u32 (table_id); - mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index); - mp->nh_addr.af = is_ip4 ? 0 : 1; - if (is_ip4) - clib_memcpy (mp->nh_addr.un.ip4, &ip4, sizeof (ip4)); - else - clib_memcpy (mp->nh_addr.un.ip6, &ip6, sizeof (ip6)); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_one_map_server_dump (vat_main_t * vam) -{ - vl_api_one_map_server_dump_t *mp; - vl_api_control_ping_t *mp_ping; - int ret; - - if (!vam->json_output) - { - print (vam->ofp, "%=20s", "Map server"); - } - - M (ONE_MAP_SERVER_DUMP, mp); - /* send it... */ - S (mp); - - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_map_server_dump api_one_map_server_dump - -static int -api_one_map_resolver_dump (vat_main_t * vam) -{ - vl_api_one_map_resolver_dump_t *mp; - vl_api_control_ping_t *mp_ping; - int ret; - - if (!vam->json_output) - { - print (vam->ofp, "%=20s", "Map resolver"); - } - - M (ONE_MAP_RESOLVER_DUMP, mp); - /* send it... */ - S (mp); - - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_map_resolver_dump api_one_map_resolver_dump - -static int -api_one_stats_flush (vat_main_t * vam) -{ - vl_api_one_stats_flush_t *mp; - int ret = 0; - - M (ONE_STATS_FLUSH, mp); - S (mp); - W (ret); - return ret; -} - -static int -api_one_stats_dump (vat_main_t * vam) -{ - vl_api_one_stats_dump_t *mp; - vl_api_control_ping_t *mp_ping; - int ret; - - M (ONE_STATS_DUMP, mp); - /* send it... */ - S (mp); - - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_show_one_status (vat_main_t * vam) -{ - vl_api_show_one_status_t *mp; - int ret; - - if (!vam->json_output) - { - print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set"); - } - - M (SHOW_ONE_STATUS, mp); - /* send it... */ - S (mp); - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_show_lisp_status api_show_one_status - -static int -api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam) -{ - vl_api_gpe_fwd_entry_path_dump_t *mp; - vl_api_control_ping_t *mp_ping; - unformat_input_t *i = vam->input; - u32 fwd_entry_index = ~0; - int ret; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "index %d", &fwd_entry_index)) - ; - else - break; - } - - if (~0 == fwd_entry_index) - { - errmsg ("no index specified!"); - return -99; - } - - if (!vam->json_output) - { - print (vam->ofp, "first line"); - } - - M (GPE_FWD_ENTRY_PATH_DUMP, mp); - - /* send it... */ - S (mp); - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_one_get_map_request_itr_rlocs (vat_main_t * vam) -{ - vl_api_one_get_map_request_itr_rlocs_t *mp; - int ret; - - if (!vam->json_output) - { - print (vam->ofp, "%=20s", "itr-rlocs:"); - } - - M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp); - /* send it... */ - S (mp); - /* Wait for a reply... */ - W (ret); - return ret; -} - -#define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs - static int api_af_packet_create (vat_main_t * vam) { @@ -20187,128 +15281,6 @@ _(get_node_graph, " ") \ _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \ _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \ _(ioam_disable, "") \ -_(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \ - " sw_if_index <sw_if_index> p <priority> " \ - "w <weight>] [del]") \ -_(one_add_del_locator, "locator-set <locator_name> " \ - "iface <intf> | sw_if_index <sw_if_index> " \ - "p <priority> w <weight> [del]") \ -_(one_add_del_local_eid,"vni <vni> eid " \ - "<ipv4|ipv6>/<prefix> | <L2 address> " \ - "locator-set <locator_name> [del]" \ - "[key-id sha1|sha256 secret-key <secret-key>]")\ -_(one_add_del_map_resolver, "<ip4|6-addr> [del]") \ -_(one_add_del_map_server, "<ip4|6-addr> [del]") \ -_(one_enable_disable, "enable|disable") \ -_(one_map_register_enable_disable, "enable|disable") \ -_(one_map_register_fallback_threshold, "<value>") \ -_(one_rloc_probe_enable_disable, "enable|disable") \ -_(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \ - "[seid <seid>] " \ - "rloc <locator> p <prio> " \ - "w <weight> [rloc <loc> ... ] " \ - "action <action> [del-all]") \ -_(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \ - "<local-eid>") \ -_(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \ -_(one_use_petr, "ip-address> | disable") \ -_(one_map_request_mode, "src-dst|dst-only") \ -_(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \ -_(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \ -_(one_locator_set_dump, "[local | remote]") \ -_(one_locator_dump, "ls_index <index> | ls_name <name>") \ -_(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \ - "[local] | [remote]") \ -_(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \ -_(one_ndp_bd_get, "") \ -_(one_ndp_entries_get, "bd <bridge-domain>") \ -_(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip <ip4>") \ -_(one_l2_arp_bd_get, "") \ -_(one_l2_arp_entries_get, "bd <bridge-domain>") \ -_(one_stats_enable_disable, "enable|disable") \ -_(show_one_stats_enable_disable, "") \ -_(one_eid_table_vni_dump, "") \ -_(one_eid_table_map_dump, "l2|l3") \ -_(one_map_resolver_dump, "") \ -_(one_map_server_dump, "") \ -_(one_adjacencies_get, "vni <vni>") \ -_(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \ -_(show_one_rloc_probe_state, "") \ -_(show_one_map_register_state, "") \ -_(show_one_status, "") \ -_(one_stats_dump, "") \ -_(one_stats_flush, "") \ -_(one_get_map_request_itr_rlocs, "") \ -_(one_map_register_set_ttl, "<ttl>") \ -_(one_set_transport_protocol, "udp|api") \ -_(one_get_transport_protocol, "") \ -_(one_enable_disable_xtr_mode, "enable|disable") \ -_(one_show_xtr_mode, "") \ -_(one_enable_disable_pitr_mode, "enable|disable") \ -_(one_show_pitr_mode, "") \ -_(one_enable_disable_petr_mode, "enable|disable") \ -_(one_show_petr_mode, "") \ -_(show_one_nsh_mapping, "") \ -_(show_one_pitr, "") \ -_(show_one_use_petr, "") \ -_(show_one_map_request_mode, "") \ -_(show_one_map_register_ttl, "") \ -_(show_one_map_register_fallback_threshold, "") \ -_(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\ - " sw_if_index <sw_if_index> p <priority> " \ - "w <weight>] [del]") \ -_(lisp_add_del_locator, "locator-set <locator_name> " \ - "iface <intf> | sw_if_index <sw_if_index> " \ - "p <priority> w <weight> [del]") \ -_(lisp_add_del_local_eid,"vni <vni> eid " \ - "<ipv4|ipv6>/<prefix> | <L2 address> " \ - "locator-set <locator_name> [del]" \ - "[key-id sha1|sha256 secret-key <secret-key>]") \ -_(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \ -_(lisp_add_del_map_server, "<ip4|6-addr> [del]") \ -_(lisp_enable_disable, "enable|disable") \ -_(lisp_map_register_enable_disable, "enable|disable") \ -_(lisp_rloc_probe_enable_disable, "enable|disable") \ -_(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \ - "[seid <seid>] " \ - "rloc <locator> p <prio> " \ - "w <weight> [rloc <loc> ... ] " \ - "action <action> [del-all]") \ -_(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \ - "<local-eid>") \ -_(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \ -_(lisp_use_petr, "<ip-address> | disable") \ -_(lisp_map_request_mode, "src-dst|dst-only") \ -_(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \ -_(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \ -_(lisp_locator_set_dump, "[local | remote]") \ -_(lisp_locator_dump, "ls_index <index> | ls_name <name>") \ -_(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \ - "[local] | [remote]") \ -_(lisp_eid_table_vni_dump, "") \ -_(lisp_eid_table_map_dump, "l2|l3") \ -_(lisp_map_resolver_dump, "") \ -_(lisp_map_server_dump, "") \ -_(lisp_adjacencies_get, "vni <vni>") \ -_(gpe_fwd_entry_vnis_get, "") \ -_(gpe_native_fwd_rpaths_get, "ip4 | ip6") \ -_(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \ - "[table <table-id>]") \ -_(lisp_gpe_fwd_entries_get, "vni <vni>") \ -_(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \ -_(gpe_set_encap_mode, "lisp|vxlan") \ -_(gpe_get_encap_mode, "") \ -_(lisp_gpe_add_del_iface, "up|down") \ -_(lisp_gpe_enable_disable, "enable|disable") \ -_(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \ - "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \ -_(show_lisp_rloc_probe_state, "") \ -_(show_lisp_map_register_state, "") \ -_(show_lisp_status, "") \ -_(lisp_get_map_request_itr_rlocs, "") \ -_(show_lisp_pitr, "") \ -_(show_lisp_use_petr, "") \ -_(show_lisp_map_request_mode, "") \ _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \ _(af_packet_delete, "name <host interface name>") \ _(af_packet_dump, "") \ |