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