-#ifdef IPV6
- /* XXX: This SUCKS. and i mean REALLY, REALLY sucks. Anyone who rewrites it pretty gets a cookie. */
- sprintf(query,"%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.ip6.int",
- ip->s6_addr[15] & 0x0f,
- (ip->s6_addr[15] & 0xf0) >> 4,
- ip->s6_addr[14] & 0x0f,
- (ip->s6_addr[14] & 0xf0) >> 4,
- ip->s6_addr[13] & 0x0f,
- (ip->s6_addr[13] & 0xf0) >> 4,
- ip->s6_addr[12] & 0x0f,
- (ip->s6_addr[12] & 0xf0) >> 4,
- ip->s6_addr[11] & 0x0f,
- (ip->s6_addr[11] & 0xf0) >> 4,
- ip->s6_addr[10] & 0x0f,
- (ip->s6_addr[10] & 0xf0) >> 4,
- ip->s6_addr[9] & 0x0f,
- (ip->s6_addr[9] & 0xf0) >> 4,
- ip->s6_addr[8] & 0x0f,
- (ip->s6_addr[8] & 0xf0) >> 4,
- ip->s6_addr[7] & 0x0f,
- (ip->s6_addr[7] & 0xf0) >> 4,
- ip->s6_addr[6] & 0x0f,
- (ip->s6_addr[6] & 0xf0) >> 4,
- ip->s6_addr[5] & 0x0f,
- (ip->s6_addr[5] & 0xf0) >> 4,
- ip->s6_addr[4] & 0x0f,
- (ip->s6_addr[4] & 0xf0) >> 4,
- ip->s6_addr[3] & 0x0f,
- (ip->s6_addr[3] & 0xf0) >> 4,
- ip->s6_addr[2] & 0x0f,
- (ip->s6_addr[2] & 0xf0) >> 4,
- ip->s6_addr[1] & 0x0f,
- (ip->s6_addr[1] & 0xf0) >> 4,
- ip->s6_addr[0] & 0x0f,
- (ip->s6_addr[0] & 0xf0) >> 4
- );
-#else
- unsigned char* c = (unsigned char*)&ip->s_addr;
-
- sprintf(query,"%d.%d.%d.%d.in-addr.arpa",c[3],c[2],c[1],c[0]);
-#endif
+ if (fp == PROTOCOL_IPV6)
+ {
+ in6_addr i;
+ if (inet_pton(AF_INET6, ip, &i) > 0)
+ {
+ DNS::MakeIP6Int(query, &i);
+ }
+ else
+ {
+ ServerInstance->Logs->Log("RESOLVER",DEBUG,"DNS::GetNameForce IPv6 bad format for '%s'", ip);
+ /* Invalid IP address */
+ return -1;
+ }
+ }
+ else
+ {
+ in_addr i;
+ if (inet_aton(ip, &i))
+ {
+ unsigned char* c = (unsigned char*)&i.s_addr;
+ sprintf(query,"%d.%d.%d.%d.in-addr.arpa",c[3],c[2],c[1],c[0]);
+ }
+ else
+ {
+ ServerInstance->Logs->Log("RESOLVER",DEBUG,"DNS::GetNameForce IPv4 bad format for '%s'", ip);
+ /* Invalid IP address */
+ return -1;
+ }
+ }