From 61f1399c2faedb8f81695da6d65c2bf1448fdef8 Mon Sep 17 00:00:00 2001 From: Dominick Meglio Date: Sat, 9 Apr 2005 16:49:47 +0000 Subject: Made sortlist support CIDR matching for IPv4 --- ares_gethostbyname.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'ares_gethostbyname.c') diff --git a/ares_gethostbyname.c b/ares_gethostbyname.c index 92dc0c7..afd4c71 100644 --- a/ares_gethostbyname.c +++ b/ares_gethostbyname.c @@ -34,6 +34,7 @@ #include "ares.h" #include "ares_private.h" #include "inet_net_pton.h" +#include "bitncmp.h" #ifdef WATT32 #undef WIN32 @@ -189,10 +190,7 @@ static void end_hquery(struct host_query *hquery, int status, static int fake_hostent(const char *name, int family, ares_host_callback callback, void *arg) { - struct in_addr addr; - struct in6_addr addr6; struct hostent hostent; - const char *p; char *aliases[1] = { NULL }; char *addrs[2]; int result = 0; @@ -333,8 +331,12 @@ static int get_address_index(struct in_addr *addr, struct apattern *sortlist, for (i = 0; i < nsort; i++) { - if ((addr->s_addr & sortlist[i].mask.s_addr) == sortlist[i].addr.s_addr) - break; + if (sortlist[i].type = PATTERN_MASK) + if ((addr->s_addr & sortlist[i].mask.addr.s_addr) == sortlist[i].addr.s_addr) + break; + else + if (!ares_bitncmp(&addr->s_addr, &sortlist[i].addr.s_addr, sortlist[i].mask.bits)) + break; } return i; } -- cgit v1.2.3