X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FIOHandler%2FIODNSLookup.c;h=36c1f044cd23b45ddfa62085d5368f234dbfbe17;hb=d2ac212695ab026aebc171d0d7c615f29c03a77c;hp=f458bf5ca033bf89e4f0eb4d264c8209a8539f3f;hpb=dd213e78a5e4f6b69cacb3e8fe1fb536795081da;p=NextIRCd.git diff --git a/src/IOHandler/IODNSLookup.c b/src/IOHandler/IODNSLookup.c index f458bf5..36c1f04 100644 --- a/src/IOHandler/IODNSLookup.c +++ b/src/IOHandler/IODNSLookup.c @@ -6,6 +6,7 @@ * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -21,6 +22,24 @@ #include "IOLog.h" #include "IOSockets.h" +#ifdef WIN32 +#ifdef _WIN32_WINNT +#undef _WIN32_WINNT +#endif +#define _WIN32_WINNT 0x501 +#include +#include +#include +#else +#include +#include +#include +#include +#include +#include +#endif +#include "compat/inet.h" + #include struct _IODNSQuery *iodnsquery_first = NULL; @@ -211,6 +230,23 @@ void iodns_abort(struct IODNSQuery *descriptor) { _stop_dnsquery(query); } +int iodns_print_address(struct IODNSAddress *address, int ipv6, char *buffer, int length) { + int af; + void *addr; + if(ipv6) { + af = AF_INET6; + addr = (void *)(&((struct sockaddr_in6 *)address->address)->sin6_addr); + } else { + af = AF_INET; + addr = (void *)(&((struct sockaddr_in *)address->address)->sin_addr); + } + buffer = (char*) inet_ntop(af, addr, buffer, length); + if(!buffer) + return 0; + else + return strlen(buffer); +} + void iodns_free_result(struct IODNSResult *result) { struct IODNSResult *next; for(;result;result = next) {