blob: 1e7f9df7c9358b3754bdf7a0e12bfca7a76523f9 [file] [log] [blame]
Neale Ranns999c8ee2019-02-01 03:31:24 -08001/*
2 * Copyright (c) 2015 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#ifndef __IPSEC_IF_H__
16#define __IPSEC_IF_H__
17
18#include <vnet/ipsec/ipsec_sa.h>
19
20typedef enum
21{
22 IPSEC_IF_SET_KEY_TYPE_NONE,
23 IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO,
24 IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO,
25 IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG,
26 IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG,
27} ipsec_if_set_key_type_t;
28
29typedef struct
30{
31 /* Required for pool_get_aligned */
32 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
33 u32 input_sa_index;
34 u32 output_sa_index;
35 u32 hw_if_index;
Neale Rannsfe480f62019-02-28 12:03:58 +000036 u32 sw_if_index;
37 vnet_hw_interface_flags_t flags;
Neale Ranns999c8ee2019-02-01 03:31:24 -080038 u32 show_instance;
39} ipsec_tunnel_if_t;
40
41typedef struct
42{
43 u8 is_add;
Kingwel Xie1ba5bc82019-03-20 07:21:58 -040044 u8 is_ip6;
Neale Ranns999c8ee2019-02-01 03:31:24 -080045 u8 esn;
46 u8 anti_replay;
Neale Ranns8d7c5022019-02-06 01:41:05 -080047 ip46_address_t local_ip, remote_ip;
Neale Ranns999c8ee2019-02-01 03:31:24 -080048 u32 local_spi;
49 u32 remote_spi;
50 ipsec_crypto_alg_t crypto_alg;
51 u8 local_crypto_key_len;
52 u8 local_crypto_key[128];
53 u8 remote_crypto_key_len;
54 u8 remote_crypto_key[128];
55 ipsec_integ_alg_t integ_alg;
56 u8 local_integ_key_len;
57 u8 local_integ_key[128];
58 u8 remote_integ_key_len;
59 u8 remote_integ_key[128];
60 u8 renumber;
61 u32 show_instance;
62 u8 udp_encap;
63 u32 tx_table_id;
64} ipsec_add_del_tunnel_args_t;
65
Kingwel Xie1ba5bc82019-03-20 07:21:58 -040066/* *INDENT-OFF* */
67typedef CLIB_PACKED
68(struct {
69 /*
70 * Key fields: remote ip and spi on incoming packet
71 * all fields in NET byte order
72 */
73 union {
74 struct {
75 u32 remote_ip;
76 u32 spi;
77 };
78 u64 as_u64;
79 };
80}) ipsec4_tunnel_key_t;
81/* *INDENT-ON* */
82
83/* *INDENT-OFF* */
84typedef CLIB_PACKED
85(struct {
86 /*
87 * Key fields: remote ip and spi on incoming packet
88 * all fields in NET byte order
89 */
90 ip6_address_t remote_ip;
91 u32 spi;
92}) ipsec6_tunnel_key_t;
93/* *INDENT-ON* */
94
Neale Ranns999c8ee2019-02-01 03:31:24 -080095typedef struct
96{
97 u8 is_add;
98 u32 local_sa_id;
99 u32 remote_sa_id;
Neale Rannse524d452019-02-19 15:22:46 +0000100 ip4_address_t src;
101 ip4_address_t dst;
102} ipsec_gre_tunnel_add_del_args_t;
Neale Ranns999c8ee2019-02-01 03:31:24 -0800103
104extern int ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm,
105 ipsec_add_del_tunnel_args_t *
106 args, u32 * sw_if_index);
107extern int ipsec_add_del_tunnel_if (ipsec_add_del_tunnel_args_t * args);
108extern int ipsec_add_del_ipsec_gre_tunnel (vnet_main_t * vnm,
Neale Rannse524d452019-02-19 15:22:46 +0000109 const
110 ipsec_gre_tunnel_add_del_args_t *
111 args);
Neale Ranns999c8ee2019-02-01 03:31:24 -0800112
113extern int ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index,
114 ipsec_if_set_key_type_t type,
115 u8 alg, u8 * key);
116extern int ipsec_set_interface_sa (vnet_main_t * vnm, u32 hw_if_index,
117 u32 sa_id, u8 is_outbound);
118
Neale Rannsb294f102019-04-03 13:17:50 +0000119extern u8 *format_ipsec_tunnel (u8 * s, va_list * args);
120
Neale Ranns999c8ee2019-02-01 03:31:24 -0800121#endif /* __IPSEC_IF_H__ */
122
123/*
124 * fd.io coding-style-patch-verification: ON
125 *
126 * Local Variables:
127 * eval: (c-set-style "gnu")
128 * End:
129 */