MIPS: Use uasm_i_ds{r,l}l_safe() instead of uasm_i_ds{r,l}l() in tlbex.c
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / net / netfilter / nf_conntrack_extend.h
blob32d15bd6efa3c573030e899bb979d98dcc811ee9
1 #ifndef _NF_CONNTRACK_EXTEND_H
2 #define _NF_CONNTRACK_EXTEND_H
4 #include <linux/slab.h>
6 #include <net/netfilter/nf_conntrack.h>
8 enum nf_ct_ext_id {
9 NF_CT_EXT_HELPER,
10 NF_CT_EXT_NAT,
11 NF_CT_EXT_ACCT,
12 NF_CT_EXT_ECACHE,
13 NF_CT_EXT_ZONE,
14 NF_CT_EXT_NUM,
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. */
24 struct nf_ct_ext {
25 struct rcu_head rcu;
26 u8 offset[NF_CT_EXT_NUM];
27 u8 len;
28 char data[0];
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))
39 return NULL;
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)
50 if (ct->ext)
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)
59 if (ct->ext)
60 kfree(ct->ext);
63 /* Add this type, returns pointer to data or NULL. */
64 void *
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);
78 enum nf_ct_ext_id id;
80 unsigned int flags;
82 /* Length and min alignment. */
83 u8 len;
84 u8 align;
85 /* initial size of nf_ct_ext. */
86 u8 alloc_size;
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 */