[NET]: netfilter checksum annotations
[linux-2.6/kvm.git] / include / linux / netfilter_ipv4 / ip_conntrack_proto_gre.h
blobe371e0fc1672d773f9991aa27ba1c7ee66ffe8cf
1 #ifndef _CONNTRACK_PROTO_GRE_H
2 #define _CONNTRACK_PROTO_GRE_H
3 #include <asm/byteorder.h>
5 /* GRE PROTOCOL HEADER */
7 /* GRE Version field */
8 #define GRE_VERSION_1701 0x0
9 #define GRE_VERSION_PPTP 0x1
11 /* GRE Protocol field */
12 #define GRE_PROTOCOL_PPTP 0x880B
14 /* GRE Flags */
15 #define GRE_FLAG_C 0x80
16 #define GRE_FLAG_R 0x40
17 #define GRE_FLAG_K 0x20
18 #define GRE_FLAG_S 0x10
19 #define GRE_FLAG_A 0x80
21 #define GRE_IS_C(f) ((f)&GRE_FLAG_C)
22 #define GRE_IS_R(f) ((f)&GRE_FLAG_R)
23 #define GRE_IS_K(f) ((f)&GRE_FLAG_K)
24 #define GRE_IS_S(f) ((f)&GRE_FLAG_S)
25 #define GRE_IS_A(f) ((f)&GRE_FLAG_A)
27 /* GRE is a mess: Four different standards */
28 struct gre_hdr {
29 #if defined(__LITTLE_ENDIAN_BITFIELD)
30 __u16 rec:3,
31 srr:1,
32 seq:1,
33 key:1,
34 routing:1,
35 csum:1,
36 version:3,
37 reserved:4,
38 ack:1;
39 #elif defined(__BIG_ENDIAN_BITFIELD)
40 __u16 csum:1,
41 routing:1,
42 key:1,
43 seq:1,
44 srr:1,
45 rec:3,
46 ack:1,
47 reserved:4,
48 version:3;
49 #else
50 #error "Adjust your <asm/byteorder.h> defines"
51 #endif
52 __be16 protocol;
55 /* modified GRE header for PPTP */
56 struct gre_hdr_pptp {
57 __u8 flags; /* bitfield */
58 __u8 version; /* should be GRE_VERSION_PPTP */
59 __be16 protocol; /* should be GRE_PROTOCOL_PPTP */
60 __be16 payload_len; /* size of ppp payload, not inc. gre header */
61 __be16 call_id; /* peer's call_id for this session */
62 __be32 seq; /* sequence number. Present if S==1 */
63 __be32 ack; /* seq number of highest packet recieved by */
64 /* sender in this session */
68 /* this is part of ip_conntrack */
69 struct ip_ct_gre {
70 unsigned int stream_timeout;
71 unsigned int timeout;
74 #ifdef __KERNEL__
75 struct ip_conntrack_expect;
76 struct ip_conntrack;
78 /* structure for original <-> reply keymap */
79 struct ip_ct_gre_keymap {
80 struct list_head list;
82 struct ip_conntrack_tuple tuple;
85 /* add new tuple->key_reply pair to keymap */
86 int ip_ct_gre_keymap_add(struct ip_conntrack *ct,
87 struct ip_conntrack_tuple *t,
88 int reply);
90 /* delete keymap entries */
91 void ip_ct_gre_keymap_destroy(struct ip_conntrack *ct);
94 /* get pointer to gre key, if present */
95 static inline __be32 *gre_key(struct gre_hdr *greh)
97 if (!greh->key)
98 return NULL;
99 if (greh->csum || greh->routing)
100 return (__be32 *) (greh+sizeof(*greh)+4);
101 return (__be32 *) (greh+sizeof(*greh));
104 /* get pointer ot gre csum, if present */
105 static inline __sum16 *gre_csum(struct gre_hdr *greh)
107 if (!greh->csum)
108 return NULL;
109 return (__sum16 *) (greh+sizeof(*greh));
112 #endif /* __KERNEL__ */
114 #endif /* _CONNTRACK_PROTO_GRE_H */