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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef included_vnet_vxlan_gpe_h
16 #define included_vnet_vxlan_gpe_h
18 #include <vppinfra/error.h>
19 #include <vppinfra/hash.h>
20 #include <vnet/vnet.h>
21 #include <vnet/ip/ip.h>
22 #include <vnet/l2/l2_input.h>
23 #include <vnet/ethernet/ethernet.h>
24 #include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
25 #include <vnet/ip/ip4_packet.h>
26 #include <vnet/ip/udp.h>
29 typedef CLIB_PACKED (struct {
30 ip4_header_t ip4; /* 20 bytes */
31 udp_header_t udp; /* 8 bytes */
32 vxlan_gpe_header_t vxlan; /* 8 bytes */
33 }) ip4_vxlan_gpe_header_t;
35 typedef CLIB_PACKED(struct {
37 * Key fields: local remote, vni
38 * all fields in NET byte order
44 u32 vni; /* shifted 8 bits */
49 }) vxlan_gpe_tunnel_key_t;
52 /* Rewrite string. $$$$ embed vnet_rewrite header */
55 /* encapsulated protocol */
58 /* tunnel src and dst addresses */
63 u32 encap_fib_index; /* tunnel partner lookup here */
64 u32 decap_fib_index; /* inner IP lookup here */
66 /* vxlan VNI in HOST byte order, shifted left 8 bits */
69 /* vnet intfc hw/sw_if_index */
75 #define foreach_vxlan_gpe_input_next \
76 _(DROP, "error-drop") \
77 _(IP4_INPUT, "ip4-input") \
78 _(IP6_INPUT, "ip6-input") \
79 _(ETHERNET_INPUT, "ethernet-input") \
80 _(NSH_INPUT, "nsh-input")
83 #define _(s,n) VXLAN_GPE_INPUT_NEXT_##s,
84 foreach_vxlan_gpe_input_next
86 VXLAN_GPE_INPUT_N_NEXT,
87 } vxlan_gpe_input_next_t;
90 #define vxlan_gpe_error(n,s) VXLAN_GPE_ERROR_##n,
91 #include <vnet/vxlan-gpe/vxlan_gpe_error.def>
92 #undef vxlan_gpe_error
94 } vxlan_gpe_input_error_t;
97 /* vector of encap tunnel instances */
98 vxlan_gpe_tunnel_t *tunnels;
100 /* lookup tunnel by key */
101 uword * vxlan_gpe_tunnel_by_key;
103 /* Free vlib hw_if_indices */
104 u32 * free_vxlan_gpe_tunnel_hw_if_indices;
106 /* show device instance by real device instance */
107 u32 * dev_inst_by_real;
110 vlib_main_t * vlib_main;
111 vnet_main_t * vnet_main;
114 vxlan_gpe_main_t vxlan_gpe_main;
116 extern vlib_node_registration_t vxlan_gpe_encap_node;
117 extern vlib_node_registration_t vxlan_gpe_input_node;
119 u8 * format_vxlan_gpe_encap_trace (u8 * s, va_list * args);
123 ip4_address_t local, remote;
127 u32 decap_next_index;
129 } vnet_vxlan_gpe_add_del_tunnel_args_t;
132 int vnet_vxlan_gpe_add_del_tunnel
133 (vnet_vxlan_gpe_add_del_tunnel_args_t *a, u32 * sw_if_indexp);
139 #endif /* included_vnet_vxlan_gpe_h */