]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
IPMARK: misc cleanups
authorJan Engelhardt <jengelh@computergmbh.de>
Tue, 8 Apr 2008 17:52:31 +0000 (19:52 +0200)
committerJan Engelhardt <jengelh@computergmbh.de>
Wed, 9 Apr 2008 11:10:00 +0000 (13:10 +0200)
- order #include lists
- const annotations, removal of casts
- add ipt_IPMARK alias
- make symbol names distinct

extensions/libxt_IPMARK.c
extensions/xt_IPMARK.c

index 384657b2655bd2d5feb76848c4959b2b50b0fc3d..25e902540039d74ca9a88d072f0f6c2be557378d 100644 (file)
@@ -5,11 +5,10 @@
  *
  * This program is distributed under the terms of GNU GPL
  */
+#include <getopt.h>
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
-#include <getopt.h>
-
+#include <string.h>
 #include <xtables.h>
 #include "xt_IPMARK.h"
 
@@ -18,8 +17,7 @@
 #define IPT_OR_MASK_USED     4
 
 /* Function which prints out usage message. */
-static void
-help(void)
+static void ipmark_tg_help(void)
 {
        printf(
 "IPMARK target options:\n"
@@ -29,27 +27,23 @@ help(void)
 "\n");
 }
 
-static struct option opts[] = {
+static const struct option ipmark_tg_opts[] = {
        { "addr", 1, 0, '1' },
        { "and-mask", 1, 0, '2' },
        { "or-mask", 1, 0, '3' },
-       { 0 }
+       {NULL},
 };
 
 /* Initialize the target. */
-static void
-init(struct xt_entry_target *t)
+static void ipmark_tg_init(struct xt_entry_target *t)
 {
        struct xt_ipmark_tginfo *info = (void *)t->data;
 
        info->andmask = ~0U;
 }
 
-/* Function which parses command options; returns true if it
-   ate an option */
-static int
-parse(int c, char **argv, int invert, unsigned int *flags,
-      const void *entry, struct xt_entry_target **target)
+static int ipmark_tg_parse(int c, char **argv, int invert, unsigned int *flags,
+                           const void *entry, struct xt_entry_target **target)
 {
        struct xt_ipmark_tginfo *info = (void *)(*target)->data;
 
@@ -91,8 +85,7 @@ parse(int c, char **argv, int invert, unsigned int *flags,
        return 1;
 }
 
-static void
-final_check(unsigned int flags)
+static void ipmark_tg_check(unsigned int flags)
 {
        if (!(flags & IPT_ADDR_USED))
                exit_error(PARAMETER_PROBLEM,
@@ -102,10 +95,9 @@ final_check(unsigned int flags)
                           "IPMARK target: Parameter --and-mask or --or-mask is required");
 }
 
-/* Prints out the targinfo. */
 static void
-print(const void *entry, const struct xt_entry_target *target,
-      int numeric)
+ipmark_tg_print(const void *entry, const struct xt_entry_target *target,
+                int numeric)
 {
        const struct xt_ipmark_tginfo *info = (const void *)target->data;
 
@@ -117,9 +109,8 @@ print(const void *entry, const struct xt_entry_target *target,
               (unsigned int)info->andmask, (unsigned int)info->ormask);
 }
 
-/* Saves the union ipt_targinfo in parsable form to stdout. */
 static void
-save(const void *entry, const struct xt_entry_target *target)
+ipmark_tg_save(const void *entry, const struct xt_entry_target *target)
 {
        const struct xt_ipmark_tginfo *info = (const void *)target->data;
 
@@ -133,22 +124,23 @@ save(const void *entry, const struct xt_entry_target *target)
                printf("--or-mask 0x%x ", (unsigned int)info->ormask);
 }
 
-static struct xtables_target ipmark = {
-       .next          = NULL,
-       .name          = "IPMARK",
+static struct xtables_target ipmark_tg4_reg = {
        .version       = XTABLES_VERSION,
+       .name          = "IPMARK",
+       .family        = PF_INET,
+       .revision      = 0,
        .size          = XT_ALIGN(sizeof(struct xt_ipmark_tginfo)),
        .userspacesize = XT_ALIGN(sizeof(struct xt_ipmark_tginfo)),
-       .help          = &help,
-       .init          = &init,
-       .parse         = &parse,
-       .final_check   = &final_check,
-       .print         = &print,
-       .save          = &save,
-       .extra_opts    = opts
+       .help          = ipmark_tg_help,
+       .init          = ipmark_tg_init,
+       .parse         = ipmark_tg_parse,
+       .final_check   = ipmark_tg_check,
+       .print         = ipmark_tg_print,
+       .save          = ipmark_tg_save,
+       .extra_opts    = ipmark_tg_opts,
 };
 
-void _init(void)
+static void _init(void)
 {
-       xtables_register_target(&ipmark);
+       xtables_register_target(&ipmark_tg4_reg);
 }
index 4db5258f1a8a5ef9c5dfcfe25e0fe05a27d1d841..e25bfe6400b0e4b5f7b04f5d12414e5d9050b2ea 100644 (file)
@@ -1,16 +1,16 @@
+#include <linux/ip.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/version.h>
-#include <linux/ip.h>
-#include <net/checksum.h>
-
 #include <linux/netfilter/x_tables.h>
+#include <net/checksum.h>
 #include "xt_IPMARK.h"
 #include "compat_xtables.h"
 
 MODULE_AUTHOR("Grzegorz Janoszka <Grzegorz@Janoszka.pl>");
 MODULE_DESCRIPTION("IP tables IPMARK: mark based on ip address");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("ipt_IPMARK");
 
 static unsigned int
 ipmark_tg(struct sk_buff *skb,
@@ -21,7 +21,7 @@ ipmark_tg(struct sk_buff *skb,
        const void *targinfo)
 {
        const struct xt_ipmark_tginfo *ipmarkinfo = targinfo;
-       struct iphdr *iph = ip_hdr(skb);
+       const struct iphdr *iph = ip_hdr(skb);
        __u32 mark;
 
        if (ipmarkinfo->selector == XT_IPMARK_SRC)