Update c-ares [ci build]

This commit is contained in:
halx99 2021-04-24 23:34:41 +08:00
parent 578ab97d82
commit f53cfe4ebf
50 changed files with 726 additions and 2661 deletions

View File

@ -8,7 +8,7 @@ INCLUDE (CheckCSourceCompiles)
INCLUDE (CheckStructHasMember)
INCLUDE (CheckLibraryExists)
PROJECT (c-ares LANGUAGES C VERSION "1.16.1" )
PROJECT (c-ares LANGUAGES C VERSION "1.17.0" )
# Set this version before release
SET (CARES_VERSION "${PROJECT_VERSION}")
@ -26,7 +26,7 @@ INCLUDE (GNUInstallDirs) # include this *AFTER* PROJECT(), otherwise paths are w
# For example, a version of 4:0:2 would generate output such as:
# libname.so -> libname.so.2
# libname.so.2 -> libname.so.2.2.0
SET (CARES_LIB_VERSIONINFO "6:1:4")
SET (CARES_LIB_VERSIONINFO "6:2:4")
OPTION (CARES_STATIC "Build as a static library" OFF)
@ -37,10 +37,11 @@ OPTION (CARES_BUILD_TESTS "Build and run tests"
OPTION (CARES_BUILD_CONTAINER_TESTS "Build and run container tests (implies CARES_BUILD_TESTS, Linux only)" OFF)
OPTION (CARES_BUILD_TOOLS "Build tools" ON)
# Tests require static to be enabled
IF (CARES_BUILD_TESTS)
# Tests require static to be enabled on Windows to be able to access otherwise hidden symbols
IF (CARES_BUILD_TESTS AND (NOT CARES_STATIC) AND WIN32)
SET (CARES_STATIC ON)
SET (CARES_STATIC_PIC ON)
MESSAGE (WARNING "Static building was requested be disabled, but reenabled to support tests")
ENDIF ()
# allow linking against the static runtime library in msvc
@ -74,6 +75,7 @@ SET (PACKAGE_DIRECTORY ${PROJECT_BINARY_DIR}/package)
# Destinations for installing different kinds of targets (pass to install command).
SET (TARGETS_INST_DEST
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
@ -137,7 +139,7 @@ return 0;
MACOS_V1012)
ENDIF ()
IF ((IOS OR APPLE) AND HAVE_LIBRESOLV)
IF ((IOS OR APPLE OR ZOS) AND HAVE_LIBRESOLV)
SET (CARES_USE_LIBRESOLV 1)
ENDIF()
@ -166,7 +168,6 @@ CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
CHECK_INCLUDE_FILES (memory.h HAVE_MEMORY_H)
CHECK_INCLUDE_FILES (netdb.h HAVE_NETDB_H)
CHECK_INCLUDE_FILES (netinet/in.h HAVE_NETINET_IN_H)
CHECK_INCLUDE_FILES (netinet/tcp.h HAVE_NETINET_TCP_H)
CHECK_INCLUDE_FILES (net/if.h HAVE_NET_IF_H)
CHECK_INCLUDE_FILES (signal.h HAVE_SIGNAL_H)
CHECK_INCLUDE_FILES (socket.h HAVE_SOCKET_H)
@ -179,15 +180,20 @@ CHECK_INCLUDE_FILES (stropts.h HAVE_STROPTS_H)
CHECK_INCLUDE_FILES (sys/ioctl.h HAVE_SYS_IOCTL_H)
CHECK_INCLUDE_FILES (sys/param.h HAVE_SYS_PARAM_H)
CHECK_INCLUDE_FILES (sys/select.h HAVE_SYS_SELECT_H)
CHECK_INCLUDE_FILES (sys/socket.h HAVE_SYS_SOCKET_H)
CHECK_INCLUDE_FILES (sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILES (sys/time.h HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILES (sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES (sys/uio.h HAVE_SYS_UIO_H)
CHECK_INCLUDE_FILES (time.h HAVE_TIME_H)
CHECK_INCLUDE_FILES (dlfcn.h HAVE_DLFCN_H)
CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
# On OpenBSD, you must include sys/types.h before netinet/tcp.h
IF (HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES ("sys/types.h;netinet/tcp.h" HAVE_NETINET_TCP_H)
ELSE ()
CHECK_INCLUDE_FILES (netinet/tcp.h HAVE_NETINET_TCP_H)
ENDIF ()
# Include order matters for these windows files.
CHECK_INCLUDE_FILES ("winsock2.h;windows.h" HAVE_WINSOCK2_H)
CHECK_INCLUDE_FILES ("winsock2.h;ws2tcpip.h;windows.h" HAVE_WS2TCPIP_H)
@ -381,6 +387,10 @@ SET (CMAKE_REQUIRED_DEFINITIONS)
SET (CMAKE_REQUIRED_LIBRARIES)
find_file(CARES_RANDOM_FILE urandom /dev)
mark_as_advanced(CARES_RANDOM_FILE)
################################################################################
# recv, recvfrom, send, getnameinfo, gethostname
# ARGUMENTS AND RETURN VALUES

View File

@ -3,6 +3,6 @@ CONFIGURE_FILE (ares_build.h.cmake ${PROJECT_BINARY_DIR}/ares_build.h)
# Headers installation target
IF (CARES_INSTALL)
SET (CARES_HEADERS ares.h ares_version.h "${PROJECT_BINARY_DIR}/ares_build.h" ares_rules.h)
SET (CARES_HEADERS ares.h ares_version.h "${PROJECT_BINARY_DIR}/ares_build.h" ares_rules.h ares_dns.h)
INSTALL (FILES ${CARES_HEADERS} COMPONENT Devel DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
ENDIF ()

View File

@ -2,6 +2,6 @@ AUTOMAKE_OPTIONS = foreign nostdinc 1.9.6
ACLOCAL_AMFLAGS = -I m4 --install
# what headers to install on 'make install':
include_HEADERS = ares.h ares_version.h ares_build.h ares_rules.h
include_HEADERS = ares.h ares_version.h ares_build.h ares_rules.h ares_dns.h
EXTRA_DIST = ares_build.h.cmake ares_build.h.in ares_build.h.dist CMakeLists.txt

View File

@ -39,7 +39,7 @@
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \
defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \
defined(__QNXNTO__)
defined(__QNXNTO__) || defined(__MVS__)
#include <sys/select.h>
#endif
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))

View File

@ -16,6 +16,15 @@
* without express or implied warranty.
*/
/*
* NOTE TO INTEGRATORS:
*
* This header is made public due to legacy projects relying on it.
* Please do not use the macros within this header, or include this
* header in your project as it may be removed in the future.
*/
/*
* Macro DNS__16BIT reads a network short (16 bit) given in network
* byte order, and returns its value as an unsigned short.

View File

@ -6,12 +6,12 @@
#define ARES_COPYRIGHT "2004 - 2020 Daniel Stenberg, <daniel@haxx.se>."
#define ARES_VERSION_MAJOR 1
#define ARES_VERSION_MINOR 16
#define ARES_VERSION_PATCH 1
#define ARES_VERSION_MINOR 17
#define ARES_VERSION_PATCH 0
#define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\
(ARES_VERSION_MINOR<<8)|\
(ARES_VERSION_PATCH))
#define ARES_VERSION_STR "1.16.1"
#define ARES_VERSION_STR "1.17.0"
#if (ARES_VERSION >= 0x010700)
# define CARES_HAVE_ARES_LIBRARY_INIT 1

View File

@ -8,7 +8,8 @@ ACLOCAL_AMFLAGS = -I m4 --install
AM_CPPFLAGS = -I$(top_builddir)/include \
-I$(top_builddir)/src/lib \
-I$(top_srcdir)/include
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/lib
lib_LTLIBRARIES = libcares.la
@ -29,7 +30,7 @@ AM_LDFLAGS =
libcares_la_LDFLAGS_EXTRA =
if CARES_LT_SHLIB_USE_VERSION_INFO
libcares_la_LDFLAGS_EXTRA += $(CARES_VERSION_INFO)
libcares_la_LDFLAGS_EXTRA += -version-info @CARES_VERSION_INFO@
endif
if CARES_LT_SHLIB_USE_NO_UNDEFINED

View File

@ -58,7 +58,6 @@ CSOURCES = ares__close_sockets.c \
HHEADERS = ares_android.h \
ares_data.h \
ares_dns.h \
ares_getenv.h \
ares_inet_net_pton.h \
ares_iphlpapi.h \
@ -73,7 +72,7 @@ HHEADERS = ares_android.h \
ares_strsplit.h \
ares_writev.h \
bitncmp.h \
nameser.h \
ares_nameser.h \
ares_setup.h \
setup_once.h

View File

@ -24,14 +24,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#ifdef HAVE_STRINGS_H
# include <strings.h>

View File

@ -453,6 +453,10 @@ int ares__sortaddrinfo(ares_channel channel, struct ares_addrinfo_node *list_sen
++nelem;
cur = cur->ai_next;
}
if (!nelem)
return ARES_ENODATA;
elems = (struct addrinfo_sort_elem *)ares_malloc(
nelem * sizeof(struct addrinfo_sort_elem));
if (!elems)

View File

@ -347,7 +347,7 @@
#cmakedefine NEED_MEMORY_H
/* a suitable file/device to read random data from */
#cmakedefine RANDOM_FILE
#cmakedefine CARES_RANDOM_FILE "@CARES_RANDOM_FILE@"
/* Define to the type qualifier pointed by arg 5 for recvfrom. */
#define RECVFROM_QUAL_ARG5 @RECVFROM_QUAL_ARG5@

View File

@ -19,22 +19,13 @@
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_dns.h"
#include "ares_private.h"
#ifndef T_OPT
# define T_OPT 41 /* EDNS0 option (meta-RR) */
#endif
/* Header format, from RFC 1035:
* 1 1 1 1 1 1
@ -57,7 +48,7 @@
* of the remaining fields:
* ID Identifier to match responses with queries
* QR Query (0) or response (1)
* Opcode For our purposes, always QUERY
* Opcode For our purposes, always O_QUERY
* RD Recursion desired
* Z Reserved (zero)
* QDCOUNT Number of queries
@ -116,7 +107,7 @@ int ares_create_query(const char *name, int dnsclass, int type,
q = buf;
memset(q, 0, HFIXEDSZ);
DNS_HEADER_SET_QID(q, id);
DNS_HEADER_SET_OPCODE(q, QUERY);
DNS_HEADER_SET_OPCODE(q, O_QUERY);
if (rd) {
DNS_HEADER_SET_RD(q, 1);
}

View File

@ -19,14 +19,8 @@
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_nowarn.h"

View File

@ -19,11 +19,8 @@
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_private.h" /* for the memdebug */

View File

@ -31,11 +31,13 @@ void ares_free_hostent(struct hostent *host)
return;
ares_free((char *)(host->h_name));
for (p = host->h_aliases; *p; p++)
for (p = host->h_aliases; p && *p; p++)
ares_free(*p);
ares_free(host->h_aliases);
if (host->h_addr_list) {
ares_free(host->h_addr_list[0]); /* no matter if there is one or many entries,
there is only one malloc for all of them */
ares_free(host->h_addr_list);
}
ares_free(host);
}

View File

@ -51,6 +51,8 @@ void ares__freeaddrinfo_nodes(struct ares_addrinfo_node *head)
void ares_freeaddrinfo(struct ares_addrinfo *ai)
{
if (ai == NULL)
return;
ares__freeaddrinfo_cnames(ai->cnames);
ares__freeaddrinfo_nodes(ai->nodes);
ares_free(ai);

View File

@ -34,14 +34,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#ifdef HAVE_STRINGS_H
#include <strings.h>
@ -386,6 +380,9 @@ static int fake_addrinfo(const char *name,
}
}
node->ai_socktype = hints->ai_socktype;
node->ai_protocol = hints->ai_protocol;
callback(arg, ARES_SUCCESS, 0, ai);
return 1;
}
@ -396,7 +393,7 @@ static void end_hquery(struct host_query *hquery, int status)
struct ares_addrinfo_node *next;
if (status == ARES_SUCCESS)
{
if (!(hquery->hints.ai_flags & ARES_AI_NOSORT))
if (!(hquery->hints.ai_flags & ARES_AI_NOSORT) && hquery->ai->nodes)
{
sentinel.ai_next = hquery->ai->nodes;
ares__sortaddrinfo(hquery->channel, &sentinel);
@ -406,6 +403,8 @@ static void end_hquery(struct host_query *hquery, int status)
/* Set port into each address (resolved separately). */
while (next)
{
next->ai_socktype = hquery->hints.ai_socktype;
next->ai_protocol = hquery->hints.ai_protocol;
if (next->ai_family == AF_INET)
{
(CARES_INADDR_CAST(struct sockaddr_in *, next->ai_addr))->sin_port = htons(hquery->port);
@ -545,11 +544,6 @@ static void host_callback(void *arg, int status, int timeouts,
{
addinfostatus = ares__parse_into_addrinfo(abuf, alen, hquery->ai);
}
else if (status == ARES_EDESTRUCTION)
{
end_hquery(hquery, status);
return;
}
if (!hquery->remaining)
{
@ -567,6 +561,13 @@ static void host_callback(void *arg, int status, int timeouts,
{
next_lookup(hquery, status);
}
else if (status == ARES_EDESTRUCTION)
{
/* NOTE: Could also be ARES_EDESTRUCTION. We need to only call this
* once all queries (there can be multiple for getaddrinfo) are
* terminated. */
end_hquery(hquery, status);
}
else
{
end_hquery(hquery, status);

View File

@ -24,14 +24,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_inet_net_pton.h"

View File

@ -25,14 +25,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#ifdef HAVE_STRINGS_H
#include <strings.h>

View File

@ -31,14 +31,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#ifdef HAVE_NET_IF_H
#include <net/if.h>

View File

@ -33,14 +33,7 @@
#include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#if defined(ANDROID) || defined(__ANDROID__)
#include <sys/system_properties.h>
@ -1472,6 +1465,57 @@ static int init_by_resolv_conf(ares_channel channel)
/* Catch the case when all the above checks fail (which happens when there
is no network card or the cable is unplugged) */
status = ARES_EFILE;
#elif defined(__MVS__)
struct __res_state *res = 0;
int count4, count6;
__STATEEXTIPV6 *v6;
struct server_state *pserver
if (0 == res) {
int rc = res_init();
while (rc == -1 && h_errno == TRY_AGAIN) {
rc = res_init();
}
if (rc == -1) {
return ARES_ENOMEM;
}
res = __res();
}
v6 = res->__res_extIPv6;
count4 = res->nscount;
if (v6) {
count6 = v6->__stat_nscount;
} else {
count6 = 0;
}
nservers = count4 + count6;
servers = ares_malloc(nservers * sizeof(struct server_state));
if (!servers)
return ARES_ENOMEM;
memset(servers, 0, nservers * sizeof(struct server_state));
pserver = servers;
for (int i = 0; i < count4; ++i, ++pserver) {
struct sockaddr_in *addr_in = &(res->nsaddr_list[i]);
pserver->addr.addrV4.s_addr = addr_in->sin_addr.s_addr;
pserver->addr.family = AF_INET;
pserver->addr.udp_port = addr_in->sin_port;
pserver->addr.tcp_port = addr_in->sin_port;
}
for (int j = 0; j < count6; ++j, ++pserver) {
struct sockaddr_in6 *addr_in = &(v6->__stat_nsaddr_list[j]);
memcpy(&(pserver->addr.addr.addr6), &(addr_in->sin6_addr),
sizeof(addr_in->sin6_addr));
pserver->addr.family = AF_INET6;
pserver->addr.udp_port = addr_in->sin6_port;
pserver->addr.tcp_port = addr_in->sin6_port;
}
status = ARES_EOF;
#elif defined(__riscos__)
@ -1621,7 +1665,7 @@ static int init_by_resolv_conf(ares_channel channel)
int entries = 0;
while ((entries < MAXDNSRCH) && res.dnsrch[entries])
entries++;
if(entries) {
channel->domains = ares_malloc(entries * sizeof(char *));
if (!channel->domains) {
status = ARES_ENOMEM;
@ -1635,6 +1679,7 @@ static int init_by_resolv_conf(ares_channel channel)
}
}
}
}
if (channel->ndots == -1)
channel->ndots = res.ndots;
if (channel->tries == -1)
@ -2470,9 +2515,10 @@ static void randomize_key(unsigned char* key,int key_data_len)
randomized = 1;
}
#else /* !WIN32 */
#ifdef RANDOM_FILE
FILE *f = fopen(RANDOM_FILE, "rb");
#ifdef CARES_RANDOM_FILE
FILE *f = fopen(CARES_RANDOM_FILE, "rb");
if(f) {
setvbuf(f, NULL, _IONBF, 0);
counter = aresx_uztosi(fread(key, 1, key_data_len, f));
fclose(f);
}

View File

@ -40,13 +40,18 @@ static unsigned int ares_initialized;
static int ares_init_flags;
/* library-private global vars with visibility across the whole library */
/* Some systems may return either NULL or a valid pointer on malloc(0). c-ares should
* never call malloc(0) so lets return NULL so we're more likely to find an issue if it
* were to occur. */
static void *default_malloc(size_t size) { if (size == 0) { return NULL; } return malloc(size); }
#if defined(WIN32)
/* We need indirections to handle Windows DLL rules. */
static void *default_malloc(size_t size) { return malloc(size); }
static void *default_realloc(void *p, size_t size) { return realloc(p, size); }
static void default_free(void *p) { free(p); }
#else
# define default_malloc malloc
# define default_realloc realloc
# define default_free free
#endif

View File

@ -23,7 +23,7 @@
#ifdef USE_WINSOCK
#include <iphlpapi.h>
#include <ares_iphlpapi.h>
#include "ares_iphlpapi.h"
typedef DWORD (WINAPI *fpGetNetworkParams_t) (FIXED_INFO*, DWORD*);
typedef BOOLEAN (APIENTRY *fpSystemFunction036_t) (void*, ULONG);

482
external/c-ares/src/lib/ares_nameser.h vendored Normal file
View File

@ -0,0 +1,482 @@
#ifndef ARES_NAMESER_H
#define ARES_NAMESER_H
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
/* ============================================================================
* arpa/nameser.h may or may not provide ALL of the below defines, so check
* each one individually and set if not
* ============================================================================
*/
#ifndef NS_PACKETSZ
# define NS_PACKETSZ 512 /* maximum packet size */
#endif
#ifndef NS_MAXDNAME
# define NS_MAXDNAME 256 /* maximum domain name */
#endif
#ifndef NS_MAXCDNAME
# define NS_MAXCDNAME 255 /* maximum compressed domain name */
#endif
#ifndef NS_MAXLABEL
# define NS_MAXLABEL 63
#endif
#ifndef NS_HFIXEDSZ
# define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */
#endif
#ifndef NS_QFIXEDSZ
# define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */
#endif
#ifndef NS_RRFIXEDSZ
# define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
#endif
#ifndef NS_INT16SZ
# define NS_INT16SZ 2
#endif
#ifndef NS_INADDRSZ
# define NS_INADDRSZ 4
#endif
#ifndef NS_IN6ADDRSZ
# define NS_IN6ADDRSZ 16
#endif
#ifndef NS_CMPRSFLGS
# define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */
#endif
#ifndef NS_DEFAULTPORT
# define NS_DEFAULTPORT 53 /* For both TCP and UDP. */
#endif
/* ============================================================================
* arpa/nameser.h should provide these enumerations always, so if not found,
* provide them
* ============================================================================
*/
#ifndef HAVE_ARPA_NAMESER_H
typedef enum __ns_class {
ns_c_invalid = 0, /* Cookie. */
ns_c_in = 1, /* Internet. */
ns_c_2 = 2, /* unallocated/unsupported. */
ns_c_chaos = 3, /* MIT Chaos-net. */
ns_c_hs = 4, /* MIT Hesiod. */
/* Query class values which do not appear in resource records */
ns_c_none = 254, /* for prereq. sections in update requests */
ns_c_any = 255, /* Wildcard match. */
ns_c_max = 65536
} ns_class;
typedef enum __ns_type {
ns_t_invalid = 0, /* Cookie. */
ns_t_a = 1, /* Host address. */
ns_t_ns = 2, /* Authoritative server. */
ns_t_md = 3, /* Mail destination. */
ns_t_mf = 4, /* Mail forwarder. */
ns_t_cname = 5, /* Canonical name. */
ns_t_soa = 6, /* Start of authority zone. */
ns_t_mb = 7, /* Mailbox domain name. */
ns_t_mg = 8, /* Mail group member. */
ns_t_mr = 9, /* Mail rename name. */
ns_t_null = 10, /* Null resource record. */
ns_t_wks = 11, /* Well known service. */
ns_t_ptr = 12, /* Domain name pointer. */
ns_t_hinfo = 13, /* Host information. */
ns_t_minfo = 14, /* Mailbox information. */
ns_t_mx = 15, /* Mail routing information. */
ns_t_txt = 16, /* Text strings. */
ns_t_rp = 17, /* Responsible person. */
ns_t_afsdb = 18, /* AFS cell database. */
ns_t_x25 = 19, /* X_25 calling address. */
ns_t_isdn = 20, /* ISDN calling address. */
ns_t_rt = 21, /* Router. */
ns_t_nsap = 22, /* NSAP address. */
ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */
ns_t_sig = 24, /* Security signature. */
ns_t_key = 25, /* Security key. */
ns_t_px = 26, /* X.400 mail mapping. */
ns_t_gpos = 27, /* Geographical position (withdrawn). */
ns_t_aaaa = 28, /* Ip6 Address. */
ns_t_loc = 29, /* Location Information. */
ns_t_nxt = 30, /* Next domain (security). */
ns_t_eid = 31, /* Endpoint identifier. */
ns_t_nimloc = 32, /* Nimrod Locator. */
ns_t_srv = 33, /* Server Selection. */
ns_t_atma = 34, /* ATM Address */
ns_t_naptr = 35, /* Naming Authority PoinTeR */
ns_t_kx = 36, /* Key Exchange */
ns_t_cert = 37, /* Certification record */
ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */
ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */
ns_t_sink = 40, /* Kitchen sink (experimentatl) */
ns_t_opt = 41, /* EDNS0 option (meta-RR) */
ns_t_apl = 42, /* Address prefix list (RFC3123) */
ns_t_ds = 43, /* Delegation Signer (RFC4034) */
ns_t_sshfp = 44, /* SSH Key Fingerprint (RFC4255) */
ns_t_rrsig = 46, /* Resource Record Signature (RFC4034) */
ns_t_nsec = 47, /* Next Secure (RFC4034) */
ns_t_dnskey = 48, /* DNS Public Key (RFC4034) */
ns_t_tkey = 249, /* Transaction key */
ns_t_tsig = 250, /* Transaction signature. */
ns_t_ixfr = 251, /* Incremental zone transfer. */
ns_t_axfr = 252, /* Transfer zone of authority. */
ns_t_mailb = 253, /* Transfer mailbox records. */
ns_t_maila = 254, /* Transfer mail agent records. */
ns_t_any = 255, /* Wildcard match. */
ns_t_zxfr = 256, /* BIND-specific, nonstandard. */
ns_t_caa = 257, /* Certification Authority Authorization. */
ns_t_max = 65536
} ns_type;
typedef enum __ns_opcode {
ns_o_query = 0, /* Standard query. */
ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */
ns_o_status = 2, /* Name server status query (unsupported). */
/* Opcode 3 is undefined/reserved. */
ns_o_notify = 4, /* Zone change notification. */
ns_o_update = 5, /* Zone update message. */
ns_o_max = 6
} ns_opcode;
typedef enum __ns_rcode {
ns_r_noerror = 0, /* No error occurred. */
ns_r_formerr = 1, /* Format error. */
ns_r_servfail = 2, /* Server failure. */
ns_r_nxdomain = 3, /* Name error. */
ns_r_notimpl = 4, /* Unimplemented. */
ns_r_refused = 5, /* Operation refused. */
/* these are for BIND_UPDATE */
ns_r_yxdomain = 6, /* Name exists */
ns_r_yxrrset = 7, /* RRset exists */
ns_r_nxrrset = 8, /* RRset does not exist */
ns_r_notauth = 9, /* Not authoritative for zone */
ns_r_notzone = 10, /* Zone of record different from zone section */
ns_r_max = 11,
/* The following are TSIG extended errors */
ns_r_badsig = 16,
ns_r_badkey = 17,
ns_r_badtime = 18
} ns_rcode;
#endif /* HAVE_ARPA_NAMESER_H */
/* ============================================================================
* arpa/nameser_compat.h typically sets these. However on some systems
* arpa/nameser.h does, but may not set all of them. Lets conditionally
* define each
* ============================================================================
*/
#ifndef PACKETSZ
# define PACKETSZ NS_PACKETSZ
#endif
#ifndef MAXDNAME
# define MAXDNAME NS_MAXDNAME
#endif
#ifndef MAXCDNAME
# define MAXCDNAME NS_MAXCDNAME
#endif
#ifndef MAXLABEL
# define MAXLABEL NS_MAXLABEL
#endif
#ifndef HFIXEDSZ
# define HFIXEDSZ NS_HFIXEDSZ
#endif
#ifndef QFIXEDSZ
# define QFIXEDSZ NS_QFIXEDSZ
#endif
#ifndef RRFIXEDSZ
# define RRFIXEDSZ NS_RRFIXEDSZ
#endif
#ifndef INDIR_MASK
# define INDIR_MASK NS_CMPRSFLGS
#endif
#ifndef NAMESERVER_PORT
# define NAMESERVER_PORT NS_DEFAULTPORT
#endif
/* opcodes */
#ifndef O_QUERY
# define O_QUERY 0 /* ns_o_query */
#endif
#ifndef O_IQUERY
# define O_IQUERY 1 /* ns_o_iquery */
#endif
#ifndef O_STATUS
# define O_STATUS 2 /* ns_o_status */
#endif
#ifndef O_NOTIFY
# define O_NOTIFY 4 /* ns_o_notify */
#endif
#ifndef O_UPDATE
# define O_UPDATE 5 /* ns_o_update */
#endif
/* response codes */
#ifndef SERVFAIL
# define SERVFAIL ns_r_servfail
#endif
#ifndef NOTIMP
# define NOTIMP ns_r_notimpl
#endif
#ifndef REFUSED
# define REFUSED ns_r_refused
#endif
#if defined(_WIN32) && !defined(HAVE_ARPA_NAMESER_COMPAT_H) && defined(NOERROR)
# undef NOERROR /* it seems this is already defined in winerror.h */
#endif
#ifndef NOERROR
# define NOERROR ns_r_noerror
#endif
#ifndef FORMERR
# define FORMERR ns_r_formerr
#endif
#ifndef NXDOMAIN
# define NXDOMAIN ns_r_nxdomain
#endif
/* Non-standard response codes, use numeric values */
#ifndef YXDOMAIN
# define YXDOMAIN 6 /* ns_r_yxdomain */
#endif
#ifndef YXRRSET
# define YXRRSET 7 /* ns_r_yxrrset */
#endif
#ifndef NXRRSET
# define NXRRSET 8 /* ns_r_nxrrset */
#endif
#ifndef NOTAUTH
# define NOTAUTH 9 /* ns_r_notauth */
#endif
#ifndef NOTZONE
# define NOTZONE 10 /* ns_r_notzone */
#endif
#ifndef TSIG_BADSIG
# define TSIG_BADSIG 16 /* ns_r_badsig */
#endif
#ifndef TSIG_BADKEY
# define TSIG_BADKEY 17 /* ns_r_badkey */
#endif
#ifndef TSIG_BADTIME
# define TSIG_BADTIME 18 /* ns_r_badtime */
#endif
/* classes */
#ifndef C_IN
# define C_IN 1 /* ns_c_in */
#endif
#ifndef C_CHAOS
# define C_CHAOS 3 /* ns_c_chaos */
#endif
#ifndef C_HS
# define C_HS 4 /* ns_c_hs */
#endif
#ifndef C_NONE
# define C_NONE 254 /* ns_c_none */
#endif
#ifndef C_ANY
# define C_ANY 255 /* ns_c_any */
#endif
/* types */
#ifndef T_A
# define T_A 1 /* ns_t_a */
#endif
#ifndef T_NS
# define T_NS 2 /* ns_t_ns */
#endif
#ifndef T_MD
# define T_MD 3 /* ns_t_md */
#endif
#ifndef T_MF
# define T_MF 4 /* ns_t_mf */
#endif
#ifndef T_CNAME
# define T_CNAME 5 /* ns_t_cname */
#endif
#ifndef T_SOA
# define T_SOA 6 /* ns_t_soa */
#endif
#ifndef T_MB
# define T_MB 7 /* ns_t_mb */
#endif
#ifndef T_MG
# define T_MG 8 /* ns_t_mg */
#endif
#ifndef T_MR
# define T_MR 9 /* ns_t_mr */
#endif
#ifndef T_NULL
# define T_NULL 10 /* ns_t_null */
#endif
#ifndef T_WKS
# define T_WKS 11 /* ns_t_wks */
#endif
#ifndef T_PTR
# define T_PTR 12 /* ns_t_ptr */
#endif
#ifndef T_HINFO
# define T_HINFO 13 /* ns_t_hinfo */
#endif
#ifndef T_MINFO
# define T_MINFO 14 /* ns_t_minfo */
#endif
#ifndef T_MX
# define T_MX 15 /* ns_t_mx */
#endif
#ifndef T_TXT
# define T_TXT 16 /* ns_t_txt */
#endif
#ifndef T_RP
# define T_RP 17 /* ns_t_rp */
#endif
#ifndef T_AFSDB
# define T_AFSDB 18 /* ns_t_afsdb */
#endif
#ifndef T_X25
# define T_X25 19 /* ns_t_x25 */
#endif
#ifndef T_ISDN
# define T_ISDN 20 /* ns_t_isdn */
#endif
#ifndef T_RT
# define T_RT 21 /* ns_t_rt */
#endif
#ifndef T_NSAP
# define T_NSAP 22 /* ns_t_nsap */
#endif
#ifndef T_NSAP_PTR
# define T_NSAP_PTR 23 /* ns_t_nsap_ptr */
#endif
#ifndef T_SIG
# define T_SIG 24 /* ns_t_sig */
#endif
#ifndef T_KEY
# define T_KEY 25 /* ns_t_key */
#endif
#ifndef T_PX
# define T_PX 26 /* ns_t_px */
#endif
#ifndef T_GPOS
# define T_GPOS 27 /* ns_t_gpos */
#endif
#ifndef T_AAAA
# define T_AAAA 28 /* ns_t_aaaa */
#endif
#ifndef T_LOC
# define T_LOC 29 /* ns_t_loc */
#endif
#ifndef T_NXT
# define T_NXT 30 /* ns_t_nxt */
#endif
#ifndef T_EID
# define T_EID 31 /* ns_t_eid */
#endif
#ifndef T_NIMLOC
# define T_NIMLOC 32 /* ns_t_nimloc */
#endif
#ifndef T_SRV
# define T_SRV 33 /* ns_t_srv */
#endif
#ifndef T_ATMA
# define T_ATMA 34 /* ns_t_atma */
#endif
#ifndef T_NAPTR
# define T_NAPTR 35 /* ns_t_naptr */
#endif
#ifndef T_KX
# define T_KX 36 /* ns_t_kx */
#endif
#ifndef T_CERT
# define T_CERT 37 /* ns_t_cert */
#endif
#ifndef T_A6
# define T_A6 38 /* ns_t_a6 */
#endif
#ifndef T_DNAME
# define T_DNAME 39 /* ns_t_dname */
#endif
#ifndef T_SINK
# define T_SINK 40 /* ns_t_sink */
#endif
#ifndef T_OPT
# define T_OPT 41 /* ns_t_opt */
#endif
#ifndef T_APL
# define T_APL 42 /* ns_t_apl */
#endif
#ifndef T_DS
# define T_DS 43 /* ns_t_ds */
#endif
#ifndef T_SSHFP
# define T_SSHFP 44 /* ns_t_sshfp */
#endif
#ifndef T_RRSIG
# define T_RRSIG 46 /* ns_t_rrsig */
#endif
#ifndef T_NSEC
# define T_NSEC 47 /* ns_t_nsec */
#endif
#ifndef T_DNSKEY
# define T_DNSKEY 48 /* ns_t_dnskey */
#endif
#ifndef T_TKEY
# define T_TKEY 249 /* ns_t_tkey */
#endif
#ifndef T_TSIG
# define T_TSIG 250 /* ns_t_tsig */
#endif
#ifndef T_IXFR
# define T_IXFR 251 /* ns_t_ixfr */
#endif
#ifndef T_AXFR
# define T_AXFR 252 /* ns_t_axfr */
#endif
#ifndef T_MAILB
# define T_MAILB 253 /* ns_t_mailb */
#endif
#ifndef T_MAILA
# define T_MAILA 254 /* ns_t_maila */
#endif
#ifndef T_ANY
# define T_ANY 255 /* ns_t_any */
#endif
#ifndef T_ZXFR
# define T_ZXFR 256 /* ns_t_zxfr */
#endif
#ifndef T_CAA
# define T_CAA 257 /* ns_t_caa */
#endif
#ifndef T_MAX
# define T_MAX 65536 /* ns_t_max */
#endif
#endif /* ARES_NAMESER_H */

View File

@ -26,14 +26,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#ifdef HAVE_STRINGS_H
# include <strings.h>

View File

@ -27,14 +27,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#ifdef HAVE_STRINGS_H
# include <strings.h>

View File

@ -25,14 +25,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#ifdef HAVE_STRINGS_H
# include <strings.h>
@ -43,10 +37,6 @@
#include "ares_data.h"
#include "ares_private.h"
#ifndef T_CAA
# define T_CAA 257 /* Certification Authority Authorization */
#endif
int
ares_parse_caa_reply (const unsigned char *abuf, int alen,
struct ares_caa_reply **caa_out)

View File

@ -26,14 +26,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_dns.h"

View File

@ -26,25 +26,14 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_dns.h"
#include "ares_data.h"
#include "ares_private.h"
/* AIX portability check */
#ifndef T_NAPTR
#define T_NAPTR 35 /* naming authority pointer */
#endif
int
ares_parse_naptr_reply (const unsigned char *abuf, int alen,
struct ares_naptr_reply **naptr_out)

View File

@ -29,14 +29,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_dns.h"

View File

@ -22,14 +22,8 @@
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#ifdef HAVE_STRINGS_H
# include <strings.h>
@ -48,7 +42,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
long len;
const unsigned char *aptr;
char *ptrname, *hostname, *rr_name, *rr_data;
struct hostent *hostent;
struct hostent *hostent = NULL;
int aliascnt = 0;
int alias_alloc = 8;
char ** aliases;
@ -175,19 +169,34 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
status = ARES_ENODATA;
if (status == ARES_SUCCESS)
{
/* If we don't reach the end, we must have failed due to out of memory */
status = ARES_ENOMEM;
/* We got our answer. Allocate memory to build the host entry. */
hostent = ares_malloc(sizeof(struct hostent));
if (hostent)
{
hostent = ares_malloc(sizeof(*hostent));
if (!hostent)
goto fail;
/* If we don't memset here, cleanups may fail */
memset(hostent, 0, sizeof(*hostent));
hostent->h_addr_list = ares_malloc(2 * sizeof(char *));
if (hostent->h_addr_list)
{
if (!hostent->h_addr_list)
goto fail;
if (addr && addrlen) {
hostent->h_addr_list[0] = ares_malloc(addrlen);
if (hostent->h_addr_list[0])
{
if (!hostent->h_addr_list[0])
goto fail;
} else {
hostent->h_addr_list[0] = NULL;
}
hostent->h_aliases = ares_malloc((aliascnt+1) * sizeof (char *));
if (hostent->h_aliases)
{
if (!hostent->h_aliases)
goto fail;
/* Fill in the hostent and return successfully. */
hostent->h_name = hostname;
for (i=0 ; i<aliascnt ; i++)
@ -195,21 +204,19 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
hostent->h_aliases[aliascnt] = NULL;
hostent->h_addrtype = aresx_sitoss(family);
hostent->h_length = aresx_sitoss(addrlen);
if (addr && addrlen)
memcpy(hostent->h_addr_list[0], addr, addrlen);
hostent->h_addr_list[1] = NULL;
*host = hostent;
ares_free(aliases);
ares_free(ptrname);
return ARES_SUCCESS;
}
ares_free(hostent->h_addr_list[0]);
}
ares_free(hostent->h_addr_list);
}
ares_free(hostent);
}
status = ARES_ENOMEM;
}
fail:
ares_free_hostent(hostent);
for (i=0 ; i<aliascnt ; i++)
if (aliases[i])
ares_free(aliases[i]);

View File

@ -26,14 +26,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_dns.h"

View File

@ -26,25 +26,14 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_dns.h"
#include "ares_data.h"
#include "ares_private.h"
/* AIX portability check */
#ifndef T_SRV
# define T_SRV 33 /* server selection */
#endif
int
ares_parse_srv_reply (const unsigned char *abuf, int alen,
struct ares_srv_reply **srv_out)

View File

@ -26,14 +26,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#ifdef HAVE_STRINGS_H
# include <strings.h>

View File

@ -32,14 +32,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "nameser.h"
#include "ares_nameser.h"
#ifdef HAVE_STRINGS_H
# include <strings.h>

View File

@ -19,14 +19,8 @@
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_dns.h"

View File

@ -19,14 +19,8 @@
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_dns.h"

View File

@ -178,8 +178,11 @@
/*
* Android does have the arpa/nameser.h header which is detected by configure
* but it appears to be empty with recent NDK r7b / r7c, so we undefine here.
* z/OS does have the arpa/nameser.h header which is detected by configure
* but it is not fully implemented and missing identifiers, so udefine here.
*/
#if (defined(ANDROID) || defined(__ANDROID__)) && defined(HAVE_ARPA_NAMESER_H)
#if (defined(ANDROID) || defined(__ANDROID__) || defined(__MVS__)) && \
defined(HAVE_ARPA_NAMESER_H)
# undef HAVE_ARPA_NAMESER_H
#endif

View File

@ -13,6 +13,10 @@
* without express or implied warranty.
*/
#if defined(__MVS__)
#include <strings.h>
#endif
#include "ares_setup.h"
#include "ares_strsplit.h"
#include "ares.h"

View File

@ -24,14 +24,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_ipv6.h"

View File

@ -23,14 +23,8 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares_nameser.h"
#include "ares.h"
#include "ares_ipv6.h"

View File

@ -1,218 +0,0 @@
#ifndef ARES_NAMESER_H
#define ARES_NAMESER_H
/* header file provided by liren@vivisimo.com */
#ifndef HAVE_ARPA_NAMESER_H
#define NS_PACKETSZ 512 /* maximum packet size */
#define NS_MAXDNAME 256 /* maximum domain name */
#define NS_MAXCDNAME 255 /* maximum compressed domain name */
#define NS_MAXLABEL 63
#define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */
#define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */
#define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
#define NS_INT16SZ 2
#define NS_INADDRSZ 4
#define NS_IN6ADDRSZ 16
#define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */
#define NS_DEFAULTPORT 53 /* For both TCP and UDP. */
typedef enum __ns_class {
ns_c_invalid = 0, /* Cookie. */
ns_c_in = 1, /* Internet. */
ns_c_2 = 2, /* unallocated/unsupported. */
ns_c_chaos = 3, /* MIT Chaos-net. */
ns_c_hs = 4, /* MIT Hesiod. */
/* Query class values which do not appear in resource records */
ns_c_none = 254, /* for prereq. sections in update requests */
ns_c_any = 255, /* Wildcard match. */
ns_c_max = 65536
} ns_class;
typedef enum __ns_type {
ns_t_invalid = 0, /* Cookie. */
ns_t_a = 1, /* Host address. */
ns_t_ns = 2, /* Authoritative server. */
ns_t_md = 3, /* Mail destination. */
ns_t_mf = 4, /* Mail forwarder. */
ns_t_cname = 5, /* Canonical name. */
ns_t_soa = 6, /* Start of authority zone. */
ns_t_mb = 7, /* Mailbox domain name. */
ns_t_mg = 8, /* Mail group member. */
ns_t_mr = 9, /* Mail rename name. */
ns_t_null = 10, /* Null resource record. */
ns_t_wks = 11, /* Well known service. */
ns_t_ptr = 12, /* Domain name pointer. */
ns_t_hinfo = 13, /* Host information. */
ns_t_minfo = 14, /* Mailbox information. */
ns_t_mx = 15, /* Mail routing information. */
ns_t_txt = 16, /* Text strings. */
ns_t_rp = 17, /* Responsible person. */
ns_t_afsdb = 18, /* AFS cell database. */
ns_t_x25 = 19, /* X_25 calling address. */
ns_t_isdn = 20, /* ISDN calling address. */
ns_t_rt = 21, /* Router. */
ns_t_nsap = 22, /* NSAP address. */
ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */
ns_t_sig = 24, /* Security signature. */
ns_t_key = 25, /* Security key. */
ns_t_px = 26, /* X.400 mail mapping. */
ns_t_gpos = 27, /* Geographical position (withdrawn). */
ns_t_aaaa = 28, /* Ip6 Address. */
ns_t_loc = 29, /* Location Information. */
ns_t_nxt = 30, /* Next domain (security). */
ns_t_eid = 31, /* Endpoint identifier. */
ns_t_nimloc = 32, /* Nimrod Locator. */
ns_t_srv = 33, /* Server Selection. */
ns_t_atma = 34, /* ATM Address */
ns_t_naptr = 35, /* Naming Authority PoinTeR */
ns_t_kx = 36, /* Key Exchange */
ns_t_cert = 37, /* Certification record */
ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */
ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */
ns_t_sink = 40, /* Kitchen sink (experimentatl) */
ns_t_opt = 41, /* EDNS0 option (meta-RR) */
ns_t_apl = 42, /* Address prefix list (RFC3123) */
ns_t_ds = 43, /* Delegation Signer (RFC4034) */
ns_t_sshfp = 44, /* SSH Key Fingerprint (RFC4255) */
ns_t_rrsig = 46, /* Resource Record Signature (RFC4034) */
ns_t_nsec = 47, /* Next Secure (RFC4034) */
ns_t_dnskey = 48, /* DNS Public Key (RFC4034) */
ns_t_tkey = 249, /* Transaction key */
ns_t_tsig = 250, /* Transaction signature. */
ns_t_ixfr = 251, /* Incremental zone transfer. */
ns_t_axfr = 252, /* Transfer zone of authority. */
ns_t_mailb = 253, /* Transfer mailbox records. */
ns_t_maila = 254, /* Transfer mail agent records. */
ns_t_any = 255, /* Wildcard match. */
ns_t_zxfr = 256, /* BIND-specific, nonstandard. */
ns_t_caa = 257, /* Certification Authority Authorization. */
ns_t_max = 65536
} ns_type;
typedef enum __ns_opcode {
ns_o_query = 0, /* Standard query. */
ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */
ns_o_status = 2, /* Name server status query (unsupported). */
/* Opcode 3 is undefined/reserved. */
ns_o_notify = 4, /* Zone change notification. */
ns_o_update = 5, /* Zone update message. */
ns_o_max = 6
} ns_opcode;
typedef enum __ns_rcode {
ns_r_noerror = 0, /* No error occurred. */
ns_r_formerr = 1, /* Format error. */
ns_r_servfail = 2, /* Server failure. */
ns_r_nxdomain = 3, /* Name error. */
ns_r_notimpl = 4, /* Unimplemented. */
ns_r_refused = 5, /* Operation refused. */
/* these are for BIND_UPDATE */
ns_r_yxdomain = 6, /* Name exists */
ns_r_yxrrset = 7, /* RRset exists */
ns_r_nxrrset = 8, /* RRset does not exist */
ns_r_notauth = 9, /* Not authoritative for zone */
ns_r_notzone = 10, /* Zone of record different from zone section */
ns_r_max = 11,
/* The following are TSIG extended errors */
ns_r_badsig = 16,
ns_r_badkey = 17,
ns_r_badtime = 18
} ns_rcode;
#endif /* HAVE_ARPA_NAMESER_H */
#ifndef HAVE_ARPA_NAMESER_COMPAT_H
#define PACKETSZ NS_PACKETSZ
#define MAXDNAME NS_MAXDNAME
#define MAXCDNAME NS_MAXCDNAME
#define MAXLABEL NS_MAXLABEL
#define HFIXEDSZ NS_HFIXEDSZ
#define QFIXEDSZ NS_QFIXEDSZ
#define RRFIXEDSZ NS_RRFIXEDSZ
#define INDIR_MASK NS_CMPRSFLGS
#define NAMESERVER_PORT NS_DEFAULTPORT
#define QUERY ns_o_query
#define SERVFAIL ns_r_servfail
#define NOTIMP ns_r_notimpl
#define REFUSED ns_r_refused
#undef NOERROR /* it seems this is already defined in winerror.h */
#define NOERROR ns_r_noerror
#define FORMERR ns_r_formerr
#define NXDOMAIN ns_r_nxdomain
#define C_IN ns_c_in
#define C_CHAOS ns_c_chaos
#define C_HS ns_c_hs
#define C_NONE ns_c_none
#define C_ANY ns_c_any
#define T_A ns_t_a
#define T_NS ns_t_ns
#define T_MD ns_t_md
#define T_MF ns_t_mf
#define T_CNAME ns_t_cname
#define T_SOA ns_t_soa
#define T_MB ns_t_mb
#define T_MG ns_t_mg
#define T_MR ns_t_mr
#define T_NULL ns_t_null
#define T_WKS ns_t_wks
#define T_PTR ns_t_ptr
#define T_HINFO ns_t_hinfo
#define T_MINFO ns_t_minfo
#define T_MX ns_t_mx
#define T_TXT ns_t_txt
#define T_RP ns_t_rp
#define T_AFSDB ns_t_afsdb
#define T_X25 ns_t_x25
#define T_ISDN ns_t_isdn
#define T_RT ns_t_rt
#define T_NSAP ns_t_nsap
#define T_NSAP_PTR ns_t_nsap_ptr
#define T_SIG ns_t_sig
#define T_KEY ns_t_key
#define T_PX ns_t_px
#define T_GPOS ns_t_gpos
#define T_AAAA ns_t_aaaa
#define T_LOC ns_t_loc
#define T_NXT ns_t_nxt
#define T_EID ns_t_eid
#define T_NIMLOC ns_t_nimloc
#define T_SRV ns_t_srv
#define T_ATMA ns_t_atma
#define T_NAPTR ns_t_naptr
#define T_KX ns_t_kx
#define T_CERT ns_t_cert
#define T_A6 ns_t_a6
#define T_DNAME ns_t_dname
#define T_SINK ns_t_sink
#define T_OPT ns_t_opt
#define T_APL ns_t_apl
#define T_DS ns_t_ds
#define T_SSHFP ns_t_sshfp
#define T_RRSIG ns_t_rrsig
#define T_NSEC ns_t_nsec
#define T_DNSKEY ns_t_dnskey
#define T_TKEY ns_t_tkey
#define T_TSIG ns_t_tsig
#define T_IXFR ns_t_ixfr
#define T_AXFR ns_t_axfr
#define T_MAILB ns_t_mailb
#define T_MAILA ns_t_maila
#define T_CAA ns_t_caa
#define T_ANY ns_t_any
#endif /* HAVE_ARPA_NAMESER_COMPAT_H */
/* Android's bionic arpa/nameser_compat.h, nor glibc versions prior to 2.25 have T_OPT defined */
#ifndef T_OPT
# define T_OPT ns_t_opt
#endif
#endif /* ARES_NAMESER_H */

View File

@ -1,55 +0,0 @@
IF (CARES_BUILD_TOOLS)
# Transform Makefile.inc
transform_makefile_inc("Makefile.inc" "${PROJECT_BINARY_DIR}/src/tools/Makefile.inc.cmake")
include(${PROJECT_BINARY_DIR}/src/tools/Makefile.inc.cmake)
# Build ahost
ADD_EXECUTABLE (ahost ahost.c ${SAMPLESOURCES})
TARGET_INCLUDE_DIRECTORIES (ahost
PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/lib>"
"$<BUILD_INTERFACE:${CARES_TOPLEVEL_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}"
)
TARGET_COMPILE_DEFINITIONS (ahost PRIVATE HAVE_CONFIG_H=1)
TARGET_LINK_LIBRARIES (ahost PRIVATE ${PROJECT_NAME})
IF (CARES_INSTALL)
INSTALL (TARGETS ahost COMPONENT Tools ${TARGETS_INST_DEST})
ENDIF ()
# Build adig
ADD_EXECUTABLE (adig adig.c ${SAMPLESOURCES})
TARGET_INCLUDE_DIRECTORIES (adig
PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/lib>"
"$<BUILD_INTERFACE:${CARES_TOPLEVEL_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}"
)
TARGET_COMPILE_DEFINITIONS (adig PRIVATE HAVE_CONFIG_H=1)
TARGET_LINK_LIBRARIES (adig PRIVATE ${PROJECT_NAME})
IF (CARES_INSTALL)
INSTALL (TARGETS adig COMPONENT Tools ${TARGETS_INST_DEST})
ENDIF ()
# Build acountry
ADD_EXECUTABLE (acountry acountry.c ${SAMPLESOURCES})
TARGET_INCLUDE_DIRECTORIES (acountry
PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/lib>"
"$<BUILD_INTERFACE:${CARES_TOPLEVEL_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}"
)
TARGET_COMPILE_DEFINITIONS (acountry PRIVATE HAVE_CONFIG_H=1)
TARGET_LINK_LIBRARIES (acountry PRIVATE ${PROJECT_NAME})
IF (CARES_INSTALL)
INSTALL (TARGETS acountry COMPONENT Tools ${TARGETS_INST_DEST})
ENDIF ()
ENDIF ()

View File

@ -1,32 +0,0 @@
AUTOMAKE_OPTIONS = foreign subdir-objects nostdinc 1.9.6
PROGS = ahost adig acountry
EXTRA_DIST = CMakeLists.txt Makefile.inc
noinst_PROGRAMS =$(PROGS)
# Specify our include paths here, and do it relative to $(top_srcdir) and
# $(top_builddir), to ensure that these paths which belong to the library
# being currently built and tested are searched before the library which
# might possibly already be installed in the system.
AM_CPPFLAGS = -I$(top_builddir)/include \
-I$(top_builddir)/src/lib \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/lib
include Makefile.inc
LDADD = $(top_builddir)/src/lib/libcares.la
ahost_SOURCES = ahost.c $(SAMPLESOURCES) $(SAMPLEHEADERS)
ahost_CFLAGS = $(AM_CFLAGS)
ahost_CPPFLAGS = $(AM_CPPFLAGS)
adig_SOURCES = adig.c $(SAMPLESOURCES) $(SAMPLEHEADERS)
adig_CFLAGS = $(AM_CFLAGS)
adig_CPPFLAGS = $(AM_CPPFLAGS)
acountry_SOURCES = acountry.c $(SAMPLESOURCES) $(SAMPLEHEADERS)
acountry_CFLAGS = $(AM_CFLAGS)
acountry_CPPFLAGS = $(AM_CPPFLAGS)

View File

@ -1,7 +0,0 @@
SAMPLESOURCES = ares_getopt.c \
../lib/ares_nowarn.c \
../lib/ares_strcasecmp.c
SAMPLEHEADERS = ares_getopt.h \
../lib/ares_nowarn.h \
../lib/ares_strcasecmp.h

View File

@ -1,652 +0,0 @@
/*
*
* IP-address/hostname to country converter.
*
* Problem; you want to know where IP a.b.c.d is located.
*
* Use ares_gethostbyname ("d.c.b.a.zz.countries.nerd.dk")
* and get the CNAME (host->h_name). Result will be:
* CNAME = zz<CC>.countries.nerd.dk with address 127.0.x.y (ver 1) or
* CNAME = <a.b.c.d>.zz.countries.nerd.dk with address 127.0.x.y (ver 2)
*
* The 2 letter country code is in <CC> and the ISO-3166 country
* number is in x.y (number = x*256 + y). Version 2 of the protocol is missing
* the <CC> number.
*
* Ref: http://countries.nerd.dk/more.html
*
* Written by G. Vanem <gvanem@yahoo.no> 2006, 2007
*
* NB! This program may not be big-endian aware.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#include "ares_setup.h"
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#if defined(WIN32) && !defined(WATT32)
#include <winsock.h>
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#endif
#include "ares.h"
#include "ares_getopt.h"
#include "ares_nowarn.h"
#ifndef HAVE_STRDUP
# include "ares_strdup.h"
# define strdup(ptr) ares_strdup(ptr)
#endif
#ifndef HAVE_STRCASECMP
# include "ares_strcasecmp.h"
# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
#endif
#ifndef HAVE_STRNCASECMP
# include "ares_strcasecmp.h"
# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
#endif
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
/* By using a double cast, we can get rid of the bogus warning of
* warning: cast from 'const struct sockaddr *' to 'const struct sockaddr_in6 *' increases required alignment from 1 to 4 [-Wcast-align]
*/
#define CARES_INADDR_CAST(type, var) ((type)((void *)var))
static const char *usage = "acountry [-?hdv] {host|addr} ...\n";
static const char nerd_fmt[] = "%u.%u.%u.%u.zz.countries.nerd.dk";
static const char *nerd_ver1 = nerd_fmt + 14; /* .countries.nerd.dk */
static const char *nerd_ver2 = nerd_fmt + 11; /* .zz.countries.nerd.dk */
static int verbose = 0;
#define TRACE(fmt) do { \
if (verbose > 0) \
printf fmt ; \
} WHILE_FALSE
static void wait_ares(ares_channel channel);
static void callback(void *arg, int status, int timeouts, struct hostent *host);
static void callback2(void *arg, int status, int timeouts, struct hostent *host);
static void find_country_from_cname(const char *cname, struct in_addr addr);
static void print_help_info_acountry(void);
static void Abort(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
exit(1);
}
int main(int argc, char **argv)
{
ares_channel channel;
int ch, status;
#if defined(WIN32) && !defined(WATT32)
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
WSADATA wsaData;
WSAStartup(wVersionRequested, &wsaData);
#endif
status = ares_library_init(ARES_LIB_INIT_ALL);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_library_init: %s\n", ares_strerror(status));
return 1;
}
while ((ch = ares_getopt(argc, argv, "dvh?")) != -1)
switch (ch)
{
case 'd':
#ifdef WATT32
dbug_init();
#endif
break;
case 'v':
verbose++;
break;
case 'h':
print_help_info_acountry();
break;
case '?':
print_help_info_acountry();
break;
default:
Abort(usage);
}
argc -= optind;
argv += optind;
if (argc < 1)
Abort(usage);
status = ares_init(&channel);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_init: %s\n", ares_strerror(status));
return 1;
}
/* Initiate the queries, one per command-line argument. */
for ( ; *argv; argv++)
{
struct in_addr addr;
char buf[100];
/* If this fails, assume '*argv' is a host-name that
* must be resolved first
*/
if (ares_inet_pton(AF_INET, *argv, &addr) != 1)
{
ares_gethostbyname(channel, *argv, AF_INET, callback2, &addr);
wait_ares(channel);
if (addr.s_addr == INADDR_NONE)
{
printf("Failed to lookup %s\n", *argv);
continue;
}
}
sprintf(buf, nerd_fmt,
(unsigned int)(addr.s_addr >> 24),
(unsigned int)((addr.s_addr >> 16) & 255),
(unsigned int)((addr.s_addr >> 8) & 255),
(unsigned int)(addr.s_addr & 255));
TRACE(("Looking up %s...", buf));
fflush(stdout);
ares_gethostbyname(channel, buf, AF_INET, callback, buf);
}
wait_ares(channel);
ares_destroy(channel);
ares_library_cleanup();
#if defined(WIN32) && !defined(WATT32)
WSACleanup();
#endif
return 0;
}
/*
* Wait for the queries to complete.
*/
static void wait_ares(ares_channel channel)
{
for (;;)
{
struct timeval *tvp, tv;
fd_set read_fds, write_fds;
int nfds;
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
nfds = ares_fds(channel, &read_fds, &write_fds);
if (nfds == 0)
break;
tvp = ares_timeout(channel, NULL, &tv);
nfds = select(nfds, &read_fds, &write_fds, NULL, tvp);
if (nfds < 0)
continue;
ares_process(channel, &read_fds, &write_fds);
}
}
/*
* This is the callback used when we have the IP-address of interest.
* Extract the CNAME and figure out the country-code from it.
*/
static void callback(void *arg, int status, int timeouts, struct hostent *host)
{
const char *name = (const char*)arg;
const char *cname;
char buf[20];
(void)timeouts;
if (!host || status != ARES_SUCCESS)
{
printf("Failed to lookup %s: %s\n", name, ares_strerror(status));
return;
}
TRACE(("\nFound address %s, name %s\n",
ares_inet_ntop(AF_INET,(const char*)host->h_addr,buf,sizeof(buf)),
host->h_name));
cname = host->h_name; /* CNAME gets put here */
if (!cname)
printf("Failed to get CNAME for %s\n", name);
else
find_country_from_cname(cname, *(CARES_INADDR_CAST(struct in_addr *, host->h_addr)));
}
/*
* This is the callback used to obtain the IP-address of the host of interest.
*/
static void callback2(void *arg, int status, int timeouts, struct hostent *host)
{
struct in_addr *addr = (struct in_addr*) arg;
(void)timeouts;
if (!host || status != ARES_SUCCESS)
memset(addr, INADDR_NONE, sizeof(*addr));
else
memcpy(addr, host->h_addr, sizeof(*addr));
}
struct search_list {
int country_number; /* ISO-3166 country number */
char short_name[3]; /* A2 short country code */
const char *long_name; /* normal country name */
};
static const struct search_list *list_lookup(int number, const struct search_list *list, int num)
{
while (num > 0 && list->long_name)
{
if (list->country_number == number)
return (list);
num--;
list++;
}
return (NULL);
}
/*
* Ref: https://en.wikipedia.org/wiki/ISO_3166-1
*/
static const struct search_list country_list[] = {
{ 4, "af", "Afghanistan" },
{ 248, "ax", "Åland Island" },
{ 8, "al", "Albania" },
{ 12, "dz", "Algeria" },
{ 16, "as", "American Samoa" },
{ 20, "ad", "Andorra" },
{ 24, "ao", "Angola" },
{ 660, "ai", "Anguilla" },
{ 10, "aq", "Antarctica" },
{ 28, "ag", "Antigua & Barbuda" },
{ 32, "ar", "Argentina" },
{ 51, "am", "Armenia" },
{ 533, "aw", "Aruba" },
{ 36, "au", "Australia" },
{ 40, "at", "Austria" },
{ 31, "az", "Azerbaijan" },
{ 44, "bs", "Bahamas" },
{ 48, "bh", "Bahrain" },
{ 50, "bd", "Bangladesh" },
{ 52, "bb", "Barbados" },
{ 112, "by", "Belarus" },
{ 56, "be", "Belgium" },
{ 84, "bz", "Belize" },
{ 204, "bj", "Benin" },
{ 60, "bm", "Bermuda" },
{ 64, "bt", "Bhutan" },
{ 68, "bo", "Bolivia" },
{ 535, "bq", "Bonaire, Sint Eustatius and Saba" }, /* Formerly 'Bonaire' / 'Netherlands Antilles' */
{ 70, "ba", "Bosnia & Herzegovina" },
{ 72, "bw", "Botswana" },
{ 74, "bv", "Bouvet Island" },
{ 76, "br", "Brazil" },
{ 86, "io", "British Indian Ocean Territory" },
{ 96, "bn", "Brunei Darussalam" },
{ 100, "bg", "Bulgaria" },
{ 854, "bf", "Burkina Faso" },
{ 108, "bi", "Burundi" },
{ 116, "kh", "Cambodia" },
{ 120, "cm", "Cameroon" },
{ 124, "ca", "Canada" },
{ 132, "cv", "Cape Verde" },
{ 136, "ky", "Cayman Islands" },
{ 140, "cf", "Central African Republic" },
{ 148, "td", "Chad" },
{ 152, "cl", "Chile" },
{ 156, "cn", "China" },
{ 162, "cx", "Christmas Island" },
{ 166, "cc", "Cocos Islands" },
{ 170, "co", "Colombia" },
{ 174, "km", "Comoros" },
{ 178, "cg", "Congo" },
{ 180, "cd", "Congo" },
{ 184, "ck", "Cook Islands" },
{ 188, "cr", "Costa Rica" },
{ 384, "ci", "Cote d'Ivoire" },
{ 191, "hr", "Croatia" },
{ 192, "cu", "Cuba" },
{ 531, "cw", "Curaçao" },
{ 196, "cy", "Cyprus" },
{ 203, "cz", "Czech Republic" },
{ 208, "dk", "Denmark" },
{ 262, "dj", "Djibouti" },
{ 212, "dm", "Dominica" },
{ 214, "do", "Dominican Republic" },
{ 218, "ec", "Ecuador" },
{ 818, "eg", "Egypt" },
{ 222, "sv", "El Salvador" },
{ 226, "gq", "Equatorial Guinea" },
{ 232, "er", "Eritrea" },
{ 233, "ee", "Estonia" },
{ 748, "sz", "Eswatini" }, /* Formerly Swaziland */
{ 231, "et", "Ethiopia" },
{ 65281, "eu", "European Union" }, /* 127.0.255.1 */
{ 238, "fk", "Falkland Islands" },
{ 234, "fo", "Faroe Islands" },
{ 242, "fj", "Fiji" },
{ 246, "fi", "Finland" },
{ 250, "fr", "France" },
{ 249, "fx", "France, Metropolitan" },
{ 254, "gf", "French Guiana" },
{ 258, "pf", "French Polynesia" },
{ 260, "tf", "French Southern Territories" },
{ 266, "ga", "Gabon" },
{ 270, "gm", "Gambia" },
{ 268, "ge", "Georgia" },
{ 276, "de", "Germany" },
{ 288, "gh", "Ghana" },
{ 292, "gi", "Gibraltar" },
{ 300, "gr", "Greece" },
{ 304, "gl", "Greenland" },
{ 308, "gd", "Grenada" },
{ 312, "gp", "Guadeloupe" },
{ 316, "gu", "Guam" },
{ 320, "gt", "Guatemala" },
{ 831, "gg", "Guernsey" },
{ 324, "gn", "Guinea" },
{ 624, "gw", "Guinea-Bissau" },
{ 328, "gy", "Guyana" },
{ 332, "ht", "Haiti" },
{ 334, "hm", "Heard & Mc Donald Islands" },
{ 336, "va", "Holy See" }, /* Vatican City */
{ 340, "hn", "Honduras" },
{ 344, "hk", "Hong kong" },
{ 348, "hu", "Hungary" },
{ 352, "is", "Iceland" },
{ 356, "in", "India" },
{ 360, "id", "Indonesia" },
{ 364, "ir", "Iran" },
{ 368, "iq", "Iraq" },
{ 372, "ie", "Ireland" },
{ 833, "im", "Isle of Man" },
{ 376, "il", "Israel" },
{ 380, "it", "Italy" },
{ 388, "jm", "Jamaica" },
{ 392, "jp", "Japan" },
{ 832, "je", "Jersey" },
{ 400, "jo", "Jordan" },
{ 398, "kz", "Kazakhstan" },
{ 404, "ke", "Kenya" },
{ 296, "ki", "Kiribati" },
{ 408, "kp", "Korea (north)" },
{ 410, "kr", "Korea (south)" },
{ 0, "xk", "Kosovo" }, /* https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 */
{ 414, "kw", "Kuwait" },
{ 417, "kg", "Kyrgyzstan" },
{ 418, "la", "Laos" },
{ 428, "lv", "Latvia" },
{ 422, "lb", "Lebanon" },
{ 426, "ls", "Lesotho" },
{ 430, "lr", "Liberia" },
{ 434, "ly", "Libya" },
{ 438, "li", "Liechtenstein" },
{ 440, "lt", "Lithuania" },
{ 442, "lu", "Luxembourg" },
{ 446, "mo", "Macao" },
{ 450, "mg", "Madagascar" },
{ 454, "mw", "Malawi" },
{ 458, "my", "Malaysia" },
{ 462, "mv", "Maldives" },
{ 466, "ml", "Mali" },
{ 470, "mt", "Malta" },
{ 584, "mh", "Marshall Islands" },
{ 474, "mq", "Martinique" },
{ 478, "mr", "Mauritania" },
{ 480, "mu", "Mauritius" },
{ 175, "yt", "Mayotte" },
{ 484, "mx", "Mexico" },
{ 583, "fm", "Micronesia" },
{ 498, "md", "Moldova" },
{ 492, "mc", "Monaco" },
{ 496, "mn", "Mongolia" },
{ 499, "me", "Montenegro" },
{ 500, "ms", "Montserrat" },
{ 504, "ma", "Morocco" },
{ 508, "mz", "Mozambique" },
{ 104, "mm", "Myanmar" },
{ 516, "na", "Namibia" },
{ 520, "nr", "Nauru" },
{ 524, "np", "Nepal" },
{ 528, "nl", "Netherlands" },
{ 540, "nc", "New Caledonia" },
{ 554, "nz", "New Zealand" },
{ 558, "ni", "Nicaragua" },
{ 562, "ne", "Niger" },
{ 566, "ng", "Nigeria" },
{ 570, "nu", "Niue" },
{ 574, "nf", "Norfolk Island" },
{ 807, "mk", "North Macedonia" }, /* 'Macedonia' until February 2019 */
{ 580, "mp", "Northern Mariana Islands" },
{ 578, "no", "Norway" },
{ 512, "om", "Oman" },
{ 586, "pk", "Pakistan" },
{ 585, "pw", "Palau" },
{ 275, "ps", "Palestinian Territory" },
{ 591, "pa", "Panama" },
{ 598, "pg", "Papua New Guinea" },
{ 600, "py", "Paraguay" },
{ 604, "pe", "Peru" },
{ 608, "ph", "Philippines" },
{ 612, "pn", "Pitcairn" },
{ 616, "pl", "Poland" },
{ 620, "pt", "Portugal" },
{ 630, "pr", "Puerto Rico" },
{ 634, "qa", "Qatar" },
{ 638, "re", "Reunion" },
{ 642, "ro", "Romania" },
{ 643, "ru", "Russian Federation" },
{ 646, "rw", "Rwanda" },
{ 0, "bl", "Saint Barthélemy" }, /* https://en.wikipedia.org/wiki/ISO_3166-2:BL */
{ 659, "kn", "Saint Kitts & Nevis" },
{ 662, "lc", "Saint Lucia" },
{ 663, "mf", "Saint Martin" },
{ 670, "vc", "Saint Vincent" },
{ 882, "ws", "Samoa" },
{ 674, "sm", "San Marino" },
{ 678, "st", "Sao Tome & Principe" },
{ 682, "sa", "Saudi Arabia" },
{ 686, "sn", "Senegal" },
{ 688, "rs", "Serbia" },
{ 690, "sc", "Seychelles" },
{ 694, "sl", "Sierra Leone" },
{ 702, "sg", "Singapore" },
{ 534, "sx", "Sint Maarten" },
{ 703, "sk", "Slovakia" },
{ 705, "si", "Slovenia" },
{ 90, "sb", "Solomon Islands" },
{ 706, "so", "Somalia" },
{ 710, "za", "South Africa" },
{ 239, "gs", "South Georgia & South Sandwich Is." },
{ 728, "ss", "South Sudan" },
{ 724, "es", "Spain" },
{ 144, "lk", "Sri Lanka" },
{ 654, "sh", "St. Helena" },
{ 666, "pm", "St. Pierre & Miquelon" },
{ 736, "sd", "Sudan" },
{ 740, "sr", "Suriname" },
{ 744, "sj", "Svalbard & Jan Mayen Islands" },
{ 752, "se", "Sweden" },
{ 756, "ch", "Switzerland" },
{ 760, "sy", "Syrian Arab Republic" },
{ 158, "tw", "Taiwan" },
{ 762, "tj", "Tajikistan" },
{ 834, "tz", "Tanzania" },
{ 764, "th", "Thailand" },
{ 626, "tl", "Timor-Leste" },
{ 768, "tg", "Togo" },
{ 772, "tk", "Tokelau" },
{ 776, "to", "Tonga" },
{ 780, "tt", "Trinidad & Tobago" },
{ 788, "tn", "Tunisia" },
{ 792, "tr", "Turkey" },
{ 795, "tm", "Turkmenistan" },
{ 796, "tc", "Turks & Caicos Islands" },
{ 798, "tv", "Tuvalu" },
{ 800, "ug", "Uganda" },
{ 804, "ua", "Ukraine" },
{ 784, "ae", "United Arab Emirates" },
{ 826, "gb", "United Kingdom" },
{ 840, "us", "United States" },
{ 581, "um", "United States Minor Outlying Islands" },
{ 858, "uy", "Uruguay" },
{ 860, "uz", "Uzbekistan" },
{ 548, "vu", "Vanuatu" },
{ 862, "ve", "Venezuela" },
{ 704, "vn", "Vietnam" },
{ 92, "vg", "Virgin Islands (British)" },
{ 850, "vi", "Virgin Islands (US)" },
{ 876, "wf", "Wallis & Futuna Islands" },
{ 732, "eh", "Western Sahara" },
{ 887, "ye", "Yemen" },
{ 894, "zm", "Zambia" },
{ 716, "zw", "Zimbabwe" }
};
/*
* Check if start of 'str' is simply an IPv4 address.
*/
#define BYTE_OK(x) ((x) >= 0 && (x) <= 255)
static int is_addr(char *str, char **end)
{
int a0, a1, a2, a3, num, rc = 0, length = 0;
num = sscanf(str,"%3d.%3d.%3d.%3d%n",&a0,&a1,&a2,&a3,&length);
if( (num == 4) &&
BYTE_OK(a0) && BYTE_OK(a1) && BYTE_OK(a2) && BYTE_OK(a3) &&
length >= (3+4))
{
rc = 1;
*end = str + length;
}
return rc;
}
/*
* Find the country-code and name from the CNAME. E.g.:
* version 1: CNAME = zzno.countries.nerd.dk with address 127.0.2.66
* yields ccode_A" = "no" and cnumber 578 (2.66).
* version 2: CNAME = <a.b.c.d>.zz.countries.nerd.dk with address 127.0.2.66
* yields cnumber 578 (2.66). ccode_A is "";
*/
static void find_country_from_cname(const char *cname, struct in_addr addr)
{
const struct search_list *country;
char ccode_A2[3], *ccopy, *dot_4;
int cnumber, z0, z1, ver_1, ver_2;
unsigned long ip;
ip = ntohl(addr.s_addr);
z0 = TOLOWER(cname[0]);
z1 = TOLOWER(cname[1]);
ccopy = strdup(cname);
dot_4 = NULL;
ver_1 = (z0 == 'z' && z1 == 'z' && !strcasecmp(cname+4,nerd_ver1));
ver_2 = (is_addr(ccopy,&dot_4) && !strcasecmp(dot_4,nerd_ver2));
if (ver_1)
{
const char *dot = strchr(cname, '.');
if (dot != cname+4)
{
printf("Unexpected CNAME %s (ver_1)\n", cname);
free(ccopy);
return;
}
}
else if (ver_2)
{
z0 = TOLOWER(dot_4[1]);
z1 = TOLOWER(dot_4[2]);
if (z0 != 'z' && z1 != 'z')
{
printf("Unexpected CNAME %s (ver_2)\n", cname);
free(ccopy);
return;
}
}
else
{
printf("Unexpected CNAME %s (ver?)\n", cname);
free(ccopy);
return;
}
if (ver_1)
{
ccode_A2[0] = (char)TOLOWER(cname[2]);
ccode_A2[1] = (char)TOLOWER(cname[3]);
ccode_A2[2] = '\0';
}
else
ccode_A2[0] = '\0';
cnumber = ip & 0xFFFF;
TRACE(("Found country-code `%s', number %d\n",
ver_1 ? ccode_A2 : "<n/a>", cnumber));
country = list_lookup(cnumber, country_list,
sizeof(country_list) / sizeof(country_list[0]));
if (!country)
printf("Name for country-number %d not found.\n", cnumber);
else
{
if (ver_1)
{
if ((country->short_name[0] != ccode_A2[0]) ||
(country->short_name[1] != ccode_A2[1]) ||
(country->short_name[2] != ccode_A2[2]))
printf("short-name mismatch; %s vs %s\n",
country->short_name, ccode_A2);
}
printf("%s (%s), number %d.\n",
country->long_name, country->short_name, cnumber);
}
free(ccopy);
}
/* Information from the man page. Formatting taken from man -h */
static void print_help_info_acountry(void) {
printf("acountry, version %s \n\n", ARES_VERSION_STR);
printf("usage: acountry [-hdv] {host|addr} ...\n\n"
" d : Print some extra debugging output.\n"
" h : Display this help and exit.\n"
" v : Be more verbose. Print extra information.\n\n");
exit(0);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,231 +0,0 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#include "ares_setup.h"
#if !defined(WIN32) || defined(WATT32)
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include "ares.h"
#include "ares_dns.h"
#include "ares_getopt.h"
#include "ares_ipv6.h"
#include "ares_nowarn.h"
#ifndef HAVE_STRDUP
# include "ares_strdup.h"
# define strdup(ptr) ares_strdup(ptr)
#endif
#ifndef HAVE_STRCASECMP
# include "ares_strcasecmp.h"
# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
#endif
#ifndef HAVE_STRNCASECMP
# include "ares_strcasecmp.h"
# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
#endif
static void callback(void *arg, int status, int timeouts, struct hostent *host);
static void usage(void);
static void print_help_info_ahost(void);
int main(int argc, char **argv)
{
struct ares_options options;
int optmask = 0;
ares_channel channel;
int status, nfds, c, addr_family = AF_INET;
fd_set read_fds, write_fds;
struct timeval *tvp, tv;
struct in_addr addr4;
struct ares_in6_addr addr6;
#ifdef USE_WINSOCK
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
WSADATA wsaData;
WSAStartup(wVersionRequested, &wsaData);
#endif
memset(&options, 0, sizeof(options));
status = ares_library_init(ARES_LIB_INIT_ALL);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_library_init: %s\n", ares_strerror(status));
return 1;
}
while ((c = ares_getopt(argc,argv,"dt:h?s:")) != -1)
{
switch (c)
{
case 'd':
#ifdef WATT32
dbug_init();
#endif
break;
case 's':
optmask |= ARES_OPT_DOMAINS;
options.ndomains++;
options.domains = (char **)realloc(options.domains,
options.ndomains * sizeof(char *));
options.domains[options.ndomains - 1] = strdup(optarg);
break;
case 't':
if (!strcasecmp(optarg,"a"))
addr_family = AF_INET;
else if (!strcasecmp(optarg,"aaaa"))
addr_family = AF_INET6;
else if (!strcasecmp(optarg,"u"))
addr_family = AF_UNSPEC;
else
usage();
break;
case 'h':
print_help_info_ahost();
break;
case '?':
print_help_info_ahost();
break;
default:
usage();
break;
}
}
argc -= optind;
argv += optind;
if (argc < 1)
usage();
status = ares_init_options(&channel, &options, optmask);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_init: %s\n", ares_strerror(status));
return 1;
}
/* Initiate the queries, one per command-line argument. */
for ( ; *argv; argv++)
{
if (ares_inet_pton(AF_INET, *argv, &addr4) == 1)
{
ares_gethostbyaddr(channel, &addr4, sizeof(addr4), AF_INET, callback,
*argv);
}
else if (ares_inet_pton(AF_INET6, *argv, &addr6) == 1)
{
ares_gethostbyaddr(channel, &addr6, sizeof(addr6), AF_INET6, callback,
*argv);
}
else
{
ares_gethostbyname(channel, *argv, addr_family, callback, *argv);
}
}
/* Wait for all queries to complete. */
for (;;)
{
int res;
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
nfds = ares_fds(channel, &read_fds, &write_fds);
if (nfds == 0)
break;
tvp = ares_timeout(channel, NULL, &tv);
res = select(nfds, &read_fds, &write_fds, NULL, tvp);
if (-1 == res)
break;
ares_process(channel, &read_fds, &write_fds);
}
ares_destroy(channel);
ares_library_cleanup();
#ifdef USE_WINSOCK
WSACleanup();
#endif
return 0;
}
static void callback(void *arg, int status, int timeouts, struct hostent *host)
{
char **p;
(void)timeouts;
if (status != ARES_SUCCESS)
{
fprintf(stderr, "%s: %s\n", (char *) arg, ares_strerror(status));
return;
}
for (p = host->h_addr_list; *p; p++)
{
char addr_buf[46] = "??";
ares_inet_ntop(host->h_addrtype, *p, addr_buf, sizeof(addr_buf));
printf("%-32s\t%s", host->h_name, addr_buf);
#if 0
if (host->h_aliases[0])
{
int i;
printf (", Aliases: ");
for (i = 0; host->h_aliases[i]; i++)
printf("%s ", host->h_aliases[i]);
}
#endif
puts("");
}
}
static void usage(void)
{
fprintf(stderr, "usage: ahost [-h] [-d] [-s {domain}] [-t {a|aaaa|u}] {host|addr} ...\n");
exit(1);
}
/* Information from the man page. Formatting taken from man -h */
static void print_help_info_ahost(void) {
printf("ahost, version %s \n\n", ARES_VERSION_STR);
printf("usage: ahost [-h] [-d] [-s {domain}] [-t {a|aaaa|u}] {host|addr} ...\n\n"
" d : Print some extra debugging output.\n"
" h : Display this help and exit.\n\n"
" s domain : Specify the domain to search instead of \n"
" using the default values from \n"
" /etc/resolv.conf. This option only has an \n"
" effect on platforms that use /etc/resolv.conf\n"
" for DNS configuration; it has no effect on other\n"
" platforms (such as Win32 or Android).\n"
" t type : If type is \"a\", print the A record (default).\n"
" If type is \"aaaa\", print the AAAA record. If\n"
" type is \"u\", look for either AAAA or A record\n"
" (in that order).\n\n");
exit(0);
}

View File

@ -1,122 +0,0 @@
/*
* Original file name getopt.c Initial import into the c-ares source tree
* on 2007-04-11. Lifted from version 5.2 of the 'Open Mash' project with
* the modified BSD license, BSD license without the advertising clause.
*
*/
/*
* getopt.c --
*
* Standard UNIX getopt function. Code is from BSD.
*
* Copyright (c) 1987-2001 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* A. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* B. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* C. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* #if !defined(lint)
* static char sccsid[] = "@(#)getopt.c 8.2 (Berkeley) 4/2/94";
* #endif
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ares_getopt.h"
int opterr = 1, /* if error message should be printed */
optind = 1; /* index into parent argv vector */
int optopt = 0; /* character checked for validity */
static int optreset; /* reset getopt */
char *optarg; /* argument associated with option */
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG (char *)""
/*
* ares_getopt --
* Parse argc/argv argument vector.
*/
int
ares_getopt(int nargc, char * const nargv[], const char *ostr)
{
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc || *(place = nargv[optind]) != '-') {
place = EMSG;
return (EOF);
}
if (place[1] && *++place == '-') { /* found "--" */
++optind;
place = EMSG;
return (EOF);
}
} /* option letter okay? */
if ((optopt = (int)*place++) == (int)':' ||
(oli = strchr(ostr, optopt)) == NULL) {
/*
* if the user didn't specify '-' as an option,
* assume it means EOF.
*/
if (optopt == (int)'-')
return (EOF);
if (!*place)
++optind;
if (opterr && *ostr != ':')
(void)fprintf(stderr,
"%s: illegal option -- %c\n", __FILE__, optopt);
return (BADCH);
}
if (*++oli != ':') { /* don't need argument */
optarg = NULL;
if (!*place)
++optind;
}
else { /* need an argument */
if (*place) /* no white space */
optarg = place;
else if (nargc <= ++optind) { /* no arg */
place = EMSG;
if (*ostr == ':')
return (BADARG);
if (opterr)
(void)fprintf(stderr,
"%s: option requires an argument -- %c\n",
__FILE__, optopt);
return (BADCH);
}
else /* white space */
optarg = nargv[optind];
place = EMSG;
++optind;
}
return (optopt); /* dump back option letter */
}

View File

@ -1,53 +0,0 @@
#ifndef ARES_GETOPT_H
#define ARES_GETOPT_H
/*
* Copyright (c) 1987-2001 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* A. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* B. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* C. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
int ares_getopt(int nargc, char * const nargv[], const char *ostr);
#undef optarg
#undef optind
#undef opterr
#undef optopt
#undef optreset
#define optarg ares_optarg
#define optind ares_optind
#define opterr ares_opterr
#define optopt ares_optopt
#define optreset ares_optreset
extern char *optarg;
extern int optind;
extern int opterr;
extern int optopt;
#endif /* ARES_GETOPT_H */