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_nsh_gre_h
16 #define included_vnet_nsh_gre_h
18 #include <vnet/vnet.h>
19 #include <vnet/gre/gre.h>
20 #include <vnet/nsh/nsh_packet.h>
21 #include <vnet/ip/ip4_packet.h>
23 typedef CLIB_PACKED (struct {
24 ip4_header_t ip4; /* 20 bytes */
25 gre_header_t gre; /* 4 bytes */
26 nsh_header_t nsh; /* 28 bytes */
27 }) ip4_gre_and_nsh_header_t;
30 /* Rewrite string. $$$$ embed vnet_rewrite header */
33 /* tunnel src and dst addresses */
38 u32 encap_fib_index; /* tunnel partner lookup here */
39 u32 decap_fib_index; /* inner IP lookup here */
41 /* when decapsulating, send pkts here */
44 /* vnet intfc hw/sw_if_index */
48 /* NSH header fields in HOST byte order */
53 #define foreach_nsh_gre_input_next \
54 _ (DROP, "error-drop") \
55 _ (IP4_INPUT, "ip4-input") \
56 _ (IP6_INPUT, "ip6-input") \
57 _ (ETHERNET_INPUT, "ethernet-input")
60 #define _(s,n) NSH_GRE_INPUT_NEXT_##s,
61 foreach_nsh_gre_input_next
64 } nsh_gre_input_next_t;
67 #define nsh_gre_error(n,s) NSH_GRE_ERROR_##n,
68 #include <vnet/nsh/nsh_error.def>
71 } nsh_gre_input_error_t;
74 /* vector of encap tunnel instances */
75 nsh_gre_tunnel_t *tunnels;
77 /* lookup tunnel by tunnel partner src address */
78 uword * nsh_gre_tunnel_by_src_address;
80 /* Free vlib hw_if_indices */
81 u32 * free_nsh_gre_tunnel_hw_if_indices;
83 /* show device instance by real device instance */
84 u32 * dev_inst_by_real;
87 vlib_main_t * vlib_main;
88 vnet_main_t * vnet_main;
91 nsh_gre_main_t nsh_gre_main;
93 extern vlib_node_registration_t nsh_gre_input_node;
94 extern vlib_node_registration_t nsh_gre_encap_node;
96 u8 * format_nsh_gre_encap_trace (u8 * s, va_list * args);
100 ip4_address_t src, dst;
103 u32 decap_next_index;
104 nsh_header_t nsh_hdr;
105 } vnet_nsh_gre_add_del_tunnel_args_t;
107 int vnet_nsh_gre_add_del_tunnel (vnet_nsh_gre_add_del_tunnel_args_t *a,
110 #endif /* included_vnet_nsh_gre_h */