aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2021-06-22 13:00:40 +0000
committerOle Tr�an <otroan@employees.org>2021-06-22 13:54:23 +0000
commite2fc003f46f70659045e563368db73eeca9a9647 (patch)
treed185e843208c9d910fa94b5ac25e5492749b7dff /src/vnet
parent36d5c97985237d4f509b07ad4e497bd0f1f6cd7e (diff)
sr: api cleanup
Use autogenerated code. Does not change API definitions. Type: improvement Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: I0bdf870e2e9b0ebc11a3ce252fbd0667a83de4e6
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/srv6/sr.h1
-rw-r--r--src/vnet/srv6/sr_api.c76
-rw-r--r--src/vnet/vnet_all_api_h.h1
3 files changed, 12 insertions, 66 deletions
diff --git a/src/vnet/srv6/sr.h b/src/vnet/srv6/sr.h
index 98304b8bafd..d47c2132ee4 100644
--- a/src/vnet/srv6/sr.h
+++ b/src/vnet/srv6/sr.h
@@ -309,6 +309,7 @@ typedef struct
/* convenience */
vlib_main_t *vlib_main;
vnet_main_t *vnet_main;
+ u16 msg_id_base;
} ip6_sr_main_t;
extern ip6_sr_main_t sr_main;
diff --git a/src/vnet/srv6/sr_api.c b/src/vnet/srv6/sr_api.c
index cb468b97ef5..c68b355922b 100644
--- a/src/vnet/srv6/sr_api.c
+++ b/src/vnet/srv6/sr_api.c
@@ -25,40 +25,15 @@
#include <vnet/api_errno.h>
#include <vnet/feature/feature.h>
#include <vnet/fib/fib_table.h>
-
#include <vnet/ip/ip_types_api.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 <vnet/srv6/sr.api_enum.h>
+#include <vnet/srv6/sr.api_types.h>
+#define REPLY_MSG_ID_BASE sr_main.msg_id_base
#include <vlibapi/api_helper_macros.h>
-#define foreach_vpe_api_msg \
-_(SR_LOCALSID_ADD_DEL, sr_localsid_add_del) \
-_(SR_POLICY_ADD, sr_policy_add) \
-_(SR_POLICY_MOD, sr_policy_mod) \
-_(SR_POLICY_DEL, sr_policy_del) \
-_(SR_STEERING_ADD_DEL, sr_steering_add_del) \
-_(SR_SET_ENCAP_SOURCE, sr_set_encap_source) \
-_(SR_SET_ENCAP_HOP_LIMIT, sr_set_encap_hop_limit) \
-_(SR_LOCALSIDS_DUMP, sr_localsids_dump) \
-_(SR_POLICIES_DUMP, sr_policies_dump) \
-_(SR_POLICIES_WITH_SL_INDEX_DUMP, sr_policies_with_sl_index_dump) \
-_(SR_STEERING_POL_DUMP, sr_steering_pol_dump)
-
static void vl_api_sr_localsid_add_del_t_handler
(vl_api_sr_localsid_add_del_t * mp)
{
@@ -239,7 +214,7 @@ static void send_sr_localsid_details
rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_SR_LOCALSIDS_DETAILS);
+ rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SR_LOCALSIDS_DETAILS);
ip6_address_encode (&t->localsid, rmp->addr);
rmp->end_psp = t->end_psp;
rmp->behavior = htons (t->behavior);
@@ -299,7 +274,7 @@ static void send_sr_policies_details
vec_len (t->segments_lists) *
sizeof (vl_api_srv6_sid_list_t)));
- rmp->_vl_msg_id = ntohs (VL_API_SR_POLICIES_DETAILS);
+ rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SR_POLICIES_DETAILS);
ip6_address_encode (&t->bsid, rmp->bsid);
rmp->is_encap = t->is_encap;
rmp->is_spray = t->type;
@@ -366,7 +341,8 @@ static void send_sr_policies_details_with_sl_index
vec_len (t->segments_lists) *
sizeof (vl_api_srv6_sid_list_with_sl_index_t)));
- rmp->_vl_msg_id = ntohs (VL_API_SR_POLICIES_WITH_SL_INDEX_DETAILS);
+ rmp->_vl_msg_id =
+ ntohs (REPLY_MSG_ID_BASE + VL_API_SR_POLICIES_WITH_SL_INDEX_DETAILS);
ip6_address_encode (&t->bsid, rmp->bsid);
rmp->is_encap = t->is_encap;
rmp->is_spray = t->type;
@@ -421,7 +397,7 @@ static void send_sr_steering_pol_details
rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_SR_STEERING_POL_DETAILS);
+ rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SR_STEERING_POL_DETAILS);
//Get the SR policy BSID
ip6_sr_policy_t *p;
@@ -460,44 +436,14 @@ static void vl_api_sr_steering_pol_dump_t_handler
/* *INDENT-ON* */
}
-/*
- * sr_api_hookup
- * Add vpe's API message handlers to the table.
- * vlib has already mapped shared memory and
- * added the client registration handlers.
- * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
- */
-#define vl_msg_name_crc_list
-#include <vnet/vnet_all_api_h.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_sr;
-#undef _
-}
-
+#include <vnet/srv6/sr.api.c>
static clib_error_t *
sr_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_vpe_api_msg;
-#undef _
-
/*
* 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 5730974f151..6f24ef457ac 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -42,7 +42,6 @@
#include <vnet/ip/ip.api.h>
#include <vnet/session/session.api.h>
#include <vnet/mpls/mpls.api.h>
-#include <vnet/srv6/sr.api.h>
#include <vnet/srmpls/sr_mpls.api.h>
#include <vnet/tcp/tcp.api.h>
#include <vnet/ip/punt.api.h>