[NETFILTER]: Add NAT support for nf_conntrack
[pandora-kernel.git] / include / net / netfilter / nf_conntrack.h
index b4beb8c..9948af0 100644 (file)
@@ -264,18 +264,45 @@ nf_conntrack_unregister_cache(u_int32_t features);
 
 /* valid combinations:
  * basic: nf_conn, nf_conn .. nf_conn_help
- * nat: nf_conn .. nf_conn_nat, nf_conn .. nf_conn_nat, nf_conn help
+ * nat: nf_conn .. nf_conn_nat, nf_conn .. nf_conn_nat .. nf_conn help
  */
+#ifdef CONFIG_NF_NAT_NEEDED
+static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct)
+{
+       unsigned int offset = sizeof(struct nf_conn);
+
+       if (!(ct->features & NF_CT_F_NAT))
+               return NULL;
+
+       offset = ALIGN(offset, __alignof__(struct nf_conn_nat));
+       return (struct nf_conn_nat *) ((void *)ct + offset);
+}
+
 static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
 {
        unsigned int offset = sizeof(struct nf_conn);
 
        if (!(ct->features & NF_CT_F_HELP))
                return NULL;
+       if (ct->features & NF_CT_F_NAT) {
+               offset = ALIGN(offset, __alignof__(struct nf_conn_nat));
+               offset += sizeof(struct nf_conn_nat);
+       }
 
        offset = ALIGN(offset, __alignof__(struct nf_conn_help));
        return (struct nf_conn_help *) ((void *)ct + offset);
 }
+#else /* No NAT */
+static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
+{
+       unsigned int offset = sizeof(struct nf_conn);
+
+       if (!(ct->features & NF_CT_F_HELP))
+               return NULL;
 
+       offset = ALIGN(offset, __alignof__(struct nf_conn_help));
+       return (struct nf_conn_help *) ((void *)ct + offset);
+}
+#endif /* CONFIG_NF_NAT_NEEDED */
 #endif /* __KERNEL__ */
 #endif /* _NF_CONNTRACK_H */