This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / net / netfilter / nf_conntrack_l3proto.h
1 /*
2  * Copyright (C)2003,2004 USAGI/WIDE Project
3  *
4  * Header for use in defining a given L3 protocol for connection tracking.
5  *
6  * Author:
7  *      Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
8  *
9  * Derived from include/netfilter_ipv4/ip_conntrack_protocol.h
10  */
11
12 #ifndef _NF_CONNTRACK_L3PROTO_H
13 #define _NF_CONNTRACK_L3PROTO_H
14 #include <linux/seq_file.h>
15 #include <net/netfilter/nf_conntrack.h>
16
17 struct nfattr;
18
19 struct nf_conntrack_l3proto
20 {
21         /* Next pointer. */
22         struct list_head list;
23
24         /* L3 Protocol Family number. ex) PF_INET */
25         u_int16_t l3proto;
26
27         /* Protocol name */
28         const char *name;
29
30         /*
31          * Try to fill in the third arg: nhoff is offset of l3 proto
32          * hdr.  Return true if possible.
33          */
34         int (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int nhoff,
35                             struct nf_conntrack_tuple *tuple);
36
37         /*
38          * Invert the per-proto part of the tuple: ie. turn xmit into reply.
39          * Some packets can't be inverted: return 0 in that case.
40          */
41         int (*invert_tuple)(struct nf_conntrack_tuple *inverse,
42                             const struct nf_conntrack_tuple *orig);
43
44         /* Print out the per-protocol part of the tuple. */
45         int (*print_tuple)(struct seq_file *s,
46                            const struct nf_conntrack_tuple *);
47
48         /* Print out the private part of the conntrack. */
49         int (*print_conntrack)(struct seq_file *s, const struct nf_conn *);
50
51         /* Returns verdict for packet, or -1 for invalid. */
52         int (*packet)(struct nf_conn *conntrack,
53                       const struct sk_buff *skb,
54                       enum ip_conntrack_info ctinfo);
55
56         /*
57          * Called when a new connection for this protocol found;
58          * returns TRUE if it's OK.  If so, packet() called next.
59          */
60         int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb);
61
62         /* Called when a conntrack entry is destroyed */
63         void (*destroy)(struct nf_conn *conntrack);
64
65         /*
66          * Called before tracking. 
67          *      *dataoff: offset of protocol header (TCP, UDP,...) in *pskb
68          *      *protonum: protocol number
69          */
70         int (*prepare)(struct sk_buff **pskb, unsigned int hooknum,
71                        unsigned int *dataoff, u_int8_t *protonum);
72
73         u_int32_t (*get_features)(const struct nf_conntrack_tuple *tuple);
74
75         int (*tuple_to_nfattr)(struct sk_buff *skb,
76                                const struct nf_conntrack_tuple *t);
77
78         int (*nfattr_to_tuple)(struct nfattr *tb[],
79                                struct nf_conntrack_tuple *t);
80
81         /* Module (if any) which this is connected to. */
82         struct module *me;
83 };
84
85 extern struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX];
86
87 /* Protocol registration. */
88 extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto);
89 extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto);
90
91 extern struct nf_conntrack_l3proto *
92 nf_ct_l3proto_find_get(u_int16_t l3proto);
93
94 extern void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p);
95
96 /* Existing built-in protocols */
97 extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4;
98 extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6;
99 extern struct nf_conntrack_l3proto nf_conntrack_generic_l3proto;
100
101 static inline struct nf_conntrack_l3proto *
102 __nf_ct_l3proto_find(u_int16_t l3proto)
103 {
104         if (unlikely(l3proto >= AF_MAX))
105                 return &nf_conntrack_generic_l3proto;
106         return nf_ct_l3protos[l3proto];
107 }
108
109 #endif /*_NF_CONNTRACK_L3PROTO_H*/