1 #ifndef __LINUX_GRE_WRAPPER_H
2 #define __LINUX_GRE_WRAPPER_H
4 #include <linux/skbuff.h>
5 #include <net/ip_tunnels.h>
7 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) || \
8 defined(HAVE_GRE_CISCO_REGISTER)
9 #include_next <net/gre.h>
12 #ifndef HAVE_GRE_CISCO_REGISTER
14 /* GRE demux not available, implement our own demux. */
15 #define MAX_GRE_PROTO_PRIORITY 255
17 struct gre_cisco_protocol {
18 int (*handler)(struct sk_buff *skb, const struct tnl_ptk_info *tpi);
22 #define gre_cisco_register rpl_gre_cisco_register
23 int gre_cisco_register(struct gre_cisco_protocol *proto);
25 #define gre_cisco_unregister rpl_gre_cisco_unregister
26 int gre_cisco_unregister(struct gre_cisco_protocol *proto);
28 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
33 #define GRE_HEADER_SECTION 4
35 static inline __be16 gre_flags_to_tnl_flags(__be16 flags)
40 tflags |= TUNNEL_CSUM;
41 if (flags & GRE_ROUTING)
42 tflags |= TUNNEL_ROUTING;
47 if (flags & GRE_STRICT)
48 tflags |= TUNNEL_STRICT;
51 if (flags & GRE_VERSION)
52 tflags |= TUNNEL_VERSION;
57 static inline __be16 tnl_flags_to_gre_flags(__be16 tflags)
61 if (tflags & TUNNEL_CSUM)
63 if (tflags & TUNNEL_ROUTING)
65 if (tflags & TUNNEL_KEY)
67 if (tflags & TUNNEL_SEQ)
69 if (tflags & TUNNEL_STRICT)
71 if (tflags & TUNNEL_REC)
73 if (tflags & TUNNEL_VERSION)
78 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) */
79 #endif /* HAVE_GRE_CISCO_REGISTER */
81 #define gre_build_header rpl_gre_build_header
82 void gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
85 #define gre_handle_offloads rpl_gre_handle_offloads
86 struct sk_buff *gre_handle_offloads(struct sk_buff *skb, bool gre_csum);
88 #define ip_gre_calc_hlen rpl_ip_gre_calc_hlen
89 static inline int ip_gre_calc_hlen(__be16 o_flags)
93 if (o_flags & TUNNEL_CSUM)
95 if (o_flags & TUNNEL_KEY)
97 if (o_flags & TUNNEL_SEQ)