Pull asus into release branch
[pandora-kernel.git] / net / ipv4 / netfilter / ipt_ULOG.c
index d46fd67..9acc018 100644 (file)
@@ -4,9 +4,9 @@
  * (C) 2000-2004 by Harald Welte <laforge@netfilter.org>
  *
  * 2000/09/22 ulog-cprange feature added
- * 2001/01/04 in-kernel queue as proposed by Sebastian Zander 
+ * 2001/01/04 in-kernel queue as proposed by Sebastian Zander
  *                                             <zander@fokus.gmd.de>
- * 2001/01/30 per-rule nlgroup conflicts with global queue. 
+ * 2001/01/30 per-rule nlgroup conflicts with global queue.
  *            nlgroup now global (sysctl)
  * 2001/04/19 ulog-queue reworked, now fixed buffer size specified at
  *           module loadtime -HW
@@ -23,8 +23,8 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * This module accepts two parameters: 
- * 
+ * This module accepts two parameters:
+ *
  * nlbufsiz:
  *   The parameter specifies how big the buffer for each netlink multicast
  * group is. e.g. If you say nlbufsiz=8192, up to eight kb of packets will
 #include <linux/mm.h>
 #include <linux/moduleparam.h>
 #include <linux/netfilter.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ipt_ULOG.h>
 #include <net/sock.h>
 #include <linux/bitops.h>
+#include <asm/unaligned.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
@@ -72,7 +73,7 @@ MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_NFLOG);
 
 #if 0
 #define DEBUGP(format, args...) printk("%s:%s:" format, \
-                                       __FILE__, __FUNCTION__ , ## args)
+                                      __FILE__, __FUNCTION__ , ## args)
 #else
 #define DEBUGP(format, args...)
 #endif
@@ -132,7 +133,6 @@ static void ulog_send(unsigned int nlgroupnum)
        ub->qlen = 0;
        ub->skb = NULL;
        ub->lastnlh = NULL;
-
 }
 
 
@@ -163,7 +163,7 @@ static struct sk_buff *ulog_alloc_skb(unsigned int size)
                PRINTR("ipt_ULOG: can't alloc whole buffer %ub!\n", n);
 
                if (n > size) {
-                       /* try to allocate only as much as we need for 
+                       /* try to allocate only as much as we need for
                         * current packet */
 
                        skb = alloc_skb(size, GFP_ATOMIC);
@@ -204,7 +204,7 @@ static void ipt_ulog_packet(unsigned int hooknum,
        size = NLMSG_SPACE(sizeof(*pm) + copy_len);
 
        ub = &ulog_buffers[groupnum];
-       
+
        spin_lock_bh(&ulog_lock);
 
        if (!ub->skb) {
@@ -212,7 +212,7 @@ static void ipt_ulog_packet(unsigned int hooknum,
                        goto alloc_failure;
        } else if (ub->qlen >= loginfo->qthreshold ||
                   size > skb_tailroom(ub->skb)) {
-               /* either the queue len is too high or we don't have 
+               /* either the queue len is too high or we don't have
                 * enough room in nlskb left. send it to userspace. */
 
                ulog_send(groupnum);
@@ -221,11 +221,11 @@ static void ipt_ulog_packet(unsigned int hooknum,
                        goto alloc_failure;
        }
 
-       DEBUGP("ipt_ULOG: qlen %d, qthreshold %d\n", ub->qlen, 
+       DEBUGP("ipt_ULOG: qlen %d, qthreshold %d\n", ub->qlen,
                loginfo->qthreshold);
 
        /* NLMSG_PUT contains a hidden goto nlmsg_failure !!! */
-       nlh = NLMSG_PUT(ub->skb, 0, ub->qlen, ULOG_NL_EVENT, 
+       nlh = NLMSG_PUT(ub->skb, 0, ub->qlen, ULOG_NL_EVENT,
                        sizeof(*pm)+copy_len);
        ub->qlen++;
 
@@ -237,9 +237,9 @@ static void ipt_ulog_packet(unsigned int hooknum,
 
        /* copy hook, prefix, timestamp, payload, etc. */
        pm->data_len = copy_len;
-       pm->timestamp_sec = skb->tstamp.off_sec;
-       pm->timestamp_usec = skb->tstamp.off_usec;
-       pm->mark = skb->nfmark;
+       put_unaligned(skb->tstamp.off_sec, &pm->timestamp_sec);
+       put_unaligned(skb->tstamp.off_usec, &pm->timestamp_usec);
+       put_unaligned(skb->mark, &pm->mark);
        pm->hook = hooknum;
        if (prefix != NULL)
                strncpy(pm->prefix, prefix, sizeof(pm->prefix));
@@ -269,7 +269,7 @@ static void ipt_ulog_packet(unsigned int hooknum,
        /* copy_len <= skb->len, so can't fail. */
        if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
                BUG();
-       
+
        /* check if we are building multi-part messages */
        if (ub->qlen > 1) {
                ub->lastnlh->nlmsg_flags |= NLM_F_MULTI;
@@ -308,15 +308,15 @@ static unsigned int ipt_ulog_target(struct sk_buff **pskb,
                                    const struct net_device *out,
                                    unsigned int hooknum,
                                    const struct xt_target *target,
-                                   const void *targinfo, void *userinfo)
+                                   const void *targinfo)
 {
        struct ipt_ulog_info *loginfo = (struct ipt_ulog_info *) targinfo;
 
        ipt_ulog_packet(hooknum, *pskb, in, out, loginfo, NULL);
-       return IPT_CONTINUE;
+
+       return XT_CONTINUE;
 }
+
 static void ipt_logfn(unsigned int pf,
                      unsigned int hooknum,
                      const struct sk_buff *skb,
@@ -346,7 +346,6 @@ static int ipt_ulog_checkentry(const char *tablename,
                               const void *e,
                               const struct xt_target *target,
                               void *targinfo,
-                              unsigned int targinfosize,
                               unsigned int hookmask)
 {
        struct ipt_ulog_info *loginfo = (struct ipt_ulog_info *) targinfo;
@@ -364,8 +363,9 @@ static int ipt_ulog_checkentry(const char *tablename,
        return 1;
 }
 
-static struct ipt_target ipt_ulog_reg = {
+static struct xt_target ipt_ulog_reg = {
        .name           = "ULOG",
+       .family         = AF_INET,
        .target         = ipt_ulog_target,
        .targetsize     = sizeof(struct ipt_ulog_info),
        .checkentry     = ipt_ulog_checkentry,
@@ -380,7 +380,7 @@ static struct nf_logger ipt_ulog_logger = {
 
 static int __init ipt_ulog_init(void)
 {
-       int i;
+       int ret, i;
 
        DEBUGP("ipt_ULOG: init module\n");
 
@@ -397,17 +397,18 @@ static int __init ipt_ulog_init(void)
        }
 
        nflognl = netlink_kernel_create(NETLINK_NFLOG, ULOG_MAXNLGROUPS, NULL,
-                                       THIS_MODULE);
+                                       THIS_MODULE);
        if (!nflognl)
                return -ENOMEM;
 
-       if (ipt_register_target(&ipt_ulog_reg) != 0) {
+       ret = xt_register_target(&ipt_ulog_reg);
+       if (ret < 0) {
                sock_release(nflognl->sk_socket);
-               return -EINVAL;
+               return ret;
        }
        if (nflog)
                nf_log_register(PF_INET, &ipt_ulog_logger);
-       
+
        return 0;
 }
 
@@ -419,8 +420,8 @@ static void __exit ipt_ulog_fini(void)
        DEBUGP("ipt_ULOG: cleanup_module\n");
 
        if (nflog)
-               nf_log_unregister_logger(&ipt_ulog_logger);
-       ipt_unregister_target(&ipt_ulog_reg);
+               nf_log_unregister(&ipt_ulog_logger);
+       xt_unregister_target(&ipt_ulog_reg);
        sock_release(nflognl->sk_socket);
 
        /* remove pending timers and free allocated skb's */
@@ -436,7 +437,6 @@ static void __exit ipt_ulog_fini(void)
                        ub->skb = NULL;
                }
        }
-
 }
 
 module_init(ipt_ulog_init);