blob: 730cd717795eacf45fbd04f09cc2281d82fd10c2 [file] [log] [blame]
Matus Fabian694265d2016-08-10 01:55:36 -07001/*
2 * Copyright (c) 2016 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/**
Chris Luke16bcf7d2016-09-01 14:31:46 -040016 * @file
Matus Fabian694265d2016-08-10 01:55:36 -070017 * @brief L2-GRE over IPSec packet processing.
18*/
19
20#ifndef included_ipsec_gre_h
21#define included_ipsec_gre_h
22
23#include <vnet/vnet.h>
24#include <vnet/gre/packet.h>
25#include <vnet/gre/gre.h>
26#include <vnet/ip/ip.h>
27#include <vnet/ip/ip4.h>
28#include <vnet/ip/ip4_packet.h>
29#include <vnet/pg/pg.h>
30#include <vnet/ip/format.h>
Neale Rannse524d452019-02-19 15:22:46 +000031#include <vnet/ipsec/ipsec.h>
32#include <vnet/ipsec/ipsec_if.h>
Matus Fabian694265d2016-08-10 01:55:36 -070033
34extern vnet_hw_interface_class_t ipsec_gre_hw_interface_class;
35
36/**
37 * @brief IPSec-GRE errors.
38 *
39*/
40typedef enum
41{
42#define ipsec_gre_error(n,s) IPSEC_GRE_ERROR_##n,
43#include <vnet/ipsec-gre/error.def>
44#undef ipsec_gre_error
45 IPSEC_GRE_N_ERROR,
46} ipsec_gre_error_t;
47
48/**
49 * @brief IPSec-GRE tunnel parameters.
50 *
51*/
52typedef struct
53{
Dave Baracheb987d32018-05-03 08:26:39 -040054 /* Required for pool_get_aligned */
55 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
Matus Fabian694265d2016-08-10 01:55:36 -070056 ip4_address_t tunnel_src; /**< tunnel IPv4 src address */
57 ip4_address_t tunnel_dst; /**< tunnel IPv4 dst address */
58 u32 local_sa; /**< local IPSec SA index */
59 u32 remote_sa; /**< remote IPSec SA index */
60 u32 local_sa_id; /**< local IPSec SA id */
61 u32 remote_sa_id; /**< remote IPSec SA id */
62 u32 hw_if_index;; /**< hardware interface index */
63 u32 sw_if_index;; /**< software interface index */
64} ipsec_gre_tunnel_t;
65
66/**
67 * @brief IPSec-GRE state.
68 *
69*/
70typedef struct
71{
72 ipsec_gre_tunnel_t *tunnels; /**< pool of tunnel instances */
73
74 uword *tunnel_by_key; /**< hash mapping src/dst addr pair to tunnel */
75
76 u32 *free_ipsec_gre_tunnel_hw_if_indices; /**< free vlib hw_if_indices */
77
78 u32 *tunnel_index_by_sw_if_index; /**< mapping from sw_if_index to tunnel
79 index */
80
81 vlib_main_t *vlib_main; /**< convenience */
82 vnet_main_t *vnet_main; /**< convenience */
83} ipsec_gre_main_t;
84
Dave Wallace71612d62017-10-24 01:32:41 -040085extern ipsec_gre_main_t ipsec_gre_main;
Matus Fabian694265d2016-08-10 01:55:36 -070086
87extern vlib_node_registration_t ipsec_gre_input_node;
88extern vnet_device_class_t ipsec_gre_device_class;
89
90/* manually added to the interface output node in ipsec_gre.c */
Neale Rannse524d452019-02-19 15:22:46 +000091#define IPSEC_GRE_OUTPUT_NEXT_ESP_ENCRYPT 0
Matus Fabian694265d2016-08-10 01:55:36 -070092
Neale Rannse524d452019-02-19 15:22:46 +000093extern int vnet_ipsec_gre_tunnel_add_del (const
94 ipsec_gre_tunnel_add_del_args_t * a,
95 u32 * sw_if_indexp);
Matus Fabian694265d2016-08-10 01:55:36 -070096
97#endif /* included_ipsec_gre_h */
98
99/*
100* fd.io coding-style-patch-verification: ON
101*
102* Local Variables:
103* eval: (c-set-style "gnu")
104* End:
105*/