FD.io VPP  v16.06
Vector Packet Processing
gre.h
Go to the documentation of this file.
1 /*
2  * gre.h: types/functions for gre.
3  *
4  * Copyright (c) 2012 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef included_gre_h
19 #define included_gre_h
20 
21 #include <vnet/vnet.h>
22 #include <vnet/gre/packet.h>
23 #include <vnet/ip/ip.h>
24 #include <vnet/ip/ip4.h>
25 #include <vnet/ip/ip4_packet.h>
26 #include <vnet/pg/pg.h>
27 #include <vnet/ip/format.h>
28 
30 
31 typedef enum {
32 #define gre_error(n,s) GRE_ERROR_##n,
33 #include <vnet/gre/error.def>
34 #undef gre_error
36 } gre_error_t;
37 
38 typedef struct {
39  /* Name (a c string). */
40  char * name;
41 
42  /* GRE protocol type in host byte order. */
44 
45  /* Node which handles this type. */
47 
48  /* Next index for this type. */
51 
52 typedef struct {
58 } gre_tunnel_t;
59 
60 typedef struct {
61  /* pool of tunnel instances */
63 
65 
66  /* Hash tables mapping name/protocol to protocol info index. */
67  uword * protocol_info_by_name, * protocol_info_by_protocol;
68  /* Hash mapping src/dst addr pair to tunnel */
70 
71  /* Free vlib hw_if_indices */
73 
74  /* Mapping from sw_if_index to tunnel index */
76 
77  /* convenience */
80 } gre_main_t;
81 
84 {
85  uword * p = hash_get (em->protocol_info_by_protocol, protocol);
86  return p ? vec_elt_at_index (em->protocol_infos, p[0]) : 0;
87 }
88 
90 
91 /* Register given node index to take input for given gre type. */
92 void
94  gre_protocol_t protocol,
95  u32 node_index);
96 
97 void gre_set_adjacency (vnet_rewrite_header_t * rw,
98  uword max_data_bytes,
99  gre_protocol_t protocol);
100 
104 
107 
108 /* Parse gre protocol as 0xXXXX or protocol name.
109  In either host or network byte order. */
112 
113 /* Parse gre header. */
116 
117 void
119  gre_protocol_t protocol,
120  u32 node_index);
121 
122 /* manually added to the interface output node in gre.c */
123 #define GRE_OUTPUT_NEXT_LOOKUP 1
124 
125 typedef struct {
127 
131 
133  (vnet_gre_add_del_tunnel_args_t *a, u32 * sw_if_indexp);
134 
135 #endif /* included_gre_h */
vnet_main_t * vnet_main
Definition: gre.h:79
Definition: gre.h:60
format_function_t format_gre_header_with_length
Definition: gre.h:103
u32 hw_if_index
Definition: gre.h:56
uword( unformat_function_t)(unformat_input_t *input, va_list *args)
Definition: format.h:229
a
Definition: bitmap.h:393
uword * protocol_info_by_protocol
Definition: gre.h:67
uword * tunnel_by_key
Definition: gre.h:69
gre_protocol_t protocol
Definition: gre.h:43
char * name
Definition: gre.h:40
u32 outer_fib_index
Definition: gre.h:55
u32 * free_vxlan_tunnel_hw_if_indices
Definition: gre.h:72
struct _vlib_node_registration vlib_node_registration_t
struct _vnet_device_class vnet_device_class_t
u32 * tunnel_index_by_sw_if_index
Definition: gre.h:75
ip4_address_t tunnel_dst
Definition: gre.h:54
always_inline gre_protocol_info_t * gre_get_protocol_info(gre_main_t *em, gre_protocol_t protocol)
Definition: gre.h:83
u32 sw_if_index
Definition: gre.h:57
#define always_inline
Definition: clib.h:84
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
unformat_function_t unformat_gre_header
Definition: gre.h:114
#define hash_get(h, key)
Definition: hash.h:231
unformat_function_t unformat_gre_protocol_net_byte_order
Definition: gre.h:111
u32 node_index
Definition: gre.h:46
format_function_t format_gre_protocol
Definition: gre.h:101
gre_protocol_t
Definition: packet.h:28
ip4_address_t tunnel_src
Definition: gre.h:53
void gre_set_adjacency(vnet_rewrite_header_t *rw, uword max_data_bytes, gre_protocol_t protocol)
unsigned int u32
Definition: types.h:88
u32 next_index
Definition: gre.h:49
gre_tunnel_t * tunnels
Definition: gre.h:62
gre_main_t gre_main
Definition: gre.h:89
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
vnet_hw_interface_class_t gre_hw_interface_class
vlib_node_registration_t gre_input_node
(constructor) VLIB_REGISTER_NODE (gre_input_node)
Definition: node.c:414
u64 uword
Definition: types.h:112
vnet_device_class_t gre_device_class
int vnet_gre_add_del_tunnel(vnet_gre_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: interface.c:38
struct _vnet_hw_interface_class vnet_hw_interface_class_t
unsigned char u8
Definition: types.h:56
void gre_register_input_type(vlib_main_t *vm, gre_protocol_t protocol, u32 node_index)
unformat_function_t unformat_pg_gre_header
Definition: gre.h:115
void gre_register_input_protocol(vlib_main_t *vm, gre_protocol_t protocol, u32 node_index)
Definition: node.c:438
unformat_function_t unformat_gre_protocol_host_byte_order
Definition: gre.h:110
gre_protocol_info_t * protocol_infos
Definition: gre.h:64
vlib_main_t * vlib_main
Definition: gre.h:78
format_function_t format_gre_header
Definition: gre.h:102
gre_error_t
Definition: gre.h:31