1 #ifndef _NF_CONNTRACK_EXTEND_H
2 #define _NF_CONNTRACK_EXTEND_H
4 #include <net/netfilter/nf_conntrack.h>
11 /* Extensions: optional stuff which isn't permanently in struct. */
13 u8 offset[NF_CT_EXT_NUM];
19 static inline int nf_ct_ext_exist(const struct nf_conn *ct, u8 id)
21 return (ct->ext && ct->ext->offset[id]);
24 static inline void *__nf_ct_ext_find(const struct nf_conn *ct, u8 id)
26 if (!nf_ct_ext_exist(ct, id))
29 return (void *)ct->ext + ct->ext->offset[id];
31 #define nf_ct_ext_find(ext, id) \
32 ((id##_TYPE *)__nf_ct_ext_find((ext), (id)))
34 /* Destroy all relationships */
35 extern void __nf_ct_ext_destroy(struct nf_conn *ct);
36 static inline void nf_ct_ext_destroy(struct nf_conn *ct)
39 __nf_ct_ext_destroy(ct);
42 /* Free operation. If you want to free a object referred from private area,
43 * please implement __nf_ct_ext_free() and call it.
45 static inline void nf_ct_ext_free(struct nf_conn *ct)
51 /* Add this type, returns pointer to data or NULL. */
53 __nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp);
54 #define nf_ct_ext_add(ct, id, gfp) \
55 ((id##_TYPE *)__nf_ct_ext_add((ct), (id), (gfp)))
57 #define NF_CT_EXT_F_PREALLOC 0x0001
61 /* Destroys relationships (can be NULL). */
62 void (*destroy)(struct nf_conn *ct);
63 /* Called when realloacted (can be NULL).
64 Contents has already been moved. */
65 void (*move)(struct nf_conn *ct, void *old);
71 /* Length and min alignment. */
74 /* initial size of nf_ct_ext. */
78 int nf_ct_extend_register(struct nf_ct_ext_type *type);
79 void nf_ct_extend_unregister(struct nf_ct_ext_type *type);
80 #endif /* _NF_CONNTRACK_EXTEND_H */