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_SPD_H__ |
| 16 | #define __IPSEC_SPD_H__ |
| 17 | |
Piotr Bronowski | 0464310 | 2022-05-10 13:18:22 +0000 | [diff] [blame] | 18 | #include <vppinfra/bihash_40_8.h> |
| 19 | #include <vppinfra/bihash_16_8.h> |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 20 | #include <vlib/vlib.h> |
| 21 | |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 22 | #define foreach_ipsec_spd_policy_type \ |
| 23 | _(IP4_OUTBOUND, "ip4-outbound") \ |
| 24 | _(IP6_OUTBOUND, "ip6-outbound") \ |
| 25 | _(IP4_INBOUND_PROTECT, "ip4-inbound-protect") \ |
| 26 | _(IP6_INBOUND_PROTECT, "ip6-inbound-protect") \ |
| 27 | _(IP4_INBOUND_BYPASS, "ip4-inbound-bypass") \ |
ShivaShankarK | 0546483 | 2020-04-14 14:01:03 +0530 | [diff] [blame] | 28 | _(IP6_INBOUND_BYPASS, "ip6-inbound-bypass") \ |
| 29 | _(IP4_INBOUND_DISCARD, "ip4-inbound-discard") \ |
| 30 | _(IP6_INBOUND_DISCARD, "ip6-inbound-discard") |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 31 | |
| 32 | typedef enum ipsec_spd_policy_t_ |
| 33 | { |
| 34 | #define _(s,v) IPSEC_SPD_POLICY_##s, |
| 35 | foreach_ipsec_spd_policy_type |
| 36 | #undef _ |
| 37 | IPSEC_SPD_POLICY_N_TYPES, |
Neale Ranns | 9f231d4 | 2019-03-19 10:06:00 +0000 | [diff] [blame] | 38 | } ipsec_spd_policy_type_t; |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 39 | |
| 40 | #define FOR_EACH_IPSEC_SPD_POLICY_TYPE(_t) \ |
| 41 | for (_t = 0; _t < IPSEC_SPD_POLICY_N_TYPES; _t++) |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 42 | |
Neale Ranns | 9f231d4 | 2019-03-19 10:06:00 +0000 | [diff] [blame] | 43 | extern u8 *format_ipsec_policy_type (u8 * s, va_list * args); |
| 44 | |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 45 | /** |
Piotr Bronowski | 0464310 | 2022-05-10 13:18:22 +0000 | [diff] [blame] | 46 | * @brief A fast path Security Policy Database |
| 47 | */ |
| 48 | typedef struct |
| 49 | { |
| 50 | /** vectors for each of the policy types */ |
| 51 | u32 *fp_policies[IPSEC_SPD_POLICY_N_TYPES]; |
| 52 | u32 *fp_mask_types[IPSEC_SPD_POLICY_N_TYPES]; |
| 53 | |
| 54 | clib_bihash_40_8_t fp_ip6_lookup_hash; /* spd fp ip6 lookup hash table. */ |
| 55 | clib_bihash_16_8_t fp_ip4_lookup_hash; /* spd fp ip4 lookup hash table. */ |
| 56 | |
| 57 | u8 fp_ip6_lookup_hash_initialized; |
| 58 | |
| 59 | } ipsec_spd_fp_t; |
| 60 | |
| 61 | /** |
| 62 | * @brief A Security Policy Database |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 63 | */ |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 64 | typedef struct |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 65 | { |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 66 | /** the User's ID for this policy */ |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 67 | u32 id; |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 68 | /** vectors for each of the policy types */ |
| 69 | u32 *policies[IPSEC_SPD_POLICY_N_TYPES]; |
Piotr Bronowski | 0464310 | 2022-05-10 13:18:22 +0000 | [diff] [blame] | 70 | /* TODO remove fp_spd. Use directly ipsec_spd_t for fast path */ |
| 71 | ipsec_spd_fp_t fp_spd; |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 72 | } ipsec_spd_t; |
| 73 | |
| 74 | /** |
| 75 | * @brief Add/Delete a SPD |
| 76 | */ |
| 77 | extern int ipsec_add_del_spd (vlib_main_t * vm, u32 spd_id, int is_add); |
| 78 | |
| 79 | /** |
| 80 | * @brief Bind/attach a SPD to an interface |
| 81 | */ |
| 82 | extern int ipsec_set_interface_spd (vlib_main_t * vm, |
| 83 | u32 sw_if_index, u32 spd_id, int is_add); |
| 84 | |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 85 | extern u8 *format_ipsec_spd (u8 * s, va_list * args); |
| 86 | |
Zachary Leaf | 7cd35f5 | 2021-06-25 08:11:15 -0500 | [diff] [blame] | 87 | extern u8 *format_ipsec_out_spd_flow_cache (u8 *s, va_list *args); |
| 88 | extern u8 *format_ipsec_in_spd_flow_cache (u8 *s, va_list *args); |
Govindarajan Mohandoss | 6d7dfcb | 2021-03-19 19:20:49 +0000 | [diff] [blame] | 89 | |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 90 | #endif /* __IPSEC_SPD_H__ */ |
| 91 | |
| 92 | /* |
| 93 | * fd.io coding-style-patch-verification: ON |
| 94 | * |
| 95 | * Local Variables: |
| 96 | * eval: (c-set-style "gnu") |
| 97 | * End: |
| 98 | */ |