diff options
author | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2010-12-10 23:04:59 +0100 |
---|---|---|
committer | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2010-12-10 23:04:59 +0100 |
commit | f1b2412ed58f56e86a70697ae3eaf55c585c39fe (patch) | |
tree | 66e18088268042cc3b018d20e3895d2cb3036f35 | |
parent | 834f20138660369342cea889e8ce81bccf3ab976 (diff) |
Support case-insensitive ICMP and ICMPv6 type/code names.
-rw-r--r-- | include/libipset/utils.h | 2 | ||||
-rw-r--r-- | lib/icmp.c | 2 | ||||
-rw-r--r-- | lib/icmpv6.c | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/include/libipset/utils.h b/include/libipset/utils.h index 75efdac..c22687f 100644 --- a/include/libipset/utils.h +++ b/include/libipset/utils.h @@ -13,6 +13,8 @@ /* String equality tests */ #define STREQ(a,b) (strcmp(a,b) == 0) #define STRNEQ(a,b,n) (strncmp(a,b,n) == 0) +#define STRCASEQ(a,b) (strcasecmp(a,b) == 0) +#define STRNCASEQ(a,b,n) (strncasecmp(a,b,n) == 0) /* Stringify tokens */ #define _STR(c) #c @@ -70,7 +70,7 @@ int name_to_icmp(const char *str, uint16_t *typecode) unsigned int i; for (i = 0; i < ARRAY_SIZE(icmp_typecodes); i++) - if (STRNEQ(icmp_typecodes[i].name, str, strlen(str))) { + if (STRNCASEQ(icmp_typecodes[i].name, str, strlen(str))) { *typecode = (icmp_typecodes[i].type << 8) | icmp_typecodes[i].code; return 0; } diff --git a/lib/icmpv6.c b/lib/icmpv6.c index c32a6a4..5ba93ca 100644 --- a/lib/icmpv6.c +++ b/lib/icmpv6.c @@ -57,7 +57,7 @@ int name_to_icmpv6(const char *str, uint16_t *typecode) unsigned int i; for (i = 0; i < ARRAY_SIZE(icmpv6_typecodes); i++) - if (STRNEQ(icmpv6_typecodes[i].name, str, strlen(str))) { + if (STRNCASEQ(icmpv6_typecodes[i].name, str, strlen(str))) { *typecode = (icmpv6_typecodes[i].type << 8) | icmpv6_typecodes[i].code; return 0; } |