2 * Copyright (c) 2016 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.
16 #ifndef __UDP_ENCAP_H__
17 #define __UDP_ENCAP_H__
19 #include <vnet/ip/ip.h>
20 #include <vnet/udp/udp.h>
21 #include <vnet/fib/fib_node.h>
25 * A representation of the encapsulation of packets in UDP-over-IP.
26 * This is encapsulation only, there is no tunnel interface, hence
27 * it is uni-directional. For decap register a handler with the UDP port
32 * Fixup behaviour. Actions performed on the encap in the data-plane
34 typedef enum udp_encap_fixup_flags_t_
36 UDP_ENCAP_FIXUP_NONE = 0,
38 * UDP source port contains an entropy/hash value for load-balancing by downstream peers.
40 UDP_ENCAP_FIXUP_UDP_SRC_PORT_ENTROPY = (1 << 0),
41 } udp_encap_fixup_flags_t;
44 * The UDP encap representation
46 typedef struct udp_encap_t_
49 * The first cacheline contains the data used in the data-plane
51 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
54 * The headers to paint, in packet painting order
62 } __attribute__ ((packed)) ip4;
67 } __attribute__ ((packed)) ip6;
68 } __attribute__ ((packed)) ue_hdrs;
71 * Flags controlling fixup behaviour
73 udp_encap_fixup_flags_t ue_flags;
76 * The DPO used to forward to the next node in the VLIB graph
81 * the protocol of the IP header imposed
83 fib_protocol_t ue_ip_proto;
86 * The second cacheline contains control-plane data
88 CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
91 * linkage into the FIB graph
93 fib_node_t ue_fib_node;
96 * Tracking information for the IP destination
98 fib_node_index_t ue_fib_entry_index;
102 * The FIB index in which the encap destination resides
104 index_t ue_fib_index;
107 extern index_t udp_encap_add_and_lock (fib_protocol_t proto,
109 const ip46_address_t * src_ip,
110 const ip46_address_t * dst_ip,
113 udp_encap_fixup_flags_t flags);
115 extern void udp_encap_lock (index_t uei);
116 extern void udp_encap_unlock (index_t uei);
117 extern u8 *format_udp_encap (u8 * s, va_list * args);
118 extern void udp_encap_contribute_forwarding (index_t uei,
122 extern void udp_encap_get_stats (index_t uei, u64 * packets, u64 * bytes);
125 * Callback function invoked when walking all encap objects.
126 * Return non-zero to continue the walk.
128 typedef walk_rc_t (*udp_encap_walk_cb_t) (index_t uei, void *ctx);
131 * Walk each of the encap objects
133 extern void udp_encap_walk (udp_encap_walk_cb_t cb, void *ctx);
138 extern udp_encap_t *udp_encap_pool;
140 static inline udp_encap_t *
141 udp_encap_get (index_t uei)
143 return (pool_elt_at_index (udp_encap_pool, uei));
147 * fd.io coding-style-patch-verification: ON
150 * eval: (c-set-style "gnu")