virtio_pci: better macro exported in uapi
[linux-2.6/btrfs-unstable.git] / include / net / gre.h
blob9f03a390c826a44a700f42715c48fe6f11eef9ca
1 #ifndef __LINUX_GRE_H
2 #define __LINUX_GRE_H
4 #include <linux/skbuff.h>
5 #include <net/ip_tunnels.h>
7 #define GREPROTO_CISCO 0
8 #define GREPROTO_PPTP 1
9 #define GREPROTO_MAX 2
11 struct gre_protocol {
12 int (*handler)(struct sk_buff *skb);
13 void (*err_handler)(struct sk_buff *skb, u32 info);
16 struct gre_base_hdr {
17 __be16 flags;
18 __be16 protocol;
20 #define GRE_HEADER_SECTION 4
22 int gre_add_protocol(const struct gre_protocol *proto, u8 version);
23 int gre_del_protocol(const struct gre_protocol *proto, u8 version);
25 static inline __be16 gre_flags_to_tnl_flags(__be16 flags)
27 __be16 tflags = 0;
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;
44 return tflags;
47 static inline __be16 tnl_flags_to_gre_flags(__be16 tflags)
49 __be16 flags = 0;
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;
66 return flags;
69 #endif