Dmitry Kozlov | 00959ad | 2010-08-21 23:05:39 -0700 | [diff] [blame] | 1 | #ifndef __LINUX_GRE_H |
| 2 | #define __LINUX_GRE_H |
| 3 | |
| 4 | #include <linux/skbuff.h> |
Pravin B Shelar | c544193 | 2013-03-25 14:49:35 +0000 | [diff] [blame] | 5 | #include <net/ip_tunnels.h> |
Dmitry Kozlov | 00959ad | 2010-08-21 23:05:39 -0700 | [diff] [blame] | 6 | |
| 7 | #define GREPROTO_CISCO 0 |
| 8 | #define GREPROTO_PPTP 1 |
| 9 | #define GREPROTO_MAX 2 |
| 10 | |
| 11 | struct gre_protocol { |
| 12 | int (*handler)(struct sk_buff *skb); |
| 13 | void (*err_handler)(struct sk_buff *skb, u32 info); |
| 14 | }; |
| 15 | |
Pravin B Shelar | c544193 | 2013-03-25 14:49:35 +0000 | [diff] [blame] | 16 | struct gre_base_hdr { |
| 17 | __be16 flags; |
| 18 | __be16 protocol; |
| 19 | }; |
| 20 | #define GRE_HEADER_SECTION 4 |
| 21 | |
Dmitry Kozlov | 00959ad | 2010-08-21 23:05:39 -0700 | [diff] [blame] | 22 | int gre_add_protocol(const struct gre_protocol *proto, u8 version); |
| 23 | int gre_del_protocol(const struct gre_protocol *proto, u8 version); |
| 24 | |
Pravin B Shelar | c544193 | 2013-03-25 14:49:35 +0000 | [diff] [blame] | 25 | static inline __be16 gre_flags_to_tnl_flags(__be16 flags) |
| 26 | { |
| 27 | __be16 tflags = 0; |
| 28 | |
| 29 | if (flags & GRE_CSUM) |
| 30 | tflags |= TUNNEL_CSUM; |
| 31 | if (flags & GRE_ROUTING) |
| 32 | tflags |= TUNNEL_ROUTING; |
| 33 | if (flags & GRE_KEY) |
| 34 | tflags |= TUNNEL_KEY; |
| 35 | if (flags & GRE_SEQ) |
| 36 | tflags |= TUNNEL_SEQ; |
| 37 | if (flags & GRE_STRICT) |
| 38 | tflags |= TUNNEL_STRICT; |
| 39 | if (flags & GRE_REC) |
| 40 | tflags |= TUNNEL_REC; |
| 41 | if (flags & GRE_VERSION) |
| 42 | tflags |= TUNNEL_VERSION; |
| 43 | |
| 44 | return tflags; |
| 45 | } |
| 46 | |
| 47 | static inline __be16 tnl_flags_to_gre_flags(__be16 tflags) |
| 48 | { |
| 49 | __be16 flags = 0; |
| 50 | |
| 51 | if (tflags & TUNNEL_CSUM) |
| 52 | flags |= GRE_CSUM; |
| 53 | if (tflags & TUNNEL_ROUTING) |
| 54 | flags |= GRE_ROUTING; |
| 55 | if (tflags & TUNNEL_KEY) |
| 56 | flags |= GRE_KEY; |
| 57 | if (tflags & TUNNEL_SEQ) |
| 58 | flags |= GRE_SEQ; |
| 59 | if (tflags & TUNNEL_STRICT) |
| 60 | flags |= GRE_STRICT; |
| 61 | if (tflags & TUNNEL_REC) |
| 62 | flags |= GRE_REC; |
| 63 | if (tflags & TUNNEL_VERSION) |
| 64 | flags |= GRE_VERSION; |
| 65 | |
| 66 | return flags; |
| 67 | } |
| 68 | |
Dmitry Kozlov | 00959ad | 2010-08-21 23:05:39 -0700 | [diff] [blame] | 69 | #endif |