blob: 3a4fd0ec91c181e0f3b5473361153f06f9f9d257 [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_SPD_H__
16#define __IPSEC_SPD_H__
17
Piotr Bronowski04643102022-05-10 13:18:22 +000018#include <vppinfra/bihash_40_8.h>
19#include <vppinfra/bihash_16_8.h>
Neale Ranns999c8ee2019-02-01 03:31:24 -080020#include <vlib/vlib.h>
21
Neale Rannsa09c1ff2019-02-04 01:10:30 -080022#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") \
ShivaShankarK05464832020-04-14 14:01:03 +053028 _(IP6_INBOUND_BYPASS, "ip6-inbound-bypass") \
29 _(IP4_INBOUND_DISCARD, "ip4-inbound-discard") \
30 _(IP6_INBOUND_DISCARD, "ip6-inbound-discard")
Neale Rannsa09c1ff2019-02-04 01:10:30 -080031
32typedef 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 Ranns9f231d42019-03-19 10:06:00 +000038} ipsec_spd_policy_type_t;
Neale Rannsa09c1ff2019-02-04 01:10:30 -080039
40#define FOR_EACH_IPSEC_SPD_POLICY_TYPE(_t) \
41 for (_t = 0; _t < IPSEC_SPD_POLICY_N_TYPES; _t++)
Neale Ranns999c8ee2019-02-01 03:31:24 -080042
Neale Ranns9f231d42019-03-19 10:06:00 +000043extern u8 *format_ipsec_policy_type (u8 * s, va_list * args);
44
Piotr Bronowski993b6be2022-08-31 13:48:14 +000045typedef struct
46{
47 /* index in the mask types pool */
48 u32 mask_type_idx;
49 /* counts references correspond to given mask type index */
50 u32 refcount;
51} ipsec_fp_mask_id_t;
52
Neale Ranns999c8ee2019-02-01 03:31:24 -080053/**
Piotr Bronowski04643102022-05-10 13:18:22 +000054 * @brief A fast path Security Policy Database
55 */
56typedef struct
57{
Piotr Bronowski993b6be2022-08-31 13:48:14 +000058 /** vectors for each of the fast path policy types */
Piotr Bronowski04643102022-05-10 13:18:22 +000059 u32 *fp_policies[IPSEC_SPD_POLICY_N_TYPES];
Piotr Bronowski993b6be2022-08-31 13:48:14 +000060 ipsec_fp_mask_id_t *fp_mask_ids[IPSEC_SPD_POLICY_N_TYPES];
61 /* names of bihash tables */
62 u8 *name4_out;
63 u8 *name4_in;
64 u8 *name6_out;
65 u8 *name6_in;
66 u32 ip6_out_lookup_hash_idx; /* fp ip6 lookup hash out index in the pool */
67 u32 ip4_out_lookup_hash_idx; /* fp ip4 lookup hash out index in the pool */
68 u32 ip6_in_lookup_hash_idx; /* fp ip6 lookup hash in index in the pool */
69 u32 ip4_in_lookup_hash_idx; /* fp ip4 lookup hash in index in the pool */
Piotr Bronowski04643102022-05-10 13:18:22 +000070} ipsec_spd_fp_t;
71
72/**
73 * @brief A Security Policy Database
Neale Ranns999c8ee2019-02-01 03:31:24 -080074 */
Neale Rannsa09c1ff2019-02-04 01:10:30 -080075typedef struct
Neale Ranns999c8ee2019-02-01 03:31:24 -080076{
Neale Rannsa09c1ff2019-02-04 01:10:30 -080077 /** the User's ID for this policy */
Neale Ranns999c8ee2019-02-01 03:31:24 -080078 u32 id;
Neale Rannsa09c1ff2019-02-04 01:10:30 -080079 /** vectors for each of the policy types */
80 u32 *policies[IPSEC_SPD_POLICY_N_TYPES];
Piotr Bronowski04643102022-05-10 13:18:22 +000081 ipsec_spd_fp_t fp_spd;
Neale Ranns999c8ee2019-02-01 03:31:24 -080082} ipsec_spd_t;
83
84/**
85 * @brief Add/Delete a SPD
86 */
87extern int ipsec_add_del_spd (vlib_main_t * vm, u32 spd_id, int is_add);
88
89/**
90 * @brief Bind/attach a SPD to an interface
91 */
92extern int ipsec_set_interface_spd (vlib_main_t * vm,
93 u32 sw_if_index, u32 spd_id, int is_add);
94
Neale Rannsa09c1ff2019-02-04 01:10:30 -080095extern u8 *format_ipsec_spd (u8 * s, va_list * args);
96
Zachary Leaf7cd35f52021-06-25 08:11:15 -050097extern u8 *format_ipsec_out_spd_flow_cache (u8 *s, va_list *args);
98extern u8 *format_ipsec_in_spd_flow_cache (u8 *s, va_list *args);
Govindarajan Mohandoss6d7dfcb2021-03-19 19:20:49 +000099
Neale Ranns999c8ee2019-02-01 03:31:24 -0800100#endif /* __IPSEC_SPD_H__ */
101
102/*
103 * fd.io coding-style-patch-verification: ON
104 *
105 * Local Variables:
106 * eval: (c-set-style "gnu")
107 * End:
108 */