diff options
author | Andy Shevchenko <andy.shevchenko@gmail.com> | 2010-09-21 00:40:26 +0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-09-22 05:04:45 +0400 |
commit | 82fd5b5d1ec370a50b3060418cde6a4ac8401117 (patch) | |
tree | d9a30b87d31636d4ad8fa0df96c9fb031564010e /net/core/utils.c | |
parent | 66bb16de6b9a05936d1eeb20155bab008b476191 (diff) | |
download | linux-82fd5b5d1ec370a50b3060418cde6a4ac8401117.tar.xz |
net: core: use kernel's converter from hex to bin
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/utils.c')
-rw-r--r-- | net/core/utils.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/net/core/utils.c b/net/core/utils.c index f41854470539..ec6bb322f372 100644 --- a/net/core/utils.c +++ b/net/core/utils.c @@ -92,18 +92,19 @@ EXPORT_SYMBOL(in_aton); static inline int xdigit2bin(char c, int delim) { + int val; + if (c == delim || c == '\0') return IN6PTON_DELIM; if (c == ':') return IN6PTON_COLON_MASK; if (c == '.') return IN6PTON_DOT; - if (c >= '0' && c <= '9') - return (IN6PTON_XDIGIT | IN6PTON_DIGIT| (c - '0')); - if (c >= 'a' && c <= 'f') - return (IN6PTON_XDIGIT | (c - 'a' + 10)); - if (c >= 'A' && c <= 'F') - return (IN6PTON_XDIGIT | (c - 'A' + 10)); + + val = hex_to_bin(c); + if (val >= 0) + return val | IN6PTON_XDIGIT | (val < 10 ? IN6PTON_DIGIT : 0); + if (delim == -1) return IN6PTON_DELIM; return IN6PTON_UNKNOWN; |