iptables-1.3.2-20050720
[iptables.git] / extensions / libipt_tos.c
index 6786911..7a10a50 100644 (file)
@@ -47,13 +47,6 @@ static struct option opts[] = {
        {0}
 };
 
-/* Initialize the match. */
-static void
-init(struct ipt_entry_match *m, unsigned int *nfcache)
-{
-       *nfcache |= NFC_IP_TOS;
-}
-
 static void
 parse_tos(const unsigned char *s, struct ipt_tos_info *info)
 {
@@ -91,6 +84,11 @@ parse(int c, char **argv, int invert, unsigned int *flags,
 
        switch (c) {
        case '1':
+               /* Ensure that `--tos' haven't been used yet. */
+               if (*flags == 1)
+                       exit_error(PARAMETER_PROBLEM,
+                                       "tos match: only use --tos once!");
+
                check_inverse(optarg, &invert, &optind, 0);
                parse_tos(argv[optind-1], tosinfo);
                if (invert)
@@ -154,20 +152,18 @@ save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
        print_tos(info->tos, 0);
 }
 
-static
-struct iptables_match tos
-= { NULL,
-    "tos",
-    IPTABLES_VERSION,
-    IPT_ALIGN(sizeof(struct ipt_tos_info)),
-    IPT_ALIGN(sizeof(struct ipt_tos_info)),
-    &help,
-    &init,
-    &parse,
-    &final_check,
-    &print,
-    &save,
-    opts
+static struct iptables_match tos = { 
+       .next           = NULL,
+       .name           = "tos",
+       .version        = IPTABLES_VERSION,
+       .size           = IPT_ALIGN(sizeof(struct ipt_tos_info)),
+       .userspacesize  = IPT_ALIGN(sizeof(struct ipt_tos_info)),
+       .help           = &help,
+       .parse          = &parse,
+       .final_check    = &final_check,
+       .print          = &print,
+       .save           = &save,
+       .extra_opts     = opts
 };
 
 void _init(void)