FD.io VPP  v17.04.2-2-ga8f93f8
Vector Packet Processing
ipsec_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * ipsec_api.c - ipsec api
4  *
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:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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  *------------------------------------------------------------------
18  */
19 
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
22 
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <vnet/ip/ip.h>
26 
27 #include <vnet/vnet_msg_enum.h>
28 
29 #if WITH_LIBSSL > 0
30 #include <vnet/ipsec/ipsec.h>
31 #include <vnet/ipsec/ikev2.h>
32 #endif /* IPSEC */
33 
34 #define vl_typedefs /* define message structures */
35 #include <vnet/vnet_all_api_h.h>
36 #undef vl_typedefs
37 
38 #define vl_endianfun /* define message structures */
39 #include <vnet/vnet_all_api_h.h>
40 #undef vl_endianfun
41 
42 /* instantiate all the print functions we know about */
43 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
44 #define vl_printfun
45 #include <vnet/vnet_all_api_h.h>
46 #undef vl_printfun
47 
49 
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_SPD_DUMP, ipsec_spd_dump) \
57 _(IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del) \
58 _(IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth) \
59 _(IKEV2_PROFILE_SET_ID, ikev2_profile_set_id) \
60 _(IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts) \
61 _(IKEV2_SET_LOCAL_KEY, ikev2_set_local_key) \
62 _(IKEV2_SET_RESPONDER, ikev2_set_responder) \
63 _(IKEV2_SET_IKE_TRANSFORMS, ikev2_set_ike_transforms) \
64 _(IKEV2_SET_ESP_TRANSFORMS, ikev2_set_esp_transforms) \
65 _(IKEV2_SET_SA_LIFETIME, ikev2_set_sa_lifetime) \
66 _(IKEV2_INITIATE_SA_INIT, ikev2_initiate_sa_init) \
67 _(IKEV2_INITIATE_DEL_IKE_SA, ikev2_initiate_del_ike_sa) \
68 _(IKEV2_INITIATE_DEL_CHILD_SA, ikev2_initiate_del_child_sa) \
69 _(IKEV2_INITIATE_REKEY_CHILD_SA, ikev2_initiate_rekey_child_sa)
70 
73 {
74 #if WITH_LIBSSL == 0
75  clib_warning ("unimplemented");
76 #else
77 
78  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
80  int rv;
81 
82  rv = ipsec_add_del_spd (vm, ntohl (mp->spd_id), mp->is_add);
83 
84  REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_REPLY);
85 #endif
86 }
87 
90 {
91  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
93  int rv;
94  u32 sw_if_index __attribute__ ((unused));
95  u32 spd_id __attribute__ ((unused));
96 
97  sw_if_index = ntohl (mp->sw_if_index);
98  spd_id = ntohl (mp->spd_id);
99 
101 
102 #if WITH_LIBSSL > 0
103  rv = ipsec_set_interface_spd (vm, sw_if_index, spd_id, mp->is_add);
104 #else
105  rv = VNET_API_ERROR_UNIMPLEMENTED;
106 #endif
107 
109 
110  REPLY_MACRO (VL_API_IPSEC_INTERFACE_ADD_DEL_SPD_REPLY);
111 }
112 
115 {
116  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
118  int rv;
119 
120 #if WITH_LIBSSL > 0
121  ipsec_policy_t p;
122 
123  memset (&p, 0, sizeof (p));
124 
125  p.id = ntohl (mp->spd_id);
126  p.priority = ntohl (mp->priority);
127  p.is_outbound = mp->is_outbound;
128  p.is_ipv6 = mp->is_ipv6;
129 
130  if (mp->is_ipv6 || mp->is_ip_any)
131  {
136  }
137  else
138  {
139  clib_memcpy (&p.raddr.start.ip4.data, mp->remote_address_start, 4);
140  clib_memcpy (&p.raddr.stop.ip4.data, mp->remote_address_stop, 4);
141  clib_memcpy (&p.laddr.start.ip4.data, mp->local_address_start, 4);
142  clib_memcpy (&p.laddr.stop.ip4.data, mp->local_address_stop, 4);
143  }
144  p.protocol = mp->protocol;
145  p.rport.start = ntohs (mp->remote_port_start);
146  p.rport.stop = ntohs (mp->remote_port_stop);
147  p.lport.start = ntohs (mp->local_port_start);
148  p.lport.stop = ntohs (mp->local_port_stop);
149  /* policy action resolve unsupported */
150  if (mp->policy == IPSEC_POLICY_ACTION_RESOLVE)
151  {
152  clib_warning ("unsupported action: 'resolve'");
153  rv = VNET_API_ERROR_UNIMPLEMENTED;
154  goto out;
155  }
156  p.policy = mp->policy;
157  p.sa_id = ntohl (mp->sa_id);
158 
159  rv = ipsec_add_del_policy (vm, &p, mp->is_add);
160  if (rv)
161  goto out;
162 
163  if (mp->is_ip_any)
164  {
165  p.is_ipv6 = 1;
166  rv = ipsec_add_del_policy (vm, &p, mp->is_add);
167  }
168 #else
169  rv = VNET_API_ERROR_UNIMPLEMENTED;
170  goto out;
171 #endif
172 
173 out:
174  REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_ENTRY_REPLY);
175 }
176 
179 {
180  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
182  int rv;
183 #if WITH_LIBSSL > 0
184  ipsec_main_t *im = &ipsec_main;
185  ipsec_sa_t sa;
186 
187  memset (&sa, 0, sizeof (sa));
188 
189  sa.id = ntohl (mp->sad_id);
190  sa.spi = ntohl (mp->spi);
191  /* security protocol AH unsupported */
192  if (mp->protocol == IPSEC_PROTOCOL_AH)
193  {
194  clib_warning ("unsupported security protocol 'AH'");
195  rv = VNET_API_ERROR_UNIMPLEMENTED;
196  goto out;
197  }
198  sa.protocol = mp->protocol;
199  /* check for unsupported crypto-alg */
200  if (mp->crypto_algorithm < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
202  {
203  clib_warning ("unsupported crypto-alg: '%U'", format_ipsec_crypto_alg,
204  mp->crypto_algorithm);
205  rv = VNET_API_ERROR_UNIMPLEMENTED;
206  goto out;
207  }
208  sa.crypto_alg = mp->crypto_algorithm;
210  clib_memcpy (&sa.crypto_key, mp->crypto_key, sizeof (sa.crypto_key));
211  /* check for unsupported integ-alg */
213  {
214  clib_warning ("unsupported integ-alg: '%U'", format_ipsec_integ_alg,
215  mp->integrity_algorithm);
216  rv = VNET_API_ERROR_UNIMPLEMENTED;
217  goto out;
218  }
219 
222  clib_memcpy (&sa.integ_key, mp->integrity_key, sizeof (sa.integ_key));
224  sa.is_tunnel = mp->is_tunnel;
225  sa.is_tunnel_ip6 = mp->is_tunnel_ipv6;
226  if (sa.is_tunnel_ip6)
227  {
230  }
231  else
232  {
233  clib_memcpy (&sa.tunnel_src_addr.ip4.data, mp->tunnel_src_address, 4);
234  clib_memcpy (&sa.tunnel_dst_addr.ip4.data, mp->tunnel_dst_address, 4);
235  }
236 
237  ASSERT (im->cb.check_support_cb);
238  clib_error_t *err = im->cb.check_support_cb (&sa);
239  if (err)
240  {
241  clib_warning ("%s", err->what);
242  rv = VNET_API_ERROR_UNIMPLEMENTED;
243  goto out;
244  }
245 
246  rv = ipsec_add_del_sa (vm, &sa, mp->is_add);
247 #else
248  rv = VNET_API_ERROR_UNIMPLEMENTED;
249  goto out;
250 #endif
251 
252 out:
253  REPLY_MACRO (VL_API_IPSEC_SAD_ADD_DEL_ENTRY_REPLY);
254 }
255 
256 static void
258  u32 context)
259 {
261 
262  mp = vl_msg_api_alloc (sizeof (*mp));
263  memset (mp, 0, sizeof (*mp));
264  mp->_vl_msg_id = ntohs (VL_API_IPSEC_SPD_DETAILS);
265  mp->context = context;
266 
267  mp->spd_id = htonl (p->id);
268  mp->priority = htonl (p->priority);
269  mp->is_outbound = p->is_outbound;
270  mp->is_ipv6 = p->is_ipv6;
271  if (p->is_ipv6)
272  {
273  memcpy (mp->local_start_addr, &p->laddr.start.ip6, 16);
274  memcpy (mp->local_stop_addr, &p->laddr.stop.ip6, 16);
275  memcpy (mp->remote_start_addr, &p->raddr.start.ip6, 16);
276  memcpy (mp->remote_stop_addr, &p->raddr.stop.ip6, 16);
277  }
278  else
279  {
280  memcpy (mp->local_start_addr, &p->laddr.start.ip4, 4);
281  memcpy (mp->local_stop_addr, &p->laddr.stop.ip4, 4);
282  memcpy (mp->remote_start_addr, &p->raddr.start.ip4, 4);
283  memcpy (mp->remote_stop_addr, &p->raddr.stop.ip4, 4);
284  }
285  mp->local_start_port = htons (p->lport.start);
286  mp->local_stop_port = htons (p->lport.stop);
287  mp->remote_start_port = htons (p->rport.start);
288  mp->remote_stop_port = htons (p->rport.stop);
289  mp->protocol = p->protocol;
290  mp->policy = p->policy;
291  mp->sa_id = htonl (p->sa_id);
292  mp->bytes = clib_host_to_net_u64 (p->counter.bytes);
293  mp->packets = clib_host_to_net_u64 (p->counter.packets);
294 
295  vl_msg_api_send_shmem (q, (u8 *) & mp);
296 }
297 
298 static void
300 {
302  ipsec_main_t *im = &ipsec_main;
303  ipsec_policy_t *policy;
304  ipsec_spd_t *spd;
305  uword *p;
306  u32 spd_index;
307 #if WITH_LIBSSL > 0
309  if (q == 0)
310  return;
311 
312  p = hash_get (im->spd_index_by_spd_id, ntohl (mp->spd_id));
313  if (!p)
314  return;
315 
316  spd_index = p[0];
317  spd = pool_elt_at_index (im->spds, spd_index);
318 
319  /* *INDENT-OFF* */
320  pool_foreach (policy, spd->policies,
321  ({
322  if (mp->sa_id == ~(0) || ntohl (mp->sa_id) == policy->sa_id)
323  send_ipsec_spd_details (policy, q,
324  mp->context);}
325  ));
326  /* *INDENT-ON* */
327 #else
328  clib_warning ("unimplemented");
329 #endif
330 }
331 
332 static void
334 {
335  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
337  int rv;
338 #if WITH_LIBSSL > 0
339  ipsec_sa_t sa;
340  sa.id = ntohl (mp->sa_id);
342  clib_memcpy (&sa.crypto_key, mp->crypto_key, sizeof (sa.crypto_key));
344  clib_memcpy (&sa.integ_key, mp->integrity_key, sizeof (sa.integ_key));
345 
346  rv = ipsec_set_sa_key (vm, &sa);
347 #else
348  rv = VNET_API_ERROR_UNIMPLEMENTED;
349 #endif
350 
351  REPLY_MACRO (VL_API_IPSEC_SA_SET_KEY_REPLY);
352 }
353 
354 static void
356 {
358  int rv = 0;
359 
360 #if WITH_LIBSSL > 0
362  clib_error_t *error;
363  u8 *tmp = format (0, "%s", mp->name);
364  error = ikev2_add_del_profile (vm, tmp, mp->is_add);
365  vec_free (tmp);
366  if (error)
367  rv = VNET_API_ERROR_UNSPECIFIED;
368 #else
369  rv = VNET_API_ERROR_UNIMPLEMENTED;
370 #endif
371 
372  REPLY_MACRO (VL_API_IKEV2_PROFILE_ADD_DEL_REPLY);
373 }
374 
375 static void
378 {
380  int rv = 0;
381 
382 #if WITH_LIBSSL > 0
384  clib_error_t *error;
385  u8 *tmp = format (0, "%s", mp->name);
386  u8 *data = vec_new (u8, mp->data_len);
387  clib_memcpy (data, mp->data, mp->data_len);
388  error = ikev2_set_profile_auth (vm, tmp, mp->auth_method, data, mp->is_hex);
389  vec_free (tmp);
390  vec_free (data);
391  if (error)
392  rv = VNET_API_ERROR_UNSPECIFIED;
393 #else
394  rv = VNET_API_ERROR_UNIMPLEMENTED;
395 #endif
396 
397  REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_AUTH_REPLY);
398 }
399 
400 static void
402 {
404  int rv = 0;
405 
406 #if WITH_LIBSSL > 0
408  clib_error_t *error;
409  u8 *tmp = format (0, "%s", mp->name);
410  u8 *data = vec_new (u8, mp->data_len);
411  clib_memcpy (data, mp->data, mp->data_len);
412  error = ikev2_set_profile_id (vm, tmp, mp->id_type, data, mp->is_local);
413  vec_free (tmp);
414  vec_free (data);
415  if (error)
416  rv = VNET_API_ERROR_UNSPECIFIED;
417 #else
418  rv = VNET_API_ERROR_UNIMPLEMENTED;
419 #endif
420 
421  REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_ID_REPLY);
422 }
423 
424 static void
426 {
428  int rv = 0;
429 
430 #if WITH_LIBSSL > 0
432  clib_error_t *error;
433  u8 *tmp = format (0, "%s", mp->name);
434  error = ikev2_set_profile_ts (vm, tmp, mp->proto, mp->start_port,
435  mp->end_port, (ip4_address_t) mp->start_addr,
436  (ip4_address_t) mp->end_addr, mp->is_local);
437  vec_free (tmp);
438  if (error)
439  rv = VNET_API_ERROR_UNSPECIFIED;
440 #else
441  rv = VNET_API_ERROR_UNIMPLEMENTED;
442 #endif
443 
444  REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_TS_REPLY);
445 }
446 
447 static void
449 {
451  int rv = 0;
452 
453 #if WITH_LIBSSL > 0
455  clib_error_t *error;
456 
457  error = ikev2_set_local_key (vm, mp->key_file);
458  if (error)
459  rv = VNET_API_ERROR_UNSPECIFIED;
460 #else
461  rv = VNET_API_ERROR_UNIMPLEMENTED;
462 #endif
463 
464  REPLY_MACRO (VL_API_IKEV2_SET_LOCAL_KEY_REPLY);
465 }
466 
467 static void
469 {
471  int rv = 0;
472 
473 #if WITH_LIBSSL > 0
475  clib_error_t *error;
476 
477  u8 *tmp = format (0, "%s", mp->name);
478  ip4_address_t ip4;
479  clib_memcpy (&ip4, mp->address, sizeof (ip4));
480 
481  error = ikev2_set_profile_responder (vm, tmp, mp->sw_if_index, ip4);
482  vec_free (tmp);
483  if (error)
484  rv = VNET_API_ERROR_UNSPECIFIED;
485 #else
486  rv = VNET_API_ERROR_UNIMPLEMENTED;
487 #endif
488 
489  REPLY_MACRO (VL_API_IKEV2_SET_RESPONDER_REPLY);
490 }
491 
492 static void
494  mp)
495 {
497  int rv = 0;
498 
499 #if WITH_LIBSSL > 0
501  clib_error_t *error;
502 
503  u8 *tmp = format (0, "%s", mp->name);
504 
505  error =
507  mp->dh_group, mp->crypto_key_size);
508  vec_free (tmp);
509  if (error)
510  rv = VNET_API_ERROR_UNSPECIFIED;
511 #else
512  rv = VNET_API_ERROR_UNIMPLEMENTED;
513 #endif
514 
515  REPLY_MACRO (VL_API_IKEV2_SET_IKE_TRANSFORMS_REPLY);
516 }
517 
518 static void
520  mp)
521 {
523  int rv = 0;
524 
525 #if WITH_LIBSSL > 0
527  clib_error_t *error;
528 
529  u8 *tmp = format (0, "%s", mp->name);
530 
531  error =
533  mp->dh_group, mp->crypto_key_size);
534  vec_free (tmp);
535  if (error)
536  rv = VNET_API_ERROR_UNSPECIFIED;
537 #else
538  rv = VNET_API_ERROR_UNIMPLEMENTED;
539 #endif
540 
541  REPLY_MACRO (VL_API_IKEV2_SET_ESP_TRANSFORMS_REPLY);
542 }
543 
544 static void
546 {
548  int rv = 0;
549 
550 #if WITH_LIBSSL > 0
552  clib_error_t *error;
553 
554  u8 *tmp = format (0, "%s", mp->name);
555 
556  error =
558  mp->handover, mp->lifetime_maxdata);
559  vec_free (tmp);
560  if (error)
561  rv = VNET_API_ERROR_UNSPECIFIED;
562 #else
563  rv = VNET_API_ERROR_UNIMPLEMENTED;
564 #endif
565 
566  REPLY_MACRO (VL_API_IKEV2_SET_SA_LIFETIME_REPLY);
567 }
568 
569 static void
571 {
573  int rv = 0;
574 
575 #if WITH_LIBSSL > 0
577  clib_error_t *error;
578 
579  u8 *tmp = format (0, "%s", mp->name);
580 
581  error = ikev2_initiate_sa_init (vm, tmp);
582  vec_free (tmp);
583  if (error)
584  rv = VNET_API_ERROR_UNSPECIFIED;
585 #else
586  rv = VNET_API_ERROR_UNIMPLEMENTED;
587 #endif
588 
589  REPLY_MACRO (VL_API_IKEV2_INITIATE_SA_INIT_REPLY);
590 }
591 
592 static void
594  * mp)
595 {
597  int rv = 0;
598 
599 #if WITH_LIBSSL > 0
601  clib_error_t *error;
602 
603  error = ikev2_initiate_delete_ike_sa (vm, mp->ispi);
604  if (error)
605  rv = VNET_API_ERROR_UNSPECIFIED;
606 #else
607  rv = VNET_API_ERROR_UNIMPLEMENTED;
608 #endif
609 
610  REPLY_MACRO (VL_API_IKEV2_INITIATE_DEL_IKE_SA_REPLY);
611 }
612 
613 static void
616 {
618  int rv = 0;
619 
620 #if WITH_LIBSSL > 0
622  clib_error_t *error;
623 
624  error = ikev2_initiate_delete_child_sa (vm, mp->ispi);
625  if (error)
626  rv = VNET_API_ERROR_UNSPECIFIED;
627 #else
628  rv = VNET_API_ERROR_UNIMPLEMENTED;
629 #endif
630 
631  REPLY_MACRO (VL_API_IKEV2_INITIATE_DEL_CHILD_SA_REPLY);
632 }
633 
634 static void
637 {
639  int rv = 0;
640 
641 #if WITH_LIBSSL > 0
643  clib_error_t *error;
644 
645  error = ikev2_initiate_rekey_child_sa (vm, mp->ispi);
646  if (error)
647  rv = VNET_API_ERROR_UNSPECIFIED;
648 #else
649  rv = VNET_API_ERROR_UNIMPLEMENTED;
650 #endif
651 
652  REPLY_MACRO (VL_API_IKEV2_INITIATE_REKEY_CHILD_SA_REPLY);
653 }
654 
655 /*
656  * ipsec_api_hookup
657  * Add vpe's API message handlers to the table.
658  * vlib has alread mapped shared memory and
659  * added the client registration handlers.
660  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
661  */
662 #define vl_msg_name_crc_list
663 #include <vnet/vnet_all_api_h.h>
664 #undef vl_msg_name_crc_list
665 
666 static void
668 {
669 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
670  foreach_vl_msg_name_crc_ipsec;
671 #undef _
672 }
673 
674 static clib_error_t *
676 {
677  api_main_t *am = &api_main;
678 
679 #define _(N,n) \
680  vl_msg_api_set_handlers(VL_API_##N, #n, \
681  vl_api_##n##_t_handler, \
682  vl_noop_handler, \
683  vl_api_##n##_t_endian, \
684  vl_api_##n##_t_print, \
685  sizeof(vl_api_##n##_t), 1);
687 #undef _
688 
689  /*
690  * Set up the (msg_name, crc, message-id) table
691  */
693 
694  return 0;
695 }
696 
698 
699 /*
700  * fd.io coding-style-patch-verification: ON
701  *
702  * Local Variables:
703  * eval: (c-set-style "gnu")
704  * End:
705  */
ip46_address_t stop
Definition: ipsec.h:137
Reply for IPsec: Add/delete Security Association Database entry.
Definition: ipsec.api:203
static void vl_api_ikev2_profile_set_auth_t_handler(vl_api_ikev2_profile_set_auth_t *mp)
Definition: ipsec_api.c:377
static void vl_api_ipsec_sa_set_key_t_handler(vl_api_ipsec_sa_set_key_t *mp)
Definition: ipsec_api.c:333
static void vl_api_ikev2_set_local_key_t_handler(vl_api_ikev2_set_local_key_t *mp)
Definition: ipsec_api.c:448
ipsec_spd_t * spds
Definition: ipsec.h:246
u8 crypto_algorithm
Definition: ipsec.api:182
u8 use_extended_sequence_number
Definition: ipsec.api:190
u32 sa_id
Definition: ipsec.api:125
u8 integrity_key_length
Definition: ipsec.api:187
clib_error_t * ikev2_set_profile_responder(vlib_main_t *vm, u8 *name, u32 sw_if_index, ip4_address_t ip4)
Definition: ikev2.c:2787
Reply for IKEv2: Set IKEv2 IKE transforms.
Definition: ipsec.api:453
u16 stop
Definition: ipsec.h:142
int ipsec_add_del_policy(vlib_main_t *vm, ipsec_policy_t *policy, int is_add)
Definition: ipsec.c:152
ip46_address_t tunnel_src_addr
Definition: ipsec.h:119
IKEv2: Set Child SA lifetime, limited by time and/or data.
Definition: ipsec.api:503
u32 id
Definition: ipsec.h:102
Reply for IKEv2: Set IKEv2 profile traffic selector parameters.
Definition: ipsec.api:367
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
clib_error_t * ikev2_add_del_profile(vlib_main_t *vm, u8 *name, int is_add)
Definition: ikev2.c:2646
static void vl_api_ikev2_initiate_rekey_child_sa_t_handler(vl_api_ikev2_initiate_rekey_child_sa_t *mp)
Definition: ipsec_api.c:636
Reply for IKEv2: Set IKEv2 profile authentication method.
Definition: ipsec.api:299
u8 tunnel_dst_address[16]
Definition: ipsec.api:195
IKEv2: Add/delete profile.
Definition: ipsec.api:254
u16 local_port_start
Definition: ipsec.api:120
VLIB_API_INIT_FUNCTION(ipsec_api_hookup)
i32 priority
Definition: ipsec.h:186
IPsec: Update Security Association keys.
Definition: ipsec.api:222
int ipsec_set_interface_spd(vlib_main_t *vm, u32 sw_if_index, u32 spd_id, int is_add)
Definition: ipsec.c:39
clib_error_t * ikev2_initiate_delete_ike_sa(vlib_main_t *vm, u64 ispi)
Definition: ikev2.c:3101
u8 is_add
Definition: ipsec.api:102
Reply for IKEv2: Set IKEv2 ESP transforms.
Definition: ipsec.api:486
Reply for IPsec: Add/delete Security Policy Database entry.
Definition: ipsec.api:133
ipsec_integ_alg_t integ_alg
Definition: ipsec.h:110
IPsec: Add/delete Security Policy Database entry.
Definition: ipsec.api:98
Reply for IKEv2: Initiate the delete Child SA exchange.
Definition: ipsec.api:594
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
static void setup_message_id_table(api_main_t *am)
Definition: ipsec_api.c:667
u8 is_tunnel
Definition: ipsec.h:117
static void vl_api_ipsec_spd_add_del_entry_t_handler(vl_api_ipsec_spd_add_del_entry_t *mp)
Definition: ipsec_api.c:114
clib_error_t * ikev2_set_profile_sa_lifetime(vlib_main_t *vm, u8 *name, u64 lifetime, u32 jitter, u32 handover, u64 maxdata)
Definition: ikev2.c:2858
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
u8 policy
Definition: ipsec.api:124
u16 remote_port_stop
Definition: ipsec.api:119
u8 crypto_key[128]
Definition: ipsec.api:184
#define foreach_vpe_api_msg
Definition: ipsec_api.c:50
u8 crypto_key[128]
Definition: ipsec.h:108
int ipsec_add_del_spd(vlib_main_t *vm, u32 spd_id, int is_add)
Definition: ipsec.c:86
u8 * what
Definition: error.h:78
u8 protocol
Definition: ipsec.api:116
u32 spi
Definition: ipsec.h:103
port_range_t lport
Definition: ipsec.h:194
static void vl_api_ipsec_interface_add_del_spd_t_handler(vl_api_ipsec_interface_add_del_spd_t *mp)
Definition: ipsec_api.c:89
api_main_t api_main
Definition: api_shared.c:35
IKEv2: Set IKEv2 IKE transforms in SA_INIT proposal (RFC 7296)
Definition: ipsec.api:437
u32 spd_id
Definition: ipsec.api:104
u8 local_address_start[16]
Definition: ipsec.api:113
u8 integ_key[128]
Definition: ipsec.h:112
u8 is_tunnel
Definition: ipsec.api:192
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:376
u8 crypto_key_length
Definition: ipsec.api:183
u32 sad_id
Definition: ipsec.api:176
clib_error_t * ikev2_initiate_sa_init(vlib_main_t *vm, u8 *name)
Definition: ikev2.c:2881
Reply for IPsec: Update Security Association keys.
Definition: ipsec.api:241
ipsec_main_t ipsec_main
Definition: ipsec.h:282
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:310
clib_error_t * ikev2_set_profile_auth(vlib_main_t *vm, u8 *name, u8 auth_method, u8 *auth_data, u8 data_hex_format)
Definition: ikev2.c:2677
Reply for IKEv2: Set IKEv2 responder interface and IP address.
Definition: ipsec.api:419
static void vl_api_ikev2_set_responder_t_handler(vl_api_ikev2_set_responder_t *mp)
Definition: ipsec_api.c:468
u8 use_esn
Definition: ipsec.h:114
Reply for IKEv2: Initiate the delete IKE SA exchange.
Definition: ipsec.api:569
static void vl_api_ipsec_spd_dump_t_handler(vl_api_ipsec_spd_dump_t *mp)
Definition: ipsec_api.c:299
u16 start
Definition: ipsec.h:142
static void vl_api_ikev2_profile_set_ts_t_handler(vl_api_ikev2_profile_set_ts_t *mp)
Definition: ipsec_api.c:425
ipsec_main_callbacks_t cb
Definition: ipsec.h:279
IKEv2: Initiate the delete Child SA exchange.
Definition: ipsec.api:582
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, ikev2_transform_dh_type_t dh_type, u32 crypto_key_size)
Definition: ikev2.c:2833
IKEv2: Set IKEv2 profile local/remote identification.
Definition: ipsec.api:315
IKEv2: Set IKEv2 profile traffic selector parameters.
Definition: ipsec.api:349
static void vl_api_ikev2_initiate_del_child_sa_t_handler(vl_api_ikev2_initiate_del_child_sa_t *mp)
Definition: ipsec_api.c:615
u8 * format_ipsec_crypto_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:58
ipsec_policy_t * policies
Definition: ipsec.h:210
i32 priority
Definition: ipsec.api:105
static void vl_api_ipsec_spd_add_del_t_handler(vl_api_ipsec_spd_add_del_t *mp)
Definition: ipsec_api.c:72
u8 local_address_stop[16]
Definition: ipsec.api:114
#define hash_get(h, key)
Definition: hash.h:248
clib_error_t * ikev2_set_profile_id(vlib_main_t *vm, u8 *name, u8 id_type, u8 *data, int is_local)
Definition: ikev2.c:2709
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:397
counter_t packets
packet counter
Definition: counter.h:141
Reply for IKEv2: Initiate the rekey Child SA exchange.
Definition: ipsec.api:619
u8 is_tunnel_ip6
Definition: ipsec.h:118
IKEv2: Initiate the rekey Child SA exchange.
Definition: ipsec.api:607
clib_error_t *(* check_support_cb)(ipsec_sa_t *sa)
Definition: ipsec.h:240
IPsec: Add/delete Security Policy Database.
Definition: ipsec.api:23
clib_error_t * ikev2_initiate_delete_child_sa(vlib_main_t *vm, u32 ispi)
Definition: ikev2.c:3061
Reply for IKEv2: Initiate the SA_INIT exchange.
Definition: ipsec.api:544
static void vl_api_ikev2_initiate_sa_init_t_handler(vl_api_ikev2_initiate_sa_init_t *mp)
Definition: ipsec_api.c:570
#define REPLY_MACRO(t)
static void vl_api_ikev2_set_sa_lifetime_t_handler(vl_api_ikev2_set_sa_lifetime_t *mp)
Definition: ipsec_api.c:545
ip46_address_range_t laddr
Definition: ipsec.h:191
u8 is_add
Definition: ipsec.api:174
u16 local_port_stop
Definition: ipsec.api:121
static void vl_api_ikev2_set_ike_transforms_t_handler(vl_api_ikev2_set_ike_transforms_t *mp)
Definition: ipsec_api.c:493
uword * spd_index_by_spd_id
Definition: ipsec.h:265
clib_error_t * ikev2_set_local_key(vlib_main_t *vm, u8 *file)
Definition: ikev2.c:2634
clib_error_t * ikev2_set_profile_ts(vlib_main_t *vm, u8 *name, u8 protocol_id, u16 start_port, u16 end_port, ip4_address_t start_addr, ip4_address_t end_addr, int is_local)
Definition: ikev2.c:2748
ip46_address_t tunnel_dst_addr
Definition: ipsec.h:120
Reply for IPsec: Add/delete Security Policy Database entry.
Definition: ipsec.api:36
#define BAD_SW_IF_INDEX_LABEL
IPsec: Add/delete SPD from interface.
Definition: ipsec.api:52
clib_error_t * ikev2_initiate_rekey_child_sa(vlib_main_t *vm, u32 ispi)
Definition: ikev2.c:3211
void * vl_msg_api_alloc(int nbytes)
u16 remote_port_start
Definition: ipsec.api:118
static void vl_api_ikev2_set_esp_transforms_t_handler(vl_api_ikev2_set_esp_transforms_t *mp)
Definition: ipsec_api.c:519
vlib_main_t * vm
Definition: buffer.c:276
u8 remote_address_stop[16]
Definition: ipsec.api:112
int ipsec_add_del_sa(vlib_main_t *vm, ipsec_sa_t *new_sa, int is_add)
Definition: ipsec.c:411
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:340
IPsec: Add/delete Security Association Database entry.
Definition: ipsec.api:170
ip46_address_t start
Definition: ipsec.h:137
#define clib_warning(format, args...)
Definition: error.h:59
#define clib_memcpy(a, b, c)
Definition: string.h:69
u8 remote_address_start[16]
Definition: ipsec.api:111
int ipsec_set_sa_key(vlib_main_t *vm, ipsec_sa_t *sa_update)
Definition: ipsec.c:455
u8 tunnel_src_address[16]
Definition: ipsec.api:194
IKEv2: Initiate the SA_INIT exchange.
Definition: ipsec.api:532
static void vl_api_ipsec_sad_add_del_entry_t_handler(vl_api_ipsec_sad_add_del_entry_t *mp)
Definition: ipsec_api.c:178
port_range_t rport
Definition: ipsec.h:195
ip46_address_range_t raddr
Definition: ipsec.h:192
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
IKEv2: Set IKEv2 responder interface and IP address.
Definition: ipsec.api:405
u32 spi
Definition: ipsec.api:178
IKEv2: Initiate the delete IKE SA exchange.
Definition: ipsec.api:557
Reply for IPsec: Add/delete SPD from interface.
Definition: ipsec.api:67
IKEv2: Set IKEv2 profile authentication method.
Definition: ipsec.api:283
u8 integ_key_len
Definition: ipsec.h:111
Dump ipsec policy database data.
Definition: ipsec.api:631
ipsec_protocol_t protocol
Definition: ipsec.h:104
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
u64 uword
Definition: types.h:112
IPsec policy database response.
Definition: ipsec.api:659
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:90
u8 crypto_key_len
Definition: ipsec.h:107
counter_t bytes
byte counter
Definition: counter.h:142
static void vl_api_ikev2_profile_set_id_t_handler(vl_api_ikev2_profile_set_id_t *mp)
Definition: ipsec_api.c:401
Reply for IKEv2: Set Child SA lifetime.
Definition: ipsec.api:519
IKEv2: Set IKEv2 local RSA private key.
Definition: ipsec.api:379
unsigned char u8
Definition: types.h:56
static void send_ipsec_spd_details(ipsec_policy_t *p, unix_shared_memory_queue_t *q, u32 context)
Definition: ipsec_api.c:257
vlib_counter_t counter
Definition: ipsec.h:203
u8 is_outbound
Definition: ipsec.h:187
u8 integrity_algorithm
Definition: ipsec.api:186
u8 integrity_key[128]
Definition: ipsec.api:188
u8 is_tunnel_ipv6
Definition: ipsec.api:193
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)
Definition: ikev2.c:2808
IKEv2: Set IKEv2 ESP transforms in SA_INIT proposal (RFC 7296)
Definition: ipsec.api:470
static void vl_api_ikev2_profile_add_del_t_handler(vl_api_ikev2_profile_add_del_t *mp)
Definition: ipsec_api.c:355
ipsec_crypto_alg_t crypto_alg
Definition: ipsec.h:106
static void vl_api_ikev2_initiate_del_ike_sa_t_handler(vl_api_ikev2_initiate_del_ike_sa_t *mp)
Definition: ipsec_api.c:593
static clib_error_t * ipsec_api_hookup(vlib_main_t *vm)
Definition: ipsec_api.c:675
u8 is_outbound
Definition: ipsec.api:106
u8 is_ipv6
Definition: ipsec.api:109
Reply for IKEv2: Add/delete profile.
Definition: ipsec.api:267
#define VALIDATE_SW_IF_INDEX(mp)
u8 protocol
Definition: ipsec.api:180
struct _unix_shared_memory_queue unix_shared_memory_queue_t
u8 is_ip_any
Definition: ipsec.api:110