FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
tunnel.h
Go to the documentation of this file.
1 /*
2  * tunnel.h: shared definitions for tunnels.
3  *
4  * Copyright (c) 2019 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 __TUNNEL_H__
19 #define __TUNNEL_H__
20 
21 #include <vnet/ip/ip_types.h>
22 #include <vnet/fib/fib_node.h>
23 
24 #define foreach_tunnel_mode \
25  _(P2P, "point-to-point") \
26  _(MP, "multi-point") \
27 
28 typedef enum tunnel_mode_t_
29 {
30 #define _(n, s) TUNNEL_MODE_##n,
32 #undef _
33 } __clib_packed tunnel_mode_t;
34 
35 extern u8 *format_tunnel_mode (u8 * s, va_list * args);
36 extern uword unformat_tunnel_mode (unformat_input_t * input, va_list * args);
37 
38 /**
39  * Keep these idenitical to those in ipip.api
40  */
41 #define foreach_tunnel_encap_decap_flag \
42  _ (NONE, "none", 0x0) \
43  _ (ENCAP_COPY_DF, "encap-copy-df", 0x1) \
44  _ (ENCAP_SET_DF, "encap-set-df", 0x2) \
45  _ (ENCAP_COPY_DSCP, "encap-copy-dscp", 0x4) \
46  _ (ENCAP_COPY_ECN, "encap-copy-ecn", 0x8) \
47  _ (DECAP_COPY_ECN, "decap-copy-ecn", 0x10) \
48  _ (ENCAP_INNER_HASH, "encap-inner-hash", 0x20) \
49  _ (ENCAP_COPY_HOP_LIMIT, "encap-copy-hop-limit", 0x40) \
50  _ (ENCAP_COPY_FLOW_LABEL, "encap-copy-flow-label", 0x80)
51 
53 {
54 #define _(a,b,c) TUNNEL_ENCAP_DECAP_FLAG_##a = c,
56 #undef _
57 } __clib_packed tunnel_encap_decap_flags_t;
58 
59 extern const u8 TUNNEL_ENCAP_DECAP_FLAG_MASK;
60 
61 extern u8 *format_tunnel_encap_decap_flags (u8 * s, va_list * args);
63  va_list *args);
64 
65 #define foreach_tunnel_flag \
66  _ (RESOLVED, 0, "resolved") \
67  _ (TRACK_MTU, 1, "track-mtu")
68 
69 typedef enum tunnel_flags_t_
70 {
72 #define _(n, b, s) TUNNEL_FLAG_##n = (1 << b),
74 #undef _
75 } __clib_packed tunnel_flags_t;
76 
77 extern const u8 TUNNEL_FLAG_MASK;
78 
79 extern u8 *format_tunnel_flags (u8 *s, va_list *args);
80 extern uword unformat_tunnel_flags (unformat_input_t *input, va_list *args);
81 
82 /**
83  * A representation of an IP tunnel config
84  */
85 typedef struct tunnel_t_
86 {
95 
96  /**
97  * derived data
98  */
100 
103 
104 } tunnel_t;
105 
106 extern u8 *format_tunnel (u8 *s, va_list *args);
107 extern uword unformat_tunnel (unformat_input_t *input, va_list *args);
108 
109 extern void tunnel_copy (const tunnel_t *src, tunnel_t *dst);
110 extern int tunnel_resolve (tunnel_t *t, fib_node_type_t child_type,
111  index_t child_index);
112 extern void tunnel_unresolve (tunnel_t *t);
113 
114 extern ip_address_family_t tunnel_get_af (const tunnel_t *t);
115 
116 extern void tunnel_contribute_forwarding (const tunnel_t *t, dpo_id_t *dpo);
117 
119  ip6_header_t *ip);
121  ip4_header_t *ip);
122 
123 #endif
124 
125 /*
126  * fd.io coding-style-patch-verification: ON
127  *
128  * Local Variables:
129  * eval: (c-set-style "gnu")
130  * End:
131  */
ip_address
Definition: ip_types.h:79
tunnel_t_::t_dscp
ip_dscp_t t_dscp
Definition: tunnel.h:93
TUNNEL_FLAG_MASK
const u8 TUNNEL_FLAG_MASK
Definition: tunnel.c:29
tunnel_encap_decap_flags_t
enum tunnel_encap_decap_flags_t_ tunnel_encap_decap_flags_t
ip_dscp_t
enum ip_dscp_t_ ip_dscp_t
foreach_tunnel_encap_decap_flag
#define foreach_tunnel_encap_decap_flag
Keep these idenitical to those in ipip.api.
Definition: tunnel.h:41
tunnel_t_::t_src
ip_address_t t_src
Definition: tunnel.h:87
format_tunnel_flags
u8 * format_tunnel_flags(u8 *s, va_list *args)
Definition: tunnel.c:96
foreach_tunnel_flag
#define foreach_tunnel_flag
Definition: tunnel.h:65
tunnel_copy
void tunnel_copy(const tunnel_t *src, tunnel_t *dst)
Definition: tunnel.c:131
tunnel_t_
A representation of an IP tunnel config.
Definition: tunnel.h:85
tunnel_flags_t
enum tunnel_flags_t_ tunnel_flags_t
foreach_tunnel_mode
#define foreach_tunnel_mode
Definition: tunnel.h:24
tunnel_t_::t_fib_index
u32 t_fib_index
derived data
Definition: tunnel.h:99
format_tunnel_mode
u8 * format_tunnel_mode(u8 *s, va_list *args)
Definition: tunnel.c:36
tunnel_t_::t_fib_entry_index
fib_node_index_t t_fib_entry_index
Definition: tunnel.h:101
tunnel_flags_t_
tunnel_flags_t_
Definition: tunnel.h:69
unformat_tunnel_encap_decap_flags
uword unformat_tunnel_encap_decap_flags(unformat_input_t *input, va_list *args)
Definition: tunnel.c:82
TUNNEL_FLAG_NONE
@ TUNNEL_FLAG_NONE
Definition: tunnel.h:71
unformat_input_t
struct _unformat_input_t unformat_input_t
fib_node.h
fib_node_type_t
enum fib_node_type_t_ fib_node_type_t
The types of nodes in a FIB graph.
ip4_header_t
Definition: ip4_packet.h:87
tunnel_build_v4_hdr
void tunnel_build_v4_hdr(const tunnel_t *t, ip_protocol_t next_proto, ip4_header_t *ip)
Definition: tunnel.c:247
unformat_tunnel_mode
uword unformat_tunnel_mode(unformat_input_t *input, va_list *args)
Definition: tunnel.c:53
TUNNEL_ENCAP_DECAP_FLAG_MASK
const u8 TUNNEL_ENCAP_DECAP_FLAG_MASK
Definition: tunnel.c:24
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
uword
u64 uword
Definition: types.h:112
tunnel_mode_t_
tunnel_mode_t_
Definition: tunnel.h:28
src
vl_api_address_t src
Definition: gre.api:54
ip_types.h
tunnel_build_v6_hdr
void tunnel_build_v6_hdr(const tunnel_t *t, ip_protocol_t next_proto, ip6_header_t *ip)
Definition: tunnel.c:229
unformat_tunnel_flags
uword unformat_tunnel_flags(unformat_input_t *input, va_list *args)
Definition: tunnel.c:110
unformat_tunnel
uword unformat_tunnel(unformat_input_t *input, va_list *args)
Definition: tunnel.c:168
tunnel_contribute_forwarding
void tunnel_contribute_forwarding(const tunnel_t *t, dpo_id_t *dpo)
Definition: tunnel.c:218
u32
unsigned int u32
Definition: types.h:88
tunnel_t_::t_mode
tunnel_mode_t t_mode
Definition: tunnel.h:91
tunnel_t_::t_dst
ip_address_t t_dst
Definition: tunnel.h:88
dst
vl_api_ip4_address_t dst
Definition: pnat.api:41
tunnel_t_::t_table_id
u32 t_table_id
Definition: tunnel.h:92
ip6_header_t
Definition: ip6_packet.h:294
next_proto
vl_api_udp_decap_next_proto_t next_proto
Definition: udp.api:65
ip_protocol_t
enum ip_protocol ip_protocol_t
tunnel_mode_t
enum tunnel_mode_t_ tunnel_mode_t
u8
unsigned char u8
Definition: types.h:56
ip
vl_api_address_t ip
Definition: l2.api:558
format_tunnel_encap_decap_flags
u8 * format_tunnel_encap_decap_flags(u8 *s, va_list *args)
Definition: tunnel.c:67
tunnel_t_::t_encap_decap_flags
tunnel_encap_decap_flags_t t_encap_decap_flags
Definition: tunnel.h:89
format_tunnel
u8 * format_tunnel(u8 *s, va_list *args)
Definition: tunnel.c:150
tunnel_resolve
int tunnel_resolve(tunnel_t *t, fib_node_type_t child_type, index_t child_index)
Definition: tunnel.c:189
tunnel_encap_decap_flags_t_
tunnel_encap_decap_flags_t_
Definition: tunnel.h:52
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
tunnel_t
struct tunnel_t_ tunnel_t
A representation of an IP tunnel config.
tunnel_get_af
ip_address_family_t tunnel_get_af(const tunnel_t *t)
Definition: tunnel.c:125
tunnel_unresolve
void tunnel_unresolve(tunnel_t *t)
Definition: tunnel.c:209
tunnel_t_::t_hop_limit
u8 t_hop_limit
Definition: tunnel.h:94
tunnel_t_::t_sibling
u32 t_sibling
Definition: tunnel.h:102
tunnel_t_::t_flags
tunnel_flags_t t_flags
Definition: tunnel.h:90
ip_address_family_t
enum ip_address_family_t_ ip_address_family_t