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
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 */
29 #if defined(__LITTLE_ENDIAN_BITFIELD)
39 #elif defined(__BIG_ENDIAN_BITFIELD)
50 #error "Adjust your <asm/byteorder.h> defines"
55 /* modified GRE header for PPTP */
57 __u8 flags; /* bitfield */
58 __u8 version; /* should be GRE_VERSION_PPTP */
59 __u16 protocol; /* should be GRE_PROTOCOL_PPTP */
60 __u16 payload_len; /* size of ppp payload, not inc. gre header */
61 __u16 call_id; /* peer's call_id for this session */
62 __u32 seq; /* sequence number. Present if S==1 */
63 __u32 ack; /* seq number of highest packet recieved by */
64 /* sender in this session */
68 /* this is part of ip_conntrack */
70 unsigned int stream_timeout;
74 /* this is part of ip_conntrack_expect */
75 struct ip_ct_gre_expect {
76 struct ip_ct_gre_keymap *keymap_orig, *keymap_reply;
80 struct ip_conntrack_expect;
82 /* structure for original <-> reply keymap */
83 struct ip_ct_gre_keymap {
84 struct list_head list;
86 struct ip_conntrack_tuple tuple;
90 /* add new tuple->key_reply pair to keymap */
91 int ip_ct_gre_keymap_add(struct ip_conntrack_expect *exp,
92 struct ip_conntrack_tuple *t,
95 /* change an existing keymap entry */
96 void ip_ct_gre_keymap_change(struct ip_ct_gre_keymap *km,
97 struct ip_conntrack_tuple *t);
99 /* delete keymap entries */
100 void ip_ct_gre_keymap_destroy(struct ip_conntrack_expect *exp);
103 /* get pointer to gre key, if present */
104 static inline u_int32_t *gre_key(struct gre_hdr *greh)
108 if (greh->csum || greh->routing)
109 return (u_int32_t *) (greh+sizeof(*greh)+4);
110 return (u_int32_t *) (greh+sizeof(*greh));
113 /* get pointer ot gre csum, if present */
114 static inline u_int16_t *gre_csum(struct gre_hdr *greh)
118 return (u_int16_t *) (greh+sizeof(*greh));
121 #endif /* __KERNEL__ */
123 #endif /* _CONNTRACK_PROTO_GRE_H */