summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2021-06-22 08:21:31 +0000
committerOle Tr�an <otroan@employees.org>2021-06-22 11:24:27 +0000
commitc73f3299ad765c87f57a0a810819d42c11b04d5e (patch)
tree77d580b3fee10ee4af546e8f81b2f0243afc9e02 /src
parent41ff1eb5ddc493abdf9721640633a137ab638262 (diff)
ipsec: api cleanup
Use autogenerated code. Does not change API definitions. Type: improvement Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: I0db7343e907524af5adb2f4771b45712927d5833
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c445
-rw-r--r--src/vnet/ipsec/ipsec.h1
-rw-r--r--src/vnet/ipsec/ipsec_api.c99
-rw-r--r--src/vnet/vnet_all_api_h.h1
4 files changed, 19 insertions, 527 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 077a4cae5d3..3a93bdfa790 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -426,34 +426,6 @@ api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
#endif /* VPP_API_TEST_BUILTIN */
-uword
-unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
-{
- u32 *r = va_arg (*args, u32 *);
-
- if (0);
-#define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
- foreach_ipsec_crypto_alg
-#undef _
- else
- return 0;
- return 1;
-}
-
-uword
-unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
-{
- u32 *r = va_arg (*args, u32 *);
-
- if (0);
-#define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
- foreach_ipsec_integ_alg
-#undef _
- else
- return 0;
- return 1;
-}
-
#if (VPP_API_TEST_BUILTIN==0)
static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
@@ -2468,10 +2440,6 @@ _(modify_vhost_user_if_reply) \
_(modify_vhost_user_if_v2_reply) \
_(delete_vhost_user_if_reply) \
_(want_l2_macs_events_reply) \
-_(ipsec_spd_add_del_reply) \
-_(ipsec_interface_add_del_spd_reply) \
-_(ipsec_spd_entry_add_del_reply) \
-_(ipsec_sad_entry_add_del_reply) \
_(delete_loopback_reply) \
_(bd_ip_mac_add_del_reply) \
_(bd_ip_mac_flush_reply) \
@@ -2618,11 +2586,6 @@ _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
_(L2_MACS_EVENT, l2_macs_event) \
_(IP_ADDRESS_DETAILS, ip_address_details) \
_(IP_DETAILS, ip_details) \
-_(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
-_(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
-_(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
-_(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
-_(IPSEC_SA_DETAILS, ipsec_sa_details) \
_(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
_(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
_(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
@@ -8676,403 +8639,6 @@ api_ip_dump (vat_main_t * vam)
}
static int
-api_ipsec_spd_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ipsec_spd_add_del_t *mp;
- u32 spd_id = ~0;
- u8 is_add = 1;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "spd_id %d", &spd_id))
- ;
- else if (unformat (i, "del"))
- is_add = 0;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
- if (spd_id == ~0)
- {
- errmsg ("spd_id must be set");
- return -99;
- }
-
- M (IPSEC_SPD_ADD_DEL, mp);
-
- mp->spd_id = ntohl (spd_id);
- mp->is_add = is_add;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_ipsec_interface_add_del_spd (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ipsec_interface_add_del_spd_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u32 spd_id = (u32) ~ 0;
- 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, "spd_id %d", &spd_id))
- ;
- else
- 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
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
-
- }
-
- if (spd_id == (u32) ~ 0)
- {
- errmsg ("spd_id must be set");
- return -99;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
-
- mp->spd_id = ntohl (spd_id);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->is_add = is_add;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_ipsec_spd_entry_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ipsec_spd_entry_add_del_t *mp;
- u8 is_add = 1, is_outbound = 0;
- u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
- i32 priority = 0;
- u32 rport_start = 0, rport_stop = (u32) ~ 0;
- u32 lport_start = 0, lport_stop = (u32) ~ 0;
- vl_api_address_t laddr_start = { }, laddr_stop =
- {
- }, raddr_start =
- {
- }, raddr_stop =
- {
- };
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "del"))
- is_add = 0;
- if (unformat (i, "outbound"))
- is_outbound = 1;
- if (unformat (i, "inbound"))
- is_outbound = 0;
- else if (unformat (i, "spd_id %d", &spd_id))
- ;
- else if (unformat (i, "sa_id %d", &sa_id))
- ;
- else if (unformat (i, "priority %d", &priority))
- ;
- else if (unformat (i, "protocol %d", &protocol))
- ;
- else if (unformat (i, "lport_start %d", &lport_start))
- ;
- else if (unformat (i, "lport_stop %d", &lport_stop))
- ;
- else if (unformat (i, "rport_start %d", &rport_start))
- ;
- else if (unformat (i, "rport_stop %d", &rport_stop))
- ;
- else if (unformat (i, "laddr_start %U",
- unformat_vl_api_address, &laddr_start))
- ;
- else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
- &laddr_stop))
- ;
- else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
- &raddr_start))
- ;
- else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
- &raddr_stop))
- ;
- else
- if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
- {
- if (policy == IPSEC_POLICY_ACTION_RESOLVE)
- {
- clib_warning ("unsupported action: 'resolve'");
- return -99;
- }
- }
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
-
- }
-
- M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
-
- mp->is_add = is_add;
-
- mp->entry.spd_id = ntohl (spd_id);
- mp->entry.priority = ntohl (priority);
- mp->entry.is_outbound = is_outbound;
-
- clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
- sizeof (vl_api_address_t));
- clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
- sizeof (vl_api_address_t));
- clib_memcpy (&mp->entry.local_address_start, &laddr_start,
- sizeof (vl_api_address_t));
- clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
- sizeof (vl_api_address_t));
-
- mp->entry.protocol = (u8) protocol;
- mp->entry.local_port_start = ntohs ((u16) lport_start);
- mp->entry.local_port_stop = ntohs ((u16) lport_stop);
- mp->entry.remote_port_start = ntohs ((u16) rport_start);
- mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
- mp->entry.policy = (u8) policy;
- mp->entry.sa_id = ntohl (sa_id);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_ipsec_sad_entry_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ipsec_sad_entry_add_del_t *mp;
- u32 sad_id = 0, spi = 0;
- u8 *ck = 0, *ik = 0;
- u8 is_add = 1;
-
- vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
- vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
- vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
- vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
- vl_api_address_t tun_src, tun_dst;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "sad_id %d", &sad_id))
- ;
- else if (unformat (i, "spi %d", &spi))
- ;
- else if (unformat (i, "esp"))
- protocol = IPSEC_API_PROTO_ESP;
- else
- if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
- {
- flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
- if (ADDRESS_IP6 == tun_src.af)
- flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
- }
- else
- if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
- {
- flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
- if (ADDRESS_IP6 == tun_src.af)
- flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
- }
- else
- if (unformat (i, "crypto_alg %U",
- unformat_ipsec_api_crypto_alg, &crypto_alg))
- ;
- else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
- ;
- else if (unformat (i, "integ_alg %U",
- unformat_ipsec_api_integ_alg, &integ_alg))
- ;
- else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
- ;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
-
- }
-
- M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
-
- mp->is_add = is_add;
- mp->entry.sad_id = ntohl (sad_id);
- mp->entry.protocol = protocol;
- mp->entry.spi = ntohl (spi);
- mp->entry.flags = flags;
-
- mp->entry.crypto_algorithm = crypto_alg;
- mp->entry.integrity_algorithm = integ_alg;
- mp->entry.crypto_key.length = vec_len (ck);
- mp->entry.integrity_key.length = vec_len (ik);
-
- if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
- mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
-
- if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
- mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
-
- if (ck)
- clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
- if (ik)
- clib_memcpy (mp->entry.integrity_key.data, ik,
- mp->entry.integrity_key.length);
-
- if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
- {
- clib_memcpy (&mp->entry.tunnel_src, &tun_src,
- sizeof (mp->entry.tunnel_src));
- clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
- sizeof (mp->entry.tunnel_dst));
- }
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static void
-vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
- "crypto_key %U integ_alg %u integ_key %U flags %x "
- "tunnel_src_addr %U tunnel_dst_addr %U "
- "salt %u seq_outbound %lu last_seq_inbound %lu "
- "replay_window %lu stat_index %u\n",
- ntohl (mp->entry.sad_id),
- ntohl (mp->sw_if_index),
- ntohl (mp->entry.spi),
- ntohl (mp->entry.protocol),
- ntohl (mp->entry.crypto_algorithm),
- format_hex_bytes, mp->entry.crypto_key.data,
- mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
- format_hex_bytes, mp->entry.integrity_key.data,
- mp->entry.integrity_key.length, ntohl (mp->entry.flags),
- format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
- &mp->entry.tunnel_dst, ntohl (mp->salt),
- clib_net_to_host_u64 (mp->seq_outbound),
- clib_net_to_host_u64 (mp->last_seq_inbound),
- clib_net_to_host_u64 (mp->replay_window), ntohl (mp->stat_index));
-}
-
-#define vl_api_ipsec_sa_details_t_endian vl_noop_handler
-#define vl_api_ipsec_sa_details_t_print vl_noop_handler
-
-static void vl_api_ipsec_sa_details_t_handler_json
- (vl_api_ipsec_sa_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
- vl_api_ipsec_sad_flags_t flags;
-
- 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, "sa_id", ntohl (mp->entry.sad_id));
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
- vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
- vat_json_object_add_uint (node, "crypto_alg",
- ntohl (mp->entry.crypto_algorithm));
- vat_json_object_add_uint (node, "integ_alg",
- ntohl (mp->entry.integrity_algorithm));
- flags = ntohl (mp->entry.flags);
- vat_json_object_add_uint (node, "use_esn",
- ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
- vat_json_object_add_uint (node, "use_anti_replay",
- ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
- vat_json_object_add_uint (node, "is_tunnel",
- ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
- vat_json_object_add_uint (node, "is_tunnel_ip6",
- ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
- vat_json_object_add_uint (node, "udp_encap",
- ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
- vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
- mp->entry.crypto_key.length);
- vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
- mp->entry.integrity_key.length);
- vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
- vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
- vat_json_object_add_uint (node, "replay_window",
- clib_net_to_host_u64 (mp->replay_window));
- vat_json_object_add_uint (node, "stat_index", ntohl (mp->stat_index));
-}
-
-static int
-api_ipsec_sa_dump (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ipsec_sa_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- u32 sa_id = ~0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sa_id %d", &sa_id))
- ;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- M (IPSEC_SA_DUMP, mp);
-
- mp->sa_id = ntohl (sa_id);
-
- S (mp);
-
- /* Use a control ping for synchronization */
- M (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static int
api_get_first_msg_id (vat_main_t * vam)
{
vl_api_get_first_msg_id_t *mp;
@@ -11675,17 +11241,6 @@ _(interface_name_renumber, \
_(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
_(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
_(ip_dump, "ipv4 | ipv6") \
-_(ipsec_spd_add_del, "spd_id <n> [del]") \
-_(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
- " spid_id <n> ") \
-_(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
- " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
- " integ_alg <alg> integ_key <hex>") \
-_(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
- " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
- " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
- " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
-_(ipsec_sa_dump, "[sa_id <n>]") \
_(delete_loopback,"sw_if_index <nn>") \
_(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
_(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
diff --git a/src/vnet/ipsec/ipsec.h b/src/vnet/ipsec/ipsec.h
index 15de80764a8..0245c5575e4 100644
--- a/src/vnet/ipsec/ipsec.h
+++ b/src/vnet/ipsec/ipsec.h
@@ -207,6 +207,7 @@ typedef struct
u32 esp6_dec_tun_fq_index;
u8 async_mode;
+ u16 msg_id_base;
} ipsec_main_t;
typedef enum ipsec_format_flags_t_
diff --git a/src/vnet/ipsec/ipsec_api.c b/src/vnet/ipsec/ipsec_api.c
index 0eb51b5727f..a0c2768318f 100644
--- a/src/vnet/ipsec/ipsec_api.c
+++ b/src/vnet/ipsec/ipsec_api.c
@@ -29,52 +29,17 @@
#include <vnet/fib/fib.h>
#include <vnet/ipip/ipip.h>
#include <vnet/tunnel/tunnel_types_api.h>
-
-#include <vnet/vnet_msg_enum.h>
-
#include <vnet/ipsec/ipsec.h>
#include <vnet/ipsec/ipsec_tun.h>
#include <vnet/ipsec/ipsec_itf.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/ipsec/ipsec.api_enum.h>
+#include <vnet/ipsec/ipsec.api_types.h>
+#define REPLY_MSG_ID_BASE ipsec_main.msg_id_base
#include <vlibapi/api_helper_macros.h>
-#define foreach_vpe_api_msg \
- _ (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del) \
- _ (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd) \
- _ (IPSEC_SPD_ENTRY_ADD_DEL, ipsec_spd_entry_add_del) \
- _ (IPSEC_SAD_ENTRY_ADD_DEL, ipsec_sad_entry_add_del) \
- _ (IPSEC_SAD_ENTRY_ADD_DEL_V2, ipsec_sad_entry_add_del_v2) \
- _ (IPSEC_SAD_ENTRY_ADD_DEL_V3, ipsec_sad_entry_add_del_v3) \
- _ (IPSEC_SA_DUMP, ipsec_sa_dump) \
- _ (IPSEC_SA_V2_DUMP, ipsec_sa_v2_dump) \
- _ (IPSEC_SA_V3_DUMP, ipsec_sa_v3_dump) \
- _ (IPSEC_SPDS_DUMP, ipsec_spds_dump) \
- _ (IPSEC_SPD_DUMP, ipsec_spd_dump) \
- _ (IPSEC_SPD_INTERFACE_DUMP, ipsec_spd_interface_dump) \
- _ (IPSEC_ITF_CREATE, ipsec_itf_create) \
- _ (IPSEC_ITF_DELETE, ipsec_itf_delete) \
- _ (IPSEC_ITF_DUMP, ipsec_itf_dump) \
- _ (IPSEC_SELECT_BACKEND, ipsec_select_backend) \
- _ (IPSEC_BACKEND_DUMP, ipsec_backend_dump) \
- _ (IPSEC_TUNNEL_PROTECT_UPDATE, ipsec_tunnel_protect_update) \
- _ (IPSEC_TUNNEL_PROTECT_DEL, ipsec_tunnel_protect_del) \
- _ (IPSEC_TUNNEL_PROTECT_DUMP, ipsec_tunnel_protect_dump) \
- _ (IPSEC_SET_ASYNC_MODE, ipsec_set_async_mode)
-
static void
vl_api_ipsec_spd_add_del_t_handler (vl_api_ipsec_spd_add_del_t * mp)
{
@@ -174,7 +139,8 @@ send_ipsec_tunnel_protect_details (index_t itpi, void *arg)
mp = vl_msg_api_alloc (sizeof (*mp) + (sizeof (u32) * itp->itp_n_sa_in));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IPSEC_TUNNEL_PROTECT_DETAILS);
+ mp->_vl_msg_id =
+ ntohs (REPLY_MSG_ID_BASE + VL_API_IPSEC_TUNNEL_PROTECT_DETAILS);
mp->context = ctx->context;
mp->tun.sw_if_index = htonl (itp->itp_sw_if_index);
@@ -505,7 +471,7 @@ send_ipsec_spds_details (ipsec_spd_t * spd, 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_IPSEC_SPDS_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IPSEC_SPDS_DETAILS);
mp->context = context;
mp->spd_id = htonl (spd->id);
@@ -557,7 +523,7 @@ send_ipsec_spd_details (ipsec_policy_t * p, 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_IPSEC_SPD_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IPSEC_SPD_DETAILS);
mp->context = context;
mp->entry.spd_id = htonl (p->id);
@@ -625,7 +591,8 @@ send_ipsec_spd_interface_details (vl_api_registration_t * reg, u32 spd_index,
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IPSEC_SPD_INTERFACE_DETAILS);
+ mp->_vl_msg_id =
+ ntohs (REPLY_MSG_ID_BASE + VL_API_IPSEC_SPD_INTERFACE_DETAILS);
mp->context = context;
mp->spd_index = htonl (spd_index);
@@ -704,7 +671,7 @@ send_ipsec_itf_details (ipsec_itf_t *itf, void *arg)
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IPSEC_ITF_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IPSEC_ITF_DETAILS);
mp->context = ctx->context;
mp->itf.mode = tunnel_mode_encode (itf->ii_mode);
@@ -773,7 +740,7 @@ send_ipsec_sa_details (ipsec_sa_t * sa, void *arg)
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IPSEC_SA_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IPSEC_SA_DETAILS);
mp->context = ctx->context;
mp->entry.sad_id = htonl (sa->id);
@@ -856,7 +823,7 @@ send_ipsec_sa_v2_details (ipsec_sa_t * sa, void *arg)
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IPSEC_SA_V2_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IPSEC_SA_V2_DETAILS);
mp->context = ctx->context;
mp->entry.sad_id = htonl (sa->id);
@@ -943,7 +910,7 @@ send_ipsec_sa_v3_details (ipsec_sa_t *sa, void *arg)
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IPSEC_SA_V3_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IPSEC_SA_V3_DETAILS);
mp->context = ctx->context;
mp->entry.sad_id = htonl (sa->id);
@@ -1036,7 +1003,7 @@ vl_api_ipsec_backend_dump_t_handler (vl_api_ipsec_backend_dump_t * mp)
pool_foreach (ab, im->ah_backends) {
vl_api_ipsec_backend_details_t *mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IPSEC_BACKEND_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IPSEC_BACKEND_DETAILS);
mp->context = context;
snprintf ((char *)mp->name, sizeof (mp->name), "%.*s", vec_len (ab->name),
ab->name);
@@ -1048,7 +1015,7 @@ vl_api_ipsec_backend_dump_t_handler (vl_api_ipsec_backend_dump_t * mp)
pool_foreach (eb, im->esp_backends) {
vl_api_ipsec_backend_details_t *mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IPSEC_BACKEND_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IPSEC_BACKEND_DETAILS);
mp->context = context;
snprintf ((char *)mp->name, sizeof (mp->name), "%.*s", vec_len (eb->name),
eb->name);
@@ -1105,44 +1072,14 @@ vl_api_ipsec_set_async_mode_t_handler (vl_api_ipsec_set_async_mode_t * mp)
REPLY_MACRO (VL_API_IPSEC_SET_ASYNC_MODE_REPLY);
}
-/*
- * ipsec_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_ipsec;
-#undef _
-}
-
+#include <vnet/ipsec/ipsec.api.c>
static clib_error_t *
ipsec_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 05b74f9e793..5ae5e7ecf7f 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -41,7 +41,6 @@
#include <vnet/l2/l2.api.h>
#include <vnet/span/span.api.h>
#include <vnet/ip/ip.api.h>
-#include <vnet/ipsec/ipsec.api.h>
#include <vnet/session/session.api.h>
#include <vnet/mpls/mpls.api.h>
#include <vnet/srv6/sr.api.h>