1 #ifndef _NF_CONNTRACK_EXTEND_H
2 #define _NF_CONNTRACK_EXTEND_H
4 #include <net/netfilter/nf_conntrack.h>
15 #define NF_CT_EXT_HELPER_TYPE struct nf_conn_help
16 #define NF_CT_EXT_NAT_TYPE struct nf_conn_nat
17 #define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter
18 #define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache
19 #define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone
21 /* Extensions: optional stuff which isn't permanently in struct. */
24 u8 offset[NF_CT_EXT_NUM];
29 static inline int nf_ct_ext_exist(const struct nf_conn *ct, u8 id)
31 return (ct->ext && ct->ext->offset[id]);
34 static inline void *__nf_ct_ext_find(const struct nf_conn *ct, u8 id)
36 if (!nf_ct_ext_exist(ct, id))
39 return (void *)ct->ext + ct->ext->offset[id];
41 #define nf_ct_ext_find(ext, id) \
42 ((id##_TYPE *)__nf_ct_ext_find((ext), (id)))
44 /* Destroy all relationships */
45 extern void __nf_ct_ext_destroy(struct nf_conn *ct);
46 static inline void nf_ct_ext_destroy(struct nf_conn *ct)
49 __nf_ct_ext_destroy(ct);
52 /* Free operation. If you want to free a object referred from private area,
53 * please implement __nf_ct_ext_free() and call it.
55 static inline void nf_ct_ext_free(struct nf_conn *ct)
61 /* Add this type, returns pointer to data or NULL. */
63 __nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp);
64 #define nf_ct_ext_add(ct, id, gfp) \
65 ((id##_TYPE *)__nf_ct_ext_add((ct), (id), (gfp)))
67 #define NF_CT_EXT_F_PREALLOC 0x0001
69 struct nf_ct_ext_type {
70 /* Destroys relationships (can be NULL). */
71 void (*destroy)(struct nf_conn *ct);
72 /* Called when realloacted (can be NULL).
73 Contents has already been moved. */
74 void (*move)(void *new, void *old);
80 /* Length and min alignment. */
83 /* initial size of nf_ct_ext. */
87 int nf_ct_extend_register(struct nf_ct_ext_type *type);
88 void nf_ct_extend_unregister(struct nf_ct_ext_type *type);
89 #endif /* _NF_CONNTRACK_EXTEND_H */