FD.io VPP  v21.01.1
Vector Packet Processing
ipsec.api
Go to the documentation of this file.
1 /* Hey Emacs use -*- mode: C -*- */
2 /*
3  * Copyright (c) 2015-2016 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 option version = "4.0.0";
18 
19 import "vnet/ipsec/ipsec_types.api";
20 import "vnet/interface_types.api";
21 import "vnet/ip/ip_types.api";
22 import "vnet/interface_types.api";
23 import "vnet/tunnel/tunnel_types.api";
24 
25 /** \brief IPsec: Add/delete Security Policy Database
26  @param client_index - opaque cookie to identify the sender
27  @param context - sender context, to match reply w/ request
28  @param is_add - add SPD if non-zero, else delete
29  @param spd_id - SPD instance id (control plane allocated)
30 */
31 
32 autoreply define ipsec_spd_add_del
33 {
36  bool is_add;
38 };
39 
40 /** \brief IPsec: Add/delete SPD from interface
41 
42  @param client_index - opaque cookie to identify the sender
43  @param context - sender context, to match reply w/ request
44  @param is_add - add security mode if non-zero, else delete
45  @param sw_if_index - index of the interface
46  @param spd_id - SPD instance id to use for lookups
47 */
48 
49 
50 autoreply define ipsec_interface_add_del_spd
51 {
54 
55  bool is_add;
56  vl_api_interface_index_t sw_if_index;
58 };
59 
60 
62 {
63  /* bypass - no IPsec processing */
65  /* discard - discard packet with ICMP processing */
67  /* resolve - send request to control plane for SA resolving */
69  /* protect - apply IPsec policy using following parameters */
71 };
72 
73 /** \brief IPsec: Security Policy Database entry
74 
75  See RFC 4301, 4.4.1.1 on how to match packet to selectors
76 
77  @param spd_id - SPD instance id (control plane allocated)
78  @param priority - priority of SPD entry (non-unique value). Used to order SPD matching - higher priorities match before lower
79  @param is_outbound - entry applies to outbound traffic if non-zero, otherwise applies to inbound traffic
80  @param remote_address_start - start of remote address range to match
81  @param remote_address_stop - end of remote address range to match
82  @param local_address_start - start of local address range to match
83  @param local_address_stop - end of local address range to match
84  @param protocol - protocol type to match [0 means any] otherwise IANA value
85  @param remote_port_start - start of remote port range to match ...
86  @param remote_port_stop - end of remote port range to match [0 to 65535 means ANY, 65535 to 0 means OPAQUE]
87  @param local_port_start - start of local port range to match ...
88  @param local_port_stop - end of remote port range to match [0 to 65535 means ANY, 65535 to 0 means OPAQUE]
89  @param policy - action to perform on match
90  @param sa_id - SAD instance id (control plane allocated)
91 */
92 typedef ipsec_spd_entry
93 {
94  u32 spd_id;
97 
99  vl_api_ipsec_spd_action_t policy;
100  /* Which protocol?? */
102 
103  // Selector
104  vl_api_address_t remote_address_start;
105  vl_api_address_t remote_address_stop;
106  vl_api_address_t local_address_start;
107  vl_api_address_t local_address_stop;
108 
113 };
114 
115 /** \brief IPsec: Add/delete Security Policy Database entry
116 
117  @param client_index - opaque cookie to identify the sender
118  @param context - sender context, to match reply w/ request
119  @param is_add - add SPD if non-zero, else delete
120  @param entry - Description of the entry to add/dell
121 */
122 define ipsec_spd_entry_add_del
123 {
126  bool is_add;
127  vl_api_ipsec_spd_entry_t entry;
128 };
129 
130 /** \brief IPsec: Reply Add/delete Security Policy Database entry
131 
132  @param context - sender context, to match reply w/ request
133  @param retval - success/fail rutrun code
134  @param stat_index - An index for the policy in the stats segment @ /net/ipec/policy
135 */
136 define ipsec_spd_entry_add_del_reply
137 {
141 };
142 
143 /** \brief Dump IPsec all SPD IDs
144  @param client_index - opaque cookie to identify the sender
145  @param context - sender context, to match reply w/ request
146 */
147 define ipsec_spds_dump {
150 };
151 
152 /** \brief Dump IPsec all SPD IDs response
153  @param client_index - opaque cookie to identify the sender
154  @param spd_id - SPD instance id (control plane allocated)
155  @param npolicies - number of policies in SPD
156 */
157 define ipsec_spds_details {
161 };
162 
163 /** \brief Dump ipsec policy database data
164  @param client_index - opaque cookie to identify the sender
165  @param context - sender context, to match reply w/ request
166  @param spd_id - SPD instance id
167  @param sa_id - SA id, optional, set to ~0 to see all policies in SPD
168 */
169 define ipsec_spd_dump {
174 };
175 
176 /** \brief IPsec policy database response
177  @param context - sender context which was passed in the request
178  €param entry - The SPD entry.
179  @param bytes - byte count of packets matching this policy
180  @param packets - count of packets matching this policy
181 */
182 define ipsec_spd_details {
184  vl_api_ipsec_spd_entry_t entry;
185 };
186 
187 /** \brief IPsec: Add/delete Security Association Database entry
188  @param client_index - opaque cookie to identify the sender
189  @param context - sender context, to match reply w/ request
190  @param entry - Entry to add or delete
191  */
192 define ipsec_sad_entry_add_del
193 {
196  bool is_add;
197  vl_api_ipsec_sad_entry_t entry;
198 };
199 define ipsec_sad_entry_add_del_v2
200 {
203  bool is_add;
204  vl_api_ipsec_sad_entry_v2_t entry;
205 };
206 define ipsec_sad_entry_add_del_reply
207 {
211 };
212 define ipsec_sad_entry_add_del_v2_reply
213 {
217 };
218 
219 /** \brief Add or Update Protection for a tunnel with IPSEC
220 
221  Tunnel protection directly associates an SA with all packets
222  ingress and egress on the tunnel. This could also be achieved by
223  assigning an SPD to the tunnel, but that would incur an unnessccary
224  SPD entry lookup.
225 
226  For tunnels the ESP acts on the post-encapsulated packet. So if this
227  packet:
228  +---------+------+
229  | Payload | O-IP |
230  +---------+------+
231  where O-IP is the overlay IP addrees that was routed into the tunnel,
232  the resulting encapsulated packet will be:
233  +---------+------+------+
234  | Payload | O-IP | T-IP |
235  +---------+------+------+
236  where T-IP is the tunnel's src.dst IP addresses.
237  If the SAs used for protection are in transport mode then the ESP is
238  inserted before T-IP, i.e.:
239  +---------+------+-----+------+
240  | Payload | O-IP | ESP | T-IP |
241  +---------+------+-----+------+
242  If the SAs used for protection are in tunnel mode then another
243  encapsulation occurs, i.e.:
244  +---------+------+------+-----+------+
245  | Payload | O-IP | T-IP | ESP | C-IP |
246  +---------+------+------+-----+------+
247  where C-IP are the crypto endpoint IP addresses defined as the tunnel
248  endpoints in the SA.
249  The mode for the inbound and outbound SA must be the same.
250 
251  @param client_index - opaque cookie to identify the sender
252  @param context - sender context, to match reply w/ request
253  @param sw_id_index - Tunnel interface to protect
254  @param nh - The peer/next-hop on the tunnel to which the traffic
255  should be protected. For a P2P interface set this to the
256  all 0s address.
257  @param sa_in - The ID [set] of inbound SAs
258  @param sa_out - The ID of outbound SA
259 */
260 typedef ipsec_tunnel_protect
261 {
262  vl_api_interface_index_t sw_if_index;
263  vl_api_address_t nh;
267 };
268 
269 autoreply define ipsec_tunnel_protect_update
270 {
273 
274  vl_api_ipsec_tunnel_protect_t tunnel;
275 };
276 
277 autoreply define ipsec_tunnel_protect_del
278 {
281 
282  vl_api_interface_index_t sw_if_index;
283  vl_api_address_t nh;
284 };
285 
286 /**
287  * @brief Dump all tunnel protections
288  */
289 define ipsec_tunnel_protect_dump
290 {
293  vl_api_interface_index_t sw_if_index;
294 };
295 
296 define ipsec_tunnel_protect_details
297 {
299  vl_api_ipsec_tunnel_protect_t tun;
300 };
301 
302 /** \brief IPsec: Get SPD interfaces
303  @param client_index - opaque cookie to identify the sender
304  @param context - sender context, to match reply w/ request
305  @param spd_index - SPD index
306  @param spd_index_valid - if 1 spd_index is used to filter
307  spd_index's, if 0 no filtering is done
308 */
309 define ipsec_spd_interface_dump {
314 };
315 
316 /** \brief IPsec: SPD interface response
317  @param context - sender context which was passed in the request
318  @param spd_index - SPD index
319  @param sw_if_index - index of the interface
320 */
321 define ipsec_spd_interface_details {
324  vl_api_interface_index_t sw_if_index;
325 };
326 
327 /** \brief Add or delete IPsec tunnel interface
328 
329  !!DEPRECATED!!
330  use the tunnel protect APIs instead
331 
332  @param client_index - opaque cookie to identify the sender
333  @param context - sender context, to match reply w/ request
334  @param is_add - add IPsec tunnel interface if nonzero, else delete
335  @param is_ip6 - tunnel v6 or v4
336  @param esn - enable extended sequence numbers if nonzero, else disable
337  @param anti_replay - enable anti replay check if nonzero, else disable
338  @param local_ip - local IP address
339  @param remote_ip - IP address of remote IPsec peer
340  @param local_spi - SPI of outbound IPsec SA
341  @param remote_spi - SPI of inbound IPsec SA
342  @param crypto_alg - encryption algorithm ID
343  @param local_crypto_key_len - length of local crypto key in bytes
344  @param local_crypto_key - crypto key for outbound IPsec SA
345  @param remote_crypto_key_len - length of remote crypto key in bytes
346  @param remote_crypto_key - crypto key for inbound IPsec SA
347  @param integ_alg - integrity algorithm ID
348  @param local_integ_key_len - length of local integrity key in bytes
349  @param local_integ_key - integrity key for outbound IPsec SA
350  @param remote_integ_key_len - length of remote integrity key in bytes
351  @param remote_integ_key - integrity key for inbound IPsec SA
352  @param renumber - intf display name uses a specified instance if != 0
353  @param show_instance - instance to display for intf if renumber is set
354  @param udp_encap - enable UDP encapsulation for NAT traversal
355  @param tx_table_id - the FIB id used after packet encap
356  @param salt - for use with counter mode ciphers
357 */
358 define ipsec_tunnel_if_add_del {
359  option deprecated;
362  bool is_add;
363  bool esn;
365  vl_api_address_t local_ip;
366  vl_api_address_t remote_ip;
371  u8 local_crypto_key[128];
373  u8 remote_crypto_key[128];
376  u8 local_integ_key[128];
378  u8 remote_integ_key[128];
379  bool renumber;
381  bool udp_encap;
384 };
385 
386 /** \brief Add/delete IPsec tunnel interface response
387  @param context - sender context, to match reply w/ request
388  @param retval - return status
389  @param sw_if_index - sw_if_index of new interface (for successful add)
390 */
391 define ipsec_tunnel_if_add_del_reply {
394  vl_api_interface_index_t sw_if_index;
395 };
396 
397 typedef ipsec_itf
398 {
399  u32 user_instance [default=0xffffffff];
400  vl_api_tunnel_mode_t mode;
401  vl_api_interface_index_t sw_if_index;
402 };
403 
404 /** \brief Create an IPSec interface
405  */
409  vl_api_ipsec_itf_t itf;
410 };
411 
412 /** \brief Add IPsec interface interface response
413  @param context - sender context, to match reply w/ request
414  @param retval - return status
415  @param sw_if_index - sw_if_index of new interface (for successful add)
416 */
417 define ipsec_itf_create_reply
418 {
421  vl_api_interface_index_t sw_if_index;
422 };
423 
424 autoreply define ipsec_itf_delete
425 {
428  vl_api_interface_index_t sw_if_index;
429 };
430 
431 define ipsec_itf_dump
432 {
435  vl_api_interface_index_t sw_if_index;
436 };
437 
438 define ipsec_itf_details
439 {
441  vl_api_ipsec_itf_t itf;
442 };
443 
444 /** \brief Dump IPsec security association
445  @param client_index - opaque cookie to identify the sender
446  @param context - sender context, to match reply w/ request
447  @param sa_id - optional ID of an SA to dump, if ~0 dump all SAs in SAD
448 */
449 define ipsec_sa_dump
450 {
454 };
455 define ipsec_sa_v2_dump
456 {
460 };
461 
462 /** \brief IPsec security association database response
463  @param context - sender context which was passed in the request
464  @param entry - The SA details
465  @param sw_if_index - sw_if_index of tunnel interface, policy-based SAs = ~0
466  @param salt - 4 byte salt
467  @param seq - current sequence number for outbound
468  @param seq_hi - high 32 bits of ESN for outbound
469  @param last_seq - highest sequence number received inbound
470  @param last_seq_hi - high 32 bits of highest ESN received inbound
471  @param replay_window - bit map of seq nums received relative to last_seq if using anti-replay
472  @param stat_index - index for the SA in the stats segment @ /net/ipsec/sa
473 */
474 define ipsec_sa_details {
476  vl_api_ipsec_sad_entry_t entry;
477 
478  vl_api_interface_index_t sw_if_index;
483 
485 };
486 define ipsec_sa_v2_details {
488  vl_api_ipsec_sad_entry_v2_t entry;
489 
490  vl_api_interface_index_t sw_if_index;
495 
497 };
498 
499 /** \brief Set new SA on IPsec interface
500 
501  !! DEPRECATED !!
502 
503  @param client_index - opaque cookie to identify the sender
504  @param context - sender context, to match reply w/ request
505  @param sw_if_index - index of tunnel interface
506  @param sa_id - ID of SA to use
507  @param is_outbound - 1 if outbound (local) SA, 0 if inbound (remote)
508 */
509 autoreply define ipsec_tunnel_if_set_sa {
510  option deprecated;
513  vl_api_interface_index_t sw_if_index;
516 };
517 
518 /** \brief Dump IPsec backends
519  @param client_index - opaque cookie to identify the sender
520  @param context - sender context, to match reply w/ request
521 */
522 define ipsec_backend_dump {
525 };
526 
527 /** \brief IPsec backend details
528  @param name - name of the backend
529  @param protocol - IPsec protocol (value from ipsec_protocol_t)
530  @param index - backend index
531  @param active - set to 1 if the backend is active, otherwise 0
532 */
533 define ipsec_backend_details {
535  string name[128];
536  vl_api_ipsec_proto_t protocol;
538  bool active;
539 };
540 
541 /** \brief Select IPsec backend
542  @param client_index - opaque cookie to identify the sender
543  @param context - sender context, to match reply w/ request
544  @param protocol - IPsec protocol (value from ipsec_protocol_t)
545  @param index - backend index
546 */
547 autoreply define ipsec_select_backend {
550  vl_api_ipsec_proto_t protocol;
552 };
553 
554 
555 /** \brief IPsec Set Async mode
556  @param client_index - opaque cookie to identify the sender
557  @param context - sender context, to match reply w/ request
558  @param async_enable - ipsec async mode on or off
559 */
560 autoreply define ipsec_set_async_mode {
564 };
565 
566 /*
567  * Local Variables:
568  * eval: (c-set-style "gnu")
569  * End:
570  */
bool is_add
Definition: ipsec.api:126
u8 n_sa_in
Definition: ipsec.api:265
unsigned long u64
Definition: types.h:89
vl_api_ipsec_itf_t itf
Definition: ipsec.api:441
u32 context
Definition: ipsec.api:208
vl_api_ipsec_proto_t protocol
Definition: ipsec.api:536
vl_api_address_t local_address_stop
Definition: ipsec.api:107
vl_api_interface_index_t sw_if_index
Definition: ipsec.api:513
vl_api_ipsec_sad_entry_v2_t entry
Definition: ipsec.api:204
u16 local_port_stop
Definition: ipsec.api:112
vl_api_address_t local_address_start
Definition: ipsec.api:106
u8 protocol
Definition: ipsec.api:101
vl_api_ipsec_itf_t itf
Definition: ipsec.api:409
vl_api_ipsec_spd_action_t policy
Definition: ipsec.api:99
vl_api_interface_index_t sw_if_index
Definition: ipsec.api:401
unsigned char u8
Definition: types.h:56
vl_api_interface_index_t sw_if_index
Definition: ipsec.api:293
vl_api_address_t remote_ip
Definition: ipsec.api:366
vl_api_interface_index_t sw_if_index
Definition: ipsec.api:282
typedef ipsec_tunnel_protect
Add or Update Protection for a tunnel with IPSEC.
Definition: ipsec.api:261
bool is_outbound
Definition: ipsec.api:96
vl_api_interface_index_t sw_if_index
Definition: ipsec.api:435
vl_api_address_t remote_address_start
Definition: ipsec.api:104
vl_api_address_t local_ip
Definition: ipsec.api:365
unsigned int u32
Definition: types.h:88
ipsec_spd_action
Definition: ipsec.api:61
u32 context
Definition: ipsec.api:138
vl_api_address_t remote_address_stop
Definition: ipsec.api:105
u32 sa_in[n_sa_in]
Definition: ipsec.api:266
i32 priority
Definition: ipsec.api:95
u32 sa_out
Definition: ipsec.api:264
typedef ipsec_itf
Definition: ipsec.api:398
u32 sa_id
Definition: ipsec.api:98
u32 stat_index
Definition: ipsec.api:216
vl_api_ipsec_tunnel_protect_t tun
Definition: ipsec.api:299
unsigned short u16
Definition: types.h:57
typedef ipsec_spd_entry
IPsec: Security Policy Database entry.
Definition: ipsec.api:93
i32 retval
Definition: ipsec.api:215
vl_api_interface_index_t sw_if_index
Definition: ipsec.api:421
u16 remote_port_stop
Definition: ipsec.api:110
vl_api_interface_index_t sw_if_index
Definition: ipsec.api:490
vl_api_ipsec_tunnel_protect_t tunnel
Definition: ipsec.api:274
vl_api_interface_index_t sw_if_index
Definition: ipsec.api:56
u32 client_index
Definition: ipsec.api:194
vl_api_ipsec_sad_entry_t entry
Definition: ipsec.api:197
vl_api_ipsec_proto_t protocol
Definition: ipsec.api:550
bool is_add
Definition: ipsec.api:196
string name[64]
Definition: ip.api:44
vl_api_ipsec_sad_entry_t entry
Definition: ipsec.api:476
signed int i32
Definition: types.h:77
vl_api_interface_index_t sw_if_index
Definition: ipsec.api:478
void ipsec_set_async_mode(u32 is_enabled)
Definition: ipsec.c:339
option version
Definition: ipsec.api:17
u32 client_index
Definition: ipsec.api:201
vl_api_interface_index_t sw_if_index
Definition: ipsec.api:394
u32 stat_index
Definition: ipsec.api:140
int ipsec_itf_delete(u32 sw_if_index)
Definition: ipsec_itf.c:328
u32 client_index
Definition: ipsec.api:124
vl_api_ipsec_spd_entry_t entry
Definition: ipsec.api:184
vl_api_ipsec_spd_entry_t entry
Definition: ipsec.api:127
u16 remote_port_start
Definition: ipsec.api:109
u32 context
Definition: ipsec.api:125
u32 context
Definition: ipsec.api:214
int ipsec_itf_create(u32 user_instance, tunnel_mode_t mode, u32 *sw_if_indexp)
Definition: ipsec_itf.c:281
vl_api_ipsec_sad_entry_v2_t entry
Definition: ipsec.api:488
bool is_add
Definition: ipsec.api:203
vl_api_address_t nh
Definition: ipsec.api:263
vl_api_tunnel_mode_t mode
Definition: ipsec.api:400
vl_api_interface_index_t sw_if_index
Definition: ipsec.api:428
i32 retval
Definition: ipsec.api:209
u16 local_port_start
Definition: ipsec.api:111
i32 retval
Definition: ipsec.api:139
u32 context
Definition: ipsec.api:202
vl_api_interface_index_t sw_if_index
Definition: ipsec.api:324
u32 context
Definition: ipsec.api:195
u32 stat_index
Definition: ipsec.api:210