1 #ifndef __LINUX_GRE_WRAPPER_H
2 #define __LINUX_GRE_WRAPPER_H
4 #include <linux/skbuff.h>
5 #include <net/ip_tunnels.h>
7 #include <linux/version.h>
8 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) || \
9 defined(HAVE_GRE_CISCO_REGISTER)
10 #include_next <net/gre.h>
13 #ifndef HAVE_GRE_CISCO_REGISTER
15 /* GRE demux not available, implement our own demux. */
16 #define MAX_GRE_PROTO_PRIORITY 255
18 struct gre_cisco_protocol {
19 int (*handler)(struct sk_buff *skb, const struct tnl_ptk_info *tpi);
23 #define gre_cisco_register rpl_gre_cisco_register
24 int gre_cisco_register(struct gre_cisco_protocol *proto);
26 #define gre_cisco_unregister rpl_gre_cisco_unregister
27 int gre_cisco_unregister(struct gre_cisco_protocol *proto);
29 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
34 #define GRE_HEADER_SECTION 4
36 static inline __be16 gre_flags_to_tnl_flags(__be16 flags)
41 tflags |= TUNNEL_CSUM;
42 if (flags & GRE_ROUTING)
43 tflags |= TUNNEL_ROUTING;
48 if (flags & GRE_STRICT)
49 tflags |= TUNNEL_STRICT;
52 if (flags & GRE_VERSION)
53 tflags |= TUNNEL_VERSION;
58 static inline __be16 tnl_flags_to_gre_flags(__be16 tflags)
62 if (tflags & TUNNEL_CSUM)
64 if (tflags & TUNNEL_ROUTING)
66 if (tflags & TUNNEL_KEY)
68 if (tflags & TUNNEL_SEQ)
70 if (tflags & TUNNEL_STRICT)
72 if (tflags & TUNNEL_REC)
74 if (tflags & TUNNEL_VERSION)
79 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) */
80 #endif /* HAVE_GRE_CISCO_REGISTER */
82 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)
84 #define gre_build_header rpl_gre_build_header
85 void gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
88 #define gre_handle_offloads rpl_gre_handle_offloads
89 struct sk_buff *gre_handle_offloads(struct sk_buff *skb, bool gre_csum);
91 #define ip_gre_calc_hlen rpl_ip_gre_calc_hlen
92 static inline int ip_gre_calc_hlen(__be16 o_flags)
96 if (o_flags & TUNNEL_CSUM)
98 if (o_flags & TUNNEL_KEY)
100 if (o_flags & TUNNEL_SEQ)