build_rdns: minor cleanup

This commit is contained in:
Elizabeth Myers 2016-06-27 18:37:46 -05:00
parent c12d9cd3b2
commit d52762b2a9
No known key found for this signature in database
GPG key ID: 1A10EF78D83E317B
2 changed files with 23 additions and 17 deletions

View file

@ -292,7 +292,6 @@ initiate_blacklist_dnsquery(struct blacklist *bl, struct auth_client *auth)
} }
build_rdns(buf, sizeof(buf), &auth->c_addr, bl->host); build_rdns(buf, sizeof(buf), &auth->c_addr, bl->host);
bllookup->query = lookup_ip(buf, AF_INET, blacklist_dns_callback, bllookup); bllookup->query = lookup_ip(buf, AF_INET, blacklist_dns_callback, bllookup);
rb_dlinkAdd(bllookup, &bllookup->node, &bluser->queries); rb_dlinkAdd(bllookup, &bllookup->node, &bluser->queries);

View file

@ -482,26 +482,33 @@ void build_rdns(char *buf, size_t size, const struct rb_sockaddr_storage *addr,
const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *)addr; const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *)addr;
cp = (const unsigned char *)&v6->sin6_addr.s6_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, (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", "%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), LO_NIBBLE(cp[15]), HI_NIBBLE(cp[15]),
(unsigned int)(cp[14] & 0xf), (unsigned int)(cp[14] >> 4), LO_NIBBLE(cp[14]), HI_NIBBLE(cp[14]),
(unsigned int)(cp[13] & 0xf), (unsigned int)(cp[13] >> 4), LO_NIBBLE(cp[13]), HI_NIBBLE(cp[13]),
(unsigned int)(cp[12] & 0xf), (unsigned int)(cp[12] >> 4), LO_NIBBLE(cp[12]), HI_NIBBLE(cp[12]),
(unsigned int)(cp[11] & 0xf), (unsigned int)(cp[11] >> 4), LO_NIBBLE(cp[11]), HI_NIBBLE(cp[11]),
(unsigned int)(cp[10] & 0xf), (unsigned int)(cp[10] >> 4), LO_NIBBLE(cp[10]), HI_NIBBLE(cp[10]),
(unsigned int)(cp[9] & 0xf), (unsigned int)(cp[9] >> 4), LO_NIBBLE(cp[9]), HI_NIBBLE(cp[9]),
(unsigned int)(cp[8] & 0xf), (unsigned int)(cp[8] >> 4), LO_NIBBLE(cp[8]), HI_NIBBLE(cp[8]),
(unsigned int)(cp[7] & 0xf), (unsigned int)(cp[7] >> 4), LO_NIBBLE(cp[7]), HI_NIBBLE(cp[7]),
(unsigned int)(cp[6] & 0xf), (unsigned int)(cp[6] >> 4), LO_NIBBLE(cp[6]), HI_NIBBLE(cp[6]),
(unsigned int)(cp[5] & 0xf), (unsigned int)(cp[5] >> 4), LO_NIBBLE(cp[5]), HI_NIBBLE(cp[5]),
(unsigned int)(cp[4] & 0xf), (unsigned int)(cp[4] >> 4), LO_NIBBLE(cp[4]), HI_NIBBLE(cp[4]),
(unsigned int)(cp[3] & 0xf), (unsigned int)(cp[3] >> 4), LO_NIBBLE(cp[3]), HI_NIBBLE(cp[3]),
(unsigned int)(cp[2] & 0xf), (unsigned int)(cp[2] >> 4), LO_NIBBLE(cp[2]), HI_NIBBLE(cp[2]),
(unsigned int)(cp[1] & 0xf), (unsigned int)(cp[1] >> 4), LO_NIBBLE(cp[1]), HI_NIBBLE(cp[1]),
(unsigned int)(cp[0] & 0xf), (unsigned int)(cp[0] >> 4), LO_NIBBLE(cp[0]), HI_NIBBLE(cp[0]),
suffix == NULL ? "ip6.arpa" : suffix); suffix == NULL ? "ip6.arpa" : suffix);
} }
#undef HI_NIBBLE
#undef LO_NIBBLE
#endif #endif
} }