summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vat/api_format.c162
-rw-r--r--src/vnet/bier/bier_api.c122
-rw-r--r--src/vnet/vnet_all_api_h.h1
3 files changed, 39 insertions, 246 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index a1c5e8ef5d8..2317af3d960 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -81,8 +81,6 @@
#define __plugin_msg_base 0
#include <vlibapi/vat_helper_macros.h>
-#include <vnet/format_fns.h>
-
void vl_api_set_elog_main (elog_main_t * m);
int vl_api_set_elog_trace_api_messages (int enable);
@@ -3261,8 +3259,6 @@ _(ip_mroute_add_del_reply) \
_(mpls_route_add_del_reply) \
_(mpls_table_add_del_reply) \
_(mpls_ip_bind_unbind_reply) \
-_(bier_route_add_del_reply) \
-_(bier_table_add_del_reply) \
_(sw_interface_set_unnumbered_reply) \
_(set_ip_flow_hash_reply) \
_(sw_interface_ip6_enable_disable_reply) \
@@ -3416,8 +3412,6 @@ _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
_(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
_(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
_(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
-_(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
-_(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
_(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
_(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
sw_interface_set_unnumbered_reply) \
@@ -6743,156 +6737,6 @@ api_sr_mpls_policy_del (vat_main_t * vam)
}
static int
-api_bier_table_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bier_table_add_del_t *mp;
- u8 is_add = 1;
- u32 set = 0, sub_domain = 0, hdr_len = 3;
- mpls_label_t local_label = MPLS_LABEL_INVALID;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sub-domain %d", &sub_domain))
- ;
- else if (unformat (i, "set %d", &set))
- ;
- else if (unformat (i, "label %d", &local_label))
- ;
- else if (unformat (i, "hdr-len %d", &hdr_len))
- ;
- else if (unformat (i, "add"))
- is_add = 1;
- else if (unformat (i, "del"))
- is_add = 0;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (MPLS_LABEL_INVALID == local_label)
- {
- errmsg ("missing label\n");
- return -99;
- }
-
- /* Construct the API message */
- M (BIER_TABLE_ADD_DEL, mp);
-
- mp->bt_is_add = is_add;
- mp->bt_label = ntohl (local_label);
- mp->bt_tbl_id.bt_set = set;
- mp->bt_tbl_id.bt_sub_domain = sub_domain;
- mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
-
- return (ret);
-}
-
-static int
-api_bier_route_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bier_route_add_del_t *mp;
- u8 is_add = 1;
- u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
- ip4_address_t v4_next_hop_address;
- ip6_address_t v6_next_hop_address;
- u8 next_hop_set = 0;
- u8 next_hop_proto_is_ip4 = 1;
- mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
- {
- next_hop_proto_is_ip4 = 1;
- next_hop_set = 1;
- }
- else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
- {
- next_hop_proto_is_ip4 = 0;
- next_hop_set = 1;
- }
- if (unformat (i, "sub-domain %d", &sub_domain))
- ;
- else if (unformat (i, "set %d", &set))
- ;
- else if (unformat (i, "hdr-len %d", &hdr_len))
- ;
- else if (unformat (i, "bp %d", &bp))
- ;
- else if (unformat (i, "add"))
- is_add = 1;
- else if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "out-label %d", &next_hop_out_label))
- ;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
- {
- errmsg ("next hop / label set\n");
- return -99;
- }
- if (0 == bp)
- {
- errmsg ("bit=position not set\n");
- return -99;
- }
-
- /* Construct the API message */
- M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
-
- mp->br_is_add = is_add;
- mp->br_route.br_tbl_id.bt_set = set;
- mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
- mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
- mp->br_route.br_bp = ntohs (bp);
- mp->br_route.br_n_paths = 1;
- mp->br_route.br_paths[0].n_labels = 1;
- mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
- mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
- FIB_API_PATH_NH_PROTO_IP4 :
- FIB_API_PATH_NH_PROTO_IP6);
-
- if (next_hop_proto_is_ip4)
- {
- clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
- &v4_next_hop_address, sizeof (v4_next_hop_address));
- }
- else
- {
- clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
- &v6_next_hop_address, sizeof (v6_next_hop_address));
- }
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
-
- return (ret);
-}
-
-static int
api_mpls_tunnel_add_del (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
@@ -14819,12 +14663,6 @@ _(sr_mpls_policy_add, \
"bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
_(sr_mpls_policy_del, \
"bsid <id>") \
-_(bier_table_add_del, \
- "<label> <sub-domain> <set> <bsl> [del]") \
-_(bier_route_add_del, \
- "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
- "[<intfc> | sw_if_index <id>]" \
- "[weight <n>] [del] [multipath]") \
_(sw_interface_set_unnumbered, \
"<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
_(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
diff --git a/src/vnet/bier/bier_api.c b/src/vnet/bier/bier_api.c
index 366fba174e7..eeab2fef964 100644
--- a/src/vnet/bier/bier_api.c
+++ b/src/vnet/bier/bier_api.c
@@ -32,37 +32,19 @@
#include <vnet/fib/fib_table.h>
#include <vnet/mfib/mfib_table.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 <vnet/format_fns.h>
+#include <bier/bier.api_enum.h>
+#include <bier/bier.api_types.h>
+#define REPLY_MSG_ID_BASE bier_main.msg_id_base
#include <vlibapi/api_helper_macros.h>
-#include <vnet/fib/fib_api.h>
-#define foreach_bier_api_msg \
- _(BIER_TABLE_ADD_DEL, bier_table_add_del) \
- _(BIER_TABLE_DUMP, bier_table_dump) \
- _(BIER_ROUTE_ADD_DEL, bier_route_add_del) \
- _(BIER_ROUTE_DUMP, bier_route_dump) \
- _(BIER_IMP_ADD, bier_imp_add) \
- _(BIER_IMP_DEL, bier_imp_del) \
- _(BIER_IMP_DUMP, bier_imp_dump) \
- _(BIER_DISP_TABLE_ADD_DEL, bier_disp_table_add_del) \
- _(BIER_DISP_TABLE_DUMP, bier_disp_table_dump) \
- _(BIER_DISP_ENTRY_ADD_DEL, bier_disp_entry_add_del) \
- _(BIER_DISP_ENTRY_DUMP, bier_disp_entry_dump)
+typedef struct
+{
+ u16 msg_id_base;
+} bier_main_t;
+
+bier_main_t bier_main;
static void
vl_api_bier_table_add_del_t_handler (vl_api_bier_table_add_del_t * mp)
@@ -124,7 +106,7 @@ send_bier_table_details (vl_api_registration_t * reg,
if (!mp)
return;
clib_memset(mp, 0, sizeof(*mp));
- mp->_vl_msg_id = ntohs(VL_API_BIER_TABLE_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_BIER_TABLE_DETAILS);
mp->context = context;
mp->bt_label = bt->bt_ll;
@@ -258,7 +240,7 @@ send_bier_route_details (const bier_table_t *bt,
return;
clib_memset(mp, 0, m_size);
- mp->_vl_msg_id = ntohs(VL_API_BIER_ROUTE_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_BIER_ROUTE_DETAILS);
mp->context = ctx->context;
mp->br_route.br_tbl_id.bt_set = bt->bt_id.bti_set;
@@ -381,7 +363,7 @@ send_bier_imp_details (vl_api_registration_t * reg,
if (!mp)
return;
clib_memset(mp, 0, sizeof(*mp)+n_bytes);
- mp->_vl_msg_id = ntohs(VL_API_BIER_IMP_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_BIER_IMP_DETAILS);
mp->context = context;
mp->bi_tbl_id.bt_set = bi->bi_tbl.bti_set;
@@ -448,7 +430,8 @@ send_bier_disp_table_details (vl_api_registration_t * reg,
if (!mp)
return;
clib_memset(mp, 0, sizeof(*mp));
- mp->_vl_msg_id = ntohs(VL_API_BIER_DISP_TABLE_DETAILS);
+ mp->_vl_msg_id =
+ ntohs (REPLY_MSG_ID_BASE + VL_API_BIER_DISP_TABLE_DETAILS);
mp->context = context;
mp->bdt_tbl_id = htonl(bdt->bdt_table_id);
@@ -629,29 +612,27 @@ send_bier_disp_entry_details (const bier_disp_table_t *bdt,
return;
clib_memset(mp, 0, m_size);
- mp->_vl_msg_id = ntohs(VL_API_BIER_DISP_ENTRY_DETAILS);
- mp->context = ctx->context;
-
- mp->bde_tbl_id = htonl(bdt->bdt_table_id);
- mp->bde_n_paths = htonl(n_paths);
- mp->bde_payload_proto = pproto;
- mp->bde_bp = htons(bp);
-
- fib_path_list_walk_w_ext(pl,
- NULL,
- fib_path_encode,
- &path_ctx);
-
- fp = mp->bde_paths;
- vec_foreach (rpath, path_ctx.rpaths)
- {
- fib_api_path_encode(rpath, fp);
- fp++;
- }
-
- vl_api_send_msg (ctx->reg, (u8 *) mp);
- vec_free(path_ctx.rpaths);
- }
+ mp->_vl_msg_id =
+ ntohs (REPLY_MSG_ID_BASE + VL_API_BIER_DISP_ENTRY_DETAILS);
+ mp->context = ctx->context;
+
+ mp->bde_tbl_id = htonl (bdt->bdt_table_id);
+ mp->bde_n_paths = htonl (n_paths);
+ mp->bde_payload_proto = pproto;
+ mp->bde_bp = htons (bp);
+
+ fib_path_list_walk_w_ext (pl, NULL, fib_path_encode, &path_ctx);
+
+ fp = mp->bde_paths;
+ vec_foreach (rpath, path_ctx.rpaths)
+ {
+ fib_api_path_encode (rpath, fp);
+ fp++;
+ }
+
+ vl_api_send_msg (ctx->reg, (u8 *) mp);
+ vec_free (path_ctx.rpaths);
+ }
}
}
@@ -673,39 +654,14 @@ vl_api_bier_disp_entry_dump_t_handler (vl_api_bier_disp_entry_dump_t * mp)
&ctx);
}
-#define vl_msg_name_crc_list
-#include <vnet/bier/bier.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_bier;
-#undef _
-}
+#include <bier/bier.api.c>
static clib_error_t *
bier_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_bier_api_msg;
-#undef _
-
- /*
- * Set up the (msg_name, crc, message-id) table
- */
- setup_message_id_table (am);
+ bier_main.msg_id_base = setup_message_id_table ();
- return 0;
+ return 0;
}
VLIB_API_INIT_FUNCTION (bier_api_hookup);
diff --git a/src/vnet/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h
index 364bbecabcc..87ae1bd0534 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -55,7 +55,6 @@
#include <vnet/ethernet/p2p_ethernet.api.h>
#include <vnet/tcp/tcp.api.h>
#include <vnet/udp/udp.api.h>
-#include <vnet/bier/bier.api.h>
#include <vnet/ip/punt.api.h>
#include <vnet/pg/pg.api.h>
#include <vnet/feature/feature.api.h>