2 *------------------------------------------------------------------
3 * ipsec_api.c - ipsec api
5 * Copyright (c) 2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <vnet/ip/ip.h>
27 #include <vnet/vnet_msg_enum.h>
30 #include <vnet/ipsec/ipsec.h>
31 #include <vnet/ipsec/ikev2.h>
34 #define vl_typedefs /* define message structures */
35 #include <vnet/vnet_all_api_h.h>
38 #define vl_endianfun /* define message structures */
39 #include <vnet/vnet_all_api_h.h>
42 /* instantiate all the print functions we know about */
43 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
45 #include <vnet/vnet_all_api_h.h>
48 #include <vlibapi/api_helper_macros.h>
50 #define foreach_vpe_api_msg \
51 _(IPSEC_SPD_ADD_DEL, ipsec_spd_add_del) \
52 _(IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd) \
53 _(IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry) \
54 _(IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry) \
55 _(IPSEC_SA_SET_KEY, ipsec_sa_set_key) \
56 _(IPSEC_SA_DUMP, ipsec_sa_dump) \
57 _(IPSEC_SPD_DUMP, ipsec_spd_dump) \
58 _(IPSEC_TUNNEL_IF_ADD_DEL, ipsec_tunnel_if_add_del) \
59 _(IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del) \
60 _(IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth) \
61 _(IKEV2_PROFILE_SET_ID, ikev2_profile_set_id) \
62 _(IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts) \
63 _(IKEV2_SET_LOCAL_KEY, ikev2_set_local_key) \
64 _(IKEV2_SET_RESPONDER, ikev2_set_responder) \
65 _(IKEV2_SET_IKE_TRANSFORMS, ikev2_set_ike_transforms) \
66 _(IKEV2_SET_ESP_TRANSFORMS, ikev2_set_esp_transforms) \
67 _(IKEV2_SET_SA_LIFETIME, ikev2_set_sa_lifetime) \
68 _(IKEV2_INITIATE_SA_INIT, ikev2_initiate_sa_init) \
69 _(IKEV2_INITIATE_DEL_IKE_SA, ikev2_initiate_del_ike_sa) \
70 _(IKEV2_INITIATE_DEL_CHILD_SA, ikev2_initiate_del_child_sa) \
71 _(IKEV2_INITIATE_REKEY_CHILD_SA, ikev2_initiate_rekey_child_sa)
73 static void vl_api_ipsec_spd_add_del_t_handler
74 (vl_api_ipsec_spd_add_del_t * mp)
77 clib_warning ("unimplemented");
80 vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
81 vl_api_ipsec_spd_add_del_reply_t *rmp;
84 rv = ipsec_add_del_spd (vm, ntohl (mp->spd_id), mp->is_add);
86 REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_REPLY);
90 static void vl_api_ipsec_interface_add_del_spd_t_handler
91 (vl_api_ipsec_interface_add_del_spd_t * mp)
93 vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
94 vl_api_ipsec_interface_add_del_spd_reply_t *rmp;
96 u32 sw_if_index __attribute__ ((unused));
97 u32 spd_id __attribute__ ((unused));
99 sw_if_index = ntohl (mp->sw_if_index);
100 spd_id = ntohl (mp->spd_id);
102 VALIDATE_SW_IF_INDEX (mp);
105 rv = ipsec_set_interface_spd (vm, sw_if_index, spd_id, mp->is_add);
107 rv = VNET_API_ERROR_UNIMPLEMENTED;
110 BAD_SW_IF_INDEX_LABEL;
112 REPLY_MACRO (VL_API_IPSEC_INTERFACE_ADD_DEL_SPD_REPLY);
115 static void vl_api_ipsec_spd_add_del_entry_t_handler
116 (vl_api_ipsec_spd_add_del_entry_t * mp)
118 vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
119 vl_api_ipsec_spd_add_del_entry_reply_t *rmp;
125 memset (&p, 0, sizeof (p));
127 p.id = ntohl (mp->spd_id);
128 p.priority = ntohl (mp->priority);
129 p.is_outbound = mp->is_outbound;
130 p.is_ipv6 = mp->is_ipv6;
132 if (mp->is_ipv6 || mp->is_ip_any)
134 clib_memcpy (&p.raddr.start, mp->remote_address_start, 16);
135 clib_memcpy (&p.raddr.stop, mp->remote_address_stop, 16);
136 clib_memcpy (&p.laddr.start, mp->local_address_start, 16);
137 clib_memcpy (&p.laddr.stop, mp->local_address_stop, 16);
141 clib_memcpy (&p.raddr.start.ip4.data, mp->remote_address_start, 4);
142 clib_memcpy (&p.raddr.stop.ip4.data, mp->remote_address_stop, 4);
143 clib_memcpy (&p.laddr.start.ip4.data, mp->local_address_start, 4);
144 clib_memcpy (&p.laddr.stop.ip4.data, mp->local_address_stop, 4);
146 p.protocol = mp->protocol;
147 p.rport.start = ntohs (mp->remote_port_start);
148 p.rport.stop = ntohs (mp->remote_port_stop);
149 p.lport.start = ntohs (mp->local_port_start);
150 p.lport.stop = ntohs (mp->local_port_stop);
151 /* policy action resolve unsupported */
152 if (mp->policy == IPSEC_POLICY_ACTION_RESOLVE)
154 clib_warning ("unsupported action: 'resolve'");
155 rv = VNET_API_ERROR_UNIMPLEMENTED;
158 p.policy = mp->policy;
159 p.sa_id = ntohl (mp->sa_id);
161 rv = ipsec_add_del_policy (vm, &p, mp->is_add);
168 rv = ipsec_add_del_policy (vm, &p, mp->is_add);
171 rv = VNET_API_ERROR_UNIMPLEMENTED;
176 REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_ENTRY_REPLY);
179 static void vl_api_ipsec_sad_add_del_entry_t_handler
180 (vl_api_ipsec_sad_add_del_entry_t * mp)
182 vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
183 vl_api_ipsec_sad_add_del_entry_reply_t *rmp;
186 ipsec_main_t *im = &ipsec_main;
189 memset (&sa, 0, sizeof (sa));
191 sa.id = ntohl (mp->sad_id);
192 sa.spi = ntohl (mp->spi);
193 /* security protocol AH unsupported */
194 if (mp->protocol == IPSEC_PROTOCOL_AH)
196 clib_warning ("unsupported security protocol 'AH'");
197 rv = VNET_API_ERROR_UNIMPLEMENTED;
200 sa.protocol = mp->protocol;
201 /* check for unsupported crypto-alg */
202 if (mp->crypto_algorithm < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
203 mp->crypto_algorithm >= IPSEC_CRYPTO_N_ALG)
205 clib_warning ("unsupported crypto-alg: '%U'", format_ipsec_crypto_alg,
206 mp->crypto_algorithm);
207 rv = VNET_API_ERROR_UNIMPLEMENTED;
210 sa.crypto_alg = mp->crypto_algorithm;
211 sa.crypto_key_len = mp->crypto_key_length;
212 clib_memcpy (&sa.crypto_key, mp->crypto_key, sizeof (sa.crypto_key));
213 /* check for unsupported integ-alg */
214 if (mp->integrity_algorithm >= IPSEC_INTEG_N_ALG)
216 clib_warning ("unsupported integ-alg: '%U'", format_ipsec_integ_alg,
217 mp->integrity_algorithm);
218 rv = VNET_API_ERROR_UNIMPLEMENTED;
222 sa.integ_alg = mp->integrity_algorithm;
223 sa.integ_key_len = mp->integrity_key_length;
224 clib_memcpy (&sa.integ_key, mp->integrity_key, sizeof (sa.integ_key));
225 sa.use_esn = mp->use_extended_sequence_number;
226 sa.is_tunnel = mp->is_tunnel;
227 sa.is_tunnel_ip6 = mp->is_tunnel_ipv6;
228 if (sa.is_tunnel_ip6)
230 clib_memcpy (&sa.tunnel_src_addr, mp->tunnel_src_address, 16);
231 clib_memcpy (&sa.tunnel_dst_addr, mp->tunnel_dst_address, 16);
235 clib_memcpy (&sa.tunnel_src_addr.ip4.data, mp->tunnel_src_address, 4);
236 clib_memcpy (&sa.tunnel_dst_addr.ip4.data, mp->tunnel_dst_address, 4);
239 ASSERT (im->cb.check_support_cb);
240 clib_error_t *err = im->cb.check_support_cb (&sa);
243 clib_warning ("%s", err->what);
244 rv = VNET_API_ERROR_UNIMPLEMENTED;
248 rv = ipsec_add_del_sa (vm, &sa, mp->is_add);
250 rv = VNET_API_ERROR_UNIMPLEMENTED;
255 REPLY_MACRO (VL_API_IPSEC_SAD_ADD_DEL_ENTRY_REPLY);
259 send_ipsec_spd_details (ipsec_policy_t * p, unix_shared_memory_queue_t * q,
262 vl_api_ipsec_spd_details_t *mp;
264 mp = vl_msg_api_alloc (sizeof (*mp));
265 memset (mp, 0, sizeof (*mp));
266 mp->_vl_msg_id = ntohs (VL_API_IPSEC_SPD_DETAILS);
267 mp->context = context;
269 mp->spd_id = htonl (p->id);
270 mp->priority = htonl (p->priority);
271 mp->is_outbound = p->is_outbound;
272 mp->is_ipv6 = p->is_ipv6;
275 memcpy (mp->local_start_addr, &p->laddr.start.ip6, 16);
276 memcpy (mp->local_stop_addr, &p->laddr.stop.ip6, 16);
277 memcpy (mp->remote_start_addr, &p->raddr.start.ip6, 16);
278 memcpy (mp->remote_stop_addr, &p->raddr.stop.ip6, 16);
282 memcpy (mp->local_start_addr, &p->laddr.start.ip4, 4);
283 memcpy (mp->local_stop_addr, &p->laddr.stop.ip4, 4);
284 memcpy (mp->remote_start_addr, &p->raddr.start.ip4, 4);
285 memcpy (mp->remote_stop_addr, &p->raddr.stop.ip4, 4);
287 mp->local_start_port = htons (p->lport.start);
288 mp->local_stop_port = htons (p->lport.stop);
289 mp->remote_start_port = htons (p->rport.start);
290 mp->remote_stop_port = htons (p->rport.stop);
291 mp->protocol = p->protocol;
292 mp->policy = p->policy;
293 mp->sa_id = htonl (p->sa_id);
294 mp->bytes = clib_host_to_net_u64 (p->counter.bytes);
295 mp->packets = clib_host_to_net_u64 (p->counter.packets);
297 vl_msg_api_send_shmem (q, (u8 *) & mp);
301 vl_api_ipsec_spd_dump_t_handler (vl_api_ipsec_spd_dump_t * mp)
303 unix_shared_memory_queue_t *q;
304 ipsec_main_t *im = &ipsec_main;
305 ipsec_policy_t *policy;
310 q = vl_api_client_index_to_input_queue (mp->client_index);
314 p = hash_get (im->spd_index_by_spd_id, ntohl (mp->spd_id));
319 spd = pool_elt_at_index (im->spds, spd_index);
322 pool_foreach (policy, spd->policies,
324 if (mp->sa_id == ~(0) || ntohl (mp->sa_id) == policy->sa_id)
325 send_ipsec_spd_details (policy, q,
330 clib_warning ("unimplemented");
335 vl_api_ipsec_sa_set_key_t_handler (vl_api_ipsec_sa_set_key_t * mp)
337 vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
338 vl_api_ipsec_sa_set_key_reply_t *rmp;
342 sa.id = ntohl (mp->sa_id);
343 sa.crypto_key_len = mp->crypto_key_length;
344 clib_memcpy (&sa.crypto_key, mp->crypto_key, sizeof (sa.crypto_key));
345 sa.integ_key_len = mp->integrity_key_length;
346 clib_memcpy (&sa.integ_key, mp->integrity_key, sizeof (sa.integ_key));
348 rv = ipsec_set_sa_key (vm, &sa);
350 rv = VNET_API_ERROR_UNIMPLEMENTED;
353 REPLY_MACRO (VL_API_IPSEC_SA_SET_KEY_REPLY);
357 vl_api_ipsec_tunnel_if_add_del_t_handler (vl_api_ipsec_tunnel_if_add_del_t *
360 vl_api_ipsec_tunnel_if_add_del_reply_t *rmp;
361 ipsec_main_t *im = &ipsec_main;
362 vnet_main_t *vnm = im->vnet_main;
363 u32 sw_if_index = ~0;
367 ipsec_add_del_tunnel_args_t tun;
369 memset (&tun, 0, sizeof (ipsec_add_del_tunnel_args_t));
371 tun.is_add = mp->is_add;
373 tun.anti_replay = mp->anti_replay;
374 tun.local_spi = ntohl (mp->local_spi);
375 tun.remote_spi = ntohl (mp->remote_spi);
376 tun.crypto_alg = mp->crypto_alg;
377 tun.local_crypto_key_len = mp->local_crypto_key_len;
378 tun.remote_crypto_key_len = mp->remote_crypto_key_len;
379 tun.integ_alg = mp->integ_alg;
380 tun.local_integ_key_len = mp->local_integ_key_len;
381 tun.remote_integ_key_len = mp->remote_integ_key_len;
382 memcpy (&tun.local_ip, mp->local_ip, 4);
383 memcpy (&tun.remote_ip, mp->remote_ip, 4);
384 memcpy (&tun.local_crypto_key, &mp->local_crypto_key,
385 mp->local_crypto_key_len);
386 memcpy (&tun.remote_crypto_key, &mp->remote_crypto_key,
387 mp->remote_crypto_key_len);
388 memcpy (&tun.local_integ_key, &mp->local_integ_key,
389 mp->local_integ_key_len);
390 memcpy (&tun.remote_integ_key, &mp->remote_integ_key,
391 mp->remote_integ_key_len);
393 rv = ipsec_add_del_tunnel_if_internal (vnm, &tun, &sw_if_index);
396 rv = VNET_API_ERROR_UNIMPLEMENTED;
399 REPLY_MACRO2 (VL_API_IPSEC_TUNNEL_IF_ADD_DEL_REPLY, (
407 send_ipsec_sa_details (ipsec_sa_t * sa, unix_shared_memory_queue_t * q,
408 u32 context, u32 sw_if_index)
410 vl_api_ipsec_sa_details_t *mp;
412 mp = vl_msg_api_alloc (sizeof (*mp));
413 memset (mp, 0, sizeof (*mp));
414 mp->_vl_msg_id = ntohs (VL_API_IPSEC_SA_DETAILS);
415 mp->context = context;
417 mp->sa_id = htonl (sa->id);
418 mp->sw_if_index = htonl (sw_if_index);
420 mp->spi = htonl (sa->spi);
421 mp->protocol = sa->protocol;
423 mp->crypto_alg = sa->crypto_alg;
424 mp->crypto_key_len = sa->crypto_key_len;
425 memcpy (mp->crypto_key, sa->crypto_key, sa->crypto_key_len);
427 mp->integ_alg = sa->integ_alg;
428 mp->integ_key_len = sa->integ_key_len;
429 memcpy (mp->integ_key, sa->integ_key, sa->integ_key_len);
431 mp->use_esn = sa->use_esn;
432 mp->use_anti_replay = sa->use_anti_replay;
434 mp->is_tunnel = sa->is_tunnel;
435 mp->is_tunnel_ip6 = sa->is_tunnel_ip6;
439 if (sa->is_tunnel_ip6)
441 memcpy (mp->tunnel_src_addr, &sa->tunnel_src_addr.ip6, 16);
442 memcpy (mp->tunnel_dst_addr, &sa->tunnel_dst_addr.ip6, 16);
446 memcpy (mp->tunnel_src_addr, &sa->tunnel_src_addr.ip4, 4);
447 memcpy (mp->tunnel_dst_addr, &sa->tunnel_dst_addr.ip4, 4);
451 mp->salt = clib_host_to_net_u32 (sa->salt);
452 mp->seq_outbound = clib_host_to_net_u64 (((u64) sa->seq));
453 mp->last_seq_inbound = clib_host_to_net_u64 (((u64) sa->last_seq));
456 mp->seq_outbound |= (u64) (clib_host_to_net_u32 (sa->seq_hi));
457 mp->last_seq_inbound |= (u64) (clib_host_to_net_u32 (sa->last_seq_hi));
459 if (sa->use_anti_replay)
460 mp->replay_window = clib_host_to_net_u64 (sa->replay_window);
461 mp->total_data_size = clib_host_to_net_u64 (sa->total_data_size);
463 vl_msg_api_send_shmem (q, (u8 *) & mp);
468 vl_api_ipsec_sa_dump_t_handler (vl_api_ipsec_sa_dump_t * mp)
470 unix_shared_memory_queue_t *q;
471 ipsec_main_t *im = &ipsec_main;
472 vnet_main_t *vnm = im->vnet_main;
474 ipsec_tunnel_if_t *t;
475 u32 *sa_index_to_tun_if_index = 0;
478 q = vl_api_client_index_to_input_queue (mp->client_index);
479 if (q == 0 || pool_elts (im->sad) == 0)
482 vec_validate_init_empty (sa_index_to_tun_if_index, vec_len (im->sad) - 1,
486 pool_foreach (t, im->tunnel_interfaces,
488 vnet_hw_interface_t *hi;
489 u32 sw_if_index = ~0;
491 hi = vnet_get_hw_interface (vnm, t->hw_if_index);
492 sw_if_index = hi->sw_if_index;
493 sa_index_to_tun_if_index[t->input_sa_index] = sw_if_index;
494 sa_index_to_tun_if_index[t->output_sa_index] = sw_if_index;
497 pool_foreach (sa, im->sad,
499 if (mp->sa_id == ~(0) || ntohl (mp->sa_id) == sa->id)
500 send_ipsec_sa_details (sa, q, mp->context,
501 sa_index_to_tun_if_index[sa - im->sad]);
505 vec_free (sa_index_to_tun_if_index);
507 clib_warning ("unimplemented");
513 vl_api_ikev2_profile_add_del_t_handler (vl_api_ikev2_profile_add_del_t * mp)
515 vl_api_ikev2_profile_add_del_reply_t *rmp;
519 vlib_main_t *vm = vlib_get_main ();
521 u8 *tmp = format (0, "%s", mp->name);
522 error = ikev2_add_del_profile (vm, tmp, mp->is_add);
525 rv = VNET_API_ERROR_UNSPECIFIED;
527 rv = VNET_API_ERROR_UNIMPLEMENTED;
530 REPLY_MACRO (VL_API_IKEV2_PROFILE_ADD_DEL_REPLY);
534 vl_api_ikev2_profile_set_auth_t_handler
535 (vl_api_ikev2_profile_set_auth_t * mp)
537 vl_api_ikev2_profile_set_auth_reply_t *rmp;
541 vlib_main_t *vm = vlib_get_main ();
543 u8 *tmp = format (0, "%s", mp->name);
544 u8 *data = vec_new (u8, mp->data_len);
545 clib_memcpy (data, mp->data, mp->data_len);
546 error = ikev2_set_profile_auth (vm, tmp, mp->auth_method, data, mp->is_hex);
550 rv = VNET_API_ERROR_UNSPECIFIED;
552 rv = VNET_API_ERROR_UNIMPLEMENTED;
555 REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_AUTH_REPLY);
559 vl_api_ikev2_profile_set_id_t_handler (vl_api_ikev2_profile_set_id_t * mp)
561 vl_api_ikev2_profile_add_del_reply_t *rmp;
565 vlib_main_t *vm = vlib_get_main ();
567 u8 *tmp = format (0, "%s", mp->name);
568 u8 *data = vec_new (u8, mp->data_len);
569 clib_memcpy (data, mp->data, mp->data_len);
570 error = ikev2_set_profile_id (vm, tmp, mp->id_type, data, mp->is_local);
574 rv = VNET_API_ERROR_UNSPECIFIED;
576 rv = VNET_API_ERROR_UNIMPLEMENTED;
579 REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_ID_REPLY);
583 vl_api_ikev2_profile_set_ts_t_handler (vl_api_ikev2_profile_set_ts_t * mp)
585 vl_api_ikev2_profile_set_ts_reply_t *rmp;
589 vlib_main_t *vm = vlib_get_main ();
591 u8 *tmp = format (0, "%s", mp->name);
592 error = ikev2_set_profile_ts (vm, tmp, mp->proto, mp->start_port,
593 mp->end_port, (ip4_address_t) mp->start_addr,
594 (ip4_address_t) mp->end_addr, mp->is_local);
597 rv = VNET_API_ERROR_UNSPECIFIED;
599 rv = VNET_API_ERROR_UNIMPLEMENTED;
602 REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_TS_REPLY);
606 vl_api_ikev2_set_local_key_t_handler (vl_api_ikev2_set_local_key_t * mp)
608 vl_api_ikev2_profile_set_ts_reply_t *rmp;
612 vlib_main_t *vm = vlib_get_main ();
615 error = ikev2_set_local_key (vm, mp->key_file);
617 rv = VNET_API_ERROR_UNSPECIFIED;
619 rv = VNET_API_ERROR_UNIMPLEMENTED;
622 REPLY_MACRO (VL_API_IKEV2_SET_LOCAL_KEY_REPLY);
626 vl_api_ikev2_set_responder_t_handler (vl_api_ikev2_set_responder_t * mp)
628 vl_api_ikev2_set_responder_reply_t *rmp;
632 vlib_main_t *vm = vlib_get_main ();
635 u8 *tmp = format (0, "%s", mp->name);
637 clib_memcpy (&ip4, mp->address, sizeof (ip4));
639 error = ikev2_set_profile_responder (vm, tmp, mp->sw_if_index, ip4);
642 rv = VNET_API_ERROR_UNSPECIFIED;
644 rv = VNET_API_ERROR_UNIMPLEMENTED;
647 REPLY_MACRO (VL_API_IKEV2_SET_RESPONDER_REPLY);
651 vl_api_ikev2_set_ike_transforms_t_handler (vl_api_ikev2_set_ike_transforms_t *
654 vl_api_ikev2_set_ike_transforms_reply_t *rmp;
658 vlib_main_t *vm = vlib_get_main ();
661 u8 *tmp = format (0, "%s", mp->name);
664 ikev2_set_profile_ike_transforms (vm, tmp, mp->crypto_alg, mp->integ_alg,
665 mp->dh_group, mp->crypto_key_size);
668 rv = VNET_API_ERROR_UNSPECIFIED;
670 rv = VNET_API_ERROR_UNIMPLEMENTED;
673 REPLY_MACRO (VL_API_IKEV2_SET_IKE_TRANSFORMS_REPLY);
677 vl_api_ikev2_set_esp_transforms_t_handler (vl_api_ikev2_set_esp_transforms_t *
680 vl_api_ikev2_set_esp_transforms_reply_t *rmp;
684 vlib_main_t *vm = vlib_get_main ();
687 u8 *tmp = format (0, "%s", mp->name);
690 ikev2_set_profile_esp_transforms (vm, tmp, mp->crypto_alg, mp->integ_alg,
691 mp->dh_group, mp->crypto_key_size);
694 rv = VNET_API_ERROR_UNSPECIFIED;
696 rv = VNET_API_ERROR_UNIMPLEMENTED;
699 REPLY_MACRO (VL_API_IKEV2_SET_ESP_TRANSFORMS_REPLY);
703 vl_api_ikev2_set_sa_lifetime_t_handler (vl_api_ikev2_set_sa_lifetime_t * mp)
705 vl_api_ikev2_set_sa_lifetime_reply_t *rmp;
709 vlib_main_t *vm = vlib_get_main ();
712 u8 *tmp = format (0, "%s", mp->name);
715 ikev2_set_profile_sa_lifetime (vm, tmp, mp->lifetime, mp->lifetime_jitter,
716 mp->handover, mp->lifetime_maxdata);
719 rv = VNET_API_ERROR_UNSPECIFIED;
721 rv = VNET_API_ERROR_UNIMPLEMENTED;
724 REPLY_MACRO (VL_API_IKEV2_SET_SA_LIFETIME_REPLY);
728 vl_api_ikev2_initiate_sa_init_t_handler (vl_api_ikev2_initiate_sa_init_t * mp)
730 vl_api_ikev2_initiate_sa_init_reply_t *rmp;
734 vlib_main_t *vm = vlib_get_main ();
737 u8 *tmp = format (0, "%s", mp->name);
739 error = ikev2_initiate_sa_init (vm, tmp);
742 rv = VNET_API_ERROR_UNSPECIFIED;
744 rv = VNET_API_ERROR_UNIMPLEMENTED;
747 REPLY_MACRO (VL_API_IKEV2_INITIATE_SA_INIT_REPLY);
751 vl_api_ikev2_initiate_del_ike_sa_t_handler (vl_api_ikev2_initiate_del_ike_sa_t
754 vl_api_ikev2_initiate_del_ike_sa_reply_t *rmp;
758 vlib_main_t *vm = vlib_get_main ();
761 error = ikev2_initiate_delete_ike_sa (vm, mp->ispi);
763 rv = VNET_API_ERROR_UNSPECIFIED;
765 rv = VNET_API_ERROR_UNIMPLEMENTED;
768 REPLY_MACRO (VL_API_IKEV2_INITIATE_DEL_IKE_SA_REPLY);
772 vl_api_ikev2_initiate_del_child_sa_t_handler
773 (vl_api_ikev2_initiate_del_child_sa_t * mp)
775 vl_api_ikev2_initiate_del_child_sa_reply_t *rmp;
779 vlib_main_t *vm = vlib_get_main ();
782 error = ikev2_initiate_delete_child_sa (vm, mp->ispi);
784 rv = VNET_API_ERROR_UNSPECIFIED;
786 rv = VNET_API_ERROR_UNIMPLEMENTED;
789 REPLY_MACRO (VL_API_IKEV2_INITIATE_DEL_CHILD_SA_REPLY);
793 vl_api_ikev2_initiate_rekey_child_sa_t_handler
794 (vl_api_ikev2_initiate_rekey_child_sa_t * mp)
796 vl_api_ikev2_initiate_rekey_child_sa_reply_t *rmp;
800 vlib_main_t *vm = vlib_get_main ();
803 error = ikev2_initiate_rekey_child_sa (vm, mp->ispi);
805 rv = VNET_API_ERROR_UNSPECIFIED;
807 rv = VNET_API_ERROR_UNIMPLEMENTED;
810 REPLY_MACRO (VL_API_IKEV2_INITIATE_REKEY_CHILD_SA_REPLY);
815 * Add vpe's API message handlers to the table.
816 * vlib has alread mapped shared memory and
817 * added the client registration handlers.
818 * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
820 #define vl_msg_name_crc_list
821 #include <vnet/vnet_all_api_h.h>
822 #undef vl_msg_name_crc_list
825 setup_message_id_table (api_main_t * am)
827 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
828 foreach_vl_msg_name_crc_ipsec;
832 static clib_error_t *
833 ipsec_api_hookup (vlib_main_t * vm)
835 api_main_t *am = &api_main;
838 vl_msg_api_set_handlers(VL_API_##N, #n, \
839 vl_api_##n##_t_handler, \
841 vl_api_##n##_t_endian, \
842 vl_api_##n##_t_print, \
843 sizeof(vl_api_##n##_t), 1);
848 * Set up the (msg_name, crc, message-id) table
850 setup_message_id_table (am);
855 VLIB_API_INIT_FUNCTION (ipsec_api_hookup);
858 * fd.io coding-style-patch-verification: ON
861 * eval: (c-set-style "gnu")