summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vat/api_format.c1661
-rw-r--r--src/vnet/ip/ip4.h2
-rw-r--r--src/vnet/ip/ip_api.c116
-rw-r--r--src/vnet/vnet_all_api_h.h1
-rw-r--r--src/vpp/api/api.c1
5 files changed, 88 insertions, 1693 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 1b77fb8bcb3..52eb5aeb4eb 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -568,51 +568,6 @@ format_ethernet_address (u8 * s, va_list * args)
}
#endif
-static void
-increment_v4_address (vl_api_ip4_address_t * i)
-{
- ip4_address_t *a = (ip4_address_t *) i;
- u32 v;
-
- v = ntohl (a->as_u32) + 1;
- a->as_u32 = ntohl (v);
-}
-
-static void
-increment_v6_address (vl_api_ip6_address_t * i)
-{
- ip6_address_t *a = (ip6_address_t *) i;
- u64 v0, v1;
-
- v0 = clib_net_to_host_u64 (a->as_u64[0]);
- v1 = clib_net_to_host_u64 (a->as_u64[1]);
-
- v1 += 1;
- if (v1 == 0)
- v0 += 1;
- a->as_u64[0] = clib_net_to_host_u64 (v0);
- a->as_u64[1] = clib_net_to_host_u64 (v1);
-}
-
-static void
-increment_address (vl_api_address_t * a)
-{
- if (a->af == ADDRESS_IP4)
- increment_v4_address (&a->un.ip4);
- else if (a->af == ADDRESS_IP6)
- increment_v6_address (&a->un.ip6);
-}
-
-static void
-set_ip4_address (vl_api_address_t * a, u32 v)
-{
- if (a->af == ADDRESS_IP4)
- {
- ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
- i->as_u32 = v;
- }
-}
-
void
ip_set (ip46_address_t * dst, void *src, u8 is_ip4)
{
@@ -623,33 +578,6 @@ ip_set (ip46_address_t * dst, void *src, u8 is_ip4)
sizeof (ip6_address_t));
}
-static void
-vat_json_object_add_address (vat_json_node_t * node,
- const char *str, const vl_api_address_t * addr)
-{
- if (ADDRESS_IP6 == addr->af)
- {
- struct in6_addr ip6;
-
- clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
- vat_json_object_add_ip6 (node, str, ip6);
- }
- else
- {
- struct in_addr ip4;
-
- clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
- vat_json_object_add_ip4 (node, str, ip4);
- }
-}
-
-static void
-vat_json_object_add_prefix (vat_json_node_t * node,
- const vl_api_prefix_t * prefix)
-{
- vat_json_object_add_uint (node, "len", prefix->len);
- vat_json_object_add_address (node, "address", &prefix->address);
-}
static void vl_api_create_loopback_reply_t_handler
(vl_api_create_loopback_reply_t * mp)
@@ -1245,89 +1173,6 @@ static void vl_api_control_ping_reply_t_handler_json
}
-static void vl_api_ip_address_details_t_handler
- (vl_api_ip_address_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- static ip_address_details_t empty_ip_address_details = { {0} };
- ip_address_details_t *address = NULL;
- ip_details_t *current_ip_details = NULL;
- ip_details_t *details = NULL;
-
- details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
-
- if (!details || vam->current_sw_if_index >= vec_len (details)
- || !details[vam->current_sw_if_index].present)
- {
- errmsg ("ip address details arrived but not stored");
- errmsg ("ip_dump should be called first");
- return;
- }
-
- current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
-
-#define addresses (current_ip_details->addr)
-
- vec_validate_init_empty (addresses, vec_len (addresses),
- empty_ip_address_details);
-
- address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
-
- clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
- address->prefix_length = mp->prefix.len;
-#undef addresses
-}
-
-static void vl_api_ip_address_details_t_handler_json
- (vl_api_ip_address_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_prefix (node, &mp->prefix);
-}
-
-static void
-vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- static ip_details_t empty_ip_details = { 0 };
- ip_details_t *ip = NULL;
- u32 sw_if_index = ~0;
-
- sw_if_index = ntohl (mp->sw_if_index);
-
- vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
- sw_if_index, empty_ip_details);
-
- ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
- sw_if_index);
-
- ip->present = 1;
-}
-
-static void
-vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- vat_json_array_add_uint (&vam->json_tree,
- clib_net_to_host_u32 (mp->sw_if_index));
-}
-
static void vl_api_get_first_msg_id_reply_t_handler
(vl_api_get_first_msg_id_reply_t * mp)
{
@@ -1492,33 +1337,20 @@ format_hex_bytes (u8 * s, va_list * va)
* a single function, but that could break in subtle ways.
*/
-#define foreach_standard_reply_retval_handler \
-_(sw_interface_set_flags_reply) \
-_(sw_interface_add_del_address_reply) \
-_(sw_interface_set_rx_placement_reply) \
-_(sw_interface_set_table_reply) \
-_(ip_route_add_del_reply) \
-_(ip_table_add_del_reply) \
-_(ip_table_replace_begin_reply) \
-_(ip_table_flush_reply) \
-_(ip_table_replace_end_reply) \
-_(ip_mroute_add_del_reply) \
-_(sw_interface_set_unnumbered_reply) \
-_(set_ip_flow_hash_reply) \
-_(sw_interface_ip6_enable_disable_reply) \
-_(delete_loopback_reply) \
-_(want_interface_events_reply) \
-_(sw_interface_clear_stats_reply) \
-_(ioam_enable_reply) \
-_(ioam_disable_reply) \
-_(ip_source_and_port_range_check_add_del_reply) \
-_(ip_source_and_port_range_check_interface_add_del_reply)\
-_(delete_subif_reply) \
-_(sw_interface_tag_add_del_reply) \
-_(sw_interface_add_del_mac_address_reply) \
-_(hw_interface_set_mtu_reply) \
-_(session_rule_add_del_reply) \
-_(ip_container_proxy_add_del_reply) \
+#define foreach_standard_reply_retval_handler \
+ _ (sw_interface_set_flags_reply) \
+ _ (sw_interface_add_del_address_reply) \
+ _ (sw_interface_set_rx_placement_reply) \
+ _ (sw_interface_set_unnumbered_reply) \
+ _ (sw_interface_set_table_reply) \
+ _ (delete_loopback_reply) \
+ _ (want_interface_events_reply) \
+ _ (sw_interface_clear_stats_reply) \
+ _ (delete_subif_reply) \
+ _ (sw_interface_tag_add_del_reply) \
+ _ (sw_interface_add_del_mac_address_reply) \
+ _ (hw_interface_set_mtu_reply) \
+ _ (session_rule_add_del_reply)
#define _(n) \
static void vl_api_##n##_t_handler \
@@ -1569,41 +1401,22 @@ _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
_(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
_(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
_(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
-_(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
-_(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
-_(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
-_(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
-_(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
-_(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
_(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
sw_interface_set_unnumbered_reply) \
_(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
_(CREATE_SUBIF_REPLY, create_subif_reply) \
-_(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
-_(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
- sw_interface_ip6_enable_disable_reply) \
_(GET_NODE_INDEX_REPLY, get_node_index_reply) \
_(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
_(SHOW_VERSION_REPLY, show_version_reply) \
_(SHOW_THREADS_REPLY, show_threads_reply) \
_(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
-_(IP_ADDRESS_DETAILS, ip_address_details) \
-_(IP_DETAILS, ip_details) \
_(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
_(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
_(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
_(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) \
_(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
-_(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
- ip_source_and_port_range_check_add_del_reply) \
-_(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
- ip_source_and_port_range_check_interface_add_del_reply) \
_(DELETE_SUBIF_REPLY, delete_subif_reply) \
-_(IP_TABLE_DETAILS, ip_table_details) \
-_(IP_ROUTE_DETAILS, ip_route_details) \
_(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
_(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
_(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
@@ -1611,7 +1424,6 @@ _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
_(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
_(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
_(SESSION_RULES_DETAILS, session_rules_details) \
-_(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
#define foreach_standalone_reply_msg \
_(SW_INTERFACE_EVENT, sw_interface_event)
@@ -1728,66 +1540,6 @@ dump_interface_table (vat_main_t * vam)
return 0;
}
-static int
-dump_ip_table (vat_main_t * vam, int is_ipv6)
-{
- const ip_details_t *det = NULL;
- const ip_address_details_t *address = NULL;
- u32 i = ~0;
-
- print (vam->ofp, "%-12s", "sw_if_index");
-
- vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
- {
- i++;
- if (!det->present)
- {
- continue;
- }
- print (vam->ofp, "%-12d", i);
- print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
- if (!det->addr)
- {
- continue;
- }
- vec_foreach (address, det->addr)
- {
- print (vam->ofp,
- " %-30U%-13d",
- is_ipv6 ? format_ip6_address : format_ip4_address,
- address->ip, address->prefix_length);
- }
- }
-
- return 0;
-}
-
-static int
-dump_ipv4_table (vat_main_t * vam)
-{
- if (vam->json_output)
- {
- clib_warning
- ("JSON output supported only for VPE API calls and dump_stats_table");
- return -99;
- }
-
- return dump_ip_table (vam, 0);
-}
-
-static int
-dump_ipv6_table (vat_main_t * vam)
-{
- if (vam->json_output)
- {
- clib_warning
- ("JSON output supported only for VPE API calls and dump_stats_table");
- return -99;
- }
-
- return dump_ip_table (vam, 1);
-}
-
/*
* Pass CLI buffers directly in the CLI_INBAND API message,
* instead of an additional shared memory area.
@@ -2416,56 +2168,6 @@ unformat_vlib_pci_addr (unformat_input_t *input, va_list *args)
return 1;
}
-static int
-api_ip_table_add_del (vat_main_t *vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ip_table_add_del_t *mp;
- u32 table_id = ~0;
- u8 is_ipv6 = 0;
- u8 is_add = 1;
- int ret = 0;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "add"))
- is_add = 1;
- else if (unformat (i, "table %d", &table_id))
- ;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (~0 == table_id)
- {
- errmsg ("missing table-ID");
- return -99;
- }
-
- /* Construct the API message */
- M (IP_TABLE_ADD_DEL, mp);
-
- mp->table.table_id = ntohl (table_id);
- mp->table.is_ip6 = is_ipv6;
- mp->is_add = is_add;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
-
- return ret;
-}
-
uword
unformat_fib_path (unformat_input_t *input, va_list *args)
{
@@ -2606,254 +2308,7 @@ unformat_fib_path (unformat_input_t *input, va_list *args)
}
static int
-api_ip_route_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ip_route_add_del_t *mp;
- u32 vrf_id = 0;
- u8 is_add = 1;
- u8 is_multipath = 0;
- u8 prefix_set = 0;
- u8 path_count = 0;
- vl_api_prefix_t pfx = { };
- vl_api_fib_path_t paths[8];
- int count = 1;
- int j;
- f64 before = 0;
- u32 random_add_del = 0;
- u32 *random_vector = 0;
- u32 random_seed = 0xdeaddabe;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
- prefix_set = 1;
- else if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "add"))
- is_add = 1;
- else if (unformat (i, "vrf %d", &vrf_id))
- ;
- else if (unformat (i, "count %d", &count))
- ;
- else if (unformat (i, "random"))
- random_add_del = 1;
- else if (unformat (i, "multipath"))
- is_multipath = 1;
- else if (unformat (i, "seed %d", &random_seed))
- ;
- else
- if (unformat
- (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
- {
- path_count++;
- if (8 == path_count)
- {
- errmsg ("max 8 paths");
- return -99;
- }
- }
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (!path_count)
- {
- errmsg ("specify a path; via ...");
- return -99;
- }
- if (prefix_set == 0)
- {
- errmsg ("missing prefix");
- return -99;
- }
-
- /* Generate a pile of unique, random routes */
- if (random_add_del)
- {
- ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
- u32 this_random_address;
- uword *random_hash;
-
- random_hash = hash_create (count, sizeof (uword));
-
- hash_set (random_hash, i->as_u32, 1);
- for (j = 0; j <= count; j++)
- {
- do
- {
- this_random_address = random_u32 (&random_seed);
- this_random_address =
- clib_host_to_net_u32 (this_random_address);
- }
- while (hash_get (random_hash, this_random_address));
- vec_add1 (random_vector, this_random_address);
- hash_set (random_hash, this_random_address, 1);
- }
- hash_free (random_hash);
- set_ip4_address (&pfx.address, random_vector[0]);
- }
-
- if (count > 1)
- {
- /* Turn on async mode */
- vam->async_mode = 1;
- vam->async_errors = 0;
- before = vat_time_now (vam);
- }
-
- for (j = 0; j < count; j++)
- {
- /* Construct the API message */
- M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
-
- mp->is_add = is_add;
- mp->is_multipath = is_multipath;
-
- clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
- mp->route.table_id = ntohl (vrf_id);
- mp->route.n_paths = path_count;
-
- clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
-
- if (random_add_del)
- set_ip4_address (&pfx.address, random_vector[j + 1]);
- else
- increment_address (&pfx.address);
- /* send it... */
- S (mp);
- /* If we receive SIGTERM, stop now... */
- if (vam->do_exit)
- break;
- }
-
- /* When testing multiple add/del ops, use a control-ping to sync */
- if (count > 1)
- {
- vl_api_control_ping_t *mp_ping;
- f64 after;
- f64 timeout;
-
- /* Shut off async mode */
- vam->async_mode = 0;
-
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- timeout = vat_time_now (vam) + 1.0;
- while (vat_time_now (vam) < timeout)
- if (vam->result_ready == 1)
- goto out;
- vam->retval = -99;
-
- out:
- if (vam->retval == -99)
- errmsg ("timeout");
-
- if (vam->async_errors > 0)
- {
- errmsg ("%d asynchronous errors", vam->async_errors);
- vam->retval = -98;
- }
- vam->async_errors = 0;
- after = vat_time_now (vam);
-
- /* slim chance, but we might have eaten SIGTERM on the first iteration */
- if (j > 0)
- count = j;
-
- print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
- count, after - before, count / (after - before));
- }
- else
- {
- int ret;
-
- /* Wait for a reply... */
- W (ret);
- return ret;
- }
-
- /* Return the good/bad news */
- return (vam->retval);
-}
-
-static int
-api_ip_mroute_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- u8 path_set = 0, prefix_set = 0, is_add = 1;
- vl_api_ip_mroute_add_del_t *mp;
- mfib_entry_flags_t eflags = 0;
- vl_api_mfib_path_t path;
- vl_api_mprefix_t pfx = { };
- u32 vrf_id = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
- {
- prefix_set = 1;
- pfx.grp_address_length = htons (pfx.grp_address_length);
- }
- else if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "add"))
- is_add = 1;
- else if (unformat (i, "vrf %d", &vrf_id))
- ;
- else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
- path.itf_flags = htonl (path.itf_flags);
- else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
- ;
- else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
- path_set = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (prefix_set == 0)
- {
- errmsg ("missing addresses\n");
- return -99;
- }
- if (path_set == 0)
- {
- errmsg ("missing path\n");
- return -99;
- }
-
- /* Construct the API message */
- M (IP_MROUTE_ADD_DEL, mp);
-
- mp->is_add = is_add;
- mp->is_multipath = 1;
-
- clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
- mp->route.table_id = htonl (vrf_id);
- mp->route.n_paths = 1;
- mp->route.entry_flags = htonl (eflags);
-
- clib_memcpy (&mp->route.paths, &path, sizeof (path));
-
- /* send it... */
- S (mp);
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_unnumbered (vat_main_t * vam)
+api_sw_interface_set_unnumbered (vat_main_t *vam)
{
unformat_input_t *i = vam->input;
vl_api_sw_interface_set_unnumbered_t *mp;
@@ -2897,9 +2352,8 @@ api_sw_interface_set_unnumbered (vat_main_t * vam)
return ret;
}
-
static int
-api_create_vlan_subif (vat_main_t * vam)
+api_create_vlan_subif (vat_main_t *vam)
{
unformat_input_t *i = vam->input;
vl_api_create_vlan_subif_t *mp;
@@ -2913,8 +2367,7 @@ api_create_vlan_subif (vat_main_t * vam)
{
if (unformat (i, "sw_if_index %d", &sw_if_index))
sw_if_index_set = 1;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ else if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
sw_if_index_set = 1;
else if (unformat (i, "vlan %d", &vlan_id))
vlan_id_set = 1;
@@ -3040,208 +2493,6 @@ api_create_subif (vat_main_t * vam)
return ret;
}
-static int
-api_ip_table_replace_begin (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ip_table_replace_begin_t *mp;
- u32 table_id = 0;
- u8 is_ipv6 = 0;
-
- int ret;
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "table %d", &table_id))
- ;
- else if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- M (IP_TABLE_REPLACE_BEGIN, mp);
-
- mp->table.table_id = ntohl (table_id);
- mp->table.is_ip6 = is_ipv6;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_ip_table_flush (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ip_table_flush_t *mp;
- u32 table_id = 0;
- u8 is_ipv6 = 0;
-
- int ret;
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "table %d", &table_id))
- ;
- else if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- M (IP_TABLE_FLUSH, mp);
-
- mp->table.table_id = ntohl (table_id);
- mp->table.is_ip6 = is_ipv6;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_ip_table_replace_end (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ip_table_replace_end_t *mp;
- u32 table_id = 0;
- u8 is_ipv6 = 0;
-
- int ret;
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "table %d", &table_id))
- ;
- else if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- M (IP_TABLE_REPLACE_END, mp);
-
- mp->table.table_id = ntohl (table_id);
- mp->table.is_ip6 = is_ipv6;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_set_ip_flow_hash (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_set_ip_flow_hash_t *mp;
- u32 vrf_id = 0;
- u8 is_ipv6 = 0;
- u8 vrf_id_set = 0;
- u8 src = 0;
- u8 dst = 0;
- u8 sport = 0;
- u8 dport = 0;
- u8 proto = 0;
- u8 reverse = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "vrf %d", &vrf_id))
- vrf_id_set = 1;
- else if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else if (unformat (i, "src"))
- src = 1;
- else if (unformat (i, "dst"))
- dst = 1;
- else if (unformat (i, "sport"))
- sport = 1;
- else if (unformat (i, "dport"))
- dport = 1;
- else if (unformat (i, "proto"))
- proto = 1;
- else if (unformat (i, "reverse"))
- reverse = 1;
-
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (vrf_id_set == 0)
- {
- errmsg ("missing vrf id");
- return -99;
- }
-
- M (SET_IP_FLOW_HASH, mp);
- mp->src = src;
- mp->dst = dst;
- mp->sport = sport;
- mp->dport = dport;
- mp->proto = proto;
- mp->reverse = reverse;
- mp->vrf_id = ntohl (vrf_id);
- mp->is_ipv6 = is_ipv6;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_ip6_enable_disable (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_ip6_enable_disable_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 enable = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "enable"))
- enable = 1;
- else if (unformat (i, "disable"))
- enable = 0;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->enable = enable;
-
- S (mp);
- W (ret);
- return ret;
-}
-
u8 is_del;
u8 localsid_addr[16];
u8 end_psp;
@@ -3251,73 +2502,23 @@ u32 vlan_index;
u32 fib_table;
u8 nh_addr[16];
-static int
-api_ioam_enable (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_ioam_enable_t *mp;
- u32 id = 0;
- int has_trace_option = 0;
- int has_pot_option = 0;
- int has_seqno_option = 0;
- int has_analyse_option = 0;
- int ret;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "trace"))
- has_trace_option = 1;
- else if (unformat (input, "pot"))
- has_pot_option = 1;
- else if (unformat (input, "seqno"))
- has_seqno_option = 1;
- else if (unformat (input, "analyse"))
- has_analyse_option = 1;
- else
- break;
- }
- M (IOAM_ENABLE, mp);
- mp->id = htons (id);
- mp->seqno = has_seqno_option;
- mp->analyse = has_analyse_option;
- mp->pot_enable = has_pot_option;
- mp->trace_enable = has_trace_option;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-
-static int
-api_ioam_disable (vat_main_t * vam)
-{
- vl_api_ioam_disable_t *mp;
- int ret;
-
- M (IOAM_DISABLE, mp);
- S (mp);
- W (ret);
- return ret;
-}
-
-#define foreach_tcp_proto_field \
-_(src_port) \
-_(dst_port)
+#define foreach_tcp_proto_field \
+ _ (src_port) \
+ _ (dst_port)
-#define foreach_udp_proto_field \
-_(src_port) \
-_(dst_port)
+#define foreach_udp_proto_field \
+ _ (src_port) \
+ _ (dst_port)
-#define foreach_ip4_proto_field \
-_(src_address) \
-_(dst_address) \
-_(tos) \
-_(length) \
-_(fragment_id) \
-_(ttl) \
-_(protocol) \
-_(checksum)
+#define foreach_ip4_proto_field \
+ _ (src_address) \
+ _ (dst_address) \
+ _ (tos) \
+ _ (length) \
+ _ (fragment_id) \
+ _ (ttl) \
+ _ (protocol) \
+ _ (checksum)
typedef struct
{
@@ -3326,25 +2527,25 @@ typedef struct
#if VPP_API_TEST_BUILTIN == 0
uword
-unformat_tcp_mask (unformat_input_t * input, va_list * args)
+unformat_tcp_mask (unformat_input_t *input, va_list *args)
{
u8 **maskp = va_arg (*args, u8 **);
u8 *mask = 0;
u8 found_something = 0;
tcp_header_t *tcp;
-#define _(a) u8 a=0;
+#define _(a) u8 a = 0;
foreach_tcp_proto_field;
#undef _
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
- if (0);
-#define _(a) else if (unformat (input, #a)) a=1;
+ if (0)
+ ;
+#define _(a) else if (unformat (input, #a)) a = 1;
foreach_tcp_proto_field
#undef _
- else
- break;
+ else break;
}
#define _(a) found_something += a;
@@ -3358,7 +2559,9 @@ unformat_tcp_mask (unformat_input_t * input, va_list * args)
tcp = (tcp_header_t *) mask;
-#define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
+#define _(a) \
+ if (a) \
+ clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
foreach_tcp_proto_field;
#undef _
@@ -3367,25 +2570,25 @@ unformat_tcp_mask (unformat_input_t * input, va_list * args)
}
uword
-unformat_udp_mask (unformat_input_t * input, va_list * args)
+unformat_udp_mask (unformat_input_t *input, va_list *args)
{
u8 **maskp = va_arg (*args, u8 **);
u8 *mask = 0;
u8 found_something = 0;
udp_header_t *udp;
-#define _(a) u8 a=0;
+#define _(a) u8 a = 0;
foreach_udp_proto_field;
#undef _
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
- if (0);
-#define _(a) else if (unformat (input, #a)) a=1;
+ if (0)
+ ;
+#define _(a) else if (unformat (input, #a)) a = 1;
foreach_udp_proto_field
#undef _
- else
- break;
+ else break;
}
#define _(a) found_something += a;
@@ -3399,7 +2602,9 @@ unformat_udp_mask (unformat_input_t * input, va_list * args)
udp = (udp_header_t *) mask;
-#define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
+#define _(a) \
+ if (a) \
+ clib_memset (&udp->a, 0xff, sizeof (udp->a));
foreach_udp_proto_field;
#undef _
@@ -3408,7 +2613,7 @@ unformat_udp_mask (unformat_input_t * input, va_list * args)
}
uword
-unformat_l4_mask (unformat_input_t * input, va_list * args)
+unformat_l4_mask (unformat_input_t *input, va_list *args)
{
u8 **maskp = va_arg (*args, u8 **);
u16 src_port = 0, dst_port = 0;
@@ -4368,7 +3573,7 @@ api_unformat_classify_match (unformat_input_t * input, va_list * args)
}
static int
-api_get_node_index (vat_main_t * vam)
+api_get_node_index (vat_main_t *vam)
{
unformat_input_t *i = vam->input;
vl_api_get_node_index_t *mp;
@@ -4403,7 +3608,7 @@ api_get_node_index (vat_main_t * vam)
}
static int
-api_get_next_index (vat_main_t * vam)
+api_get_next_index (vat_main_t *vam)
{
unformat_input_t *i = vam->input;
vl_api_get_next_index_t *mp;
@@ -4452,7 +3657,7 @@ api_get_next_index (vat_main_t * vam)
}
static int
-api_add_node_next (vat_main_t * vam)
+api_add_node_next (vat_main_t *vam)
{
unformat_input_t *i = vam->input;
vl_api_add_node_next_t *mp;
@@ -4501,16 +3706,16 @@ api_add_node_next (vat_main_t * vam)
return ret;
}
-#define foreach_vtr_op \
-_("disable", L2_VTR_DISABLED) \
-_("push-1", L2_VTR_PUSH_1) \
-_("push-2", L2_VTR_PUSH_2) \
-_("pop-1", L2_VTR_POP_1) \
-_("pop-2", L2_VTR_POP_2) \
-_("translate-1-1", L2_VTR_TRANSLATE_1_1) \
-_("translate-1-2", L2_VTR_TRANSLATE_1_2) \
-_("translate-2-1", L2_VTR_TRANSLATE_2_1) \
-_("translate-2-2", L2_VTR_TRANSLATE_2_2)
+#define foreach_vtr_op \
+ _ ("disable", L2_VTR_DISABLED) \
+ _ ("push-1", L2_VTR_PUSH_1) \
+ _ ("push-2", L2_VTR_PUSH_2) \
+ _ ("pop-1", L2_VTR_POP_1) \
+ _ ("pop-2", L2_VTR_POP_2) \
+ _ ("translate-1-1", L2_VTR_TRANSLATE_1_1) \
+ _ ("translate-1-2", L2_VTR_TRANSLATE_1_2) \
+ _ ("translate-2-1", L2_VTR_TRANSLATE_2_1) \
+ _ ("translate-2-2", L2_VTR_TRANSLATE_2_2)
static int
api_show_version (vat_main_t *vam)
@@ -4571,123 +3776,7 @@ api_interface_name_renumber (vat_main_t *vam)
}
static int
-api_ip_address_dump (vat_main_t *vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ip_address_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- u32 sw_if_index = ~0;
- u8 sw_if_index_set = 0;
- u8 ipv4_set = 0;
- u8 ipv6_set = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "ipv4"))
- ipv4_set = 1;
- else if (unformat (i, "ipv6"))
- ipv6_set = 1;
- else
- break;
- }
-
- if (ipv4_set && ipv6_set)
- {
- errmsg ("ipv4 and ipv6 flags cannot be both set");
- return -99;
- }
-
- if ((!ipv4_set) && (!ipv6_set))
- {
- errmsg ("no ipv4 nor ipv6 flag set");
- return -99;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- vam->current_sw_if_index = sw_if_index;
- vam->is_ipv6 = ipv6_set;
-
- M (IP_ADDRESS_DUMP, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->is_ipv6 = ipv6_set;
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static int
-api_ip_dump (vat_main_t * vam)
-{
- vl_api_ip_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- unformat_input_t *in = vam->input;
- int ipv4_set = 0;
- int ipv6_set = 0;
- int is_ipv6;
- int i;
- int ret;
-
- while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (in, "ipv4"))
- ipv4_set = 1;
- else if (unformat (in, "ipv6"))
- ipv6_set = 1;
- else
- break;
- }
-
- if (ipv4_set && ipv6_set)
- {
- errmsg ("ipv4 and ipv6 flags cannot be both set");
- return -99;
- }
-
- if ((!ipv4_set) && (!ipv6_set))
- {
- errmsg ("no ipv4 nor ipv6 flag set");
- return -99;
- }
-
- is_ipv6 = ipv6_set;
- vam->is_ipv6 = is_ipv6;
-
- /* free old data */
- for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
- {
- vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
- }
- vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
-
- M (IP_DUMP, mp);
- mp->is_ipv6 = ipv6_set;
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static int
-api_get_first_msg_id (vat_main_t * vam)
+api_get_first_msg_id (vat_main_t *vam)
{
vl_api_get_first_msg_id_t *mp;
unformat_input_t *i = vam->input;
@@ -4724,7 +3813,7 @@ api_get_first_msg_id (vat_main_t * vam)
}
static int
-api_get_node_graph (vat_main_t * vam)
+api_get_node_graph (vat_main_t *vam)
{
vl_api_get_node_graph_t *mp;
int ret;
@@ -4738,522 +3827,6 @@ api_get_node_graph (vat_main_t * vam)
return ret;
}
-static u8 *
-format_fib_api_path_nh_proto (u8 * s, va_list * args)
-{
- vl_api_fib_path_nh_proto_t proto =
- va_arg (*args, vl_api_fib_path_nh_proto_t);
-
- switch (proto)
- {
- case FIB_API_PATH_NH_PROTO_IP4:
- s = format (s, "ip4");
- break;
- case FIB_API_PATH_NH_PROTO_IP6:
- s = format (s, "ip6");
- break;
- case FIB_API_PATH_NH_PROTO_MPLS:
- s = format (s, "mpls");
- break;
- case FIB_API_PATH_NH_PROTO_BIER:
- s = format (s, "bier");
- break;
- case FIB_API_PATH_NH_PROTO_ETHERNET:
- s = format (s, "ethernet");
- break;
- }
-
- return (s);
-}
-
-static u8 *
-format_vl_api_ip_address_union (u8 * s, va_list * args)
-{
- vl_api_address_family_t af = va_arg (*args, int);
- const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
-
- switch (af)
- {
- case ADDRESS_IP4:
- s = format (s, "%U", format_ip4_address, u->ip4);
- break;
- case ADDRESS_IP6:
- s = format (s, "%U", format_ip6_address, u->ip6);
- break;
- }
- return (s);
-}
-
-static u8 *
-format_vl_api_fib_path_type (u8 * s, va_list * args)
-{
- vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
-
- switch (t)
- {
- case FIB_API_PATH_TYPE_NORMAL:
- s = format (s, "normal");
- break;
- case FIB_API_PATH_TYPE_LOCAL:
- s = format (s, "local");
- break;
- case FIB_API_PATH_TYPE_DROP:
- s = format (s, "drop");
- break;
- case FIB_API_PATH_TYPE_UDP_ENCAP:
- s = format (s, "udp-encap");
- break;
- case FIB_API_PATH_TYPE_BIER_IMP:
- s = format (s, "bier-imp");
- break;
- case FIB_API_PATH_TYPE_ICMP_UNREACH:
- s = format (s, "unreach");
- break;
- case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
- s = format (s, "prohibit");
- break;
- case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
- s = format (s, "src-lookup");
- break;
- case FIB_API_PATH_TYPE_DVR:
- s = format (s, "dvr");
- break;
- case FIB_API_PATH_TYPE_INTERFACE_RX:
- s = format (s, "interface-rx");
- break;
- case FIB_API_PATH_TYPE_CLASSIFY:
- s = format (s, "classify");
- break;
- }
-
- return (s);
-}
-
-static void
-vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
-{
- print (vam->ofp,
- " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
- ntohl (fp->weight), ntohl (fp->sw_if_index),
- format_vl_api_fib_path_type, fp->type,
- format_fib_api_path_nh_proto, fp->proto,
- format_vl_api_ip_address_union, &fp->nh.address);
-}
-
-static void
-vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
- vl_api_fib_path_t * fp)
-{
- struct in_addr ip4;
- struct in6_addr ip6;
-
- vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
- vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
- vat_json_object_add_uint (node, "type", fp->type);
- vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
- if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
- {
- clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
- vat_json_object_add_ip4 (node, "next_hop", ip4);
- }
- else if (fp->proto == FIB_API_PATH_NH_PROTO_IP6)
- {
- clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
- vat_json_object_add_ip6 (node, "next_hop", ip6);
- }
-}
-
-#define vl_api_ip_table_details_t_endian vl_noop_handler
-#define vl_api_ip_table_details_t_print vl_noop_handler
-
-static void
-vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp,
- "%s; table-id %d, prefix %U/%d",
- mp->table.name, ntohl (mp->table.table_id));
-}
-
-
-static void vl_api_ip_table_details_t_handler_json
- (vl_api_ip_table_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, "table", ntohl (mp->table.table_id));
-}
-
-static int
-api_ip_table_dump (vat_main_t * vam)
-{
- vl_api_ip_table_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- int ret;
-
- M (IP_TABLE_DUMP, mp);
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static int
-api_ip_mtable_dump (vat_main_t * vam)
-{
- vl_api_ip_mtable_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- int ret;
-
- M (IP_MTABLE_DUMP, mp);
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static int
-api_ip_mroute_dump (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_control_ping_t *mp_ping;
- vl_api_ip_mroute_dump_t *mp;
- int ret, is_ip6;
- u32 table_id;
-
- is_ip6 = 0;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "table_id %d", &table_id))
- ;
- else if (unformat (input, "ip6"))
- is_ip6 = 1;
- else if (unformat (input, "ip4"))
- is_ip6 = 0;
- else
- break;
- }
- if (table_id == ~0)
- {
- errmsg ("missing table id");
- return -99;
- }
-
- M (IP_MROUTE_DUMP, mp);
- mp->table.table_id = table_id;
- mp->table.is_ip6 = is_ip6;
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-#define vl_api_ip_route_details_t_endian vl_noop_handler
-#define vl_api_ip_route_details_t_print vl_noop_handler
-
-static void
-vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- u8 count = mp->route.n_paths;
- vl_api_fib_path_t *fp;
- int i;
-
- print (vam->ofp,
- "table-id %d, prefix %U/%d",
- ntohl (mp->route.table_id),
- format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
- for (i = 0; i < count; i++)
- {
- fp = &mp->route.paths[i];
-
- vl_api_fib_path_print (vam, fp);
- fp++;
- }
-}
-
-static void vl_api_ip_route_details_t_handler_json
- (vl_api_ip_route_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- u8 count = mp->route.n_paths;
- vat_json_node_t *node = NULL;
- struct in_addr ip4;
- struct in6_addr ip6;
- vl_api_fib_path_t *fp;
- int i;
-
- 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, "table", ntohl (mp->route.table_id));
- if (ADDRESS_IP6 == mp->route.prefix.address.af)
- {
- clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
- vat_json_object_add_ip6 (node, "prefix", ip6);
- }
- else
- {
- clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
- vat_json_object_add_ip4 (node, "prefix", ip4);
- }
- vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
- vat_json_object_add_uint (node, "path_count", count);
- for (i = 0; i < count; i++)
- {
- fp = &mp->route.paths[i];
- vl_api_mpls_fib_path_json_print (node, fp);
- }
-}
-
-static int
-api_ip_route_dump (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_ip_route_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- u32 table_id;
- u8 is_ip6;
- int ret;
-
- is_ip6 = 0;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "table_id %d", &table_id))
- ;
- else if (unformat (input, "ip6"))
- is_ip6 = 1;
- else if (unformat (input, "ip4"))
- is_ip6 = 0;
- else
- break;
- }
- if (table_id == ~0)
- {
- errmsg ("missing table id");
- return -99;
- }
-
- M (IP_ROUTE_DUMP, mp);
-
- mp->table.table_id = table_id;
- mp->table.is_ip6 = is_ip6;
-
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-int
-api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_ip_source_and_port_range_check_add_del_t *mp;
-
- u16 *low_ports = 0;
- u16 *high_ports = 0;
- u16 this_low;
- u16 this_hi;
- vl_api_prefix_t prefix;
- u32 tmp, tmp2;
- u8 prefix_set = 0;
- u32 vrf_id = ~0;
- u8 is_add = 1;
- int ret;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
- prefix_set = 1;
- else if (unformat (input, "vrf %d", &vrf_id))
- ;
- else if (unformat (input, "del"))
- is_add = 0;
- else if (unformat (input, "port %d", &tmp))
- {
- if (tmp == 0 || tmp > 65535)
- {
- errmsg ("port %d out of range", tmp);
- return -99;
- }
- this_low = tmp;
- this_hi = this_low + 1;
- vec_add1 (low_ports, this_low);
- vec_add1 (high_ports, this_hi);
- }
- else if (unformat (input, "range %d - %d", &tmp, &tmp2))
- {
- if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
- {
- errmsg ("incorrect range parameters");
- return -99;
- }
- this_low = tmp;
- /* Note: in debug CLI +1 is added to high before
- passing to real fn that does "the work"
- (ip_source_and_port_range_check_add_del).
- This fn is a wrapper around the binary API fn a
- control plane will call, which expects this increment
- to have occurred. Hence letting the binary API control
- plane fn do the increment for consistency between VAT
- and other control planes.
- */
- this_hi = tmp2;
- vec_add1 (low_ports, this_low);
- vec_add1 (high_ports, this_hi);
- }
- else
- break;
- }
-
- if (prefix_set == 0)
- {
- errmsg ("<address>/<mask> not specified");
- return -99;
- }
-
- if (vrf_id == ~0)
- {
- errmsg ("VRF ID required, not specified");
- return -99;
- }
-
- if (vrf_id == 0)
- {
- errmsg
- ("VRF ID should not be default. Should be distinct VRF for this purpose.");
- return -99;
- }
-
- if (vec_len (low_ports) == 0)
- {
- errmsg ("At least one port or port range required");
- return -99;
- }
-
- M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
-
- mp->is_add = is_add;
-
- clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
-
- mp->number_of_ranges = vec_len (low_ports);
-
- clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
- vec_free (low_ports);
-
- clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
- vec_free (high_ports);
-
- mp->vrf_id = ntohl (vrf_id);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-int
-api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
- u32 sw_if_index = ~0;
- int vrf_set = 0;
- u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
- u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
- u8 is_add = 1;
- int ret;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- ;
- else if (unformat (input, "sw_if_index %d", &sw_if_index))
- ;
- else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
- vrf_set = 1;
- else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
- vrf_set = 1;
- else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
- vrf_set = 1;
- else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
- vrf_set = 1;
- else if (unformat (input, "del"))
- is_add = 0;
- else
- break;
- }
-
- if (sw_if_index == ~0)
- {
- errmsg ("Interface required but not specified");
- return -99;
- }
-
- if (vrf_set == 0)
- {
- errmsg ("VRF ID required but not specified");
- return -99;
- }
-
- if (tcp_out_vrf_id == 0
- || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
- {
- errmsg
- ("VRF ID should not be default. Should be distinct VRF for this purpose.");
- return -99;
- }
-
- /* Construct the API message */
- M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->is_add = is_add;
- mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
- mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
- mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
- mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
static int
api_delete_subif (vat_main_t * vam)
{
@@ -5791,46 +4364,6 @@ api_session_rules_dump (vat_main_t * vam)
}
static int
-api_ip_container_proxy_add_del (vat_main_t * vam)
-{
- vl_api_ip_container_proxy_add_del_t *mp;
- unformat_input_t *i = vam->input;
- u32 sw_if_index = ~0;
- vl_api_prefix_t pfx = { };
- u8 is_add = 1;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "add"))
- ;
- if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
- ;
- else if (unformat (i, "sw_if_index %u", &sw_if_index))
- ;
- else
- break;
- }
- if (sw_if_index == ~0 || pfx.len == 0)
- {
- errmsg ("address and sw_if_index must be set");
- return -99;
- }
-
- M (IP_CONTAINER_PROXY_ADD_DEL, mp);
-
- mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
- mp->is_add = is_add;
- clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
q_or_quit (vat_main_t * vam)
{
#if VPP_API_TEST_BUILTIN == 0
@@ -6158,34 +4691,6 @@ dump_macro_table (vat_main_t * vam)
}
static int
-dump_node_table (vat_main_t * vam)
-{
- int i, j;
- vlib_node_t *node, *next_node;
-
- if (vec_len (vam->graph_nodes) == 0)
- {
- print (vam->ofp, "Node table empty, issue get_node_graph...");
- return 0;
- }
-
- for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
- {
- node = vam->graph_nodes[0][i];
- print (vam->ofp, "[%d] %s", i, node->name);
- for (j = 0; j < vec_len (node->next_nodes); j++)
- {
- if (node->next_nodes[j] != ~0)
- {
- next_node = vam->graph_nodes[0][node->next_nodes[j]];
- print (vam->ofp, " [%d] %s", j, next_node->name);
- }
- }
- }
- return 0;
-}
-
-static int
value_sort_cmp (void *a1, void *a2)
{
name_sort_t *n1 = a1;
@@ -6374,16 +4879,6 @@ _(sw_interface_rx_placement_dump, \
"[<intfc> | sw_if_index <id>]") \
_(sw_interface_set_table, \
"<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
-_(ip_table_add_del, \
- "table <n> [ipv6] [add | del]\n") \
-_(ip_route_add_del, \
- "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
- "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
- "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
- "[multipath] [count <n>] [del]") \
-_(ip_mroute_add_del, \
- "<src> <grp>/<mask> [table-id <n>]\n" \
- "[<intfc> | sw_if_index <id>] [local] [del]") \
_(sw_interface_set_unnumbered, \
"<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
_(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
@@ -6391,39 +4886,19 @@ _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
"[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
"[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
"[outer_vlan_id_any][inner_vlan_id_any]") \
-_(ip_table_replace_begin, "table <n> [ipv6]") \
-_(ip_table_flush, "table <n> [ipv6]") \
-_(ip_table_replace_end, "table <n> [ipv6]") \
-_(set_ip_flow_hash, \
- "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
-_(sw_interface_ip6_enable_disable, \
- "<intfc> | sw_if_index <id> enable | disable") \
_(get_node_index, "node <node-name") \
_(add_node_next, "node <node-name> next <next-node-name>") \
_(show_version, "") \
_(show_threads, "") \
_(interface_name_renumber, \
"<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
-_(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
-_(ip_dump, "ipv4 | ipv6") \
_(delete_loopback,"sw_if_index <nn>") \
_(want_interface_events, "enable|disable") \
_(get_first_msg_id, "client <name>") \
_(get_node_graph, " ") \
_(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
-_(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
-_(ioam_disable, "") \
_(get_next_index, "node-name <node-name> next-node-name <node-name>") \
-_(ip_source_and_port_range_check_add_del, \
- "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
-_(ip_source_and_port_range_check_interface_add_del, \
- "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
- "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
_(delete_subif,"<intfc> | sw_if_index <nn>") \
-_(ip_table_dump, "") \
-_(ip_route_dump, "table-id [ip4|ip6]") \
-_(ip_mtable_dump, "") \
-_(ip_mroute_dump, "table-id [ip4|ip6]") \
_(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
"[disable]") \
_(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
@@ -6435,17 +4910,13 @@ _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
_(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
"<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
_(session_rules_dump, "") \
-_(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
/* List of command functions, CLI names map directly to functions */
#define foreach_cli_function \
_(comment, "usage: comment <ignore-rest-of-line>") \
_(dump_interface_table, "usage: dump_interface_table") \
_(dump_sub_interface_table, "usage: dump_sub_interface_table") \
-_(dump_ipv4_table, "usage: dump_ipv4_table") \
-_(dump_ipv6_table, "usage: dump_ipv6_table") \
_(dump_macro_table, "usage: dump_macro_table ") \
-_(dump_node_table, "usage: dump_node_table") \
_(dump_msg_api_table, "usage: dump_msg_api_table") \
_(elog_setup, "usage: elog_setup [nevents, default 128K]") \
_(elog_disable, "usage: elog_disable") \
diff --git a/src/vnet/ip/ip4.h b/src/vnet/ip/ip4.h
index 32552eafbff..bc971a2b7ca 100644
--- a/src/vnet/ip/ip4.h
+++ b/src/vnet/ip/ip4.h
@@ -164,6 +164,8 @@ typedef struct ip4_main_t
u8 pad[2];
} host_config;
+
+ u16 msg_id_base;
} ip4_main_t;
#define ARP_THROTTLE_BITS (512)
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index 91b12e5896a..6f06e382024 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -48,71 +48,12 @@
#include <vnet/ip/ip_table.h>
#include <vnet/ip/ip_container_proxy.h>
-#include <vnet/vnet_msg_enum.h>
-
-#define vl_typedefs /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
-#define vl_printfun
-#include <vnet/vnet_all_api_h.h>
-#undef vl_printfun
-
-#include <vlibapi/api_helper_macros.h>
-
#include <vnet/format_fns.h>
+#include <vnet/ip/ip.api_enum.h>
+#include <vnet/ip/ip.api_types.h>
-#define foreach_ip_api_msg \
- _ (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable) \
- _ (IP_TABLE_DUMP, ip_table_dump) \
- _ (IP_ROUTE_DUMP, ip_route_dump) \
- _ (IP_ROUTE_V2_DUMP, ip_route_v2_dump) \
- _ (IP_MTABLE_DUMP, ip_mtable_dump) \
- _ (IP_MROUTE_DUMP, ip_mroute_dump) \
- _ (IP_MROUTE_ADD_DEL, ip_mroute_add_del) \
- _ (MFIB_SIGNAL_DUMP, mfib_signal_dump) \
- _ (IP_ADDRESS_DUMP, ip_address_dump) \
- _ (IP_UNNUMBERED_DUMP, ip_unnumbered_dump) \
- _ (IP_DUMP, ip_dump) \
- _ (IP_TABLE_REPLACE_BEGIN, ip_table_replace_begin) \
- _ (IP_TABLE_REPLACE_END, ip_table_replace_end) \
- _ (IP_TABLE_FLUSH, ip_table_flush) \
- _ (IP_ROUTE_ADD_DEL, ip_route_add_del) \
- _ (IP_ROUTE_ADD_DEL_V2, ip_route_add_del_v2) \
- _ (IP_ROUTE_LOOKUP, ip_route_lookup) \
- _ (IP_ROUTE_LOOKUP_V2, ip_route_lookup_v2) \
- _ (IP_TABLE_ADD_DEL, ip_table_add_del) \
- _ (IP_PUNT_POLICE, ip_punt_police) \
- _ (IP_PUNT_REDIRECT, ip_punt_redirect) \
- _ (SET_IP_FLOW_HASH, set_ip_flow_hash) \
- _ (SET_IP_FLOW_HASH_V2, set_ip_flow_hash_v2) \
- _ (SET_IP_FLOW_HASH_ROUTER_ID, set_ip_flow_hash_router_id) \
- _ (IP_CONTAINER_PROXY_ADD_DEL, ip_container_proxy_add_del) \
- _ (IP_CONTAINER_PROXY_DUMP, ip_container_proxy_dump) \
- _ (IOAM_ENABLE, ioam_enable) \
- _ (IOAM_DISABLE, ioam_disable) \
- _ (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
- ip_source_and_port_range_check_add_del) \
- _ (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
- ip_source_and_port_range_check_interface_add_del) \
- _ (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \
- sw_interface_ip6_set_link_local_address) \
- _ (SW_INTERFACE_IP6_GET_LINK_LOCAL_ADDRESS, \
- sw_interface_ip6_get_link_local_address) \
- _ (IP_REASSEMBLY_SET, ip_reassembly_set) \
- _ (IP_REASSEMBLY_GET, ip_reassembly_get) \
- _ (IP_REASSEMBLY_ENABLE_DISABLE, ip_reassembly_enable_disable) \
- _ (IP_PUNT_REDIRECT_DUMP, ip_punt_redirect_dump) \
- _ (IP_PATH_MTU_UPDATE, ip_path_mtu_update) \
- _ (IP_PATH_MTU_REPLACE_BEGIN, ip_path_mtu_replace_begin) \
- _ (IP_PATH_MTU_REPLACE_END, ip_path_mtu_replace_end) \
- _ (IP_PATH_MTU_GET, ip_path_mtu_get)
+#define REPLY_MSG_ID_BASE ip4_main.msg_id_base
+#include <vlibapi/api_helper_macros.h>
static void
vl_api_sw_interface_ip6_enable_disable_t_handler
@@ -143,7 +84,7 @@ send_ip_table_details (vpe_api_main_t * am,
if (!mp)
return;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_TABLE_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_TABLE_DETAILS);
mp->context = context;
mp->table.is_ip6 = (table->ft_proto == FIB_PROTOCOL_IP6);
@@ -215,7 +156,7 @@ send_ip_route_details (vpe_api_main_t * am,
if (!mp)
return;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_ROUTE_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_ROUTE_DETAILS);
mp->context = context;
ip_prefix_encode (pfx, &mp->route.prefix);
@@ -257,7 +198,7 @@ send_ip_route_v2_details (vpe_api_main_t *am, vl_api_registration_t *reg,
if (!mp)
return;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_ROUTE_V2_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_ROUTE_V2_DETAILS);
mp->context = context;
ip_prefix_encode (pfx, &mp->route.prefix);
@@ -366,7 +307,7 @@ send_ip_mtable_details (vl_api_registration_t * reg,
if (!mp)
return;
memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_MTABLE_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_MTABLE_DETAILS);
mp->context = context;
mp->table.table_id = htonl (mfib_table->mft_table_id);
@@ -432,7 +373,7 @@ send_ip_mroute_details (vpe_api_main_t * am,
if (!mp)
return;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_MROUTE_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_MROUTE_DETAILS);
mp->context = context;
ip_mprefix_encode (pfx, &mp->route.prefix);
@@ -1031,7 +972,7 @@ send_ip_details (vpe_api_main_t * am,
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_DETAILS);
mp->sw_if_index = ntohl (sw_if_index);
mp->is_ipv6 = is_ipv6;
@@ -1050,7 +991,7 @@ send_ip_address_details (vpe_api_main_t * am,
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_ADDRESS_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_ADDRESS_DETAILS);
ip_prefix_encode (pfx, &mp->prefix);
mp->context = context;
@@ -1126,7 +1067,7 @@ send_ip_unnumbered_details (vpe_api_main_t * am,
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_UNNUMBERED_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_UNNUMBERED_DETAILS);
mp->context = context;
mp->sw_if_index = htonl (sw_if_index);
@@ -1286,7 +1227,7 @@ vl_mfib_signal_send_one (vl_api_registration_t * reg,
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_MFIB_SIGNAL_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_MFIB_SIGNAL_DETAILS);
mp->context = context;
mfi = mfib_itf_get (mfs->mfs_itf);
@@ -1367,7 +1308,8 @@ ip_container_proxy_send_details (const fib_prefix_t * pfx, u32 sw_if_index,
return 1;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_CONTAINER_PROXY_DETAILS);
+ mp->_vl_msg_id =
+ ntohs (REPLY_MSG_ID_BASE + VL_API_IP_CONTAINER_PROXY_DETAILS);
mp->context = ctx->context;
mp->sw_if_index = ntohl (sw_if_index);
@@ -1758,7 +1700,7 @@ vl_api_ip_reassembly_get_t_handler (vl_api_ip_reassembly_get_t * mp)
vl_api_ip_reassembly_get_reply_t *rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_IP_REASSEMBLY_GET_REPLY);
+ rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_REASSEMBLY_GET_REPLY);
rmp->context = mp->context;
rmp->retval = 0;
u32 timeout_ms;
@@ -1854,7 +1796,7 @@ send_ip_punt_redirect_details (u32 rx_sw_if_index,
return (WALK_STOP);;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_PUNT_REDIRECT_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_PUNT_REDIRECT_DETAILS);
mp->context = ctx->context;
fib_path_list_walk_w_ext (ipr->pl, NULL, fib_path_encode, &path_ctx);
@@ -1975,33 +1917,13 @@ vl_api_ip_path_mtu_get_t_handler (vl_api_ip_path_mtu_get_t *mp)
({ send_ip_path_mtu_details (cursor, rp, mp->context); }));
}
-#define vl_msg_name_crc_list
-#include <vnet/ip/ip.api.h>
-#undef vl_msg_name_crc_list
-
-static void
-setup_message_id_table (api_main_t * am)
-{
-#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
- foreach_vl_msg_name_crc_ip;
-#undef _
-}
+#include <vnet/ip/ip.api.c>
static clib_error_t *
ip_api_hookup (vlib_main_t * vm)
{
api_main_t *am = vlibapi_get_main ();
-#define _(N,n) \
- vl_msg_api_set_handlers(VL_API_##N, #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_ip_api_msg;
-#undef _
-
/*
* Mark the route add/del API as MP safe
*/
@@ -2013,7 +1935,7 @@ ip_api_hookup (vlib_main_t * vm)
/*
* Set up the (msg_name, crc, message-id) table
*/
- setup_message_id_table (am);
+ REPLY_MSG_ID_BASE = setup_message_id_table ();
return 0;
}
diff --git a/src/vnet/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h
index 4aca0d74e53..6a8ee152d92 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -34,7 +34,6 @@
#endif
#include <vnet/interface.api.h>
-#include <vnet/ip/ip.api.h>
#include <vnet/session/session.api.h>
#include <vnet/srmpls/sr_mpls.api.h>
diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c
index 6fe779cec2a..b935c002228 100644
--- a/src/vpp/api/api.c
+++ b/src/vpp/api/api.c
@@ -61,6 +61,7 @@
#include <vpp/api/vpe_msg_enum.h>
#include <vpp/api/types.h>
#include <vnet/classify/classify.api_enum.h>
+#include <vnet/ip/ip.api_enum.h>
#define vl_typedefs /* define message structures */
#include <vpp/api/vpe_all_api_h.h>