[GFS2] test for IS_ERR rather than 0
[linux-2.6/btrfs-unstable.git] / include / net / netfilter / nf_conntrack_extend.h
blobf736e842977f07ce8469bf832fcf2905af36ded1
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_NUM,
13 #define NF_CT_EXT_HELPER_TYPE struct nf_conn_help
14 #define NF_CT_EXT_NAT_TYPE struct nf_conn_nat
16 /* Extensions: optional stuff which isn't permanently in struct. */
17 struct nf_ct_ext {
18 u8 offset[NF_CT_EXT_NUM];
19 u8 len;
20 char data[0];
23 static inline int nf_ct_ext_exist(const struct nf_conn *ct, u8 id)
25 return (ct->ext && ct->ext->offset[id]);
28 static inline void *__nf_ct_ext_find(const struct nf_conn *ct, u8 id)
30 if (!nf_ct_ext_exist(ct, id))
31 return NULL;
33 return (void *)ct->ext + ct->ext->offset[id];
35 #define nf_ct_ext_find(ext, id) \
36 ((id##_TYPE *)__nf_ct_ext_find((ext), (id)))
38 /* Destroy all relationships */
39 extern void __nf_ct_ext_destroy(struct nf_conn *ct);
40 static inline void nf_ct_ext_destroy(struct nf_conn *ct)
42 if (ct->ext)
43 __nf_ct_ext_destroy(ct);
46 /* Free operation. If you want to free a object referred from private area,
47 * please implement __nf_ct_ext_free() and call it.
49 static inline void nf_ct_ext_free(struct nf_conn *ct)
51 if (ct->ext)
52 kfree(ct->ext);
55 /* Add this type, returns pointer to data or NULL. */
56 void *
57 __nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp);
58 #define nf_ct_ext_add(ct, id, gfp) \
59 ((id##_TYPE *)__nf_ct_ext_add((ct), (id), (gfp)))
61 #define NF_CT_EXT_F_PREALLOC 0x0001
63 struct nf_ct_ext_type
65 /* Destroys relationships (can be NULL). */
66 void (*destroy)(struct nf_conn *ct);
67 /* Called when realloacted (can be NULL).
68 Contents has already been moved. */
69 void (*move)(void *new, void *old);
71 enum nf_ct_ext_id id;
73 unsigned int flags;
75 /* Length and min alignment. */
76 u8 len;
77 u8 align;
78 /* initial size of nf_ct_ext. */
79 u8 alloc_size;
82 int nf_ct_extend_register(struct nf_ct_ext_type *type);
83 void nf_ct_extend_unregister(struct nf_ct_ext_type *type);
84 #endif /* _NF_CONNTRACK_EXTEND_H */