Implemented IKEv2 initiator features:
[vpp.git] / src / vnet / ipsec / ipsec.api
1 /*
2  * Copyright (c) 2015-2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 /** \brief IPsec: Add/delete Security Policy Database
17     @param client_index - opaque cookie to identify the sender
18     @param context - sender context, to match reply w/ request
19     @param is_add - add SPD if non-zero, else delete
20     @param spd_id - SPD instance id (control plane allocated)
21 */
22
23 define ipsec_spd_add_del
24 {
25   u32 client_index;
26   u32 context;
27   u8 is_add;
28   u32 spd_id;
29 };
30
31 /** \brief Reply for IPsec: Add/delete Security Policy Database entry
32     @param context - returned sender context, to match reply w/ request
33     @param retval - return code
34 */
35
36 define ipsec_spd_add_del_reply
37 {
38   u32 context;
39   i32 retval;
40 };
41
42 /** \brief IPsec: Add/delete SPD from interface
43
44     @param client_index - opaque cookie to identify the sender
45     @param context - sender context, to match reply w/ request
46     @param is_add - add security mode if non-zero, else delete
47     @param sw_if_index - index of the interface
48     @param spd_id - SPD instance id to use for lookups
49 */
50
51
52 define ipsec_interface_add_del_spd
53 {
54   u32 client_index;
55   u32 context;
56
57   u8 is_add;
58   u32 sw_if_index;
59   u32 spd_id;
60 };
61
62 /** \brief Reply for IPsec: Add/delete SPD from interface
63     @param context - returned sender context, to match reply w/ request
64     @param retval - return code
65 */
66
67 define ipsec_interface_add_del_spd_reply
68 {
69   u32 context;
70   i32 retval;
71 };
72
73 /** \brief IPsec: Add/delete Security Policy Database entry
74
75     See RFC 4301, 4.4.1.1 on how to match packet to selectors
76
77     @param client_index - opaque cookie to identify the sender
78     @param context - sender context, to match reply w/ request
79     @param is_add - add SPD if non-zero, else delete
80     @param spd_id - SPD instance id (control plane allocated)
81     @param priority - priority of SPD entry (non-unique value).  Used to order SPD matching - higher priorities match before lower
82     @param is_outbound - entry applies to outbound traffic if non-zero, otherwise applies to inbound traffic
83     @param is_ipv6 - remote/local address are IPv6 if non-zero, else IPv4
84     @param remote_address_start - start of remote address range to match
85     @param remote_address_stop - end of remote address range to match
86     @param local_address_start - start of local address range to match
87     @param local_address_stop - end of local address range to match
88     @param protocol - protocol type to match [0 means any]
89     @param remote_port_start - start of remote port range to match ...
90     @param remote_port_stop - end of remote port range to match [0 to 65535 means ANY, 65535 to 0 means OPAQUE]
91     @param local_port_start - start of local port range to match ...
92     @param local_port_stop - end of remote port range to match [0 to 65535 means ANY, 65535 to 0 means OPAQUE]
93     @param policy - 0 = bypass (no IPsec processing), 1 = discard (discard packet with ICMP processing), 2 = resolve (send request to control plane for SA resolving, and discard without ICMP processing), 3 = protect (apply IPsec policy using following parameters)
94     @param sa_id - SAD instance id (control plane allocated)
95
96 */
97
98 define ipsec_spd_add_del_entry
99 {
100   u32 client_index;
101   u32 context;
102   u8 is_add;
103
104   u32 spd_id;
105   i32 priority;
106   u8 is_outbound;
107
108   // Selector
109   u8 is_ipv6;
110   u8 is_ip_any;
111   u8 remote_address_start[16];
112   u8 remote_address_stop[16];
113   u8 local_address_start[16];
114   u8 local_address_stop[16];
115
116   u8 protocol;
117
118   u16 remote_port_start;
119   u16 remote_port_stop;
120   u16 local_port_start;
121   u16 local_port_stop;
122
123   // Policy
124   u8 policy;
125   u32 sa_id;
126 };
127
128 /** \brief Reply for IPsec: Add/delete Security Policy Database entry
129     @param context - returned sender context, to match reply w/ request
130     @param retval - return code
131 */
132
133 define ipsec_spd_add_del_entry_reply
134 {
135   u32 context;
136   i32 retval;
137 };
138
139 /** \brief IPsec: Add/delete Security Association Database entry
140     @param client_index - opaque cookie to identify the sender
141     @param context - sender context, to match reply w/ request
142     @param is_add - add SAD entry if non-zero, else delete
143
144     @param sad_id - sad id
145
146     @param spi - security parameter index
147
148     @param protocol - 0 = AH, 1 = ESP
149
150     @param crypto_algorithm - 0 = Null, 1 = AES-CBC-128, 2 = AES-CBC-192, 3 = AES-CBC-256, 4 = 3DES-CBC
151     @param crypto_key_length - length of crypto_key in bytes
152     @param crypto_key - crypto keying material
153
154     @param integrity_algorithm - 0 = None, 1 = MD5-96, 2 = SHA1-96, 3 = SHA-256, 4 = SHA-384, 5=SHA-512
155     @param integrity_key_length - length of integrity_key in bytes
156     @param integrity_key - integrity keying material
157
158     @param use_extended_sequence_number - use ESN when non-zero
159
160     @param is_tunnel - IPsec tunnel mode if non-zero, else transport mode
161     @param is_tunnel_ipv6 - IPsec tunnel mode is IPv6 if non-zero, else IPv4 tunnel only valid if is_tunnel is non-zero
162     @param tunnel_src_address - IPsec tunnel source address IPv6 if is_tunnel_ipv6 is non-zero, else IPv4. Only valid if is_tunnel is non-zero
163     @param tunnel_dst_address - IPsec tunnel destination address IPv6 if is_tunnel_ipv6 is non-zero, else IPv4. Only valid if is_tunnel is non-zero
164
165     To be added:
166      Anti-replay
167      IPsec tunnel address copy mode (to support GDOI)
168  */
169
170 define ipsec_sad_add_del_entry
171 {
172   u32 client_index;
173   u32 context;
174   u8 is_add;
175
176   u32 sad_id;
177
178   u32 spi;
179
180   u8 protocol;
181
182   u8 crypto_algorithm;
183   u8 crypto_key_length;
184   u8 crypto_key[128];
185
186   u8 integrity_algorithm;
187   u8 integrity_key_length;
188   u8 integrity_key[128];
189
190   u8 use_extended_sequence_number;
191
192   u8 is_tunnel;
193   u8 is_tunnel_ipv6;
194   u8 tunnel_src_address[16];
195   u8 tunnel_dst_address[16];
196 };
197
198 /** \brief Reply for IPsec: Add/delete Security Association Database entry
199     @param context - returned sender context, to match reply w/ request
200     @param retval - return code
201 */
202
203 define ipsec_sad_add_del_entry_reply
204 {
205   u32 context;
206   i32 retval;
207 };
208
209 /** \brief IPsec: Update Security Association keys
210     @param client_index - opaque cookie to identify the sender
211     @param context - sender context, to match reply w/ request
212
213     @param sa_id - sa id
214
215     @param crypto_key_length - length of crypto_key in bytes
216     @param crypto_key - crypto keying material
217
218     @param integrity_key_length - length of integrity_key in bytes
219     @param integrity_key - integrity keying material
220 */
221
222 define ipsec_sa_set_key
223 {
224   u32 client_index;
225   u32 context;
226
227   u32 sa_id;
228
229   u8 crypto_key_length;
230   u8 crypto_key[128];
231
232   u8 integrity_key_length;
233   u8 integrity_key[128];
234 };
235
236 /** \brief Reply for IPsec: Update Security Association keys
237     @param context - returned sender context, to match reply w/ request
238     @param retval - return code
239 */
240
241 define ipsec_sa_set_key_reply
242 {
243   u32 context;
244   i32 retval;
245 };
246
247 /** \brief IKEv2: Add/delete profile
248     @param client_index - opaque cookie to identify the sender
249     @param context - sender context, to match reply w/ request
250
251     @param name - IKEv2 profile name
252     @param is_add - Add IKEv2 profile if non-zero, else delete
253 */
254 define ikev2_profile_add_del
255 {
256   u32 client_index;
257   u32 context;
258
259   u8 name[64];
260   u8 is_add;
261 };
262
263 /** \brief Reply for IKEv2: Add/delete profile
264     @param context - returned sender context, to match reply w/ request
265     @param retval - return code
266 */
267 define ikev2_profile_add_del_reply
268 {
269   u32 context;
270   i32 retval;
271 };
272
273 /** \brief IKEv2: Set IKEv2 profile authentication method
274     @param client_index - opaque cookie to identify the sender
275     @param context - sender context, to match reply w/ request
276
277     @param name - IKEv2 profile name
278     @param auth_method - IKEv2 authentication method (shared-key-mic/rsa-sig)
279     @param is_hex - Authentication data in hex format if non-zero, else string
280     @param data_len - Authentication data length
281     @param data - Authentication data (for rsa-sig cert file path)
282 */
283 define ikev2_profile_set_auth
284 {
285   u32 client_index;
286   u32 context;
287
288   u8 name[64];
289   u8 auth_method;
290   u8 is_hex;
291   u32 data_len;
292   u8 data[0];
293 };
294
295 /** \brief Reply for IKEv2: Set IKEv2 profile authentication method
296     @param context - returned sender context, to match reply w/ request
297     @param retval - return code
298 */
299 define ikev2_profile_set_auth_reply
300 {
301   u32 context;
302   i32 retval;
303 };
304
305 /** \brief IKEv2: Set IKEv2 profile local/remote identification
306     @param client_index - opaque cookie to identify the sender
307     @param context - sender context, to match reply w/ request
308
309     @param name - IKEv2 profile name
310     @param is_local - Identification is local if non-zero, else remote
311     @param id_type - Identification type
312     @param data_len - Identification data length
313     @param data - Identification data
314 */
315 define ikev2_profile_set_id
316 {
317   u32 client_index;
318   u32 context;
319
320   u8 name[64];
321   u8 is_local;
322   u8 id_type;
323   u32 data_len;
324   u8 data[0];
325 };
326
327 /** \brief Reply for IKEv2:
328     @param context - returned sender context, to match reply w/ request
329     @param retval - return code
330 */
331 define ikev2_profile_set_id_reply
332 {
333   u32 context;
334   i32 retval;
335 };
336
337 /** \brief IKEv2: Set IKEv2 profile traffic selector parameters
338     @param client_index - opaque cookie to identify the sender
339     @param context - sender context, to match reply w/ request
340
341     @param name - IKEv2 profile name
342     @param is_local - Traffic selector is local if non-zero, else remote
343     @param proto - Traffic selector IP protocol (if zero not relevant)
344     @param start_port - The smallest port number allowed by traffic selector
345     @param end_port - The largest port number allowed by traffic selector
346     @param start_addr - The smallest address included in traffic selector
347     @param end_addr - The largest address included in traffic selector
348 */
349 define ikev2_profile_set_ts
350 {
351   u32 client_index;
352   u32 context;
353
354   u8 name[64];
355   u8 is_local;
356   u8 proto;
357   u16 start_port;
358   u16 end_port;
359   u32 start_addr;
360   u32 end_addr;
361 };
362
363 /** \brief Reply for IKEv2: Set IKEv2 profile traffic selector parameters
364     @param context - returned sender context, to match reply w/ request
365     @param retval - return code
366 */
367 define ikev2_profile_set_ts_reply
368 {
369   u32 context;
370   i32 retval;
371 };
372
373 /** \brief IKEv2: Set IKEv2 local RSA private key
374     @param client_index - opaque cookie to identify the sender
375     @param context - sender context, to match reply w/ request
376
377     @param key_file - Key file absolute path
378 */
379 define ikev2_set_local_key
380 {
381   u32 client_index;
382   u32 context;
383
384   u8 key_file[256];
385 };
386
387 /** \brief Reply for IKEv2: Set IKEv2 local key
388     @param context - returned sender context, to match reply w/ request
389     @param retval - return code
390 */
391 define ikev2_set_local_key_reply
392 {
393   u32 context;
394   i32 retval;
395 };
396
397 /** \brief IKEv2: Set IKEv2 responder interface and IP address
398     @param client_index - opaque cookie to identify the sender
399     @param context - sender context, to match reply w/ request
400
401     @param name - IKEv2 profile name
402     @param sw_if_index - interface index
403     @param address - interface address
404 */
405 define ikev2_set_responder
406 {
407   u32 client_index;
408   u32 context;
409
410   u8 name[64];
411   u32 sw_if_index;
412   u8 address[4];
413 };
414
415 /** \brief Reply for IKEv2: Set IKEv2 responder interface and IP address
416     @param context - returned sender context, to match reply w/ request
417     @param retval - return code
418 */
419 define ikev2_set_responder_reply
420 {
421   u32 context;
422   i32 retval;
423 };
424
425
426 /** \brief IKEv2: Set IKEv2 IKE transforms in SA_INIT proposal (RFC 7296)
427     @param client_index - opaque cookie to identify the sender
428     @param context - sender context, to match reply w/ request
429
430     @param name - IKEv2 profile name
431     @param crypto_alg - encryption algorithm
432     @param crypto_key_size - encryption key size
433     @param integ_alg - integrity algorithm
434     @param dh_group - Diffie-Hellman group
435     
436 */
437 define ikev2_set_ike_transforms
438 {
439   u32 client_index;
440   u32 context;
441
442   u8 name[64];
443   u32 crypto_alg;
444   u32 crypto_key_size;
445   u32 integ_alg;
446   u32 dh_group;
447 };
448
449 /** \brief Reply for IKEv2: Set IKEv2 IKE transforms
450     @param context - returned sender context, to match reply w/ request
451     @param retval - return code
452 */
453 define ikev2_set_ike_transforms_reply
454 {
455   u32 context;
456   i32 retval;
457 };
458
459 /** \brief IKEv2: Set IKEv2 ESP transforms in SA_INIT proposal (RFC 7296)
460     @param client_index - opaque cookie to identify the sender
461     @param context - sender context, to match reply w/ request
462
463     @param name - IKEv2 profile name
464     @param crypto_alg - encryption algorithm
465     @param crypto_key_size - encryption key size
466     @param integ_alg - integrity algorithm
467     @param dh_group - Diffie-Hellman group
468     
469 */
470 define ikev2_set_esp_transforms
471 {
472   u32 client_index;
473   u32 context;
474
475   u8 name[64];
476   u32 crypto_alg;
477   u32 crypto_key_size;
478   u32 integ_alg;
479   u32 dh_group;
480 };
481
482 /** \brief Reply for IKEv2: Set IKEv2 ESP transforms
483     @param context - returned sender context, to match reply w/ request
484     @param retval - return code
485 */
486 define ikev2_set_esp_transforms_reply
487 {
488   u32 context;
489   i32 retval;
490 };
491
492 /** \brief IKEv2: Set Child SA lifetime, limited by time and/or data
493     @param client_index - opaque cookie to identify the sender
494     @param context - sender context, to match reply w/ request
495
496     @param name - IKEv2 profile name
497     @param lifetime - SA maximum life time in seconds (0 to disable)
498     @param lifetime_jitter - Jitter added to prevent simultaneounus rekeying
499     @param handover - Hand over time
500     @param lifetime_maxdata - SA maximum life time in bytes (0 to disable)
501     
502 */
503 define ikev2_set_sa_lifetime
504 {
505   u32 client_index;
506   u32 context;
507
508   u8 name[64];
509   u64 lifetime;
510   u32 lifetime_jitter;
511   u32 handover;
512   u64 lifetime_maxdata;
513 };
514
515 /** \brief Reply for IKEv2: Set Child SA lifetime
516     @param context - returned sender context, to match reply w/ request
517     @param retval - return code
518 */
519 define ikev2_set_sa_lifetime_reply
520 {
521   u32 context;
522   i32 retval;
523 };
524
525 /** \brief IKEv2: Initiate the SA_INIT exchange
526     @param client_index - opaque cookie to identify the sender
527     @param context - sender context, to match reply w/ request
528
529     @param name - IKEv2 profile name
530     
531 */
532 define ikev2_initiate_sa_init
533 {
534   u32 client_index;
535   u32 context;
536
537   u8 name[64];
538 };
539
540 /** \brief Reply for IKEv2: Initiate the SA_INIT exchange
541     @param context - returned sender context, to match reply w/ request
542     @param retval - return code
543 */
544 define ikev2_initiate_sa_init_reply
545 {
546   u32 context;
547   i32 retval;
548 };
549
550 /** \brief IKEv2: Initiate the delete IKE SA exchange
551     @param client_index - opaque cookie to identify the sender
552     @param context - sender context, to match reply w/ request
553
554     @param ispi - IKE SA initiator SPI
555     
556 */
557 define ikev2_initiate_del_ike_sa
558 {
559   u32 client_index;
560   u32 context;
561
562   u64 ispi;
563 };
564
565 /** \brief Reply for IKEv2: Initiate the delete IKE SA exchange
566     @param context - returned sender context, to match reply w/ request
567     @param retval - return code
568 */
569 define ikev2_initiate_del_ike_sa_reply
570 {
571   u32 context;
572   i32 retval;
573 };
574
575 /** \brief IKEv2: Initiate the delete Child SA exchange
576     @param client_index - opaque cookie to identify the sender
577     @param context - sender context, to match reply w/ request
578
579     @param ispi - Child SA initiator SPI
580     
581 */
582 define ikev2_initiate_del_child_sa
583 {
584   u32 client_index;
585   u32 context;
586
587   u32 ispi;
588 };
589
590 /** \brief Reply for IKEv2: Initiate the delete Child SA exchange
591     @param context - returned sender context, to match reply w/ request
592     @param retval - return code
593 */
594 define ikev2_initiate_del_child_sa_reply
595 {
596   u32 context;
597   i32 retval;
598 };
599
600 /** \brief IKEv2: Initiate the rekey Child SA exchange
601     @param client_index - opaque cookie to identify the sender
602     @param context - sender context, to match reply w/ request
603
604     @param ispi - Child SA initiator SPI
605     
606 */
607 define ikev2_initiate_rekey_child_sa
608 {
609   u32 client_index;
610   u32 context;
611
612   u32 ispi;
613 };
614
615 /** \brief Reply for IKEv2: Initiate the rekey Child SA exchange
616     @param context - returned sender context, to match reply w/ request
617     @param retval - return code
618 */
619 define ikev2_initiate_rekey_child_sa_reply
620 {
621   u32 context;
622   i32 retval;
623 };
624
625 /** \brief Dump ipsec policy database data
626     @param client_index - opaque cookie to identify the sender
627     @param context - sender context, to match reply w/ request
628     @param spd_id - SPD instance id
629     @param sa_id - SA id, optional, set to ~0 to see all policies in SPD
630 */
631 define ipsec_spd_dump {
632     u32 client_index;
633     u32 context;
634     u32 spd_id;
635     u32 sa_id;
636 };
637
638 /** \brief IPsec policy database response
639     @param context - sender context which was passed in the request
640     @param spd_id - SPD instance id
641     @param priority - numeric value to control policy evaluation order
642     @param is_outbound - [1|0] to indicate if direction is [out|in]bound
643     @param is_ipv6 - [1|0] to indicate if address family is ipv[6|4]
644     @param local_start_addr - first address in local traffic selector range
645     @param local_stop_addr - last address in local traffic selector range
646     @param local_start_port - first port in local traffic selector range
647     @param local_stop_port - last port in local traffic selector range
648     @param remote_start_addr - first address in remote traffic selector range
649     @param remote_stop_addr - last address in remote traffic selector range
650     @param remote_start_port - first port in remote traffic selector range
651     @param remote_stop_port - last port in remote traffic selector range
652     @param protocol - traffic selector protocol
653     @param policy - policy action
654     @param sa_id - SA id
655     @param bytes - byte count of packets matching this policy
656     @param packets - count of packets matching this policy
657 */
658
659 define ipsec_spd_details {
660     u32 context;
661     u32 spd_id;
662     i32 priority;
663     u8 is_outbound;
664     u8 is_ipv6;
665     u8 local_start_addr[16];
666     u8 local_stop_addr[16];
667     u16 local_start_port;
668     u16 local_stop_port;
669     u8 remote_start_addr[16];
670     u8 remote_stop_addr[16];
671     u16 remote_start_port;
672     u16 remote_stop_port;
673     u8 protocol;
674     u8 policy;
675     u32 sa_id;
676     u64 bytes;
677     u64 packets;
678 };
679
680 /*
681  * Local Variables:
682  * eval: (c-set-style "gnu")
683  * End:
684  */
685