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 | |
| 20 | typedef 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 | |
| 29 | typedef 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 Ranns | fe480f6 | 2019-02-28 12:03:58 +0000 | [diff] [blame] | 36 | u32 sw_if_index; |
| 37 | vnet_hw_interface_flags_t flags; |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 38 | u32 show_instance; |
| 39 | } ipsec_tunnel_if_t; |
| 40 | |
| 41 | typedef struct |
| 42 | { |
| 43 | u8 is_add; |
Kingwel Xie | 1ba5bc8 | 2019-03-20 07:21:58 -0400 | [diff] [blame] | 44 | u8 is_ip6; |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 45 | u8 esn; |
| 46 | u8 anti_replay; |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 47 | ip46_address_t local_ip, remote_ip; |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 48 | 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; |
Neale Ranns | 47feb11 | 2019-04-11 15:14:07 +0000 | [diff] [blame] | 64 | u32 salt; |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 65 | } ipsec_add_del_tunnel_args_t; |
| 66 | |
Kingwel Xie | 1ba5bc8 | 2019-03-20 07:21:58 -0400 | [diff] [blame] | 67 | /* *INDENT-OFF* */ |
| 68 | typedef CLIB_PACKED |
| 69 | (struct { |
| 70 | /* |
| 71 | * Key fields: remote ip and spi on incoming packet |
| 72 | * all fields in NET byte order |
| 73 | */ |
| 74 | union { |
| 75 | struct { |
| 76 | u32 remote_ip; |
| 77 | u32 spi; |
| 78 | }; |
| 79 | u64 as_u64; |
| 80 | }; |
| 81 | }) ipsec4_tunnel_key_t; |
| 82 | /* *INDENT-ON* */ |
| 83 | |
| 84 | /* *INDENT-OFF* */ |
| 85 | typedef CLIB_PACKED |
| 86 | (struct { |
| 87 | /* |
| 88 | * Key fields: remote ip and spi on incoming packet |
| 89 | * all fields in NET byte order |
| 90 | */ |
| 91 | ip6_address_t remote_ip; |
| 92 | u32 spi; |
| 93 | }) ipsec6_tunnel_key_t; |
| 94 | /* *INDENT-ON* */ |
| 95 | |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 96 | typedef struct |
| 97 | { |
| 98 | u8 is_add; |
| 99 | u32 local_sa_id; |
| 100 | u32 remote_sa_id; |
Neale Ranns | e524d45 | 2019-02-19 15:22:46 +0000 | [diff] [blame] | 101 | ip4_address_t src; |
| 102 | ip4_address_t dst; |
| 103 | } ipsec_gre_tunnel_add_del_args_t; |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 104 | |
| 105 | extern int ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm, |
| 106 | ipsec_add_del_tunnel_args_t * |
| 107 | args, u32 * sw_if_index); |
| 108 | extern int ipsec_add_del_tunnel_if (ipsec_add_del_tunnel_args_t * args); |
| 109 | extern int ipsec_add_del_ipsec_gre_tunnel (vnet_main_t * vnm, |
Neale Ranns | e524d45 | 2019-02-19 15:22:46 +0000 | [diff] [blame] | 110 | const |
| 111 | ipsec_gre_tunnel_add_del_args_t * |
| 112 | args); |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 113 | |
| 114 | extern int ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index, |
| 115 | ipsec_if_set_key_type_t type, |
| 116 | u8 alg, u8 * key); |
| 117 | extern int ipsec_set_interface_sa (vnet_main_t * vnm, u32 hw_if_index, |
| 118 | u32 sa_id, u8 is_outbound); |
| 119 | |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 120 | extern u8 *format_ipsec_tunnel (u8 * s, va_list * args); |
| 121 | |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 122 | #endif /* __IPSEC_IF_H__ */ |
| 123 | |
| 124 | /* |
| 125 | * fd.io coding-style-patch-verification: ON |
| 126 | * |
| 127 | * Local Variables: |
| 128 | * eval: (c-set-style "gnu") |
| 129 | * End: |
| 130 | */ |