diff options
-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 */ |