netfilter: ctnetlink: only assign helpers for matching protocols
[safe/jmp/linux-2.6] / include / net / netfilter / nf_conntrack_helper.h
1 /*
2  * connection tracking helpers.
3  *
4  * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
5  *      - generalize L3 protocol dependent part.
6  *
7  * Derived from include/linux/netfiter_ipv4/ip_conntrack_helper.h
8  */
9
10 #ifndef _NF_CONNTRACK_HELPER_H
11 #define _NF_CONNTRACK_HELPER_H
12 #include <net/netfilter/nf_conntrack.h>
13 #include <net/netfilter/nf_conntrack_extend.h>
14
15 struct module;
16
17 #define NF_CT_HELPER_NAME_LEN   16
18
19 struct nf_conntrack_helper {
20         struct hlist_node hnode;        /* Internal use. */
21
22         const char *name;               /* name of the module */
23         struct module *me;              /* pointer to self */
24         const struct nf_conntrack_expect_policy *expect_policy;
25
26         /* Tuple of things we will help (compared against server response) */
27         struct nf_conntrack_tuple tuple;
28
29         /* Function to call when data passes; return verdict, or -1 to
30            invalidate. */
31         int (*help)(struct sk_buff *skb,
32                     unsigned int protoff,
33                     struct nf_conn *ct,
34                     enum ip_conntrack_info conntrackinfo);
35
36         void (*destroy)(struct nf_conn *ct);
37
38         int (*to_nlattr)(struct sk_buff *skb, const struct nf_conn *ct);
39         unsigned int expect_class_max;
40 };
41
42 extern struct nf_conntrack_helper *
43 __nf_conntrack_helper_find(const char *name, u16 l3num, u8 protonum);
44
45 extern int nf_conntrack_helper_register(struct nf_conntrack_helper *);
46 extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *);
47
48 extern struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp);
49
50 extern int __nf_ct_try_assign_helper(struct nf_conn *ct, gfp_t flags);
51
52 extern void nf_ct_helper_destroy(struct nf_conn *ct);
53
54 static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
55 {
56         return nf_ct_ext_find(ct, NF_CT_EXT_HELPER);
57 }
58
59 extern int nf_conntrack_helper_init(void);
60 extern void nf_conntrack_helper_fini(void);
61
62 #endif /*_NF_CONNTRACK_HELPER_H*/