[PATCH] mark struct file_operations const 7
[safe/jmp/linux-2.6] / net / ipv4 / netfilter / ipt_LOG.c
index 6606ddb..f4a62f2 100644 (file)
@@ -20,7 +20,7 @@
 #include <net/route.h>
 
 #include <linux/netfilter.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ipt_LOG.h>
 
 MODULE_LICENSE("GPL");
@@ -171,11 +171,15 @@ static void dump_packet(const struct nf_loginfo *info,
                }
                break;
        }
-       case IPPROTO_UDP: {
+       case IPPROTO_UDP:
+       case IPPROTO_UDPLITE: {
                struct udphdr _udph, *uh;
 
-               /* Max length: 10 "PROTO=UDP " */
-               printk("PROTO=UDP ");
+               if (ih->protocol == IPPROTO_UDP)
+                       /* Max length: 10 "PROTO=UDP "     */
+                       printk("PROTO=UDP " );
+               else    /* Max length: 14 "PROTO=UDPLITE " */
+                       printk("PROTO=UDPLITE ");
 
                if (ntohs(ih->frag_off) & IP_OFFSET)
                        break;
@@ -285,7 +289,7 @@ static void dump_packet(const struct nf_loginfo *info,
 
                if (ntohs(ih->frag_off) & IP_OFFSET)
                        break;
-               
+
                /* Max length: 9 "PROTO=AH " */
                printk("PROTO=AH ");
 
@@ -330,10 +334,10 @@ static void dump_packet(const struct nf_loginfo *info,
        }
 
        /* Max length: 15 "UID=4294967295 " */
-       if ((logflags & IPT_LOG_UID) && !iphoff && skb->sk) {
+       if ((logflags & IPT_LOG_UID) && !iphoff && skb->sk) {
                read_lock_bh(&skb->sk->sk_callback_lock);
                if (skb->sk->sk_socket && skb->sk->sk_socket->file)
-                       printk("UID=%u ", skb->sk->sk_socket->file->f_uid);
+                       printk("UID=%u ", skb->sk->sk_socket->file->f_uid);
                read_unlock_bh(&skb->sk->sk_callback_lock);
        }
 
@@ -341,6 +345,7 @@ static void dump_packet(const struct nf_loginfo *info,
        /* IP:      40+46+6+11+127 = 230 */
        /* TCP:     10+max(25,20+30+13+9+32+11+127) = 252 */
        /* UDP:     10+max(25,20) = 35 */
+       /* UDPLITE: 14+max(25,20) = 39 */
        /* ICMP:    11+max(25, 18+25+max(19,14,24+3+n+10,3+n+10)) = 91+n */
        /* ESP:     10+max(25)+15 = 50 */
        /* AH:      9+max(25)+15 = 49 */
@@ -415,8 +420,8 @@ ipt_log_target(struct sk_buff **pskb,
               const struct net_device *in,
               const struct net_device *out,
               unsigned int hooknum,
-              const void *targinfo,
-              void *userinfo)
+              const struct xt_target *target,
+              const void *targinfo)
 {
        const struct ipt_log_info *loginfo = targinfo;
        struct nf_loginfo li;
@@ -425,42 +430,36 @@ ipt_log_target(struct sk_buff **pskb,
        li.u.log.level = loginfo->level;
        li.u.log.logflags = loginfo->logflags;
 
-       nf_log_packet(PF_INET, hooknum, *pskb, in, out, &li, loginfo->prefix);
-
-       return IPT_CONTINUE;
+       ipt_log_packet(PF_INET, hooknum, *pskb, in, out, &li,
+                      loginfo->prefix);
+       return XT_CONTINUE;
 }
 
 static int ipt_log_checkentry(const char *tablename,
                              const void *e,
+                             const struct xt_target *target,
                              void *targinfo,
-                             unsigned int targinfosize,
                              unsigned int hook_mask)
 {
        const struct ipt_log_info *loginfo = targinfo;
 
-       if (targinfosize != IPT_ALIGN(sizeof(struct ipt_log_info))) {
-               DEBUGP("LOG: targinfosize %u != %u\n",
-                      targinfosize, IPT_ALIGN(sizeof(struct ipt_log_info)));
-               return 0;
-       }
-
        if (loginfo->level >= 8) {
                DEBUGP("LOG: level %u >= 8\n", loginfo->level);
                return 0;
        }
-
        if (loginfo->prefix[sizeof(loginfo->prefix)-1] != '\0') {
                DEBUGP("LOG: prefix term %i\n",
                       loginfo->prefix[sizeof(loginfo->prefix)-1]);
                return 0;
        }
-
        return 1;
 }
 
-static struct ipt_target ipt_log_reg = {
+static struct xt_target ipt_log_reg = {
        .name           = "LOG",
+       .family         = AF_INET,
        .target         = ipt_log_target,
+       .targetsize     = sizeof(struct ipt_log_info),
        .checkentry     = ipt_log_checkentry,
        .me             = THIS_MODULE,
 };
@@ -471,25 +470,28 @@ static struct nf_logger ipt_log_logger ={
        .me             = THIS_MODULE,
 };
 
-static int __init init(void)
+static int __init ipt_log_init(void)
 {
-       if (ipt_register_target(&ipt_log_reg))
-               return -EINVAL;
+       int ret;
+
+       ret = xt_register_target(&ipt_log_reg);
+       if (ret < 0)
+               return ret;
        if (nf_log_register(PF_INET, &ipt_log_logger) < 0) {
                printk(KERN_WARNING "ipt_LOG: not logging via system console "
                       "since somebody else already registered for PF_INET\n");
                /* we cannot make module load fail here, since otherwise
                 * iptables userspace would abort */
        }
-       
+
        return 0;
 }
 
-static void __exit fini(void)
+static void __exit ipt_log_fini(void)
 {
        nf_log_unregister_logger(&ipt_log_logger);
-       ipt_unregister_target(&ipt_log_reg);
+       xt_unregister_target(&ipt_log_reg);
 }
 
-module_init(init);
-module_exit(fini);
+module_init(ipt_log_init);
+module_exit(ipt_log_fini);