2 * tunnel.h: shared definitions for tunnels.
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <vnet/ip/ip_types.h>
22 #include <vnet/fib/fib_node.h>
24 #define foreach_tunnel_mode \
25 _(P2P, "point-to-point") \
26 _(MP, "multi-point") \
28 typedef enum tunnel_mode_t_
30 #define _(n, s) TUNNEL_MODE_##n,
33 } __clib_packed tunnel_mode_t;
35 extern u8 *format_tunnel_mode (u8 * s, va_list * args);
36 extern uword unformat_tunnel_mode (unformat_input_t * input, va_list * args);
39 * Keep these idenitical to those in ipip.api
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)
52 typedef enum tunnel_encap_decap_flags_t_
54 #define _(a,b,c) TUNNEL_ENCAP_DECAP_FLAG_##a = c,
55 foreach_tunnel_encap_decap_flag
57 } __clib_packed tunnel_encap_decap_flags_t;
59 extern const u8 TUNNEL_ENCAP_DECAP_FLAG_MASK;
61 extern u8 *format_tunnel_encap_decap_flags (u8 * s, va_list * args);
62 extern uword unformat_tunnel_encap_decap_flags (unformat_input_t *input,
65 #define foreach_tunnel_flag \
66 _ (RESOLVED, 0, "resolved") \
67 _ (TRACK_MTU, 1, "track-mtu")
69 typedef enum tunnel_flags_t_
72 #define _(n, b, s) TUNNEL_FLAG_##n = (1 << b),
75 } __clib_packed tunnel_flags_t;
77 extern const u8 TUNNEL_FLAG_MASK;
79 extern u8 *format_tunnel_flags (u8 *s, va_list *args);
80 extern uword unformat_tunnel_flags (unformat_input_t *input, va_list *args);
83 * A representation of an IP tunnel config
85 typedef struct tunnel_t_
89 tunnel_encap_decap_flags_t t_encap_decap_flags;
90 tunnel_flags_t t_flags;
101 fib_node_index_t t_fib_entry_index;
106 extern u8 *format_tunnel (u8 *s, va_list *args);
107 extern uword unformat_tunnel (unformat_input_t *input, va_list *args);
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);
114 extern ip_address_family_t tunnel_get_af (const tunnel_t *t);
116 extern void tunnel_contribute_forwarding (const tunnel_t *t, dpo_id_t *dpo);
118 extern void tunnel_build_v6_hdr (const tunnel_t *t, ip_protocol_t next_proto,
120 extern void tunnel_build_v4_hdr (const tunnel_t *t, ip_protocol_t next_proto,
126 * fd.io coding-style-patch-verification: ON
129 * eval: (c-set-style "gnu")