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:
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.
16 #ifndef included_vnet_lisp_gpe_h
17 #define included_vnet_lisp_gpe_h
19 #include <vppinfra/error.h>
20 #include <vppinfra/mhash.h>
21 #include <vnet/vnet.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/l2/l2_input.h>
24 #include <vnet/ethernet/ethernet.h>
25 #include <vnet/ip/ip4_packet.h>
26 #include <vnet/ip/udp.h>
27 #include <vnet/lisp-cp/lisp_types.h>
28 #include <vnet/lisp-gpe/lisp_gpe_packet.h>
30 #define IP_UDP_HDR_LEN (word) (sizeof(udp_header_t) + sizeof(ip4_header_t))
32 typedef CLIB_PACKED (struct {
33 ip4_header_t ip4; /* 20 bytes */
34 udp_header_t udp; /* 8 bytes */
35 lisp_gpe_header_t lisp; /* 8 bytes */
36 }) ip4_udp_lisp_gpe_header_t;
50 } lisp_gpe_tunnel_key_t;
54 /* Rewrite string. $$$$ embed vnet_rewrite header */
57 /* decap next index */
60 /* tunnel src and dst addresses */
65 u32 encap_fib_index; /* tunnel partner lookup here */
66 u32 decap_fib_index; /* inner IP lookup here */
68 /* vnet intfc hw/sw_if_index */
72 /* LISP header fields in HOST byte order */
80 #define foreach_lisp_gpe_input_next \
81 _(DROP, "error-drop") \
82 _(IP4_INPUT, "ip4-input") \
83 _(IP6_INPUT, "ip6-input") \
84 _(ETHERNET_INPUT, "ethernet-input") \
85 _(LISP_GPE_ENCAP, "lisp-gpe-encap")
88 #define _(s,n) LISP_GPE_INPUT_NEXT_##s,
89 foreach_lisp_gpe_input_next
91 LISP_GPE_INPUT_N_NEXT,
92 } lisp_gpe_input_next_t;
95 #define lisp_gpe_error(n,s) LISP_GPE_ERROR_##n,
96 #include <vnet/lisp-gpe/lisp_gpe_error.def>
99 } lisp_gpe_input_error_t;
101 /* As a first step, reuse v4 fib. The goal of the typedef is to shield
102 * consumers from future updates that may result in the lisp ip4 fib diverging
104 typedef ip4_fib_t lisp_ip4_fib_t;
106 typedef struct lisp_gpe_main
108 /* Pool of src fibs that are paired with dst fibs */
109 ip4_fib_t * src_fibs;
111 /* vector of encap tunnel instances */
112 lisp_gpe_tunnel_t * tunnels;
114 /* lookup tunnel by key */
115 mhash_t lisp_gpe_tunnel_by_key;
117 /* lookup tunnel by adjacency index */
118 uword * lisp_gpe_tunnel_by_adj_index;
120 /* Free vlib hw_if_indices */
121 u32 * free_lisp_gpe_tunnel_hw_if_indices;
123 u32 lisp_gpe_hw_if_index;
125 /* next node indexes that points ip4 lookup to lisp gpe lookup and lisp cp */
126 u32 ip4_lookup_next_lgpe_ip4_lookup;
129 vlib_main_t * vlib_main;
130 vnet_main_t * vnet_main;
131 ip_lookup_main_t * lookup_main;
135 lisp_gpe_main_t lisp_gpe_main;
137 extern vlib_node_registration_t lgpe_ip4_lookup_node;
138 extern vlib_node_registration_t lisp_gpe_input_node;
139 extern vlib_node_registration_t lisp_gpe_encap_node;
142 format_lisp_gpe_encap_trace (u8 * s, va_list * args);
144 format_lisp_gpe_header_with_length (u8 * s, va_list * args);
149 ip4_address_t src, dst;
152 u32 decap_next_index;
157 u32 iid; /* host byte order */
158 } vnet_lisp_gpe_add_del_tunnel_args_t;
161 vnet_lisp_gpe_add_del_tunnel (vnet_lisp_gpe_add_del_tunnel_args_t *a,
167 } vnet_lisp_gpe_add_del_iface_args_t;
170 vnet_lisp_gpe_add_del_iface (vnet_lisp_gpe_add_del_iface_args_t *a,
179 } negative_fwd_actions_e;
185 negative_fwd_actions_e action;
186 gid_address_t seid; /* TODO convert to ip4, ip6, mac ? */
188 ip_address_t slocator;
189 ip_address_t dlocator;
192 u32 decap_next_index;
197 u32 iid; /* host byte order */
198 } vnet_lisp_gpe_add_del_fwd_entry_args_t;
201 vnet_lisp_gpe_add_del_fwd_entry (vnet_lisp_gpe_add_del_fwd_entry_args_t *a,
205 format_lisp_gpe_header_with_length (u8 * s, va_list * args);
207 #endif /* included_vnet_lisp_gpe_h */