1 #ifndef _NF_CONNTRACK_EXTEND_H
2 #define _NF_CONNTRACK_EXTEND_H
4 #include <net/netfilter/nf_conntrack.h>
12 #define NF_CT_EXT_HELPER_TYPE struct nf_conn_help
14 /* Extensions: optional stuff which isn't permanently in struct. */
16 u8 offset[NF_CT_EXT_NUM];
22 static inline int nf_ct_ext_exist(const struct nf_conn *ct, u8 id)
24 return (ct->ext && ct->ext->offset[id]);
27 static inline void *__nf_ct_ext_find(const struct nf_conn *ct, u8 id)
29 if (!nf_ct_ext_exist(ct, id))
32 return (void *)ct->ext + ct->ext->offset[id];
34 #define nf_ct_ext_find(ext, id) \
35 ((id##_TYPE *)__nf_ct_ext_find((ext), (id)))
37 /* Destroy all relationships */
38 extern void __nf_ct_ext_destroy(struct nf_conn *ct);
39 static inline void nf_ct_ext_destroy(struct nf_conn *ct)
42 __nf_ct_ext_destroy(ct);
45 /* Free operation. If you want to free a object referred from private area,
46 * please implement __nf_ct_ext_free() and call it.
48 static inline void nf_ct_ext_free(struct nf_conn *ct)
54 /* Add this type, returns pointer to data or NULL. */
56 __nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp);
57 #define nf_ct_ext_add(ct, id, gfp) \
58 ((id##_TYPE *)__nf_ct_ext_add((ct), (id), (gfp)))
60 #define NF_CT_EXT_F_PREALLOC 0x0001
64 /* Destroys relationships (can be NULL). */
65 void (*destroy)(struct nf_conn *ct);
66 /* Called when realloacted (can be NULL).
67 Contents has already been moved. */
68 void (*move)(struct nf_conn *ct, void *old);
74 /* Length and min alignment. */
77 /* initial size of nf_ct_ext. */
81 int nf_ct_extend_register(struct nf_ct_ext_type *type);
82 void nf_ct_extend_unregister(struct nf_ct_ext_type *type);
83 #endif /* _NF_CONNTRACK_EXTEND_H */