V4L/DVB (9654): new email address
[linux-2.6/btrfs-unstable.git] / include / net / netfilter / nf_conntrack_extend.h
blobda8ee52613a59f202e341fb96b1d5c6c097ab37d
1 #ifndef _NF_CONNTRACK_EXTEND_H
2 #define _NF_CONNTRACK_EXTEND_H
4 #include <net/netfilter/nf_conntrack.h>
6 enum nf_ct_ext_id
8 NF_CT_EXT_HELPER,
9 NF_CT_EXT_NAT,
10 NF_CT_EXT_ACCT,
11 NF_CT_EXT_NUM,
14 #define NF_CT_EXT_HELPER_TYPE struct nf_conn_help
15 #define NF_CT_EXT_NAT_TYPE struct nf_conn_nat
16 #define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter
18 /* Extensions: optional stuff which isn't permanently in struct. */
19 struct nf_ct_ext {
20 struct rcu_head rcu;
21 u8 offset[NF_CT_EXT_NUM];
22 u8 len;
23 char data[0];
26 static inline int nf_ct_ext_exist(const struct nf_conn *ct, u8 id)
28 return (ct->ext && ct->ext->offset[id]);
31 static inline void *__nf_ct_ext_find(const struct nf_conn *ct, u8 id)
33 if (!nf_ct_ext_exist(ct, id))
34 return NULL;
36 return (void *)ct->ext + ct->ext->offset[id];
38 #define nf_ct_ext_find(ext, id) \
39 ((id##_TYPE *)__nf_ct_ext_find((ext), (id)))
41 /* Destroy all relationships */
42 extern void __nf_ct_ext_destroy(struct nf_conn *ct);
43 static inline void nf_ct_ext_destroy(struct nf_conn *ct)
45 if (ct->ext)
46 __nf_ct_ext_destroy(ct);
49 /* Free operation. If you want to free a object referred from private area,
50 * please implement __nf_ct_ext_free() and call it.
52 static inline void nf_ct_ext_free(struct nf_conn *ct)
54 if (ct->ext)
55 kfree(ct->ext);
58 /* Add this type, returns pointer to data or NULL. */
59 void *
60 __nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp);
61 #define nf_ct_ext_add(ct, id, gfp) \
62 ((id##_TYPE *)__nf_ct_ext_add((ct), (id), (gfp)))
64 #define NF_CT_EXT_F_PREALLOC 0x0001
66 struct nf_ct_ext_type
68 /* Destroys relationships (can be NULL). */
69 void (*destroy)(struct nf_conn *ct);
70 /* Called when realloacted (can be NULL).
71 Contents has already been moved. */
72 void (*move)(void *new, void *old);
74 enum nf_ct_ext_id id;
76 unsigned int flags;
78 /* Length and min alignment. */
79 u8 len;
80 u8 align;
81 /* initial size of nf_ct_ext. */
82 u8 alloc_size;
85 int nf_ct_extend_register(struct nf_ct_ext_type *type);
86 void nf_ct_extend_unregister(struct nf_ct_ext_type *type);
87 #endif /* _NF_CONNTRACK_EXTEND_H */