23 #include <vpp/app/version.h> 30 #include <plugins/ikev2/ikev2.api_enum.h> 31 #include <plugins/ikev2/ikev2.api_types.h> 35 #include <plugins/ikev2/ikev2.api.h> 36 #include <plugins/ikev2/ikev2_types.api.h> 41 #define IKEV2_PLUGIN_VERSION_MAJOR 1 42 #define IKEV2_PLUGIN_VERSION_MINOR 0 43 #define REPLY_MSG_ID_BASE ikev2_main.msg_id_base 49 return (ti << 16) | sai;
55 *sai = api_sai & 0xffff;
65 vl_api_ts->dh_group = ts->
dh_type;
85 vl_api_id->type =
id->type;
86 size_data =
sizeof (vl_api_id->data) - 1;
90 vl_api_id->data_len = size_data;
108 vl_api_auth->method = auth->
method;
110 vl_api_auth->hex = auth->
hex;
118 vl_api_responder->sw_if_index = responder->
sw_if_index;
126 vl_tr->transform_type = tr->
type;
146 int size_data =
sizeof (rmp->
profile.name) - 1;
174 vl_api_ikev2_profile_t_endian (&rmp->
profile);
192 send_profile (profile, reg, mp->context);
207 vl_api_ikev2_sa_t *rsa = &rmp->
sa;
208 vl_api_ikev2_keys_t* k = &rsa->keys;
209 rsa->profile_index = rsa->profile_index;
210 rsa->sa_index = api_sa_index;
213 rsa->ispi = sa->
ispi;
214 rsa->rspi = sa->
rspi;
227 IKEV2_TRANSFORM_TYPE_INTEG);
256 vl_api_ikev2_sa_t_endian(rsa);
273 u32 api_sa_index = ikev2_encode_sa_index (sa - tkm->sas,
274 tkm - km->per_thread_data);
275 send_sa (sa, mp, api_sa_index);
294 vl_api_ikev2_keys_t *k = &rmp->
child_sa.keys;
303 IKEV2_TRANSFORM_TYPE_ENCR);
308 IKEV2_TRANSFORM_TYPE_INTEG);
313 IKEV2_TRANSFORM_TYPE_ESN);
334 vl_api_ikev2_child_sa_t_endian (&rmp->
child_sa);
346 u32 sai = ~0, ti = ~0;
376 u32 sai = ~0, ti = ~0;
378 u32 api_sa_index = clib_net_to_host_u32 (mp->
sa_index);
405 rmp->
ts.sa_index = api_sa_index;
408 vl_api_ikev2_ts_t_endian (&rmp->
ts);
420 u32 sai = ~0, ti = ~0;
442 rmp->
data_len = clib_host_to_net_u32 (data_len);
454 int msg_size =
sizeof (*rmp);
476 vl_api_ikev2_profile_set_liveness_reply_t *rmp;
487 rv = VNET_API_ERROR_UNSPECIFIED;
490 rv = VNET_API_ERROR_UNIMPLEMENTED;
493 REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_LIVENESS_REPLY);
499 vl_api_ikev2_profile_add_del_reply_t *rmp;
512 rv = VNET_API_ERROR_UNSPECIFIED;
515 rv = VNET_API_ERROR_UNIMPLEMENTED;
525 vl_api_ikev2_profile_set_auth_reply_t *rmp;
542 rv = VNET_API_ERROR_UNSPECIFIED;
545 rv = VNET_API_ERROR_UNIMPLEMENTED;
554 vl_api_ikev2_profile_set_id_reply_t *rmp;
571 rv = VNET_API_ERROR_UNSPECIFIED;
574 rv = VNET_API_ERROR_UNIMPLEMENTED;
584 vl_api_ikev2_profile_set_udp_encap_reply_t *rmp;
597 rv = VNET_API_ERROR_UNSPECIFIED;
600 rv = VNET_API_ERROR_UNIMPLEMENTED;
603 REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_UDP_ENCAP_REPLY);
609 vl_api_ikev2_profile_set_ts_reply_t *rmp;
621 clib_net_to_host_u16 (mp->
ts.start_port),
622 clib_net_to_host_u16 (mp->
ts.end_port),
623 start_addr, end_addr, mp->
ts.is_local);
629 rv = VNET_API_ERROR_UNSPECIFIED;
632 rv = VNET_API_ERROR_UNIMPLEMENTED;
641 vl_api_ikev2_set_local_key_reply_t *rmp;
653 rv = VNET_API_ERROR_UNSPECIFIED;
656 rv = VNET_API_ERROR_UNIMPLEMENTED;
665 vl_api_ikev2_set_responder_reply_t *rmp;
683 rv = VNET_API_ERROR_UNSPECIFIED;
686 rv = VNET_API_ERROR_UNIMPLEMENTED;
696 vl_api_ikev2_set_ike_transforms_reply_t *rmp;
709 ntohl (mp->
tr.crypto_key_size));
715 rv = VNET_API_ERROR_UNSPECIFIED;
718 rv = VNET_API_ERROR_UNIMPLEMENTED;
721 REPLY_MACRO (VL_API_IKEV2_SET_IKE_TRANSFORMS_REPLY);
728 vl_api_ikev2_set_esp_transforms_reply_t *rmp;
740 ntohl (mp->
tr.crypto_key_size));
746 rv = VNET_API_ERROR_UNSPECIFIED;
749 rv = VNET_API_ERROR_UNIMPLEMENTED;
752 REPLY_MACRO (VL_API_IKEV2_SET_ESP_TRANSFORMS_REPLY);
758 vl_api_ikev2_set_sa_lifetime_reply_t *rmp;
769 clib_net_to_host_u64 (mp->
lifetime),
779 rv = VNET_API_ERROR_UNSPECIFIED;
782 rv = VNET_API_ERROR_UNIMPLEMENTED;
792 vl_api_ikev2_profile_set_ipsec_udp_port_reply_t *rmp;
802 clib_net_to_host_u16 (mp->
port),
806 rv = VNET_API_ERROR_UNIMPLEMENTED;
809 REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_IPSEC_UDP_PORT_REPLY);
816 vl_api_ikev2_set_tunnel_interface_reply_t *rmp;
832 rv = VNET_API_ERROR_UNSPECIFIED;
836 rv = VNET_API_ERROR_UNIMPLEMENTED;
840 REPLY_MACRO (VL_API_IKEV2_SET_TUNNEL_INTERFACE_REPLY);
846 vl_api_ikev2_initiate_sa_init_reply_t *rmp;
861 rv = VNET_API_ERROR_UNSPECIFIED;
864 rv = VNET_API_ERROR_UNIMPLEMENTED;
874 vl_api_ikev2_initiate_del_ike_sa_reply_t *rmp;
886 rv = VNET_API_ERROR_UNSPECIFIED;
889 rv = VNET_API_ERROR_UNIMPLEMENTED;
892 REPLY_MACRO (VL_API_IKEV2_INITIATE_DEL_IKE_SA_REPLY);
899 vl_api_ikev2_initiate_del_child_sa_reply_t *rmp;
911 rv = VNET_API_ERROR_UNSPECIFIED;
914 rv = VNET_API_ERROR_UNIMPLEMENTED;
917 REPLY_MACRO (VL_API_IKEV2_INITIATE_DEL_CHILD_SA_REPLY);
924 vl_api_ikev2_profile_disable_natt_reply_t *rmp;
937 rv = VNET_API_ERROR_UNSPECIFIED;
940 rv = VNET_API_ERROR_UNIMPLEMENTED;
943 REPLY_MACRO (VL_API_IKEV2_PROFILE_DISABLE_NATT_REPLY);
950 vl_api_ikev2_initiate_rekey_child_sa_reply_t *rmp;
962 rv = VNET_API_ERROR_UNSPECIFIED;
965 rv = VNET_API_ERROR_UNIMPLEMENTED;
968 REPLY_MACRO (VL_API_IKEV2_INITIATE_REKEY_CHILD_SA_REPLY);
971 #include <ikev2/ikev2.api.c> ikev2_main_per_thread_data_t * per_thread_data
clib_error_t * ikev2_profile_natt_disable(u8 *name)
vl_api_address_t end_addr
u8 * format_clib_error(u8 *s, va_list *va)
details on specific traffic selector
ikev2_transforms_set ike_ts
static void vl_api_ikev2_profile_set_ipsec_udp_port_t_handler(vl_api_ikev2_profile_set_ipsec_udp_port_t *mp)
void ip_address_encode2(const ip_address_t *in, vl_api_address_t *out)
static void vl_api_ikev2_initiate_rekey_child_sa_t_handler(vl_api_ikev2_initiate_rekey_child_sa_t *mp)
IKEv2: Set Child SA lifetime, limited by time and/or data.
static void vl_api_ikev2_nonce_get_t_handler(vl_api_ikev2_nonce_get_t *mp)
clib_error_t * ikev2_add_del_profile(vlib_main_t *vm, u8 *name, int is_add)
clib_error_t * ikev2_set_profile_udp_encap(vlib_main_t *vm, u8 *name)
IKEv2: Disable NAT traversal.
static void cp_responder(vl_api_ikev2_responder_t *vl_api_responder, ikev2_responder_t *responder)
IKEv2: Add/delete profile.
ikev2_profile_t * profiles
clib_error_t * ikev2_initiate_delete_ike_sa(vlib_main_t *vm, u64 ispi)
vl_api_address_t start_addr
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
clib_error_t * ikev2_set_profile_tunnel_interface(vlib_main_t *vm, u8 *name, u32 sw_if_index)
IKEv2: Set liveness parameters.
static void vl_api_ikev2_profile_disable_natt_t_handler(vl_api_ikev2_profile_disable_natt_t *mp)
clib_error_t * ikev2_set_profile_sa_lifetime(vlib_main_t *vm, u8 *name, u64 lifetime, u32 jitter, u32 handover, u64 maxdata)
static void vl_api_ikev2_initiate_sa_init_t_handler(vl_api_ikev2_initiate_sa_init_t *mp)
clib_error_t * ikev2_set_liveness_params(u32 period, u32 max_retries)
#define REPLY_MACRO2_ZERO(t, body)
static u32 ikev2_encode_sa_index(u32 sai, u32 ti)
static void ikev2_decode_sa_index(u32 api_sai, u32 *sai, u32 *ti)
static void vl_api_ikev2_set_sa_lifetime_t_handler(vl_api_ikev2_set_sa_lifetime_t *mp)
void * vl_msg_api_alloc(int nbytes)
static void vl_api_ikev2_initiate_del_ike_sa_t_handler(vl_api_ikev2_initiate_del_ike_sa_t *mp)
vnet_api_error_t ikev2_set_profile_ipsec_udp_port(vlib_main_t *vm, u8 *name, u16 port, u8 is_set)
#define pool_len(p)
Number of elements in pool vector.
ikev2_sa_transform_t * ikev2_sa_get_td_for_type(ikev2_sa_proposal_t *p, ikev2_transform_type_t type)
#define clib_memcpy(d, s, n)
static void vl_api_ikev2_child_sa_dump_t_handler(vl_api_ikev2_child_sa_dump_t *mp)
static void vl_api_ikev2_profile_dump_t_handler(vl_api_ikev2_profile_dump_t *mp)
static void vl_api_ikev2_plugin_get_version_t_handler(vl_api_ikev2_plugin_get_version_t *mp)
static void vl_api_ikev2_set_local_key_t_handler(vl_api_ikev2_set_local_key_t *mp)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
ikev2_sa_proposal_t * r_proposals
#define VLIB_INIT_FUNCTION(x)
clib_error_t * ikev2_initiate_sa_init(vlib_main_t *vm, u8 *name)
static void send_sa(ikev2_sa_t *sa, vl_api_ikev2_sa_dump_t *mp, u32 api_sa_index)
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
clib_error_t * ikev2_set_profile_auth(vlib_main_t *vm, u8 *name, u8 auth_method, u8 *auth_data, u8 data_hex_format)
static void vl_api_ikev2_set_tunnel_interface_t_handler(vl_api_ikev2_set_tunnel_interface_t *mp)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static void cp_id(vl_api_ikev2_id_t *vl_api_id, ikev2_id_t *id)
IKEv2: Initiate the delete Child SA exchange.
IKEv2: Set IKEv2 profile local/remote identification.
static void vl_api_ikev2_profile_set_ts_t_handler(vl_api_ikev2_profile_set_ts_t *mp)
IKEv2: Set IKEv2 profile traffic selector parameters.
static void cp_esp_transforms(vl_api_ikev2_esp_transforms_t *vl_api_ts, ikev2_transforms_set *ts)
clib_error_t * ikev2_set_profile_esp_transforms(vlib_main_t *vm, u8 *name, ikev2_transform_encr_type_t crypto_alg, ikev2_transform_integ_type_t integ_alg, u32 crypto_key_size)
static void vl_api_ikev2_set_ike_transforms_t_handler(vl_api_ikev2_set_ike_transforms_t *mp)
ikev2_responder_t responder
static void cp_ike_transforms(vl_api_ikev2_ike_transforms_t *vl_api_ts, ikev2_transforms_set *ts)
clib_error_t * ikev2_set_profile_id(vlib_main_t *vm, u8 *name, u8 id_type, u8 *data, int is_local)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
IKEv2: Initiate the rekey Child SA exchange.
static void vl_api_ikev2_traffic_selector_dump_t_handler(vl_api_ikev2_traffic_selector_dump_t *mp)
ikev2_sa_proposal_t * i_proposals
clib_error_t * ikev2_initiate_delete_child_sa(vlib_main_t *vm, u32 ispi)
vl_api_ikev2_profile_t profile
vl_api_interface_index_t sw_if_index
static void vl_api_ikev2_set_responder_t_handler(vl_api_ikev2_set_responder_t *mp)
clib_error_t * ikev2_set_local_key(vlib_main_t *vm, u8 *file)
Dump child SA of specific SA.
void ip_address_decode2(const vl_api_address_t *in, ip_address_t *out)
An API client registration, only in vpp/vlib.
#define BAD_SW_IF_INDEX_LABEL
clib_error_t * ikev2_initiate_rekey_child_sa(vlib_main_t *vm, u32 ispi)
ikev2_auth_method_t method
static void vl_api_ikev2_initiate_del_child_sa_t_handler(vl_api_ikev2_initiate_del_child_sa_t *mp)
#define vec_free(V)
Free vector's memory (no header).
static void cp_auth(vl_api_ikev2_auth_t *vl_api_auth, ikev2_auth_t *auth)
vl_api_ikev2_responder_t responder
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
IKEv2: Initiate the SA_INIT exchange.
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
static void vl_api_ikev2_profile_set_liveness_t_handler(vl_api_ikev2_profile_set_liveness_t *mp)
#define ikev2_log_error(...)
ikev2_sa_proposal_t * r_proposals
IKEv2: Set/unset custom ipsec-over-udp port.
IKEv2: Set IKEv2 responder interface and IP address.
IKEv2: Initiate the delete IKE SA exchange.
vl_api_ikev2_responder_t responder
IKEv2: Set IKEv2 profile authentication method.
static void vl_api_ikev2_profile_set_auth_t_handler(vl_api_ikev2_profile_set_auth_t *mp)
Details about all profiles.
static vlib_main_t * vlib_get_main(void)
#define IKEV2_PLUGIN_VERSION_MINOR
static void vl_api_ikev2_sa_dump_t_handler(vl_api_ikev2_sa_dump_t *mp)
#define IKEV2_PLUGIN_VERSION_MAJOR
IKEv2: Set IKEv2 local RSA private key.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * ikev2_set_profile_responder(vlib_main_t *vm, u8 *name, u32 sw_if_index, ip_address_t addr)
void cp_sa_transform(vl_api_ikev2_sa_transform_t *vl_tr, ikev2_sa_transform_t *tr)
static void vl_api_ikev2_profile_set_id_t_handler(vl_api_ikev2_profile_set_id_t *mp)
clib_error_t * ikev2_set_profile_ike_transforms(vlib_main_t *vm, u8 *name, ikev2_transform_encr_type_t crypto_alg, ikev2_transform_integ_type_t integ_alg, ikev2_transform_dh_type_t dh_type, u32 crypto_key_size)
static void vl_api_ikev2_profile_set_udp_encap_t_handler(vl_api_ikev2_profile_set_udp_encap_t *mp)
ikev2_child_sa_t * childs
#define clib_error_free(e)
static void send_profile(ikev2_profile_t *profile, vl_api_registration_t *reg, u32 context)
static void vl_api_ikev2_set_esp_transforms_t_handler(vl_api_ikev2_set_esp_transforms_t *mp)
#define vec_foreach(var, vec)
Vector iterator.
static void setup_message_id_table(snat_main_t *sm, api_main_t *am)
static void cp_ts(vl_api_ikev2_ts_t *vl_api_ts, ikev2_ts_t *ts, u8 is_local)
static void vl_api_ikev2_profile_add_del_t_handler(vl_api_ikev2_profile_add_del_t *mp)
Reply to get the plugin version.
static void send_child_sa(ikev2_child_sa_t *child, vl_api_ikev2_child_sa_dump_t *mp, u32 child_sa_index, u32 sa_index)
IKEv2: Set UDP encapsulation.
ikev2_transforms_set esp_ts
#define REPLY_MACRO3_ZERO(t, n, body)
clib_error_t * ikev2_set_profile_ts(vlib_main_t *vm, u8 *name, u8 protocol_id, u16 start_port, u16 end_port, ip_address_t start_addr, ip_address_t end_addr, int is_local)
vl_api_ikev2_child_sa_t child_sa
IKEv2: Set the tunnel interface which will be protected by IKE If this API is not called...
static clib_error_t * ikev2_api_init(vlib_main_t *vm)
vl_api_interface_index_t sw_if_index
#define VALIDATE_SW_IF_INDEX(mp)