nf_conntrack_helper.h 2.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/*
 * connection tracking helpers.
 *
 * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
 *	- generalize L3 protocol dependent part.
 *
 * Derived from include/linux/netfiter_ipv4/ip_conntrack_helper.h
 */

#ifndef _NF_CONNTRACK_HELPER_H
#define _NF_CONNTRACK_HELPER_H
#include <net/netfilter/nf_conntrack.h>
13
#include <net/netfilter/nf_conntrack_extend.h>
14 15 16

struct module;

17 18
#define NF_CT_HELPER_NAME_LEN	16

E
Eric Dumazet 已提交
19
struct nf_conntrack_helper {
20
	struct hlist_node hnode;	/* Internal use. */
21 22 23

	const char *name;		/* name of the module */
	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 30
	/* Function to call when data passes; return verdict, or -1 to
           invalidate. */
31
	int (*help)(struct sk_buff *skb,
32 33 34
		    unsigned int protoff,
		    struct nf_conn *ct,
		    enum ip_conntrack_info conntrackinfo);
35

36 37
	void (*destroy)(struct nf_conn *ct);

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 46 47
extern struct nf_conntrack_helper *
nf_conntrack_helper_try_module_get(const char *name, u16 l3num, u8 protonum);

48 49 50
extern int nf_conntrack_helper_register(struct nf_conntrack_helper *);
extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *);

51 52
extern struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp);

53 54
extern int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
				     gfp_t flags);
55

56 57
extern void nf_ct_helper_destroy(struct nf_conn *ct);

58 59 60 61
static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
{
	return nf_ct_ext_find(ct, NF_CT_EXT_HELPER);
}
62 63 64 65

extern int nf_conntrack_helper_init(void);
extern void nf_conntrack_helper_fini(void);

66 67 68 69 70 71
extern int nf_conntrack_broadcast_help(struct sk_buff *skb,
				       unsigned int protoff,
				       struct nf_conn *ct,
				       enum ip_conntrack_info ctinfo,
				       unsigned int timeout);

72 73 74 75 76 77 78 79 80 81 82 83 84
struct nf_ct_helper_expectfn {
	struct list_head head;
	const char *name;
	void (*expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
};

void nf_ct_helper_expectfn_register(struct nf_ct_helper_expectfn *n);
void nf_ct_helper_expectfn_unregister(struct nf_ct_helper_expectfn *n);
struct nf_ct_helper_expectfn *
nf_ct_helper_expectfn_find_by_name(const char *name);
struct nf_ct_helper_expectfn *
nf_ct_helper_expectfn_find_by_symbol(const void *symbol);

85
#endif /*_NF_CONNTRACK_HELPER_H*/