16 #ifndef included_hdr_offset_parser_h 17 #define included_hdr_offset_parser_h 27 #define foreach_gho_flag \ 39 _( 11, IPIP6_TUNNEL) \ 44 #define _(bit, name) GHO_F_##name = (1 << bit), 49 #define GHO_F_TUNNEL (GHO_F_VXLAN_TUNNEL | \ 50 GHO_F_GENEVE_TUNNEL | \ 52 GHO_F_IPIP6_TUNNEL | \ 55 #define GHO_F_OUTER_HDR (GHO_F_OUTER_IP4 | \ 60 #define GHO_F_INNER_HDR (GHO_F_IP4 | \ 89 s =
format (s,
"vxlan-tunnel ");
90 else if (gho->
gho_flags & GHO_F_IPIP_TUNNEL)
91 s =
format (s,
"ipip-tunnel ");
92 else if (gho->
gho_flags & GHO_F_GRE_TUNNEL)
93 s =
format (s,
"gre-tunnel ");
94 else if (gho->
gho_flags & GHO_F_GENEVE_TUNNEL)
95 s =
format (s,
"geneve-tunnel ");
98 s =
format (s,
"outer-ipv4 ");
99 else if (gho->
gho_flags & GHO_F_OUTER_IP6)
100 s =
format (s,
"outer-ipv6 ");
103 s =
format (s,
"outer-udp ");
104 else if (gho->
gho_flags & GHO_F_OUTER_TCP)
105 s =
format (s,
"outer-tcp ");
107 s =
format (s,
"outer-hdr-sz %u outer-l2-hdr-offset %d " 108 "outer-l3-hdr-offset %d outer-l4-hdr-offset %d " 109 "outer-l4-hdr-sz %u\n\t",
125 s =
format (s,
"hdr-sz %u l2-hdr-offset %d " 126 "l3-hdr-offset %d l4-hdr-offset %d " 157 if ((gho->
gho_flags & GHO_F_GENEVE_TUNNEL) == 0)
168 if ((gho->
gho_flags & GHO_F_GRE_TUNNEL) == 0)
178 if ((gho->
gho_flags & (GHO_F_IPIP_TUNNEL | GHO_F_IPIP6_TUNNEL)) == 0)
227 if (l4_proto == IP_PROTOCOL_TCP)
236 else if (l4_proto == IP_PROTOCOL_UDP)
240 l4_hdr_sz =
sizeof (*udp);
258 if ((gho->
gho_flags & GHO_F_VXLAN_TUNNEL) == 0)
294 u16 ethertype = clib_net_to_host_u16 (eh->
type);
301 ethertype = clib_net_to_host_u16 (vlan->
type);
302 l2hdr_sz +=
sizeof (*vlan);
303 if (ethertype == ETHERNET_TYPE_VLAN)
306 ethertype = clib_net_to_host_u16 (vlan->
type);
307 l2hdr_sz +=
sizeof (*vlan);
330 if (l4_proto == IP_PROTOCOL_TCP)
339 else if (l4_proto == IP_PROTOCOL_UDP)
343 l4_hdr_sz =
sizeof (*udp);
361 else if (gho->
gho_flags & (GHO_F_IPIP_TUNNEL | GHO_F_IPIP6_TUNNEL))
363 else if (gho->
gho_flags & GHO_F_GRE_TUNNEL)
365 else if (gho->
gho_flags & GHO_F_GENEVE_TUNNEL)
372 int is_l2,
int is_ip4,
int is_ip6)
385 ethertype = clib_net_to_host_u16 (eh->
type);
392 ethertype = clib_net_to_host_u16 (vlan->
type);
393 l2hdr_sz +=
sizeof (*vlan);
394 if (ethertype == ETHERNET_TYPE_VLAN)
397 ethertype = clib_net_to_host_u16 (vlan->
type);
398 l2hdr_sz +=
sizeof (*vlan);
403 l2hdr_sz =
vnet_buffer (b0)->ip.save_rewrite_length;
425 if (l4_proto == IP_PROTOCOL_TCP)
433 else if (l4_proto == IP_PROTOCOL_UDP)
437 l4_hdr_sz =
sizeof (*udp);
441 if (UDP_DST_PORT_vxlan == clib_net_to_host_u16 (udp->
dst_port))
446 else if (UDP_DST_PORT_geneve == clib_net_to_host_u16 (udp->
dst_port))
451 else if (l4_proto == IP_PROTOCOL_IP_IN_IP)
456 else if (l4_proto == IP_PROTOCOL_IPV6)
461 else if (l4_proto == IP_PROTOCOL_GRE)
static_always_inline void vnet_get_outer_header(vlib_buffer_t *b0, generic_header_offset_t *gho)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static_always_inline void vnet_get_inner_header(vlib_buffer_t *b0, generic_header_offset_t *gho)
struct _tcp_header tcp_header_t
static_always_inline void vnet_generic_inner_header_parser_inline(vlib_buffer_t *b0, generic_header_offset_t *gho)
#define static_always_inline
static_always_inline void vnet_vxlan_inner_header_parser_inline(vlib_buffer_t *b0, generic_header_offset_t *gho)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
enum gho_flag_t_ gho_flag_t
static_always_inline void vnet_geneve_inner_header_parser_inline(vlib_buffer_t *b0, generic_header_offset_t *gho)
static_always_inline int ethernet_frame_is_tagged(u16 type)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static_always_inline void vnet_gre_inner_header_parser_inline(vlib_buffer_t *b0, generic_header_offset_t *gho)
static_always_inline void vnet_generic_header_offset_parser(vlib_buffer_t *b0, generic_header_offset_t *gho, int is_l2, int is_ip4, int is_ip6)
VLIB buffer representation.
static_always_inline void vnet_ipip_inner_header_parser_inline(vlib_buffer_t *b0, generic_header_offset_t *gho)
static_always_inline u8 * format_generic_header_offset(u8 *s, va_list *args)
static int tcp_header_bytes(tcp_header_t *t)
static int ip4_header_bytes(const ip4_header_t *i)
static_always_inline void vnet_generic_outer_header_parser_inline(vlib_buffer_t *b0, generic_header_offset_t *gho, int is_l2, int is_ip4, int is_ip6)