From ec99b87f5bb800371bf3e236836b6c74bc07eee6 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 3 Aug 2006 19:06:05 +0000 Subject: Tidier MakeIP6Int() git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4681 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/dns.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/dns.cpp') 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 */ -- cgit v1.2.3