PCI: Hotplug core: remove 'name'
[safe/jmp/linux-2.6] / include / linux / netfilter / x_tables.h
index 03e6ce9..be41b60 100644 (file)
@@ -126,10 +126,145 @@ struct xt_counters_info
 
 #define XT_INV_PROTO           0x40    /* Invert the sense of PROTO. */
 
+/* fn returns 0 to continue iteration */
+#define XT_MATCH_ITERATE(type, e, fn, args...)                 \
+({                                                             \
+       unsigned int __i;                                       \
+       int __ret = 0;                                          \
+       struct xt_entry_match *__m;                             \
+                                                               \
+       for (__i = sizeof(type);                                \
+            __i < (e)->target_offset;                          \
+            __i += __m->u.match_size) {                        \
+               __m = (void *)e + __i;                          \
+                                                               \
+               __ret = fn(__m , ## args);                      \
+               if (__ret != 0)                                 \
+                       break;                                  \
+       }                                                       \
+       __ret;                                                  \
+})
+
+/* fn returns 0 to continue iteration */
+#define XT_ENTRY_ITERATE_CONTINUE(type, entries, size, n, fn, args...) \
+({                                                             \
+       unsigned int __i, __n;                                  \
+       int __ret = 0;                                          \
+       type *__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;                                                  \
+})
+
+/* fn returns 0 to continue iteration */
+#define XT_ENTRY_ITERATE(type, entries, size, fn, args...) \
+       XT_ENTRY_ITERATE_CONTINUE(type, entries, size, 0, fn, args)
+
 #ifdef __KERNEL__
 
 #include <linux/netdevice.h>
 
+/**
+ * struct xt_match_param - parameters for match extensions' match functions
+ *
+ * @in:                input netdevice
+ * @out:       output netdevice
+ * @match:     struct xt_match through which this function was invoked
+ * @matchinfo: per-match data
+ * @fragoff:   packet is a fragment, this is the data offset
+ * @thoff:     position of transport header relative to skb->data
+ * @hotdrop:   drop packet if we had inspection problems
+ * @family:    Actual NFPROTO_* through which the function is invoked
+ *             (helpful when match->family == NFPROTO_UNSPEC)
+ */
+struct xt_match_param {
+       const struct net_device *in, *out;
+       const struct xt_match *match;
+       const void *matchinfo;
+       int fragoff;
+       unsigned int thoff;
+       bool *hotdrop;
+       u_int8_t family;
+};
+
+/**
+ * struct xt_mtchk_param - parameters for match extensions'
+ * checkentry functions
+ *
+ * @table:     table the rule is tried to be inserted into
+ * @entryinfo: the family-specific rule data
+ *             (struct ipt_ip, ip6t_ip, ebt_entry)
+ * @match:     struct xt_match through which this function was invoked
+ * @matchinfo: per-match data
+ * @hook_mask: via which hooks the new rule is reachable
+ */
+struct xt_mtchk_param {
+       const char *table;
+       const void *entryinfo;
+       const struct xt_match *match;
+       void *matchinfo;
+       unsigned int hook_mask;
+       u_int8_t family;
+};
+
+/* Match destructor parameters */
+struct xt_mtdtor_param {
+       const struct xt_match *match;
+       void *matchinfo;
+       u_int8_t family;
+};
+
+/**
+ * struct xt_target_param - parameters for target extensions' target functions
+ *
+ * @hooknum:   hook through which this target was invoked
+ * @target:    struct xt_target through which this function was invoked
+ * @targinfo:  per-target data
+ *
+ * Other fields see above.
+ */
+struct xt_target_param {
+       const struct net_device *in, *out;
+       unsigned int hooknum;
+       const struct xt_target *target;
+       const void *targinfo;
+       u_int8_t family;
+};
+
+/**
+ * struct xt_tgchk_param - parameters for target extensions'
+ * checkentry functions
+ *
+ * @entryinfo: the family-specific rule data
+ *             (struct ipt_entry, ip6t_entry, arpt_entry, ebt_entry)
+ *
+ * Other fields see above.
+ */
+struct xt_tgchk_param {
+       const char *table;
+       void *entryinfo;
+       const struct xt_target *target;
+       void *targinfo;
+       unsigned int hook_mask;
+       u_int8_t family;
+};
+
+/* Target destructor parameters */
+struct xt_tgdtor_param {
+       const struct xt_target *target;
+       void *targinfo;
+       u_int8_t family;
+};
+
 struct xt_match
 {
        struct list_head list;
@@ -142,24 +277,13 @@ struct xt_match
           non-linear skb, using skb_header_pointer and
           skb_ip_make_writable. */
        bool (*match)(const struct sk_buff *skb,
-                     const struct net_device *in,
-                     const struct net_device *out,
-                     const struct xt_match *match,
-                     const void *matchinfo,
-                     int offset,
-                     unsigned int protoff,
-                     bool *hotdrop);
+                     const struct xt_match_param *);
 
        /* Called when user tries to insert an entry of this type. */
-       /* Should return true or false. */
-       bool (*checkentry)(const char *tablename,
-                          const void *ip,
-                          const struct xt_match *match,
-                          void *matchinfo,
-                          unsigned int hook_mask);
+       bool (*checkentry)(const struct xt_mtchk_param *);
 
        /* Called when entry of this type deleted. */
-       void (*destroy)(const struct xt_match *match, void *matchinfo);
+       void (*destroy)(const struct xt_mtdtor_param *);
 
        /* Called when userspace align differs from kernel space one */
        void (*compat_from_user)(void *dst, void *src);
@@ -171,7 +295,7 @@ struct xt_match
        /* Free to use by each match */
        unsigned long data;
 
-       char *table;
+       const char *table;
        unsigned int matchsize;
        unsigned int compatsize;
        unsigned int hooks;
@@ -192,24 +316,16 @@ struct xt_target
           must now handle non-linear skbs, using skb_copy_bits and
           skb_ip_make_writable. */
        unsigned int (*target)(struct sk_buff *skb,
-                              const struct net_device *in,
-                              const struct net_device *out,
-                              unsigned int hooknum,
-                              const struct xt_target *target,
-                              const void *targinfo);
+                              const struct xt_target_param *);
 
        /* Called when user tries to insert an entry of this type:
            hook_mask is a bitmask of hooks from which it can be
            called. */
        /* Should return true or false. */
-       bool (*checkentry)(const char *tablename,
-                          const void *entry,
-                          const struct xt_target *target,
-                          void *targinfo,
-                          unsigned int hook_mask);
+       bool (*checkentry)(const struct xt_tgchk_param *);
 
        /* Called when entry of this type deleted. */
-       void (*destroy)(const struct xt_target *target, void *targinfo);
+       void (*destroy)(const struct xt_tgdtor_param *);
 
        /* Called when userspace align differs from kernel space one */
        void (*compat_from_user)(void *dst, void *src);
@@ -218,7 +334,7 @@ struct xt_target
        /* Set this to THIS_MODULE if you are a module, otherwise NULL */
        struct module *me;
 
-       char *table;
+       const char *table;
        unsigned int targetsize;
        unsigned int compatsize;
        unsigned int hooks;
@@ -234,7 +350,7 @@ struct xt_table
        struct list_head list;
 
        /* A unique name... */
-       char name[XT_TABLE_MAXNAMELEN];
+       const char name[XT_TABLE_MAXNAMELEN];
 
        /* What hooks you will enter on */
        unsigned int valid_hooks;
@@ -249,7 +365,7 @@ struct xt_table
        /* Set this to THIS_MODULE if you are a module, otherwise NULL */
        struct module *me;
 
-       int af;         /* address/protocol family */
+       u_int8_t af;            /* address/protocol family */
 };
 
 #include <linux/netfilter_ipv4.h>
@@ -265,13 +381,16 @@ struct xt_table_info
        unsigned int initial_entries;
 
        /* Entry points and underflows */
-       unsigned int hook_entry[NF_IP_NUMHOOKS];
-       unsigned int underflow[NF_IP_NUMHOOKS];
+       unsigned int hook_entry[NF_INET_NUMHOOKS];
+       unsigned int underflow[NF_INET_NUMHOOKS];
 
        /* ipt_entry tables: one per CPU */
-       char *entries[NR_CPUS];
+       /* Note : this field MUST be the last one, see XT_TABLE_INFO_SZ */
+       char *entries[1];
 };
 
+#define XT_TABLE_INFO_SZ (offsetof(struct xt_table_info, entries) \
+                         + nr_cpu_ids * sizeof(char *))
 extern int xt_register_target(struct xt_target *target);
 extern void xt_unregister_target(struct xt_target *target);
 extern int xt_register_targets(struct xt_target *target, unsigned int n);
@@ -282,16 +401,15 @@ extern void xt_unregister_match(struct xt_match *target);
 extern int xt_register_matches(struct xt_match *match, unsigned int n);
 extern void xt_unregister_matches(struct xt_match *match, unsigned int n);
 
-extern int xt_check_match(const struct xt_match *match, unsigned short family,
-                         unsigned int size, const char *table, unsigned int hook,
-                         unsigned short proto, int inv_proto);
-extern int xt_check_target(const struct xt_target *target, unsigned short family,
-                          unsigned int size, const char *table, unsigned int hook,
-                          unsigned short proto, int inv_proto);
+extern int xt_check_match(struct xt_mtchk_param *,
+                         unsigned int size, u_int8_t proto, bool inv_proto);
+extern int xt_check_target(struct xt_tgchk_param *,
+                          unsigned int size, u_int8_t proto, bool inv_proto);
 
-extern int xt_register_table(struct xt_table *table,
-                            struct xt_table_info *bootstrap,
-                            struct xt_table_info *newinfo);
+extern struct xt_table *xt_register_table(struct net *net,
+                                         struct xt_table *table,
+                                         struct xt_table_info *bootstrap,
+                                         struct xt_table_info *newinfo);
 extern void *xt_unregister_table(struct xt_table *table);
 
 extern struct xt_table_info *xt_replace_table(struct xt_table *table,
@@ -299,18 +417,19 @@ extern struct xt_table_info *xt_replace_table(struct xt_table *table,
                                              struct xt_table_info *newinfo,
                                              int *error);
 
-extern struct xt_match *xt_find_match(int af, const char *name, u8 revision);
-extern struct xt_target *xt_find_target(int af, const char *name, u8 revision);
-extern struct xt_target *xt_request_find_target(int af, const char *name, 
+extern struct xt_match *xt_find_match(u8 af, const char *name, u8 revision);
+extern struct xt_target *xt_find_target(u8 af, const char *name, u8 revision);
+extern struct xt_target *xt_request_find_target(u8 af, const char *name,
                                                u8 revision);
-extern int xt_find_revision(int af, const char *name, u8 revision, int target,
-                           int *err);
+extern int xt_find_revision(u8 af, const char *name, u8 revision,
+                           int target, int *err);
 
-extern struct xt_table *xt_find_table_lock(int af, const char *name);
+extern struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af,
+                                          const char *name);
 extern void xt_table_unlock(struct xt_table *t);
 
-extern int xt_proto_init(int af);
-extern void xt_proto_fini(int af);
+extern int xt_proto_init(struct net *net, u_int8_t af);
+extern void xt_proto_fini(struct net *net, u_int8_t af);
 
 extern struct xt_table_info *xt_alloc_table_info(unsigned int size);
 extern void xt_free_table_info(struct xt_table_info *info);
@@ -375,20 +494,24 @@ struct compat_xt_counters_info
 #define COMPAT_XT_ALIGN(s) (((s) + (__alignof__(struct compat_xt_counters)-1)) \
                & ~(__alignof__(struct compat_xt_counters)-1))
 
-extern void xt_compat_lock(int af);
-extern void xt_compat_unlock(int af);
+extern void xt_compat_lock(u_int8_t af);
+extern void xt_compat_unlock(u_int8_t af);
+
+extern int xt_compat_add_offset(u_int8_t af, unsigned int offset, short delta);
+extern void xt_compat_flush_offsets(u_int8_t af);
+extern short xt_compat_calc_jump(u_int8_t af, unsigned int offset);
 
-extern int xt_compat_match_offset(struct xt_match *match);
-extern void xt_compat_match_from_user(struct xt_entry_match *m,
-                                     void **dstptr, int *size);
+extern int xt_compat_match_offset(const struct xt_match *match);
+extern int xt_compat_match_from_user(struct xt_entry_match *m,
+                                    void **dstptr, unsigned int *size);
 extern int xt_compat_match_to_user(struct xt_entry_match *m,
-                                  void __user **dstptr, int *size);
+                                  void __user **dstptr, unsigned int *size);
 
-extern int xt_compat_target_offset(struct xt_target *target);
+extern int xt_compat_target_offset(const struct xt_target *target);
 extern void xt_compat_target_from_user(struct xt_entry_target *t,
-                                      void **dstptr, int *size);
+                                      void **dstptr, unsigned int *size);
 extern int xt_compat_target_to_user(struct xt_entry_target *t,
-                                   void __user **dstptr, int *size);
+                                   void __user **dstptr, unsigned int *size);
 
 #endif /* CONFIG_COMPAT */
 #endif /* __KERNEL__ */