*
* 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"
#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"
"\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;
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,
"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;
(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;
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);
}
+#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,
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)