[NETFILTER]: ip_tables: fix compat related crash
[sfrench/cifs-2.6.git] / include / linux / netfilter_ipv4 / ip_tables.h
index 4f06dad0bde90d5f6de514adb2d2825e3c4ad861..e992cd6b28f57798e17d4e3c7f7aa9c81554da01 100644 (file)
@@ -28,7 +28,7 @@
 #include <linux/netfilter/x_tables.h>
 
 #define IPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
-#define IPT_TABLE_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
+#define IPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
 #define ipt_match xt_match
 #define ipt_target xt_target
 #define ipt_table xt_table
@@ -264,6 +264,26 @@ ipt_get_target(struct ipt_entry *e)
        __ret;                                                  \
 })
 
+/* fn returns 0 to continue iteration */
+#define IPT_ENTRY_ITERATE_CONTINUE(entries, size, n, fn, args...) \
+({                                                             \
+       unsigned int __i, __n;                                  \
+       int __ret = 0;                                          \
+       struct ipt_entry *__entry;                              \
+                                                               \
+       for (__i = 0, __n = 0; __i < (size);                    \
+            __i += __entry->next_offset, __n++) {              \
+               __entry = (void *)(entries) + __i;              \
+               if (__n < n)                                    \
+                       continue;                               \
+                                                               \
+               __ret = fn(__entry , ## args);                  \
+               if (__ret != 0)                                 \
+                       break;                                  \
+       }                                                       \
+       __ret;                                                  \
+})
+
 /*
  *     Main firewall chains definitions and global var's definitions.
  */
@@ -272,25 +292,9 @@ ipt_get_target(struct ipt_entry *e)
 #include <linux/init.h>
 extern void ipt_init(void) __init;
 
-#define ipt_register_target(tgt)       \
-({     (tgt)->family = AF_INET;        \
-       xt_register_target(tgt); })
-#define ipt_unregister_target(tgt) xt_unregister_target(tgt)
-
-#define ipt_register_match(mtch)       \
-({     (mtch)->family = AF_INET;       \
-       xt_register_match(mtch); })
-#define ipt_unregister_match(mtch) xt_unregister_match(mtch)
-
-//#define ipt_register_table(tbl, repl) xt_register_table(AF_INET, tbl, repl)
-//#define ipt_unregister_table(tbl) xt_unregister_table(AF_INET, tbl)
-
-extern int ipt_register_table(struct ipt_table *table,
+extern int ipt_register_table(struct xt_table *table,
                              const struct ipt_replace *repl);
-extern void ipt_unregister_table(struct ipt_table *table);
-
-/* net/sched/ipt.c: Gimme access to your targets!  Gets target->me. */
-extern struct ipt_target *ipt_find_target(const char *name, u8 revision);
+extern void ipt_unregister_table(struct xt_table *table);
 
 /* Standard entry. */
 struct ipt_standard
@@ -311,11 +315,33 @@ struct ipt_error
        struct ipt_error_target target;
 };
 
+#define IPT_ENTRY_INIT(__size)                                                \
+{                                                                             \
+       .target_offset  = sizeof(struct ipt_entry),                            \
+       .next_offset    = (__size),                                            \
+}
+
+#define IPT_STANDARD_INIT(__verdict)                                          \
+{                                                                             \
+       .entry          = IPT_ENTRY_INIT(sizeof(struct ipt_standard)),         \
+       .target         = XT_TARGET_INIT(IPT_STANDARD_TARGET,                  \
+                                        sizeof(struct xt_standard_target)),   \
+       .target.verdict = -(__verdict) - 1,                                    \
+}
+
+#define IPT_ERROR_INIT                                                        \
+{                                                                             \
+       .entry          = IPT_ENTRY_INIT(sizeof(struct ipt_error)),            \
+       .target         = XT_TARGET_INIT(IPT_ERROR_TARGET,                     \
+                                        sizeof(struct ipt_error_target)),     \
+       .target.errorname = "ERROR",                                           \
+}
+
 extern unsigned int ipt_do_table(struct sk_buff **pskb,
                                 unsigned int hook,
                                 const struct net_device *in,
                                 const struct net_device *out,
-                                struct ipt_table *table);
+                                struct xt_table *table);
 
 #define IPT_ALIGN(s) XT_ALIGN(s)