Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 20 | typedef struct |
| 21 | { |
| 22 | /* Required for pool_get_aligned */ |
| 23 | CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); |
| 24 | u32 input_sa_index; |
| 25 | u32 output_sa_index; |
| 26 | u32 hw_if_index; |
Neale Ranns | fe480f6 | 2019-02-28 12:03:58 +0000 | [diff] [blame] | 27 | u32 sw_if_index; |
| 28 | vnet_hw_interface_flags_t flags; |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 29 | u32 show_instance; |
| 30 | } ipsec_tunnel_if_t; |
| 31 | |
| 32 | typedef struct |
| 33 | { |
| 34 | u8 is_add; |
Kingwel Xie | 1ba5bc8 | 2019-03-20 07:21:58 -0400 | [diff] [blame] | 35 | u8 is_ip6; |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 36 | u8 esn; |
| 37 | u8 anti_replay; |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 38 | ip46_address_t local_ip, remote_ip; |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 39 | u32 local_spi; |
| 40 | u32 remote_spi; |
| 41 | ipsec_crypto_alg_t crypto_alg; |
| 42 | u8 local_crypto_key_len; |
| 43 | u8 local_crypto_key[128]; |
| 44 | u8 remote_crypto_key_len; |
| 45 | u8 remote_crypto_key[128]; |
| 46 | ipsec_integ_alg_t integ_alg; |
| 47 | u8 local_integ_key_len; |
| 48 | u8 local_integ_key[128]; |
| 49 | u8 remote_integ_key_len; |
| 50 | u8 remote_integ_key[128]; |
| 51 | u8 renumber; |
| 52 | u32 show_instance; |
| 53 | u8 udp_encap; |
| 54 | u32 tx_table_id; |
Neale Ranns | 47feb11 | 2019-04-11 15:14:07 +0000 | [diff] [blame] | 55 | u32 salt; |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 56 | } ipsec_add_del_tunnel_args_t; |
| 57 | |
Kingwel Xie | 1ba5bc8 | 2019-03-20 07:21:58 -0400 | [diff] [blame] | 58 | /* *INDENT-OFF* */ |
| 59 | typedef CLIB_PACKED |
| 60 | (struct { |
| 61 | /* |
| 62 | * Key fields: remote ip and spi on incoming packet |
| 63 | * all fields in NET byte order |
| 64 | */ |
| 65 | union { |
| 66 | struct { |
Neale Ranns | 41afb33 | 2019-07-16 06:19:35 -0700 | [diff] [blame] | 67 | ip4_address_t remote_ip; |
Kingwel Xie | 1ba5bc8 | 2019-03-20 07:21:58 -0400 | [diff] [blame] | 68 | u32 spi; |
| 69 | }; |
| 70 | u64 as_u64; |
| 71 | }; |
| 72 | }) ipsec4_tunnel_key_t; |
| 73 | /* *INDENT-ON* */ |
| 74 | |
| 75 | /* *INDENT-OFF* */ |
| 76 | typedef CLIB_PACKED |
| 77 | (struct { |
| 78 | /* |
| 79 | * Key fields: remote ip and spi on incoming packet |
| 80 | * all fields in NET byte order |
| 81 | */ |
| 82 | ip6_address_t remote_ip; |
| 83 | u32 spi; |
| 84 | }) ipsec6_tunnel_key_t; |
| 85 | /* *INDENT-ON* */ |
| 86 | |
Neale Ranns | 41afb33 | 2019-07-16 06:19:35 -0700 | [diff] [blame] | 87 | extern u8 *format_ipsec4_tunnel_key (u8 * s, va_list * args); |
| 88 | extern u8 *format_ipsec6_tunnel_key (u8 * s, va_list * args); |
| 89 | |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 90 | extern int ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm, |
| 91 | ipsec_add_del_tunnel_args_t * |
| 92 | args, u32 * sw_if_index); |
| 93 | extern int ipsec_add_del_tunnel_if (ipsec_add_del_tunnel_args_t * args); |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 94 | |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 95 | extern int ipsec_set_interface_sa (vnet_main_t * vnm, u32 hw_if_index, |
| 96 | u32 sa_id, u8 is_outbound); |
| 97 | |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 98 | extern u8 *format_ipsec_tunnel (u8 * s, va_list * args); |
| 99 | |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 100 | #endif /* __IPSEC_IF_H__ */ |
| 101 | |
| 102 | /* |
| 103 | * fd.io coding-style-patch-verification: ON |
| 104 | * |
| 105 | * Local Variables: |
| 106 | * eval: (c-set-style "gnu") |
| 107 | * End: |
| 108 | */ |