#define RDLENGTH_SIZE (size_t)2
#define ANSWER_FIXED_SIZE (TYPE_SIZE + CLASS_SIZE + TTL_SIZE + RDLENGTH_SIZE)
-#ifdef RB_IPV6
struct in6_addr ipv6_addr;
-#endif
struct in_addr ipv4_addr;
struct reslist
static int
res_ourserver(const struct rb_sockaddr_storage *inp)
{
-#ifdef RB_IPV6
const struct sockaddr_in6 *v6;
const struct sockaddr_in6 *v6in = (const struct sockaddr_in6 *)inp;
-#endif
const struct sockaddr_in *v4;
const struct sockaddr_in *v4in = (const struct sockaddr_in *)inp;
int ns;
for(ns = 0; ns < irc_nscount; ns++)
{
const struct rb_sockaddr_storage *srv = &irc_nsaddr_list[ns];
-#ifdef RB_IPV6
v6 = (const struct sockaddr_in6 *)srv;
-#endif
v4 = (const struct sockaddr_in *)srv;
/* could probably just memcmp(srv, inp, srv.ss_len) here
*/
switch (GET_SS_FAMILY(srv))
{
-#ifdef RB_IPV6
case AF_INET6:
if(GET_SS_FAMILY(srv) == GET_SS_FAMILY(inp))
if(v6->sin6_port == v6in->sin6_port)
sizeof(struct in6_addr)) == 0))
return 1;
break;
-#endif
case AF_INET:
if(GET_SS_FAMILY(srv) == GET_SS_FAMILY(inp))
if(v4->sin_port == v4in->sin_port)
(unsigned int)(cp[0]),
suffix == NULL ? "in-addr.arpa" : suffix);
}
-#ifdef RB_IPV6
else if (GET_SS_FAMILY(addr) == AF_INET6)
{
const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *)addr;
cp = (const unsigned char *)&v6->sin6_addr.s6_addr;
+#define HI_NIBBLE(x) (unsigned int)((x) >> 4)
+#define LO_NIBBLE(x) (unsigned int)((x) & 0xf)
+
(void) snprintf(buf, size,
"%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%s",
- (unsigned int)(cp[15] & 0xf), (unsigned int)(cp[15] >> 4),
- (unsigned int)(cp[14] & 0xf), (unsigned int)(cp[14] >> 4),
- (unsigned int)(cp[13] & 0xf), (unsigned int)(cp[13] >> 4),
- (unsigned int)(cp[12] & 0xf), (unsigned int)(cp[12] >> 4),
- (unsigned int)(cp[11] & 0xf), (unsigned int)(cp[11] >> 4),
- (unsigned int)(cp[10] & 0xf), (unsigned int)(cp[10] >> 4),
- (unsigned int)(cp[9] & 0xf), (unsigned int)(cp[9] >> 4),
- (unsigned int)(cp[8] & 0xf), (unsigned int)(cp[8] >> 4),
- (unsigned int)(cp[7] & 0xf), (unsigned int)(cp[7] >> 4),
- (unsigned int)(cp[6] & 0xf), (unsigned int)(cp[6] >> 4),
- (unsigned int)(cp[5] & 0xf), (unsigned int)(cp[5] >> 4),
- (unsigned int)(cp[4] & 0xf), (unsigned int)(cp[4] >> 4),
- (unsigned int)(cp[3] & 0xf), (unsigned int)(cp[3] >> 4),
- (unsigned int)(cp[2] & 0xf), (unsigned int)(cp[2] >> 4),
- (unsigned int)(cp[1] & 0xf), (unsigned int)(cp[1] >> 4),
- (unsigned int)(cp[0] & 0xf), (unsigned int)(cp[0] >> 4),
+ LO_NIBBLE(cp[15]), HI_NIBBLE(cp[15]),
+ LO_NIBBLE(cp[14]), HI_NIBBLE(cp[14]),
+ LO_NIBBLE(cp[13]), HI_NIBBLE(cp[13]),
+ LO_NIBBLE(cp[12]), HI_NIBBLE(cp[12]),
+ LO_NIBBLE(cp[11]), HI_NIBBLE(cp[11]),
+ LO_NIBBLE(cp[10]), HI_NIBBLE(cp[10]),
+ LO_NIBBLE(cp[9]), HI_NIBBLE(cp[9]),
+ LO_NIBBLE(cp[8]), HI_NIBBLE(cp[8]),
+ LO_NIBBLE(cp[7]), HI_NIBBLE(cp[7]),
+ LO_NIBBLE(cp[6]), HI_NIBBLE(cp[6]),
+ LO_NIBBLE(cp[5]), HI_NIBBLE(cp[5]),
+ LO_NIBBLE(cp[4]), HI_NIBBLE(cp[4]),
+ LO_NIBBLE(cp[3]), HI_NIBBLE(cp[3]),
+ LO_NIBBLE(cp[2]), HI_NIBBLE(cp[2]),
+ LO_NIBBLE(cp[1]), HI_NIBBLE(cp[1]),
+ LO_NIBBLE(cp[0]), HI_NIBBLE(cp[0]),
suffix == NULL ? "ip6.arpa" : suffix);
}
-#endif
+
+#undef HI_NIBBLE
+#undef LO_NIBBLE
}
/*
do_query_number(NULL, &request->addr, request);
break;
case T_A:
-#ifdef RB_IPV6
case T_AAAA:
-#endif
do_query_name(NULL, request->name, request, request->type);
break;
default:
int n; /* temp count */
int rd_length;
struct sockaddr_in *v4; /* conversion */
-#ifdef RB_IPV6
struct sockaddr_in6 *v6;
-#endif
current = (unsigned char *)buf + sizeof(HEADER);
for (; header->qdcount > 0; --header->qdcount)
v4->sin_family = AF_INET;
memcpy(&v4->sin_addr, current, sizeof(struct in_addr));
return (1);
-#ifdef RB_IPV6
case T_AAAA:
if (request->type != T_AAAA)
return (0);
v6->sin6_family = AF_INET6;
memcpy(&v6->sin6_addr, current, sizeof(struct in6_addr));
return (1);
-#endif
case T_PTR:
if (request->type != T_PTR)
return (0);
rb_strlcpy(request->name, hostbuf, IRCD_RES_HOSTLEN + 1);
return (1);
- case T_CNAME:
- /* real answer will follow */
- current += rd_length;
- break;
- default:
- break;
}
+ /* skip any other record type e.g. CNAME, DNAME; real answer should follow */
+ current += rd_length;
}
return (1);
* Lookup the 'authoritative' name that we were given for the
* ip#.
*/
-#ifdef RB_IPV6
if (GET_SS_FAMILY(&request->addr) == AF_INET6)
gethost_byname_type_fqdn(request->name, request->query, T_AAAA);
else
-#endif
gethost_byname_type_fqdn(request->name, request->query, T_A);
rem_request(request);
}