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-gre/nsh_gre_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 */
55 /* Context headers, always present, in HOST byte order */
60 #define foreach_nsh_gre_input_next \
61 _ (DROP, "error-drop") \
62 _ (IP4_INPUT, "ip4-input") \
63 _ (IP6_INPUT, "ip6-input") \
64 _ (ETHERNET_INPUT, "ethernet-input")
67 #define _(s,n) NSH_INPUT_NEXT_##s,
68 foreach_nsh_gre_input_next
71 } nsh_gre_input_next_t;
74 #define nsh_gre_error(n,s) NSH_GRE_ERROR_##n,
75 #include <vnet/nsh-gre/nsh_gre_error.def>
78 } nsh_gre_input_error_t;
81 /* vector of encap tunnel instances */
82 nsh_gre_tunnel_t *tunnels;
84 /* lookup tunnel by tunnel partner src address */
85 uword * nsh_gre_tunnel_by_src_address;
87 /* Free vlib hw_if_indices */
88 u32 * free_nsh_gre_tunnel_hw_if_indices;
90 /* show device instance by real device instance */
91 u32 * dev_inst_by_real;
94 vlib_main_t * vlib_main;
95 vnet_main_t * vnet_main;
98 nsh_gre_main_t nsh_gre_main;
100 vlib_node_registration_t nsh_gre_input_node;
101 vlib_node_registration_t nsh_gre_encap_node;
103 u8 * format_nsh_gre_encap_trace (u8 * s, va_list * args);
107 ip4_address_t src, dst;
110 u32 decap_next_index;
118 } vnet_nsh_gre_add_del_tunnel_args_t;
120 int vnet_nsh_gre_add_del_tunnel (vnet_nsh_gre_add_del_tunnel_args_t *a,
123 #endif /* included_vnet_nsh_gre_h */