blob: 5d56b4e1e1f170363b669809ba64101fd9376455 [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>
31
32extern vnet_hw_interface_class_t ipsec_gre_hw_interface_class;
33
34/**
35 * @brief IPSec-GRE errors.
36 *
37*/
38typedef enum
39{
40#define ipsec_gre_error(n,s) IPSEC_GRE_ERROR_##n,
41#include <vnet/ipsec-gre/error.def>
42#undef ipsec_gre_error
43 IPSEC_GRE_N_ERROR,
44} ipsec_gre_error_t;
45
46/**
47 * @brief IPSec-GRE tunnel parameters.
48 *
49*/
50typedef struct
51{
52 ip4_address_t tunnel_src; /**< tunnel IPv4 src address */
53 ip4_address_t tunnel_dst; /**< tunnel IPv4 dst address */
54 u32 local_sa; /**< local IPSec SA index */
55 u32 remote_sa; /**< remote IPSec SA index */
56 u32 local_sa_id; /**< local IPSec SA id */
57 u32 remote_sa_id; /**< remote IPSec SA id */
58 u32 hw_if_index;; /**< hardware interface index */
59 u32 sw_if_index;; /**< software interface index */
60} ipsec_gre_tunnel_t;
61
62/**
63 * @brief IPSec-GRE state.
64 *
65*/
66typedef struct
67{
68 ipsec_gre_tunnel_t *tunnels; /**< pool of tunnel instances */
69
70 uword *tunnel_by_key; /**< hash mapping src/dst addr pair to tunnel */
71
72 u32 *free_ipsec_gre_tunnel_hw_if_indices; /**< free vlib hw_if_indices */
73
74 u32 *tunnel_index_by_sw_if_index; /**< mapping from sw_if_index to tunnel
75 index */
76
77 vlib_main_t *vlib_main; /**< convenience */
78 vnet_main_t *vnet_main; /**< convenience */
79} ipsec_gre_main_t;
80
Dave Wallace71612d62017-10-24 01:32:41 -040081extern ipsec_gre_main_t ipsec_gre_main;
Matus Fabian694265d2016-08-10 01:55:36 -070082
83extern vlib_node_registration_t ipsec_gre_input_node;
84extern vnet_device_class_t ipsec_gre_device_class;
85
86/* manually added to the interface output node in ipsec_gre.c */
87#define IPSEC_GRE_OUTPUT_NEXT_ESP_ENCRYPT 1
88
89/**
90 * @brief IPSec-GRE tunnel add/del arguments.
91 *
92*/
93typedef struct
94{
95 u8 is_add; /**< 1 - add, 0 - delete */
96
97 ip4_address_t src; /**< tunnel IPv4 src address */
98 ip4_address_t dst; /**< tunnel IPv4 dst address */
99 u32 lsa; /**< local IPSec SA id */
100 u32 rsa; /**< remote IPSec SA id */
101} vnet_ipsec_gre_add_del_tunnel_args_t;
102
103int vnet_ipsec_gre_add_del_tunnel
104 (vnet_ipsec_gre_add_del_tunnel_args_t * a, u32 * sw_if_indexp);
105
106#endif /* included_ipsec_gre_h */
107
108/*
109* fd.io coding-style-patch-verification: ON
110*
111* Local Variables:
112* eval: (c-set-style "gnu")
113* End:
114*/