fd7068e926e198a3a0baab37c7a22782fe89ff54
[vpp.git] / src / vnet / ipsec / ipsec_types.api
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 = "3.0.1";
18
19 import "vnet/ip/ip_types.api";
20 import "vnet/tunnel/tunnel_types.api";
21
22 /*
23  * @brief Support cryptographic algorithms
24  */
25 enum ipsec_crypto_alg
26 {
27   IPSEC_API_CRYPTO_ALG_NONE = 0,
28   IPSEC_API_CRYPTO_ALG_AES_CBC_128,
29   IPSEC_API_CRYPTO_ALG_AES_CBC_192,
30   IPSEC_API_CRYPTO_ALG_AES_CBC_256,
31   IPSEC_API_CRYPTO_ALG_AES_CTR_128,
32   IPSEC_API_CRYPTO_ALG_AES_CTR_192,
33   IPSEC_API_CRYPTO_ALG_AES_CTR_256,
34   IPSEC_API_CRYPTO_ALG_AES_GCM_128,
35   IPSEC_API_CRYPTO_ALG_AES_GCM_192,
36   IPSEC_API_CRYPTO_ALG_AES_GCM_256,
37   IPSEC_API_CRYPTO_ALG_DES_CBC,
38   IPSEC_API_CRYPTO_ALG_3DES_CBC,
39 };
40
41 /*
42  * @brief Supported Integrity Algorithms
43  */
44 enum ipsec_integ_alg
45 {
46   IPSEC_API_INTEG_ALG_NONE = 0,
47   /* RFC2403 */
48   IPSEC_API_INTEG_ALG_MD5_96,
49   /* RFC2404 */
50   IPSEC_API_INTEG_ALG_SHA1_96,
51   /* draft-ietf-ipsec-ciph-sha-256-00 */
52   IPSEC_API_INTEG_ALG_SHA_256_96,
53   /* RFC4868 */
54   IPSEC_API_INTEG_ALG_SHA_256_128,
55   /* RFC4868 */
56   IPSEC_API_INTEG_ALG_SHA_384_192,
57   /* RFC4868 */
58   IPSEC_API_INTEG_ALG_SHA_512_256,
59 };
60
61 enum ipsec_sad_flags
62 {
63   IPSEC_API_SAD_FLAG_NONE = 0,
64   /* Enable extended sequence numbers */
65   IPSEC_API_SAD_FLAG_USE_ESN = 0x01,
66   /* Enable Anti-replay */
67   IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY = 0x02,
68   /* IPsec tunnel mode if non-zero, else transport mode */
69   IPSEC_API_SAD_FLAG_IS_TUNNEL = 0x04,
70   /* IPsec tunnel mode is IPv6 if non-zero,
71    *  else IPv4 tunnel only valid if is_tunnel is non-zero
72    *  DEPRECATED - the user does not need to set this it is
73    *               derived from the tunnel's address types.
74    */
75   IPSEC_API_SAD_FLAG_IS_TUNNEL_V6 = 0x08,
76   /* enable UDP encapsulation for NAT traversal */
77   IPSEC_API_SAD_FLAG_UDP_ENCAP = 0x10,
78   /* IPsec SA is for inbound traffic */
79   IPSEC_API_SAD_FLAG_IS_INBOUND = 0x40,
80   /* IPsec SA uses an Async driver */
81   IPSEC_API_SAD_FLAG_ASYNC = 0x80 [backwards_compatible],
82 };
83
84 enum ipsec_proto
85 {
86   IPSEC_API_PROTO_ESP = 50,
87   IPSEC_API_PROTO_AH = 51,
88 };
89
90 typedef key
91 {
92   /* the length of the key */
93   u8 length;
94   /* The data for the key */
95   u8 data[128];
96 };
97
98 enum ipsec_spd_action
99 {
100   /* bypass - no IPsec processing */
101   IPSEC_API_SPD_ACTION_BYPASS = 0,
102   /* discard - discard packet with ICMP processing */
103   IPSEC_API_SPD_ACTION_DISCARD,
104   /* resolve - send request to control plane for SA resolving */
105   IPSEC_API_SPD_ACTION_RESOLVE,
106   /* protect - apply IPsec policy using following parameters */
107   IPSEC_API_SPD_ACTION_PROTECT,
108 };
109
110 /** \brief IPsec: Security Policy Database entry
111
112     See RFC 4301, 4.4.1.1 on how to match packet to selectors
113
114     @param spd_id - SPD instance id (control plane allocated)
115     @param priority - priority of SPD entry (non-unique value).  Used to order SPD matching - higher priorities match before lower
116     @param is_outbound - entry applies to outbound traffic if non-zero, otherwise applies to inbound traffic
117     @param remote_address_start - start of remote address range to match
118     @param remote_address_stop - end of remote address range to match
119     @param local_address_start - start of local address range to match
120     @param local_address_stop - end of local address range to match
121     @param protocol - protocol type to match [0 means any] otherwise IANA value
122     @param remote_port_start - start of remote port range to match ...
123     @param remote_port_stop - end of remote port range to match [0 to 65535 means ANY, 65535 to 0 means OPAQUE]
124     @param local_port_start - start of local port range to match ...
125     @param local_port_stop - end of remote port range to match [0 to 65535 means ANY, 65535 to 0 means OPAQUE]
126     @param policy - action to perform on match
127     @param sa_id - SAD instance id (control plane allocated)
128 */
129 typedef ipsec_spd_entry
130 {
131   u32 spd_id;
132   i32 priority;
133   bool is_outbound;
134
135   u32 sa_id;
136   vl_api_ipsec_spd_action_t policy;
137   /* Which protocol?? */
138   u8 protocol;
139
140   // Selector
141   vl_api_address_t remote_address_start;
142   vl_api_address_t remote_address_stop;
143   vl_api_address_t local_address_start;
144   vl_api_address_t local_address_stop;
145
146   u16 remote_port_start;
147   u16 remote_port_stop;
148   u16 local_port_start;
149   u16 local_port_stop;
150 };
151
152 /** \brief IPsec: Security Policy Database entry v2
153
154     See RFC 4301, 4.4.1.1 on how to match packet to selectors
155
156     @param spd_id - SPD instance id (control plane allocated)
157     @param priority - priority of SPD entry (non-unique value).  Used to order SPD matching - higher priorities match before lower
158     @param is_outbound - entry applies to outbound traffic if non-zero, otherwise applies to inbound traffic
159     @param remote_address_start - start of remote address range to match
160     @param remote_address_stop - end of remote address range to match
161     @param local_address_start - start of local address range to match
162     @param local_address_stop - end of local address range to match
163     @param protocol - protocol type to match [255 means any] otherwise IANA value
164     @param remote_port_start - start of remote port range to match ...
165     @param remote_port_stop - end of remote port range to match [0 to 65535 means ANY, 65535 to 0 means OPAQUE]
166     @param local_port_start - start of local port range to match ...
167     @param local_port_stop - end of remote port range to match [0 to 65535 means ANY, 65535 to 0 means OPAQUE]
168     @param policy - action to perform on match
169     @param sa_id - SAD instance id (control plane allocated)
170 */
171 typedef ipsec_spd_entry_v2
172 {
173   u32 spd_id;
174   i32 priority;
175   bool is_outbound;
176
177   u32 sa_id;
178   vl_api_ipsec_spd_action_t policy;
179   u8 protocol;
180
181   // Selector
182   vl_api_address_t remote_address_start;
183   vl_api_address_t remote_address_stop;
184   vl_api_address_t local_address_start;
185   vl_api_address_t local_address_stop;
186
187   u16 remote_port_start;
188   u16 remote_port_stop;
189   u16 local_port_start;
190   u16 local_port_stop;
191 };
192
193
194 /** \brief IPsec: Security Association Database entry
195     @param client_index - opaque cookie to identify the sender
196     @param context - sender context, to match reply w/ request
197     @param is_add - add SAD entry if non-zero, else delete
198     @param sad_id - sad id
199     @param spi - security parameter index
200     @param protocol - 0 = AH, 1 = ESP
201     @param crypto_algorithm - a supported crypto algorithm
202     @param crypto_key - crypto keying material
203     @param integrity_algorithm - one of the supported algorithms
204     @param integrity_key - integrity keying material
205     @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
206     @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
207     @param tx_table_id - the FIB id used for encapsulated packets
208     @param salt - for use with counter mode ciphers
209     @param udp_src_port - If using UDP Encapsulation, use this source port for
210                           TX. It is ignored for RX.
211     @param udp_dst_port - If using UDP Encapsulation, use this destination port
212                           for TX. Expect traffic on this port for RX.
213     @param tunnel_flags - Flags controlling the copying of encap/decap value
214     @param dscp - Fixed DSCP vaule for tunnel encap
215  */
216
217 typedef ipsec_sad_entry
218 {
219   u32 sad_id;
220
221   u32 spi;
222
223   vl_api_ipsec_proto_t protocol;
224
225   vl_api_ipsec_crypto_alg_t crypto_algorithm;
226   vl_api_key_t crypto_key;
227
228   vl_api_ipsec_integ_alg_t integrity_algorithm;
229   vl_api_key_t integrity_key;
230
231   vl_api_ipsec_sad_flags_t flags;
232
233   vl_api_address_t tunnel_src;
234   vl_api_address_t tunnel_dst;
235   u32 tx_table_id;
236   u32 salt;
237   u16 udp_src_port [default=4500];
238   u16 udp_dst_port [default=4500];
239 };
240
241 typedef ipsec_sad_entry_v2
242 {
243   u32 sad_id;
244
245   u32 spi;
246
247   vl_api_ipsec_proto_t protocol;
248
249   vl_api_ipsec_crypto_alg_t crypto_algorithm;
250   vl_api_key_t crypto_key;
251
252   vl_api_ipsec_integ_alg_t integrity_algorithm;
253   vl_api_key_t integrity_key;
254
255   vl_api_ipsec_sad_flags_t flags;
256
257   vl_api_address_t tunnel_src;
258   vl_api_address_t tunnel_dst;
259   vl_api_tunnel_encap_decap_flags_t tunnel_flags;
260   vl_api_ip_dscp_t dscp;
261   u32 tx_table_id;
262   u32 salt;
263   u16 udp_src_port [default=4500];
264   u16 udp_dst_port [default=4500];
265 };
266
267 typedef ipsec_sad_entry_v3
268 {
269   u32 sad_id;
270   u32 spi;
271
272   vl_api_ipsec_proto_t protocol;
273
274   vl_api_ipsec_crypto_alg_t crypto_algorithm;
275   vl_api_key_t crypto_key;
276
277   vl_api_ipsec_integ_alg_t integrity_algorithm;
278   vl_api_key_t integrity_key;
279
280   vl_api_ipsec_sad_flags_t flags;
281
282   vl_api_tunnel_t tunnel;
283
284   u32 salt;
285   u16 udp_src_port [default=4500];
286   u16 udp_dst_port [default=4500];
287 };
288
289
290 /*
291  * Local Variables:
292  * eval: (c-set-style "gnu")
293  * End:
294  */