static void blacklist_dns_callback(const char *result, int status, int aftype, void *vptr)
{
struct BlacklistClient *blcptr = (struct BlacklistClient *) vptr;
- int listed = 0;
+ bool listed = false;
if (blcptr == NULL || blcptr->client_p == NULL)
return;
if (result != NULL && status)
{
if (blacklist_check_reply(blcptr, result))
- listed = TRUE;
+ listed = true;
}
/* they have a blacklist entry for this client */
blcptr->blacklist = blptr;
blcptr->client_p = client_p;
- if ((client_p->localClient->ip.ss_family == AF_INET) && blptr->ipv4)
+ /* IPv4 */
+ if ((GET_SS_FAMILY(&client_p->localClient->ip) == AF_INET) && blptr->ipv4)
{
ip = (uint8_t *)&((struct sockaddr_in *)&client_p->localClient->ip)->sin_addr.s_addr;
(unsigned int) ip[0],
blptr->host);
}
- /* IPv6 is supported now. --Elizabeth */
- else if ((client_p->localClient->ip.ss_family == AF_INET6) && blptr->ipv6)
+#ifdef RB_IPV6
+ /* IPv6 */
+ else if ((GET_SS_FAMILY(&client_p->localClient->ip) == AF_INET6) && blptr->ipv6)
{
- /* Breaks it into ip[0] = 0x00, ip[1] = 0x00... ip[16] = 0x01 for localhost
- * I wish there was a uint4_t for C, this would make the below cleaner, but... */
+ /* Split up for rDNS lookup
+ * ex: ip[0] = 0x00, ip[1] = 0x00... ip[16] = 0x01 for localhost
+ * Giving us:
+ * 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.foobl.invalid
+ * or something like that.
+ */
ip = (uint8_t *)&((struct sockaddr_in6 *)&client_p->localClient->ip)->sin6_addr.s6_addr;
char *bufptr = buf;
int i;
- /* The below will give us something like
- * 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.foobl.invalid
- */
-
/* Going backwards */
- for (i = 15; i >= 0; i--)
+ for (i = 15; i >= 0; i--, bufptr += 4)
{
- /* Get upper and lower nibbles (yes this works fine on
- * both big and little endian) */
+ /* Get upper and lower nibbles */
uint8_t hi = (ip[i] >> 4) & 0x0F;
uint8_t lo = ip[i] & 0x0F;
- /* One part... (why 5? rb_snprintf adds \0) */
+ /* One part... 4 chars + terminator */
snprintf(bufptr, 5, "%1x.%1x.",
(unsigned int) lo, /* Remember, backwards */
(unsigned int) hi);
-
- /* Lurch forward to next position */
- bufptr += 4;
}
/* Tack host on */
strcpy(bufptr, blptr->host);
}
+#endif
/* This shouldn't happen... */
else
return;