netfilter: xtables: provide invoked family value to extensions
[deliverable/linux.git] / include / linux / netfilter / x_tables.h
index 90dc6ea2a683c3e3672ea0c26cf717c1e092bfa0..be41b609c88fddbe6384ab5e73f3fe393fb56320 100644 (file)
@@ -173,6 +173,98 @@ struct xt_counters_info
 
 #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;
@@ -185,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);
@@ -235,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);
@@ -292,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>
@@ -328,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,
@@ -345,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);
@@ -421,24 +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(int af, unsigned int offset, short delta);
-extern void xt_compat_flush_offsets(int af);
-extern short xt_compat_calc_jump(int af, unsigned int offset);
+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 int xt_compat_match_offset(const struct xt_match *match);
 extern int xt_compat_match_from_user(struct xt_entry_match *m,
-                                    void **dstptr, int *size);
+                                    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__ */
This page took 0.049022 seconds and 5 git commands to generate.