]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
Major icmpv6 cleanup / fixes by Kis-Szabo Andras.
authorAndrás Kis-Szabó <kisza@sch.bme.hu>
Sat, 14 Jul 2001 20:21:46 +0000 (20:21 +0000)
committerHarald Welte <laforge@gnumonks.org>
Sat, 14 Jul 2001 20:21:46 +0000 (20:21 +0000)
extensions/Makefile
extensions/libip6t_icmpv6.c [moved from extensions/libip6t_icmp.c with 64% similarity]
ip6tables-save.c

index 1ffba2a81d99d25481673e2a662872cdba09e729..d7b617332590e5a81a8b87d42a4bb2e9dd067aa1 100644 (file)
@@ -1,7 +1,7 @@
 #! /usr/bin/make
 
 PF_EXT_SLIB:=tcp udp icmp mac limit standard REJECT LOG unclean state multiport tos TOS mark MARK owner SNAT DNAT MASQUERADE REDIRECT MIRROR SAME
-PF6_EXT_SLIB:=tcp udp icmp standard MARK mark
+PF6_EXT_SLIB:=tcp udp icmpv6 standard MARK mark
 
 # The following may not be present, but compile them anyway.
 PF_EXT_SLIB+=FTOS TCPMSS TTL ULOG ah esp iplimit tcpmss ttl
similarity index 64%
rename from extensions/libip6t_icmp.c
rename to extensions/libip6t_icmpv6.c
index 8025175ac1e6ff011b1d9b8743a408de5b8f9f29..41ae5ca3edadcdff6c0fd175a7454c537857d1fd 100644 (file)
@@ -7,13 +7,13 @@
 #include <ip6tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 
-struct icmp_names {
+struct icmpv6_names {
        const char *name;
        u_int8_t type;
        u_int8_t code_min, code_max;
 };
 
-static const struct icmp_names icmp_codes[] = {
+static const struct icmpv6_names icmpv6_codes[] = {
        { "destination-unreachable", 1, 0, 0xFF },
        {   "no-route", 1, 0, 0 },
        {   "communication-prohibited", 1, 1, 1 },
@@ -53,22 +53,22 @@ static const struct icmp_names icmp_codes[] = {
 };
 
 static void
-print_icmptypes()
+print_icmpv6types()
 {
        unsigned int i;
        printf("Valid ICMPv6 Types:");
 
-       for (i = 0; i < sizeof(icmp_codes)/sizeof(struct icmp_names); i++) {
-               if (i && icmp_codes[i].type == icmp_codes[i-1].type) {
-                       if (icmp_codes[i].code_min == icmp_codes[i-1].code_min
-                           && (icmp_codes[i].code_max
-                               == icmp_codes[i-1].code_max))
-                               printf(" (%s)", icmp_codes[i].name);
+       for (i = 0; i < sizeof(icmpv6_codes)/sizeof(struct icmpv6_names); i++) {
+               if (i && icmpv6_codes[i].type == icmpv6_codes[i-1].type) {
+                       if (icmpv6_codes[i].code_min == icmpv6_codes[i-1].code_min
+                           && (icmpv6_codes[i].code_max
+                               == icmpv6_codes[i-1].code_max))
+                               printf(" (%s)", icmpv6_codes[i].name);
                        else
-                               printf("\n   %s", icmp_codes[i].name);
+                               printf("\n   %s", icmpv6_codes[i].name);
                }
                else
-                       printf("\n%s", icmp_codes[i].name);
+                       printf("\n%s", icmpv6_codes[i].name);
        }
        printf("\n");
 }
@@ -79,48 +79,48 @@ help(void)
 {
        printf(
 "ICMPv6 v%s options:\n"
-" --icmp-type [!] typename     match icmp type\n"
+" --icmpv6-type [!] typename   match icmpv6 type\n"
 "                              (or numeric type or type/code)\n"
 "\n", NETFILTER_VERSION);
-       print_icmptypes();
+       print_icmpv6types();
 }
 
 static struct option opts[] = {
-       { "icmp-type", 1, 0, '1' },
+       { "icmpv6-type", 1, 0, '1' },
        {0}
 };
 
 static unsigned int
-parse_icmp(const char *icmptype, u_int8_t *type, u_int8_t code[])
+parse_icmpv6(const char *icmpv6type, u_int8_t *type, u_int8_t code[])
 {
-       unsigned int limit = sizeof(icmp_codes)/sizeof(struct icmp_names);
+       unsigned int limit = sizeof(icmpv6_codes)/sizeof(struct icmpv6_names);
        unsigned int match = limit;
        unsigned int i;
 
        for (i = 0; i < limit; i++) {
-               if (strncasecmp(icmp_codes[i].name, icmptype, strlen(icmptype))
+               if (strncasecmp(icmpv6_codes[i].name, icmpv6type, strlen(icmpv6type))
                    == 0) {
                        if (match != limit)
                                exit_error(PARAMETER_PROBLEM,
                                           "Ambiguous ICMPv6 type `%s':"
                                           " `%s' or `%s'?",
-                                          icmptype,
-                                          icmp_codes[match].name,
-                                          icmp_codes[i].name);
+                                          icmpv6type,
+                                          icmpv6_codes[match].name,
+                                          icmpv6_codes[i].name);
                        match = i;
                }
        }
 
        if (match != limit) {
-               *type = icmp_codes[match].type;
-               code[0] = icmp_codes[match].code_min;
-               code[1] = icmp_codes[match].code_max;
+               *type = icmpv6_codes[match].type;
+               code[0] = icmpv6_codes[match].code_min;
+               code[1] = icmpv6_codes[match].code_max;
        } else {
                char *slash;
-               char buffer[strlen(icmptype) + 1];
+               char buffer[strlen(icmpv6type) + 1];
                int number;
 
-               strcpy(buffer, icmptype);
+               strcpy(buffer, icmpv6type);
                slash = strchr(buffer, '/');
 
                if (slash)
@@ -153,9 +153,9 @@ parse_icmp(const char *icmptype, u_int8_t *type, u_int8_t code[])
 static void
 init(struct ip6t_entry_match *m, unsigned int *nfcache)
 {
-       struct ip6t_icmp *icmpinfo = (struct ip6t_icmp *)m->data;
+       struct ip6t_icmp *icmpv6info = (struct ip6t_icmp *)m->data;
 
-       icmpinfo->code[1] = 0xFF;
+       icmpv6info->code[1] = 0xFF;
 }
 
 /* Function which parses command options; returns true if it
@@ -166,17 +166,17 @@ parse(int c, char **argv, int invert, unsigned int *flags,
       unsigned int *nfcache,
       struct ip6t_entry_match **match)
 {
-       struct ip6t_icmp *icmpinfo = (struct ip6t_icmp *)(*match)->data;
+       struct ip6t_icmp *icmpv6info = (struct ip6t_icmp *)(*match)->data;
 
        switch (c) {
        case '1':
                if (check_inverse(optarg, &invert))
                        optind++;
-               *nfcache |= parse_icmp(argv[optind-1],
-                                      &icmpinfo->type,
-                                      icmpinfo->code);
+               *nfcache |= parse_icmpv6(argv[optind-1],
+                                      &icmpv6info->type,
+                                      icmpv6info->code);
                if (invert)
-                       icmpinfo->invflags |= IP6T_ICMP_INV;
+                       icmpv6info->invflags |= IP6T_ICMP_INV;
                break;
 
        default:
@@ -186,7 +186,7 @@ parse(int c, char **argv, int invert, unsigned int *flags,
        return 1;
 }
 
-static void print_icmptype(u_int8_t type,
+static void print_icmpv6type(u_int8_t type,
                           u_int8_t code_min, u_int8_t code_max,
                           int invert,
                           int numeric)
@@ -195,18 +195,18 @@ static void print_icmptype(u_int8_t type,
                unsigned int i;
 
                for (i = 0;
-                    i < sizeof(icmp_codes)/sizeof(struct icmp_names);
+                    i < sizeof(icmpv6_codes)/sizeof(struct icmpv6_names);
                     i++) {
-                       if (icmp_codes[i].type == type
-                           && icmp_codes[i].code_min == code_min
-                           && icmp_codes[i].code_max == code_max)
+                       if (icmpv6_codes[i].type == type
+                           && icmpv6_codes[i].code_min == code_min
+                           && icmpv6_codes[i].code_max == code_max)
                                break;
                }
 
-               if (i != sizeof(icmp_codes)/sizeof(struct icmp_names)) {
+               if (i != sizeof(icmpv6_codes)/sizeof(struct icmpv6_names)) {
                        printf("%s%s ",
                               invert ? "!" : "",
-                              icmp_codes[i].name);
+                              icmpv6_codes[i].name);
                        return;
                }
        }
@@ -229,29 +229,29 @@ print(const struct ip6t_ip6 *ip,
       const struct ip6t_entry_match *match,
       int numeric)
 {
-       const struct ip6t_icmp *icmp = (struct ip6t_icmp *)match->data;
+       const struct ip6t_icmp *icmpv6 = (struct ip6t_icmp *)match->data;
 
-       printf("icmp ");
-       print_icmptype(icmp->type, icmp->code[0], icmp->code[1],
-                      icmp->invflags & IP6T_ICMP_INV,
+       printf("icmpv6 ");
+       print_icmpv6type(icmpv6->type, icmpv6->code[0], icmpv6->code[1],
+                      icmpv6->invflags & IP6T_ICMP_INV,
                       numeric);
 
-       if (icmp->invflags & ~IP6T_ICMP_INV)
+       if (icmpv6->invflags & ~IP6T_ICMP_INV)
                printf("Unknown invflags: 0x%X ",
-                      icmp->invflags & ~IP6T_ICMP_INV);
+                      icmpv6->invflags & ~IP6T_ICMP_INV);
 }
 
 /* Saves the match in parsable form to stdout. */
 static void save(const struct ip6t_ip6 *ip, const struct ip6t_entry_match *match)
 {
-       const struct ip6t_icmp *icmp = (struct ip6t_icmp *)match->data;
+       const struct ip6t_icmp *icmpv6 = (struct ip6t_icmp *)match->data;
 
-       if (icmp->invflags & IP6T_ICMP_INV)
+       if (icmpv6->invflags & IP6T_ICMP_INV)
                printf("! ");
 
-       printf("--icmp-type %u", icmp->type);
-       if (icmp->code[0] != 0 || icmp->code[1] != 0xFF)
-               printf("/%u", icmp->code[0]);
+       printf("--icmpv6-type %u", icmpv6->type);
+       if (icmpv6->code[0] != 0 || icmpv6->code[1] != 0xFF)
+               printf("/%u", icmpv6->code[0]);
        printf(" ");
 }
 
@@ -260,9 +260,9 @@ static void final_check(unsigned int flags)
 {
 }
 
-struct ip6tables_match icmp
+struct ip6tables_match icmpv6
 = { NULL,
-    "icmp",
+    "icmpv6",
     NETFILTER_VERSION,
     IP6T_ALIGN(sizeof(struct ip6t_icmp)),
     IP6T_ALIGN(sizeof(struct ip6t_icmp)),
@@ -277,5 +277,5 @@ struct ip6tables_match icmp
 
 void _init(void)
 {
-       register_match6(&icmp);
+       register_match6(&icmpv6);
 }
index d8b15c317f53bde90167914f626f4946ffa5d09f..c18bda21de57c7db4c4600c0dc23ffa9f9aa069a 100644 (file)
@@ -69,7 +69,7 @@ struct pprot {
 static const struct pprot chain_protos[] = {
        { "tcp", IPPROTO_TCP },
        { "udp", IPPROTO_UDP },
-       { "icmp", IPPROTO_ICMP },
+       { "icmpv6", IPPROTO_ICMPV6 },
        { "esp", IPPROTO_ESP },
        { "ah", IPPROTO_AH },
 };