drm/radeon/kms: move panel mode setup into encoder mode set
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / net / netfilter / nf_conntrack_extend.h
blob2dcf31703acba7a18b9f167866390827054f9d98
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 #if defined(CONFIG_NF_NAT) || defined(CONFIG_NF_NAT_MODULE)
11 NF_CT_EXT_NAT,
12 #endif
13 NF_CT_EXT_ACCT,
14 #ifdef CONFIG_NF_CONNTRACK_EVENTS
15 NF_CT_EXT_ECACHE,
16 #endif
17 #ifdef CONFIG_NF_CONNTRACK_ZONES
18 NF_CT_EXT_ZONE,
19 #endif
20 #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
21 NF_CT_EXT_TSTAMP,
22 #endif
23 NF_CT_EXT_NUM,
26 #define NF_CT_EXT_HELPER_TYPE struct nf_conn_help
27 #define NF_CT_EXT_NAT_TYPE struct nf_conn_nat
28 #define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter
29 #define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache
30 #define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone
31 #define NF_CT_EXT_TSTAMP_TYPE struct nf_conn_tstamp
33 /* Extensions: optional stuff which isn't permanently in struct. */
34 struct nf_ct_ext {
35 struct rcu_head rcu;
36 u8 offset[NF_CT_EXT_NUM];
37 u8 len;
38 char data[0];
41 static inline bool __nf_ct_ext_exist(const struct nf_ct_ext *ext, u8 id)
43 return !!ext->offset[id];
46 static inline bool nf_ct_ext_exist(const struct nf_conn *ct, u8 id)
48 return (ct->ext && __nf_ct_ext_exist(ct->ext, id));
51 static inline void *__nf_ct_ext_find(const struct nf_conn *ct, u8 id)
53 if (!nf_ct_ext_exist(ct, id))
54 return NULL;
56 return (void *)ct->ext + ct->ext->offset[id];
58 #define nf_ct_ext_find(ext, id) \
59 ((id##_TYPE *)__nf_ct_ext_find((ext), (id)))
61 /* Destroy all relationships */
62 extern void __nf_ct_ext_destroy(struct nf_conn *ct);
63 static inline void nf_ct_ext_destroy(struct nf_conn *ct)
65 if (ct->ext)
66 __nf_ct_ext_destroy(ct);
69 /* Free operation. If you want to free a object referred from private area,
70 * please implement __nf_ct_ext_free() and call it.
72 static inline void nf_ct_ext_free(struct nf_conn *ct)
74 if (ct->ext)
75 kfree(ct->ext);
78 /* Add this type, returns pointer to data or NULL. */
79 void *
80 __nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp);
81 #define nf_ct_ext_add(ct, id, gfp) \
82 ((id##_TYPE *)__nf_ct_ext_add((ct), (id), (gfp)))
84 #define NF_CT_EXT_F_PREALLOC 0x0001
86 struct nf_ct_ext_type {
87 /* Destroys relationships (can be NULL). */
88 void (*destroy)(struct nf_conn *ct);
89 /* Called when realloacted (can be NULL).
90 Contents has already been moved. */
91 void (*move)(void *new, void *old);
93 enum nf_ct_ext_id id;
95 unsigned int flags;
97 /* Length and min alignment. */
98 u8 len;
99 u8 align;
100 /* initial size of nf_ct_ext. */
101 u8 alloc_size;
104 int nf_ct_extend_register(struct nf_ct_ext_type *type);
105 void nf_ct_extend_unregister(struct nf_ct_ext_type *type);
106 #endif /* _NF_CONNTRACK_EXTEND_H */