diff options
author | Dominick Meglio <dcm5151@esu.edu> | 2005-04-09 16:49:47 +0000 |
---|---|---|
committer | Dominick Meglio <dcm5151@esu.edu> | 2005-04-09 16:49:47 +0000 |
commit | 61f1399c2faedb8f81695da6d65c2bf1448fdef8 (patch) | |
tree | 73ddd1c0a03de19cfd0759bb206adc7f7d4b30c5 /ares_gethostbyname.c | |
parent | 00b7a550b5f226f577966163747a28989bed5c32 (diff) | |
download | c-ares-61f1399c2faedb8f81695da6d65c2bf1448fdef8.tar.gz c-ares-61f1399c2faedb8f81695da6d65c2bf1448fdef8.tar.bz2 c-ares-61f1399c2faedb8f81695da6d65c2bf1448fdef8.zip |
Made sortlist support CIDR matching for IPv4
Diffstat (limited to 'ares_gethostbyname.c')
-rw-r--r-- | ares_gethostbyname.c | 12 |
1 files changed, 7 insertions, 5 deletions
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; } |