diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-03 19:06:05 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-03 19:06:05 +0000 |
commit | ec99b87f5bb800371bf3e236836b6c74bc07eee6 (patch) | |
tree | 779571bde8f4164e060aacc1b2a6df117234cdca /src/dns.cpp | |
parent | b14375407cbaa7ff62195061d8502cb3786942ae (diff) |
Tidier MakeIP6Int()
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4681 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/dns.cpp')
-rw-r--r-- | src/dns.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/dns.cpp b/src/dns.cpp index 852c9282e..52e541967 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -471,15 +471,14 @@ int DNS::GetNameForce(const char *ip, ForceProtocol fp) void DNS::MakeIP6Int(char* query, const in6_addr *ip) { const char* hex = "0123456789abcdef"; - int step = 31; /* 32 nibbles, 0..31 */ - for (int index = 15; index > -1; (!(step-- % 2) ? index-- : index = index)) /* for() loop steps twice per byte */ + for (int index = 31; index >= 0; index--) /* for() loop steps twice per byte */ { - if (step % 2) + if (index % 2) /* low nibble */ - *query++ = hex[ip->s6_addr[index] & 0x0F]; + *query++ = hex[ip->s6_addr[index / 2] & 0x0F]; else /* high nibble */ - *query++ = hex[(ip->s6_addr[index] & 0xF0) >> 4]; + *query++ = hex[(ip->s6_addr[index / 2] & 0xF0) >> 4]; *query++ = '.'; /* Seperator */ } strcpy(query,"ip6.arpa"); /* Suffix the string */ |