2 * connection tracking helpers.
4 * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
5 * - generalize L3 protocol dependent part.
7 * Derived from include/linux/netfiter_ipv4/ip_conntrack_helper.h
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 #include <net/netfilter/nf_conntrack_expect.h>
18 enum nf_ct_helper_flags {
19 NF_CT_HELPER_F_USERSPACE = (1 << 0),
20 NF_CT_HELPER_F_CONFIGURED = (1 << 1),
23 #define NF_CT_HELPER_NAME_LEN 16
25 struct nf_conntrack_helper {
26 struct hlist_node hnode; /* Internal use. */
28 char name[NF_CT_HELPER_NAME_LEN]; /* name of the module */
29 struct module *me; /* pointer to self */
30 const struct nf_conntrack_expect_policy *expect_policy;
32 /* length of internal data, ie. sizeof(struct nf_ct_*_master) */
35 /* Tuple of things we will help (compared against server response) */
36 struct nf_conntrack_tuple tuple;
38 /* Function to call when data passes; return verdict, or -1 to
40 int (*help)(struct sk_buff *skb,
43 enum ip_conntrack_info conntrackinfo);
45 void (*destroy)(struct nf_conn *ct);
47 int (*from_nlattr)(struct nlattr *attr, struct nf_conn *ct);
48 int (*to_nlattr)(struct sk_buff *skb, const struct nf_conn *ct);
49 unsigned int expect_class_max;
52 unsigned int queue_num; /* For user-space helpers. */
55 struct nf_conntrack_helper *__nf_conntrack_helper_find(const char *name,
56 u16 l3num, u8 protonum);
58 struct nf_conntrack_helper *nf_conntrack_helper_try_module_get(const char *name,
61 void nf_ct_helper_init(struct nf_conntrack_helper *helper,
62 u16 l3num, u16 protonum, const char *name,
63 u16 default_port, u16 spec_port, u32 id,
64 const struct nf_conntrack_expect_policy *exp_pol,
65 u32 expect_class_max, u32 data_len,
66 int (*help)(struct sk_buff *skb, unsigned int protoff,
68 enum ip_conntrack_info ctinfo),
69 int (*from_nlattr)(struct nlattr *attr,
71 struct module *module);
73 int nf_conntrack_helper_register(struct nf_conntrack_helper *);
74 void nf_conntrack_helper_unregister(struct nf_conntrack_helper *);
76 int nf_conntrack_helpers_register(struct nf_conntrack_helper *, unsigned int);
77 void nf_conntrack_helpers_unregister(struct nf_conntrack_helper *,
80 struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct,
81 struct nf_conntrack_helper *helper,
84 int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
87 void nf_ct_helper_destroy(struct nf_conn *ct);
89 static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
91 return nf_ct_ext_find(ct, NF_CT_EXT_HELPER);
94 static inline void *nfct_help_data(const struct nf_conn *ct)
96 struct nf_conn_help *help;
98 help = nf_ct_ext_find(ct, NF_CT_EXT_HELPER);
100 return (void *)help->data;
103 int nf_conntrack_helper_pernet_init(struct net *net);
104 void nf_conntrack_helper_pernet_fini(struct net *net);
106 int nf_conntrack_helper_init(void);
107 void nf_conntrack_helper_fini(void);
109 int nf_conntrack_broadcast_help(struct sk_buff *skb, unsigned int protoff,
111 enum ip_conntrack_info ctinfo,
112 unsigned int timeout);
114 struct nf_ct_helper_expectfn {
115 struct list_head head;
117 void (*expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
121 void nf_ct_helper_log(struct sk_buff *skb, const struct nf_conn *ct,
122 const char *fmt, ...);
124 void nf_ct_helper_expectfn_register(struct nf_ct_helper_expectfn *n);
125 void nf_ct_helper_expectfn_unregister(struct nf_ct_helper_expectfn *n);
126 struct nf_ct_helper_expectfn *
127 nf_ct_helper_expectfn_find_by_name(const char *name);
128 struct nf_ct_helper_expectfn *
129 nf_ct_helper_expectfn_find_by_symbol(const void *symbol);
131 extern struct hlist_head *nf_ct_helper_hash;
132 extern unsigned int nf_ct_helper_hsize;
134 #endif /*_NF_CONNTRACK_HELPER_H*/