Update libuv to revision ee599ec1141cc48f895de1f9d148033babdf9c2a
This commit is contained in:
parent
f4b87c749f
commit
8229c3fa75
4
mk/rt.mk
4
mk/rt.mk
|
@ -66,7 +66,7 @@ RUNTIME_HDR := rt/globals.h \
|
|||
|
||||
RUNTIME_DEF := rt/rustrt$(CFG_DEF_SUFFIX)
|
||||
RUNTIME_INCS := -I $(S)src/rt/isaac -I $(S)src/rt/uthash \
|
||||
-I $(S)src/rt/arch/i386 -I $(S)src/rt/libuv
|
||||
-I $(S)src/rt/arch/i386 -I $(S)src/rt/libuv/include
|
||||
RUNTIME_OBJS := $(RUNTIME_CS:.cpp=.o) $(RUNTIME_LL:.ll=.o) $(RUNTIME_S:.s=.o)
|
||||
RUNTIME_LIBS := $(S)src/rt/libuv/uv.a
|
||||
|
||||
|
@ -97,7 +97,7 @@ rt/$(CFG_RUNTIME): $(RUNTIME_OBJS) $(MKFILES) $(RUNTIME_HDR) $(RUNTIME_DEF) $(RU
|
|||
@$(call E, link: $@)
|
||||
$(Q)$(call CFG_LINK_C,$@,$(CFG_GCCISH_POST_LIB_FLAGS) $(RUNTIME_LIBS) $(RUNTIME_OBJS),$(RUNTIME_DEF))
|
||||
|
||||
$(S)src/rt/libuv/uv.a: rt/libuv/LIBUV_REVISION
|
||||
$(S)src/rt/libuv/uv.a: $(S)src/rt/libuv/LIBUV_REVISION
|
||||
$(Q)$(MAKE) -C $(S)src/rt/libuv CFLAGS=\"-m32\" LDFLAGS=\"-m32\"
|
||||
$(Q)mkdir -p rt/libuv
|
||||
$(Q)cp $(S)src/rt/libuv/uv.a rt/libuv/uv.a
|
||||
|
|
|
@ -26,3 +26,18 @@ test/run-tests.exe
|
|||
test/run-benchmarks.exe
|
||||
test/run-benchmarks.dSYM/
|
||||
test/run-tests.dSYM/
|
||||
|
||||
|
||||
c-ares/.deps/
|
||||
c-ares/.libs/
|
||||
c-ares/Makefile
|
||||
c-ares/acountry
|
||||
c-ares/adig
|
||||
c-ares/ahost
|
||||
c-ares/ares_config.h
|
||||
c-ares/config.log
|
||||
c-ares/config.status
|
||||
c-ares/libcares.pc
|
||||
c-ares/libtool
|
||||
c-ares/stamp-h1
|
||||
c-ares/stamp-h2
|
||||
|
|
|
@ -3,4 +3,9 @@ Ryan Dahl <ryan@joyent.com>
|
|||
Bert Belder <bertbelder@gmail.com>
|
||||
Josh Roesslein <jroesslein@gmail.com>
|
||||
Alan Gutierrez <alan@prettyrobots.com>
|
||||
Igor Zinkovsky <igorzi@microsoft.com>
|
||||
Vanilla Hsu <vanilla@fatpipi.com>
|
||||
Ben Noordhuis <info@bnoordhuis.nl>
|
||||
Henry Rawas <henryr@schakra.com>
|
||||
Robert Mustacchi <rm@joyent.com>
|
||||
Matt Stevens <matt@alloysoft.com>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
This subtree is pulled from:
|
||||
2b5707d834a6b85b8e589ac04cb61a6db2dab94b
|
||||
ee599ec1141cc48f895de1f9d148033babdf9c2a
|
||||
|
||||
When pulling in a new version of libuv, please update this file to ensure that
|
||||
everyone correctly rebuilds libuv.
|
||||
|
|
|
@ -35,3 +35,6 @@ The externally maintained libraries used by libuv are:
|
|||
|
||||
- libev, located at ev/ is copyright Marc Alexander Lehmann, and
|
||||
dual-licensed under the MIT license and GPL2.
|
||||
|
||||
- libeio, located at eio/ is copyright Marc Alexander Lehmann, and
|
||||
dual-licensed under the MIT license and GPL2.
|
||||
|
|
|
@ -20,26 +20,44 @@
|
|||
|
||||
# Use make -f Makefile.gcc PREFIX=i686-w64-mingw32-
|
||||
# for cross compilation
|
||||
CC = $(PREFIX)gcc
|
||||
AR = $(PREFIX)ar
|
||||
CC ?= $(PREFIX)gcc
|
||||
AR ?= $(PREFIX)ar
|
||||
E=.exe
|
||||
|
||||
CFLAGS=-g --std=gnu89 -Wno-variadic-macros
|
||||
CFLAGS=$(CPPFLAGS) -g --std=gnu89 -D_WIN32_WINNT=0x0501 -Isrc/ares/config_win32
|
||||
LINKFLAGS=-lm
|
||||
|
||||
CARES_OBJS += src/ares/windows_port.o
|
||||
|
||||
RUNNER_CFLAGS=$(CFLAGS) -D_GNU_SOURCE # Need _GNU_SOURCE for strdup?
|
||||
RUNNER_LINKFLAGS=$(LINKFLAGS)
|
||||
RUNNER_LIBS=-lws2_32
|
||||
RUNNER_SRC=test/runner-win.c
|
||||
|
||||
uv.a: uv-win.o uv-common.o
|
||||
$(AR) rcs uv.a uv-win.o uv-common.o
|
||||
uv.a: src/uv-win.o src/uv-common.o src/uv-eio.o src/eio/eio.o $(CARES_OBJS)
|
||||
$(AR) rcs uv.a src/uv-win.o src/uv-common.o src/uv-eio.o src/eio/eio.o $(CARES_OBJS)
|
||||
|
||||
uv-win.o: uv-win.c uv.h uv-win.h
|
||||
$(CC) $(CFLAGS) -c uv-win.c -o uv-win.o
|
||||
src/uv-win.o: src/uv-win.c include/uv.h include/uv-win.h
|
||||
$(CC) $(CFLAGS) -c src/uv-win.c -o src/uv-win.o
|
||||
|
||||
uv-common.o: uv-common.c uv.h uv-win.h
|
||||
$(CC) $(CFLAGS) -c uv-common.c -o uv-common.o
|
||||
src/uv-common.o: src/uv-common.c include/uv.h include/uv-win.h
|
||||
$(CC) $(CFLAGS) -c src/uv-common.c -o src/uv-common.o
|
||||
|
||||
EIO_CPPFLAGS += $(CPPFLAGS)
|
||||
EIO_CPPFLAGS += -DEIO_CONFIG_H=\"$(EIO_CONFIG)\"
|
||||
EIO_CPPFLAGS += -DEIO_STACKSIZE=65536
|
||||
EIO_CPPFLAGS += -D_GNU_SOURCE
|
||||
|
||||
src/eio/eio.o: src/eio/eio.c
|
||||
$(CC) $(EIO_CPPFLAGS) $(CFLAGS) -c src/eio/eio.c -o src/eio/eio.o
|
||||
|
||||
src/uv-eio.o: src/uv-eio.c
|
||||
$(CC) $(CPPFLAGS) -Isrc/eio/ $(CFLAGS) -c src/uv-eio.c -o src/uv-eio.o
|
||||
|
||||
clean-platform:
|
||||
-rm -f src/ares/*.o
|
||||
-rm -f src/eio/*.o
|
||||
|
||||
distclean-platform:
|
||||
clean-platform:
|
||||
-rm -f src/ares/*.o
|
||||
-rm -f src/eio/*.o
|
||||
|
|
|
@ -18,14 +18,56 @@
|
|||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
|
||||
CC = $(PREFIX)gcc
|
||||
AR = $(PREFIX)ar
|
||||
CC ?= $(PREFIX)gcc
|
||||
AR ?= $(PREFIX)ar
|
||||
E=
|
||||
CFLAGS=--std=gnu89 -Wno-variadic-macros -g
|
||||
CSTDFLAG=--std=c89 -pedantic
|
||||
CFLAGS=-g
|
||||
CPPFLAGS += -Isrc/ev
|
||||
LINKFLAGS=-lm
|
||||
|
||||
CPPFLAGS += -D_LARGEFILE_SOURCE
|
||||
CPPFLAGS += -D_FILE_OFFSET_BITS=64
|
||||
|
||||
ifeq (SunOS,$(uname_S))
|
||||
EV_CONFIG=config_sunos.h
|
||||
EIO_CONFIG=config_sunos.h
|
||||
CPPFLAGS += -Isrc/ares/config_sunos
|
||||
LINKFLAGS+=-lsocket -lnsl
|
||||
UV_OS_FILE=uv-sunos.c
|
||||
endif
|
||||
|
||||
ifeq (Darwin,$(uname_S))
|
||||
EV_CONFIG=config_darwin.h
|
||||
EIO_CONFIG=config_darwin.h
|
||||
CPPFLAGS += -Isrc/ares/config_darwin
|
||||
LINKFLAGS+=-framework CoreServices
|
||||
UV_OS_FILE=uv-darwin.c
|
||||
endif
|
||||
|
||||
ifeq (Linux,$(uname_S))
|
||||
EV_CONFIG=config_linux.h
|
||||
EIO_CONFIG=config_linux.h
|
||||
CSTDFLAG += -D_XOPEN_SOURCE=600
|
||||
CPPFLAGS += -Isrc/ares/config_linux
|
||||
LINKFLAGS+=-lrt
|
||||
UV_OS_FILE=uv-linux.c
|
||||
endif
|
||||
|
||||
ifeq (FreeBSD,$(uname_S))
|
||||
EV_CONFIG=config_freebsd.h
|
||||
EIO_CONFIG=config_freebsd.h
|
||||
CPPFLAGS += -Isrc/ares/config_freebsd
|
||||
LINKFLAGS+=
|
||||
UV_OS_FILE=uv-freebsd.c
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring CYGWIN,$(uname_S)))
|
||||
EV_CONFIG=config_cygwin.h
|
||||
EIO_CONFIG=config_cygwin.h
|
||||
CPPFLAGS += -Isrc/ares/config_cygwin
|
||||
LINKFLAGS+=
|
||||
UV_OS_FILE=uv-cygwin.c
|
||||
endif
|
||||
|
||||
# Need _GNU_SOURCE for strdup?
|
||||
|
@ -35,23 +77,43 @@ RUNNER_LINKFLAGS=$(LINKFLAGS) -pthread
|
|||
RUNNER_LIBS=
|
||||
RUNNER_SRC=test/runner-unix.c
|
||||
|
||||
uv.a: uv-unix.o uv-common.o ev/ev.o
|
||||
$(AR) rcs uv.a uv-unix.o uv-common.o ev/ev.o
|
||||
uv.a: src/uv-unix.o src/uv-common.o src/uv-platform.o src/ev/ev.o src/uv-eio.o src/eio/eio.o $(CARES_OBJS)
|
||||
$(AR) rcs uv.a src/uv-unix.o src/uv-platform.o src/uv-common.o src/uv-eio.o src/ev/ev.o \
|
||||
src/eio/eio.o $(CARES_OBJS)
|
||||
|
||||
uv-unix.o: uv-unix.c uv.h uv-unix.h
|
||||
$(CC) $(CFLAGS) -c uv-unix.c -o uv-unix.o
|
||||
src/uv-platform.o: src/$(UV_OS_FILE) include/uv.h include/uv-unix.h
|
||||
$(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c src/$(UV_OS_FILE) -o src/uv-platform.o
|
||||
|
||||
uv-common.o: uv-common.c uv.h uv-unix.h
|
||||
$(CC) $(CFLAGS) -c uv-common.c -o uv-common.o
|
||||
src/uv-unix.o: src/uv-unix.c include/uv.h include/uv-unix.h
|
||||
$(CC) $(CSTDFLAG) $(CPPFLAGS) -Ieio $(CFLAGS) -c src/uv-unix.c -o src/uv-unix.o
|
||||
|
||||
ev/ev.o: ev/config.h ev/ev.c
|
||||
$(MAKE) -C ev
|
||||
src/uv-common.o: src/uv-common.c include/uv.h include/uv-unix.h
|
||||
$(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c src/uv-common.c -o src/uv-common.o
|
||||
|
||||
src/ev/ev.o: src/ev/ev.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c src/ev/ev.c -o src/ev/ev.o -DEV_CONFIG_H=\"$(EV_CONFIG)\"
|
||||
|
||||
|
||||
EIO_CPPFLAGS += $(CPPFLAGS)
|
||||
EIO_CPPFLAGS += -DEIO_CONFIG_H=\"$(EIO_CONFIG)\"
|
||||
EIO_CPPFLAGS += -DEIO_STACKSIZE=65536
|
||||
EIO_CPPFLAGS += -D_GNU_SOURCE
|
||||
|
||||
src/eio/eio.o: src/eio/eio.c
|
||||
$(CC) $(EIO_CPPFLAGS) $(CFLAGS) -c src/eio/eio.c -o src/eio/eio.o
|
||||
|
||||
src/uv-eio.o: src/uv-eio.c
|
||||
$(CC) $(CPPFLAGS) -Isrc/eio/ $(CSTDFLAG) $(CFLAGS) -c src/uv-eio.c -o src/uv-eio.o
|
||||
|
||||
ev/config.h:
|
||||
cd ev && ./configure
|
||||
|
||||
clean-platform:
|
||||
$(MAKE) -C ev clean
|
||||
-rm -f src/ares/*.o
|
||||
-rm -f src/ev/*.o
|
||||
-rm -f src/eio/*.o
|
||||
-rm -rf test/run-tests.dSYM run-benchmarks.dSYM
|
||||
|
||||
distclean-platform:
|
||||
$(MAKE) -C ev distclean
|
||||
-rm -f src/ares/*.o
|
||||
-rm -f src/ev/*.o
|
||||
-rm -f src/eio/*.o
|
||||
-rm -rf test/run-tests.dSYM run-benchmarks.dSYM
|
||||
|
|
|
@ -0,0 +1,582 @@
|
|||
|
||||
/* Copyright 1998, 2009 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2007-2010 by Daniel Stenberg
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef ARES__H
|
||||
#define ARES__H
|
||||
|
||||
#include "ares_version.h" /* c-ares version defines */
|
||||
|
||||
/*
|
||||
* Define WIN32 when build target is Win32 API
|
||||
*/
|
||||
|
||||
#if (defined(_WIN32) || defined(__WIN32__)) && \
|
||||
!defined(WIN32) && !defined(__SYMBIAN32__)
|
||||
# define WIN32
|
||||
#endif
|
||||
|
||||
/*************************** libuv patch ***************/
|
||||
|
||||
/*
|
||||
* We want to avoid autoconf altogether since there are a finite number of
|
||||
* operating systems and simply build c-ares. Therefore we do not want the
|
||||
* configurations provided by ares_build.h since we are always statically
|
||||
* linking c-ares into libuv. Having a system dependent ares_build.h forces
|
||||
* all users of ares.h to include the correct ares_build.h. We do not care
|
||||
* about the linking checks provided by ares_rules.h. This would complicate
|
||||
* the libuv build process.
|
||||
*/
|
||||
|
||||
|
||||
#if defined(WIN32)
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file ws2tcpip.h must be included by the external interface. */
|
||||
/* #undef CARES_PULL_WS2TCPIP_H */
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
# include <windows.h>
|
||||
|
||||
#else /* Not Windows */
|
||||
|
||||
# include <sys/time.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define CARES_SIZEOF_LONG 4
|
||||
#endif
|
||||
|
||||
/* Integral data type used for ares_socklen_t. */
|
||||
#define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
|
||||
|
||||
#if 0
|
||||
/* The size of `ares_socklen_t', as computed by sizeof. */
|
||||
#define CARES_SIZEOF_ARES_SOCKLEN_T 4
|
||||
#endif
|
||||
|
||||
/* Data type definition of ares_socklen_t. */
|
||||
typedef int ares_socklen_t;
|
||||
|
||||
#if 0 /* libuv disabled */
|
||||
#include "ares_rules.h" /* c-ares rules enforcement */
|
||||
#endif
|
||||
|
||||
/*********************** end libuv patch ***************/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
|
||||
libc5-based Linux systems. Only include it on system that are known to
|
||||
require it! */
|
||||
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
|
||||
defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY)
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
|
||||
#include <sys/bsdskt.h>
|
||||
#endif
|
||||
|
||||
#if defined(WATT32)
|
||||
# include <netinet/in.h>
|
||||
# include <sys/socket.h>
|
||||
# include <tcp.h>
|
||||
#elif defined(WIN32)
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** c-ares external API function linkage decorations.
|
||||
*/
|
||||
|
||||
#if !defined(CARES_STATICLIB) && \
|
||||
(defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
|
||||
/* __declspec function decoration for Win32 and Symbian DLL's */
|
||||
# if defined(CARES_BUILDING_LIBRARY)
|
||||
# define CARES_EXTERN __declspec(dllexport)
|
||||
# else
|
||||
# define CARES_EXTERN __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
/* visibility function decoration for other cases */
|
||||
# if !defined(CARES_SYMBOL_HIDING) || \
|
||||
defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
|
||||
# define CARES_EXTERN
|
||||
# else
|
||||
# define CARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#define ARES_SUCCESS 0
|
||||
|
||||
/* Server error codes (ARES_ENODATA indicates no relevant answer) */
|
||||
#define ARES_ENODATA 1
|
||||
#define ARES_EFORMERR 2
|
||||
#define ARES_ESERVFAIL 3
|
||||
#define ARES_ENOTFOUND 4
|
||||
#define ARES_ENOTIMP 5
|
||||
#define ARES_EREFUSED 6
|
||||
|
||||
/* Locally generated error codes */
|
||||
#define ARES_EBADQUERY 7
|
||||
#define ARES_EBADNAME 8
|
||||
#define ARES_EBADFAMILY 9
|
||||
#define ARES_EBADRESP 10
|
||||
#define ARES_ECONNREFUSED 11
|
||||
#define ARES_ETIMEOUT 12
|
||||
#define ARES_EOF 13
|
||||
#define ARES_EFILE 14
|
||||
#define ARES_ENOMEM 15
|
||||
#define ARES_EDESTRUCTION 16
|
||||
#define ARES_EBADSTR 17
|
||||
|
||||
/* ares_getnameinfo error codes */
|
||||
#define ARES_EBADFLAGS 18
|
||||
|
||||
/* ares_getaddrinfo error codes */
|
||||
#define ARES_ENONAME 19
|
||||
#define ARES_EBADHINTS 20
|
||||
|
||||
/* Uninitialized library error code */
|
||||
#define ARES_ENOTINITIALIZED 21 /* introduced in 1.7.0 */
|
||||
|
||||
/* ares_library_init error codes */
|
||||
#define ARES_ELOADIPHLPAPI 22 /* introduced in 1.7.0 */
|
||||
#define ARES_EADDRGETNETWORKPARAMS 23 /* introduced in 1.7.0 */
|
||||
|
||||
/* More error codes */
|
||||
#define ARES_ECANCELLED 24 /* introduced in 1.7.0 */
|
||||
|
||||
/* Flag values */
|
||||
#define ARES_FLAG_USEVC (1 << 0)
|
||||
#define ARES_FLAG_PRIMARY (1 << 1)
|
||||
#define ARES_FLAG_IGNTC (1 << 2)
|
||||
#define ARES_FLAG_NORECURSE (1 << 3)
|
||||
#define ARES_FLAG_STAYOPEN (1 << 4)
|
||||
#define ARES_FLAG_NOSEARCH (1 << 5)
|
||||
#define ARES_FLAG_NOALIASES (1 << 6)
|
||||
#define ARES_FLAG_NOCHECKRESP (1 << 7)
|
||||
|
||||
/* Option mask values */
|
||||
#define ARES_OPT_FLAGS (1 << 0)
|
||||
#define ARES_OPT_TIMEOUT (1 << 1)
|
||||
#define ARES_OPT_TRIES (1 << 2)
|
||||
#define ARES_OPT_NDOTS (1 << 3)
|
||||
#define ARES_OPT_UDP_PORT (1 << 4)
|
||||
#define ARES_OPT_TCP_PORT (1 << 5)
|
||||
#define ARES_OPT_SERVERS (1 << 6)
|
||||
#define ARES_OPT_DOMAINS (1 << 7)
|
||||
#define ARES_OPT_LOOKUPS (1 << 8)
|
||||
#define ARES_OPT_SOCK_STATE_CB (1 << 9)
|
||||
#define ARES_OPT_SORTLIST (1 << 10)
|
||||
#define ARES_OPT_SOCK_SNDBUF (1 << 11)
|
||||
#define ARES_OPT_SOCK_RCVBUF (1 << 12)
|
||||
#define ARES_OPT_TIMEOUTMS (1 << 13)
|
||||
#define ARES_OPT_ROTATE (1 << 14)
|
||||
|
||||
/* Nameinfo flag values */
|
||||
#define ARES_NI_NOFQDN (1 << 0)
|
||||
#define ARES_NI_NUMERICHOST (1 << 1)
|
||||
#define ARES_NI_NAMEREQD (1 << 2)
|
||||
#define ARES_NI_NUMERICSERV (1 << 3)
|
||||
#define ARES_NI_DGRAM (1 << 4)
|
||||
#define ARES_NI_TCP 0
|
||||
#define ARES_NI_UDP ARES_NI_DGRAM
|
||||
#define ARES_NI_SCTP (1 << 5)
|
||||
#define ARES_NI_DCCP (1 << 6)
|
||||
#define ARES_NI_NUMERICSCOPE (1 << 7)
|
||||
#define ARES_NI_LOOKUPHOST (1 << 8)
|
||||
#define ARES_NI_LOOKUPSERVICE (1 << 9)
|
||||
/* Reserved for future use */
|
||||
#define ARES_NI_IDN (1 << 10)
|
||||
#define ARES_NI_IDN_ALLOW_UNASSIGNED (1 << 11)
|
||||
#define ARES_NI_IDN_USE_STD3_ASCII_RULES (1 << 12)
|
||||
|
||||
/* Addrinfo flag values */
|
||||
#define ARES_AI_CANONNAME (1 << 0)
|
||||
#define ARES_AI_NUMERICHOST (1 << 1)
|
||||
#define ARES_AI_PASSIVE (1 << 2)
|
||||
#define ARES_AI_NUMERICSERV (1 << 3)
|
||||
#define ARES_AI_V4MAPPED (1 << 4)
|
||||
#define ARES_AI_ALL (1 << 5)
|
||||
#define ARES_AI_ADDRCONFIG (1 << 6)
|
||||
/* Reserved for future use */
|
||||
#define ARES_AI_IDN (1 << 10)
|
||||
#define ARES_AI_IDN_ALLOW_UNASSIGNED (1 << 11)
|
||||
#define ARES_AI_IDN_USE_STD3_ASCII_RULES (1 << 12)
|
||||
#define ARES_AI_CANONIDN (1 << 13)
|
||||
|
||||
#define ARES_AI_MASK (ARES_AI_CANONNAME|ARES_AI_NUMERICHOST|ARES_AI_PASSIVE| \
|
||||
ARES_AI_NUMERICSERV|ARES_AI_V4MAPPED|ARES_AI_ALL| \
|
||||
ARES_AI_ADDRCONFIG)
|
||||
#define ARES_GETSOCK_MAXNUM 16 /* ares_getsock() can return info about this
|
||||
many sockets */
|
||||
#define ARES_GETSOCK_READABLE(bits,num) (bits & (1<< (num)))
|
||||
#define ARES_GETSOCK_WRITABLE(bits,num) (bits & (1 << ((num) + \
|
||||
ARES_GETSOCK_MAXNUM)))
|
||||
|
||||
/* c-ares library initialization flag values */
|
||||
#define ARES_LIB_INIT_NONE (0)
|
||||
#define ARES_LIB_INIT_WIN32 (1 << 0)
|
||||
#define ARES_LIB_INIT_ALL (ARES_LIB_INIT_WIN32)
|
||||
|
||||
|
||||
/*
|
||||
* Typedef our socket type
|
||||
*/
|
||||
|
||||
#ifndef ares_socket_typedef
|
||||
#ifdef WIN32
|
||||
typedef SOCKET ares_socket_t;
|
||||
#define ARES_SOCKET_BAD INVALID_SOCKET
|
||||
#else
|
||||
typedef int ares_socket_t;
|
||||
#define ARES_SOCKET_BAD -1
|
||||
#endif
|
||||
#define ares_socket_typedef
|
||||
#endif /* ares_socket_typedef */
|
||||
|
||||
typedef void (*ares_sock_state_cb)(void *data,
|
||||
ares_socket_t socket_fd,
|
||||
int readable,
|
||||
int writable);
|
||||
|
||||
struct apattern;
|
||||
|
||||
/* NOTE about the ares_options struct to users and developers.
|
||||
|
||||
This struct will remain looking like this. It will not be extended nor
|
||||
shrunk in future releases, but all new options will be set by ares_set_*()
|
||||
options instead of with the ares_init_options() function.
|
||||
|
||||
Eventually (in a galaxy far far away), all options will be settable by
|
||||
ares_set_*() options and the ares_init_options() function will become
|
||||
deprecated.
|
||||
|
||||
When new options are added to c-ares, they are not added to this
|
||||
struct. And they are not "saved" with the ares_save_options() function but
|
||||
instead we encourage the use of the ares_dup() function. Needless to say,
|
||||
if you add config options to c-ares you need to make sure ares_dup()
|
||||
duplicates this new option.
|
||||
|
||||
*/
|
||||
struct ares_options {
|
||||
int flags;
|
||||
int timeout; /* in seconds or milliseconds, depending on options */
|
||||
int tries;
|
||||
int ndots;
|
||||
unsigned short udp_port;
|
||||
unsigned short tcp_port;
|
||||
int socket_send_buffer_size;
|
||||
int socket_receive_buffer_size;
|
||||
struct in_addr *servers;
|
||||
int nservers;
|
||||
char **domains;
|
||||
int ndomains;
|
||||
char *lookups;
|
||||
ares_sock_state_cb sock_state_cb;
|
||||
void *sock_state_cb_data;
|
||||
struct apattern *sortlist;
|
||||
int nsort;
|
||||
};
|
||||
|
||||
struct hostent;
|
||||
struct timeval;
|
||||
struct sockaddr;
|
||||
struct ares_channeldata;
|
||||
|
||||
typedef struct ares_channeldata *ares_channel;
|
||||
|
||||
typedef void (*ares_callback)(void *arg,
|
||||
int status,
|
||||
int timeouts,
|
||||
unsigned char *abuf,
|
||||
int alen);
|
||||
|
||||
typedef void (*ares_host_callback)(void *arg,
|
||||
int status,
|
||||
int timeouts,
|
||||
struct hostent *hostent);
|
||||
|
||||
typedef void (*ares_nameinfo_callback)(void *arg,
|
||||
int status,
|
||||
int timeouts,
|
||||
char *node,
|
||||
char *service);
|
||||
|
||||
typedef int (*ares_sock_create_callback)(ares_socket_t socket_fd,
|
||||
int type,
|
||||
void *data);
|
||||
|
||||
CARES_EXTERN int ares_library_init(int flags);
|
||||
|
||||
CARES_EXTERN void ares_library_cleanup(void);
|
||||
|
||||
CARES_EXTERN const char *ares_version(int *version);
|
||||
|
||||
CARES_EXTERN int ares_init(ares_channel *channelptr);
|
||||
|
||||
CARES_EXTERN int ares_init_options(ares_channel *channelptr,
|
||||
struct ares_options *options,
|
||||
int optmask);
|
||||
|
||||
CARES_EXTERN int ares_save_options(ares_channel channel,
|
||||
struct ares_options *options,
|
||||
int *optmask);
|
||||
|
||||
CARES_EXTERN void ares_destroy_options(struct ares_options *options);
|
||||
|
||||
CARES_EXTERN int ares_dup(ares_channel *dest,
|
||||
ares_channel src);
|
||||
|
||||
CARES_EXTERN void ares_destroy(ares_channel channel);
|
||||
|
||||
CARES_EXTERN void ares_cancel(ares_channel channel);
|
||||
|
||||
/* These next 3 configure local binding for the out-going socket
|
||||
* connection. Use these to specify source IP and/or network device
|
||||
* on multi-homed systems.
|
||||
*/
|
||||
CARES_EXTERN void ares_set_local_ip4(ares_channel channel, unsigned int local_ip);
|
||||
|
||||
/* local_ip6 should be 16 bytes in length */
|
||||
CARES_EXTERN void ares_set_local_ip6(ares_channel channel,
|
||||
const unsigned char* local_ip6);
|
||||
|
||||
/* local_dev_name should be null terminated. */
|
||||
CARES_EXTERN void ares_set_local_dev(ares_channel channel,
|
||||
const char* local_dev_name);
|
||||
|
||||
CARES_EXTERN void ares_set_socket_callback(ares_channel channel,
|
||||
ares_sock_create_callback callback,
|
||||
void *user_data);
|
||||
|
||||
CARES_EXTERN void ares_send(ares_channel channel,
|
||||
const unsigned char *qbuf,
|
||||
int qlen,
|
||||
ares_callback callback,
|
||||
void *arg);
|
||||
|
||||
CARES_EXTERN void ares_query(ares_channel channel,
|
||||
const char *name,
|
||||
int dnsclass,
|
||||
int type,
|
||||
ares_callback callback,
|
||||
void *arg);
|
||||
|
||||
CARES_EXTERN void ares_search(ares_channel channel,
|
||||
const char *name,
|
||||
int dnsclass,
|
||||
int type,
|
||||
ares_callback callback,
|
||||
void *arg);
|
||||
|
||||
CARES_EXTERN void ares_gethostbyname(ares_channel channel,
|
||||
const char *name,
|
||||
int family,
|
||||
ares_host_callback callback,
|
||||
void *arg);
|
||||
|
||||
CARES_EXTERN int ares_gethostbyname_file(ares_channel channel,
|
||||
const char *name,
|
||||
int family,
|
||||
struct hostent **host);
|
||||
|
||||
CARES_EXTERN void ares_gethostbyaddr(ares_channel channel,
|
||||
const void *addr,
|
||||
int addrlen,
|
||||
int family,
|
||||
ares_host_callback callback,
|
||||
void *arg);
|
||||
|
||||
CARES_EXTERN void ares_getnameinfo(ares_channel channel,
|
||||
const struct sockaddr *sa,
|
||||
ares_socklen_t salen,
|
||||
int flags,
|
||||
ares_nameinfo_callback callback,
|
||||
void *arg);
|
||||
|
||||
CARES_EXTERN int ares_fds(ares_channel channel,
|
||||
fd_set *read_fds,
|
||||
fd_set *write_fds);
|
||||
|
||||
CARES_EXTERN int ares_getsock(ares_channel channel,
|
||||
ares_socket_t *socks,
|
||||
int numsocks);
|
||||
|
||||
CARES_EXTERN struct timeval *ares_timeout(ares_channel channel,
|
||||
struct timeval *maxtv,
|
||||
struct timeval *tv);
|
||||
|
||||
CARES_EXTERN void ares_process(ares_channel channel,
|
||||
fd_set *read_fds,
|
||||
fd_set *write_fds);
|
||||
|
||||
CARES_EXTERN void ares_process_fd(ares_channel channel,
|
||||
ares_socket_t read_fd,
|
||||
ares_socket_t write_fd);
|
||||
|
||||
CARES_EXTERN int ares_mkquery(const char *name,
|
||||
int dnsclass,
|
||||
int type,
|
||||
unsigned short id,
|
||||
int rd,
|
||||
unsigned char **buf,
|
||||
int *buflen);
|
||||
|
||||
CARES_EXTERN int ares_expand_name(const unsigned char *encoded,
|
||||
const unsigned char *abuf,
|
||||
int alen,
|
||||
char **s,
|
||||
long *enclen);
|
||||
|
||||
CARES_EXTERN int ares_expand_string(const unsigned char *encoded,
|
||||
const unsigned char *abuf,
|
||||
int alen,
|
||||
unsigned char **s,
|
||||
long *enclen);
|
||||
|
||||
/*
|
||||
* NOTE: before c-ares 1.7.0 we would most often use the system in6_addr
|
||||
* struct below when ares itself was built, but many apps would use this
|
||||
* private version since the header checked a HAVE_* define for it. Starting
|
||||
* with 1.7.0 we always declare and use our own to stop relying on the
|
||||
* system's one.
|
||||
*/
|
||||
struct ares_in6_addr {
|
||||
union {
|
||||
unsigned char _S6_u8[16];
|
||||
} _S6_un;
|
||||
};
|
||||
|
||||
struct ares_addrttl {
|
||||
struct in_addr ipaddr;
|
||||
int ttl;
|
||||
};
|
||||
|
||||
struct ares_addr6ttl {
|
||||
struct ares_in6_addr ip6addr;
|
||||
int ttl;
|
||||
};
|
||||
|
||||
struct ares_srv_reply {
|
||||
struct ares_srv_reply *next;
|
||||
char *host;
|
||||
unsigned short priority;
|
||||
unsigned short weight;
|
||||
unsigned short port;
|
||||
};
|
||||
|
||||
struct ares_mx_reply {
|
||||
struct ares_mx_reply *next;
|
||||
char *host;
|
||||
unsigned short priority;
|
||||
};
|
||||
|
||||
struct ares_txt_reply {
|
||||
struct ares_txt_reply *next;
|
||||
unsigned char *txt;
|
||||
size_t length; /* length excludes null termination */
|
||||
};
|
||||
|
||||
/*
|
||||
** Parse the buffer, starting at *abuf and of length alen bytes, previously
|
||||
** obtained from an ares_search call. Put the results in *host, if nonnull.
|
||||
** Also, if addrttls is nonnull, put up to *naddrttls IPv4 addresses along with
|
||||
** their TTLs in that array, and set *naddrttls to the number of addresses
|
||||
** so written.
|
||||
*/
|
||||
|
||||
CARES_EXTERN int ares_parse_a_reply(const unsigned char *abuf,
|
||||
int alen,
|
||||
struct hostent **host,
|
||||
struct ares_addrttl *addrttls,
|
||||
int *naddrttls);
|
||||
|
||||
CARES_EXTERN int ares_parse_aaaa_reply(const unsigned char *abuf,
|
||||
int alen,
|
||||
struct hostent **host,
|
||||
struct ares_addr6ttl *addrttls,
|
||||
int *naddrttls);
|
||||
|
||||
CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf,
|
||||
int alen,
|
||||
const void *addr,
|
||||
int addrlen,
|
||||
int family,
|
||||
struct hostent **host);
|
||||
|
||||
CARES_EXTERN int ares_parse_ns_reply(const unsigned char *abuf,
|
||||
int alen,
|
||||
struct hostent **host);
|
||||
|
||||
CARES_EXTERN int ares_parse_srv_reply(const unsigned char* abuf,
|
||||
int alen,
|
||||
struct ares_srv_reply** srv_out);
|
||||
|
||||
CARES_EXTERN int ares_parse_mx_reply(const unsigned char* abuf,
|
||||
int alen,
|
||||
struct ares_mx_reply** mx_out);
|
||||
|
||||
CARES_EXTERN int ares_parse_txt_reply(const unsigned char* abuf,
|
||||
int alen,
|
||||
struct ares_txt_reply** txt_out);
|
||||
|
||||
CARES_EXTERN void ares_free_string(void *str);
|
||||
|
||||
CARES_EXTERN void ares_free_hostent(struct hostent *host);
|
||||
|
||||
CARES_EXTERN void ares_free_data(void *dataptr);
|
||||
|
||||
CARES_EXTERN const char *ares_strerror(int code);
|
||||
|
||||
/* TODO: Hold port here as well. */
|
||||
struct ares_addr_node {
|
||||
struct ares_addr_node *next;
|
||||
int family;
|
||||
union {
|
||||
struct in_addr addr4;
|
||||
struct ares_in6_addr addr6;
|
||||
} addr;
|
||||
};
|
||||
|
||||
CARES_EXTERN int ares_set_servers(ares_channel channel,
|
||||
struct ares_addr_node *servers);
|
||||
|
||||
/* Incomming string format: host[:port][,host[:port]]... */
|
||||
CARES_EXTERN int ares_set_servers_csv(ares_channel channel,
|
||||
const char* servers);
|
||||
|
||||
CARES_EXTERN int ares_get_servers(ares_channel channel,
|
||||
struct ares_addr_node **servers);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ARES__H */
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
#ifndef ARES__VERSION_H
|
||||
#define ARES__VERSION_H
|
||||
|
||||
/* This is the global package copyright */
|
||||
#define ARES_COPYRIGHT "2004 - 2010 Daniel Stenberg, <daniel@haxx.se>."
|
||||
|
||||
#define ARES_VERSION_MAJOR 1
|
||||
#define ARES_VERSION_MINOR 7
|
||||
#define ARES_VERSION_PATCH 4
|
||||
#define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\
|
||||
(ARES_VERSION_MINOR<<8)|\
|
||||
(ARES_VERSION_PATCH))
|
||||
#define ARES_VERSION_STR "1.7.4"
|
||||
|
||||
#if (ARES_VERSION >= 0x010700)
|
||||
# define CARES_HAVE_ARES_LIBRARY_INIT 1
|
||||
# define CARES_HAVE_ARES_LIBRARY_CLEANUP 1
|
||||
#else
|
||||
# undef CARES_HAVE_ARES_LIBRARY_INIT
|
||||
# undef CARES_HAVE_ARES_LIBRARY_CLEANUP
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,356 @@
|
|||
/*
|
||||
* libeio API header
|
||||
*
|
||||
* Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libeio@schmorp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modifica-
|
||||
* tion, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
||||
* CIAL, 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 OTH-
|
||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
||||
* in which case the provisions of the GPL are applicable instead of
|
||||
* the above. If you wish to allow the use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the BSD license, indicate your decision
|
||||
* by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file under
|
||||
* either the BSD or the GPL.
|
||||
*/
|
||||
|
||||
#ifndef EIO_H_
|
||||
#define EIO_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# define uid_t int
|
||||
# define gid_t int
|
||||
#endif
|
||||
|
||||
typedef struct eio_req eio_req;
|
||||
typedef struct eio_dirent eio_dirent;
|
||||
|
||||
typedef int (*eio_cb)(eio_req *req);
|
||||
|
||||
#ifndef EIO_REQ_MEMBERS
|
||||
# define EIO_REQ_MEMBERS
|
||||
#endif
|
||||
|
||||
#ifndef EIO_STRUCT_STAT
|
||||
# ifdef _WIN32
|
||||
# define EIO_STRUCT_STAT struct _stati64
|
||||
# else
|
||||
# define EIO_STRUCT_STAT struct stat
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef EIO_STRUCT_STATVFS
|
||||
# define EIO_STRUCT_STATVFS struct statvfs
|
||||
#endif
|
||||
|
||||
/* for readdir */
|
||||
|
||||
/* eio_readdir flags */
|
||||
enum
|
||||
{
|
||||
EIO_READDIR_DENTS = 0x01, /* ptr2 contains eio_dirents, not just the (unsorted) names */
|
||||
EIO_READDIR_DIRS_FIRST = 0x02, /* dirents gets sorted into a good stat() ing order to find directories first */
|
||||
EIO_READDIR_STAT_ORDER = 0x04, /* dirents gets sorted into a good stat() ing order to quickly stat all files */
|
||||
EIO_READDIR_FOUND_UNKNOWN = 0x80, /* set by eio_readdir when *_ARRAY was set and any TYPE=UNKNOWN's were found */
|
||||
|
||||
EIO_READDIR_CUSTOM1 = 0x100, /* for use by apps */
|
||||
EIO_READDIR_CUSTOM2 = 0x200 /* for use by apps */
|
||||
};
|
||||
|
||||
/* using "typical" values in the hope that the compiler will do something sensible */
|
||||
enum eio_dtype
|
||||
{
|
||||
EIO_DT_UNKNOWN = 0,
|
||||
EIO_DT_FIFO = 1,
|
||||
EIO_DT_CHR = 2,
|
||||
EIO_DT_MPC = 3, /* multiplexed char device (v7+coherent) */
|
||||
EIO_DT_DIR = 4,
|
||||
EIO_DT_NAM = 5, /* xenix special named file */
|
||||
EIO_DT_BLK = 6,
|
||||
EIO_DT_MPB = 7, /* multiplexed block device (v7+coherent) */
|
||||
EIO_DT_REG = 8,
|
||||
EIO_DT_NWK = 9, /* HP-UX network special */
|
||||
EIO_DT_CMP = 9, /* VxFS compressed */
|
||||
EIO_DT_LNK = 10,
|
||||
/* DT_SHAD = 11,*/
|
||||
EIO_DT_SOCK = 12,
|
||||
EIO_DT_DOOR = 13, /* solaris door */
|
||||
EIO_DT_WHT = 14,
|
||||
EIO_DT_MAX = 15 /* highest DT_VALUE ever, hopefully */
|
||||
};
|
||||
|
||||
struct eio_dirent
|
||||
{
|
||||
int nameofs; /* offset of null-terminated name string in (char *)req->ptr2 */
|
||||
unsigned short namelen; /* size of filename without trailing 0 */
|
||||
unsigned char type; /* one of EIO_DT_* */
|
||||
signed char score; /* internal use */
|
||||
ino_t inode; /* the inode number, if available, otherwise unspecified */
|
||||
};
|
||||
|
||||
/* eio_msync flags */
|
||||
enum
|
||||
{
|
||||
EIO_MS_ASYNC = 1,
|
||||
EIO_MS_INVALIDATE = 2,
|
||||
EIO_MS_SYNC = 4
|
||||
};
|
||||
|
||||
/* eio_mtouch flags */
|
||||
|
||||
enum
|
||||
{
|
||||
EIO_MT_MODIFY = 1
|
||||
};
|
||||
|
||||
/* eio_sync_file_range flags */
|
||||
|
||||
enum
|
||||
{
|
||||
EIO_SYNC_FILE_RANGE_WAIT_BEFORE = 1,
|
||||
EIO_SYNC_FILE_RANGE_WRITE = 2,
|
||||
EIO_SYNC_FILE_RANGE_WAIT_AFTER = 4
|
||||
};
|
||||
|
||||
typedef double eio_tstamp; /* feel free to use double in your code directly */
|
||||
|
||||
/* the eio request structure */
|
||||
|
||||
enum
|
||||
{
|
||||
EIO_CUSTOM,
|
||||
EIO_OPEN, EIO_CLOSE, EIO_DUP2,
|
||||
EIO_READ, EIO_WRITE,
|
||||
EIO_READAHEAD, EIO_SENDFILE,
|
||||
EIO_STAT, EIO_LSTAT, EIO_FSTAT,
|
||||
EIO_STATVFS, EIO_FSTATVFS,
|
||||
EIO_TRUNCATE, EIO_FTRUNCATE,
|
||||
EIO_UTIME, EIO_FUTIME,
|
||||
EIO_CHMOD, EIO_FCHMOD,
|
||||
EIO_CHOWN, EIO_FCHOWN,
|
||||
EIO_SYNC, EIO_FSYNC, EIO_FDATASYNC,
|
||||
EIO_MSYNC, EIO_MTOUCH, EIO_SYNC_FILE_RANGE,
|
||||
EIO_MLOCK, EIO_MLOCKALL,
|
||||
EIO_UNLINK, EIO_RMDIR, EIO_MKDIR, EIO_RENAME,
|
||||
EIO_MKNOD, EIO_READDIR,
|
||||
EIO_LINK, EIO_SYMLINK, EIO_READLINK,
|
||||
EIO_GROUP, EIO_NOP,
|
||||
EIO_BUSY
|
||||
};
|
||||
|
||||
/* mlockall constants */
|
||||
enum
|
||||
{
|
||||
EIO_MCL_CURRENT = 1,
|
||||
EIO_MCL_FUTURE = 2
|
||||
};
|
||||
|
||||
/* request priorities */
|
||||
|
||||
enum {
|
||||
EIO_PRI_MIN = -4,
|
||||
EIO_PRI_MAX = 4,
|
||||
EIO_PRI_DEFAULT = 0
|
||||
};
|
||||
|
||||
/* eio request structure */
|
||||
/* this structure is mostly read-only */
|
||||
/* when initialising it, all members must be zero-initialised */
|
||||
struct eio_req
|
||||
{
|
||||
eio_req volatile *next; /* private ETP */
|
||||
|
||||
ssize_t result; /* result of syscall, e.g. result = read (... */
|
||||
off_t offs; /* read, write, truncate, readahead, sync_file_range: file offset */
|
||||
size_t size; /* read, write, readahead, sendfile, msync, mlock, sync_file_range: length */
|
||||
void *ptr1; /* all applicable requests: pathname, old name; readdir: optional eio_dirents */
|
||||
void *ptr2; /* all applicable requests: new name or memory buffer; readdir: name strings */
|
||||
eio_tstamp nv1; /* utime, futime: atime; busy: sleep time */
|
||||
eio_tstamp nv2; /* utime, futime: mtime */
|
||||
|
||||
int type; /* EIO_xxx constant ETP */
|
||||
int int1; /* all applicable requests: file descriptor; sendfile: output fd; open, msync, mlockall, readdir: flags */
|
||||
long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode, sync_file_range: flags */
|
||||
long int3; /* chown, fchown: gid; mknod: dev_t */
|
||||
int errorno; /* errno value on syscall return */
|
||||
|
||||
unsigned char flags; /* private */
|
||||
signed char pri; /* the priority */
|
||||
|
||||
void *data;
|
||||
eio_cb finish;
|
||||
void (*destroy)(eio_req *req); /* called when requets no longer needed */
|
||||
void (*feed)(eio_req *req); /* only used for group requests */
|
||||
|
||||
EIO_REQ_MEMBERS
|
||||
|
||||
eio_req *grp, *grp_prev, *grp_next, *grp_first; /* private */
|
||||
};
|
||||
|
||||
/* _private_ request flags */
|
||||
enum {
|
||||
EIO_FLAG_CANCELLED = 0x01, /* request was cancelled */
|
||||
EIO_FLAG_PTR1_FREE = 0x02, /* need to free(ptr1) */
|
||||
EIO_FLAG_PTR2_FREE = 0x04, /* need to free(ptr2) */
|
||||
EIO_FLAG_GROUPADD = 0x08 /* some request was added to the group */
|
||||
};
|
||||
|
||||
/* undocumented/unsupported/private helper */
|
||||
/*void eio_page_align (void **addr, size_t *length);*/
|
||||
|
||||
/* returns < 0 on error, errno set
|
||||
* need_poll, if non-zero, will be called when results are available
|
||||
* and eio_poll_cb needs to be invoked (it MUST NOT call eio_poll_cb itself).
|
||||
* done_poll is called when the need to poll is gone.
|
||||
*/
|
||||
int eio_init (void (*want_poll)(void), void (*done_poll)(void));
|
||||
|
||||
/* must be called regularly to handle pending requests */
|
||||
/* returns 0 if all requests were handled, -1 if not, or the value of EIO_FINISH if != 0 */
|
||||
int eio_poll (void);
|
||||
|
||||
/* stop polling if poll took longer than duration seconds */
|
||||
void eio_set_max_poll_time (eio_tstamp nseconds);
|
||||
/* do not handle more then count requests in one call to eio_poll_cb */
|
||||
void eio_set_max_poll_reqs (unsigned int nreqs);
|
||||
|
||||
/* set minimum required number
|
||||
* maximum wanted number
|
||||
* or maximum idle number of threads */
|
||||
void eio_set_min_parallel (unsigned int nthreads);
|
||||
void eio_set_max_parallel (unsigned int nthreads);
|
||||
void eio_set_max_idle (unsigned int nthreads);
|
||||
|
||||
unsigned int eio_nreqs (void); /* number of requests in-flight */
|
||||
unsigned int eio_nready (void); /* number of not-yet handled requests */
|
||||
unsigned int eio_npending (void); /* numbe rof finished but unhandled requests */
|
||||
unsigned int eio_nthreads (void); /* number of worker threads in use currently */
|
||||
|
||||
/*****************************************************************************/
|
||||
/* convinience wrappers */
|
||||
|
||||
#ifndef EIO_NO_WRAPPERS
|
||||
eio_req *eio_nop (int pri, eio_cb cb, void *data); /* does nothing except go through the whole process */
|
||||
eio_req *eio_busy (eio_tstamp delay, int pri, eio_cb cb, void *data); /* ties a thread for this long, simulating busyness */
|
||||
eio_req *eio_sync (int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_fsync (int fd, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_msync (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_mlock (void *addr, size_t length, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_mlockall (int flags, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_close (int fd, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_fstat (int fd, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */
|
||||
eio_req *eio_fstatvfs (int fd, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */
|
||||
eio_req *eio_futime (int fd, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_ftruncate (int fd, off_t offset, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_fchown (int fd, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_sendfile (int out_fd, int in_fd, off_t in_offset, size_t length, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_open (const char *path, int flags, mode_t mode, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_utime (const char *path, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_chown (const char *path, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_chmod (const char *path, mode_t mode, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_mkdir (const char *path, mode_t mode, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_readdir (const char *path, int flags, int pri, eio_cb cb, void *data); /* result=ptr2 allocated dynamically */
|
||||
eio_req *eio_rmdir (const char *path, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data); /* result=ptr2 allocated dynamically */
|
||||
eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */
|
||||
eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */
|
||||
eio_req *eio_statvfs (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */
|
||||
eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data);
|
||||
eio_req *eio_custom (eio_cb execute, int pri, eio_cb cb, void *data);
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* groups */
|
||||
|
||||
eio_req *eio_grp (eio_cb cb, void *data);
|
||||
void eio_grp_feed (eio_req *grp, void (*feed)(eio_req *req), int limit);
|
||||
void eio_grp_limit (eio_req *grp, int limit);
|
||||
void eio_grp_add (eio_req *grp, eio_req *req);
|
||||
void eio_grp_cancel (eio_req *grp); /* cancels all sub requests but not the group */
|
||||
|
||||
/*****************************************************************************/
|
||||
/* request api */
|
||||
|
||||
/* true if the request was cancelled, useful in the invoke callback */
|
||||
#define EIO_CANCELLED(req) ((req)->flags & EIO_FLAG_CANCELLED)
|
||||
|
||||
#define EIO_RESULT(req) ((req)->result)
|
||||
/* returns a pointer to the result buffer allocated by eio */
|
||||
#define EIO_BUF(req) ((req)->ptr2)
|
||||
#define EIO_STAT_BUF(req) ((EIO_STRUCT_STAT *)EIO_BUF(req))
|
||||
#define EIO_STATVFS_BUF(req) ((EIO_STRUCT_STATVFS *)EIO_BUF(req))
|
||||
#define EIO_PATH(req) ((char *)(req)->ptr1)
|
||||
|
||||
/* submit a request for execution */
|
||||
void eio_submit (eio_req *req);
|
||||
/* cancel a request as soon fast as possible, if possible */
|
||||
void eio_cancel (eio_req *req);
|
||||
/* destroy a request that has never been submitted */
|
||||
void eio_destroy (eio_req *req);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* convinience functions */
|
||||
|
||||
ssize_t eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* export these so node_file can use these function instead of pread/write */
|
||||
|
||||
#if !HAVE_PREADWRITE
|
||||
ssize_t eio__pread (int fd, void *buf, size_t count, off_t offset);
|
||||
ssize_t eio__pwrite (int fd, void *buf, size_t count, off_t offset);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -197,7 +197,7 @@ struct ev_loop;
|
|||
|
||||
/* eventmask, revents, events... */
|
||||
enum {
|
||||
EV_UNDEF = 0xFFFFFFFF, /* guaranteed to be invalid */
|
||||
EV_UNDEF = -1, /* guaranteed to be invalid */
|
||||
EV_NONE = 0x00, /* no events */
|
||||
EV_READ = 0x01, /* ev_io detected read will not block */
|
||||
EV_WRITE = 0x02, /* ev_io detected write will not block */
|
||||
|
@ -219,7 +219,7 @@ enum {
|
|||
EV_CLEANUP = 0x00040000, /* event loop resumed in child */
|
||||
EV_ASYNC = 0x00080000, /* async intra-loop signal */
|
||||
EV_CUSTOM = 0x01000000, /* for use by user code */
|
||||
EV_ERROR = 0x80000000 /* sent when an error occurs */
|
||||
EV_ERROR = (-2147483647 - 1) /* sent when an error occurs */
|
||||
};
|
||||
|
||||
/* can be used to add custom fields to all watchers, while losing binary compatibility */
|
|
@ -24,9 +24,11 @@
|
|||
|
||||
#include "ngx-queue.h"
|
||||
|
||||
#include "ev/ev.h"
|
||||
#include "ev.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
|
||||
|
@ -37,13 +39,15 @@ typedef struct {
|
|||
size_t len;
|
||||
} uv_buf_t;
|
||||
|
||||
#define UV_REQ_BUFSML_SIZE (4)
|
||||
|
||||
#define UV_REQ_PRIVATE_FIELDS \
|
||||
int write_index; \
|
||||
ev_timer timer; \
|
||||
ngx_queue_t queue; \
|
||||
uv_buf_t* bufs; \
|
||||
int bufcnt;
|
||||
int bufcnt; \
|
||||
uv_buf_t bufsml[UV_REQ_BUFSML_SIZE];
|
||||
|
||||
|
||||
/* TODO: union or classes please! */
|
||||
|
@ -53,48 +57,64 @@ typedef struct {
|
|||
ev_idle next_watcher;
|
||||
|
||||
|
||||
#define UV_STREAM_PRIVATE_FIELDS \
|
||||
uv_read_cb read_cb; \
|
||||
uv_alloc_cb alloc_cb;
|
||||
|
||||
|
||||
/* UV_TCP */
|
||||
#define UV_TCP_PRIVATE_FIELDS \
|
||||
int delayed_error; \
|
||||
uv_read_cb read_cb; \
|
||||
uv_alloc_cb alloc_cb; \
|
||||
uv_connection_cb connection_cb; \
|
||||
int accepted_fd; \
|
||||
uv_req_t *connect_req; \
|
||||
uv_req_t *shutdown_req; \
|
||||
ev_io read_watcher; \
|
||||
ev_io write_watcher; \
|
||||
ngx_queue_t write_queue;
|
||||
ngx_queue_t write_queue; \
|
||||
ngx_queue_t write_completed_queue;
|
||||
|
||||
|
||||
/* UV_PREPARE */ \
|
||||
#define UV_PREPARE_PRIVATE_FIELDS \
|
||||
ev_prepare prepare_watcher; \
|
||||
uv_loop_cb prepare_cb;
|
||||
uv_prepare_cb prepare_cb;
|
||||
|
||||
|
||||
/* UV_CHECK */
|
||||
#define UV_CHECK_PRIVATE_FIELDS \
|
||||
ev_check check_watcher; \
|
||||
uv_loop_cb check_cb;
|
||||
uv_check_cb check_cb;
|
||||
|
||||
|
||||
/* UV_IDLE */
|
||||
#define UV_IDLE_PRIVATE_FIELDS \
|
||||
ev_idle idle_watcher; \
|
||||
uv_loop_cb idle_cb;
|
||||
uv_idle_cb idle_cb;
|
||||
|
||||
|
||||
/* UV_ASYNC */
|
||||
#define UV_ASYNC_PRIVATE_FIELDS \
|
||||
ev_async async_watcher; \
|
||||
uv_loop_cb async_cb;
|
||||
uv_async_cb async_cb;
|
||||
|
||||
|
||||
/* UV_TIMER */
|
||||
#define UV_TIMER_PRIVATE_FIELDS \
|
||||
ev_timer timer_watcher; \
|
||||
uv_loop_cb timer_cb;
|
||||
uv_timer_cb timer_cb;
|
||||
|
||||
#define UV_ARES_TASK_PRIVATE_FIELDS \
|
||||
int sock; \
|
||||
ev_io read_watcher; \
|
||||
ev_io write_watcher;
|
||||
|
||||
#define UV_GETADDRINFO_PRIVATE_FIELDS \
|
||||
uv_getaddrinfo_cb cb; \
|
||||
struct addrinfo* hints; \
|
||||
char* hostname; \
|
||||
char* service; \
|
||||
struct addrinfo* res; \
|
||||
int retcode;
|
||||
|
||||
#endif /* UV_UNIX_H */
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include "tree.h"
|
||||
|
||||
|
||||
/**
|
||||
* It should be possible to cast uv_buf_t[] to WSABUF[]
|
||||
* see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
|
||||
|
@ -53,10 +52,12 @@ typedef struct uv_buf_t {
|
|||
uv_err_t error; \
|
||||
struct uv_req_s* next_req;
|
||||
|
||||
#define uv_tcp_connection_fields \
|
||||
#define UV_STREAM_PRIVATE_FIELDS \
|
||||
uv_alloc_cb alloc_cb; \
|
||||
uv_read_cb read_cb; \
|
||||
struct uv_req_s read_req; \
|
||||
|
||||
#define uv_tcp_connection_fields \
|
||||
unsigned int write_reqs_pending; \
|
||||
uv_req_t* shutdown_req;
|
||||
|
||||
|
@ -81,32 +82,49 @@ typedef struct uv_buf_t {
|
|||
RB_ENTRY(uv_timer_s) tree_entry; \
|
||||
int64_t due; \
|
||||
int64_t repeat; \
|
||||
uv_loop_cb timer_cb;
|
||||
|
||||
#define UV_LOOP_PRIVATE_FIELDS \
|
||||
uv_handle_t* loop_prev; \
|
||||
uv_handle_t* loop_next; \
|
||||
uv_loop_cb loop_cb;
|
||||
uv_timer_cb timer_cb;
|
||||
|
||||
#define UV_ASYNC_PRIVATE_FIELDS \
|
||||
struct uv_req_s async_req; \
|
||||
/* char to avoid alignment issues */ \
|
||||
char volatile async_sent;
|
||||
|
||||
#define UV_PREPARE_PRIVATE_FIELDS /* empty */
|
||||
#define UV_CHECK_PRIVATE_FIELDS /* empty */
|
||||
#define UV_IDLE_PRIVATE_FIELDS /* empty */
|
||||
#define UV_PREPARE_PRIVATE_FIELDS \
|
||||
uv_prepare_t* prepare_prev; \
|
||||
uv_prepare_t* prepare_next; \
|
||||
uv_prepare_cb prepare_cb;
|
||||
|
||||
/*
|
||||
* TODO: remove UV_LOOP_PRIVATE_FIELDS from UV_HANDLE_PRIVATE_FIELDS and
|
||||
* use it in UV_(PREPARE|CHECK|IDLE)_PRIVATE_FIELDS instead.
|
||||
*/
|
||||
#define UV_CHECK_PRIVATE_FIELDS \
|
||||
uv_check_t* check_prev; \
|
||||
uv_check_t* check_next; \
|
||||
uv_check_cb check_cb;
|
||||
|
||||
#define UV_IDLE_PRIVATE_FIELDS \
|
||||
uv_idle_t* idle_prev; \
|
||||
uv_idle_t* idle_next; \
|
||||
uv_idle_cb idle_cb;
|
||||
|
||||
#define UV_HANDLE_PRIVATE_FIELDS \
|
||||
uv_handle_t* endgame_next; \
|
||||
unsigned int flags; \
|
||||
uv_err_t error; \
|
||||
UV_LOOP_PRIVATE_FIELDS
|
||||
uv_err_t error;
|
||||
|
||||
#define UV_ARES_TASK_PRIVATE_FIELDS \
|
||||
struct uv_req_s ares_req; \
|
||||
SOCKET sock; \
|
||||
HANDLE h_wait; \
|
||||
WSAEVENT h_event; \
|
||||
HANDLE h_close_event;
|
||||
|
||||
#define UV_GETADDRINFO_PRIVATE_FIELDS \
|
||||
struct uv_req_s getadddrinfo_req; \
|
||||
uv_getaddrinfo_cb getaddrinfo_cb; \
|
||||
void* alloc; \
|
||||
wchar_t* node; \
|
||||
wchar_t* service; \
|
||||
struct addrinfoW* hints; \
|
||||
struct addrinfoW* res; \
|
||||
int retcode;
|
||||
|
||||
int uv_utf16_to_utf8(wchar_t* utf16Buffer, size_t utf16Size, char* utf8Buffer, size_t utf8Size);
|
||||
int uv_utf8_to_utf16(const char* utf8Buffer, wchar_t* utf16Buffer, size_t utf16Size);
|
|
@ -28,21 +28,28 @@ extern "C" {
|
|||
#define UV_VERSION_MAJOR 0
|
||||
#define UV_VERSION_MINOR 1
|
||||
|
||||
#define CARES_STATICLIB 1
|
||||
|
||||
#include <stdint.h> /* int64_t */
|
||||
#include <sys/types.h> /* size_t */
|
||||
|
||||
#ifndef ssize_t
|
||||
#include "ares.h"
|
||||
|
||||
#ifndef _SSIZE_T_
|
||||
typedef intptr_t ssize_t;
|
||||
#endif
|
||||
|
||||
typedef struct uv_err_s uv_err_t;
|
||||
typedef struct uv_handle_s uv_handle_t;
|
||||
typedef struct uv_stream_s uv_stream_t;
|
||||
typedef struct uv_tcp_s uv_tcp_t;
|
||||
typedef struct uv_timer_s uv_timer_t;
|
||||
typedef struct uv_prepare_s uv_prepare_t;
|
||||
typedef struct uv_check_s uv_check_t;
|
||||
typedef struct uv_idle_s uv_idle_t;
|
||||
typedef struct uv_req_s uv_req_t;
|
||||
typedef struct uv_async_s uv_async_t;
|
||||
typedef struct uv_getaddrinfo_s uv_getaddrinfo_t;
|
||||
|
||||
|
||||
#if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__)
|
||||
|
@ -60,16 +67,20 @@ typedef struct uv_req_s uv_req_t;
|
|||
* In the case of uv_read_cb the uv_buf_t returned should be freed by the
|
||||
* user.
|
||||
*/
|
||||
typedef uv_buf_t (*uv_alloc_cb)(uv_tcp_t* tcp, size_t suggested_size);
|
||||
typedef void (*uv_read_cb)(uv_tcp_t* tcp, ssize_t nread, uv_buf_t buf);
|
||||
typedef uv_buf_t (*uv_alloc_cb)(uv_stream_t* tcp, size_t suggested_size);
|
||||
typedef void (*uv_read_cb)(uv_stream_t* tcp, ssize_t nread, uv_buf_t buf);
|
||||
typedef void (*uv_write_cb)(uv_req_t* req, int status);
|
||||
typedef void (*uv_connect_cb)(uv_req_t* req, int status);
|
||||
typedef void (*uv_shutdown_cb)(uv_req_t* req, int status);
|
||||
typedef void (*uv_connection_cb)(uv_tcp_t* server, int status);
|
||||
typedef void (*uv_connection_cb)(uv_handle_t* server, int status);
|
||||
typedef void (*uv_close_cb)(uv_handle_t* handle);
|
||||
/* TODO: do loop_cb and async_cb really need a status argument? */
|
||||
typedef void (*uv_loop_cb)(uv_handle_t* handle, int status);
|
||||
typedef void (*uv_async_cb)(uv_handle_t* handle, int status);
|
||||
typedef void (*uv_timer_cb)(uv_timer_t* handle, int status);
|
||||
/* TODO: do these really need a status argument? */
|
||||
typedef void (*uv_async_cb)(uv_async_t* handle, int status);
|
||||
typedef void (*uv_prepare_cb)(uv_prepare_t* handle, int status);
|
||||
typedef void (*uv_check_cb)(uv_check_t* handle, int status);
|
||||
typedef void (*uv_idle_cb)(uv_idle_t* handle, int status);
|
||||
typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* handle, int status, struct addrinfo* res);
|
||||
|
||||
|
||||
/* Expand this list if necessary. */
|
||||
|
@ -108,7 +119,12 @@ typedef enum {
|
|||
UV_EPROTO,
|
||||
UV_EPROTONOSUPPORT,
|
||||
UV_EPROTOTYPE,
|
||||
UV_ETIMEDOUT
|
||||
UV_ETIMEDOUT,
|
||||
UV_ECHARSET,
|
||||
UV_EAIFAMNOSUPPORT,
|
||||
UV_EAINONAME,
|
||||
UV_EAISERVICE,
|
||||
UV_EAISOCKTYPE
|
||||
} uv_err_code;
|
||||
|
||||
typedef enum {
|
||||
|
@ -121,7 +137,10 @@ typedef enum {
|
|||
UV_PREPARE,
|
||||
UV_CHECK,
|
||||
UV_IDLE,
|
||||
UV_ASYNC
|
||||
UV_ASYNC,
|
||||
UV_ARES,
|
||||
UV_ARES_TASK,
|
||||
UV_GETADDRINFO
|
||||
} uv_handle_type;
|
||||
|
||||
typedef enum {
|
||||
|
@ -148,7 +167,7 @@ struct uv_req_s {
|
|||
uv_req_type type;
|
||||
/* public */
|
||||
uv_handle_t* handle;
|
||||
void* cb;
|
||||
void *(*cb)(void *);
|
||||
void* data;
|
||||
/* private */
|
||||
UV_REQ_PRIVATE_FIELDS
|
||||
|
@ -157,7 +176,9 @@ struct uv_req_s {
|
|||
/*
|
||||
* Initialize a request for use with uv_write, uv_shutdown, or uv_connect.
|
||||
*/
|
||||
void uv_req_init(uv_req_t* req, uv_handle_t* handle, void* cb);
|
||||
void uv_req_init(uv_req_t* req, uv_handle_t* handle, void *(*cb)(void *));
|
||||
|
||||
int uv_shutdown(uv_req_t* req);
|
||||
|
||||
|
||||
#define UV_HANDLE_FIELDS \
|
||||
|
@ -167,7 +188,7 @@ void uv_req_init(uv_req_t* req, uv_handle_t* handle, void* cb);
|
|||
uv_close_cb close_cb; \
|
||||
void* data; \
|
||||
/* private */ \
|
||||
UV_HANDLE_PRIVATE_FIELDS \
|
||||
UV_HANDLE_PRIVATE_FIELDS
|
||||
|
||||
/* The abstract base class of all handles. */
|
||||
struct uv_handle_s {
|
||||
|
@ -187,33 +208,29 @@ int uv_is_active(uv_handle_t* handle);
|
|||
int uv_close(uv_handle_t* handle, uv_close_cb close_cb);
|
||||
|
||||
|
||||
/*
|
||||
* A subclass of uv_handle_t representing a TCP stream or TCP server. In the
|
||||
* future this will probably be split into two classes - one a stream and
|
||||
* the other a server.
|
||||
*/
|
||||
struct uv_tcp_s {
|
||||
#define UV_STREAM_FIELDS \
|
||||
/* number of bytes queued for writing */ \
|
||||
size_t write_queue_size; \
|
||||
/* private */ \
|
||||
UV_STREAM_PRIVATE_FIELDS
|
||||
|
||||
/* The abstract base class for all streams. */
|
||||
struct uv_stream_s {
|
||||
UV_HANDLE_FIELDS
|
||||
size_t write_queue_size; /* number of bytes queued for writing */
|
||||
UV_TCP_PRIVATE_FIELDS
|
||||
UV_STREAM_FIELDS
|
||||
};
|
||||
|
||||
int uv_tcp_init(uv_tcp_t* handle);
|
||||
|
||||
int uv_bind(uv_tcp_t* handle, struct sockaddr_in);
|
||||
|
||||
int uv_connect(uv_req_t* req, struct sockaddr_in);
|
||||
|
||||
int uv_shutdown(uv_req_t* req);
|
||||
|
||||
int uv_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb);
|
||||
|
||||
/* This call is used in conjunction with uv_listen() to accept incoming TCP
|
||||
/* This call is used in conjunction with uv_listen() to accept incoming
|
||||
* connections. Call uv_accept after receiving a uv_connection_cb to accept
|
||||
* the connection. Before calling uv_accept use uv_tcp_init() must be
|
||||
* the connection. Before calling uv_accept use uv_*_init() must be
|
||||
* called on the client. Non-zero return value indicates an error.
|
||||
*
|
||||
* When the uv_connection_cb is called it is guaranteed that uv_accept will
|
||||
* complete successfully the first time. If you attempt to use it more than
|
||||
* once, it may fail. It is suggested to only call uv_accept once per
|
||||
* uv_connection_cb call.
|
||||
*/
|
||||
int uv_accept(uv_tcp_t* server, uv_tcp_t* client);
|
||||
int uv_accept(uv_handle_t* server, uv_stream_t* client);
|
||||
|
||||
/* Read data from an incoming stream. The callback will be made several
|
||||
* several times until there is no more data to read or uv_read_stop is
|
||||
|
@ -224,13 +241,52 @@ int uv_accept(uv_tcp_t* server, uv_tcp_t* client);
|
|||
* eof; it happens when libuv requested a buffer through the alloc callback
|
||||
* but then decided that it didn't need that buffer.
|
||||
*/
|
||||
int uv_read_start(uv_tcp_t*, uv_alloc_cb alloc_cb, uv_read_cb read_cb);
|
||||
int uv_read_start(uv_stream_t*, uv_alloc_cb alloc_cb, uv_read_cb read_cb);
|
||||
|
||||
int uv_read_stop(uv_tcp_t*);
|
||||
int uv_read_stop(uv_stream_t*);
|
||||
|
||||
/* Write data to stream. Buffers are written in order. Example:
|
||||
*
|
||||
* uv_buf_t a[] = {
|
||||
* { .base = "1", .len = 1 },
|
||||
* { .base = "2", .len = 1 }
|
||||
* };
|
||||
*
|
||||
* uv_buf_t b[] = {
|
||||
* { .base = "3", .len = 1 },
|
||||
* { .base = "4", .len = 1 }
|
||||
* };
|
||||
*
|
||||
* // writes "1234"
|
||||
* uv_write(req, a, 2);
|
||||
* uv_write(req, b, 2);
|
||||
*
|
||||
*/
|
||||
int uv_write(uv_req_t* req, uv_buf_t bufs[], int bufcnt);
|
||||
|
||||
|
||||
/*
|
||||
* A subclass of uv_stream_t representing a TCP stream or TCP server. In the
|
||||
* future this will probably be split into two classes - one a stream and
|
||||
* the other a server.
|
||||
*/
|
||||
struct uv_tcp_s {
|
||||
UV_HANDLE_FIELDS
|
||||
UV_STREAM_FIELDS
|
||||
UV_TCP_PRIVATE_FIELDS
|
||||
};
|
||||
|
||||
int uv_tcp_init(uv_tcp_t* handle);
|
||||
|
||||
int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in);
|
||||
int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6);
|
||||
|
||||
int uv_tcp_connect(uv_req_t* req, struct sockaddr_in);
|
||||
int uv_tcp_connect6(uv_req_t* req, struct sockaddr_in6);
|
||||
|
||||
int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb);
|
||||
|
||||
|
||||
/*
|
||||
* Subclass of uv_handle_t. libev wrapper. Every active prepare handle gets
|
||||
* its callback called exactly once per loop iteration, just before the
|
||||
|
@ -243,7 +299,7 @@ struct uv_prepare_s {
|
|||
|
||||
int uv_prepare_init(uv_prepare_t* prepare);
|
||||
|
||||
int uv_prepare_start(uv_prepare_t* prepare, uv_loop_cb cb);
|
||||
int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb);
|
||||
|
||||
int uv_prepare_stop(uv_prepare_t* prepare);
|
||||
|
||||
|
@ -260,7 +316,7 @@ struct uv_check_s {
|
|||
|
||||
int uv_check_init(uv_check_t* check);
|
||||
|
||||
int uv_check_start(uv_check_t* check, uv_loop_cb cb);
|
||||
int uv_check_start(uv_check_t* check, uv_check_cb cb);
|
||||
|
||||
int uv_check_stop(uv_check_t* check);
|
||||
|
||||
|
@ -278,7 +334,7 @@ struct uv_idle_s {
|
|||
|
||||
int uv_idle_init(uv_idle_t* idle);
|
||||
|
||||
int uv_idle_start(uv_idle_t* idle, uv_loop_cb cb);
|
||||
int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb);
|
||||
|
||||
int uv_idle_stop(uv_idle_t* idle);
|
||||
|
||||
|
@ -291,10 +347,10 @@ int uv_idle_stop(uv_idle_t* idle);
|
|||
* after the call to async_send. Unlike all other libuv functions,
|
||||
* uv_async_send can be called from another thread.
|
||||
*/
|
||||
typedef struct {
|
||||
struct uv_async_s {
|
||||
UV_HANDLE_FIELDS
|
||||
UV_ASYNC_PRIVATE_FIELDS
|
||||
} uv_async_t;
|
||||
};
|
||||
|
||||
int uv_async_init(uv_async_t* async, uv_async_cb async_cb);
|
||||
|
||||
|
@ -312,7 +368,7 @@ struct uv_timer_s {
|
|||
|
||||
int uv_timer_init(uv_timer_t* timer);
|
||||
|
||||
int uv_timer_start(uv_timer_t* timer, uv_loop_cb cb, int64_t timeout, int64_t repeat);
|
||||
int uv_timer_start(uv_timer_t* timer, uv_timer_cb cb, int64_t timeout, int64_t repeat);
|
||||
|
||||
int uv_timer_stop(uv_timer_t* timer);
|
||||
|
||||
|
@ -334,6 +390,37 @@ void uv_timer_set_repeat(uv_timer_t* timer, int64_t repeat);
|
|||
int64_t uv_timer_get_repeat(uv_timer_t* timer);
|
||||
|
||||
|
||||
/* c-ares integration initialize and terminate */
|
||||
int uv_ares_init_options(ares_channel *channelptr,
|
||||
struct ares_options *options,
|
||||
int optmask);
|
||||
|
||||
void uv_ares_destroy(ares_channel channel);
|
||||
|
||||
|
||||
/*
|
||||
* Subclass of uv_handle_t. Used for integration of getaddrinfo.
|
||||
*/
|
||||
struct uv_getaddrinfo_s {
|
||||
UV_HANDLE_FIELDS
|
||||
UV_GETADDRINFO_PRIVATE_FIELDS
|
||||
};
|
||||
|
||||
|
||||
/* uv_getaddrinfo
|
||||
* return code of UV_OK means that request is accepted,
|
||||
* and callback will be called with result.
|
||||
* Other return codes mean that there will not be a callback.
|
||||
* Input arguments may be released after return from this call.
|
||||
* Callback must not call freeaddrinfo
|
||||
*/
|
||||
int uv_getaddrinfo(uv_getaddrinfo_t* handle,
|
||||
uv_getaddrinfo_cb getaddrinfo_cb,
|
||||
const char* node,
|
||||
const char* service,
|
||||
const struct addrinfo* hints);
|
||||
|
||||
|
||||
/*
|
||||
* Most functions return boolean: 0 for success and -1 for failure.
|
||||
* On error the user should then call uv_last_error() to determine
|
||||
|
@ -358,10 +445,22 @@ int64_t uv_now();
|
|||
|
||||
|
||||
/* Utility */
|
||||
struct sockaddr_in uv_ip4_addr(char* ip, int port);
|
||||
struct sockaddr_in uv_ip4_addr(const char* ip, int port);
|
||||
struct sockaddr_in6 uv_ip6_addr(const char* ip, int port);
|
||||
|
||||
/* Gets the executable path */
|
||||
int uv_get_exepath(char* buffer, size_t* size);
|
||||
int uv_exepath(char* buffer, size_t* size);
|
||||
|
||||
/*
|
||||
* Returns the current high-resolution real time. This is expressed in
|
||||
* nanoseconds. It is relative to an arbitrary time in the past. It is not
|
||||
* related to the time of day and therefore not subject to clock drift. The
|
||||
* primary use is for measuring performance between intervals.
|
||||
*
|
||||
* Note not every platform can support nanosecond resolution; however, this
|
||||
* value will always be in nanoseconds.
|
||||
*/
|
||||
extern uint64_t uv_hrtime(void);
|
||||
|
||||
|
||||
/* the presence of this union forces similar struct layout */
|
||||
|
@ -372,6 +471,7 @@ union uv_any_handle {
|
|||
uv_idle_t idle;
|
||||
uv_async_t async;
|
||||
uv_timer_t timer;
|
||||
uv_getaddrinfo_t getaddrinfo;
|
||||
};
|
||||
|
||||
/* Diagnostic counters */
|
||||
|
@ -386,7 +486,19 @@ typedef struct {
|
|||
uint64_t timer_init;
|
||||
} uv_counters_t;
|
||||
|
||||
uv_counters_t* const uv_counters();
|
||||
uv_counters_t* uv_counters();
|
||||
|
||||
|
||||
/* Don't export the private CPP symbols. */
|
||||
#undef UV_REQ_PRIVATE_FIELDS
|
||||
#undef UV_STREAM_PRIVATE_FIELDS
|
||||
#undef UV_TCP_PRIVATE_FIELDS
|
||||
#undef UV_PREPARE_PRIVATE_FIELDS
|
||||
#undef UV_CHECK_PRIVATE_FIELDS
|
||||
#undef UV_IDLE_PRIVATE_FIELDS
|
||||
#undef UV_ASYNC_PRIVATE_FIELDS
|
||||
#undef UV_TIMER_PRIVATE_FIELDS
|
||||
#undef UV_GETADDRINFO_PRIVATE_FIELDS
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;HAVE_CONFIG_H;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;HAVE_CONFIG_H;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;HAVE_CONFIG_H;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;HAVE_CONFIG_H;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\ares\ares__close_sockets.c" />
|
||||
<ClCompile Include="..\src\ares\ares__get_hostent.c" />
|
||||
<ClCompile Include="..\src\ares\ares__read_line.c" />
|
||||
<ClCompile Include="..\src\ares\ares__timeval.c" />
|
||||
<ClCompile Include="..\src\ares\ares_cancel.c" />
|
||||
<ClCompile Include="..\src\ares\ares_data.c" />
|
||||
<ClCompile Include="..\src\ares\ares_destroy.c" />
|
||||
<ClCompile Include="..\src\ares\ares_expand_name.c" />
|
||||
<ClCompile Include="..\src\ares\ares_expand_string.c" />
|
||||
<ClCompile Include="..\src\ares\ares_fds.c" />
|
||||
<ClCompile Include="..\src\ares\ares_free_hostent.c" />
|
||||
<ClCompile Include="..\src\ares\ares_free_string.c" />
|
||||
<ClCompile Include="..\src\ares\ares_gethostbyaddr.c" />
|
||||
<ClCompile Include="..\src\ares\ares_gethostbyname.c" />
|
||||
<ClCompile Include="..\src\ares\ares_getnameinfo.c" />
|
||||
<ClCompile Include="..\src\ares\ares_getsock.c" />
|
||||
<ClCompile Include="..\src\ares\ares_init.c" />
|
||||
<ClCompile Include="..\src\ares\ares_library_init.c" />
|
||||
<ClCompile Include="..\src\ares\ares_llist.c" />
|
||||
<ClCompile Include="..\src\ares\ares_mkquery.c" />
|
||||
<ClCompile Include="..\src\ares\ares_nowarn.c" />
|
||||
<ClCompile Include="..\src\ares\ares_options.c" />
|
||||
<ClCompile Include="..\src\ares\ares_parse_a_reply.c" />
|
||||
<ClCompile Include="..\src\ares\ares_parse_aaaa_reply.c" />
|
||||
<ClCompile Include="..\src\ares\ares_parse_mx_reply.c" />
|
||||
<ClCompile Include="..\src\ares\ares_parse_ns_reply.c" />
|
||||
<ClCompile Include="..\src\ares\ares_parse_ptr_reply.c" />
|
||||
<ClCompile Include="..\src\ares\ares_parse_srv_reply.c" />
|
||||
<ClCompile Include="..\src\ares\ares_parse_txt_reply.c" />
|
||||
<ClCompile Include="..\src\ares\ares_process.c" />
|
||||
<ClCompile Include="..\src\ares\ares_query.c" />
|
||||
<ClCompile Include="..\src\ares\ares_search.c" />
|
||||
<ClCompile Include="..\src\ares\ares_send.c" />
|
||||
<ClCompile Include="..\src\ares\ares_strcasecmp.c" />
|
||||
<ClCompile Include="..\src\ares\ares_strdup.c" />
|
||||
<ClCompile Include="..\src\ares\ares_strerror.c" />
|
||||
<ClCompile Include="..\src\ares\ares_timeout.c" />
|
||||
<ClCompile Include="..\src\ares\ares_version.c" />
|
||||
<ClCompile Include="..\src\ares\ares_writev.c" />
|
||||
<ClCompile Include="..\src\ares\bitncmp.c" />
|
||||
<ClCompile Include="..\src\ares\inet_net_pton.c" />
|
||||
<ClCompile Include="..\src\ares\inet_ntop.c" />
|
||||
<ClCompile Include="..\src\ares\windows_port.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\ares.h" />
|
||||
<ClInclude Include="..\include\ares_version.h" />
|
||||
<ClInclude Include="..\src\ares\ares_data.h" />
|
||||
<ClInclude Include="..\src\ares\ares_dns.h" />
|
||||
<ClInclude Include="..\src\ares\ares_iphlpapi.h" />
|
||||
<ClInclude Include="..\src\ares\ares_ipv6.h" />
|
||||
<ClInclude Include="..\src\ares\ares_library_init.h" />
|
||||
<ClInclude Include="..\src\ares\ares_llist.h" />
|
||||
<ClInclude Include="..\src\ares\ares_nowarn.h" />
|
||||
<ClInclude Include="..\src\ares\ares_private.h" />
|
||||
<ClInclude Include="..\src\ares\ares_rules.h" />
|
||||
<ClInclude Include="..\src\ares\ares_setup.h" />
|
||||
<ClInclude Include="..\src\ares\ares_strcasecmp.h" />
|
||||
<ClInclude Include="..\src\ares\ares_strdup.h" />
|
||||
<ClInclude Include="..\src\ares\ares_version.h" />
|
||||
<ClInclude Include="..\src\ares\ares_writev.h" />
|
||||
<ClInclude Include="..\src\ares\bitncmp.h" />
|
||||
<ClInclude Include="..\src\ares\config_win32\ares_config.h" />
|
||||
<ClInclude Include="..\src\ares\inet_net_pton.h" />
|
||||
<ClInclude Include="..\src\ares\inet_ntop.h" />
|
||||
<ClInclude Include="..\src\ares\nameser.h" />
|
||||
<ClInclude Include="..\src\ares\setup_once.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -81,6 +81,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
|
@ -96,6 +97,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
@ -109,6 +111,7 @@
|
|||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
|
@ -125,6 +128,7 @@
|
|||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
@ -135,28 +139,19 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\test\benchmark-ares.c" />
|
||||
<ClCompile Include="..\test\benchmark-getaddrinfo.c" />
|
||||
<ClCompile Include="..\test\benchmark-ping-pongs.c" />
|
||||
<ClCompile Include="..\test\benchmark-pump.c" />
|
||||
<ClCompile Include="..\test\benchmark-sizes.c" />
|
||||
<ClCompile Include="..\test\dns-server.c" />
|
||||
<ClCompile Include="..\test\echo-server.c" />
|
||||
<ClCompile Include="..\test\run-benchmarks.c" />
|
||||
<ClCompile Include="..\test\runner-unix.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test\runner-win.c" />
|
||||
<ClCompile Include="..\test\runner.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\test\benchmark-list.h" />
|
||||
<ClInclude Include="..\test\runner-unix.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\test\runner-win.h" />
|
||||
<ClInclude Include="..\test\runner.h" />
|
||||
<ClInclude Include="..\test\task.h" />
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
|
@ -97,6 +98,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
@ -110,6 +112,7 @@
|
|||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
|
@ -126,6 +129,7 @@
|
|||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
@ -137,18 +141,16 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\test\echo-server.c" />
|
||||
<ClCompile Include="..\test\runner-unix.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test\test-async.c" />
|
||||
<ClCompile Include="..\test\test-bind6-error.c" />
|
||||
<ClCompile Include="..\test\test-delayed-accept.c" />
|
||||
<ClCompile Include="..\test\test-callback-stack.c" />
|
||||
<ClCompile Include="..\test\test-connection-fail.c" />
|
||||
<ClCompile Include="..\test\test-get-currentexe.c" />
|
||||
<ClCompile Include="..\test\test-fail-always.c" />
|
||||
<ClCompile Include="..\test\test-gethostbyname.c" />
|
||||
<ClCompile Include="..\test\test-getaddrinfo.c" />
|
||||
<ClCompile Include="..\test\test-hrtime.c" />
|
||||
<ClCompile Include="..\test\test-loop-handles.c" />
|
||||
<ClCompile Include="..\test\test-pass-always.c" />
|
||||
<ClCompile Include="..\test\test-ping-pong.c" />
|
||||
|
@ -162,12 +164,6 @@
|
|||
<ClCompile Include="..\test\run-tests.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\test\runner-unix.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\test\test-list.h" />
|
||||
<ClInclude Include="..\test\runner-win.h" />
|
||||
<ClInclude Include="..\test\runner.h" />
|
||||
|
|
|
@ -7,6 +7,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libuv-test", "libuv-test.vc
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libuv-benchmark", "libuv-benchmark.vcxproj", "{6CCBDAFD-7A11-133D-357B-E2D2F4C621E4}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c-ares", "c-ares.vcxproj", "{2B6A4644-EBA9-DFB5-AF35-6C56EDF05C7F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -39,6 +41,14 @@ Global
|
|||
{6CCBDAFD-7A11-133D-357B-E2D2F4C621E4}.Release|Win32.Build.0 = Release|Win32
|
||||
{6CCBDAFD-7A11-133D-357B-E2D2F4C621E4}.Release|x64.ActiveCfg = Release|x64
|
||||
{6CCBDAFD-7A11-133D-357B-E2D2F4C621E4}.Release|x64.Build.0 = Release|x64
|
||||
{2B6A4644-EBA9-DFB5-AF35-6C56EDF05C7F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{2B6A4644-EBA9-DFB5-AF35-6C56EDF05C7F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{2B6A4644-EBA9-DFB5-AF35-6C56EDF05C7F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2B6A4644-EBA9-DFB5-AF35-6C56EDF05C7F}.Debug|x64.Build.0 = Debug|x64
|
||||
{2B6A4644-EBA9-DFB5-AF35-6C56EDF05C7F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{2B6A4644-EBA9-DFB5-AF35-6C56EDF05C7F}.Release|Win32.Build.0 = Release|Win32
|
||||
{2B6A4644-EBA9-DFB5-AF35-6C56EDF05C7F}.Release|x64.ActiveCfg = Release|x64
|
||||
{2B6A4644-EBA9-DFB5-AF35-6C56EDF05C7F}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
|
@ -87,48 +88,42 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\include;..\src\ares\config_win32</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\ngx-queue.h" />
|
||||
<ClInclude Include="..\uv-unix.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\uv-win.h" />
|
||||
<ClInclude Include="..\uv.h" />
|
||||
<ClInclude Include="..\tree.h" />
|
||||
<ProjectReference Include="c-ares.vcxproj">
|
||||
<Project>{2b6a4644-eba9-dfb5-af35-6c56edf05c7f}</Project>
|
||||
<Private>true</Private>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\uv-unix.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\uv-win.c" />
|
||||
<ClCompile Include="..\uv-common.c" />
|
||||
<ClCompile Include="..\src\uv-common.c" />
|
||||
<ClCompile Include="..\src\uv-win.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\AUTHORS" />
|
||||
<None Include="..\config-mingw.mk" />
|
||||
<None Include="..\config-unix.mk" />
|
||||
<None Include="..\iocp-links.html" />
|
||||
<None Include="..\LICENSE" />
|
||||
<None Include="..\Makefile" />
|
||||
<None Include="..\README" />
|
||||
<ClInclude Include="..\include\ares.h" />
|
||||
<ClInclude Include="..\include\ares_version.h" />
|
||||
<ClInclude Include="..\include\tree.h" />
|
||||
<ClInclude Include="..\include\uv-win.h" />
|
||||
<ClInclude Include="..\include\uv.h" />
|
||||
<ClInclude Include="..\src\uv-common.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
c-ares is based on ares, and these are the people that have worked on it since
|
||||
the fork was made:
|
||||
|
||||
Alexander Lazic
|
||||
Alexey Simak
|
||||
Andreas Rieke
|
||||
Ashish Sharma
|
||||
Brad House
|
||||
Brad Spencer
|
||||
Bram Matthys
|
||||
Dan Fandrich
|
||||
Daniel Stenberg
|
||||
Dirk Manske
|
||||
Dominick Meglio
|
||||
Doug Goldstein
|
||||
Duncan Wilcox
|
||||
Eino Tuominen
|
||||
Erik Kline
|
||||
George Neill
|
||||
Gisle Vanem
|
||||
Guilherme Balena Versiani
|
||||
Gunter Knauf
|
||||
Henrik Stoerner
|
||||
James Bursa
|
||||
Michael Wallner
|
||||
Nick Mathewson
|
||||
Phil Blundell
|
||||
Ravi Pratap
|
||||
Robin Cornelius
|
||||
Sebastian at basti79.de
|
||||
Shmulik Regev
|
||||
Steinar H. Gunderson
|
||||
Tofu Linden
|
||||
Vlad Dinulescu
|
||||
William Ahern
|
||||
Yang Tse
|
||||
liren at vivisimo.com
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,22 @@
|
|||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${node_platform}-${cares_arch})
|
||||
add_definitions(-DHAVE_CONFIG_H=1)
|
||||
|
||||
include(CheckLibraryExists)
|
||||
check_library_exists(socket socket "" HAVE_SOCKET_LIB)
|
||||
check_library_exists(nsl gethostbyname "" HAVE_NSL_LIB)
|
||||
|
||||
file(GLOB lib_sources *.c)
|
||||
add_library(cares ${lib_sources})
|
||||
|
||||
if(${HAVE_SOCKET_LIB})
|
||||
set(cares_libs ${cares_libs} socket)
|
||||
endif()
|
||||
|
||||
if(${HAVE_NSL_LIB})
|
||||
set(cares_libs ${cares_libs} nsl)
|
||||
endif()
|
||||
|
||||
if(cares_libs)
|
||||
target_link_libraries(cares ${cares_libs})
|
||||
endif()
|
|
@ -0,0 +1,21 @@
|
|||
Major changes since:
|
||||
* see the CHANGES file
|
||||
|
||||
Major changes in release 1.1.1:
|
||||
* ares should now compile as C++ code (no longer uses reserved word
|
||||
"class").
|
||||
* Added SRV support to adig test program.
|
||||
* Fixed a few error handling bugs in query processing.
|
||||
|
||||
Major changes in release 1.1.0:
|
||||
* Added ares_free_string() function so that memory can be freed in the
|
||||
same layer as it is allocated, a desirable feature in some
|
||||
environments.
|
||||
* A few of the ares_dns.h macros are fixed to use the proper bitwise
|
||||
operator.
|
||||
* Fixed a couple of fenceposts fixed in ares_expand_name()'s
|
||||
bounds-checking.
|
||||
* In process_timeouts(), extract query->next before calling
|
||||
next_server() and possibly freeing the query structure.
|
||||
* Casted arguments to ctype macros casted to unsigned char, since not
|
||||
all char values are valid inputs to those macros according to ANSI.
|
|
@ -0,0 +1,60 @@
|
|||
c-ares
|
||||
======
|
||||
|
||||
This is c-ares, an asynchronous resolver library. It is intended for
|
||||
applications which need to perform DNS queries without blocking, or need to
|
||||
perform multiple DNS queries in parallel. The primary examples of such
|
||||
applications are servers which communicate with multiple clients and programs
|
||||
with graphical user interfaces.
|
||||
|
||||
The full source code is available in the 'c-ares' release archives, and in a
|
||||
git repository: http://github.com/bagder/c-ares
|
||||
|
||||
If you find bugs, correct flaws, have questions or have comments in general in
|
||||
regard to c-ares (or by all means the original ares too), get in touch with us
|
||||
on the c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares
|
||||
|
||||
c-ares is of course distributed under the same MIT-style license as the
|
||||
original ares.
|
||||
|
||||
You'll find all c-ares details and news here:
|
||||
|
||||
http://c-ares.haxx.se/
|
||||
|
||||
|
||||
NOTES FOR C-ARES HACKERS
|
||||
|
||||
The following notes apply to c-ares version 1.7.0 and later.
|
||||
|
||||
* The distributed ares_build.h file is only intended to be used on systems
|
||||
which can not run the also distributed configure script.
|
||||
|
||||
* The distributed ares_build.h file is generated as a copy of ares_build.h.dist
|
||||
when the c-ares source code distribution archive file is originally created.
|
||||
|
||||
* If you check out from git on a non-configure platform, you must run the
|
||||
appropriate buildconf* script to set up ares_build.h and other local files
|
||||
before being able of compiling the library.
|
||||
|
||||
* On systems capable of running the configure script, the configure process
|
||||
will overwrite the distributed ares_build.h file with one that is suitable
|
||||
and specific to the library being configured and built, this new file is
|
||||
generated from the ares_build.h.in template file.
|
||||
|
||||
* If you intend to distribute an already compiled c-ares library you _MUST_
|
||||
also distribute along with it the generated ares_build.h which has been
|
||||
used to compile it. Otherwise the library will be of no use for the users of
|
||||
the library that you have built. It is _your_ responsibility to provide this
|
||||
file. No one at the c-ares project can know how you have built the library.
|
||||
|
||||
* File ares_build.h includes platform and configuration dependent info,
|
||||
and must not be modified by anyone. Configure script generates it for you.
|
||||
|
||||
* We cannot assume anything else but very basic compiler features being
|
||||
present. While c-ares requires an ANSI C compiler to build, some of the
|
||||
earlier ANSI compilers clearly can't deal with some preprocessor operators.
|
||||
|
||||
* Newlines must remain unix-style for older compilers' sake.
|
||||
|
||||
* Comments must be written in the old-style /* unnested C-fashion */
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
c-ares
|
||||
======
|
||||
|
||||
This package is based on ares 1.1.1 (written by Greg Hudson). I decided to
|
||||
fork and release a separate project since the ares author didn't want the
|
||||
improvements that were vital for our use of it.
|
||||
|
||||
This package is dubbed 'c-ares' since I (Daniel Stenberg) wanted this for use
|
||||
within the curl project (hence the letter C) and it makes a nice pun. Also,
|
||||
c-ares is not API compatible with ares: a new name makes that more obvious to
|
||||
the public.
|
||||
|
||||
The original libares was distributed at athena-dist.mit.edu:pub/ATHENA/ares.
|
|
@ -0,0 +1,118 @@
|
|||
|
||||
|
||||
___ __ _ _ __ ___ ___
|
||||
/ __| ___ / _` | '__/ _ \/ __|
|
||||
| (_ |___| (_| | | | __/\__ \
|
||||
\___| \__,_|_| \___||___/
|
||||
|
||||
|
||||
How to build c-ares using MSVC or Visual Studio
|
||||
=================================================
|
||||
|
||||
|
||||
|
||||
How to build using MSVC from the command line
|
||||
---------------------------------------------
|
||||
|
||||
Open a command prompt window and ensure that the environment is properly
|
||||
set up in order to use MSVC or Visual Studio compiler tools.
|
||||
|
||||
Change to c-ares source folder where Makefile.msvc file is located and run:
|
||||
|
||||
> nmake -f Makefile.msvc
|
||||
|
||||
This will build all c-ares libraries as well as three sample programs.
|
||||
|
||||
Once the above command has finished a new folder named MSVCXX will exist
|
||||
below the folder where makefile.msvc is found. The name of the folder
|
||||
depends on the MSVC compiler version being used to build c-ares.
|
||||
|
||||
Below the MSVCXX folder there will exist four folders named 'cares',
|
||||
'ahost', 'acountry', and 'adig'. The 'cares' folder is the one that
|
||||
holds the c-ares libraries you have just generated, the other three
|
||||
hold sample programs that use the libraries.
|
||||
|
||||
The above command builds four versions of the c-ares library, dynamic
|
||||
and static versions and each one in release and debug flavours. Each
|
||||
of these is found in folders named dll-release, dll-debug, lib-release,
|
||||
and lib-debug, which hang from the 'cares' folder mentioned above. Each
|
||||
sample program also has folders with the same names to reflect which
|
||||
library version it is using.
|
||||
|
||||
|
||||
How to build using Visual Studio 6 IDE
|
||||
--------------------------------------
|
||||
|
||||
A VC++ 6.0 reference workspace (vc6aws.dsw) is available within the 'vc'
|
||||
folder to allow proper building of the library and sample programs.
|
||||
|
||||
1) Open the vc6aws.dsw workspace with MSVC6's IDE.
|
||||
2) Select 'Build' from top menu.
|
||||
3) Select 'Batch Build' from dropdown menu.
|
||||
4) Make sure that the sixteen project configurations are 'checked'.
|
||||
5) Click on the 'Build' button.
|
||||
6) Once the sixteen project configurations are built you are done.
|
||||
|
||||
Dynamic and static c-ares libraries are built in debug and release flavours,
|
||||
and can be located each one in its own subdirectory, dll-debug, dll-release,
|
||||
lib-debug and lib-release, all of them below the 'vc\cares' subdirectory.
|
||||
|
||||
In the same way four executable versions of each sample program are built,
|
||||
each using its respective library. The resulting sample executables are
|
||||
located in its own subdirectory, dll-debug, dll-release, lib-debug and
|
||||
lib-release, below the 'vc\acountry', 'vc\adig' and 'vc\ahost'folders.
|
||||
|
||||
These reference VC++ 6.0 configurations are generated using the dynamic CRT.
|
||||
|
||||
|
||||
How to build using Visual Studio 2003 or newer IDE
|
||||
--------------------------------------------------
|
||||
|
||||
First you have to convert the VC++ 6.0 reference workspace and project files
|
||||
to the Visual Studio IDE version you are using, following next steps:
|
||||
|
||||
1) Open vc\vc6aws.dsw with VS20XX.
|
||||
2) Allow VS20XX to update all projects and workspaces.
|
||||
3) Save ALL and close VS20XX.
|
||||
4) Open vc\vc6aws.sln with VS20XX.
|
||||
5) Select batch build, check 'all' projects and click 'build' button.
|
||||
|
||||
Same comments relative to generated files and folders as done above for
|
||||
Visual Studio 6 IDE apply here.
|
||||
|
||||
|
||||
Relationship between c-ares library file names and versions
|
||||
-----------------------------------------------------------
|
||||
|
||||
c-ares static release library version files:
|
||||
|
||||
libcares.lib -> static release library
|
||||
|
||||
c-ares static debug library version files:
|
||||
|
||||
libcaresd.lib -> static debug library
|
||||
|
||||
c-ares dynamic release library version files:
|
||||
|
||||
cares.dll -> dynamic release library
|
||||
cares.lib -> import library for the dynamic release library
|
||||
cares.exp -> export file for the dynamic release library
|
||||
|
||||
c-ares dynamic debug library version files:
|
||||
|
||||
caresd.dll -> dynamic debug library
|
||||
caresd.lib -> import library for the dynamic debug library
|
||||
caresd.exp -> export file for the dynamic debug library
|
||||
caresd.pdb -> debug symbol file for the dynamic debug library
|
||||
|
||||
|
||||
How to use c-ares static libraries
|
||||
----------------------------------
|
||||
|
||||
When using the c-ares static library in your program, you will have to
|
||||
define preprocessor symbol CARES_STATICLIB while building your program,
|
||||
otherwise you will get errors at linkage stage.
|
||||
|
||||
|
||||
Have Fun!
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
Library: c-ares, DNS resolver
|
||||
|
||||
Version: 1.7.3 (11 June, 2010)
|
||||
|
||||
Authors: Greg Hudson, Daniel Stenberg
|
||||
|
||||
License: MIT
|
||||
|
||||
Notes:
|
||||
|
||||
Just use waf instead of the autoconf based configure script. Delete most of
|
||||
the documentation and other files distributed with it. To upgrade, run
|
||||
./configure on linux, macintosh, solaris (and other supported platforms) and
|
||||
copy
|
||||
- ares_config.h
|
||||
- ares_setup.h
|
||||
- ares_build.h
|
||||
into the appropriate directory.
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
c-ares version 1.7.4
|
||||
|
||||
Changed:
|
||||
|
||||
o local-bind: Support binding to local interface/IPs, see
|
||||
ares_set_local_ip4, ares_set_local_ip6, ares_set_local_dev
|
||||
|
||||
Fixed:
|
||||
|
||||
o memory leak in ares_getnameinfo
|
||||
o add missing break that caused get_ares_servers to fail
|
||||
o ares_parse_a_reply: fix CNAME response parsing
|
||||
o init_by_options: don't copy an empty sortlist
|
||||
o Replaced uint32_t with unsigned int to fix broken builds
|
||||
on a couple of platforms
|
||||
o Fix lookup with HOSTALIASES set
|
||||
o adig: fix NAPTR parsing
|
||||
o compiler warning cleanups
|
||||
|
||||
Thanks go to these friendly people for their efforts and contributions:
|
||||
|
||||
Andrew C. Morrow, Ben Greear, Ben Noordhuis, Daniel Stenberg,
|
||||
Guenter Knauf, Mike Crowe, Patrik Thunstrom, Yang Tse
|
||||
|
||||
Have fun!
|
|
@ -0,0 +1,23 @@
|
|||
TODO
|
||||
====
|
||||
|
||||
ares_reinit()
|
||||
|
||||
- To allow an app to force a re-read of /etc/resolv.conf etc, pretty much
|
||||
like the res_init() resolver function offers
|
||||
|
||||
ares_gethostbyname
|
||||
|
||||
- When built to support IPv6, it needs to also support PF_UNSPEC or similar,
|
||||
so that an application can ask for any protocol and then c-ares would return
|
||||
all known resolves and not just explicitly IPv4 _or_ IPv6 resolves.
|
||||
|
||||
ares_process
|
||||
|
||||
- Upon next ABI breakage ares_process() should be changed to return 'int'
|
||||
and return ARES_ENOTINITIALIZED if ares_library_init() has not been called.
|
||||
|
||||
ares_process_fd
|
||||
|
||||
- Upon next ABI breakage ares_process_fd() should be changed to return
|
||||
'int' and return ARES_ENOTINITIALIZED if library has not been initialized.
|
|
@ -0,0 +1,66 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
void ares__close_sockets(ares_channel channel, struct server_state *server)
|
||||
{
|
||||
struct send_request *sendreq;
|
||||
|
||||
/* Free all pending output buffers. */
|
||||
while (server->qhead)
|
||||
{
|
||||
/* Advance server->qhead; pull out query as we go. */
|
||||
sendreq = server->qhead;
|
||||
server->qhead = sendreq->next;
|
||||
if (sendreq->data_storage != NULL)
|
||||
free(sendreq->data_storage);
|
||||
free(sendreq);
|
||||
}
|
||||
server->qtail = NULL;
|
||||
|
||||
/* Reset any existing input buffer. */
|
||||
if (server->tcp_buffer)
|
||||
free(server->tcp_buffer);
|
||||
server->tcp_buffer = NULL;
|
||||
server->tcp_lenbuf_pos = 0;
|
||||
|
||||
/* Reset brokenness */
|
||||
server->is_broken = 0;
|
||||
|
||||
/* Close the TCP and UDP sockets. */
|
||||
if (server->tcp_socket != ARES_SOCKET_BAD)
|
||||
{
|
||||
SOCK_STATE_CALLBACK(channel, server->tcp_socket, 0, 0);
|
||||
sclose(server->tcp_socket);
|
||||
server->tcp_socket = ARES_SOCKET_BAD;
|
||||
server->tcp_connection_generation = ++channel->tcp_connection_generation;
|
||||
}
|
||||
if (server->udp_socket != ARES_SOCKET_BAD)
|
||||
{
|
||||
SOCK_STATE_CALLBACK(channel, server->udp_socket, 0, 0);
|
||||
sclose(server->udp_socket);
|
||||
server->udp_socket = ARES_SOCKET_BAD;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,263 @@
|
|||
|
||||
/* Copyright 1998, 2010 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"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "inet_net_pton.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
{
|
||||
char *line = NULL, *p, *q, **alias;
|
||||
char *txtaddr, *txthost, *txtalias;
|
||||
int status;
|
||||
size_t addrlen, linesize, naliases;
|
||||
struct ares_addr addr;
|
||||
struct hostent *hostent = NULL;
|
||||
|
||||
*host = NULL; /* Assume failure */
|
||||
|
||||
/* Validate family */
|
||||
switch (family) {
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
case AF_UNSPEC:
|
||||
break;
|
||||
default:
|
||||
return ARES_EBADFAMILY;
|
||||
}
|
||||
|
||||
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
|
||||
{
|
||||
|
||||
/* Trim line comment. */
|
||||
p = line;
|
||||
while (*p && (*p != '#'))
|
||||
p++;
|
||||
*p = '\0';
|
||||
|
||||
/* Trim trailing whitespace. */
|
||||
q = p - 1;
|
||||
while ((q >= line) && ISSPACE(*q))
|
||||
q--;
|
||||
*++q = '\0';
|
||||
|
||||
/* Skip leading whitespace. */
|
||||
p = line;
|
||||
while (*p && ISSPACE(*p))
|
||||
p++;
|
||||
if (!*p)
|
||||
/* Ignore line if empty. */
|
||||
continue;
|
||||
|
||||
/* Pointer to start of IPv4 or IPv6 address part. */
|
||||
txtaddr = p;
|
||||
|
||||
/* Advance past address part. */
|
||||
while (*p && !ISSPACE(*p))
|
||||
p++;
|
||||
if (!*p)
|
||||
/* Ignore line if reached end of line. */
|
||||
continue;
|
||||
|
||||
/* Null terminate address part. */
|
||||
*p = '\0';
|
||||
|
||||
/* Advance to host name */
|
||||
p++;
|
||||
while (*p && ISSPACE(*p))
|
||||
p++;
|
||||
if (!*p)
|
||||
/* Ignore line if reached end of line. */
|
||||
continue;
|
||||
|
||||
/* Pointer to start of host name. */
|
||||
txthost = p;
|
||||
|
||||
/* Advance past host name. */
|
||||
while (*p && !ISSPACE(*p))
|
||||
p++;
|
||||
|
||||
/* Pointer to start of first alias. */
|
||||
txtalias = NULL;
|
||||
if (*p)
|
||||
{
|
||||
q = p + 1;
|
||||
while (*q && ISSPACE(*q))
|
||||
q++;
|
||||
if (*q)
|
||||
txtalias = q;
|
||||
}
|
||||
|
||||
/* Null terminate host name. */
|
||||
*p = '\0';
|
||||
|
||||
/* find out number of aliases. */
|
||||
naliases = 0;
|
||||
if (txtalias)
|
||||
{
|
||||
p = txtalias;
|
||||
while (*p)
|
||||
{
|
||||
while (*p && !ISSPACE(*p))
|
||||
p++;
|
||||
while (*p && ISSPACE(*p))
|
||||
p++;
|
||||
naliases++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert address string to network address for the requested family. */
|
||||
addrlen = 0;
|
||||
addr.family = AF_UNSPEC;
|
||||
addr.addrV4.s_addr = INADDR_NONE;
|
||||
if ((family == AF_INET) || (family == AF_UNSPEC))
|
||||
{
|
||||
addr.addrV4.s_addr = inet_addr(txtaddr);
|
||||
if (addr.addrV4.s_addr != INADDR_NONE)
|
||||
{
|
||||
/* Actual network address family and length. */
|
||||
addr.family = AF_INET;
|
||||
addrlen = sizeof(addr.addrV4);
|
||||
}
|
||||
}
|
||||
if ((family == AF_INET6) || ((family == AF_UNSPEC) && (!addrlen)))
|
||||
{
|
||||
if (ares_inet_pton(AF_INET6, txtaddr, &addr.addrV6) > 0)
|
||||
{
|
||||
/* Actual network address family and length. */
|
||||
addr.family = AF_INET6;
|
||||
addrlen = sizeof(addr.addrV6);
|
||||
}
|
||||
}
|
||||
if (!addrlen)
|
||||
/* Ignore line if invalid address string for the requested family. */
|
||||
continue;
|
||||
|
||||
/*
|
||||
** Actual address family possible values are AF_INET and AF_INET6 only.
|
||||
*/
|
||||
|
||||
/* Allocate memory for the hostent structure. */
|
||||
hostent = malloc(sizeof(struct hostent));
|
||||
if (!hostent)
|
||||
break;
|
||||
|
||||
/* Initialize fields for out of memory condition. */
|
||||
hostent->h_aliases = NULL;
|
||||
hostent->h_addr_list = NULL;
|
||||
|
||||
/* Copy official host name. */
|
||||
hostent->h_name = strdup(txthost);
|
||||
if (!hostent->h_name)
|
||||
break;
|
||||
|
||||
/* Copy network address. */
|
||||
hostent->h_addr_list = malloc(2 * sizeof(char *));
|
||||
if (!hostent->h_addr_list)
|
||||
break;
|
||||
hostent->h_addr_list[1] = NULL;
|
||||
hostent->h_addr_list[0] = malloc(addrlen);
|
||||
if (!hostent->h_addr_list[0])
|
||||
break;
|
||||
if (addr.family == AF_INET)
|
||||
memcpy(hostent->h_addr_list[0], &addr.addrV4, sizeof(addr.addrV4));
|
||||
else
|
||||
memcpy(hostent->h_addr_list[0], &addr.addrV6, sizeof(addr.addrV6));
|
||||
|
||||
/* Copy aliases. */
|
||||
hostent->h_aliases = malloc((naliases + 1) * sizeof(char *));
|
||||
if (!hostent->h_aliases)
|
||||
break;
|
||||
alias = hostent->h_aliases;
|
||||
while (naliases)
|
||||
*(alias + naliases--) = NULL;
|
||||
*alias = NULL;
|
||||
while (txtalias)
|
||||
{
|
||||
p = txtalias;
|
||||
while (*p && !ISSPACE(*p))
|
||||
p++;
|
||||
q = p;
|
||||
while (*q && ISSPACE(*q))
|
||||
q++;
|
||||
*p = '\0';
|
||||
if ((*alias = strdup(txtalias)) == NULL)
|
||||
break;
|
||||
alias++;
|
||||
txtalias = *q ? q : NULL;
|
||||
}
|
||||
if (txtalias)
|
||||
/* Alias memory allocation failure. */
|
||||
break;
|
||||
|
||||
/* Copy actual network address family and length. */
|
||||
hostent->h_addrtype = addr.family;
|
||||
hostent->h_length = (int)addrlen;
|
||||
|
||||
/* Free line buffer. */
|
||||
free(line);
|
||||
|
||||
/* Return hostent successfully */
|
||||
*host = hostent;
|
||||
return ARES_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/* If allocated, free line buffer. */
|
||||
if (line)
|
||||
free(line);
|
||||
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
/* Memory allocation failure; clean up. */
|
||||
if (hostent)
|
||||
{
|
||||
if (hostent->h_name)
|
||||
free((char *) hostent->h_name);
|
||||
if (hostent->h_aliases)
|
||||
{
|
||||
for (alias = hostent->h_aliases; *alias; alias++)
|
||||
free(*alias);
|
||||
free(hostent->h_aliases);
|
||||
}
|
||||
if (hostent->h_addr_list)
|
||||
{
|
||||
if (hostent->h_addr_list[0])
|
||||
free(hostent->h_addr_list[0]);
|
||||
free(hostent->h_addr_list);
|
||||
}
|
||||
free(hostent);
|
||||
}
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
|
||||
/* 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"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ares.h"
|
||||
#include "ares_nowarn.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
/* This is an internal function. Its contract is to read a line from
|
||||
* a file into a dynamically allocated buffer, zeroing the trailing
|
||||
* newline if there is one. The calling routine may call
|
||||
* ares__read_line multiple times with the same buf and bufsize
|
||||
* pointers; *buf will be reallocated and *bufsize adjusted as
|
||||
* appropriate. The initial value of *buf should be NULL. After the
|
||||
* calling routine is done reading lines, it should free *buf.
|
||||
*/
|
||||
int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
|
||||
{
|
||||
char *newbuf;
|
||||
size_t offset = 0;
|
||||
size_t len;
|
||||
|
||||
if (*buf == NULL)
|
||||
{
|
||||
*buf = malloc(128);
|
||||
if (!*buf)
|
||||
return ARES_ENOMEM;
|
||||
*bufsize = 128;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int bytestoread = aresx_uztosi(*bufsize - offset);
|
||||
|
||||
if (!fgets(*buf + offset, bytestoread, fp))
|
||||
return (offset != 0) ? 0 : (ferror(fp)) ? ARES_EFILE : ARES_EOF;
|
||||
len = offset + strlen(*buf + offset);
|
||||
if ((*buf)[len - 1] == '\n')
|
||||
{
|
||||
(*buf)[len - 1] = 0;
|
||||
break;
|
||||
}
|
||||
offset = len;
|
||||
if(len < *bufsize - 1)
|
||||
continue;
|
||||
|
||||
/* Allocate more space. */
|
||||
newbuf = realloc(*buf, *bufsize * 2);
|
||||
if (!newbuf)
|
||||
return ARES_ENOMEM;
|
||||
*buf = newbuf;
|
||||
*bufsize *= 2;
|
||||
}
|
||||
return ARES_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
|
||||
/* Copyright (C) 2008 by Daniel Stenberg et al
|
||||
*
|
||||
* 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"
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
#if defined(WIN32) && !defined(MSDOS)
|
||||
|
||||
struct timeval ares__tvnow(void)
|
||||
{
|
||||
/*
|
||||
** GetTickCount() is available on _all_ Windows versions from W95 up
|
||||
** to nowadays. Returns milliseconds elapsed since last system boot,
|
||||
** increases monotonically and wraps once 49.7 days have elapsed.
|
||||
*/
|
||||
struct timeval now;
|
||||
DWORD milliseconds = GetTickCount();
|
||||
now.tv_sec = milliseconds / 1000;
|
||||
now.tv_usec = (milliseconds % 1000) * 1000;
|
||||
return now;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)
|
||||
|
||||
struct timeval ares__tvnow(void)
|
||||
{
|
||||
/*
|
||||
** clock_gettime() is granted to be increased monotonically when the
|
||||
** monotonic clock is queried. Time starting point is unspecified, it
|
||||
** could be the system start-up time, the Epoch, or something else,
|
||||
** in any case the time starting point does not change once that the
|
||||
** system has started up.
|
||||
*/
|
||||
struct timeval now;
|
||||
struct timespec tsnow;
|
||||
if(0 == clock_gettime(CLOCK_MONOTONIC, &tsnow)) {
|
||||
now.tv_sec = tsnow.tv_sec;
|
||||
now.tv_usec = tsnow.tv_nsec / 1000;
|
||||
}
|
||||
/*
|
||||
** Even when the configure process has truly detected monotonic clock
|
||||
** availability, it might happen that it is not actually available at
|
||||
** run-time. When this occurs simply fallback to other time source.
|
||||
*/
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
else
|
||||
(void)gettimeofday(&now, NULL);
|
||||
#else
|
||||
else {
|
||||
now.tv_sec = (long)time(NULL);
|
||||
now.tv_usec = 0;
|
||||
}
|
||||
#endif
|
||||
return now;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_GETTIMEOFDAY)
|
||||
|
||||
struct timeval ares__tvnow(void)
|
||||
{
|
||||
/*
|
||||
** gettimeofday() is not granted to be increased monotonically, due to
|
||||
** clock drifting and external source time synchronization it can jump
|
||||
** forward or backward in time.
|
||||
*/
|
||||
struct timeval now;
|
||||
(void)gettimeofday(&now, NULL);
|
||||
return now;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct timeval ares__tvnow(void)
|
||||
{
|
||||
/*
|
||||
** time() returns the value of time in seconds since the Epoch.
|
||||
*/
|
||||
struct timeval now;
|
||||
now.tv_sec = (long)time(NULL);
|
||||
now.tv_usec = 0;
|
||||
return now;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if 0 /* Not used */
|
||||
/*
|
||||
* Make sure that the first argument is the more recent time, as otherwise
|
||||
* we'll get a weird negative time-diff back...
|
||||
*
|
||||
* Returns: the time difference in number of milliseconds.
|
||||
*/
|
||||
long ares__tvdiff(struct timeval newer, struct timeval older)
|
||||
{
|
||||
return (newer.tv_sec-older.tv_sec)*1000+
|
||||
(newer.tv_usec-older.tv_usec)/1000;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
/* Copyright (C) 2004 by Daniel Stenberg et al
|
||||
*
|
||||
* 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"
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
/*
|
||||
* ares_cancel() cancels all ongoing requests/resolves that might be going on
|
||||
* on the given channel. It does NOT kill the channel, use ares_destroy() for
|
||||
* that.
|
||||
*/
|
||||
void ares_cancel(ares_channel channel)
|
||||
{
|
||||
struct query *query;
|
||||
struct list_node* list_head;
|
||||
struct list_node* list_node;
|
||||
int i;
|
||||
|
||||
list_head = &(channel->all_queries);
|
||||
for (list_node = list_head->next; list_node != list_head; )
|
||||
{
|
||||
query = list_node->data;
|
||||
list_node = list_node->next; /* since we're deleting the query */
|
||||
query->callback(query->arg, ARES_ECANCELLED, 0, NULL, 0);
|
||||
ares__free_query(query);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
/* Freeing the query should remove it from all the lists in which it sits,
|
||||
* so all query lists should be empty now.
|
||||
*/
|
||||
assert(ares__is_list_empty(&(channel->all_queries)));
|
||||
for (i = 0; i < ARES_QID_TABLE_SIZE; i++)
|
||||
{
|
||||
assert(ares__is_list_empty(&(channel->queries_by_qid[i])));
|
||||
}
|
||||
for (i = 0; i < ARES_TIMEOUT_TABLE_SIZE; i++)
|
||||
{
|
||||
assert(ares__is_list_empty(&(channel->queries_by_timeout[i])));
|
||||
}
|
||||
#endif
|
||||
if (!(channel->flags & ARES_FLAG_STAYOPEN))
|
||||
{
|
||||
if (channel->servers)
|
||||
{
|
||||
for (i = 0; i < channel->nservers; i++)
|
||||
ares__close_sockets(channel, &channel->servers[i]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,190 @@
|
|||
|
||||
/* Copyright (C) 2009-2010 by Daniel Stenberg
|
||||
*
|
||||
* 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"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_data.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
|
||||
/*
|
||||
** ares_free_data() - c-ares external API function.
|
||||
**
|
||||
** This function must be used by the application to free data memory that
|
||||
** has been internally allocated by some c-ares function and for which a
|
||||
** pointer has already been returned to the calling application. The list
|
||||
** of c-ares functions returning pointers that must be free'ed using this
|
||||
** function is:
|
||||
**
|
||||
** ares_get_servers()
|
||||
** ares_parse_srv_reply()
|
||||
** ares_parse_txt_reply()
|
||||
*/
|
||||
|
||||
void ares_free_data(void *dataptr)
|
||||
{
|
||||
struct ares_data *ptr;
|
||||
|
||||
if (!dataptr)
|
||||
return;
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:1684)
|
||||
/* 1684: conversion from pointer to same-sized integral type */
|
||||
#endif
|
||||
|
||||
ptr = (void *)((char *)dataptr - offsetof(struct ares_data, data));
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
if (ptr->mark != ARES_DATATYPE_MARK)
|
||||
return;
|
||||
|
||||
switch (ptr->type)
|
||||
{
|
||||
case ARES_DATATYPE_MX_REPLY:
|
||||
|
||||
if (ptr->data.mx_reply.next)
|
||||
ares_free_data(ptr->data.mx_reply.next);
|
||||
if (ptr->data.mx_reply.host)
|
||||
free(ptr->data.mx_reply.host);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_SRV_REPLY:
|
||||
|
||||
if (ptr->data.srv_reply.next)
|
||||
ares_free_data(ptr->data.srv_reply.next);
|
||||
if (ptr->data.srv_reply.host)
|
||||
free(ptr->data.srv_reply.host);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_TXT_REPLY:
|
||||
|
||||
if (ptr->data.txt_reply.next)
|
||||
ares_free_data(ptr->data.txt_reply.next);
|
||||
if (ptr->data.txt_reply.txt)
|
||||
free(ptr->data.txt_reply.txt);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_ADDR_NODE:
|
||||
|
||||
if (ptr->data.addr_node.next)
|
||||
ares_free_data(ptr->data.addr_node.next);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** ares_malloc_data() - c-ares internal helper function.
|
||||
**
|
||||
** This function allocates memory for a c-ares private ares_data struct
|
||||
** for the specified ares_datatype, initializes c-ares private fields
|
||||
** and zero initializes those which later might be used from the public
|
||||
** API. It returns an interior pointer which can be passed by c-ares
|
||||
** functions to the calling application, and that must be free'ed using
|
||||
** c-ares external API function ares_free_data().
|
||||
*/
|
||||
|
||||
void *ares_malloc_data(ares_datatype type)
|
||||
{
|
||||
struct ares_data *ptr;
|
||||
|
||||
ptr = malloc(sizeof(struct ares_data));
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ARES_DATATYPE_MX_REPLY:
|
||||
ptr->data.mx_reply.next = NULL;
|
||||
ptr->data.mx_reply.host = NULL;
|
||||
ptr->data.mx_reply.priority = 0;
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_SRV_REPLY:
|
||||
ptr->data.srv_reply.next = NULL;
|
||||
ptr->data.srv_reply.host = NULL;
|
||||
ptr->data.srv_reply.priority = 0;
|
||||
ptr->data.srv_reply.weight = 0;
|
||||
ptr->data.srv_reply.port = 0;
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_TXT_REPLY:
|
||||
ptr->data.txt_reply.next = NULL;
|
||||
ptr->data.txt_reply.txt = NULL;
|
||||
ptr->data.txt_reply.length = 0;
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_ADDR_NODE:
|
||||
ptr->data.addr_node.next = NULL;
|
||||
ptr->data.addr_node.family = 0;
|
||||
memset(&ptr->data.addr_node.addrV6, 0,
|
||||
sizeof(ptr->data.addr_node.addrV6));
|
||||
break;
|
||||
|
||||
default:
|
||||
free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptr->mark = ARES_DATATYPE_MARK;
|
||||
ptr->type = type;
|
||||
|
||||
return &ptr->data;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** ares_get_datatype() - c-ares internal helper function.
|
||||
**
|
||||
** This function returns the ares_datatype of the data stored in a
|
||||
** private ares_data struct when given the public API pointer.
|
||||
*/
|
||||
|
||||
ares_datatype ares_get_datatype(void * dataptr)
|
||||
{
|
||||
struct ares_data *ptr;
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:1684)
|
||||
/* 1684: conversion from pointer to same-sized integral type */
|
||||
#endif
|
||||
|
||||
ptr = (void *)((char *)dataptr - offsetof(struct ares_data, data));
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
if (ptr->mark == ARES_DATATYPE_MARK)
|
||||
return ptr->type;
|
||||
|
||||
return ARES_DATATYPE_UNKNOWN;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
|
||||
/* Copyright (C) 2009-2010 by Daniel Stenberg
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
ARES_DATATYPE_UNKNOWN = 1, /* unknown data type - introduced in 1.7.0 */
|
||||
ARES_DATATYPE_SRV_REPLY, /* struct ares_srv_reply - introduced in 1.7.0 */
|
||||
ARES_DATATYPE_TXT_REPLY, /* struct ares_txt_reply - introduced in 1.7.0 */
|
||||
ARES_DATATYPE_ADDR_NODE, /* struct ares_addr_node - introduced in 1.7.1 */
|
||||
ARES_DATATYPE_MX_REPLY, /* struct ares_mx_reply - introduced in 1.7.2 */
|
||||
#if 0
|
||||
ARES_DATATYPE_ADDR6TTL, /* struct ares_addrttl */
|
||||
ARES_DATATYPE_ADDRTTL, /* struct ares_addr6ttl */
|
||||
ARES_DATATYPE_HOSTENT, /* struct hostent */
|
||||
ARES_DATATYPE_OPTIONS, /* struct ares_options */
|
||||
#endif
|
||||
ARES_DATATYPE_LAST /* not used - introduced in 1.7.0 */
|
||||
} ares_datatype;
|
||||
|
||||
#define ARES_DATATYPE_MARK 0xbead
|
||||
|
||||
/*
|
||||
* ares_data struct definition is internal to c-ares and shall not
|
||||
* be exposed by the public API in order to allow future changes
|
||||
* and extensions to it without breaking ABI. This will be used
|
||||
* internally by c-ares as the container of multiple types of data
|
||||
* dynamically allocated for which a reference will be returned
|
||||
* to the calling application.
|
||||
*
|
||||
* c-ares API functions returning a pointer to c-ares internally
|
||||
* allocated data will actually be returning an interior pointer
|
||||
* into this ares_data struct.
|
||||
*
|
||||
* All this is 'invisible' to the calling application, the only
|
||||
* requirement is that this kind of data must be free'ed by the
|
||||
* calling application using ares_free_data() with the pointer
|
||||
* it has received from a previous c-ares function call.
|
||||
*/
|
||||
|
||||
struct ares_data {
|
||||
ares_datatype type; /* Actual data type identifier. */
|
||||
unsigned int mark; /* Private ares_data signature. */
|
||||
union {
|
||||
struct ares_txt_reply txt_reply;
|
||||
struct ares_srv_reply srv_reply;
|
||||
struct ares_addr_node addr_node;
|
||||
struct ares_mx_reply mx_reply;
|
||||
} data;
|
||||
};
|
||||
|
||||
void *ares_malloc_data(ares_datatype type);
|
||||
|
||||
ares_datatype ares_get_datatype(void * dataptr);
|
|
@ -0,0 +1,105 @@
|
|||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2004-2010 by Daniel Stenberg
|
||||
*
|
||||
* 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"
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
void ares_destroy_options(struct ares_options *options)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(options->servers)
|
||||
free(options->servers);
|
||||
for (i = 0; i < options->ndomains; i++)
|
||||
free(options->domains[i]);
|
||||
free(options->domains);
|
||||
if(options->sortlist)
|
||||
free(options->sortlist);
|
||||
free(options->lookups);
|
||||
}
|
||||
|
||||
void ares_destroy(ares_channel channel)
|
||||
{
|
||||
int i;
|
||||
struct query *query;
|
||||
struct list_node* list_head;
|
||||
struct list_node* list_node;
|
||||
|
||||
if (!channel)
|
||||
return;
|
||||
|
||||
list_head = &(channel->all_queries);
|
||||
for (list_node = list_head->next; list_node != list_head; )
|
||||
{
|
||||
query = list_node->data;
|
||||
list_node = list_node->next; /* since we're deleting the query */
|
||||
query->callback(query->arg, ARES_EDESTRUCTION, 0, NULL, 0);
|
||||
ares__free_query(query);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
/* Freeing the query should remove it from all the lists in which it sits,
|
||||
* so all query lists should be empty now.
|
||||
*/
|
||||
assert(ares__is_list_empty(&(channel->all_queries)));
|
||||
for (i = 0; i < ARES_QID_TABLE_SIZE; i++)
|
||||
{
|
||||
assert(ares__is_list_empty(&(channel->queries_by_qid[i])));
|
||||
}
|
||||
for (i = 0; i < ARES_TIMEOUT_TABLE_SIZE; i++)
|
||||
{
|
||||
assert(ares__is_list_empty(&(channel->queries_by_timeout[i])));
|
||||
}
|
||||
#endif
|
||||
|
||||
ares__destroy_servers_state(channel);
|
||||
|
||||
if (channel->domains) {
|
||||
for (i = 0; i < channel->ndomains; i++)
|
||||
free(channel->domains[i]);
|
||||
free(channel->domains);
|
||||
}
|
||||
|
||||
if(channel->sortlist)
|
||||
free(channel->sortlist);
|
||||
|
||||
if (channel->lookups)
|
||||
free(channel->lookups);
|
||||
|
||||
free(channel);
|
||||
}
|
||||
|
||||
void ares__destroy_servers_state(ares_channel channel)
|
||||
{
|
||||
struct server_state *server;
|
||||
int i;
|
||||
|
||||
if (channel->servers)
|
||||
{
|
||||
for (i = 0; i < channel->nservers; i++)
|
||||
{
|
||||
server = &channel->servers[i];
|
||||
ares__close_sockets(channel, server);
|
||||
assert(ares__is_list_empty(&server->queries_to_server));
|
||||
}
|
||||
free(channel->servers);
|
||||
channel->servers = NULL;
|
||||
}
|
||||
channel->nservers = -1;
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef ARES__DNS_H
|
||||
#define ARES__DNS_H
|
||||
|
||||
#define DNS__16BIT(p) (((p)[0] << 8) | (p)[1])
|
||||
#define DNS__32BIT(p) (((p)[0] << 24) | ((p)[1] << 16) | \
|
||||
((p)[2] << 8) | (p)[3])
|
||||
|
||||
#define DNS__SET16BIT(p, v) (((p)[0] = (unsigned char)(((v) >> 8) & 0xff)), \
|
||||
((p)[1] = (unsigned char)((v) & 0xff)))
|
||||
#define DNS__SET32BIT(p, v) (((p)[0] = (unsigned char)(((v) >> 24) & 0xff)), \
|
||||
((p)[1] = (unsigned char)(((v) >> 16) & 0xff)), \
|
||||
((p)[2] = (unsigned char)(((v) >> 8) & 0xff)), \
|
||||
((p)[3] = (unsigned char)((v) & 0xff)))
|
||||
|
||||
#if 0
|
||||
/* we cannot use this approach on systems where we can't access 16/32 bit
|
||||
data on un-aligned addresses */
|
||||
#define DNS__16BIT(p) ntohs(*(unsigned short*)(p))
|
||||
#define DNS__32BIT(p) ntohl(*(unsigned long*)(p))
|
||||
#define DNS__SET16BIT(p, v) *(unsigned short*)(p) = htons(v)
|
||||
#define DNS__SET32BIT(p, v) *(unsigned long*)(p) = htonl(v)
|
||||
#endif
|
||||
|
||||
/* Macros for parsing a DNS header */
|
||||
#define DNS_HEADER_QID(h) DNS__16BIT(h)
|
||||
#define DNS_HEADER_QR(h) (((h)[2] >> 7) & 0x1)
|
||||
#define DNS_HEADER_OPCODE(h) (((h)[2] >> 3) & 0xf)
|
||||
#define DNS_HEADER_AA(h) (((h)[2] >> 2) & 0x1)
|
||||
#define DNS_HEADER_TC(h) (((h)[2] >> 1) & 0x1)
|
||||
#define DNS_HEADER_RD(h) ((h)[2] & 0x1)
|
||||
#define DNS_HEADER_RA(h) (((h)[3] >> 7) & 0x1)
|
||||
#define DNS_HEADER_Z(h) (((h)[3] >> 4) & 0x7)
|
||||
#define DNS_HEADER_RCODE(h) ((h)[3] & 0xf)
|
||||
#define DNS_HEADER_QDCOUNT(h) DNS__16BIT((h) + 4)
|
||||
#define DNS_HEADER_ANCOUNT(h) DNS__16BIT((h) + 6)
|
||||
#define DNS_HEADER_NSCOUNT(h) DNS__16BIT((h) + 8)
|
||||
#define DNS_HEADER_ARCOUNT(h) DNS__16BIT((h) + 10)
|
||||
|
||||
/* Macros for constructing a DNS header */
|
||||
#define DNS_HEADER_SET_QID(h, v) DNS__SET16BIT(h, v)
|
||||
#define DNS_HEADER_SET_QR(h, v) ((h)[2] |= (unsigned char)(((v) & 0x1) << 7))
|
||||
#define DNS_HEADER_SET_OPCODE(h, v) ((h)[2] |= (unsigned char)(((v) & 0xf) << 3))
|
||||
#define DNS_HEADER_SET_AA(h, v) ((h)[2] |= (unsigned char)(((v) & 0x1) << 2))
|
||||
#define DNS_HEADER_SET_TC(h, v) ((h)[2] |= (unsigned char)(((v) & 0x1) << 1))
|
||||
#define DNS_HEADER_SET_RD(h, v) ((h)[2] |= (unsigned char)((v) & 0x1))
|
||||
#define DNS_HEADER_SET_RA(h, v) ((h)[3] |= (unsigned char)(((v) & 0x1) << 7))
|
||||
#define DNS_HEADER_SET_Z(h, v) ((h)[3] |= (unsigned char)(((v) & 0x7) << 4))
|
||||
#define DNS_HEADER_SET_RCODE(h, v) ((h)[3] |= (unsigned char)((v) & 0xf))
|
||||
#define DNS_HEADER_SET_QDCOUNT(h, v) DNS__SET16BIT((h) + 4, v)
|
||||
#define DNS_HEADER_SET_ANCOUNT(h, v) DNS__SET16BIT((h) + 6, v)
|
||||
#define DNS_HEADER_SET_NSCOUNT(h, v) DNS__SET16BIT((h) + 8, v)
|
||||
#define DNS_HEADER_SET_ARCOUNT(h, v) DNS__SET16BIT((h) + 10, v)
|
||||
|
||||
/* Macros for parsing the fixed part of a DNS question */
|
||||
#define DNS_QUESTION_TYPE(q) DNS__16BIT(q)
|
||||
#define DNS_QUESTION_CLASS(q) DNS__16BIT((q) + 2)
|
||||
|
||||
/* Macros for constructing the fixed part of a DNS question */
|
||||
#define DNS_QUESTION_SET_TYPE(q, v) DNS__SET16BIT(q, v)
|
||||
#define DNS_QUESTION_SET_CLASS(q, v) DNS__SET16BIT((q) + 2, v)
|
||||
|
||||
/* Macros for parsing the fixed part of a DNS resource record */
|
||||
#define DNS_RR_TYPE(r) DNS__16BIT(r)
|
||||
#define DNS_RR_CLASS(r) DNS__16BIT((r) + 2)
|
||||
#define DNS_RR_TTL(r) DNS__32BIT((r) + 4)
|
||||
#define DNS_RR_LEN(r) DNS__16BIT((r) + 8)
|
||||
|
||||
/* Macros for constructing the fixed part of a DNS resource record */
|
||||
#define DNS_RR_SET_TYPE(r) DNS__SET16BIT(r, v)
|
||||
#define DNS_RR_SET_CLASS(r) DNS__SET16BIT((r) + 2, v)
|
||||
#define DNS_RR_SET_TTL(r) DNS__SET32BIT((r) + 4, v)
|
||||
#define DNS_RR_SET_LEN(r) DNS__SET16BIT((r) + 8, v)
|
||||
|
||||
#endif /* ARES__DNS_H */
|
|
@ -0,0 +1,193 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#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 <stdlib.h>
|
||||
#include "ares.h"
|
||||
#include "ares_private.h" /* for the memdebug */
|
||||
|
||||
static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
||||
int alen);
|
||||
|
||||
/* Expand an RFC1035-encoded domain name given by encoded. The
|
||||
* containing message is given by abuf and alen. The result given by
|
||||
* *s, which is set to a NUL-terminated allocated buffer. *enclen is
|
||||
* set to the length of the encoded name (not the length of the
|
||||
* expanded name; the goal is to tell the caller how many bytes to
|
||||
* move forward to get past the encoded name).
|
||||
*
|
||||
* In the simple case, an encoded name is a series of labels, each
|
||||
* composed of a one-byte length (limited to values between 0 and 63
|
||||
* inclusive) followed by the label contents. The name is terminated
|
||||
* by a zero-length label.
|
||||
*
|
||||
* In the more complicated case, a label may be terminated by an
|
||||
* indirection pointer, specified by two bytes with the high bits of
|
||||
* the first byte (corresponding to INDIR_MASK) set to 11. With the
|
||||
* two high bits of the first byte stripped off, the indirection
|
||||
* pointer gives an offset from the beginning of the containing
|
||||
* message with more labels to decode. Indirection can happen an
|
||||
* arbitrary number of times, so we have to detect loops.
|
||||
*
|
||||
* Since the expanded name uses '.' as a label separator, we use
|
||||
* backslashes to escape periods or backslashes in the expanded name.
|
||||
*/
|
||||
|
||||
int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
|
||||
int alen, char **s, long *enclen)
|
||||
{
|
||||
int len, indir = 0;
|
||||
char *q;
|
||||
const unsigned char *p;
|
||||
union {
|
||||
ssize_t sig;
|
||||
size_t uns;
|
||||
} nlen;
|
||||
|
||||
nlen.sig = name_length(encoded, abuf, alen);
|
||||
if (nlen.sig < 0)
|
||||
return ARES_EBADNAME;
|
||||
|
||||
*s = malloc(nlen.uns + 1);
|
||||
if (!*s)
|
||||
return ARES_ENOMEM;
|
||||
q = *s;
|
||||
|
||||
if (nlen.uns == 0) {
|
||||
/* RFC2181 says this should be ".": the root of the DNS tree.
|
||||
* Since this function strips trailing dots though, it becomes ""
|
||||
*/
|
||||
q[0] = '\0';
|
||||
*enclen = 1; /* the caller should move one byte to get past this */
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
/* No error-checking necessary; it was all done by name_length(). */
|
||||
p = encoded;
|
||||
while (*p)
|
||||
{
|
||||
if ((*p & INDIR_MASK) == INDIR_MASK)
|
||||
{
|
||||
if (!indir)
|
||||
{
|
||||
*enclen = p + 2 - encoded;
|
||||
indir = 1;
|
||||
}
|
||||
p = abuf + ((*p & ~INDIR_MASK) << 8 | *(p + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
len = *p;
|
||||
p++;
|
||||
while (len--)
|
||||
{
|
||||
if (*p == '.' || *p == '\\')
|
||||
*q++ = '\\';
|
||||
*q++ = *p;
|
||||
p++;
|
||||
}
|
||||
*q++ = '.';
|
||||
}
|
||||
}
|
||||
if (!indir)
|
||||
*enclen = p + 1 - encoded;
|
||||
|
||||
/* Nuke the trailing period if we wrote one. */
|
||||
if (q > *s)
|
||||
*(q - 1) = 0;
|
||||
else
|
||||
*q = 0; /* zero terminate */
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
/* Return the length of the expansion of an encoded domain name, or
|
||||
* -1 if the encoding is invalid.
|
||||
*/
|
||||
static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
||||
int alen)
|
||||
{
|
||||
int n = 0, offset, indir = 0;
|
||||
|
||||
/* Allow the caller to pass us abuf + alen and have us check for it. */
|
||||
if (encoded == abuf + alen)
|
||||
return -1;
|
||||
|
||||
while (*encoded)
|
||||
{
|
||||
if ((*encoded & INDIR_MASK) == INDIR_MASK)
|
||||
{
|
||||
/* Check the offset and go there. */
|
||||
if (encoded + 1 >= abuf + alen)
|
||||
return -1;
|
||||
offset = (*encoded & ~INDIR_MASK) << 8 | *(encoded + 1);
|
||||
if (offset >= alen)
|
||||
return -1;
|
||||
encoded = abuf + offset;
|
||||
|
||||
/* If we've seen more indirects than the message length,
|
||||
* then there's a loop.
|
||||
*/
|
||||
if (++indir > alen)
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = *encoded;
|
||||
if (encoded + offset + 1 >= abuf + alen)
|
||||
return -1;
|
||||
encoded++;
|
||||
while (offset--)
|
||||
{
|
||||
n += (*encoded == '.' || *encoded == '\\') ? 2 : 1;
|
||||
encoded++;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
/* If there were any labels at all, then the number of dots is one
|
||||
* less than the number of labels, so subtract one.
|
||||
*/
|
||||
return (n) ? n - 1 : n;
|
||||
}
|
||||
|
||||
/* Like ares_expand_name but returns EBADRESP in case of invalid input. */
|
||||
int ares__expand_name_for_response(const unsigned char *encoded,
|
||||
const unsigned char *abuf, int alen,
|
||||
char **s, long *enclen)
|
||||
{
|
||||
int status = ares_expand_name(encoded, abuf, alen, s, enclen);
|
||||
if (status == ARES_EBADNAME)
|
||||
status = ARES_EBADRESP;
|
||||
return status;
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#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 <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "ares.h"
|
||||
#include "ares_private.h" /* for the memdebug */
|
||||
|
||||
/* Simply decodes a length-encoded character string. The first byte of the
|
||||
* input is the length of the string to be returned and the bytes thereafter
|
||||
* are the characters of the string. The returned result will be NULL
|
||||
* terminated.
|
||||
*/
|
||||
int ares_expand_string(const unsigned char *encoded,
|
||||
const unsigned char *abuf,
|
||||
int alen,
|
||||
unsigned char **s,
|
||||
long *enclen)
|
||||
{
|
||||
unsigned char *q;
|
||||
union {
|
||||
ssize_t sig;
|
||||
size_t uns;
|
||||
} elen;
|
||||
|
||||
if (encoded == abuf+alen)
|
||||
return ARES_EBADSTR;
|
||||
|
||||
elen.uns = *encoded;
|
||||
if (encoded+elen.sig+1 > abuf+alen)
|
||||
return ARES_EBADSTR;
|
||||
|
||||
encoded++;
|
||||
|
||||
*s = malloc(elen.uns+1);
|
||||
if (*s == NULL)
|
||||
return ARES_ENOMEM;
|
||||
q = *s;
|
||||
strncpy((char *)q, (char *)encoded, elen.uns);
|
||||
q[elen.uns] = '\0';
|
||||
|
||||
*s = q;
|
||||
|
||||
*enclen = (long)(elen.sig+1);
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds)
|
||||
{
|
||||
struct server_state *server;
|
||||
ares_socket_t nfds;
|
||||
int i;
|
||||
|
||||
/* Are there any active queries? */
|
||||
int active_queries = !ares__is_list_empty(&(channel->all_queries));
|
||||
|
||||
nfds = 0;
|
||||
for (i = 0; i < channel->nservers; i++)
|
||||
{
|
||||
server = &channel->servers[i];
|
||||
/* We only need to register interest in UDP sockets if we have
|
||||
* outstanding queries.
|
||||
*/
|
||||
if (active_queries && server->udp_socket != ARES_SOCKET_BAD)
|
||||
{
|
||||
FD_SET(server->udp_socket, read_fds);
|
||||
if (server->udp_socket >= nfds)
|
||||
nfds = server->udp_socket + 1;
|
||||
}
|
||||
/* We always register for TCP events, because we want to know
|
||||
* when the other side closes the connection, so we don't waste
|
||||
* time trying to use a broken connection.
|
||||
*/
|
||||
if (server->tcp_socket != ARES_SOCKET_BAD)
|
||||
{
|
||||
FD_SET(server->tcp_socket, read_fds);
|
||||
if (server->qhead)
|
||||
FD_SET(server->tcp_socket, write_fds);
|
||||
if (server->tcp_socket >= nfds)
|
||||
nfds = server->tcp_socket + 1;
|
||||
}
|
||||
}
|
||||
return (int)nfds;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
|
||||
/* 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"
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h" /* for memdebug */
|
||||
|
||||
void ares_free_hostent(struct hostent *host)
|
||||
{
|
||||
char **p;
|
||||
|
||||
free((char *)(host->h_name));
|
||||
for (p = host->h_aliases; *p; p++)
|
||||
free(*p);
|
||||
free(host->h_aliases);
|
||||
free(host->h_addr_list[0]); /* no matter if there is one or many entries,
|
||||
there is only one malloc for all of them */
|
||||
free(host->h_addr_list);
|
||||
free(host);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
/* Copyright 2000 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"
|
||||
#include <stdlib.h>
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
void ares_free_string(void *str)
|
||||
{
|
||||
free(str);
|
||||
}
|
|
@ -0,0 +1,292 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "inet_net_pton.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
#ifdef WATT32
|
||||
#undef WIN32
|
||||
#endif
|
||||
|
||||
struct addr_query {
|
||||
/* Arguments passed to ares_gethostbyaddr() */
|
||||
ares_channel channel;
|
||||
struct ares_addr addr;
|
||||
ares_host_callback callback;
|
||||
void *arg;
|
||||
|
||||
const char *remaining_lookups;
|
||||
int timeouts;
|
||||
};
|
||||
|
||||
static void next_lookup(struct addr_query *aquery);
|
||||
static void addr_callback(void *arg, int status, int timeouts,
|
||||
unsigned char *abuf, int alen);
|
||||
static void end_aquery(struct addr_query *aquery, int status,
|
||||
struct hostent *host);
|
||||
static int file_lookup(struct ares_addr *addr, struct hostent **host);
|
||||
static void ptr_rr_name(char *name, const struct ares_addr *addr);
|
||||
|
||||
void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
|
||||
int family, ares_host_callback callback, void *arg)
|
||||
{
|
||||
struct addr_query *aquery;
|
||||
|
||||
if (family != AF_INET && family != AF_INET6)
|
||||
{
|
||||
callback(arg, ARES_ENOTIMP, 0, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((family == AF_INET && addrlen != sizeof(aquery->addr.addrV4)) ||
|
||||
(family == AF_INET6 && addrlen != sizeof(aquery->addr.addrV6)))
|
||||
{
|
||||
callback(arg, ARES_ENOTIMP, 0, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
aquery = malloc(sizeof(struct addr_query));
|
||||
if (!aquery)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
||||
return;
|
||||
}
|
||||
aquery->channel = channel;
|
||||
if (family == AF_INET)
|
||||
memcpy(&aquery->addr.addrV4, addr, sizeof(aquery->addr.addrV4));
|
||||
else
|
||||
memcpy(&aquery->addr.addrV6, addr, sizeof(aquery->addr.addrV6));
|
||||
aquery->addr.family = family;
|
||||
aquery->callback = callback;
|
||||
aquery->arg = arg;
|
||||
aquery->remaining_lookups = channel->lookups;
|
||||
aquery->timeouts = 0;
|
||||
|
||||
next_lookup(aquery);
|
||||
}
|
||||
|
||||
static void next_lookup(struct addr_query *aquery)
|
||||
{
|
||||
const char *p;
|
||||
char name[128];
|
||||
int status;
|
||||
struct hostent *host;
|
||||
|
||||
for (p = aquery->remaining_lookups; *p; p++)
|
||||
{
|
||||
switch (*p)
|
||||
{
|
||||
case 'b':
|
||||
ptr_rr_name(name, &aquery->addr);
|
||||
aquery->remaining_lookups = p + 1;
|
||||
ares_query(aquery->channel, name, C_IN, T_PTR, addr_callback,
|
||||
aquery);
|
||||
return;
|
||||
case 'f':
|
||||
status = file_lookup(&aquery->addr, &host);
|
||||
|
||||
/* this status check below previously checked for !ARES_ENOTFOUND,
|
||||
but we should not assume that this single error code is the one
|
||||
that can occur, as that is in fact no longer the case */
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
end_aquery(aquery, status, host);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
end_aquery(aquery, ARES_ENOTFOUND, NULL);
|
||||
}
|
||||
|
||||
static void addr_callback(void *arg, int status, int timeouts,
|
||||
unsigned char *abuf, int alen)
|
||||
{
|
||||
struct addr_query *aquery = (struct addr_query *) arg;
|
||||
struct hostent *host;
|
||||
size_t addrlen;
|
||||
|
||||
aquery->timeouts += timeouts;
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
if (aquery->addr.family == AF_INET)
|
||||
{
|
||||
addrlen = sizeof(aquery->addr.addrV4);
|
||||
status = ares_parse_ptr_reply(abuf, alen, &aquery->addr.addrV4,
|
||||
(int)addrlen, AF_INET, &host);
|
||||
}
|
||||
else
|
||||
{
|
||||
addrlen = sizeof(aquery->addr.addrV6);
|
||||
status = ares_parse_ptr_reply(abuf, alen, &aquery->addr.addrV6,
|
||||
(int)addrlen, AF_INET6, &host);
|
||||
}
|
||||
end_aquery(aquery, status, host);
|
||||
}
|
||||
else if (status == ARES_EDESTRUCTION)
|
||||
end_aquery(aquery, status, NULL);
|
||||
else
|
||||
next_lookup(aquery);
|
||||
}
|
||||
|
||||
static void end_aquery(struct addr_query *aquery, int status,
|
||||
struct hostent *host)
|
||||
{
|
||||
aquery->callback(aquery->arg, status, aquery->timeouts, host);
|
||||
if (host)
|
||||
ares_free_hostent(host);
|
||||
free(aquery);
|
||||
}
|
||||
|
||||
static int file_lookup(struct ares_addr *addr, struct hostent **host)
|
||||
{
|
||||
FILE *fp;
|
||||
int status;
|
||||
int error;
|
||||
|
||||
#ifdef WIN32
|
||||
char PATH_HOSTS[MAX_PATH];
|
||||
if (IS_NT()) {
|
||||
char tmp[MAX_PATH];
|
||||
HKEY hkeyHosts;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ,
|
||||
&hkeyHosts) == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD dwLength = MAX_PATH;
|
||||
RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp,
|
||||
&dwLength);
|
||||
ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH);
|
||||
RegCloseKey(hkeyHosts);
|
||||
}
|
||||
}
|
||||
else
|
||||
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
|
||||
|
||||
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
|
||||
|
||||
#elif defined(WATT32)
|
||||
extern const char *_w32_GetHostsFile (void);
|
||||
const char *PATH_HOSTS = _w32_GetHostsFile();
|
||||
|
||||
if (!PATH_HOSTS)
|
||||
return ARES_ENOTFOUND;
|
||||
#endif
|
||||
|
||||
fp = fopen(PATH_HOSTS, "r");
|
||||
if (!fp)
|
||||
{
|
||||
error = ERRNO;
|
||||
switch(error)
|
||||
{
|
||||
case ENOENT:
|
||||
case ESRCH:
|
||||
return ARES_ENOTFOUND;
|
||||
default:
|
||||
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||
error, strerror(error)));
|
||||
DEBUGF(fprintf(stderr, "Error opening file: %s\n",
|
||||
PATH_HOSTS));
|
||||
*host = NULL;
|
||||
return ARES_EFILE;
|
||||
}
|
||||
}
|
||||
while ((status = ares__get_hostent(fp, addr->family, host)) == ARES_SUCCESS)
|
||||
{
|
||||
if (addr->family != (*host)->h_addrtype)
|
||||
{
|
||||
ares_free_hostent(*host);
|
||||
continue;
|
||||
}
|
||||
if (addr->family == AF_INET)
|
||||
{
|
||||
if (memcmp((*host)->h_addr, &addr->addrV4,
|
||||
sizeof(addr->addrV4)) == 0)
|
||||
break;
|
||||
}
|
||||
else if (addr->family == AF_INET6)
|
||||
{
|
||||
if (memcmp((*host)->h_addr, &addr->addrV6,
|
||||
sizeof(addr->addrV6)) == 0)
|
||||
break;
|
||||
}
|
||||
ares_free_hostent(*host);
|
||||
}
|
||||
fclose(fp);
|
||||
if (status == ARES_EOF)
|
||||
status = ARES_ENOTFOUND;
|
||||
if (status != ARES_SUCCESS)
|
||||
*host = NULL;
|
||||
return status;
|
||||
}
|
||||
|
||||
static void ptr_rr_name(char *name, const struct ares_addr *addr)
|
||||
{
|
||||
if (addr->family == AF_INET)
|
||||
{
|
||||
unsigned long laddr = ntohl(addr->addrV4.s_addr);
|
||||
unsigned long a1 = (laddr >> 24UL) & 0xFFUL;
|
||||
unsigned long a2 = (laddr >> 16UL) & 0xFFUL;
|
||||
unsigned long a3 = (laddr >> 8UL) & 0xFFUL;
|
||||
unsigned long a4 = laddr & 0xFFUL;
|
||||
sprintf(name, "%lu.%lu.%lu.%lu.in-addr.arpa", a4, a3, a2, a1);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char *bytes = (unsigned char *)&addr->addrV6;
|
||||
/* There are too many arguments to do this in one line using
|
||||
* minimally C89-compliant compilers */
|
||||
sprintf(name,
|
||||
"%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.",
|
||||
bytes[15]&0xf, bytes[15] >> 4, bytes[14]&0xf, bytes[14] >> 4,
|
||||
bytes[13]&0xf, bytes[13] >> 4, bytes[12]&0xf, bytes[12] >> 4,
|
||||
bytes[11]&0xf, bytes[11] >> 4, bytes[10]&0xf, bytes[10] >> 4,
|
||||
bytes[9]&0xf, bytes[9] >> 4, bytes[8]&0xf, bytes[8] >> 4);
|
||||
sprintf(name+strlen(name),
|
||||
"%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa",
|
||||
bytes[7]&0xf, bytes[7] >> 4, bytes[6]&0xf, bytes[6] >> 4,
|
||||
bytes[5]&0xf, bytes[5] >> 4, bytes[4]&0xf, bytes[4] >> 4,
|
||||
bytes[3]&0xf, bytes[3] >> 4, bytes[2]&0xf, bytes[2] >> 4,
|
||||
bytes[1]&0xf, bytes[1] >> 4, bytes[0]&0xf, bytes[0] >> 4);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,515 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "inet_net_pton.h"
|
||||
#include "bitncmp.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
#ifdef WATT32
|
||||
#undef WIN32
|
||||
#endif
|
||||
|
||||
struct host_query {
|
||||
/* Arguments passed to ares_gethostbyname() */
|
||||
ares_channel channel;
|
||||
char *name;
|
||||
ares_host_callback callback;
|
||||
void *arg;
|
||||
int sent_family; /* this family is what was is being used */
|
||||
int want_family; /* this family is what is asked for in the API */
|
||||
const char *remaining_lookups;
|
||||
int timeouts;
|
||||
};
|
||||
|
||||
static void next_lookup(struct host_query *hquery, int status_code);
|
||||
static void host_callback(void *arg, int status, int timeouts,
|
||||
unsigned char *abuf, int alen);
|
||||
static void end_hquery(struct host_query *hquery, int status,
|
||||
struct hostent *host);
|
||||
static int fake_hostent(const char *name, int family,
|
||||
ares_host_callback callback, void *arg);
|
||||
static int file_lookup(const char *name, int family, struct hostent **host);
|
||||
static void sort_addresses(struct hostent *host,
|
||||
const struct apattern *sortlist, int nsort);
|
||||
static void sort6_addresses(struct hostent *host,
|
||||
const struct apattern *sortlist, int nsort);
|
||||
static int get_address_index(const struct in_addr *addr,
|
||||
const struct apattern *sortlist, int nsort);
|
||||
static int get6_address_index(const struct ares_in6_addr *addr,
|
||||
const struct apattern *sortlist, int nsort);
|
||||
|
||||
void ares_gethostbyname(ares_channel channel, const char *name, int family,
|
||||
ares_host_callback callback, void *arg)
|
||||
{
|
||||
struct host_query *hquery;
|
||||
|
||||
/* Right now we only know how to look up Internet addresses - and unspec
|
||||
means try both basically. */
|
||||
switch (family) {
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
case AF_UNSPEC:
|
||||
break;
|
||||
default:
|
||||
callback(arg, ARES_ENOTIMP, 0, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fake_hostent(name, family, callback, arg))
|
||||
return;
|
||||
|
||||
/* Allocate and fill in the host query structure. */
|
||||
hquery = malloc(sizeof(struct host_query));
|
||||
if (!hquery)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
||||
return;
|
||||
}
|
||||
hquery->channel = channel;
|
||||
hquery->name = strdup(name);
|
||||
hquery->want_family = family;
|
||||
hquery->sent_family = -1; /* nothing is sent yet */
|
||||
if (!hquery->name) {
|
||||
free(hquery);
|
||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
||||
return;
|
||||
}
|
||||
hquery->callback = callback;
|
||||
hquery->arg = arg;
|
||||
hquery->remaining_lookups = channel->lookups;
|
||||
hquery->timeouts = 0;
|
||||
|
||||
/* Start performing lookups according to channel->lookups. */
|
||||
next_lookup(hquery, ARES_ECONNREFUSED /* initial error code */);
|
||||
}
|
||||
|
||||
static void next_lookup(struct host_query *hquery, int status_code)
|
||||
{
|
||||
const char *p;
|
||||
struct hostent *host;
|
||||
int status = status_code;
|
||||
|
||||
for (p = hquery->remaining_lookups; *p; p++)
|
||||
{
|
||||
switch (*p)
|
||||
{
|
||||
case 'b':
|
||||
/* DNS lookup */
|
||||
hquery->remaining_lookups = p + 1;
|
||||
if ((hquery->want_family == AF_INET6) ||
|
||||
(hquery->want_family == AF_UNSPEC)) {
|
||||
/* if inet6 or unspec, start out with AAAA */
|
||||
hquery->sent_family = AF_INET6;
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_AAAA,
|
||||
host_callback, hquery);
|
||||
}
|
||||
else {
|
||||
hquery->sent_family = AF_INET;
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_A,
|
||||
host_callback, hquery);
|
||||
}
|
||||
return;
|
||||
|
||||
case 'f':
|
||||
/* Host file lookup */
|
||||
status = file_lookup(hquery->name, hquery->want_family, &host);
|
||||
|
||||
/* this status check below previously checked for !ARES_ENOTFOUND,
|
||||
but we should not assume that this single error code is the one
|
||||
that can occur, as that is in fact no longer the case */
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
end_hquery(hquery, status, host);
|
||||
return;
|
||||
}
|
||||
status = status_code; /* Use original status code */
|
||||
break;
|
||||
}
|
||||
}
|
||||
end_hquery(hquery, status, NULL);
|
||||
}
|
||||
|
||||
static void host_callback(void *arg, int status, int timeouts,
|
||||
unsigned char *abuf, int alen)
|
||||
{
|
||||
struct host_query *hquery = (struct host_query *) arg;
|
||||
ares_channel channel = hquery->channel;
|
||||
struct hostent *host = NULL;
|
||||
|
||||
hquery->timeouts += timeouts;
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
if (hquery->sent_family == AF_INET)
|
||||
{
|
||||
status = ares_parse_a_reply(abuf, alen, &host, NULL, NULL);
|
||||
if (host && channel->nsort)
|
||||
sort_addresses(host, channel->sortlist, channel->nsort);
|
||||
}
|
||||
else if (hquery->sent_family == AF_INET6)
|
||||
{
|
||||
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
|
||||
if (status == ARES_ENODATA || status == ARES_EBADRESP) {
|
||||
/* The query returned something but either there were no AAAA
|
||||
records (e.g. just CNAME) or the response was malformed. Try
|
||||
looking up A instead. We should possibly limit this
|
||||
attempt-next logic to AF_UNSPEC lookups only. */
|
||||
hquery->sent_family = AF_INET;
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_A,
|
||||
host_callback, hquery);
|
||||
return;
|
||||
}
|
||||
if (host && channel->nsort)
|
||||
sort6_addresses(host, channel->sortlist, channel->nsort);
|
||||
}
|
||||
end_hquery(hquery, status, host);
|
||||
}
|
||||
else if ((status == ARES_ENODATA || status == ARES_EBADRESP ||
|
||||
status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
|
||||
{
|
||||
/* The AAAA query yielded no useful result. Now look up an A instead.
|
||||
We should possibly limit this attempt-next logic to AF_UNSPEC lookups
|
||||
only. */
|
||||
hquery->sent_family = AF_INET;
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
|
||||
hquery);
|
||||
}
|
||||
else if (status == ARES_EDESTRUCTION)
|
||||
end_hquery(hquery, status, NULL);
|
||||
else
|
||||
next_lookup(hquery, status);
|
||||
}
|
||||
|
||||
static void end_hquery(struct host_query *hquery, int status,
|
||||
struct hostent *host)
|
||||
{
|
||||
hquery->callback(hquery->arg, status, hquery->timeouts, host);
|
||||
if (host)
|
||||
ares_free_hostent(host);
|
||||
free(hquery->name);
|
||||
free(hquery);
|
||||
}
|
||||
|
||||
/* If the name looks like an IP address, fake up a host entry, end the
|
||||
* query immediately, and return true. Otherwise return false.
|
||||
*/
|
||||
static int fake_hostent(const char *name, int family,
|
||||
ares_host_callback callback, void *arg)
|
||||
{
|
||||
struct hostent hostent;
|
||||
char *aliases[1] = { NULL };
|
||||
char *addrs[2];
|
||||
int result = 0;
|
||||
struct in_addr in;
|
||||
struct ares_in6_addr in6;
|
||||
|
||||
if (family == AF_INET || family == AF_INET6)
|
||||
{
|
||||
/* It only looks like an IP address if it's all numbers and dots. */
|
||||
int numdots = 0, valid = 1;
|
||||
const char *p;
|
||||
for (p = name; *p; p++)
|
||||
{
|
||||
if (!ISDIGIT(*p) && *p != '.') {
|
||||
valid = 0;
|
||||
break;
|
||||
} else if (*p == '.') {
|
||||
numdots++;
|
||||
}
|
||||
}
|
||||
|
||||
/* if we don't have 3 dots, it is illegal
|
||||
* (although inet_addr doesn't think so).
|
||||
*/
|
||||
if (numdots != 3 || !valid)
|
||||
result = 0;
|
||||
else
|
||||
result = ((in.s_addr = inet_addr(name)) == INADDR_NONE ? 0 : 1);
|
||||
|
||||
if (result)
|
||||
family = AF_INET;
|
||||
}
|
||||
if (family == AF_INET6)
|
||||
result = (ares_inet_pton(AF_INET6, name, &in6) < 1 ? 0 : 1);
|
||||
|
||||
if (!result)
|
||||
return 0;
|
||||
|
||||
if (family == AF_INET)
|
||||
{
|
||||
hostent.h_length = (int)sizeof(struct in_addr);
|
||||
addrs[0] = (char *)∈
|
||||
}
|
||||
else if (family == AF_INET6)
|
||||
{
|
||||
hostent.h_length = (int)sizeof(struct ares_in6_addr);
|
||||
addrs[0] = (char *)&in6;
|
||||
}
|
||||
/* Duplicate the name, to avoid a constness violation. */
|
||||
hostent.h_name = strdup(name);
|
||||
if (!hostent.h_name)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Fill in the rest of the host structure and terminate the query. */
|
||||
addrs[1] = NULL;
|
||||
hostent.h_aliases = aliases;
|
||||
hostent.h_addrtype = family;
|
||||
hostent.h_addr_list = addrs;
|
||||
callback(arg, ARES_SUCCESS, 0, &hostent);
|
||||
|
||||
free((char *)(hostent.h_name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* This is an API method */
|
||||
int ares_gethostbyname_file(ares_channel channel, const char *name,
|
||||
int family, struct hostent **host)
|
||||
{
|
||||
int result;
|
||||
|
||||
/* We only take the channel to ensure that ares_init() been called. */
|
||||
if(channel == NULL)
|
||||
{
|
||||
/* Anything will do, really. This seems fine, and is consistent with
|
||||
other error cases. */
|
||||
*host = NULL;
|
||||
return ARES_ENOTFOUND;
|
||||
}
|
||||
|
||||
/* Just chain to the internal implementation we use here; it's exactly
|
||||
* what we want.
|
||||
*/
|
||||
result = file_lookup(name, family, host);
|
||||
if(result != ARES_SUCCESS)
|
||||
{
|
||||
/* We guarantee a NULL hostent on failure. */
|
||||
*host = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int file_lookup(const char *name, int family, struct hostent **host)
|
||||
{
|
||||
FILE *fp;
|
||||
char **alias;
|
||||
int status;
|
||||
int error;
|
||||
|
||||
#ifdef WIN32
|
||||
char PATH_HOSTS[MAX_PATH];
|
||||
if (IS_NT()) {
|
||||
char tmp[MAX_PATH];
|
||||
HKEY hkeyHosts;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ,
|
||||
&hkeyHosts) == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD dwLength = MAX_PATH;
|
||||
RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp,
|
||||
&dwLength);
|
||||
ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH);
|
||||
RegCloseKey(hkeyHosts);
|
||||
}
|
||||
}
|
||||
else
|
||||
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
|
||||
|
||||
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
|
||||
|
||||
#elif defined(WATT32)
|
||||
extern const char *_w32_GetHostsFile (void);
|
||||
const char *PATH_HOSTS = _w32_GetHostsFile();
|
||||
|
||||
if (!PATH_HOSTS)
|
||||
return ARES_ENOTFOUND;
|
||||
#endif
|
||||
|
||||
fp = fopen(PATH_HOSTS, "r");
|
||||
if (!fp)
|
||||
{
|
||||
error = ERRNO;
|
||||
switch(error)
|
||||
{
|
||||
case ENOENT:
|
||||
case ESRCH:
|
||||
return ARES_ENOTFOUND;
|
||||
default:
|
||||
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||
error, strerror(error)));
|
||||
DEBUGF(fprintf(stderr, "Error opening file: %s\n",
|
||||
PATH_HOSTS));
|
||||
*host = NULL;
|
||||
return ARES_EFILE;
|
||||
}
|
||||
}
|
||||
while ((status = ares__get_hostent(fp, family, host)) == ARES_SUCCESS)
|
||||
{
|
||||
if (strcasecmp((*host)->h_name, name) == 0)
|
||||
break;
|
||||
for (alias = (*host)->h_aliases; *alias; alias++)
|
||||
{
|
||||
if (strcasecmp(*alias, name) == 0)
|
||||
break;
|
||||
}
|
||||
if (*alias)
|
||||
break;
|
||||
ares_free_hostent(*host);
|
||||
}
|
||||
fclose(fp);
|
||||
if (status == ARES_EOF)
|
||||
status = ARES_ENOTFOUND;
|
||||
if (status != ARES_SUCCESS)
|
||||
*host = NULL;
|
||||
return status;
|
||||
}
|
||||
|
||||
static void sort_addresses(struct hostent *host,
|
||||
const struct apattern *sortlist, int nsort)
|
||||
{
|
||||
struct in_addr a1, a2;
|
||||
int i1, i2, ind1, ind2;
|
||||
|
||||
/* This is a simple insertion sort, not optimized at all. i1 walks
|
||||
* through the address list, with the loop invariant that everything
|
||||
* to the left of i1 is sorted. In the loop body, the value at i1 is moved
|
||||
* back through the list (via i2) until it is in sorted order.
|
||||
*/
|
||||
for (i1 = 0; host->h_addr_list[i1]; i1++)
|
||||
{
|
||||
memcpy(&a1, host->h_addr_list[i1], sizeof(struct in_addr));
|
||||
ind1 = get_address_index(&a1, sortlist, nsort);
|
||||
for (i2 = i1 - 1; i2 >= 0; i2--)
|
||||
{
|
||||
memcpy(&a2, host->h_addr_list[i2], sizeof(struct in_addr));
|
||||
ind2 = get_address_index(&a2, sortlist, nsort);
|
||||
if (ind2 <= ind1)
|
||||
break;
|
||||
memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct in_addr));
|
||||
}
|
||||
memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct in_addr));
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the first entry in sortlist which matches addr. Return nsort
|
||||
* if none of them match.
|
||||
*/
|
||||
static int get_address_index(const struct in_addr *addr,
|
||||
const struct apattern *sortlist,
|
||||
int nsort)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nsort; i++)
|
||||
{
|
||||
if (sortlist[i].family != AF_INET)
|
||||
continue;
|
||||
if (sortlist[i].type == PATTERN_MASK)
|
||||
{
|
||||
if ((addr->s_addr & sortlist[i].mask.addr4.s_addr)
|
||||
== sortlist[i].addrV4.s_addr)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ares_bitncmp(&addr->s_addr, &sortlist[i].addrV4.s_addr,
|
||||
sortlist[i].mask.bits))
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static void sort6_addresses(struct hostent *host,
|
||||
const struct apattern *sortlist, int nsort)
|
||||
{
|
||||
struct ares_in6_addr a1, a2;
|
||||
int i1, i2, ind1, ind2;
|
||||
|
||||
/* This is a simple insertion sort, not optimized at all. i1 walks
|
||||
* through the address list, with the loop invariant that everything
|
||||
* to the left of i1 is sorted. In the loop body, the value at i1 is moved
|
||||
* back through the list (via i2) until it is in sorted order.
|
||||
*/
|
||||
for (i1 = 0; host->h_addr_list[i1]; i1++)
|
||||
{
|
||||
memcpy(&a1, host->h_addr_list[i1], sizeof(struct ares_in6_addr));
|
||||
ind1 = get6_address_index(&a1, sortlist, nsort);
|
||||
for (i2 = i1 - 1; i2 >= 0; i2--)
|
||||
{
|
||||
memcpy(&a2, host->h_addr_list[i2], sizeof(struct ares_in6_addr));
|
||||
ind2 = get6_address_index(&a2, sortlist, nsort);
|
||||
if (ind2 <= ind1)
|
||||
break;
|
||||
memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct ares_in6_addr));
|
||||
}
|
||||
memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct ares_in6_addr));
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the first entry in sortlist which matches addr. Return nsort
|
||||
* if none of them match.
|
||||
*/
|
||||
static int get6_address_index(const struct ares_in6_addr *addr,
|
||||
const struct apattern *sortlist,
|
||||
int nsort)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nsort; i++)
|
||||
{
|
||||
if (sortlist[i].family != AF_INET6)
|
||||
continue;
|
||||
if (!ares_bitncmp(addr,
|
||||
&sortlist[i].addrV6,
|
||||
sortlist[i].mask.bits))
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
}
|
|
@ -0,0 +1,426 @@
|
|||
|
||||
/* Copyright 2005 by Dominick Meglio
|
||||
*
|
||||
* 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_GETSERVBYPORT_R
|
||||
# if !defined(GETSERVBYPORT_R_ARGS) || \
|
||||
(GETSERVBYPORT_R_ARGS < 4) || (GETSERVBYPORT_R_ARGS > 6)
|
||||
# error "you MUST specifiy a valid number of arguments for getservbyport_r"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#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
|
||||
|
||||
#ifdef HAVE_NET_IF_H
|
||||
#include <net/if.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_ipv6.h"
|
||||
#include "inet_ntop.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
struct nameinfo_query {
|
||||
ares_nameinfo_callback callback;
|
||||
void *arg;
|
||||
union {
|
||||
struct sockaddr_in addr4;
|
||||
struct sockaddr_in6 addr6;
|
||||
} addr;
|
||||
int family;
|
||||
int flags;
|
||||
int timeouts;
|
||||
};
|
||||
|
||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||
#define IPBUFSIZ \
|
||||
(sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") + IF_NAMESIZE)
|
||||
#else
|
||||
#define IPBUFSIZ \
|
||||
(sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"))
|
||||
#endif
|
||||
|
||||
static void nameinfo_callback(void *arg, int status, int timeouts,
|
||||
struct hostent *host);
|
||||
static char *lookup_service(unsigned short port, int flags,
|
||||
char *buf, size_t buflen);
|
||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||
static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int scopeid,
|
||||
char *buf, size_t buflen);
|
||||
#endif
|
||||
static char *ares_striendstr(const char *s1, const char *s2);
|
||||
|
||||
void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
||||
ares_socklen_t salen,
|
||||
int flags, ares_nameinfo_callback callback, void *arg)
|
||||
{
|
||||
struct sockaddr_in *addr = NULL;
|
||||
struct sockaddr_in6 *addr6 = NULL;
|
||||
struct nameinfo_query *niquery;
|
||||
unsigned int port = 0;
|
||||
|
||||
/* Validate socket address family and length */
|
||||
if ((sa->sa_family == AF_INET) &&
|
||||
(salen == sizeof(struct sockaddr_in)))
|
||||
{
|
||||
addr = (struct sockaddr_in *)sa;
|
||||
port = addr->sin_port;
|
||||
}
|
||||
else if ((sa->sa_family == AF_INET6) &&
|
||||
(salen == sizeof(struct sockaddr_in6)))
|
||||
{
|
||||
addr6 = (struct sockaddr_in6 *)sa;
|
||||
port = addr6->sin6_port;
|
||||
}
|
||||
else
|
||||
{
|
||||
callback(arg, ARES_ENOTIMP, 0, NULL, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If neither, assume they want a host */
|
||||
if (!(flags & ARES_NI_LOOKUPSERVICE) && !(flags & ARES_NI_LOOKUPHOST))
|
||||
flags |= ARES_NI_LOOKUPHOST;
|
||||
|
||||
/* All they want is a service, no need for DNS */
|
||||
if ((flags & ARES_NI_LOOKUPSERVICE) && !(flags & ARES_NI_LOOKUPHOST))
|
||||
{
|
||||
char buf[33], *service;
|
||||
|
||||
service = lookup_service((unsigned short)(port & 0xffff),
|
||||
flags, buf, sizeof(buf));
|
||||
callback(arg, ARES_SUCCESS, 0, NULL, service);
|
||||
return;
|
||||
}
|
||||
|
||||
/* They want a host lookup */
|
||||
if ((flags & ARES_NI_LOOKUPHOST))
|
||||
{
|
||||
/* A numeric host can be handled without DNS */
|
||||
if ((flags & ARES_NI_NUMERICHOST))
|
||||
{
|
||||
char ipbuf[IPBUFSIZ];
|
||||
char srvbuf[33];
|
||||
char *service = NULL;
|
||||
ipbuf[0] = 0;
|
||||
|
||||
/* Specifying not to lookup a host, but then saying a host
|
||||
* is required has to be illegal.
|
||||
*/
|
||||
if (flags & ARES_NI_NAMEREQD)
|
||||
{
|
||||
callback(arg, ARES_EBADFLAGS, 0, NULL, NULL);
|
||||
return;
|
||||
}
|
||||
if (salen == sizeof(struct sockaddr_in6))
|
||||
{
|
||||
ares_inet_ntop(AF_INET6, &addr6->sin6_addr, ipbuf, IPBUFSIZ);
|
||||
/* If the system supports scope IDs, use it */
|
||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||
append_scopeid(addr6, flags, ipbuf, sizeof(ipbuf));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ares_inet_ntop(AF_INET, &addr->sin_addr, ipbuf, IPBUFSIZ);
|
||||
}
|
||||
/* They also want a service */
|
||||
if (flags & ARES_NI_LOOKUPSERVICE)
|
||||
service = lookup_service((unsigned short)(port & 0xffff),
|
||||
flags, srvbuf, sizeof(srvbuf));
|
||||
callback(arg, ARES_SUCCESS, 0, ipbuf, service);
|
||||
return;
|
||||
}
|
||||
/* This is where a DNS lookup becomes necessary */
|
||||
else
|
||||
{
|
||||
niquery = malloc(sizeof(struct nameinfo_query));
|
||||
if (!niquery)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, NULL);
|
||||
return;
|
||||
}
|
||||
niquery->callback = callback;
|
||||
niquery->arg = arg;
|
||||
niquery->flags = flags;
|
||||
niquery->timeouts = 0;
|
||||
if (sa->sa_family == AF_INET)
|
||||
{
|
||||
niquery->family = AF_INET;
|
||||
memcpy(&niquery->addr.addr4, addr, sizeof(addr));
|
||||
ares_gethostbyaddr(channel, &addr->sin_addr,
|
||||
sizeof(struct in_addr), AF_INET,
|
||||
nameinfo_callback, niquery);
|
||||
}
|
||||
else
|
||||
{
|
||||
niquery->family = AF_INET6;
|
||||
memcpy(&niquery->addr.addr6, addr6, sizeof(addr6));
|
||||
ares_gethostbyaddr(channel, &addr6->sin6_addr,
|
||||
sizeof(struct ares_in6_addr), AF_INET6,
|
||||
nameinfo_callback, niquery);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void nameinfo_callback(void *arg, int status, int timeouts,
|
||||
struct hostent *host)
|
||||
{
|
||||
struct nameinfo_query *niquery = (struct nameinfo_query *) arg;
|
||||
char srvbuf[33];
|
||||
char *service = NULL;
|
||||
|
||||
niquery->timeouts += timeouts;
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
/* They want a service too */
|
||||
if (niquery->flags & ARES_NI_LOOKUPSERVICE)
|
||||
{
|
||||
if (niquery->family == AF_INET)
|
||||
service = lookup_service(niquery->addr.addr4.sin_port,
|
||||
niquery->flags, srvbuf, sizeof(srvbuf));
|
||||
else
|
||||
service = lookup_service(niquery->addr.addr6.sin6_port,
|
||||
niquery->flags, srvbuf, sizeof(srvbuf));
|
||||
}
|
||||
/* NOFQDN means we have to strip off the domain name portion. We do
|
||||
this by determining our own domain name, then searching the string
|
||||
for this domain name and removing it.
|
||||
*/
|
||||
#ifdef HAVE_GETHOSTNAME
|
||||
if (niquery->flags & ARES_NI_NOFQDN)
|
||||
{
|
||||
char buf[255];
|
||||
char *domain;
|
||||
gethostname(buf, 255);
|
||||
if ((domain = strchr(buf, '.')) != NULL)
|
||||
{
|
||||
char *end = ares_striendstr(host->h_name, domain);
|
||||
if (end)
|
||||
*end = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts,
|
||||
(char *)(host->h_name),
|
||||
service);
|
||||
free(niquery);
|
||||
return;
|
||||
}
|
||||
/* We couldn't find the host, but it's OK, we can use the IP */
|
||||
else if (status == ARES_ENOTFOUND && !(niquery->flags & ARES_NI_NAMEREQD))
|
||||
{
|
||||
char ipbuf[IPBUFSIZ];
|
||||
if (niquery->family == AF_INET)
|
||||
ares_inet_ntop(AF_INET, &niquery->addr.addr4.sin_addr, ipbuf,
|
||||
IPBUFSIZ);
|
||||
else
|
||||
{
|
||||
ares_inet_ntop(AF_INET6, &niquery->addr.addr6.sin6_addr, ipbuf,
|
||||
IPBUFSIZ);
|
||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||
append_scopeid(&niquery->addr.addr6, niquery->flags, ipbuf,
|
||||
sizeof(ipbuf));
|
||||
#endif
|
||||
}
|
||||
/* They want a service too */
|
||||
if (niquery->flags & ARES_NI_LOOKUPSERVICE)
|
||||
{
|
||||
if (niquery->family == AF_INET)
|
||||
service = lookup_service(niquery->addr.addr4.sin_port,
|
||||
niquery->flags, srvbuf, sizeof(srvbuf));
|
||||
else
|
||||
service = lookup_service(niquery->addr.addr6.sin6_port,
|
||||
niquery->flags, srvbuf, sizeof(srvbuf));
|
||||
}
|
||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, ipbuf,
|
||||
service);
|
||||
free(niquery);
|
||||
return;
|
||||
}
|
||||
niquery->callback(niquery->arg, status, niquery->timeouts, NULL, NULL);
|
||||
free(niquery);
|
||||
}
|
||||
|
||||
static char *lookup_service(unsigned short port, int flags,
|
||||
char *buf, size_t buflen)
|
||||
{
|
||||
const char *proto;
|
||||
struct servent *sep;
|
||||
#ifdef HAVE_GETSERVBYPORT_R
|
||||
struct servent se;
|
||||
#endif
|
||||
char tmpbuf[4096];
|
||||
|
||||
if (port)
|
||||
{
|
||||
if (flags & ARES_NI_NUMERICSERV)
|
||||
sep = NULL;
|
||||
else
|
||||
{
|
||||
if (flags & ARES_NI_UDP)
|
||||
proto = "udp";
|
||||
else if (flags & ARES_NI_SCTP)
|
||||
proto = "sctp";
|
||||
else if (flags & ARES_NI_DCCP)
|
||||
proto = "dccp";
|
||||
else
|
||||
proto = "tcp";
|
||||
#ifdef HAVE_GETSERVBYPORT_R
|
||||
sep = &se;
|
||||
memset(tmpbuf, 0, sizeof(tmpbuf));
|
||||
#if GETSERVBYPORT_R_ARGS == 6
|
||||
if (getservbyport_r(port, proto, &se, (void *)tmpbuf,
|
||||
sizeof(tmpbuf), &sep) != 0)
|
||||
sep = NULL;
|
||||
#elif GETSERVBYPORT_R_ARGS == 5
|
||||
sep = getservbyport_r(port, proto, &se, (void *)tmpbuf,
|
||||
sizeof(tmpbuf));
|
||||
#elif GETSERVBYPORT_R_ARGS == 4
|
||||
if (getservbyport_r(port, proto, &se, (void *)tmpbuf) != 0)
|
||||
sep = NULL;
|
||||
#else
|
||||
/* Lets just hope the OS uses TLS! */
|
||||
sep = getservbyport(port, proto);
|
||||
#endif
|
||||
#else
|
||||
/* Lets just hope the OS uses TLS! */
|
||||
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
|
||||
sep = getservbyport(port, (char*)proto);
|
||||
#else
|
||||
sep = getservbyport(port, proto);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
if (sep && sep->s_name)
|
||||
/* get service name */
|
||||
strcpy(tmpbuf, sep->s_name);
|
||||
else
|
||||
/* get port as a string */
|
||||
sprintf(tmpbuf, "%u", (unsigned int)ntohs(port));
|
||||
if (strlen(tmpbuf) < buflen)
|
||||
/* return it if buffer big enough */
|
||||
strcpy(buf, tmpbuf);
|
||||
else
|
||||
/* avoid reusing previous one */
|
||||
buf[0] = '\0';
|
||||
return buf;
|
||||
}
|
||||
buf[0] = '\0';
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||
static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags,
|
||||
char *buf, size_t buflen)
|
||||
{
|
||||
#ifdef HAVE_IF_INDEXTONAME
|
||||
int is_ll, is_mcll;
|
||||
#endif
|
||||
static const char fmt_u[] = "%u";
|
||||
static const char fmt_lu[] = "%lu";
|
||||
char tmpbuf[IF_NAMESIZE + 2];
|
||||
size_t bufl;
|
||||
const char *fmt = (sizeof(addr6->sin6_scope_id) > sizeof(unsigned int))?
|
||||
fmt_lu:fmt_u;
|
||||
|
||||
tmpbuf[0] = '%';
|
||||
|
||||
#ifdef HAVE_IF_INDEXTONAME
|
||||
is_ll = IN6_IS_ADDR_LINKLOCAL(&addr6->sin6_addr);
|
||||
is_mcll = IN6_IS_ADDR_MC_LINKLOCAL(&addr6->sin6_addr);
|
||||
if ((flags & ARES_NI_NUMERICSCOPE) ||
|
||||
(!is_ll && !is_mcll))
|
||||
{
|
||||
sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (if_indextoname(addr6->sin6_scope_id, &tmpbuf[1]) == NULL)
|
||||
sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id);
|
||||
}
|
||||
#else
|
||||
sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id);
|
||||
(void) flags;
|
||||
#endif
|
||||
tmpbuf[IF_NAMESIZE + 1] = '\0';
|
||||
bufl = strlen(buf);
|
||||
|
||||
if(bufl + strlen(tmpbuf) < buflen)
|
||||
/* only append the scopeid string if it fits in the target buffer */
|
||||
strcpy(&buf[bufl], tmpbuf);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Determines if s1 ends with the string in s2 (case-insensitive) */
|
||||
static char *ares_striendstr(const char *s1, const char *s2)
|
||||
{
|
||||
const char *c1, *c2, *c1_begin;
|
||||
int lo1, lo2;
|
||||
size_t s1_len = strlen(s1), s2_len = strlen(s2);
|
||||
|
||||
/* If the substr is longer than the full str, it can't match */
|
||||
if (s2_len > s1_len)
|
||||
return NULL;
|
||||
|
||||
/* Jump to the end of s1 minus the length of s2 */
|
||||
c1_begin = s1+s1_len-s2_len;
|
||||
c1 = (const char *)c1_begin;
|
||||
c2 = s2;
|
||||
while (c2 < s2+s2_len)
|
||||
{
|
||||
lo1 = TOLOWER(*c1);
|
||||
lo2 = TOLOWER(*c2);
|
||||
if (lo1 != lo2)
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
c1++;
|
||||
c2++;
|
||||
}
|
||||
}
|
||||
if (c2 == c1 && c2 == NULL)
|
||||
return (char *)c1_begin;
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* 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 */
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
#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 */
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
/* Copyright (C) 2005 - 2010, Daniel Stenberg
|
||||
*
|
||||
* 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_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
int ares_getsock(ares_channel channel,
|
||||
ares_socket_t *socks,
|
||||
int numsocks) /* size of the 'socks' array */
|
||||
{
|
||||
struct server_state *server;
|
||||
int i;
|
||||
int sockindex=0;
|
||||
int bitmap = 0;
|
||||
unsigned int setbits = 0xffffffff;
|
||||
|
||||
/* Are there any active queries? */
|
||||
int active_queries = !ares__is_list_empty(&(channel->all_queries));
|
||||
|
||||
for (i = 0;
|
||||
(i < channel->nservers) && (sockindex < ARES_GETSOCK_MAXNUM);
|
||||
i++)
|
||||
{
|
||||
server = &channel->servers[i];
|
||||
/* We only need to register interest in UDP sockets if we have
|
||||
* outstanding queries.
|
||||
*/
|
||||
if (active_queries && server->udp_socket != ARES_SOCKET_BAD)
|
||||
{
|
||||
if(sockindex >= numsocks)
|
||||
break;
|
||||
socks[sockindex] = server->udp_socket;
|
||||
bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex);
|
||||
sockindex++;
|
||||
}
|
||||
/* We always register for TCP events, because we want to know
|
||||
* when the other side closes the connection, so we don't waste
|
||||
* time trying to use a broken connection.
|
||||
*/
|
||||
if (server->tcp_socket != ARES_SOCKET_BAD)
|
||||
{
|
||||
if(sockindex >= numsocks)
|
||||
break;
|
||||
socks[sockindex] = server->tcp_socket;
|
||||
bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex);
|
||||
|
||||
if (server->qhead && active_queries)
|
||||
/* then the tcp socket is also writable! */
|
||||
bitmap |= ARES_GETSOCK_WRITABLE(setbits, sockindex);
|
||||
|
||||
sockindex++;
|
||||
}
|
||||
}
|
||||
return bitmap;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,78 @@
|
|||
|
||||
/* Copyright (C) 2005 by Dominick Meglio
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef ARES_IPV6_H
|
||||
#define ARES_IPV6_H
|
||||
|
||||
#ifndef HAVE_PF_INET6
|
||||
#define PF_INET6 AF_INET6
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRUCT_SOCKADDR_IN6
|
||||
struct sockaddr_in6
|
||||
{
|
||||
unsigned short sin6_family;
|
||||
unsigned short sin6_port;
|
||||
unsigned long sin6_flowinfo;
|
||||
struct ares_in6_addr sin6_addr;
|
||||
unsigned int sin6_scope_id;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRUCT_ADDRINFO
|
||||
struct addrinfo
|
||||
{
|
||||
int ai_flags;
|
||||
int ai_family;
|
||||
int ai_socktype;
|
||||
int ai_protocol;
|
||||
ares_socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */
|
||||
char *ai_canonname;
|
||||
struct sockaddr *ai_addr;
|
||||
struct addrinfo *ai_next;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef NS_IN6ADDRSZ
|
||||
#if SIZEOF_STRUCT_IN6_ADDR == 0
|
||||
/* We cannot have it set to zero, so we pick a fixed value here */
|
||||
#define NS_IN6ADDRSZ 16
|
||||
#else
|
||||
#define NS_IN6ADDRSZ SIZEOF_STRUCT_IN6_ADDR
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NS_INADDRSZ
|
||||
#define NS_INADDRSZ SIZEOF_STRUCT_IN_ADDR
|
||||
#endif
|
||||
|
||||
#ifndef NS_INT16SZ
|
||||
#define NS_INT16SZ 2
|
||||
#endif
|
||||
|
||||
#ifndef IF_NAMESIZE
|
||||
#ifdef IFNAMSIZ
|
||||
#define IF_NAMESIZE IFNAMSIZ
|
||||
#else
|
||||
#define IF_NAMESIZE 256
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Defined in ares_net_pton.c for no particular reason. */
|
||||
extern const struct ares_in6_addr ares_in6addr_any; /* :: */
|
||||
|
||||
|
||||
#endif /* ARES_IPV6_H */
|
|
@ -0,0 +1,132 @@
|
|||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2004-2009 by Daniel Stenberg
|
||||
*
|
||||
* 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"
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_library_init.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
/* library-private global and unique instance vars */
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
fpGetNetworkParams_t ares_fpGetNetworkParams = ZERO_NULL;
|
||||
fpSystemFunction036_t ares_fpSystemFunction036 = ZERO_NULL;
|
||||
#endif
|
||||
|
||||
/* library-private global vars with source visibility restricted to this file */
|
||||
|
||||
static unsigned int ares_initialized;
|
||||
static int ares_init_flags;
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
static HMODULE hnd_iphlpapi;
|
||||
static HMODULE hnd_advapi32;
|
||||
#endif
|
||||
|
||||
|
||||
static int ares_win32_init(void)
|
||||
{
|
||||
#ifdef USE_WINSOCK
|
||||
|
||||
hnd_iphlpapi = 0;
|
||||
hnd_iphlpapi = LoadLibrary("iphlpapi.dll");
|
||||
if (!hnd_iphlpapi)
|
||||
return ARES_ELOADIPHLPAPI;
|
||||
|
||||
ares_fpGetNetworkParams = (fpGetNetworkParams_t)
|
||||
GetProcAddress(hnd_iphlpapi, "GetNetworkParams");
|
||||
if (!ares_fpGetNetworkParams)
|
||||
{
|
||||
FreeLibrary(hnd_iphlpapi);
|
||||
return ARES_EADDRGETNETWORKPARAMS;
|
||||
}
|
||||
|
||||
/*
|
||||
* When advapi32.dll is unavailable or advapi32.dll has no SystemFunction036,
|
||||
* also known as RtlGenRandom, which is the case for Windows versions prior
|
||||
* to WinXP then c-ares uses portable rand() function. Then don't error here.
|
||||
*/
|
||||
|
||||
hnd_advapi32 = 0;
|
||||
hnd_advapi32 = LoadLibrary("advapi32.dll");
|
||||
if (hnd_advapi32)
|
||||
{
|
||||
ares_fpSystemFunction036 = (fpSystemFunction036_t)
|
||||
GetProcAddress(hnd_advapi32, "SystemFunction036");
|
||||
}
|
||||
|
||||
#endif
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void ares_win32_cleanup(void)
|
||||
{
|
||||
#ifdef USE_WINSOCK
|
||||
if (hnd_advapi32)
|
||||
FreeLibrary(hnd_advapi32);
|
||||
if (hnd_iphlpapi)
|
||||
FreeLibrary(hnd_iphlpapi);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int ares_library_init(int flags)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (ares_initialized)
|
||||
return ARES_SUCCESS;
|
||||
ares_initialized++;
|
||||
|
||||
if (flags & ARES_LIB_INIT_WIN32)
|
||||
{
|
||||
res = ares_win32_init();
|
||||
if (res != ARES_SUCCESS)
|
||||
return res;
|
||||
}
|
||||
|
||||
ares_init_flags = flags;
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void ares_library_cleanup(void)
|
||||
{
|
||||
if (!ares_initialized)
|
||||
return;
|
||||
ares_initialized--;
|
||||
|
||||
if (ares_init_flags & ARES_LIB_INIT_WIN32)
|
||||
ares_win32_cleanup();
|
||||
|
||||
ares_init_flags = ARES_LIB_INIT_NONE;
|
||||
}
|
||||
|
||||
|
||||
int ares_library_initialized(void)
|
||||
{
|
||||
#ifdef USE_WINSOCK
|
||||
if (!ares_initialized)
|
||||
return ARES_ENOTINITIALIZED;
|
||||
#endif
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef HEADER_CARES_LIBRARY_INIT_H
|
||||
#define HEADER_CARES_LIBRARY_INIT_H
|
||||
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2004-2009 by Daniel Stenberg
|
||||
*
|
||||
* 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 USE_WINSOCK
|
||||
|
||||
#include <iphlpapi.h>
|
||||
|
||||
typedef DWORD (WINAPI *fpGetNetworkParams_t) (FIXED_INFO*, DWORD*);
|
||||
typedef BOOLEAN (APIENTRY *fpSystemFunction036_t) (void*, ULONG);
|
||||
|
||||
/* Forward-declaration of variables defined in ares_library_init.c */
|
||||
/* that are global and unique instances for whole c-ares library. */
|
||||
|
||||
extern fpGetNetworkParams_t ares_fpGetNetworkParams;
|
||||
extern fpSystemFunction036_t ares_fpSystemFunction036;
|
||||
|
||||
#endif /* USE_WINSOCK */
|
||||
|
||||
#endif /* HEADER_CARES_LIBRARY_INIT_H */
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
/* Routines for managing doubly-linked circular linked lists with a
|
||||
* dummy head.
|
||||
*/
|
||||
|
||||
/* Initialize a new head node */
|
||||
void ares__init_list_head(struct list_node* head) {
|
||||
head->prev = head;
|
||||
head->next = head;
|
||||
head->data = NULL;
|
||||
}
|
||||
|
||||
/* Initialize a list node */
|
||||
void ares__init_list_node(struct list_node* node, void* d) {
|
||||
node->prev = NULL;
|
||||
node->next = NULL;
|
||||
node->data = d;
|
||||
}
|
||||
|
||||
/* Returns true iff the given list is empty */
|
||||
int ares__is_list_empty(struct list_node* head) {
|
||||
return ((head->next == head) && (head->prev == head));
|
||||
}
|
||||
|
||||
/* Inserts new_node before old_node */
|
||||
void ares__insert_in_list(struct list_node* new_node,
|
||||
struct list_node* old_node) {
|
||||
new_node->next = old_node;
|
||||
new_node->prev = old_node->prev;
|
||||
old_node->prev->next = new_node;
|
||||
old_node->prev = new_node;
|
||||
}
|
||||
|
||||
/* Removes the node from the list it's in, if any */
|
||||
void ares__remove_from_list(struct list_node* node) {
|
||||
if (node->next != NULL) {
|
||||
node->prev->next = node->next;
|
||||
node->next->prev = node->prev;
|
||||
node->prev = NULL;
|
||||
node->next = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Swap the contents of two lists */
|
||||
void ares__swap_lists(struct list_node* head_a,
|
||||
struct list_node* head_b) {
|
||||
int is_a_empty = ares__is_list_empty(head_a);
|
||||
int is_b_empty = ares__is_list_empty(head_b);
|
||||
struct list_node old_a = *head_a;
|
||||
struct list_node old_b = *head_b;
|
||||
|
||||
if (is_a_empty) {
|
||||
ares__init_list_head(head_b);
|
||||
} else {
|
||||
*head_b = old_a;
|
||||
old_a.next->prev = head_b;
|
||||
old_a.prev->next = head_b;
|
||||
}
|
||||
if (is_b_empty) {
|
||||
ares__init_list_head(head_a);
|
||||
} else {
|
||||
*head_a = old_b;
|
||||
old_b.next->prev = head_a;
|
||||
old_b.prev->next = head_a;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef __ARES_LLIST_H
|
||||
#define __ARES_LLIST_H
|
||||
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
|
||||
/* Node definition for circular, doubly-linked list */
|
||||
struct list_node {
|
||||
struct list_node *prev;
|
||||
struct list_node *next;
|
||||
void* data;
|
||||
};
|
||||
|
||||
void ares__init_list_head(struct list_node* head);
|
||||
|
||||
void ares__init_list_node(struct list_node* node, void* d);
|
||||
|
||||
int ares__is_list_empty(struct list_node* head);
|
||||
|
||||
void ares__insert_in_list(struct list_node* new_node,
|
||||
struct list_node* old_node);
|
||||
|
||||
void ares__remove_from_list(struct list_node* node);
|
||||
|
||||
void ares__swap_lists(struct list_node* head_a,
|
||||
struct list_node* head_b);
|
||||
|
||||
#endif /* __ARES_LLIST_H */
|
|
@ -0,0 +1,195 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
/* Header format, from RFC 1035:
|
||||
* 1 1 1 1 1 1
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ID |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* |QR| Opcode |AA|TC|RD|RA| Z | RCODE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | QDCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ANCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | NSCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ARCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* AA, TC, RA, and RCODE are only set in responses. Brief description
|
||||
* of the remaining fields:
|
||||
* ID Identifier to match responses with queries
|
||||
* QR Query (0) or response (1)
|
||||
* Opcode For our purposes, always QUERY
|
||||
* RD Recursion desired
|
||||
* Z Reserved (zero)
|
||||
* QDCOUNT Number of queries
|
||||
* ANCOUNT Number of answers
|
||||
* NSCOUNT Number of name server records
|
||||
* ARCOUNT Number of additional records
|
||||
*
|
||||
* Question format, from RFC 1035:
|
||||
* 1 1 1 1 1 1
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | |
|
||||
* / QNAME /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | QTYPE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | QCLASS |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* The query name is encoded as a series of labels, each represented
|
||||
* as a one-byte length (maximum 63) followed by the text of the
|
||||
* label. The list is terminated by a label of length zero (which can
|
||||
* be thought of as the root domain).
|
||||
*/
|
||||
|
||||
int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
|
||||
int rd, unsigned char **buf, int *buflen)
|
||||
{
|
||||
int len;
|
||||
unsigned char *q;
|
||||
const char *p;
|
||||
|
||||
/* Set our results early, in case we bail out early with an error. */
|
||||
*buflen = 0;
|
||||
*buf = NULL;
|
||||
|
||||
/* Compute the length of the encoded name so we can check buflen.
|
||||
* Start counting at 1 for the zero-length label at the end. */
|
||||
len = 1;
|
||||
for (p = name; *p; p++)
|
||||
{
|
||||
if (*p == '\\' && *(p + 1) != 0)
|
||||
p++;
|
||||
len++;
|
||||
}
|
||||
/* If there are n periods in the name, there are n + 1 labels, and
|
||||
* thus n + 1 length fields, unless the name is empty or ends with a
|
||||
* period. So add 1 unless name is empty or ends with a period.
|
||||
*/
|
||||
if (*name && *(p - 1) != '.')
|
||||
len++;
|
||||
|
||||
/* Immediately reject names that are longer than the maximum of 255
|
||||
* bytes that's specified in RFC 1035 ("To simplify implementations,
|
||||
* the total length of a domain name (i.e., label octets and label
|
||||
* length octets) is restricted to 255 octets or less."). We aren't
|
||||
* doing this just to be a stickler about RFCs. For names that are
|
||||
* too long, 'dnscache' closes its TCP connection to us immediately
|
||||
* (when using TCP) and ignores the request when using UDP, and
|
||||
* BIND's named returns ServFail (TCP or UDP). Sending a request
|
||||
* that we know will cause 'dnscache' to close the TCP connection is
|
||||
* painful, since that makes any other outstanding requests on that
|
||||
* connection fail. And sending a UDP request that we know
|
||||
* 'dnscache' will ignore is bad because resources will be tied up
|
||||
* until we time-out the request.
|
||||
*/
|
||||
if (len > MAXCDNAME)
|
||||
return ARES_EBADNAME;
|
||||
|
||||
*buflen = len + HFIXEDSZ + QFIXEDSZ;
|
||||
*buf = malloc(*buflen);
|
||||
if (!*buf)
|
||||
return ARES_ENOMEM;
|
||||
|
||||
/* Set up the header. */
|
||||
q = *buf;
|
||||
memset(q, 0, HFIXEDSZ);
|
||||
DNS_HEADER_SET_QID(q, id);
|
||||
DNS_HEADER_SET_OPCODE(q, QUERY);
|
||||
if (rd) {
|
||||
DNS_HEADER_SET_RD(q, 1);
|
||||
}
|
||||
else {
|
||||
DNS_HEADER_SET_RD(q, 0);
|
||||
}
|
||||
DNS_HEADER_SET_QDCOUNT(q, 1);
|
||||
|
||||
/* A name of "." is a screw case for the loop below, so adjust it. */
|
||||
if (strcmp(name, ".") == 0)
|
||||
name++;
|
||||
|
||||
/* Start writing out the name after the header. */
|
||||
q += HFIXEDSZ;
|
||||
while (*name)
|
||||
{
|
||||
if (*name == '.')
|
||||
return ARES_EBADNAME;
|
||||
|
||||
/* Count the number of bytes in this label. */
|
||||
len = 0;
|
||||
for (p = name; *p && *p != '.'; p++)
|
||||
{
|
||||
if (*p == '\\' && *(p + 1) != 0)
|
||||
p++;
|
||||
len++;
|
||||
}
|
||||
if (len > MAXLABEL)
|
||||
return ARES_EBADNAME;
|
||||
|
||||
/* Encode the length and copy the data. */
|
||||
*q++ = (unsigned char)len;
|
||||
for (p = name; *p && *p != '.'; p++)
|
||||
{
|
||||
if (*p == '\\' && *(p + 1) != 0)
|
||||
p++;
|
||||
*q++ = *p;
|
||||
}
|
||||
|
||||
/* Go to the next label and repeat, unless we hit the end. */
|
||||
if (!*p)
|
||||
break;
|
||||
name = p + 1;
|
||||
}
|
||||
|
||||
/* Add the zero-length label at the end. */
|
||||
*q++ = 0;
|
||||
|
||||
/* Finish off the question with the type and class. */
|
||||
DNS_QUESTION_SET_TYPE(q, type);
|
||||
DNS_QUESTION_SET_CLASS(q, dnsclass);
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
/* Copyright (C) 2010 by Daniel Stenberg
|
||||
*
|
||||
* 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"
|
||||
|
||||
#include "ares_nowarn.h"
|
||||
|
||||
#define CARES_MASK_UINT (~(unsigned int) 0)
|
||||
#define CARES_MASK_SINT (CARES_MASK_UINT >> 1)
|
||||
|
||||
/*
|
||||
** size_t to signed int
|
||||
*/
|
||||
|
||||
int aresx_uztosi(size_t uznum)
|
||||
{
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
#endif
|
||||
|
||||
return (int)(uznum & (size_t) CARES_MASK_SINT);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** signed long to signed int
|
||||
*/
|
||||
|
||||
int aresx_sltosi(long slnum)
|
||||
{
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
#endif
|
||||
|
||||
return (int)(slnum & (long) CARES_MASK_SINT);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef HEADER_CARES_NOWARN_H
|
||||
#define HEADER_CARES_NOWARN_H
|
||||
|
||||
|
||||
/* Copyright (C) 2010 by Daniel Stenberg
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
int aresx_uztosi(size_t uznum);
|
||||
|
||||
int aresx_sltosi(long slnum);
|
||||
|
||||
#endif /* HEADER_CARES_NOWARN_H */
|
|
@ -0,0 +1,253 @@
|
|||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2008-2010 by Daniel Stenberg
|
||||
*
|
||||
* 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_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_data.h"
|
||||
#include "inet_net_pton.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
|
||||
int ares_get_servers(ares_channel channel,
|
||||
struct ares_addr_node **servers)
|
||||
{
|
||||
struct ares_addr_node *srvr_head = NULL;
|
||||
struct ares_addr_node *srvr_last = NULL;
|
||||
struct ares_addr_node *srvr_curr;
|
||||
int status = ARES_SUCCESS;
|
||||
int i;
|
||||
|
||||
if (!channel)
|
||||
return ARES_ENODATA;
|
||||
|
||||
for (i = 0; i < channel->nservers; i++)
|
||||
{
|
||||
/* Allocate storage for this server node appending it to the list */
|
||||
srvr_curr = ares_malloc_data(ARES_DATATYPE_ADDR_NODE);
|
||||
if (!srvr_curr)
|
||||
{
|
||||
status = ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
if (srvr_last)
|
||||
{
|
||||
srvr_last->next = srvr_curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
srvr_head = srvr_curr;
|
||||
}
|
||||
srvr_last = srvr_curr;
|
||||
|
||||
/* Fill this server node data */
|
||||
srvr_curr->family = channel->servers[i].addr.family;
|
||||
if (srvr_curr->family == AF_INET)
|
||||
memcpy(&srvr_curr->addrV4, &channel->servers[i].addr.addrV4,
|
||||
sizeof(srvr_curr->addrV4));
|
||||
else
|
||||
memcpy(&srvr_curr->addrV6, &channel->servers[i].addr.addrV6,
|
||||
sizeof(srvr_curr->addrV6));
|
||||
}
|
||||
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
if (srvr_head)
|
||||
{
|
||||
ares_free_data(srvr_head);
|
||||
srvr_head = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
*servers = srvr_head;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
int ares_set_servers(ares_channel channel,
|
||||
struct ares_addr_node *servers)
|
||||
{
|
||||
struct ares_addr_node *srvr;
|
||||
int num_srvrs = 0;
|
||||
int i;
|
||||
|
||||
if (ares_library_initialized() != ARES_SUCCESS)
|
||||
return ARES_ENOTINITIALIZED;
|
||||
|
||||
if (!channel)
|
||||
return ARES_ENODATA;
|
||||
|
||||
ares__destroy_servers_state(channel);
|
||||
|
||||
for (srvr = servers; srvr; srvr = srvr->next)
|
||||
{
|
||||
num_srvrs++;
|
||||
}
|
||||
|
||||
if (num_srvrs > 0)
|
||||
{
|
||||
/* Allocate storage for servers state */
|
||||
channel->servers = malloc(num_srvrs * sizeof(struct server_state));
|
||||
if (!channel->servers)
|
||||
{
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
channel->nservers = num_srvrs;
|
||||
/* Fill servers state address data */
|
||||
for (i = 0, srvr = servers; srvr; i++, srvr = srvr->next)
|
||||
{
|
||||
channel->servers[i].addr.family = srvr->family;
|
||||
if (srvr->family == AF_INET)
|
||||
memcpy(&channel->servers[i].addr.addrV4, &srvr->addrV4,
|
||||
sizeof(srvr->addrV4));
|
||||
else
|
||||
memcpy(&channel->servers[i].addr.addrV6, &srvr->addrV6,
|
||||
sizeof(srvr->addrV6));
|
||||
}
|
||||
/* Initialize servers state remaining data */
|
||||
ares__init_servers_state(channel);
|
||||
}
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
/* Incomming string format: host[:port][,host[:port]]... */
|
||||
int ares_set_servers_csv(ares_channel channel,
|
||||
const char* _csv)
|
||||
{
|
||||
int i;
|
||||
char* csv = NULL;
|
||||
char* ptr;
|
||||
char* start_host;
|
||||
long port;
|
||||
bool found_port;
|
||||
int rv = ARES_SUCCESS;
|
||||
struct ares_addr_node *servers = NULL;
|
||||
struct ares_addr_node *last = NULL;
|
||||
|
||||
if (ares_library_initialized() != ARES_SUCCESS)
|
||||
return ARES_ENOTINITIALIZED;
|
||||
|
||||
if (!channel)
|
||||
return ARES_ENODATA;
|
||||
|
||||
ares__destroy_servers_state(channel);
|
||||
|
||||
i = strlen(_csv);
|
||||
if (i == 0)
|
||||
return ARES_SUCCESS; /* blank all servers */
|
||||
|
||||
csv = malloc(i + 2);
|
||||
strcpy(csv, _csv);
|
||||
if (csv[i-1] != ',') { /* make parsing easier by ensuring ending ',' */
|
||||
csv[i] = ',';
|
||||
csv[i+1] = 0;
|
||||
}
|
||||
|
||||
start_host = csv;
|
||||
found_port = false;
|
||||
for (ptr = csv; *ptr; ptr++) {
|
||||
if (*ptr == ',') {
|
||||
char* pp = ptr - 1;
|
||||
struct in_addr in4;
|
||||
struct ares_in6_addr in6;
|
||||
struct ares_addr_node *s = NULL;
|
||||
|
||||
*ptr = 0; /* null terminate host:port string */
|
||||
/* Got an entry..see if port was specified. */
|
||||
while (pp > start_host) {
|
||||
if (*pp == ':')
|
||||
break; /* yes */
|
||||
if (!ISDIGIT(*pp)) {
|
||||
/* Found end of digits before we found :, so wasn't a port */
|
||||
pp = ptr;
|
||||
break;
|
||||
}
|
||||
pp--;
|
||||
}
|
||||
if ((pp != start_host) && ((pp + 1) < ptr)) {
|
||||
/* Found it. */
|
||||
found_port = true;
|
||||
port = strtol(pp + 1, NULL, 10);
|
||||
*pp = 0; /* null terminate host */
|
||||
}
|
||||
/* resolve host, try ipv4 first, rslt is in network byte order */
|
||||
rv = ares_inet_pton(AF_INET, start_host, &in4);
|
||||
if (!rv) {
|
||||
/* Ok, try IPv6 then */
|
||||
rv = ares_inet_pton(AF_INET6, start_host, &in6);
|
||||
if (!rv) {
|
||||
rv = ARES_EBADSTR;
|
||||
goto out;
|
||||
}
|
||||
/* was ipv6, add new server */
|
||||
s = malloc(sizeof(*s));
|
||||
if (!s) {
|
||||
rv = ARES_ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
s->family = AF_INET6;
|
||||
memcpy(&s->addr, &in6, sizeof(struct ares_in6_addr));
|
||||
}
|
||||
else {
|
||||
/* was ipv4, add new server */
|
||||
s = malloc(sizeof(*s));
|
||||
if (!s) {
|
||||
rv = ARES_ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
s->family = AF_INET;
|
||||
memcpy(&s->addr, &in4, sizeof(struct in_addr));
|
||||
}
|
||||
if (s) {
|
||||
/* TODO: Add port to ares_addr_node and assign it here. */
|
||||
|
||||
s->next = NULL;
|
||||
if (last) {
|
||||
last->next = s;
|
||||
}
|
||||
else {
|
||||
servers = s;
|
||||
last = s;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up for next one */
|
||||
found_port = false;
|
||||
start_host = ptr + 1;
|
||||
}
|
||||
}
|
||||
|
||||
rv = ares_set_servers(channel, servers);
|
||||
|
||||
out:
|
||||
if (csv)
|
||||
free(csv);
|
||||
while (servers) {
|
||||
struct ares_addr_node *s = servers;
|
||||
servers = servers->next;
|
||||
free(s);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
|
@ -0,0 +1,258 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#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
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||
struct hostent **host,
|
||||
struct ares_addrttl *addrttls, int *naddrttls)
|
||||
{
|
||||
unsigned int qdcount, ancount;
|
||||
int status, i, rr_type, rr_class, rr_len, rr_ttl, naddrs;
|
||||
int cname_ttl = INT_MAX; /* the TTL imposed by the CNAME chain */
|
||||
int naliases;
|
||||
long len;
|
||||
const unsigned char *aptr;
|
||||
char *hostname, *rr_name, *rr_data, **aliases;
|
||||
struct in_addr *addrs;
|
||||
struct hostent *hostent;
|
||||
const int max_addr_ttls = (addrttls && naddrttls) ? *naddrttls : 0;
|
||||
|
||||
/* Set *host to NULL for all failure cases. */
|
||||
if (host)
|
||||
*host = NULL;
|
||||
/* Same with *naddrttls. */
|
||||
if (naddrttls)
|
||||
*naddrttls = 0;
|
||||
|
||||
/* Give up if abuf doesn't have room for a header. */
|
||||
if (alen < HFIXEDSZ)
|
||||
return ARES_EBADRESP;
|
||||
|
||||
/* Fetch the question and answer count from the header. */
|
||||
qdcount = DNS_HEADER_QDCOUNT(abuf);
|
||||
ancount = DNS_HEADER_ANCOUNT(abuf);
|
||||
if (qdcount != 1)
|
||||
return ARES_EBADRESP;
|
||||
|
||||
/* Expand the name from the question, and skip past the question. */
|
||||
aptr = abuf + HFIXEDSZ;
|
||||
status = ares__expand_name_for_response(aptr, abuf, alen, &hostname, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
return status;
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free(hostname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
|
||||
if (host)
|
||||
{
|
||||
/* Allocate addresses and aliases; ancount gives an upper bound for
|
||||
both. */
|
||||
addrs = malloc(ancount * sizeof(struct in_addr));
|
||||
if (!addrs)
|
||||
{
|
||||
free(hostname);
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
aliases = malloc((ancount + 1) * sizeof(char *));
|
||||
if (!aliases)
|
||||
{
|
||||
free(hostname);
|
||||
free(addrs);
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
addrs = NULL;
|
||||
aliases = NULL;
|
||||
}
|
||||
|
||||
naddrs = 0;
|
||||
naliases = 0;
|
||||
|
||||
/* Examine each answer resource record (RR) in turn. */
|
||||
for (i = 0; i < (int)ancount; i++)
|
||||
{
|
||||
/* Decode the RR up to the data field. */
|
||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
break;
|
||||
aptr += len;
|
||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
rr_type = DNS_RR_TYPE(aptr);
|
||||
rr_class = DNS_RR_CLASS(aptr);
|
||||
rr_len = DNS_RR_LEN(aptr);
|
||||
rr_ttl = DNS_RR_TTL(aptr);
|
||||
aptr += RRFIXEDSZ;
|
||||
|
||||
if (rr_class == C_IN && rr_type == T_A
|
||||
&& rr_len == sizeof(struct in_addr)
|
||||
&& strcasecmp(rr_name, hostname) == 0)
|
||||
{
|
||||
if (addrs)
|
||||
{
|
||||
if (aptr + sizeof(struct in_addr) > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
memcpy(&addrs[naddrs], aptr, sizeof(struct in_addr));
|
||||
}
|
||||
if (naddrs < max_addr_ttls)
|
||||
{
|
||||
struct ares_addrttl * const at = &addrttls[naddrs];
|
||||
if (aptr + sizeof(struct in_addr) > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
memcpy(&at->ipaddr, aptr, sizeof(struct in_addr));
|
||||
at->ttl = rr_ttl;
|
||||
}
|
||||
naddrs++;
|
||||
status = ARES_SUCCESS;
|
||||
}
|
||||
|
||||
if (rr_class == C_IN && rr_type == T_CNAME)
|
||||
{
|
||||
/* Record the RR name as an alias. */
|
||||
if (aliases)
|
||||
aliases[naliases] = rr_name;
|
||||
else
|
||||
free(rr_name);
|
||||
naliases++;
|
||||
|
||||
/* Decode the RR data and replace the hostname with it. */
|
||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data,
|
||||
&len);
|
||||
if (status != ARES_SUCCESS)
|
||||
break;
|
||||
free(hostname);
|
||||
hostname = rr_data;
|
||||
|
||||
/* Take the min of the TTLs we see in the CNAME chain. */
|
||||
if (cname_ttl > rr_ttl)
|
||||
cname_ttl = rr_ttl;
|
||||
}
|
||||
else
|
||||
free(rr_name);
|
||||
|
||||
aptr += rr_len;
|
||||
if (aptr > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (status == ARES_SUCCESS && naddrs == 0 && naliases == 0)
|
||||
/* the check for naliases to be zero is to make sure CNAME responses
|
||||
don't get caught here */
|
||||
status = ARES_ENODATA;
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
/* We got our answer. */
|
||||
if (naddrttls)
|
||||
{
|
||||
const int n = naddrs < max_addr_ttls ? naddrs : max_addr_ttls;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
/* Ensure that each A TTL is no larger than the CNAME TTL. */
|
||||
if (addrttls[i].ttl > cname_ttl)
|
||||
addrttls[i].ttl = cname_ttl;
|
||||
}
|
||||
*naddrttls = n;
|
||||
}
|
||||
if (aliases)
|
||||
aliases[naliases] = NULL;
|
||||
if (host)
|
||||
{
|
||||
/* Allocate memory to build the host entry. */
|
||||
hostent = malloc(sizeof(struct hostent));
|
||||
if (hostent)
|
||||
{
|
||||
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
|
||||
if (hostent->h_addr_list)
|
||||
{
|
||||
/* Fill in the hostent and return successfully. */
|
||||
hostent->h_name = hostname;
|
||||
hostent->h_aliases = aliases;
|
||||
hostent->h_addrtype = AF_INET;
|
||||
hostent->h_length = sizeof(struct in_addr);
|
||||
for (i = 0; i < naddrs; i++)
|
||||
hostent->h_addr_list[i] = (char *) &addrs[i];
|
||||
hostent->h_addr_list[naddrs] = NULL;
|
||||
*host = hostent;
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
free(hostent);
|
||||
}
|
||||
status = ARES_ENOMEM;
|
||||
}
|
||||
}
|
||||
if (aliases)
|
||||
{
|
||||
for (i = 0; i < naliases; i++)
|
||||
free(aliases[i]);
|
||||
free(aliases);
|
||||
}
|
||||
free(addrs);
|
||||
free(hostname);
|
||||
return status;
|
||||
}
|
|
@ -0,0 +1,256 @@
|
|||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright 2005 Dominick Meglio
|
||||
*
|
||||
* 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_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#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
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "inet_net_pton.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||
struct hostent **host, struct ares_addr6ttl *addrttls,
|
||||
int *naddrttls)
|
||||
{
|
||||
unsigned int qdcount, ancount;
|
||||
int status, i, rr_type, rr_class, rr_len, rr_ttl, naddrs;
|
||||
int cname_ttl = INT_MAX; /* the TTL imposed by the CNAME chain */
|
||||
int naliases;
|
||||
long len;
|
||||
const unsigned char *aptr;
|
||||
char *hostname, *rr_name, *rr_data, **aliases;
|
||||
struct ares_in6_addr *addrs;
|
||||
struct hostent *hostent;
|
||||
const int max_addr_ttls = (addrttls && naddrttls) ? *naddrttls : 0;
|
||||
|
||||
/* Set *host to NULL for all failure cases. */
|
||||
if (host)
|
||||
*host = NULL;
|
||||
/* Same with *naddrttls. */
|
||||
if (naddrttls)
|
||||
*naddrttls = 0;
|
||||
|
||||
/* Give up if abuf doesn't have room for a header. */
|
||||
if (alen < HFIXEDSZ)
|
||||
return ARES_EBADRESP;
|
||||
|
||||
/* Fetch the question and answer count from the header. */
|
||||
qdcount = DNS_HEADER_QDCOUNT(abuf);
|
||||
ancount = DNS_HEADER_ANCOUNT(abuf);
|
||||
if (qdcount != 1)
|
||||
return ARES_EBADRESP;
|
||||
|
||||
/* Expand the name from the question, and skip past the question. */
|
||||
aptr = abuf + HFIXEDSZ;
|
||||
status = ares__expand_name_for_response(aptr, abuf, alen, &hostname, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
return status;
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free(hostname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
|
||||
/* Allocate addresses and aliases; ancount gives an upper bound for both. */
|
||||
if (host)
|
||||
{
|
||||
addrs = malloc(ancount * sizeof(struct ares_in6_addr));
|
||||
if (!addrs)
|
||||
{
|
||||
free(hostname);
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
aliases = malloc((ancount + 1) * sizeof(char *));
|
||||
if (!aliases)
|
||||
{
|
||||
free(hostname);
|
||||
free(addrs);
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
addrs = NULL;
|
||||
aliases = NULL;
|
||||
}
|
||||
naddrs = 0;
|
||||
naliases = 0;
|
||||
|
||||
/* Examine each answer resource record (RR) in turn. */
|
||||
for (i = 0; i < (int)ancount; i++)
|
||||
{
|
||||
/* Decode the RR up to the data field. */
|
||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
break;
|
||||
aptr += len;
|
||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
rr_type = DNS_RR_TYPE(aptr);
|
||||
rr_class = DNS_RR_CLASS(aptr);
|
||||
rr_len = DNS_RR_LEN(aptr);
|
||||
rr_ttl = DNS_RR_TTL(aptr);
|
||||
aptr += RRFIXEDSZ;
|
||||
|
||||
if (rr_class == C_IN && rr_type == T_AAAA
|
||||
&& rr_len == sizeof(struct ares_in6_addr)
|
||||
&& strcasecmp(rr_name, hostname) == 0)
|
||||
{
|
||||
if (addrs)
|
||||
{
|
||||
if (aptr + sizeof(struct ares_in6_addr) > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
memcpy(&addrs[naddrs], aptr, sizeof(struct ares_in6_addr));
|
||||
}
|
||||
if (naddrs < max_addr_ttls)
|
||||
{
|
||||
struct ares_addr6ttl * const at = &addrttls[naddrs];
|
||||
if (aptr + sizeof(struct ares_in6_addr) > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
memcpy(&at->ip6addr, aptr, sizeof(struct ares_in6_addr));
|
||||
at->ttl = rr_ttl;
|
||||
}
|
||||
naddrs++;
|
||||
status = ARES_SUCCESS;
|
||||
}
|
||||
|
||||
if (rr_class == C_IN && rr_type == T_CNAME)
|
||||
{
|
||||
/* Record the RR name as an alias. */
|
||||
if (aliases)
|
||||
aliases[naliases] = rr_name;
|
||||
else
|
||||
free(rr_name);
|
||||
naliases++;
|
||||
|
||||
/* Decode the RR data and replace the hostname with it. */
|
||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data,
|
||||
&len);
|
||||
if (status != ARES_SUCCESS)
|
||||
break;
|
||||
free(hostname);
|
||||
hostname = rr_data;
|
||||
|
||||
/* Take the min of the TTLs we see in the CNAME chain. */
|
||||
if (cname_ttl > rr_ttl)
|
||||
cname_ttl = rr_ttl;
|
||||
}
|
||||
else
|
||||
free(rr_name);
|
||||
|
||||
aptr += rr_len;
|
||||
if (aptr > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (status == ARES_SUCCESS && naddrs == 0)
|
||||
status = ARES_ENODATA;
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
/* We got our answer. */
|
||||
if (naddrttls)
|
||||
{
|
||||
const int n = naddrs < max_addr_ttls ? naddrs : max_addr_ttls;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
/* Ensure that each A TTL is no larger than the CNAME TTL. */
|
||||
if (addrttls[i].ttl > cname_ttl)
|
||||
addrttls[i].ttl = cname_ttl;
|
||||
}
|
||||
*naddrttls = n;
|
||||
}
|
||||
if (aliases)
|
||||
aliases[naliases] = NULL;
|
||||
if (host)
|
||||
{
|
||||
/* Allocate memory to build the host entry. */
|
||||
hostent = malloc(sizeof(struct hostent));
|
||||
if (hostent)
|
||||
{
|
||||
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
|
||||
if (hostent->h_addr_list)
|
||||
{
|
||||
/* Fill in the hostent and return successfully. */
|
||||
hostent->h_name = hostname;
|
||||
hostent->h_aliases = aliases;
|
||||
hostent->h_addrtype = AF_INET6;
|
||||
hostent->h_length = sizeof(struct ares_in6_addr);
|
||||
for (i = 0; i < naddrs; i++)
|
||||
hostent->h_addr_list[i] = (char *) &addrs[i];
|
||||
hostent->h_addr_list[naddrs] = NULL;
|
||||
*host = hostent;
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
free(hostent);
|
||||
}
|
||||
status = ARES_ENOMEM;
|
||||
}
|
||||
}
|
||||
if (aliases)
|
||||
{
|
||||
for (i = 0; i < naliases; i++)
|
||||
free(aliases[i]);
|
||||
free(aliases);
|
||||
}
|
||||
free(addrs);
|
||||
free(hostname);
|
||||
return status;
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2010 Jeremy Lal <kapouer@melix.org>
|
||||
*
|
||||
* 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_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "ares_data.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
int
|
||||
ares_parse_mx_reply (const unsigned char *abuf, int alen,
|
||||
struct ares_mx_reply **mx_out)
|
||||
{
|
||||
unsigned int qdcount, ancount, i;
|
||||
const unsigned char *aptr, *vptr;
|
||||
int status, rr_type, rr_class, rr_len;
|
||||
long len;
|
||||
char *hostname = NULL, *rr_name = NULL;
|
||||
struct ares_mx_reply *mx_head = NULL;
|
||||
struct ares_mx_reply *mx_last = NULL;
|
||||
struct ares_mx_reply *mx_curr;
|
||||
|
||||
/* Set *mx_out to NULL for all failure cases. */
|
||||
*mx_out = NULL;
|
||||
|
||||
/* Give up if abuf doesn't have room for a header. */
|
||||
if (alen < HFIXEDSZ)
|
||||
return ARES_EBADRESP;
|
||||
|
||||
/* Fetch the question and answer count from the header. */
|
||||
qdcount = DNS_HEADER_QDCOUNT (abuf);
|
||||
ancount = DNS_HEADER_ANCOUNT (abuf);
|
||||
if (qdcount != 1)
|
||||
return ARES_EBADRESP;
|
||||
if (ancount == 0)
|
||||
return ARES_ENODATA;
|
||||
|
||||
/* Expand the name from the question, and skip past the question. */
|
||||
aptr = abuf + HFIXEDSZ;
|
||||
status = ares_expand_name (aptr, abuf, alen, &hostname, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
return status;
|
||||
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free (hostname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
|
||||
/* Examine each answer resource record (RR) in turn. */
|
||||
for (i = 0; i < ancount; i++)
|
||||
{
|
||||
/* Decode the RR up to the data field. */
|
||||
status = ares_expand_name (aptr, abuf, alen, &rr_name, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
aptr += len;
|
||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
rr_type = DNS_RR_TYPE (aptr);
|
||||
rr_class = DNS_RR_CLASS (aptr);
|
||||
rr_len = DNS_RR_LEN (aptr);
|
||||
aptr += RRFIXEDSZ;
|
||||
|
||||
/* Check if we are really looking at a MX record */
|
||||
if (rr_class == C_IN && rr_type == T_MX)
|
||||
{
|
||||
/* parse the MX record itself */
|
||||
if (rr_len < 2)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Allocate storage for this MX answer appending it to the list */
|
||||
mx_curr = ares_malloc_data(ARES_DATATYPE_MX_REPLY);
|
||||
if (!mx_curr)
|
||||
{
|
||||
status = ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
if (mx_last)
|
||||
{
|
||||
mx_last->next = mx_curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
mx_head = mx_curr;
|
||||
}
|
||||
mx_last = mx_curr;
|
||||
|
||||
vptr = aptr;
|
||||
mx_curr->priority = ntohs (*((unsigned short *)vptr));
|
||||
vptr += sizeof(unsigned short);
|
||||
|
||||
status = ares_expand_name (vptr, abuf, alen, &mx_curr->host, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Don't lose memory in the next iteration */
|
||||
free (rr_name);
|
||||
rr_name = NULL;
|
||||
|
||||
/* Move on to the next record */
|
||||
aptr += rr_len;
|
||||
}
|
||||
|
||||
if (hostname)
|
||||
free (hostname);
|
||||
if (rr_name)
|
||||
free (rr_name);
|
||||
|
||||
/* clean up on error */
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
if (mx_head)
|
||||
ares_free_data (mx_head);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* everything looks fine, return the data */
|
||||
*mx_out = mx_head;
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,182 @@
|
|||
/* $Id */
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ares_parse_ns_reply created by Vlad Dinulescu <vlad.dinulescu@avira.com>
|
||||
* on behalf of AVIRA Gmbh - http://www.avira.com
|
||||
*/
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
int ares_parse_ns_reply( const unsigned char* abuf, int alen,
|
||||
struct hostent** host )
|
||||
{
|
||||
unsigned int qdcount, ancount;
|
||||
int status, i, rr_type, rr_class, rr_len;
|
||||
int nameservers_num;
|
||||
long len;
|
||||
const unsigned char *aptr;
|
||||
char* hostname, *rr_name, *rr_data, **nameservers;
|
||||
struct hostent *hostent;
|
||||
|
||||
/* Set *host to NULL for all failure cases. */
|
||||
*host = NULL;
|
||||
|
||||
/* Give up if abuf doesn't have room for a header. */
|
||||
if ( alen < HFIXEDSZ )
|
||||
return ARES_EBADRESP;
|
||||
|
||||
/* Fetch the question and answer count from the header. */
|
||||
qdcount = DNS_HEADER_QDCOUNT( abuf );
|
||||
ancount = DNS_HEADER_ANCOUNT( abuf );
|
||||
if ( qdcount != 1 )
|
||||
return ARES_EBADRESP;
|
||||
|
||||
/* Expand the name from the question, and skip past the question. */
|
||||
aptr = abuf + HFIXEDSZ;
|
||||
status = ares__expand_name_for_response( aptr, abuf, alen, &hostname, &len);
|
||||
if ( status != ARES_SUCCESS )
|
||||
return status;
|
||||
if ( aptr + len + QFIXEDSZ > abuf + alen )
|
||||
{
|
||||
free( hostname );
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
|
||||
/* Allocate nameservers array; ancount gives an upper bound */
|
||||
nameservers = malloc( ( ancount + 1 ) * sizeof( char * ) );
|
||||
if ( !nameservers )
|
||||
{
|
||||
free( hostname );
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
nameservers_num = 0;
|
||||
|
||||
/* Examine each answer resource record (RR) in turn. */
|
||||
for ( i = 0; i < ( int ) ancount; i++ )
|
||||
{
|
||||
/* Decode the RR up to the data field. */
|
||||
status = ares__expand_name_for_response( aptr, abuf, alen, &rr_name, &len );
|
||||
if ( status != ARES_SUCCESS )
|
||||
break;
|
||||
aptr += len;
|
||||
if ( aptr + RRFIXEDSZ > abuf + alen )
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
rr_type = DNS_RR_TYPE( aptr );
|
||||
rr_class = DNS_RR_CLASS( aptr );
|
||||
rr_len = DNS_RR_LEN( aptr );
|
||||
aptr += RRFIXEDSZ;
|
||||
|
||||
if ( rr_class == C_IN && rr_type == T_NS )
|
||||
{
|
||||
/* Decode the RR data and add it to the nameservers list */
|
||||
status = ares__expand_name_for_response( aptr, abuf, alen, &rr_data,
|
||||
&len);
|
||||
if ( status != ARES_SUCCESS )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
nameservers[nameservers_num] = malloc(strlen(rr_data)+1);
|
||||
|
||||
if (nameservers[nameservers_num]==NULL)
|
||||
{
|
||||
free(rr_name);
|
||||
free(rr_data);
|
||||
status=ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
strcpy(nameservers[nameservers_num],rr_data);
|
||||
free(rr_data);
|
||||
|
||||
nameservers_num++;
|
||||
}
|
||||
|
||||
free( rr_name );
|
||||
|
||||
aptr += rr_len;
|
||||
if ( aptr > abuf + alen )
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( status == ARES_SUCCESS && nameservers_num == 0 )
|
||||
{
|
||||
status = ARES_ENODATA;
|
||||
}
|
||||
if ( status == ARES_SUCCESS )
|
||||
{
|
||||
/* We got our answer. Allocate memory to build the host entry. */
|
||||
nameservers[nameservers_num] = NULL;
|
||||
hostent = malloc( sizeof( struct hostent ) );
|
||||
if ( hostent )
|
||||
{
|
||||
hostent->h_addr_list = malloc( 1 * sizeof( char * ) );
|
||||
if ( hostent->h_addr_list )
|
||||
{
|
||||
/* Fill in the hostent and return successfully. */
|
||||
hostent->h_name = hostname;
|
||||
hostent->h_aliases = nameservers;
|
||||
hostent->h_addrtype = AF_INET;
|
||||
hostent->h_length = sizeof( struct in_addr );
|
||||
hostent->h_addr_list[0] = NULL;
|
||||
*host = hostent;
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
free( hostent );
|
||||
}
|
||||
status = ARES_ENOMEM;
|
||||
}
|
||||
for ( i = 0; i < nameservers_num; i++ )
|
||||
free( nameservers[i] );
|
||||
free( nameservers );
|
||||
free( hostname );
|
||||
return status;
|
||||
}
|
|
@ -0,0 +1,208 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#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
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
||||
int addrlen, int family, struct hostent **host)
|
||||
{
|
||||
unsigned int qdcount, ancount;
|
||||
int status, i, rr_type, rr_class, rr_len;
|
||||
long len;
|
||||
const unsigned char *aptr;
|
||||
char *ptrname, *hostname, *rr_name, *rr_data;
|
||||
struct hostent *hostent;
|
||||
int aliascnt = 0;
|
||||
int alias_alloc = 8;
|
||||
char ** aliases;
|
||||
|
||||
/* Set *host to NULL for all failure cases. */
|
||||
*host = NULL;
|
||||
|
||||
/* Give up if abuf doesn't have room for a header. */
|
||||
if (alen < HFIXEDSZ)
|
||||
return ARES_EBADRESP;
|
||||
|
||||
/* Fetch the question and answer count from the header. */
|
||||
qdcount = DNS_HEADER_QDCOUNT(abuf);
|
||||
ancount = DNS_HEADER_ANCOUNT(abuf);
|
||||
if (qdcount != 1)
|
||||
return ARES_EBADRESP;
|
||||
|
||||
/* Expand the name from the question, and skip past the question. */
|
||||
aptr = abuf + HFIXEDSZ;
|
||||
status = ares__expand_name_for_response(aptr, abuf, alen, &ptrname, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
return status;
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free(ptrname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
|
||||
/* Examine each answer resource record (RR) in turn. */
|
||||
hostname = NULL;
|
||||
aliases = malloc(alias_alloc * sizeof(char *));
|
||||
if (!aliases)
|
||||
{
|
||||
free(ptrname);
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
for (i = 0; i < (int)ancount; i++)
|
||||
{
|
||||
/* Decode the RR up to the data field. */
|
||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
break;
|
||||
aptr += len;
|
||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
rr_type = DNS_RR_TYPE(aptr);
|
||||
rr_class = DNS_RR_CLASS(aptr);
|
||||
rr_len = DNS_RR_LEN(aptr);
|
||||
aptr += RRFIXEDSZ;
|
||||
|
||||
if (rr_class == C_IN && rr_type == T_PTR
|
||||
&& strcasecmp(rr_name, ptrname) == 0)
|
||||
{
|
||||
/* Decode the RR data and set hostname to it. */
|
||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data,
|
||||
&len);
|
||||
if (status != ARES_SUCCESS)
|
||||
break;
|
||||
if (hostname)
|
||||
free(hostname);
|
||||
hostname = rr_data;
|
||||
aliases[aliascnt] = malloc((strlen(rr_data)+1) * sizeof(char *));
|
||||
if (!aliases[aliascnt])
|
||||
{
|
||||
status = ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
strncpy(aliases[aliascnt], rr_data, strlen(rr_data)+1);
|
||||
aliascnt++;
|
||||
if (aliascnt >= alias_alloc) {
|
||||
char **ptr;
|
||||
alias_alloc *= 2;
|
||||
ptr = realloc(aliases, alias_alloc * sizeof(char *));
|
||||
if(!ptr) {
|
||||
status = ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
aliases = ptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (rr_class == C_IN && rr_type == T_CNAME)
|
||||
{
|
||||
/* Decode the RR data and replace ptrname with it. */
|
||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data,
|
||||
&len);
|
||||
if (status != ARES_SUCCESS)
|
||||
break;
|
||||
free(ptrname);
|
||||
ptrname = rr_data;
|
||||
}
|
||||
|
||||
free(rr_name);
|
||||
aptr += rr_len;
|
||||
if (aptr > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (status == ARES_SUCCESS && !hostname)
|
||||
status = ARES_ENODATA;
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
/* We got our answer. Allocate memory to build the host entry. */
|
||||
hostent = malloc(sizeof(struct hostent));
|
||||
if (hostent)
|
||||
{
|
||||
hostent->h_addr_list = malloc(2 * sizeof(char *));
|
||||
if (hostent->h_addr_list)
|
||||
{
|
||||
hostent->h_addr_list[0] = malloc(addrlen);
|
||||
if (hostent->h_addr_list[0])
|
||||
{
|
||||
hostent->h_aliases = malloc((aliascnt+1) * sizeof (char *));
|
||||
if (hostent->h_aliases)
|
||||
{
|
||||
/* Fill in the hostent and return successfully. */
|
||||
hostent->h_name = hostname;
|
||||
for (i=0 ; i<aliascnt ; i++)
|
||||
hostent->h_aliases[i] = aliases[i];
|
||||
hostent->h_aliases[aliascnt] = NULL;
|
||||
hostent->h_addrtype = family;
|
||||
hostent->h_length = addrlen;
|
||||
memcpy(hostent->h_addr_list[0], addr, addrlen);
|
||||
hostent->h_addr_list[1] = NULL;
|
||||
*host = hostent;
|
||||
free(aliases);
|
||||
free(ptrname);
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
free(hostent->h_addr_list[0]);
|
||||
}
|
||||
free(hostent->h_addr_list);
|
||||
}
|
||||
free(hostent);
|
||||
}
|
||||
status = ARES_ENOMEM;
|
||||
}
|
||||
for (i=0 ; i<aliascnt ; i++)
|
||||
if (aliases[i])
|
||||
free(aliases[i]);
|
||||
free(aliases);
|
||||
if (hostname)
|
||||
free(hostname);
|
||||
free(ptrname);
|
||||
return status;
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2009 by Jakub Hrozek <jhrozek@redhat.com>
|
||||
*
|
||||
* 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_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#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 <stdlib.h>
|
||||
#include <string.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)
|
||||
{
|
||||
unsigned int qdcount, ancount, i;
|
||||
const unsigned char *aptr, *vptr;
|
||||
int status, rr_type, rr_class, rr_len;
|
||||
long len;
|
||||
char *hostname = NULL, *rr_name = NULL;
|
||||
struct ares_srv_reply *srv_head = NULL;
|
||||
struct ares_srv_reply *srv_last = NULL;
|
||||
struct ares_srv_reply *srv_curr;
|
||||
|
||||
/* Set *srv_out to NULL for all failure cases. */
|
||||
*srv_out = NULL;
|
||||
|
||||
/* Give up if abuf doesn't have room for a header. */
|
||||
if (alen < HFIXEDSZ)
|
||||
return ARES_EBADRESP;
|
||||
|
||||
/* Fetch the question and answer count from the header. */
|
||||
qdcount = DNS_HEADER_QDCOUNT (abuf);
|
||||
ancount = DNS_HEADER_ANCOUNT (abuf);
|
||||
if (qdcount != 1)
|
||||
return ARES_EBADRESP;
|
||||
if (ancount == 0)
|
||||
return ARES_ENODATA;
|
||||
|
||||
/* Expand the name from the question, and skip past the question. */
|
||||
aptr = abuf + HFIXEDSZ;
|
||||
status = ares_expand_name (aptr, abuf, alen, &hostname, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
return status;
|
||||
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free (hostname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
|
||||
/* Examine each answer resource record (RR) in turn. */
|
||||
for (i = 0; i < ancount; i++)
|
||||
{
|
||||
/* Decode the RR up to the data field. */
|
||||
status = ares_expand_name (aptr, abuf, alen, &rr_name, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
aptr += len;
|
||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
rr_type = DNS_RR_TYPE (aptr);
|
||||
rr_class = DNS_RR_CLASS (aptr);
|
||||
rr_len = DNS_RR_LEN (aptr);
|
||||
aptr += RRFIXEDSZ;
|
||||
|
||||
/* Check if we are really looking at a SRV record */
|
||||
if (rr_class == C_IN && rr_type == T_SRV)
|
||||
{
|
||||
/* parse the SRV record itself */
|
||||
if (rr_len < 6)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Allocate storage for this SRV answer appending it to the list */
|
||||
srv_curr = ares_malloc_data(ARES_DATATYPE_SRV_REPLY);
|
||||
if (!srv_curr)
|
||||
{
|
||||
status = ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
if (srv_last)
|
||||
{
|
||||
srv_last->next = srv_curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
srv_head = srv_curr;
|
||||
}
|
||||
srv_last = srv_curr;
|
||||
|
||||
vptr = aptr;
|
||||
srv_curr->priority = ntohs (*((unsigned short *)vptr));
|
||||
vptr += sizeof(unsigned short);
|
||||
srv_curr->weight = ntohs (*((unsigned short *)vptr));
|
||||
vptr += sizeof(unsigned short);
|
||||
srv_curr->port = ntohs (*((unsigned short *)vptr));
|
||||
vptr += sizeof(unsigned short);
|
||||
|
||||
status = ares_expand_name (vptr, abuf, alen, &srv_curr->host, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Don't lose memory in the next iteration */
|
||||
free (rr_name);
|
||||
rr_name = NULL;
|
||||
|
||||
/* Move on to the next record */
|
||||
aptr += rr_len;
|
||||
}
|
||||
|
||||
if (hostname)
|
||||
free (hostname);
|
||||
if (rr_name)
|
||||
free (rr_name);
|
||||
|
||||
/* clean up on error */
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
if (srv_head)
|
||||
ares_free_data (srv_head);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* everything looks fine, return the data */
|
||||
*srv_out = srv_head;
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2009 by Jakub Hrozek <jhrozek@redhat.com>
|
||||
*
|
||||
* 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_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#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
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "ares_data.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
int
|
||||
ares_parse_txt_reply (const unsigned char *abuf, int alen,
|
||||
struct ares_txt_reply **txt_out)
|
||||
{
|
||||
size_t substr_len, str_len;
|
||||
unsigned int qdcount, ancount, i;
|
||||
const unsigned char *aptr;
|
||||
const unsigned char *strptr;
|
||||
int status, rr_type, rr_class, rr_len;
|
||||
long len;
|
||||
char *hostname = NULL, *rr_name = NULL;
|
||||
struct ares_txt_reply *txt_head = NULL;
|
||||
struct ares_txt_reply *txt_last = NULL;
|
||||
struct ares_txt_reply *txt_curr;
|
||||
|
||||
/* Set *txt_out to NULL for all failure cases. */
|
||||
*txt_out = NULL;
|
||||
|
||||
/* Give up if abuf doesn't have room for a header. */
|
||||
if (alen < HFIXEDSZ)
|
||||
return ARES_EBADRESP;
|
||||
|
||||
/* Fetch the question and answer count from the header. */
|
||||
qdcount = DNS_HEADER_QDCOUNT (abuf);
|
||||
ancount = DNS_HEADER_ANCOUNT (abuf);
|
||||
if (qdcount != 1)
|
||||
return ARES_EBADRESP;
|
||||
if (ancount == 0)
|
||||
return ARES_ENODATA;
|
||||
|
||||
/* Expand the name from the question, and skip past the question. */
|
||||
aptr = abuf + HFIXEDSZ;
|
||||
status = ares_expand_name (aptr, abuf, alen, &hostname, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
return status;
|
||||
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free (hostname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
|
||||
/* Examine each answer resource record (RR) in turn. */
|
||||
for (i = 0; i < ancount; i++)
|
||||
{
|
||||
/* Decode the RR up to the data field. */
|
||||
status = ares_expand_name (aptr, abuf, alen, &rr_name, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
aptr += len;
|
||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
rr_type = DNS_RR_TYPE (aptr);
|
||||
rr_class = DNS_RR_CLASS (aptr);
|
||||
rr_len = DNS_RR_LEN (aptr);
|
||||
aptr += RRFIXEDSZ;
|
||||
|
||||
/* Check if we are really looking at a TXT record */
|
||||
if (rr_class == C_IN && rr_type == T_TXT)
|
||||
{
|
||||
/* Allocate storage for this TXT answer appending it to the list */
|
||||
txt_curr = ares_malloc_data(ARES_DATATYPE_TXT_REPLY);
|
||||
if (!txt_curr)
|
||||
{
|
||||
status = ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
if (txt_last)
|
||||
{
|
||||
txt_last->next = txt_curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
txt_head = txt_curr;
|
||||
}
|
||||
txt_last = txt_curr;
|
||||
|
||||
/*
|
||||
* There may be multiple substrings in a single TXT record. Each
|
||||
* substring may be up to 255 characters in length, with a
|
||||
* "length byte" indicating the size of the substring payload.
|
||||
* RDATA contains both the length-bytes and payloads of all
|
||||
* substrings contained therein.
|
||||
*/
|
||||
|
||||
/* Compute total length to allow a single memory allocation */
|
||||
strptr = aptr;
|
||||
while (strptr < (aptr + rr_len))
|
||||
{
|
||||
substr_len = (unsigned char)*strptr;
|
||||
txt_curr->length += substr_len;
|
||||
strptr += substr_len + 1;
|
||||
}
|
||||
|
||||
/* Including null byte */
|
||||
txt_curr->txt = malloc (txt_curr->length + 1);
|
||||
if (txt_curr->txt == NULL)
|
||||
{
|
||||
status = ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Step through the list of substrings, concatenating them */
|
||||
str_len = 0;
|
||||
strptr = aptr;
|
||||
while (strptr < (aptr + rr_len))
|
||||
{
|
||||
substr_len = (unsigned char)*strptr;
|
||||
strptr++;
|
||||
memcpy ((char *) txt_curr->txt + str_len, strptr, substr_len);
|
||||
str_len += substr_len;
|
||||
strptr += substr_len;
|
||||
}
|
||||
/* Make sure we NULL-terminate */
|
||||
*((char *) txt_curr->txt + txt_curr->length) = '\0';
|
||||
}
|
||||
|
||||
/* Don't lose memory in the next iteration */
|
||||
free (rr_name);
|
||||
rr_name = NULL;
|
||||
|
||||
/* Move on to the next record */
|
||||
aptr += rr_len;
|
||||
}
|
||||
|
||||
if (hostname)
|
||||
free (hostname);
|
||||
if (rr_name)
|
||||
free (rr_name);
|
||||
|
||||
/* clean up on error */
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
if (txt_head)
|
||||
ares_free_data (txt_head);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* everything looks fine, return the data */
|
||||
*txt_out = txt_head;
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,351 @@
|
|||
#ifndef __ARES_PRIVATE_H
|
||||
#define __ARES_PRIVATE_H
|
||||
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2004-2010 by Daniel Stenberg
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Define WIN32 when build target is Win32 API
|
||||
*/
|
||||
|
||||
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||
#define WIN32
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#ifdef WATT32
|
||||
#include <tcp.h>
|
||||
#include <sys/ioctl.h>
|
||||
#define writev(s,v,c) writev_s(s,v,c)
|
||||
#define HAVE_WRITEV 1
|
||||
#endif
|
||||
|
||||
#ifdef NETWARE
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#define DEFAULT_TIMEOUT 5000 /* milliseconds */
|
||||
#define DEFAULT_TRIES 4
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE 0xffffffff
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && !defined(WATT32)
|
||||
|
||||
#define IS_NT() ((int)GetVersion() > 0)
|
||||
#define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP"
|
||||
#define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters"
|
||||
#define NAMESERVER "NameServer"
|
||||
#define DHCPNAMESERVER "DhcpNameServer"
|
||||
#define DATABASEPATH "DatabasePath"
|
||||
#define WIN_PATH_HOSTS "\\hosts"
|
||||
|
||||
#elif defined(WATT32)
|
||||
|
||||
#define PATH_RESOLV_CONF "/dev/ENV/etc/resolv.conf"
|
||||
|
||||
#elif defined(NETWARE)
|
||||
|
||||
#define PATH_RESOLV_CONF "sys:/etc/resolv.cfg"
|
||||
#define PATH_HOSTS "sys:/etc/hosts"
|
||||
|
||||
#elif defined(__riscos__)
|
||||
|
||||
#define PATH_HOSTS "InetDBase:Hosts"
|
||||
|
||||
#else
|
||||
|
||||
#define PATH_RESOLV_CONF "/etc/resolv.conf"
|
||||
#ifdef ETC_INET
|
||||
#define PATH_HOSTS "/etc/inet/hosts"
|
||||
#else
|
||||
#define PATH_HOSTS "/etc/hosts"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define ARES_ID_KEY_LEN 31
|
||||
|
||||
#include "ares_ipv6.h"
|
||||
#include "ares_llist.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 HAVE_WRITEV
|
||||
# include "ares_writev.h"
|
||||
# define writev(s,ptr,cnt) ares_writev(s,ptr,cnt)
|
||||
#endif
|
||||
|
||||
struct ares_addr {
|
||||
int family;
|
||||
union {
|
||||
struct in_addr addr4;
|
||||
struct ares_in6_addr addr6;
|
||||
} addr;
|
||||
};
|
||||
#define addrV4 addr.addr4
|
||||
#define addrV6 addr.addr6
|
||||
|
||||
struct query;
|
||||
|
||||
struct send_request {
|
||||
/* Remaining data to send */
|
||||
const unsigned char *data;
|
||||
size_t len;
|
||||
|
||||
/* The query for which we're sending this data */
|
||||
struct query* owner_query;
|
||||
/* The buffer we're using, if we have our own copy of the packet */
|
||||
unsigned char *data_storage;
|
||||
|
||||
/* Next request in queue */
|
||||
struct send_request *next;
|
||||
};
|
||||
|
||||
struct server_state {
|
||||
struct ares_addr addr;
|
||||
ares_socket_t udp_socket;
|
||||
ares_socket_t tcp_socket;
|
||||
|
||||
/* Mini-buffer for reading the length word */
|
||||
unsigned char tcp_lenbuf[2];
|
||||
int tcp_lenbuf_pos;
|
||||
int tcp_length;
|
||||
|
||||
/* Buffer for reading actual TCP data */
|
||||
unsigned char *tcp_buffer;
|
||||
int tcp_buffer_pos;
|
||||
|
||||
/* TCP output queue */
|
||||
struct send_request *qhead;
|
||||
struct send_request *qtail;
|
||||
|
||||
/* Which incarnation of this connection is this? We don't want to
|
||||
* retransmit requests into the very same socket, but if the server
|
||||
* closes on us and we re-open the connection, then we do want to
|
||||
* re-send. */
|
||||
int tcp_connection_generation;
|
||||
|
||||
/* Circular, doubly-linked list of outstanding queries to this server */
|
||||
struct list_node queries_to_server;
|
||||
|
||||
/* Link back to owning channel */
|
||||
ares_channel channel;
|
||||
|
||||
/* Is this server broken? We mark connections as broken when a
|
||||
* request that is queued for sending times out.
|
||||
*/
|
||||
int is_broken;
|
||||
};
|
||||
|
||||
/* State to represent a DNS query */
|
||||
struct query {
|
||||
/* Query ID from qbuf, for faster lookup, and current timeout */
|
||||
unsigned short qid;
|
||||
struct timeval timeout;
|
||||
|
||||
/*
|
||||
* Links for the doubly-linked lists in which we insert a query.
|
||||
* These circular, doubly-linked lists that are hash-bucketed based
|
||||
* the attributes we care about, help making most important
|
||||
* operations O(1).
|
||||
*/
|
||||
struct list_node queries_by_qid; /* hopefully in same cache line as qid */
|
||||
struct list_node queries_by_timeout;
|
||||
struct list_node queries_to_server;
|
||||
struct list_node all_queries;
|
||||
|
||||
/* Query buf with length at beginning, for TCP transmission */
|
||||
unsigned char *tcpbuf;
|
||||
int tcplen;
|
||||
|
||||
/* Arguments passed to ares_send() (qbuf points into tcpbuf) */
|
||||
const unsigned char *qbuf;
|
||||
int qlen;
|
||||
ares_callback callback;
|
||||
void *arg;
|
||||
|
||||
/* Query status */
|
||||
int try; /* Number of times we tried this query already. */
|
||||
int server; /* Server this query has last been sent to. */
|
||||
struct query_server_info *server_info; /* per-server state */
|
||||
int using_tcp;
|
||||
int error_status;
|
||||
int timeouts; /* number of timeouts we saw for this request */
|
||||
};
|
||||
|
||||
/* Per-server state for a query */
|
||||
struct query_server_info {
|
||||
int skip_server; /* should we skip server, due to errors, etc? */
|
||||
int tcp_connection_generation; /* into which TCP connection did we send? */
|
||||
};
|
||||
|
||||
/* An IP address pattern; matches an IP address X if X & mask == addr */
|
||||
#define PATTERN_MASK 0x1
|
||||
#define PATTERN_CIDR 0x2
|
||||
|
||||
struct apattern {
|
||||
union
|
||||
{
|
||||
struct in_addr addr4;
|
||||
struct ares_in6_addr addr6;
|
||||
} addr;
|
||||
union
|
||||
{
|
||||
struct in_addr addr4;
|
||||
struct ares_in6_addr addr6;
|
||||
unsigned short bits;
|
||||
} mask;
|
||||
int family;
|
||||
unsigned short type;
|
||||
};
|
||||
|
||||
typedef struct rc4_key
|
||||
{
|
||||
unsigned char state[256];
|
||||
unsigned char x;
|
||||
unsigned char y;
|
||||
} rc4_key;
|
||||
|
||||
struct ares_channeldata {
|
||||
/* Configuration data */
|
||||
int flags;
|
||||
int timeout; /* in milliseconds */
|
||||
int tries;
|
||||
int ndots;
|
||||
int rotate; /* if true, all servers specified are used */
|
||||
int udp_port;
|
||||
int tcp_port;
|
||||
int socket_send_buffer_size;
|
||||
int socket_receive_buffer_size;
|
||||
char **domains;
|
||||
int ndomains;
|
||||
struct apattern *sortlist;
|
||||
int nsort;
|
||||
char *lookups;
|
||||
|
||||
/* For binding to local devices and/or IP addresses. Leave
|
||||
* them null/zero for no binding.
|
||||
*/
|
||||
char local_dev_name[32];
|
||||
unsigned int local_ip4;
|
||||
unsigned char local_ip6[16];
|
||||
|
||||
int optmask; /* the option bitfield passed in at init time */
|
||||
|
||||
/* Server addresses and communications state */
|
||||
struct server_state *servers;
|
||||
int nservers;
|
||||
|
||||
/* ID to use for next query */
|
||||
unsigned short next_id;
|
||||
/* key to use when generating new ids */
|
||||
rc4_key id_key;
|
||||
|
||||
/* Generation number to use for the next TCP socket open/close */
|
||||
int tcp_connection_generation;
|
||||
|
||||
/* The time at which we last called process_timeouts(). Uses integer seconds
|
||||
just to draw the line somewhere. */
|
||||
time_t last_timeout_processed;
|
||||
|
||||
/* Last server we sent a query to. */
|
||||
int last_server;
|
||||
|
||||
/* Circular, doubly-linked list of queries, bucketed various ways.... */
|
||||
/* All active queries in a single list: */
|
||||
struct list_node all_queries;
|
||||
/* Queries bucketed by qid, for quickly dispatching DNS responses: */
|
||||
#define ARES_QID_TABLE_SIZE 2048
|
||||
struct list_node queries_by_qid[ARES_QID_TABLE_SIZE];
|
||||
/* Queries bucketed by timeout, for quickly handling timeouts: */
|
||||
#define ARES_TIMEOUT_TABLE_SIZE 1024
|
||||
struct list_node queries_by_timeout[ARES_TIMEOUT_TABLE_SIZE];
|
||||
|
||||
ares_sock_state_cb sock_state_cb;
|
||||
void *sock_state_cb_data;
|
||||
|
||||
ares_sock_create_callback sock_create_cb;
|
||||
void *sock_create_cb_data;
|
||||
};
|
||||
|
||||
/* return true if now is exactly check time or later */
|
||||
int ares__timedout(struct timeval *now,
|
||||
struct timeval *check);
|
||||
/* add the specific number of milliseconds to the time in the first argument */
|
||||
int ares__timeadd(struct timeval *now,
|
||||
int millisecs);
|
||||
/* return time offset between now and (future) check, in milliseconds */
|
||||
long ares__timeoffset(struct timeval *now,
|
||||
struct timeval *check);
|
||||
/* returns ARES_SUCCESS if library has been initialized */
|
||||
int ares_library_initialized(void);
|
||||
void ares__rc4(rc4_key* key,unsigned char *buffer_ptr, int buffer_len);
|
||||
void ares__send_query(ares_channel channel, struct query *query,
|
||||
struct timeval *now);
|
||||
void ares__close_sockets(ares_channel channel, struct server_state *server);
|
||||
int ares__get_hostent(FILE *fp, int family, struct hostent **host);
|
||||
int ares__read_line(FILE *fp, char **buf, size_t *bufsize);
|
||||
void ares__free_query(struct query *query);
|
||||
unsigned short ares__generate_new_id(rc4_key* key);
|
||||
struct timeval ares__tvnow(void);
|
||||
int ares__expand_name_for_response(const unsigned char *encoded,
|
||||
const unsigned char *abuf, int alen,
|
||||
char **s, long *enclen);
|
||||
void ares__init_servers_state(ares_channel channel);
|
||||
void ares__destroy_servers_state(ares_channel channel);
|
||||
#if 0 /* Not used */
|
||||
long ares__tvdiff(struct timeval t1, struct timeval t2);
|
||||
#endif
|
||||
|
||||
#define ARES_SWAP_BYTE(a,b) \
|
||||
{ unsigned char swapByte = *(a); *(a) = *(b); *(b) = swapByte; }
|
||||
|
||||
#define SOCK_STATE_CALLBACK(c, s, r, w) \
|
||||
do { \
|
||||
if ((c)->sock_state_cb) \
|
||||
(c)->sock_state_cb((c)->sock_state_cb_data, (s), (r), (w)); \
|
||||
} while (0)
|
||||
|
||||
#ifdef CURLDEBUG
|
||||
/* This is low-level hard-hacking memory leak tracking and similar. Using the
|
||||
libcurl lowlevel code from within library is ugly and only works when
|
||||
c-ares is built and linked with a similarly curldebug-enabled libcurl,
|
||||
but we do this anyway for convenience. */
|
||||
#include "../lib/memdebug.h"
|
||||
#endif
|
||||
|
||||
#endif /* __ARES_PRIVATE_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,183 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#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 <stdlib.h>
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
struct qquery {
|
||||
ares_callback callback;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf, int alen);
|
||||
|
||||
void ares__rc4(rc4_key* key, unsigned char *buffer_ptr, int buffer_len)
|
||||
{
|
||||
unsigned char x;
|
||||
unsigned char y;
|
||||
unsigned char* state;
|
||||
unsigned char xorIndex;
|
||||
short counter;
|
||||
|
||||
x = key->x;
|
||||
y = key->y;
|
||||
|
||||
state = &key->state[0];
|
||||
for(counter = 0; counter < buffer_len; counter ++)
|
||||
{
|
||||
x = (unsigned char)((x + 1) % 256);
|
||||
y = (unsigned char)((state[x] + y) % 256);
|
||||
ARES_SWAP_BYTE(&state[x], &state[y]);
|
||||
|
||||
xorIndex = (unsigned char)((state[x] + state[y]) % 256);
|
||||
|
||||
buffer_ptr[counter] = (unsigned char)(buffer_ptr[counter]^state[xorIndex]);
|
||||
}
|
||||
key->x = x;
|
||||
key->y = y;
|
||||
}
|
||||
|
||||
static struct query* find_query_by_id(ares_channel channel, unsigned short id)
|
||||
{
|
||||
unsigned short qid;
|
||||
struct list_node* list_head;
|
||||
struct list_node* list_node;
|
||||
DNS_HEADER_SET_QID(((unsigned char*)&qid), id);
|
||||
|
||||
/* Find the query corresponding to this packet. */
|
||||
list_head = &(channel->queries_by_qid[qid % ARES_QID_TABLE_SIZE]);
|
||||
for (list_node = list_head->next; list_node != list_head;
|
||||
list_node = list_node->next)
|
||||
{
|
||||
struct query *q = list_node->data;
|
||||
if (q->qid == qid)
|
||||
return q;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* a unique query id is generated using an rc4 key. Since the id may already
|
||||
be used by a running query (as infrequent as it may be), a lookup is
|
||||
performed per id generation. In practice this search should happen only
|
||||
once per newly generated id
|
||||
*/
|
||||
static unsigned short generate_unique_id(ares_channel channel)
|
||||
{
|
||||
unsigned short id;
|
||||
|
||||
do {
|
||||
id = ares__generate_new_id(&channel->id_key);
|
||||
} while (find_query_by_id(channel, id));
|
||||
|
||||
return (unsigned short)id;
|
||||
}
|
||||
|
||||
void ares_query(ares_channel channel, const char *name, int dnsclass,
|
||||
int type, ares_callback callback, void *arg)
|
||||
{
|
||||
struct qquery *qquery;
|
||||
unsigned char *qbuf;
|
||||
int qlen, rd, status;
|
||||
|
||||
/* Compose the query. */
|
||||
rd = !(channel->flags & ARES_FLAG_NORECURSE);
|
||||
status = ares_mkquery(name, dnsclass, type, channel->next_id, rd, &qbuf,
|
||||
&qlen);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
if (qbuf != NULL) free(qbuf);
|
||||
callback(arg, status, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
channel->next_id = generate_unique_id(channel);
|
||||
|
||||
/* Allocate and fill in the query structure. */
|
||||
qquery = malloc(sizeof(struct qquery));
|
||||
if (!qquery)
|
||||
{
|
||||
ares_free_string(qbuf);
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
qquery->callback = callback;
|
||||
qquery->arg = arg;
|
||||
|
||||
/* Send it off. qcallback will be called when we get an answer. */
|
||||
ares_send(channel, qbuf, qlen, qcallback, qquery);
|
||||
ares_free_string(qbuf);
|
||||
}
|
||||
|
||||
static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf, int alen)
|
||||
{
|
||||
struct qquery *qquery = (struct qquery *) arg;
|
||||
unsigned int ancount;
|
||||
int rcode;
|
||||
|
||||
if (status != ARES_SUCCESS)
|
||||
qquery->callback(qquery->arg, status, timeouts, abuf, alen);
|
||||
else
|
||||
{
|
||||
/* Pull the response code and answer count from the packet. */
|
||||
rcode = DNS_HEADER_RCODE(abuf);
|
||||
ancount = DNS_HEADER_ANCOUNT(abuf);
|
||||
|
||||
/* Convert errors. */
|
||||
switch (rcode)
|
||||
{
|
||||
case NOERROR:
|
||||
status = (ancount > 0) ? ARES_SUCCESS : ARES_ENODATA;
|
||||
break;
|
||||
case FORMERR:
|
||||
status = ARES_EFORMERR;
|
||||
break;
|
||||
case SERVFAIL:
|
||||
status = ARES_ESERVFAIL;
|
||||
break;
|
||||
case NXDOMAIN:
|
||||
status = ARES_ENOTFOUND;
|
||||
break;
|
||||
case NOTIMP:
|
||||
status = ARES_ENOTIMP;
|
||||
break;
|
||||
case REFUSED:
|
||||
status = ARES_EREFUSED;
|
||||
break;
|
||||
}
|
||||
qquery->callback(qquery->arg, status, timeouts, abuf, alen);
|
||||
}
|
||||
free(qquery);
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
#ifndef __CARES_RULES_H
|
||||
#define __CARES_RULES_H
|
||||
|
||||
|
||||
/* Copyright (C) 2009 by Daniel Stenberg et al
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* ================================================================ */
|
||||
/* COMPILE TIME SANITY CHECKS */
|
||||
/* ================================================================ */
|
||||
|
||||
/*
|
||||
* NOTE 1:
|
||||
* -------
|
||||
*
|
||||
* All checks done in this file are intentionally placed in a public
|
||||
* header file which is pulled by ares.h when an application is
|
||||
* being built using an already built c-ares library. Additionally
|
||||
* this file is also included and used when building the library.
|
||||
*
|
||||
* If compilation fails on this file it is certainly sure that the
|
||||
* problem is elsewhere. It could be a problem in the ares_build.h
|
||||
* header file, or simply that you are using different compilation
|
||||
* settings than those used to build the library.
|
||||
*
|
||||
* Nothing in this file is intended to be modified or adjusted by the
|
||||
* c-ares library user nor by the c-ares library builder.
|
||||
*
|
||||
* Do not deactivate any check, these are done to make sure that the
|
||||
* library is properly built and used.
|
||||
*
|
||||
* You can find further help on the c-ares development mailing list:
|
||||
* http://cool.haxx.se/mailman/listinfo/c-ares/
|
||||
*
|
||||
* NOTE 2
|
||||
* ------
|
||||
*
|
||||
* Some of the following compile time checks are based on the fact
|
||||
* that the dimension of a constant array can not be a negative one.
|
||||
* In this way if the compile time verification fails, the compilation
|
||||
* will fail issuing an error. The error description wording is compiler
|
||||
* dependent but it will be quite similar to one of the following:
|
||||
*
|
||||
* "negative subscript or subscript is too large"
|
||||
* "array must have at least one element"
|
||||
* "-1 is an illegal array size"
|
||||
* "size of array is negative"
|
||||
*
|
||||
* If you are building an application which tries to use an already
|
||||
* built c-ares library and you are getting this kind of errors on
|
||||
* this file, it is a clear indication that there is a mismatch between
|
||||
* how the library was built and how you are trying to use it for your
|
||||
* application. Your already compiled or binary library provider is the
|
||||
* only one who can give you the details you need to properly use it.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Verify that some macros are actually defined.
|
||||
*/
|
||||
|
||||
#ifndef CARES_SIZEOF_LONG
|
||||
# error "CARES_SIZEOF_LONG definition is missing!"
|
||||
Error Compilation_aborted_CARES_SIZEOF_LONG_is_missing
|
||||
#endif
|
||||
|
||||
#ifndef CARES_TYPEOF_ARES_SOCKLEN_T
|
||||
# error "CARES_TYPEOF_ARES_SOCKLEN_T definition is missing!"
|
||||
Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_is_missing
|
||||
#endif
|
||||
|
||||
#ifndef CARES_SIZEOF_ARES_SOCKLEN_T
|
||||
# error "CARES_SIZEOF_ARES_SOCKLEN_T definition is missing!"
|
||||
Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_is_missing
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros private to this header file.
|
||||
*/
|
||||
|
||||
#define CareschkszEQ(t, s) sizeof(t) == s ? 1 : -1
|
||||
|
||||
#define CareschkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1
|
||||
|
||||
/*
|
||||
* Verify that the size previously defined and expected for long
|
||||
* is the same as the one reported by sizeof() at compile time.
|
||||
*/
|
||||
|
||||
typedef char
|
||||
__cares_rule_01__
|
||||
[CareschkszEQ(long, CARES_SIZEOF_LONG)];
|
||||
|
||||
/*
|
||||
* Verify that the size previously defined and expected for
|
||||
* ares_socklen_t is actually the the same as the one reported
|
||||
* by sizeof() at compile time.
|
||||
*/
|
||||
|
||||
typedef char
|
||||
__cares_rule_02__
|
||||
[CareschkszEQ(ares_socklen_t, CARES_SIZEOF_ARES_SOCKLEN_T)];
|
||||
|
||||
/*
|
||||
* Verify at compile time that the size of ares_socklen_t as reported
|
||||
* by sizeof() is greater or equal than the one reported for int for
|
||||
* the current compilation.
|
||||
*/
|
||||
|
||||
typedef char
|
||||
__cares_rule_03__
|
||||
[CareschkszGE(ares_socklen_t, int)];
|
||||
|
||||
/* ================================================================ */
|
||||
/* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */
|
||||
/* ================================================================ */
|
||||
|
||||
/*
|
||||
* Get rid of macros private to this header file.
|
||||
*/
|
||||
|
||||
#undef CareschkszEQ
|
||||
#undef CareschkszGE
|
||||
|
||||
/*
|
||||
* Get rid of macros not intended to exist beyond this point.
|
||||
*/
|
||||
|
||||
#undef CARES_PULL_WS2TCPIP_H
|
||||
#undef CARES_PULL_SYS_TYPES_H
|
||||
#undef CARES_PULL_SYS_SOCKET_H
|
||||
|
||||
#undef CARES_TYPEOF_ARES_SOCKLEN_T
|
||||
|
||||
#endif /* __CARES_RULES_H */
|
|
@ -0,0 +1,322 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
struct search_query {
|
||||
/* Arguments passed to ares_search */
|
||||
ares_channel channel;
|
||||
char *name; /* copied into an allocated buffer */
|
||||
int dnsclass;
|
||||
int type;
|
||||
ares_callback callback;
|
||||
void *arg;
|
||||
|
||||
int status_as_is; /* error status from trying as-is */
|
||||
int next_domain; /* next search domain to try */
|
||||
int trying_as_is; /* current query is for name as-is */
|
||||
int timeouts; /* number of timeouts we saw for this request */
|
||||
int ever_got_nodata; /* did we ever get ARES_ENODATA along the way? */
|
||||
};
|
||||
|
||||
static void search_callback(void *arg, int status, int timeouts,
|
||||
unsigned char *abuf, int alen);
|
||||
static void end_squery(struct search_query *squery, int status,
|
||||
unsigned char *abuf, int alen);
|
||||
static int cat_domain(const char *name, const char *domain, char **s);
|
||||
static int single_domain(ares_channel channel, const char *name, char **s);
|
||||
|
||||
void ares_search(ares_channel channel, const char *name, int dnsclass,
|
||||
int type, ares_callback callback, void *arg)
|
||||
{
|
||||
struct search_query *squery;
|
||||
char *s;
|
||||
const char *p;
|
||||
int status, ndots;
|
||||
|
||||
/* If name only yields one domain to search, then we don't have
|
||||
* to keep extra state, so just do an ares_query().
|
||||
*/
|
||||
status = single_domain(channel, name, &s);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
callback(arg, status, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
if (s)
|
||||
{
|
||||
ares_query(channel, s, dnsclass, type, callback, arg);
|
||||
free(s);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Allocate a search_query structure to hold the state necessary for
|
||||
* doing multiple lookups.
|
||||
*/
|
||||
squery = malloc(sizeof(struct search_query));
|
||||
if (!squery)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
squery->channel = channel;
|
||||
squery->name = strdup(name);
|
||||
if (!squery->name)
|
||||
{
|
||||
free(squery);
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
squery->dnsclass = dnsclass;
|
||||
squery->type = type;
|
||||
squery->status_as_is = -1;
|
||||
squery->callback = callback;
|
||||
squery->arg = arg;
|
||||
squery->timeouts = 0;
|
||||
squery->ever_got_nodata = 0;
|
||||
|
||||
/* Count the number of dots in name. */
|
||||
ndots = 0;
|
||||
for (p = name; *p; p++)
|
||||
{
|
||||
if (*p == '.')
|
||||
ndots++;
|
||||
}
|
||||
|
||||
/* If ndots is at least the channel ndots threshold (usually 1),
|
||||
* then we try the name as-is first. Otherwise, we try the name
|
||||
* as-is last.
|
||||
*/
|
||||
if (ndots >= channel->ndots)
|
||||
{
|
||||
/* Try the name as-is first. */
|
||||
squery->next_domain = 0;
|
||||
squery->trying_as_is = 1;
|
||||
ares_query(channel, name, dnsclass, type, search_callback, squery);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Try the name as-is last; start with the first search domain. */
|
||||
squery->next_domain = 1;
|
||||
squery->trying_as_is = 0;
|
||||
status = cat_domain(name, channel->domains[0], &s);
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
ares_query(channel, s, dnsclass, type, search_callback, squery);
|
||||
free(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* failed, free the malloc()ed memory */
|
||||
free(squery->name);
|
||||
free(squery);
|
||||
callback(arg, status, 0, NULL, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void search_callback(void *arg, int status, int timeouts,
|
||||
unsigned char *abuf, int alen)
|
||||
{
|
||||
struct search_query *squery = (struct search_query *) arg;
|
||||
ares_channel channel = squery->channel;
|
||||
char *s;
|
||||
|
||||
squery->timeouts += timeouts;
|
||||
|
||||
/* Stop searching unless we got a non-fatal error. */
|
||||
if (status != ARES_ENODATA && status != ARES_ESERVFAIL
|
||||
&& status != ARES_ENOTFOUND)
|
||||
end_squery(squery, status, abuf, alen);
|
||||
else
|
||||
{
|
||||
/* Save the status if we were trying as-is. */
|
||||
if (squery->trying_as_is)
|
||||
squery->status_as_is = status;
|
||||
|
||||
/*
|
||||
* If we ever get ARES_ENODATA along the way, record that; if the search
|
||||
* should run to the very end and we got at least one ARES_ENODATA,
|
||||
* then callers like ares_gethostbyname() may want to try a T_A search
|
||||
* even if the last domain we queried for T_AAAA resource records
|
||||
* returned ARES_ENOTFOUND.
|
||||
*/
|
||||
if (status == ARES_ENODATA)
|
||||
squery->ever_got_nodata = 1;
|
||||
|
||||
if (squery->next_domain < channel->ndomains)
|
||||
{
|
||||
/* Try the next domain. */
|
||||
status = cat_domain(squery->name,
|
||||
channel->domains[squery->next_domain], &s);
|
||||
if (status != ARES_SUCCESS)
|
||||
end_squery(squery, status, NULL, 0);
|
||||
else
|
||||
{
|
||||
squery->trying_as_is = 0;
|
||||
squery->next_domain++;
|
||||
ares_query(channel, s, squery->dnsclass, squery->type,
|
||||
search_callback, squery);
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
else if (squery->status_as_is == -1)
|
||||
{
|
||||
/* Try the name as-is at the end. */
|
||||
squery->trying_as_is = 1;
|
||||
ares_query(channel, squery->name, squery->dnsclass, squery->type,
|
||||
search_callback, squery);
|
||||
}
|
||||
else {
|
||||
if (squery->status_as_is == ARES_ENOTFOUND && squery->ever_got_nodata) {
|
||||
end_squery(squery, ARES_ENODATA, NULL, 0);
|
||||
}
|
||||
else
|
||||
end_squery(squery, squery->status_as_is, NULL, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void end_squery(struct search_query *squery, int status,
|
||||
unsigned char *abuf, int alen)
|
||||
{
|
||||
squery->callback(squery->arg, status, squery->timeouts, abuf, alen);
|
||||
free(squery->name);
|
||||
free(squery);
|
||||
}
|
||||
|
||||
/* Concatenate two domains. */
|
||||
static int cat_domain(const char *name, const char *domain, char **s)
|
||||
{
|
||||
size_t nlen = strlen(name);
|
||||
size_t dlen = strlen(domain);
|
||||
|
||||
*s = malloc(nlen + 1 + dlen + 1);
|
||||
if (!*s)
|
||||
return ARES_ENOMEM;
|
||||
memcpy(*s, name, nlen);
|
||||
(*s)[nlen] = '.';
|
||||
memcpy(*s + nlen + 1, domain, dlen);
|
||||
(*s)[nlen + 1 + dlen] = 0;
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
/* Determine if this name only yields one query. If it does, set *s to
|
||||
* the string we should query, in an allocated buffer. If not, set *s
|
||||
* to NULL.
|
||||
*/
|
||||
static int single_domain(ares_channel channel, const char *name, char **s)
|
||||
{
|
||||
size_t len = strlen(name);
|
||||
const char *hostaliases;
|
||||
FILE *fp;
|
||||
char *line = NULL;
|
||||
int status;
|
||||
size_t linesize;
|
||||
const char *p, *q;
|
||||
int error;
|
||||
|
||||
/* If the name contains a trailing dot, then the single query is the name
|
||||
* sans the trailing dot.
|
||||
*/
|
||||
if (name[len - 1] == '.')
|
||||
{
|
||||
*s = strdup(name);
|
||||
return (*s) ? ARES_SUCCESS : ARES_ENOMEM;
|
||||
}
|
||||
|
||||
if (!(channel->flags & ARES_FLAG_NOALIASES) && !strchr(name, '.'))
|
||||
{
|
||||
/* The name might be a host alias. */
|
||||
hostaliases = getenv("HOSTALIASES");
|
||||
if (hostaliases)
|
||||
{
|
||||
fp = fopen(hostaliases, "r");
|
||||
if (fp)
|
||||
{
|
||||
while ((status = ares__read_line(fp, &line, &linesize))
|
||||
== ARES_SUCCESS)
|
||||
{
|
||||
if (strncasecmp(line, name, len) != 0 ||
|
||||
!ISSPACE(line[len]))
|
||||
continue;
|
||||
p = line + len;
|
||||
while (ISSPACE(*p))
|
||||
p++;
|
||||
if (*p)
|
||||
{
|
||||
q = p + 1;
|
||||
while (*q && !ISSPACE(*q))
|
||||
q++;
|
||||
*s = malloc(q - p + 1);
|
||||
if (*s)
|
||||
{
|
||||
memcpy(*s, p, q - p);
|
||||
(*s)[q - p] = 0;
|
||||
}
|
||||
free(line);
|
||||
fclose(fp);
|
||||
return (*s) ? ARES_SUCCESS : ARES_ENOMEM;
|
||||
}
|
||||
}
|
||||
free(line);
|
||||
fclose(fp);
|
||||
if (status != ARES_SUCCESS && status != ARES_EOF)
|
||||
return status;
|
||||
}
|
||||
else
|
||||
{
|
||||
error = errno;
|
||||
switch(error)
|
||||
{
|
||||
case ENOENT:
|
||||
case ESRCH:
|
||||
break;
|
||||
default:
|
||||
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||
error, strerror(error)));
|
||||
DEBUGF(fprintf(stderr, "Error opening file: %s\n",
|
||||
hostaliases));
|
||||
*s = NULL;
|
||||
return ARES_EFILE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (channel->flags & ARES_FLAG_NOSEARCH || channel->ndomains == 0)
|
||||
{
|
||||
/* No domain search to do; just try the name as-is. */
|
||||
*s = strdup(name);
|
||||
return (*s) ? ARES_SUCCESS : ARES_ENOMEM;
|
||||
}
|
||||
|
||||
*s = NULL;
|
||||
return ARES_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
|
||||
ares_callback callback, void *arg)
|
||||
{
|
||||
struct query *query;
|
||||
int i;
|
||||
struct timeval now;
|
||||
|
||||
/* Verify that the query is at least long enough to hold the header. */
|
||||
if (qlen < HFIXEDSZ || qlen >= (1 << 16))
|
||||
{
|
||||
callback(arg, ARES_EBADQUERY, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Allocate space for query and allocated fields. */
|
||||
query = malloc(sizeof(struct query));
|
||||
if (!query)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
query->tcpbuf = malloc(qlen + 2);
|
||||
if (!query->tcpbuf)
|
||||
{
|
||||
free(query);
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
query->server_info = malloc(channel->nservers *
|
||||
sizeof(query->server_info[0]));
|
||||
if (!query->server_info)
|
||||
{
|
||||
free(query->tcpbuf);
|
||||
free(query);
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Compute the query ID. Start with no timeout. */
|
||||
query->qid = (unsigned short)DNS_HEADER_QID(qbuf);
|
||||
query->timeout.tv_sec = 0;
|
||||
query->timeout.tv_usec = 0;
|
||||
|
||||
/* Form the TCP query buffer by prepending qlen (as two
|
||||
* network-order bytes) to qbuf.
|
||||
*/
|
||||
query->tcpbuf[0] = (unsigned char)((qlen >> 8) & 0xff);
|
||||
query->tcpbuf[1] = (unsigned char)(qlen & 0xff);
|
||||
memcpy(query->tcpbuf + 2, qbuf, qlen);
|
||||
query->tcplen = qlen + 2;
|
||||
|
||||
/* Fill in query arguments. */
|
||||
query->qbuf = query->tcpbuf + 2;
|
||||
query->qlen = qlen;
|
||||
query->callback = callback;
|
||||
query->arg = arg;
|
||||
|
||||
/* Initialize query status. */
|
||||
query->try = 0;
|
||||
|
||||
/* Choose the server to send the query to. If rotation is enabled, keep track
|
||||
* of the next server we want to use. */
|
||||
query->server = channel->last_server;
|
||||
if (channel->rotate == 1)
|
||||
channel->last_server = (channel->last_server + 1) % channel->nservers;
|
||||
|
||||
for (i = 0; i < channel->nservers; i++)
|
||||
{
|
||||
query->server_info[i].skip_server = 0;
|
||||
query->server_info[i].tcp_connection_generation = 0;
|
||||
}
|
||||
query->using_tcp = (channel->flags & ARES_FLAG_USEVC) || qlen > PACKETSZ;
|
||||
query->error_status = ARES_ECONNREFUSED;
|
||||
query->timeouts = 0;
|
||||
|
||||
/* Initialize our list nodes. */
|
||||
ares__init_list_node(&(query->queries_by_qid), query);
|
||||
ares__init_list_node(&(query->queries_by_timeout), query);
|
||||
ares__init_list_node(&(query->queries_to_server), query);
|
||||
ares__init_list_node(&(query->all_queries), query);
|
||||
|
||||
/* Chain the query into the list of all queries. */
|
||||
ares__insert_in_list(&(query->all_queries), &(channel->all_queries));
|
||||
/* Keep track of queries bucketed by qid, so we can process DNS
|
||||
* responses quickly.
|
||||
*/
|
||||
ares__insert_in_list(
|
||||
&(query->queries_by_qid),
|
||||
&(channel->queries_by_qid[query->qid % ARES_QID_TABLE_SIZE]));
|
||||
|
||||
/* Perform the first query action. */
|
||||
now = ares__tvnow();
|
||||
ares__send_query(channel, query, &now);
|
||||
}
|
|
@ -0,0 +1,191 @@
|
|||
#ifndef HEADER_CARES_SETUP_H
|
||||
#define HEADER_CARES_SETUP_H
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 2004 - 2009 by Daniel Stenberg et al
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Define WIN32 when build target is Win32 API
|
||||
*/
|
||||
|
||||
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||
#define WIN32
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Include configuration script results or hand-crafted
|
||||
* configuration file for platforms which lack config tool.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "ares_config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
/* ================================================================ */
|
||||
/* Definition of preprocessor macros/symbols which modify compiler */
|
||||
/* behaviour or generated code characteristics must be done here, */
|
||||
/* as appropriate, before any system header file is included. It is */
|
||||
/* also possible to have them defined in the config file included */
|
||||
/* before this point. As a result of all this we frown inclusion of */
|
||||
/* system header files in our config files, avoid this at any cost. */
|
||||
/* ================================================================ */
|
||||
|
||||
/*
|
||||
* AIX 4.3 and newer needs _THREAD_SAFE defined to build
|
||||
* proper reentrant code. Others may also need it.
|
||||
*/
|
||||
|
||||
#ifdef NEED_THREAD_SAFE
|
||||
# ifndef _THREAD_SAFE
|
||||
# define _THREAD_SAFE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Tru64 needs _REENTRANT set for a few function prototypes and
|
||||
* things to appear in the system header files. Unixware needs it
|
||||
* to build proper reentrant code. Others may also need it.
|
||||
*/
|
||||
|
||||
#ifdef NEED_REENTRANT
|
||||
# ifndef _REENTRANT
|
||||
# define _REENTRANT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* ================================================================ */
|
||||
/* If you need to include a system header file for your platform, */
|
||||
/* please, do it beyond the point further indicated in this file. */
|
||||
/* ================================================================ */
|
||||
|
||||
#if 0 /* libuv disabled */
|
||||
/*
|
||||
* c-ares external interface definitions are also used internally,
|
||||
* and might also include required system header files to define them.
|
||||
*/
|
||||
|
||||
#include <ares_build.h>
|
||||
|
||||
/*
|
||||
* Compile time sanity checks must also be done when building the library.
|
||||
*/
|
||||
|
||||
#include <ares_rules.h>
|
||||
#endif
|
||||
|
||||
/* ================================================================= */
|
||||
/* No system header file shall be included in this file before this */
|
||||
/* point. The only allowed ones are those included from ares_build.h */
|
||||
/* ================================================================= */
|
||||
|
||||
/*
|
||||
* Include header files for windows builds before redefining anything.
|
||||
* Use this preproessor block only to include or exclude windows.h,
|
||||
* winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
|
||||
* to any other further and independent block. Under Cygwin things work
|
||||
* just as under linux (e.g. <sys/socket.h>) and the winsock headers should
|
||||
* never be included when __CYGWIN__ is defined. configure script takes
|
||||
* care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
|
||||
* neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# ifdef HAVE_WINSOCK2_H
|
||||
# include <winsock2.h>
|
||||
# ifdef HAVE_WS2TCPIP_H
|
||||
# include <ws2tcpip.h>
|
||||
# endif
|
||||
# else
|
||||
# ifdef HAVE_WINSOCK_H
|
||||
# include <winsock.h>
|
||||
# endif
|
||||
# endif
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
|
||||
* define USE_WINSOCK to 1 if we have and use WINSOCK API, else
|
||||
* undefine USE_WINSOCK.
|
||||
*/
|
||||
|
||||
#undef USE_WINSOCK
|
||||
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
# define USE_WINSOCK 2
|
||||
#else
|
||||
# ifdef HAVE_WINSOCK_H
|
||||
# define USE_WINSOCK 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Work-arounds for systems without configure support
|
||||
*/
|
||||
|
||||
#ifndef HAVE_CONFIG_H
|
||||
|
||||
#if !defined(HAVE_SYS_TIME_H) && !defined(_MSC_VER) && !defined(__WATCOMC__)
|
||||
#define HAVE_SYS_TIME_H
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
|
||||
#define HAVE_UNISTD_H 1
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SYS_UIO_H) && !defined(WIN32) && !defined(MSDOS)
|
||||
#define HAVE_SYS_UIO_H
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#ifdef __POCC__
|
||||
# include <sys/types.h>
|
||||
# include <unistd.h>
|
||||
# define ESRCH 3
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Recent autoconf versions define these symbols in ares_config.h. We don't
|
||||
* want them (since they collide with the libcurl ones when we build
|
||||
* --enable-debug) so we undef them again here.
|
||||
*/
|
||||
|
||||
#undef PACKAGE_STRING
|
||||
#undef PACKAGE_TARNAME
|
||||
#undef PACKAGE_VERSION
|
||||
#undef PACKAGE_BUGREPORT
|
||||
#undef PACKAGE_NAME
|
||||
#undef VERSION
|
||||
#undef PACKAGE
|
||||
|
||||
/* IPv6 compatibility */
|
||||
#if !defined(HAVE_AF_INET6)
|
||||
#if defined(HAVE_PF_INET6)
|
||||
#define AF_INET6 PF_INET6
|
||||
#else
|
||||
#define AF_INET6 AF_MAX+1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Include macros and defines that should only be processed once.
|
||||
*/
|
||||
|
||||
#ifndef __SETUP_ONCE_H
|
||||
#include "setup_once.h"
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CARES_SETUP_H */
|
|
@ -0,0 +1,66 @@
|
|||
|
||||
|
||||
/* 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"
|
||||
#include "ares_strcasecmp.h"
|
||||
|
||||
#ifndef HAVE_STRCASECMP
|
||||
int ares_strcasecmp(const char *a, const char *b)
|
||||
{
|
||||
#if defined(HAVE_STRCMPI)
|
||||
return strcmpi(a, b);
|
||||
#elif defined(HAVE_STRICMP)
|
||||
return stricmp(a, b);
|
||||
#else
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < (size_t)-1; i++) {
|
||||
int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i];
|
||||
int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i];
|
||||
if (c1 != c2)
|
||||
return c1-c2;
|
||||
if (!c1)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNCASECMP
|
||||
int ares_strncasecmp(const char *a, const char *b, size_t n)
|
||||
{
|
||||
#if defined(HAVE_STRNCMPI)
|
||||
return strncmpi(a, b, n);
|
||||
#elif defined(HAVE_STRNICMP)
|
||||
return strnicmp(a, b, n);
|
||||
#else
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i];
|
||||
int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i];
|
||||
if (c1 != c2)
|
||||
return c1-c2;
|
||||
if (!c1)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef HEADER_CARES_STRCASECMP_H
|
||||
#define HEADER_CARES_STRCASECMP_H
|
||||
|
||||
|
||||
/* 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"
|
||||
|
||||
#ifndef HAVE_STRCASECMP
|
||||
extern int ares_strcasecmp(const char *a, const char *b);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNCASECMP
|
||||
extern int ares_strncasecmp(const char *a, const char *b, size_t n);
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CARES_STRCASECMP_H */
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
|
||||
/* 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"
|
||||
#include "ares_strdup.h"
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
char *ares_strdup(const char *s1)
|
||||
{
|
||||
size_t sz;
|
||||
char * s2;
|
||||
|
||||
if(s1) {
|
||||
sz = strlen(s1);
|
||||
if(sz < (size_t)-1) {
|
||||
sz++;
|
||||
if(sz < ((size_t)-1) / sizeof(char)) {
|
||||
s2 = malloc(sz * sizeof(char));
|
||||
if(s2) {
|
||||
memcpy(s2, s1, sz * sizeof(char));
|
||||
return s2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (char *)NULL;
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef HEADER_CARES_STRDUP_H
|
||||
#define HEADER_CARES_STRDUP_H
|
||||
|
||||
|
||||
/* 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"
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
extern char *ares_strdup(const char *s1);
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CARES_STRDUP_H */
|
|
@ -0,0 +1,56 @@
|
|||
|
||||
/* 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"
|
||||
#include <assert.h>
|
||||
#include "ares.h"
|
||||
|
||||
const char *ares_strerror(int code)
|
||||
{
|
||||
/* Return a string literal from a table. */
|
||||
const char *errtext[] = {
|
||||
"Successful completion",
|
||||
"DNS server returned answer with no data",
|
||||
"DNS server claims query was misformatted",
|
||||
"DNS server returned general failure",
|
||||
"Domain name not found",
|
||||
"DNS server does not implement requested operation",
|
||||
"DNS server refused query",
|
||||
"Misformatted DNS query",
|
||||
"Misformatted domain name",
|
||||
"Unsupported address family",
|
||||
"Misformatted DNS reply",
|
||||
"Could not contact DNS servers",
|
||||
"Timeout while contacting DNS servers",
|
||||
"End of file",
|
||||
"Error reading file",
|
||||
"Out of memory",
|
||||
"Channel is being destroyed",
|
||||
"Misformatted string",
|
||||
"Illegal flags specified",
|
||||
"Given hostname is not numeric",
|
||||
"Illegal hints flags specified",
|
||||
"c-ares library initialization not yet performed",
|
||||
"Error loading iphlpapi.dll",
|
||||
"Could not find GetNetworkParams function",
|
||||
"DNS query cancelled"
|
||||
};
|
||||
|
||||
if(code >= 0 && code < (int)(sizeof(errtext) / sizeof(*errtext)))
|
||||
return errtext[code];
|
||||
else
|
||||
return "unknown";
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
|
||||
/* 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"
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
/* WARNING: Beware that this is linear in the number of outstanding
|
||||
* requests! You are probably far better off just calling ares_process()
|
||||
* once per second, rather than calling ares_timeout() to figure out
|
||||
* when to next call ares_process().
|
||||
*/
|
||||
struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv,
|
||||
struct timeval *tvbuf)
|
||||
{
|
||||
struct query *query;
|
||||
struct list_node* list_head;
|
||||
struct list_node* list_node;
|
||||
struct timeval now;
|
||||
struct timeval nextstop;
|
||||
long offset, min_offset;
|
||||
|
||||
/* No queries, no timeout (and no fetch of the current time). */
|
||||
if (ares__is_list_empty(&(channel->all_queries)))
|
||||
return maxtv;
|
||||
|
||||
/* Find the minimum timeout for the current set of queries. */
|
||||
now = ares__tvnow();
|
||||
min_offset = -1;
|
||||
|
||||
list_head = &(channel->all_queries);
|
||||
for (list_node = list_head->next; list_node != list_head;
|
||||
list_node = list_node->next)
|
||||
{
|
||||
query = list_node->data;
|
||||
if (query->timeout.tv_sec == 0)
|
||||
continue;
|
||||
offset = ares__timeoffset(&now, &query->timeout);
|
||||
if (offset < 0)
|
||||
offset = 0;
|
||||
if (min_offset == -1 || offset < min_offset)
|
||||
min_offset = offset;
|
||||
}
|
||||
|
||||
if(min_offset != -1) {
|
||||
nextstop.tv_sec = min_offset/1000;
|
||||
nextstop.tv_usec = (min_offset%1000)*1000;
|
||||
}
|
||||
|
||||
/* If we found a minimum timeout and it's sooner than the one specified in
|
||||
* maxtv (if any), return it. Otherwise go with maxtv.
|
||||
*/
|
||||
if (min_offset != -1 && (!maxtv || ares__timedout(maxtv, &nextstop)))
|
||||
{
|
||||
*tvbuf = nextstop;
|
||||
return tvbuf;
|
||||
}
|
||||
else
|
||||
return maxtv;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
#include "ares_setup.h"
|
||||
#include "ares.h"
|
||||
|
||||
const char *ares_version(int *version)
|
||||
{
|
||||
if(version)
|
||||
*version = ARES_VERSION;
|
||||
|
||||
return ARES_VERSION_STR;
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
|
||||
|
||||
/* 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"
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
#ifndef HAVE_WRITEV
|
||||
ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt)
|
||||
{
|
||||
char *buffer, *bp;
|
||||
int i;
|
||||
size_t bytes = 0;
|
||||
ssize_t result;
|
||||
|
||||
/* Validate iovcnt */
|
||||
if (iovcnt <= 0)
|
||||
{
|
||||
SET_ERRNO(EINVAL);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Validate and find the sum of the iov_len values in the iov array */
|
||||
for (i = 0; i < iovcnt; i++)
|
||||
{
|
||||
if (iov[i].iov_len > INT_MAX - bytes)
|
||||
{
|
||||
SET_ERRNO(EINVAL);
|
||||
return (-1);
|
||||
}
|
||||
bytes += iov[i].iov_len;
|
||||
}
|
||||
|
||||
if (bytes == 0)
|
||||
return (0);
|
||||
|
||||
/* Allocate a temporary buffer to hold the data */
|
||||
buffer = malloc(bytes);
|
||||
if (!buffer)
|
||||
{
|
||||
SET_ERRNO(ENOMEM);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Copy the data into buffer */
|
||||
for (bp = buffer, i = 0; i < iovcnt; ++i)
|
||||
{
|
||||
memcpy (bp, iov[i].iov_base, iov[i].iov_len);
|
||||
bp += iov[i].iov_len;
|
||||
}
|
||||
|
||||
/* Send buffer contents */
|
||||
result = swrite(s, buffer, bytes);
|
||||
|
||||
free(buffer);
|
||||
|
||||
return (result);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef HEADER_CARES_WRITEV_H
|
||||
#define HEADER_CARES_WRITEV_H
|
||||
|
||||
|
||||
/* 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"
|
||||
#include "ares.h"
|
||||
|
||||
#ifndef HAVE_WRITEV
|
||||
|
||||
/* Structure for scatter/gather I/O. */
|
||||
struct iovec
|
||||
{
|
||||
void *iov_base; /* Pointer to data. */
|
||||
size_t iov_len; /* Length of data. */
|
||||
};
|
||||
|
||||
extern ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CARES_WRITEV_H */
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1996,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef HAVE_BITNCMP
|
||||
|
||||
#include "ares_setup.h"
|
||||
#include "bitncmp.h"
|
||||
|
||||
/*
|
||||
* int
|
||||
* bitncmp(l, r, n)
|
||||
* compare bit masks l and r, for n bits.
|
||||
* return:
|
||||
* -1, 1, or 0 in the libc tradition.
|
||||
* note:
|
||||
* network byte order assumed. this means 192.5.5.240/28 has
|
||||
* 0x11110000 in its fourth octet.
|
||||
* author:
|
||||
* Paul Vixie (ISC), June 1996
|
||||
*/
|
||||
int
|
||||
ares_bitncmp(const void *l, const void *r, int n) {
|
||||
unsigned int lb, rb;
|
||||
int x, b;
|
||||
|
||||
b = n / 8;
|
||||
x = memcmp(l, r, b);
|
||||
if (x || (n % 8) == 0)
|
||||
return (x);
|
||||
|
||||
lb = ((const unsigned char *)l)[b];
|
||||
rb = ((const unsigned char *)r)[b];
|
||||
for (b = n % 8; b > 0; b--) {
|
||||
if ((lb & 0x80) != (rb & 0x80)) {
|
||||
if (lb & 0x80)
|
||||
return (1);
|
||||
return (-1);
|
||||
}
|
||||
lb <<= 1;
|
||||
rb <<= 1;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef __ARES_BITNCMP_H
|
||||
#define __ARES_BITNCMP_H
|
||||
|
||||
|
||||
/* Copyright (C) 2005 by Dominick Meglio
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HAVE_BITNCMP
|
||||
int ares_bitncmp(const void *l, const void *r, int n);
|
||||
#else
|
||||
#define ares_bitncmp(x,y,z) bitncmp(x,y,z)
|
||||
#endif
|
||||
|
||||
#endif /* __ARES_BITNCMP_H */
|
|
@ -0,0 +1,510 @@
|
|||
/* ares_config.h. Generated from ares_config.h.in by configure. */
|
||||
/* ares_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* define this if ares is built for a big endian system */
|
||||
/* #undef ARES_BIG_ENDIAN */
|
||||
|
||||
/* when building as static part of libcurl */
|
||||
/* #undef BUILDING_LIBCURL */
|
||||
|
||||
/* when building c-ares library */
|
||||
/* #undef CARES_BUILDING_LIBRARY */
|
||||
|
||||
/* when not building a shared library */
|
||||
/* #undef CARES_STATICLIB */
|
||||
|
||||
/* Define to 1 to enable hiding of library internal symbols. */
|
||||
#define CARES_SYMBOL_HIDING 1
|
||||
|
||||
/* Definition to make a library symbol externally visible. */
|
||||
#define CARES_SYMBOL_SCOPE_EXTERN __attribute__ ((visibility ("default")))
|
||||
|
||||
/* if a /etc/inet dir is being used */
|
||||
/* #undef ETC_INET */
|
||||
|
||||
/* Define to the type qualifier of arg 1 for getnameinfo. */
|
||||
#define GETNAMEINFO_QUAL_ARG1 const
|
||||
|
||||
/* Define to the type of arg 1 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG1 struct sockaddr *
|
||||
|
||||
/* Define to the type of arg 2 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG2 socklen_t
|
||||
|
||||
/* Define to the type of args 4 and 6 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG46 int
|
||||
|
||||
/* Define to the type of arg 7 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG7 int
|
||||
|
||||
/* Specifies the number of arguments to getservbyport_r */
|
||||
/* #undef GETSERVBYPORT_R_ARGS */
|
||||
|
||||
/* Specifies the size of the buffer to pass to getservbyport_r */
|
||||
/* #undef GETSERVBYPORT_R_BUFSIZE */
|
||||
|
||||
/* Define to 1 if you have AF_INET6. */
|
||||
#define HAVE_AF_INET6 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_COMPAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_H 1
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the `bitncmp' function. */
|
||||
/* #undef HAVE_BITNCMP */
|
||||
|
||||
/* Define to 1 if bool is an available type. */
|
||||
#define HAVE_BOOL_T 1
|
||||
|
||||
/* Define to 1 if you have the clock_gettime function and monotonic timer. */
|
||||
/* #undef HAVE_CLOCK_GETTIME_MONOTONIC */
|
||||
|
||||
/* Define to 1 if you have the closesocket function. */
|
||||
/* #undef HAVE_CLOSESOCKET */
|
||||
|
||||
/* Define to 1 if you have the CloseSocket camel case function. */
|
||||
/* #undef HAVE_CLOSESOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have the connect function. */
|
||||
#define HAVE_CONNECT 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the fcntl function. */
|
||||
#define HAVE_FCNTL 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
|
||||
#define HAVE_FCNTL_O_NONBLOCK 1
|
||||
|
||||
/* Define to 1 if you have the freeaddrinfo function. */
|
||||
#define HAVE_FREEADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have a working getaddrinfo function. */
|
||||
#define HAVE_GETADDRINFO 1
|
||||
|
||||
/* Define to 1 if the getaddrinfo function is threadsafe. */
|
||||
/* #undef HAVE_GETADDRINFO_THREADSAFE */
|
||||
|
||||
/* Define to 1 if you have the gethostbyaddr function. */
|
||||
#define HAVE_GETHOSTBYADDR 1
|
||||
|
||||
/* Define to 1 if you have the gethostbyname function. */
|
||||
#define HAVE_GETHOSTBYNAME 1
|
||||
|
||||
/* Define to 1 if you have the gethostname function. */
|
||||
#define HAVE_GETHOSTNAME 1
|
||||
|
||||
/* Define to 1 if you have the getnameinfo function. */
|
||||
#define HAVE_GETNAMEINFO 1
|
||||
|
||||
/* Define to 1 if you have the getservbyport_r function. */
|
||||
/* #undef HAVE_GETSERVBYPORT_R */
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the `if_indextoname' function. */
|
||||
#define HAVE_IF_INDEXTONAME 1
|
||||
|
||||
/* Define to 1 if you have the `inet_net_pton' function. */
|
||||
/* #undef HAVE_INET_NET_PTON */
|
||||
|
||||
/* Define to 1 if inet_net_pton supports IPv6. */
|
||||
/* #undef HAVE_INET_NET_PTON_IPV6 */
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_ntop function. */
|
||||
#define HAVE_INET_NTOP 1
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_pton function. */
|
||||
#define HAVE_INET_PTON 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the ioctl function. */
|
||||
#define HAVE_IOCTL 1
|
||||
|
||||
/* Define to 1 if you have the ioctlsocket function. */
|
||||
/* #undef HAVE_IOCTLSOCKET */
|
||||
|
||||
/* Define to 1 if you have the IoctlSocket camel case function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function.
|
||||
*/
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctl FIONBIO function. */
|
||||
#define HAVE_IOCTL_FIONBIO 1
|
||||
|
||||
/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */
|
||||
#define HAVE_IOCTL_SIOCGIFADDR 1
|
||||
|
||||
/* Define to 1 if you have the `resolve' library (-lresolve). */
|
||||
/* #undef HAVE_LIBRESOLVE */
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* if your compiler supports LL */
|
||||
#define HAVE_LL 1
|
||||
|
||||
/* Define to 1 if the compiler supports the 'long long' data type. */
|
||||
#define HAVE_LONGLONG 1
|
||||
|
||||
/* Define to 1 if you have the malloc.h header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the memory.h header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the MSG_NOSIGNAL flag. */
|
||||
#define HAVE_MSG_NOSIGNAL 1
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#define HAVE_NETDB_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/tcp.h> header file. */
|
||||
#define HAVE_NETINET_TCP_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/if.h> header file. */
|
||||
#define HAVE_NET_IF_H 1
|
||||
|
||||
/* Define to 1 if you have PF_INET6. */
|
||||
#define HAVE_PF_INET6 1
|
||||
|
||||
/* Define to 1 if you have the recv function. */
|
||||
#define HAVE_RECV 1
|
||||
|
||||
/* Define to 1 if you have the recvfrom function. */
|
||||
#define HAVE_RECVFROM 1
|
||||
|
||||
/* Define to 1 if you have the send function. */
|
||||
#define HAVE_SEND 1
|
||||
|
||||
/* Define to 1 if you have the setsockopt function. */
|
||||
#define HAVE_SETSOCKOPT 1
|
||||
|
||||
/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
|
||||
/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is an available typedef. */
|
||||
#define HAVE_SIG_ATOMIC_T 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is already defined as volatile. */
|
||||
/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */
|
||||
|
||||
/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */
|
||||
#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
|
||||
|
||||
/* Define to 1 if you have the socket function. */
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if you have the <socket.h> header file. */
|
||||
/* #undef HAVE_SOCKET_H */
|
||||
|
||||
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||
#define HAVE_STDBOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the strcasecmp function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strcmpi function. */
|
||||
/* #undef HAVE_STRCMPI */
|
||||
|
||||
/* Define to 1 if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define to 1 if you have the stricmp function. */
|
||||
/* #undef HAVE_STRICMP */
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the strncasecmp function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strncmpi function. */
|
||||
/* #undef HAVE_STRNCMPI */
|
||||
|
||||
/* Define to 1 if you have the strnicmp function. */
|
||||
/* #undef HAVE_STRNICMP */
|
||||
|
||||
/* Define to 1 if you have the <stropts.h> header file. */
|
||||
/* #undef HAVE_STROPTS_H */
|
||||
|
||||
/* Define to 1 if you have struct addrinfo. */
|
||||
#define HAVE_STRUCT_ADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have struct in6_addr. */
|
||||
#define HAVE_STRUCT_IN6_ADDR 1
|
||||
|
||||
/* Define to 1 if you have struct sockaddr_in6. */
|
||||
#define HAVE_STRUCT_SOCKADDR_IN6 1
|
||||
|
||||
/* if struct sockaddr_storage is defined */
|
||||
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
|
||||
|
||||
/* Define to 1 if you have the timeval struct. */
|
||||
#define HAVE_STRUCT_TIMEVAL 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#define HAVE_SYS_UIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the windows.h header file. */
|
||||
/* #undef HAVE_WINDOWS_H */
|
||||
|
||||
/* Define to 1 if you have the winsock2.h header file. */
|
||||
/* #undef HAVE_WINSOCK2_H */
|
||||
|
||||
/* Define to 1 if you have the winsock.h header file. */
|
||||
/* #undef HAVE_WINSOCK_H */
|
||||
|
||||
/* Define to 1 if you have the writev function. */
|
||||
#define HAVE_WRITEV 1
|
||||
|
||||
/* Define to 1 if you have the ws2tcpip.h header file. */
|
||||
/* #undef HAVE_WS2TCPIP_H */
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to 1 if you are building a native Windows target. */
|
||||
/* #undef NATIVE_WINDOWS */
|
||||
|
||||
/* Define to 1 if you need the malloc.h header file even with stdlib.h */
|
||||
/* #undef NEED_MALLOC_H */
|
||||
|
||||
/* Define to 1 if you need the memory.h header file even with stdlib.h */
|
||||
/* #undef NEED_MEMORY_H */
|
||||
|
||||
/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
|
||||
/* #undef NEED_REENTRANT */
|
||||
|
||||
/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
|
||||
/* #undef NEED_THREAD_SAFE */
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* cpu-machine-OS */
|
||||
#define OS "i686-pc-cygwin"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "c-ares"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "c-ares mailing list => http://cool.haxx.se/mailman/listinfo/c-ares"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "c-ares"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "c-ares 1.7.1"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "c-ares"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.7.1"
|
||||
|
||||
/* a suitable file/device to read random data from */
|
||||
#define RANDOM_FILE "/dev/urandom"
|
||||
|
||||
/* Define to the type of arg 1 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type pointed by arg 2 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG2 void
|
||||
|
||||
/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */
|
||||
#define RECVFROM_TYPE_ARG2_IS_VOID 1
|
||||
|
||||
/* Define to the type of arg 3 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG4 int
|
||||
|
||||
/* Define to the type pointed by arg 5 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG5 struct sockaddr
|
||||
|
||||
/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG5_IS_VOID */
|
||||
|
||||
/* Define to the type pointed by arg 6 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG6 socklen_t
|
||||
|
||||
/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG6_IS_VOID */
|
||||
|
||||
/* Define to the function return type for recvfrom. */
|
||||
#define RECVFROM_TYPE_RETV int
|
||||
|
||||
/* Define to the type of arg 1 for recv. */
|
||||
#define RECV_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for recv. */
|
||||
#define RECV_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for recv. */
|
||||
#define RECV_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recv. */
|
||||
#define RECV_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for recv. */
|
||||
#define RECV_TYPE_RETV int
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to the type qualifier of arg 2 for send. */
|
||||
#define SEND_QUAL_ARG2 const
|
||||
|
||||
/* Define to the type of arg 1 for send. */
|
||||
#define SEND_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for send. */
|
||||
#define SEND_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for send. */
|
||||
#define SEND_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for send. */
|
||||
#define SEND_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for send. */
|
||||
#define SEND_TYPE_RETV int
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#define SIZEOF_SIZE_T 4
|
||||
|
||||
/* The size of `struct in6_addr', as computed by sizeof. */
|
||||
#define SIZEOF_STRUCT_IN6_ADDR 16
|
||||
|
||||
/* The size of `struct in_addr', as computed by sizeof. */
|
||||
#define SIZEOF_STRUCT_IN_ADDR 4
|
||||
|
||||
/* The size of `time_t', as computed by sizeof. */
|
||||
#define SIZEOF_TIME_T 4
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Define to disable non-blocking sockets. */
|
||||
/* #undef USE_BLOCKING_SOCKETS */
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.7.1"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define to 1 if OS is AIX. */
|
||||
#ifndef _ALL_SOURCE
|
||||
/* # undef _ALL_SOURCE */
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
/* #undef _FILE_OFFSET_BITS */
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Type to use in place of in_addr_t when system does not provide it. */
|
||||
/* #undef in_addr_t */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* the signed version of size_t */
|
||||
/* #undef ssize_t */
|
|
@ -0,0 +1,510 @@
|
|||
/* ares_config.h. Generated from ares_config.h.in by configure. */
|
||||
/* ares_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* define this if ares is built for a big endian system */
|
||||
/* #undef ARES_BIG_ENDIAN */
|
||||
|
||||
/* when building as static part of libcurl */
|
||||
/* #undef BUILDING_LIBCURL */
|
||||
|
||||
/* when building c-ares library */
|
||||
/* #undef CARES_BUILDING_LIBRARY */
|
||||
|
||||
/* when not building a shared library */
|
||||
/* #undef CARES_STATICLIB */
|
||||
|
||||
/* Define to 1 to enable hiding of library internal symbols. */
|
||||
#define CARES_SYMBOL_HIDING 1
|
||||
|
||||
/* Definition to make a library symbol externally visible. */
|
||||
#define CARES_SYMBOL_SCOPE_EXTERN __attribute__ ((visibility ("default")))
|
||||
|
||||
/* if a /etc/inet dir is being used */
|
||||
/* #undef ETC_INET */
|
||||
|
||||
/* Define to the type qualifier of arg 1 for getnameinfo. */
|
||||
#define GETNAMEINFO_QUAL_ARG1 const
|
||||
|
||||
/* Define to the type of arg 1 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG1 struct sockaddr *
|
||||
|
||||
/* Define to the type of arg 2 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG2 socklen_t
|
||||
|
||||
/* Define to the type of args 4 and 6 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG46 socklen_t
|
||||
|
||||
/* Define to the type of arg 7 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG7 int
|
||||
|
||||
/* Specifies the number of arguments to getservbyport_r */
|
||||
/* #undef GETSERVBYPORT_R_ARGS */
|
||||
|
||||
/* Specifies the size of the buffer to pass to getservbyport_r */
|
||||
/* #undef GETSERVBYPORT_R_BUFSIZE */
|
||||
|
||||
/* Define to 1 if you have AF_INET6. */
|
||||
#define HAVE_AF_INET6 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_COMPAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_H 1
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the `bitncmp' function. */
|
||||
/* #undef HAVE_BITNCMP */
|
||||
|
||||
/* Define to 1 if bool is an available type. */
|
||||
#define HAVE_BOOL_T 1
|
||||
|
||||
/* Define to 1 if you have the clock_gettime function and monotonic timer. */
|
||||
/* #undef HAVE_CLOCK_GETTIME_MONOTONIC */
|
||||
|
||||
/* Define to 1 if you have the closesocket function. */
|
||||
/* #undef HAVE_CLOSESOCKET */
|
||||
|
||||
/* Define to 1 if you have the CloseSocket camel case function. */
|
||||
/* #undef HAVE_CLOSESOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have the connect function. */
|
||||
#define HAVE_CONNECT 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the fcntl function. */
|
||||
#define HAVE_FCNTL 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
|
||||
#define HAVE_FCNTL_O_NONBLOCK 1
|
||||
|
||||
/* Define to 1 if you have the freeaddrinfo function. */
|
||||
#define HAVE_FREEADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have a working getaddrinfo function. */
|
||||
#define HAVE_GETADDRINFO 1
|
||||
|
||||
/* Define to 1 if the getaddrinfo function is threadsafe. */
|
||||
#define HAVE_GETADDRINFO_THREADSAFE 1
|
||||
|
||||
/* Define to 1 if you have the gethostbyaddr function. */
|
||||
#define HAVE_GETHOSTBYADDR 1
|
||||
|
||||
/* Define to 1 if you have the gethostbyname function. */
|
||||
#define HAVE_GETHOSTBYNAME 1
|
||||
|
||||
/* Define to 1 if you have the gethostname function. */
|
||||
#define HAVE_GETHOSTNAME 1
|
||||
|
||||
/* Define to 1 if you have the getnameinfo function. */
|
||||
#define HAVE_GETNAMEINFO 1
|
||||
|
||||
/* Define to 1 if you have the getservbyport_r function. */
|
||||
/* #undef HAVE_GETSERVBYPORT_R */
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the `if_indextoname' function. */
|
||||
#define HAVE_IF_INDEXTONAME 1
|
||||
|
||||
/* Define to 1 if you have the `inet_net_pton' function. */
|
||||
#define HAVE_INET_NET_PTON 1
|
||||
|
||||
/* Define to 1 if inet_net_pton supports IPv6. */
|
||||
#define HAVE_INET_NET_PTON_IPV6 1
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_ntop function. */
|
||||
#define HAVE_INET_NTOP 1
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_pton function. */
|
||||
#define HAVE_INET_PTON 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the ioctl function. */
|
||||
#define HAVE_IOCTL 1
|
||||
|
||||
/* Define to 1 if you have the ioctlsocket function. */
|
||||
/* #undef HAVE_IOCTLSOCKET */
|
||||
|
||||
/* Define to 1 if you have the IoctlSocket camel case function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function.
|
||||
*/
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctl FIONBIO function. */
|
||||
#define HAVE_IOCTL_FIONBIO 1
|
||||
|
||||
/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */
|
||||
#define HAVE_IOCTL_SIOCGIFADDR 1
|
||||
|
||||
/* Define to 1 if you have the `resolve' library (-lresolve). */
|
||||
/* #undef HAVE_LIBRESOLVE */
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* if your compiler supports LL */
|
||||
#define HAVE_LL 1
|
||||
|
||||
/* Define to 1 if the compiler supports the 'long long' data type. */
|
||||
#define HAVE_LONGLONG 1
|
||||
|
||||
/* Define to 1 if you have the malloc.h header file. */
|
||||
/* #undef HAVE_MALLOC_H */
|
||||
|
||||
/* Define to 1 if you have the memory.h header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the MSG_NOSIGNAL flag. */
|
||||
/* #undef HAVE_MSG_NOSIGNAL */
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#define HAVE_NETDB_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/tcp.h> header file. */
|
||||
#define HAVE_NETINET_TCP_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/if.h> header file. */
|
||||
#define HAVE_NET_IF_H 1
|
||||
|
||||
/* Define to 1 if you have PF_INET6. */
|
||||
#define HAVE_PF_INET6 1
|
||||
|
||||
/* Define to 1 if you have the recv function. */
|
||||
#define HAVE_RECV 1
|
||||
|
||||
/* Define to 1 if you have the recvfrom function. */
|
||||
#define HAVE_RECVFROM 1
|
||||
|
||||
/* Define to 1 if you have the send function. */
|
||||
#define HAVE_SEND 1
|
||||
|
||||
/* Define to 1 if you have the setsockopt function. */
|
||||
#define HAVE_SETSOCKOPT 1
|
||||
|
||||
/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
|
||||
/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is an available typedef. */
|
||||
#define HAVE_SIG_ATOMIC_T 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is already defined as volatile. */
|
||||
/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */
|
||||
|
||||
/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */
|
||||
#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
|
||||
|
||||
/* Define to 1 if you have the socket function. */
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if you have the <socket.h> header file. */
|
||||
/* #undef HAVE_SOCKET_H */
|
||||
|
||||
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||
#define HAVE_STDBOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the strcasecmp function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strcmpi function. */
|
||||
/* #undef HAVE_STRCMPI */
|
||||
|
||||
/* Define to 1 if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define to 1 if you have the stricmp function. */
|
||||
/* #undef HAVE_STRICMP */
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the strncasecmp function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strncmpi function. */
|
||||
/* #undef HAVE_STRNCMPI */
|
||||
|
||||
/* Define to 1 if you have the strnicmp function. */
|
||||
/* #undef HAVE_STRNICMP */
|
||||
|
||||
/* Define to 1 if you have the <stropts.h> header file. */
|
||||
/* #undef HAVE_STROPTS_H */
|
||||
|
||||
/* Define to 1 if you have struct addrinfo. */
|
||||
#define HAVE_STRUCT_ADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have struct in6_addr. */
|
||||
#define HAVE_STRUCT_IN6_ADDR 1
|
||||
|
||||
/* Define to 1 if you have struct sockaddr_in6. */
|
||||
#define HAVE_STRUCT_SOCKADDR_IN6 1
|
||||
|
||||
/* if struct sockaddr_storage is defined */
|
||||
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
|
||||
|
||||
/* Define to 1 if you have the timeval struct. */
|
||||
#define HAVE_STRUCT_TIMEVAL 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#define HAVE_SYS_UIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the windows.h header file. */
|
||||
/* #undef HAVE_WINDOWS_H */
|
||||
|
||||
/* Define to 1 if you have the winsock2.h header file. */
|
||||
/* #undef HAVE_WINSOCK2_H */
|
||||
|
||||
/* Define to 1 if you have the winsock.h header file. */
|
||||
/* #undef HAVE_WINSOCK_H */
|
||||
|
||||
/* Define to 1 if you have the writev function. */
|
||||
#define HAVE_WRITEV 1
|
||||
|
||||
/* Define to 1 if you have the ws2tcpip.h header file. */
|
||||
/* #undef HAVE_WS2TCPIP_H */
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to 1 if you are building a native Windows target. */
|
||||
/* #undef NATIVE_WINDOWS */
|
||||
|
||||
/* Define to 1 if you need the malloc.h header file even with stdlib.h */
|
||||
/* #undef NEED_MALLOC_H */
|
||||
|
||||
/* Define to 1 if you need the memory.h header file even with stdlib.h */
|
||||
/* #undef NEED_MEMORY_H */
|
||||
|
||||
/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
|
||||
/* #undef NEED_REENTRANT */
|
||||
|
||||
/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
|
||||
/* #undef NEED_THREAD_SAFE */
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* cpu-machine-OS */
|
||||
#define OS "i386-apple-darwin9.8.0"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "c-ares"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "c-ares mailing list => http://cool.haxx.se/mailman/listinfo/c-ares"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "c-ares"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "c-ares 1.7.1"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "c-ares"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.7.1"
|
||||
|
||||
/* a suitable file/device to read random data from */
|
||||
#define RANDOM_FILE "/dev/urandom"
|
||||
|
||||
/* Define to the type of arg 1 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type pointed by arg 2 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG2 void
|
||||
|
||||
/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */
|
||||
#define RECVFROM_TYPE_ARG2_IS_VOID 1
|
||||
|
||||
/* Define to the type of arg 3 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG4 int
|
||||
|
||||
/* Define to the type pointed by arg 5 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG5 struct sockaddr
|
||||
|
||||
/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG5_IS_VOID */
|
||||
|
||||
/* Define to the type pointed by arg 6 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG6 socklen_t
|
||||
|
||||
/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG6_IS_VOID */
|
||||
|
||||
/* Define to the function return type for recvfrom. */
|
||||
#define RECVFROM_TYPE_RETV ssize_t
|
||||
|
||||
/* Define to the type of arg 1 for recv. */
|
||||
#define RECV_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for recv. */
|
||||
#define RECV_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for recv. */
|
||||
#define RECV_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recv. */
|
||||
#define RECV_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for recv. */
|
||||
#define RECV_TYPE_RETV ssize_t
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to the type qualifier of arg 2 for send. */
|
||||
#define SEND_QUAL_ARG2 const
|
||||
|
||||
/* Define to the type of arg 1 for send. */
|
||||
#define SEND_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for send. */
|
||||
#define SEND_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for send. */
|
||||
#define SEND_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for send. */
|
||||
#define SEND_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for send. */
|
||||
#define SEND_TYPE_RETV ssize_t
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#define SIZEOF_SIZE_T 4
|
||||
|
||||
/* The size of `struct in6_addr', as computed by sizeof. */
|
||||
#define SIZEOF_STRUCT_IN6_ADDR 16
|
||||
|
||||
/* The size of `struct in_addr', as computed by sizeof. */
|
||||
#define SIZEOF_STRUCT_IN_ADDR 4
|
||||
|
||||
/* The size of `time_t', as computed by sizeof. */
|
||||
#define SIZEOF_TIME_T 4
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Define to disable non-blocking sockets. */
|
||||
/* #undef USE_BLOCKING_SOCKETS */
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.7.1"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define to 1 if OS is AIX. */
|
||||
#ifndef _ALL_SOURCE
|
||||
/* # undef _ALL_SOURCE */
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
/* #undef _FILE_OFFSET_BITS */
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Type to use in place of in_addr_t when system does not provide it. */
|
||||
/* #undef in_addr_t */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* the signed version of size_t */
|
||||
/* #undef ssize_t */
|
|
@ -0,0 +1,510 @@
|
|||
/* ares_config.h. Generated from ares_config.h.in by configure. */
|
||||
/* ares_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* define this if ares is built for a big endian system */
|
||||
/* #undef ARES_BIG_ENDIAN */
|
||||
|
||||
/* when building as static part of libcurl */
|
||||
/* #undef BUILDING_LIBCURL */
|
||||
|
||||
/* when building c-ares library */
|
||||
/* #undef CARES_BUILDING_LIBRARY */
|
||||
|
||||
/* when not building a shared library */
|
||||
/* #undef CARES_STATICLIB */
|
||||
|
||||
/* Define to 1 to enable hiding of library internal symbols. */
|
||||
#define CARES_SYMBOL_HIDING 1
|
||||
|
||||
/* Definition to make a library symbol externally visible. */
|
||||
#define CARES_SYMBOL_SCOPE_EXTERN __attribute__ ((visibility ("default")))
|
||||
|
||||
/* if a /etc/inet dir is being used */
|
||||
/* #undef ETC_INET */
|
||||
|
||||
/* Define to the type qualifier of arg 1 for getnameinfo. */
|
||||
#define GETNAMEINFO_QUAL_ARG1 const
|
||||
|
||||
/* Define to the type of arg 1 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG1 struct sockaddr *
|
||||
|
||||
/* Define to the type of arg 2 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG2 socklen_t
|
||||
|
||||
/* Define to the type of args 4 and 6 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG46 size_t
|
||||
|
||||
/* Define to the type of arg 7 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG7 int
|
||||
|
||||
/* Specifies the number of arguments to getservbyport_r */
|
||||
#define GETSERVBYPORT_R_ARGS 6
|
||||
|
||||
/* Specifies the size of the buffer to pass to getservbyport_r */
|
||||
#define GETSERVBYPORT_R_BUFSIZE 4096
|
||||
|
||||
/* Define to 1 if you have AF_INET6. */
|
||||
#define HAVE_AF_INET6 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_COMPAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_H 1
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the `bitncmp' function. */
|
||||
/* #undef HAVE_BITNCMP */
|
||||
|
||||
/* Define to 1 if bool is an available type. */
|
||||
#define HAVE_BOOL_T 1
|
||||
|
||||
/* Define to 1 if you have the clock_gettime function and monotonic timer. */
|
||||
#define HAVE_CLOCK_GETTIME_MONOTONIC 1
|
||||
|
||||
/* Define to 1 if you have the closesocket function. */
|
||||
/* #undef HAVE_CLOSESOCKET */
|
||||
|
||||
/* Define to 1 if you have the CloseSocket camel case function. */
|
||||
/* #undef HAVE_CLOSESOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have the connect function. */
|
||||
#define HAVE_CONNECT 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the fcntl function. */
|
||||
#define HAVE_FCNTL 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
|
||||
#define HAVE_FCNTL_O_NONBLOCK 1
|
||||
|
||||
/* Define to 1 if you have the freeaddrinfo function. */
|
||||
#define HAVE_FREEADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have a working getaddrinfo function. */
|
||||
#define HAVE_GETADDRINFO 1
|
||||
|
||||
/* Define to 1 if the getaddrinfo function is threadsafe. */
|
||||
#define HAVE_GETADDRINFO_THREADSAFE 1
|
||||
|
||||
/* Define to 1 if you have the gethostbyaddr function. */
|
||||
#define HAVE_GETHOSTBYADDR 1
|
||||
|
||||
/* Define to 1 if you have the gethostbyname function. */
|
||||
#define HAVE_GETHOSTBYNAME 1
|
||||
|
||||
/* Define to 1 if you have the gethostname function. */
|
||||
#define HAVE_GETHOSTNAME 1
|
||||
|
||||
/* Define to 1 if you have the getnameinfo function. */
|
||||
#define HAVE_GETNAMEINFO 1
|
||||
|
||||
/* Define to 1 if you have the getservbyport_r function. */
|
||||
#define HAVE_GETSERVBYPORT_R 1
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the `if_indextoname' function. */
|
||||
#define HAVE_IF_INDEXTONAME 1
|
||||
|
||||
/* Define to 1 if you have the `inet_net_pton' function. */
|
||||
#define HAVE_INET_NET_PTON 1
|
||||
|
||||
/* Define to 1 if inet_net_pton supports IPv6. */
|
||||
/* #undef HAVE_INET_NET_PTON_IPV6 */
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_ntop function. */
|
||||
#define HAVE_INET_NTOP 1
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_pton function. */
|
||||
#define HAVE_INET_PTON 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the ioctl function. */
|
||||
#define HAVE_IOCTL 1
|
||||
|
||||
/* Define to 1 if you have the ioctlsocket function. */
|
||||
/* #undef HAVE_IOCTLSOCKET */
|
||||
|
||||
/* Define to 1 if you have the IoctlSocket camel case function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function.
|
||||
*/
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctl FIONBIO function. */
|
||||
#define HAVE_IOCTL_FIONBIO 1
|
||||
|
||||
/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */
|
||||
#define HAVE_IOCTL_SIOCGIFADDR 1
|
||||
|
||||
/* Define to 1 if you have the `resolve' library (-lresolve). */
|
||||
/* #undef HAVE_LIBRESOLVE */
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* if your compiler supports LL */
|
||||
#define HAVE_LL 1
|
||||
|
||||
/* Define to 1 if the compiler supports the 'long long' data type. */
|
||||
#define HAVE_LONGLONG 1
|
||||
|
||||
/* Define to 1 if you have the malloc.h header file. */
|
||||
/* #undef HAVE_MALLOC_H */
|
||||
|
||||
/* Define to 1 if you have the memory.h header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the MSG_NOSIGNAL flag. */
|
||||
#define HAVE_MSG_NOSIGNAL 1
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#define HAVE_NETDB_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/tcp.h> header file. */
|
||||
#define HAVE_NETINET_TCP_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/if.h> header file. */
|
||||
#define HAVE_NET_IF_H 1
|
||||
|
||||
/* Define to 1 if you have PF_INET6. */
|
||||
#define HAVE_PF_INET6 1
|
||||
|
||||
/* Define to 1 if you have the recv function. */
|
||||
#define HAVE_RECV 1
|
||||
|
||||
/* Define to 1 if you have the recvfrom function. */
|
||||
#define HAVE_RECVFROM 1
|
||||
|
||||
/* Define to 1 if you have the send function. */
|
||||
#define HAVE_SEND 1
|
||||
|
||||
/* Define to 1 if you have the setsockopt function. */
|
||||
#define HAVE_SETSOCKOPT 1
|
||||
|
||||
/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
|
||||
/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is an available typedef. */
|
||||
#define HAVE_SIG_ATOMIC_T 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is already defined as volatile. */
|
||||
/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */
|
||||
|
||||
/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */
|
||||
#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
|
||||
|
||||
/* Define to 1 if you have the socket function. */
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if you have the <socket.h> header file. */
|
||||
/* #undef HAVE_SOCKET_H */
|
||||
|
||||
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||
#define HAVE_STDBOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the strcasecmp function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strcmpi function. */
|
||||
/* #undef HAVE_STRCMPI */
|
||||
|
||||
/* Define to 1 if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define to 1 if you have the stricmp function. */
|
||||
/* #undef HAVE_STRICMP */
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the strncasecmp function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strncmpi function. */
|
||||
/* #undef HAVE_STRNCMPI */
|
||||
|
||||
/* Define to 1 if you have the strnicmp function. */
|
||||
/* #undef HAVE_STRNICMP */
|
||||
|
||||
/* Define to 1 if you have the <stropts.h> header file. */
|
||||
/* #undef HAVE_STROPTS_H */
|
||||
|
||||
/* Define to 1 if you have struct addrinfo. */
|
||||
#define HAVE_STRUCT_ADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have struct in6_addr. */
|
||||
#define HAVE_STRUCT_IN6_ADDR 1
|
||||
|
||||
/* Define to 1 if you have struct sockaddr_in6. */
|
||||
#define HAVE_STRUCT_SOCKADDR_IN6 1
|
||||
|
||||
/* if struct sockaddr_storage is defined */
|
||||
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
|
||||
|
||||
/* Define to 1 if you have the timeval struct. */
|
||||
#define HAVE_STRUCT_TIMEVAL 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#define HAVE_SYS_UIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the windows.h header file. */
|
||||
/* #undef HAVE_WINDOWS_H */
|
||||
|
||||
/* Define to 1 if you have the winsock2.h header file. */
|
||||
/* #undef HAVE_WINSOCK2_H */
|
||||
|
||||
/* Define to 1 if you have the winsock.h header file. */
|
||||
/* #undef HAVE_WINSOCK_H */
|
||||
|
||||
/* Define to 1 if you have the writev function. */
|
||||
#define HAVE_WRITEV 1
|
||||
|
||||
/* Define to 1 if you have the ws2tcpip.h header file. */
|
||||
/* #undef HAVE_WS2TCPIP_H */
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to 1 if you are building a native Windows target. */
|
||||
/* #undef NATIVE_WINDOWS */
|
||||
|
||||
/* Define to 1 if you need the malloc.h header file even with stdlib.h */
|
||||
/* #undef NEED_MALLOC_H */
|
||||
|
||||
/* Define to 1 if you need the memory.h header file even with stdlib.h */
|
||||
/* #undef NEED_MEMORY_H */
|
||||
|
||||
/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
|
||||
/* #undef NEED_REENTRANT */
|
||||
|
||||
/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
|
||||
/* #undef NEED_THREAD_SAFE */
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* cpu-machine-OS */
|
||||
#define OS "i386-portbld-freebsd8.0"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "c-ares"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "c-ares mailing list => http://cool.haxx.se/mailman/listinfo/c-ares"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "c-ares"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "c-ares 1.7.1"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "c-ares"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.7.1"
|
||||
|
||||
/* a suitable file/device to read random data from */
|
||||
#define RANDOM_FILE "/dev/urandom"
|
||||
|
||||
/* Define to the type of arg 1 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type pointed by arg 2 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG2 void
|
||||
|
||||
/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */
|
||||
#define RECVFROM_TYPE_ARG2_IS_VOID 1
|
||||
|
||||
/* Define to the type of arg 3 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG4 int
|
||||
|
||||
/* Define to the type pointed by arg 5 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG5 struct sockaddr
|
||||
|
||||
/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG5_IS_VOID */
|
||||
|
||||
/* Define to the type pointed by arg 6 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG6 socklen_t
|
||||
|
||||
/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG6_IS_VOID */
|
||||
|
||||
/* Define to the function return type for recvfrom. */
|
||||
#define RECVFROM_TYPE_RETV int
|
||||
|
||||
/* Define to the type of arg 1 for recv. */
|
||||
#define RECV_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for recv. */
|
||||
#define RECV_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for recv. */
|
||||
#define RECV_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recv. */
|
||||
#define RECV_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for recv. */
|
||||
#define RECV_TYPE_RETV int
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to the type qualifier of arg 2 for send. */
|
||||
#define SEND_QUAL_ARG2 const
|
||||
|
||||
/* Define to the type of arg 1 for send. */
|
||||
#define SEND_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for send. */
|
||||
#define SEND_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for send. */
|
||||
#define SEND_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for send. */
|
||||
#define SEND_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for send. */
|
||||
#define SEND_TYPE_RETV int
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#define SIZEOF_SIZE_T 4
|
||||
|
||||
/* The size of `struct in6_addr', as computed by sizeof. */
|
||||
#define SIZEOF_STRUCT_IN6_ADDR 16
|
||||
|
||||
/* The size of `struct in_addr', as computed by sizeof. */
|
||||
#define SIZEOF_STRUCT_IN_ADDR 4
|
||||
|
||||
/* The size of `time_t', as computed by sizeof. */
|
||||
#define SIZEOF_TIME_T 4
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Define to disable non-blocking sockets. */
|
||||
/* #undef USE_BLOCKING_SOCKETS */
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.7.1"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define to 1 if OS is AIX. */
|
||||
#ifndef _ALL_SOURCE
|
||||
/* # undef _ALL_SOURCE */
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
/* #undef _FILE_OFFSET_BITS */
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Type to use in place of in_addr_t when system does not provide it. */
|
||||
/* #undef in_addr_t */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* the signed version of size_t */
|
||||
/* #undef ssize_t */
|
|
@ -0,0 +1,510 @@
|
|||
/* ares_config.h. Generated from ares_config.h.in by configure. */
|
||||
/* ares_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* define this if ares is built for a big endian system */
|
||||
/* #undef ARES_BIG_ENDIAN */
|
||||
|
||||
/* when building as static part of libcurl */
|
||||
/* #undef BUILDING_LIBCURL */
|
||||
|
||||
/* when building c-ares library */
|
||||
/* #undef CARES_BUILDING_LIBRARY */
|
||||
|
||||
/* when not building a shared library */
|
||||
/* #undef CARES_STATICLIB */
|
||||
|
||||
/* Define to 1 to enable hiding of library internal symbols. */
|
||||
#define CARES_SYMBOL_HIDING 1
|
||||
|
||||
/* Definition to make a library symbol externally visible. */
|
||||
#define CARES_SYMBOL_SCOPE_EXTERN __attribute__ ((visibility ("default")))
|
||||
|
||||
/* if a /etc/inet dir is being used */
|
||||
/* #undef ETC_INET */
|
||||
|
||||
/* Define to the type qualifier of arg 1 for getnameinfo. */
|
||||
#define GETNAMEINFO_QUAL_ARG1 const
|
||||
|
||||
/* Define to the type of arg 1 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG1 struct sockaddr *
|
||||
|
||||
/* Define to the type of arg 2 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG2 socklen_t
|
||||
|
||||
/* Define to the type of args 4 and 6 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG46 size_t
|
||||
|
||||
/* Define to the type of arg 7 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG7 unsigned int
|
||||
|
||||
/* Specifies the number of arguments to getservbyport_r */
|
||||
#define GETSERVBYPORT_R_ARGS 6
|
||||
|
||||
/* Specifies the size of the buffer to pass to getservbyport_r */
|
||||
#define GETSERVBYPORT_R_BUFSIZE 4096
|
||||
|
||||
/* Define to 1 if you have AF_INET6. */
|
||||
#define HAVE_AF_INET6 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_COMPAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_H 1
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the `bitncmp' function. */
|
||||
/* #undef HAVE_BITNCMP */
|
||||
|
||||
/* Define to 1 if bool is an available type. */
|
||||
#define HAVE_BOOL_T 1
|
||||
|
||||
/* Define to 1 if you have the clock_gettime function and monotonic timer. */
|
||||
#define HAVE_CLOCK_GETTIME_MONOTONIC 1
|
||||
|
||||
/* Define to 1 if you have the closesocket function. */
|
||||
/* #undef HAVE_CLOSESOCKET */
|
||||
|
||||
/* Define to 1 if you have the CloseSocket camel case function. */
|
||||
/* #undef HAVE_CLOSESOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have the connect function. */
|
||||
#define HAVE_CONNECT 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the fcntl function. */
|
||||
#define HAVE_FCNTL 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
|
||||
#define HAVE_FCNTL_O_NONBLOCK 1
|
||||
|
||||
/* Define to 1 if you have the freeaddrinfo function. */
|
||||
#define HAVE_FREEADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have a working getaddrinfo function. */
|
||||
#define HAVE_GETADDRINFO 1
|
||||
|
||||
/* Define to 1 if the getaddrinfo function is threadsafe. */
|
||||
#define HAVE_GETADDRINFO_THREADSAFE 1
|
||||
|
||||
/* Define to 1 if you have the gethostbyaddr function. */
|
||||
#define HAVE_GETHOSTBYADDR 1
|
||||
|
||||
/* Define to 1 if you have the gethostbyname function. */
|
||||
#define HAVE_GETHOSTBYNAME 1
|
||||
|
||||
/* Define to 1 if you have the gethostname function. */
|
||||
#define HAVE_GETHOSTNAME 1
|
||||
|
||||
/* Define to 1 if you have the getnameinfo function. */
|
||||
#define HAVE_GETNAMEINFO 1
|
||||
|
||||
/* Define to 1 if you have the getservbyport_r function. */
|
||||
#define HAVE_GETSERVBYPORT_R 1
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the `if_indextoname' function. */
|
||||
#define HAVE_IF_INDEXTONAME 1
|
||||
|
||||
/* Define to 1 if you have the `inet_net_pton' function. */
|
||||
/* #undef HAVE_INET_NET_PTON */
|
||||
|
||||
/* Define to 1 if inet_net_pton supports IPv6. */
|
||||
/* #undef HAVE_INET_NET_PTON_IPV6 */
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_ntop function. */
|
||||
#define HAVE_INET_NTOP 1
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_pton function. */
|
||||
#define HAVE_INET_PTON 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the ioctl function. */
|
||||
#define HAVE_IOCTL 1
|
||||
|
||||
/* Define to 1 if you have the ioctlsocket function. */
|
||||
/* #undef HAVE_IOCTLSOCKET */
|
||||
|
||||
/* Define to 1 if you have the IoctlSocket camel case function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function.
|
||||
*/
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctl FIONBIO function. */
|
||||
#define HAVE_IOCTL_FIONBIO 1
|
||||
|
||||
/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */
|
||||
#define HAVE_IOCTL_SIOCGIFADDR 1
|
||||
|
||||
/* Define to 1 if you have the `resolve' library (-lresolve). */
|
||||
/* #undef HAVE_LIBRESOLVE */
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* if your compiler supports LL */
|
||||
#define HAVE_LL 1
|
||||
|
||||
/* Define to 1 if the compiler supports the 'long long' data type. */
|
||||
#define HAVE_LONGLONG 1
|
||||
|
||||
/* Define to 1 if you have the malloc.h header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the memory.h header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the MSG_NOSIGNAL flag. */
|
||||
#define HAVE_MSG_NOSIGNAL 1
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#define HAVE_NETDB_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/tcp.h> header file. */
|
||||
#define HAVE_NETINET_TCP_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/if.h> header file. */
|
||||
#define HAVE_NET_IF_H 1
|
||||
|
||||
/* Define to 1 if you have PF_INET6. */
|
||||
#define HAVE_PF_INET6 1
|
||||
|
||||
/* Define to 1 if you have the recv function. */
|
||||
#define HAVE_RECV 1
|
||||
|
||||
/* Define to 1 if you have the recvfrom function. */
|
||||
#define HAVE_RECVFROM 1
|
||||
|
||||
/* Define to 1 if you have the send function. */
|
||||
#define HAVE_SEND 1
|
||||
|
||||
/* Define to 1 if you have the setsockopt function. */
|
||||
#define HAVE_SETSOCKOPT 1
|
||||
|
||||
/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
|
||||
/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is an available typedef. */
|
||||
#define HAVE_SIG_ATOMIC_T 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is already defined as volatile. */
|
||||
/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */
|
||||
|
||||
/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */
|
||||
#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
|
||||
|
||||
/* Define to 1 if you have the socket function. */
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if you have the <socket.h> header file. */
|
||||
/* #undef HAVE_SOCKET_H */
|
||||
|
||||
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||
#define HAVE_STDBOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the strcasecmp function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strcmpi function. */
|
||||
/* #undef HAVE_STRCMPI */
|
||||
|
||||
/* Define to 1 if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define to 1 if you have the stricmp function. */
|
||||
/* #undef HAVE_STRICMP */
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the strncasecmp function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strncmpi function. */
|
||||
/* #undef HAVE_STRNCMPI */
|
||||
|
||||
/* Define to 1 if you have the strnicmp function. */
|
||||
/* #undef HAVE_STRNICMP */
|
||||
|
||||
/* Define to 1 if you have the <stropts.h> header file. */
|
||||
#define HAVE_STROPTS_H 1
|
||||
|
||||
/* Define to 1 if you have struct addrinfo. */
|
||||
#define HAVE_STRUCT_ADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have struct in6_addr. */
|
||||
#define HAVE_STRUCT_IN6_ADDR 1
|
||||
|
||||
/* Define to 1 if you have struct sockaddr_in6. */
|
||||
#define HAVE_STRUCT_SOCKADDR_IN6 1
|
||||
|
||||
/* if struct sockaddr_storage is defined */
|
||||
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
|
||||
|
||||
/* Define to 1 if you have the timeval struct. */
|
||||
#define HAVE_STRUCT_TIMEVAL 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#define HAVE_SYS_UIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the windows.h header file. */
|
||||
/* #undef HAVE_WINDOWS_H */
|
||||
|
||||
/* Define to 1 if you have the winsock2.h header file. */
|
||||
/* #undef HAVE_WINSOCK2_H */
|
||||
|
||||
/* Define to 1 if you have the winsock.h header file. */
|
||||
/* #undef HAVE_WINSOCK_H */
|
||||
|
||||
/* Define to 1 if you have the writev function. */
|
||||
#define HAVE_WRITEV 1
|
||||
|
||||
/* Define to 1 if you have the ws2tcpip.h header file. */
|
||||
/* #undef HAVE_WS2TCPIP_H */
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to 1 if you are building a native Windows target. */
|
||||
/* #undef NATIVE_WINDOWS */
|
||||
|
||||
/* Define to 1 if you need the malloc.h header file even with stdlib.h */
|
||||
/* #undef NEED_MALLOC_H */
|
||||
|
||||
/* Define to 1 if you need the memory.h header file even with stdlib.h */
|
||||
/* #undef NEED_MEMORY_H */
|
||||
|
||||
/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
|
||||
/* #undef NEED_REENTRANT */
|
||||
|
||||
/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
|
||||
/* #undef NEED_THREAD_SAFE */
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* cpu-machine-OS */
|
||||
#define OS "i686-pc-linux-gnu"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "c-ares"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "c-ares mailing list => http://cool.haxx.se/mailman/listinfo/c-ares"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "c-ares"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "c-ares 1.7.1"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "c-ares"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.7.1"
|
||||
|
||||
/* a suitable file/device to read random data from */
|
||||
#define RANDOM_FILE "/dev/urandom"
|
||||
|
||||
/* Define to the type of arg 1 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type pointed by arg 2 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG2 void
|
||||
|
||||
/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */
|
||||
#define RECVFROM_TYPE_ARG2_IS_VOID 1
|
||||
|
||||
/* Define to the type of arg 3 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG4 int
|
||||
|
||||
/* Define to the type pointed by arg 5 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG5 struct sockaddr
|
||||
|
||||
/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG5_IS_VOID */
|
||||
|
||||
/* Define to the type pointed by arg 6 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG6 socklen_t
|
||||
|
||||
/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG6_IS_VOID */
|
||||
|
||||
/* Define to the function return type for recvfrom. */
|
||||
#define RECVFROM_TYPE_RETV int
|
||||
|
||||
/* Define to the type of arg 1 for recv. */
|
||||
#define RECV_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for recv. */
|
||||
#define RECV_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for recv. */
|
||||
#define RECV_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recv. */
|
||||
#define RECV_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for recv. */
|
||||
#define RECV_TYPE_RETV int
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to the type qualifier of arg 2 for send. */
|
||||
#define SEND_QUAL_ARG2 const
|
||||
|
||||
/* Define to the type of arg 1 for send. */
|
||||
#define SEND_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for send. */
|
||||
#define SEND_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for send. */
|
||||
#define SEND_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for send. */
|
||||
#define SEND_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for send. */
|
||||
#define SEND_TYPE_RETV int
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#define SIZEOF_SIZE_T 4
|
||||
|
||||
/* The size of `struct in6_addr', as computed by sizeof. */
|
||||
#define SIZEOF_STRUCT_IN6_ADDR 16
|
||||
|
||||
/* The size of `struct in_addr', as computed by sizeof. */
|
||||
#define SIZEOF_STRUCT_IN_ADDR 4
|
||||
|
||||
/* The size of `time_t', as computed by sizeof. */
|
||||
#define SIZEOF_TIME_T 4
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Define to disable non-blocking sockets. */
|
||||
/* #undef USE_BLOCKING_SOCKETS */
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.7.1"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define to 1 if OS is AIX. */
|
||||
#ifndef _ALL_SOURCE
|
||||
/* # undef _ALL_SOURCE */
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Type to use in place of in_addr_t when system does not provide it. */
|
||||
/* #undef in_addr_t */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* the signed version of size_t */
|
||||
/* #undef ssize_t */
|
|
@ -0,0 +1,510 @@
|
|||
/* ares_config.h. Generated from ares_config.h.in by configure. */
|
||||
/* ares_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* define this if ares is built for a big endian system */
|
||||
/* #undef ARES_BIG_ENDIAN */
|
||||
|
||||
/* when building as static part of libcurl */
|
||||
/* #undef BUILDING_LIBCURL */
|
||||
|
||||
/* when building c-ares library */
|
||||
/* #undef CARES_BUILDING_LIBRARY */
|
||||
|
||||
/* when not building a shared library */
|
||||
/* #undef CARES_STATICLIB */
|
||||
|
||||
/* Define to 1 to enable hiding of library internal symbols. */
|
||||
/* #undef CARES_SYMBOL_HIDING */
|
||||
|
||||
/* Definition to make a library symbol externally visible. */
|
||||
/* #undef CARES_SYMBOL_SCOPE_EXTERN */
|
||||
|
||||
/* if a /etc/inet dir is being used */
|
||||
/* #undef ETC_INET */
|
||||
|
||||
/* Define to the type qualifier of arg 1 for getnameinfo. */
|
||||
#define GETNAMEINFO_QUAL_ARG1 const
|
||||
|
||||
/* Define to the type of arg 1 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG1 struct sockaddr *
|
||||
|
||||
/* Define to the type of arg 2 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG2 socklen_t
|
||||
|
||||
/* Define to the type of args 4 and 6 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG46 size_t
|
||||
|
||||
/* Define to the type of arg 7 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG7 int
|
||||
|
||||
/* Specifies the number of arguments to getservbyport_r */
|
||||
#define GETSERVBYPORT_R_ARGS 4
|
||||
|
||||
/* Specifies the size of the buffer to pass to getservbyport_r */
|
||||
#define GETSERVBYPORT_R_BUFSIZE sizeof(struct servent_data)
|
||||
|
||||
/* Define to 1 if you have AF_INET6. */
|
||||
#define HAVE_AF_INET6 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */
|
||||
/* #undef HAVE_ARPA_NAMESER_COMPAT_H */
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_H 1
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the `bitncmp' function. */
|
||||
/* #undef HAVE_BITNCMP */
|
||||
|
||||
/* Define to 1 if bool is an available type. */
|
||||
#define HAVE_BOOL_T 1
|
||||
|
||||
/* Define to 1 if you have the clock_gettime function and monotonic timer. */
|
||||
#define HAVE_CLOCK_GETTIME_MONOTONIC 1
|
||||
|
||||
/* Define to 1 if you have the closesocket function. */
|
||||
/* #undef HAVE_CLOSESOCKET */
|
||||
|
||||
/* Define to 1 if you have the CloseSocket camel case function. */
|
||||
/* #undef HAVE_CLOSESOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have the connect function. */
|
||||
#define HAVE_CONNECT 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the fcntl function. */
|
||||
#define HAVE_FCNTL 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
|
||||
#define HAVE_FCNTL_O_NONBLOCK 1
|
||||
|
||||
/* Define to 1 if you have the freeaddrinfo function. */
|
||||
#define HAVE_FREEADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have a working getaddrinfo function. */
|
||||
#define HAVE_GETADDRINFO 1
|
||||
|
||||
/* Define to 1 if the getaddrinfo function is threadsafe. */
|
||||
/* #undef HAVE_GETADDRINFO_THREADSAFE */
|
||||
|
||||
/* Define to 1 if you have the gethostbyaddr function. */
|
||||
#define HAVE_GETHOSTBYADDR 1
|
||||
|
||||
/* Define to 1 if you have the gethostbyname function. */
|
||||
#define HAVE_GETHOSTBYNAME 1
|
||||
|
||||
/* Define to 1 if you have the gethostname function. */
|
||||
#define HAVE_GETHOSTNAME 1
|
||||
|
||||
/* Define to 1 if you have the getnameinfo function. */
|
||||
#define HAVE_GETNAMEINFO 1
|
||||
|
||||
/* Define to 1 if you have the getservbyport_r function. */
|
||||
#define HAVE_GETSERVBYPORT_R 1
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the `if_indextoname' function. */
|
||||
#define HAVE_IF_INDEXTONAME 1
|
||||
|
||||
/* Define to 1 if you have the `inet_net_pton' function. */
|
||||
#define HAVE_INET_NET_PTON 1
|
||||
|
||||
/* Define to 1 if inet_net_pton supports IPv6. */
|
||||
/* #undef HAVE_INET_NET_PTON_IPV6 */
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_ntop function. */
|
||||
#define HAVE_INET_NTOP 1
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_pton function. */
|
||||
#define HAVE_INET_PTON 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the ioctl function. */
|
||||
#define HAVE_IOCTL 1
|
||||
|
||||
/* Define to 1 if you have the ioctlsocket function. */
|
||||
/* #undef HAVE_IOCTLSOCKET */
|
||||
|
||||
/* Define to 1 if you have the IoctlSocket camel case function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function.
|
||||
*/
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctl FIONBIO function. */
|
||||
#define HAVE_IOCTL_FIONBIO 1
|
||||
|
||||
/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */
|
||||
#define HAVE_IOCTL_SIOCGIFADDR 1
|
||||
|
||||
/* Define to 1 if you have the `resolve' library (-lresolve). */
|
||||
/* #undef HAVE_LIBRESOLVE */
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* if your compiler supports LL */
|
||||
#define HAVE_LL 1
|
||||
|
||||
/* Define to 1 if the compiler supports the 'long long' data type. */
|
||||
#define HAVE_LONGLONG 1
|
||||
|
||||
/* Define to 1 if you have the malloc.h header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the memory.h header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the MSG_NOSIGNAL flag. */
|
||||
/* #undef HAVE_MSG_NOSIGNAL */
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#define HAVE_NETDB_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/tcp.h> header file. */
|
||||
#define HAVE_NETINET_TCP_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/if.h> header file. */
|
||||
#define HAVE_NET_IF_H 1
|
||||
|
||||
/* Define to 1 if you have PF_INET6. */
|
||||
#define HAVE_PF_INET6 1
|
||||
|
||||
/* Define to 1 if you have the recv function. */
|
||||
#define HAVE_RECV 1
|
||||
|
||||
/* Define to 1 if you have the recvfrom function. */
|
||||
#define HAVE_RECVFROM 1
|
||||
|
||||
/* Define to 1 if you have the send function. */
|
||||
#define HAVE_SEND 1
|
||||
|
||||
/* Define to 1 if you have the setsockopt function. */
|
||||
#define HAVE_SETSOCKOPT 1
|
||||
|
||||
/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
|
||||
/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is an available typedef. */
|
||||
#define HAVE_SIG_ATOMIC_T 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is already defined as volatile. */
|
||||
/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */
|
||||
|
||||
/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */
|
||||
#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
|
||||
|
||||
/* Define to 1 if you have the socket function. */
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if you have the <socket.h> header file. */
|
||||
/* #undef HAVE_SOCKET_H */
|
||||
|
||||
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||
#define HAVE_STDBOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the strcasecmp function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strcmpi function. */
|
||||
/* #undef HAVE_STRCMPI */
|
||||
|
||||
/* Define to 1 if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define to 1 if you have the stricmp function. */
|
||||
/* #undef HAVE_STRICMP */
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the strncasecmp function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strncmpi function. */
|
||||
/* #undef HAVE_STRNCMPI */
|
||||
|
||||
/* Define to 1 if you have the strnicmp function. */
|
||||
/* #undef HAVE_STRNICMP */
|
||||
|
||||
/* Define to 1 if you have the <stropts.h> header file. */
|
||||
/* #undef HAVE_STROPTS_H */
|
||||
|
||||
/* Define to 1 if you have struct addrinfo. */
|
||||
#define HAVE_STRUCT_ADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have struct in6_addr. */
|
||||
#define HAVE_STRUCT_IN6_ADDR 1
|
||||
|
||||
/* Define to 1 if you have struct sockaddr_in6. */
|
||||
#define HAVE_STRUCT_SOCKADDR_IN6 1
|
||||
|
||||
/* if struct sockaddr_storage is defined */
|
||||
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
|
||||
|
||||
/* Define to 1 if you have the timeval struct. */
|
||||
#define HAVE_STRUCT_TIMEVAL 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#define HAVE_SYS_UIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the windows.h header file. */
|
||||
/* #undef HAVE_WINDOWS_H */
|
||||
|
||||
/* Define to 1 if you have the winsock2.h header file. */
|
||||
/* #undef HAVE_WINSOCK2_H */
|
||||
|
||||
/* Define to 1 if you have the winsock.h header file. */
|
||||
/* #undef HAVE_WINSOCK_H */
|
||||
|
||||
/* Define to 1 if you have the writev function. */
|
||||
#define HAVE_WRITEV 1
|
||||
|
||||
/* Define to 1 if you have the ws2tcpip.h header file. */
|
||||
/* #undef HAVE_WS2TCPIP_H */
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to 1 if you are building a native Windows target. */
|
||||
/* #undef NATIVE_WINDOWS */
|
||||
|
||||
/* Define to 1 if you need the malloc.h header file even with stdlib.h */
|
||||
/* #undef NEED_MALLOC_H */
|
||||
|
||||
/* Define to 1 if you need the memory.h header file even with stdlib.h */
|
||||
/* #undef NEED_MEMORY_H */
|
||||
|
||||
/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
|
||||
/* #undef NEED_REENTRANT */
|
||||
|
||||
/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
|
||||
/* #undef NEED_THREAD_SAFE */
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* cpu-machine-OS */
|
||||
#define OS "i386-unknown-openbsd4.7"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "c-ares"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "c-ares mailing list => http://cool.haxx.se/mailman/listinfo/c-ares"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "c-ares"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "c-ares 1.7.1"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "c-ares"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.7.1"
|
||||
|
||||
/* a suitable file/device to read random data from */
|
||||
#define RANDOM_FILE "/dev/urandom"
|
||||
|
||||
/* Define to the type of arg 1 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type pointed by arg 2 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG2 void
|
||||
|
||||
/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */
|
||||
#define RECVFROM_TYPE_ARG2_IS_VOID 1
|
||||
|
||||
/* Define to the type of arg 3 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG4 int
|
||||
|
||||
/* Define to the type pointed by arg 5 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG5 struct sockaddr
|
||||
|
||||
/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG5_IS_VOID */
|
||||
|
||||
/* Define to the type pointed by arg 6 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG6 socklen_t
|
||||
|
||||
/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG6_IS_VOID */
|
||||
|
||||
/* Define to the function return type for recvfrom. */
|
||||
#define RECVFROM_TYPE_RETV int
|
||||
|
||||
/* Define to the type of arg 1 for recv. */
|
||||
#define RECV_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for recv. */
|
||||
#define RECV_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for recv. */
|
||||
#define RECV_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recv. */
|
||||
#define RECV_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for recv. */
|
||||
#define RECV_TYPE_RETV int
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to the type qualifier of arg 2 for send. */
|
||||
#define SEND_QUAL_ARG2 const
|
||||
|
||||
/* Define to the type of arg 1 for send. */
|
||||
#define SEND_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for send. */
|
||||
#define SEND_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for send. */
|
||||
#define SEND_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for send. */
|
||||
#define SEND_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for send. */
|
||||
#define SEND_TYPE_RETV int
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#define SIZEOF_SIZE_T 4
|
||||
|
||||
/* The size of `struct in6_addr', as computed by sizeof. */
|
||||
#define SIZEOF_STRUCT_IN6_ADDR 16
|
||||
|
||||
/* The size of `struct in_addr', as computed by sizeof. */
|
||||
#define SIZEOF_STRUCT_IN_ADDR 4
|
||||
|
||||
/* The size of `time_t', as computed by sizeof. */
|
||||
#define SIZEOF_TIME_T 4
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Define to disable non-blocking sockets. */
|
||||
/* #undef USE_BLOCKING_SOCKETS */
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.7.1"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define to 1 if OS is AIX. */
|
||||
#ifndef _ALL_SOURCE
|
||||
/* # undef _ALL_SOURCE */
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
/* #undef _FILE_OFFSET_BITS */
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Type to use in place of in_addr_t when system does not provide it. */
|
||||
/* #undef in_addr_t */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* the signed version of size_t */
|
||||
/* #undef ssize_t */
|
|
@ -0,0 +1,510 @@
|
|||
/* ares_config.h. Generated from ares_config.h.in by configure. */
|
||||
/* ares_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* define this if ares is built for a big endian system */
|
||||
/* #undef ARES_BIG_ENDIAN */
|
||||
|
||||
/* when building as static part of libcurl */
|
||||
/* #undef BUILDING_LIBCURL */
|
||||
|
||||
/* when building c-ares library */
|
||||
/* #undef CARES_BUILDING_LIBRARY */
|
||||
|
||||
/* when not building a shared library */
|
||||
/* #undef CARES_STATICLIB */
|
||||
|
||||
/* Define to 1 to enable hiding of library internal symbols. */
|
||||
/* #undef CARES_SYMBOL_HIDING */
|
||||
|
||||
/* Definition to make a library symbol externally visible. */
|
||||
/* #undef CARES_SYMBOL_SCOPE_EXTERN */
|
||||
|
||||
/* if a /etc/inet dir is being used */
|
||||
#define ETC_INET 1
|
||||
|
||||
/* Define to the type qualifier of arg 1 for getnameinfo. */
|
||||
#define GETNAMEINFO_QUAL_ARG1 const
|
||||
|
||||
/* Define to the type of arg 1 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG1 struct sockaddr *
|
||||
|
||||
/* Define to the type of arg 2 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG2 socklen_t
|
||||
|
||||
/* Define to the type of args 4 and 6 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG46 size_t
|
||||
|
||||
/* Define to the type of arg 7 for getnameinfo. */
|
||||
#define GETNAMEINFO_TYPE_ARG7 int
|
||||
|
||||
/* Specifies the number of arguments to getservbyport_r */
|
||||
#define GETSERVBYPORT_R_ARGS 5
|
||||
|
||||
/* Specifies the size of the buffer to pass to getservbyport_r */
|
||||
#define GETSERVBYPORT_R_BUFSIZE 4096
|
||||
|
||||
/* Define to 1 if you have AF_INET6. */
|
||||
#define HAVE_AF_INET6 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_COMPAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_H 1
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the `bitncmp' function. */
|
||||
/* #undef HAVE_BITNCMP */
|
||||
|
||||
/* Define to 1 if bool is an available type. */
|
||||
#define HAVE_BOOL_T 1
|
||||
|
||||
/* Define to 1 if you have the clock_gettime function and monotonic timer. */
|
||||
#define HAVE_CLOCK_GETTIME_MONOTONIC 1
|
||||
|
||||
/* Define to 1 if you have the closesocket function. */
|
||||
/* #undef HAVE_CLOSESOCKET */
|
||||
|
||||
/* Define to 1 if you have the CloseSocket camel case function. */
|
||||
/* #undef HAVE_CLOSESOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have the connect function. */
|
||||
#define HAVE_CONNECT 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the fcntl function. */
|
||||
#define HAVE_FCNTL 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
|
||||
#define HAVE_FCNTL_O_NONBLOCK 1
|
||||
|
||||
/* Define to 1 if you have the freeaddrinfo function. */
|
||||
#define HAVE_FREEADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have a working getaddrinfo function. */
|
||||
#define HAVE_GETADDRINFO 1
|
||||
|
||||
/* Define to 1 if the getaddrinfo function is threadsafe. */
|
||||
#define HAVE_GETADDRINFO_THREADSAFE 1
|
||||
|
||||
/* Define to 1 if you have the gethostbyaddr function. */
|
||||
#define HAVE_GETHOSTBYADDR 1
|
||||
|
||||
/* Define to 1 if you have the gethostbyname function. */
|
||||
#define HAVE_GETHOSTBYNAME 1
|
||||
|
||||
/* Define to 1 if you have the gethostname function. */
|
||||
#define HAVE_GETHOSTNAME 1
|
||||
|
||||
/* Define to 1 if you have the getnameinfo function. */
|
||||
#define HAVE_GETNAMEINFO 1
|
||||
|
||||
/* Define to 1 if you have the getservbyport_r function. */
|
||||
#define HAVE_GETSERVBYPORT_R 1
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the `if_indextoname' function. */
|
||||
#define HAVE_IF_INDEXTONAME 1
|
||||
|
||||
/* Define to 1 if you have the `inet_net_pton' function. */
|
||||
/* #undef HAVE_INET_NET_PTON */
|
||||
|
||||
/* Define to 1 if inet_net_pton supports IPv6. */
|
||||
/* #undef HAVE_INET_NET_PTON_IPV6 */
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_ntop function. */
|
||||
#define HAVE_INET_NTOP 1
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_pton function. */
|
||||
#define HAVE_INET_PTON 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the ioctl function. */
|
||||
#define HAVE_IOCTL 1
|
||||
|
||||
/* Define to 1 if you have the ioctlsocket function. */
|
||||
/* #undef HAVE_IOCTLSOCKET */
|
||||
|
||||
/* Define to 1 if you have the IoctlSocket camel case function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function.
|
||||
*/
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctl FIONBIO function. */
|
||||
/* #undef HAVE_IOCTL_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */
|
||||
/* #undef HAVE_IOCTL_SIOCGIFADDR */
|
||||
|
||||
/* Define to 1 if you have the `resolve' library (-lresolve). */
|
||||
/* #undef HAVE_LIBRESOLVE */
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* if your compiler supports LL */
|
||||
#define HAVE_LL 1
|
||||
|
||||
/* Define to 1 if the compiler supports the 'long long' data type. */
|
||||
#define HAVE_LONGLONG 1
|
||||
|
||||
/* Define to 1 if you have the malloc.h header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the memory.h header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the MSG_NOSIGNAL flag. */
|
||||
/* #undef HAVE_MSG_NOSIGNAL */
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#define HAVE_NETDB_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/tcp.h> header file. */
|
||||
#define HAVE_NETINET_TCP_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/if.h> header file. */
|
||||
#define HAVE_NET_IF_H 1
|
||||
|
||||
/* Define to 1 if you have PF_INET6. */
|
||||
#define HAVE_PF_INET6 1
|
||||
|
||||
/* Define to 1 if you have the recv function. */
|
||||
#define HAVE_RECV 1
|
||||
|
||||
/* Define to 1 if you have the recvfrom function. */
|
||||
#define HAVE_RECVFROM 1
|
||||
|
||||
/* Define to 1 if you have the send function. */
|
||||
#define HAVE_SEND 1
|
||||
|
||||
/* Define to 1 if you have the setsockopt function. */
|
||||
#define HAVE_SETSOCKOPT 1
|
||||
|
||||
/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
|
||||
/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is an available typedef. */
|
||||
#define HAVE_SIG_ATOMIC_T 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is already defined as volatile. */
|
||||
/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */
|
||||
|
||||
/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */
|
||||
#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
|
||||
|
||||
/* Define to 1 if you have the socket function. */
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if you have the <socket.h> header file. */
|
||||
/* #undef HAVE_SOCKET_H */
|
||||
|
||||
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||
#define HAVE_STDBOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the strcasecmp function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strcmpi function. */
|
||||
/* #undef HAVE_STRCMPI */
|
||||
|
||||
/* Define to 1 if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define to 1 if you have the stricmp function. */
|
||||
/* #undef HAVE_STRICMP */
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the strncasecmp function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strncmpi function. */
|
||||
/* #undef HAVE_STRNCMPI */
|
||||
|
||||
/* Define to 1 if you have the strnicmp function. */
|
||||
/* #undef HAVE_STRNICMP */
|
||||
|
||||
/* Define to 1 if you have the <stropts.h> header file. */
|
||||
#define HAVE_STROPTS_H 1
|
||||
|
||||
/* Define to 1 if you have struct addrinfo. */
|
||||
#define HAVE_STRUCT_ADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have struct in6_addr. */
|
||||
#define HAVE_STRUCT_IN6_ADDR 1
|
||||
|
||||
/* Define to 1 if you have struct sockaddr_in6. */
|
||||
#define HAVE_STRUCT_SOCKADDR_IN6 1
|
||||
|
||||
/* if struct sockaddr_storage is defined */
|
||||
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
|
||||
|
||||
/* Define to 1 if you have the timeval struct. */
|
||||
#define HAVE_STRUCT_TIMEVAL 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#define HAVE_SYS_UIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the windows.h header file. */
|
||||
/* #undef HAVE_WINDOWS_H */
|
||||
|
||||
/* Define to 1 if you have the winsock2.h header file. */
|
||||
/* #undef HAVE_WINSOCK2_H */
|
||||
|
||||
/* Define to 1 if you have the winsock.h header file. */
|
||||
/* #undef HAVE_WINSOCK_H */
|
||||
|
||||
/* Define to 1 if you have the writev function. */
|
||||
#define HAVE_WRITEV 1
|
||||
|
||||
/* Define to 1 if you have the ws2tcpip.h header file. */
|
||||
/* #undef HAVE_WS2TCPIP_H */
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to 1 if you are building a native Windows target. */
|
||||
/* #undef NATIVE_WINDOWS */
|
||||
|
||||
/* Define to 1 if you need the malloc.h header file even with stdlib.h */
|
||||
/* #undef NEED_MALLOC_H */
|
||||
|
||||
/* Define to 1 if you need the memory.h header file even with stdlib.h */
|
||||
/* #undef NEED_MEMORY_H */
|
||||
|
||||
/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
|
||||
#define NEED_REENTRANT 1
|
||||
|
||||
/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
|
||||
/* #undef NEED_THREAD_SAFE */
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* cpu-machine-OS */
|
||||
#define OS "i386-pc-solaris2.11"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "c-ares"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "c-ares mailing list => http://cool.haxx.se/mailman/listinfo/c-ares"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "c-ares"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "c-ares 1.7.1"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "c-ares"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.7.1"
|
||||
|
||||
/* a suitable file/device to read random data from */
|
||||
#define RANDOM_FILE "/dev/urandom"
|
||||
|
||||
/* Define to the type of arg 1 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type pointed by arg 2 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG2 void
|
||||
|
||||
/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */
|
||||
#define RECVFROM_TYPE_ARG2_IS_VOID 1
|
||||
|
||||
/* Define to the type of arg 3 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG4 int
|
||||
|
||||
/* Define to the type pointed by arg 5 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG5 struct sockaddr
|
||||
|
||||
/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG5_IS_VOID */
|
||||
|
||||
/* Define to the type pointed by arg 6 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG6 void
|
||||
|
||||
/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */
|
||||
#define RECVFROM_TYPE_ARG6_IS_VOID 1
|
||||
|
||||
/* Define to the function return type for recvfrom. */
|
||||
#define RECVFROM_TYPE_RETV int
|
||||
|
||||
/* Define to the type of arg 1 for recv. */
|
||||
#define RECV_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for recv. */
|
||||
#define RECV_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for recv. */
|
||||
#define RECV_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recv. */
|
||||
#define RECV_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for recv. */
|
||||
#define RECV_TYPE_RETV int
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to the type qualifier of arg 2 for send. */
|
||||
#define SEND_QUAL_ARG2 const
|
||||
|
||||
/* Define to the type of arg 1 for send. */
|
||||
#define SEND_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for send. */
|
||||
#define SEND_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for send. */
|
||||
#define SEND_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for send. */
|
||||
#define SEND_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for send. */
|
||||
#define SEND_TYPE_RETV int
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#define SIZEOF_SIZE_T 4
|
||||
|
||||
/* The size of `struct in6_addr', as computed by sizeof. */
|
||||
#define SIZEOF_STRUCT_IN6_ADDR 16
|
||||
|
||||
/* The size of `struct in_addr', as computed by sizeof. */
|
||||
#define SIZEOF_STRUCT_IN_ADDR 4
|
||||
|
||||
/* The size of `time_t', as computed by sizeof. */
|
||||
#define SIZEOF_TIME_T 4
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Define to disable non-blocking sockets. */
|
||||
/* #undef USE_BLOCKING_SOCKETS */
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.7.1"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define to 1 if OS is AIX. */
|
||||
#ifndef _ALL_SOURCE
|
||||
/* # undef _ALL_SOURCE */
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Type to use in place of in_addr_t when system does not provide it. */
|
||||
/* #undef in_addr_t */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* the signed version of size_t */
|
||||
/* #undef ssize_t */
|
|
@ -0,0 +1,369 @@
|
|||
#ifndef __ARES_CONFIG_WIN32_H
|
||||
#define __ARES_CONFIG_WIN32_H
|
||||
|
||||
/* when building c-ares library */
|
||||
#define CARES_BUILDING_LIBRARY 1
|
||||
|
||||
/* when not building a shared library */
|
||||
#define CARES_STATICLIB 1
|
||||
|
||||
/* Copyright (C) 2004 - 2008 by Daniel Stenberg et al
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define ARES_
|
||||
|
||||
/* ================================================================ */
|
||||
/* ares/config-win32.h - Hand crafted config file for Windows */
|
||||
/* ================================================================ */
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* HEADER FILES */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Define if you have the <getopt.h> header file. */
|
||||
#if defined(__MINGW32__) || defined(__POCC__)
|
||||
#define HAVE_GETOPT_H 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define if you have the <process.h> header file. */
|
||||
#ifndef __SALFORDC__
|
||||
#define HAVE_PROCESS_H 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define if you have the <sys/time.h> header file */
|
||||
#if defined(__MINGW32__)
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#if defined(__MINGW32__) || defined(__WATCOMC__) || defined(__LCC__) || \
|
||||
defined(__POCC__)
|
||||
#define HAVE_UNISTD_H 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the windows.h header file. */
|
||||
#define HAVE_WINDOWS_H 1
|
||||
|
||||
/* Define if you have the <winsock.h> header file. */
|
||||
#define HAVE_WINSOCK_H 1
|
||||
|
||||
/* Define if you have the <winsock2.h> header file. */
|
||||
#ifndef __SALFORDC__
|
||||
#define HAVE_WINSOCK2_H 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the <ws2tcpip.h> header file. */
|
||||
#ifndef __SALFORDC__
|
||||
#define HAVE_WS2TCPIP_H 1
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* OTHER HEADER INFO */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Define if sig_atomic_t is an available typedef. */
|
||||
#define HAVE_SIG_ATOMIC_T 1
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
/* #define TIME_WITH_SYS_TIME 1 */
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* FUNCTIONS */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Define if you have the closesocket function. */
|
||||
#define HAVE_CLOSESOCKET 1
|
||||
|
||||
/* Define if you have the gethostname function. */
|
||||
#define HAVE_GETHOSTNAME 1
|
||||
|
||||
/* Define if you have the ioctlsocket function. */
|
||||
#define HAVE_IOCTLSOCKET 1
|
||||
|
||||
/* Define if you have a working ioctlsocket FIONBIO function. */
|
||||
#define HAVE_IOCTLSOCKET_FIONBIO 1
|
||||
|
||||
/* Define if you have the strcasecmp function. */
|
||||
/* #define HAVE_STRCASECMP 1 */
|
||||
|
||||
/* Define if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define if you have the stricmp function. */
|
||||
#define HAVE_STRICMP 1
|
||||
|
||||
/* Define if you have the strncasecmp function. */
|
||||
/* #define HAVE_STRNCASECMP 1 */
|
||||
|
||||
/* Define if you have the strnicmp function. */
|
||||
#define HAVE_STRNICMP 1
|
||||
|
||||
/* Define if you have the recv function. */
|
||||
#define HAVE_RECV 1
|
||||
|
||||
/* Define to the type of arg 1 for recv. */
|
||||
#define RECV_TYPE_ARG1 SOCKET
|
||||
|
||||
/* Define to the type of arg 2 for recv. */
|
||||
#define RECV_TYPE_ARG2 char *
|
||||
|
||||
/* Define to the type of arg 3 for recv. */
|
||||
#define RECV_TYPE_ARG3 int
|
||||
|
||||
/* Define to the type of arg 4 for recv. */
|
||||
#define RECV_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for recv. */
|
||||
#define RECV_TYPE_RETV int
|
||||
|
||||
/* Define if you have the recvfrom function. */
|
||||
#define HAVE_RECVFROM 1
|
||||
|
||||
/* Define to the type of arg 1 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG1 SOCKET
|
||||
|
||||
/* Define to the type pointed by arg 2 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG2 char
|
||||
|
||||
/* Define to the type of arg 3 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG3 int
|
||||
|
||||
/* Define to the type of arg 4 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG4 int
|
||||
|
||||
/* Define to the type pointed by arg 5 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG5 struct sockaddr
|
||||
|
||||
/* Define to the type pointed by arg 6 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG6 int
|
||||
|
||||
/* Define to the function return type for recvfrom. */
|
||||
#define RECVFROM_TYPE_RETV int
|
||||
|
||||
/* Define if you have the send function. */
|
||||
#define HAVE_SEND 1
|
||||
|
||||
/* Define to the type of arg 1 for send. */
|
||||
#define SEND_TYPE_ARG1 SOCKET
|
||||
|
||||
/* Define to the type qualifier of arg 2 for send. */
|
||||
#define SEND_QUAL_ARG2 const
|
||||
|
||||
/* Define to the type of arg 2 for send. */
|
||||
#define SEND_TYPE_ARG2 char *
|
||||
|
||||
/* Define to the type of arg 3 for send. */
|
||||
#define SEND_TYPE_ARG3 int
|
||||
|
||||
/* Define to the type of arg 4 for send. */
|
||||
#define SEND_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for send. */
|
||||
#define SEND_TYPE_RETV int
|
||||
|
||||
/* Specifics for the Watt-32 tcp/ip stack */
|
||||
#ifdef WATT32
|
||||
#define SOCKET int
|
||||
#define NS_INADDRSZ 4
|
||||
#define HAVE_ARPA_NAMESER_H 1
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
#define HAVE_NETDB_H 1
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
#define HAVE_NETINET_TCP_H 1
|
||||
#define HAVE_AF_INET6 1
|
||||
#define HAVE_PF_INET6 1
|
||||
#define HAVE_STRUCT_IN6_ADDR 1
|
||||
#define HAVE_STRUCT_SOCKADDR_IN6 1
|
||||
#undef HAVE_WINSOCK_H
|
||||
#undef HAVE_WINSOCK2_H
|
||||
#undef HAVE_WS2TCPIP_H
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* TYPEDEF REPLACEMENTS */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Define this if in_addr_t is not an available 'typedefed' type */
|
||||
#define in_addr_t unsigned long
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define ssize_t if it is not an available 'typedefed' type */
|
||||
#ifndef _SSIZE_T_DEFINED
|
||||
# if (defined(__WATCOMC__) && (__WATCOMC__ >= 1240)) || \
|
||||
defined(__POCC__) || \
|
||||
defined(__MINGW32__)
|
||||
# elif defined(_WIN64)
|
||||
# define _SSIZE_T_DEFINED
|
||||
# define ssize_t __int64
|
||||
# else
|
||||
# define _SSIZE_T_DEFINED
|
||||
# define ssize_t int
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* TYPE SIZES */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of `short', as computed by sizeof. */
|
||||
#define SIZEOF_SHORT 2
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#if defined(_WIN64)
|
||||
# define SIZEOF_SIZE_T 8
|
||||
#else
|
||||
# define SIZEOF_SIZE_T 4
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* STRUCT RELATED */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Define this if you have struct addrinfo */
|
||||
#define HAVE_STRUCT_ADDRINFO 1
|
||||
|
||||
/* Define this if you have struct sockaddr_storage */
|
||||
#ifndef __SALFORDC__
|
||||
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
|
||||
#endif
|
||||
|
||||
/* Define this if you have struct timeval */
|
||||
#define HAVE_STRUCT_TIMEVAL 1
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* COMPILER SPECIFIC */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Define to avoid VS2005 complaining about portable C functions */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
||||
#endif
|
||||
|
||||
/* Officially, Microsoft's Windows SDK versions 6.X do not support Windows
|
||||
2000 as a supported build target. VS2008 default installations provide an
|
||||
embedded Windows SDK v6.0A along with the claim that Windows 2000 is a
|
||||
valid build target for VS2008. Popular belief is that binaries built using
|
||||
Windows SDK versions 6.X and Windows 2000 as a build target are functional */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
|
||||
# define VS2008_MINIMUM_TARGET 0x0500
|
||||
#endif
|
||||
|
||||
/* When no build target is specified VS2008 default build target is Windows
|
||||
Vista, which leaves out even Winsows XP. If no build target has been given
|
||||
for VS2008 we will target the minimum Officially supported build target,
|
||||
which happens to be Windows XP. */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
|
||||
# define VS2008_DEFAULT_TARGET 0x0501
|
||||
#endif
|
||||
|
||||
/* VS2008 default target settings and minimum build target check */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
|
||||
# ifndef _WIN32_WINNT
|
||||
# define _WIN32_WINNT VS2008_DEFAULT_TARGET
|
||||
# endif
|
||||
# ifndef WINVER
|
||||
# define WINVER VS2008_DEFAULT_TARGET
|
||||
# endif
|
||||
# if (_WIN32_WINNT < VS2008_MINIMUM_TARGET) || (WINVER < VS2008_MINIMUM_TARGET)
|
||||
# error VS2008 does not support Windows build targets prior to Windows 2000
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* When no build target is specified Pelles C 5.00 and later default build
|
||||
target is Windows Vista. We override default target to be Windows 2000. */
|
||||
#if defined(__POCC__) && (__POCC__ >= 500)
|
||||
# ifndef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x0500
|
||||
# endif
|
||||
# ifndef WINVER
|
||||
# define WINVER 0x0500
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Availability of freeaddrinfo, getaddrinfo and getnameinfo functions is
|
||||
quite convoluted, compiler dependent and even build target dependent. */
|
||||
#if defined(HAVE_WS2TCPIP_H)
|
||||
# if defined(__POCC__)
|
||||
# define HAVE_FREEADDRINFO 1
|
||||
# define HAVE_GETADDRINFO 1
|
||||
# define HAVE_GETNAMEINFO 1
|
||||
# elif defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501)
|
||||
# define HAVE_FREEADDRINFO 1
|
||||
# define HAVE_GETADDRINFO 1
|
||||
# define HAVE_GETNAMEINFO 1
|
||||
# elif defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# define HAVE_FREEADDRINFO 1
|
||||
# define HAVE_GETADDRINFO 1
|
||||
# define HAVE_GETNAMEINFO 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__POCC__)
|
||||
# ifndef _MSC_VER
|
||||
# error Microsoft extensions /Ze compiler option is required
|
||||
# endif
|
||||
# ifndef __POCC__OLDNAMES
|
||||
# error Compatibility names /Go compiler option is required
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* IPV6 COMPATIBILITY */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Define this if you have address family AF_INET6 */
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#define HAVE_AF_INET6 1
|
||||
#endif
|
||||
|
||||
/* Define this if you have protocol family PF_INET6 */
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#define HAVE_PF_INET6 1
|
||||
#endif
|
||||
|
||||
/* Define this if you have struct in6_addr */
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
#define HAVE_STRUCT_IN6_ADDR 1
|
||||
#endif
|
||||
|
||||
/* Define this if you have struct sockaddr_in6 */
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
#define HAVE_STRUCT_SOCKADDR_IN6 1
|
||||
#endif
|
||||
|
||||
/* Define this if you have sockaddr_in6 with scopeid */
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __ARES_CONFIG_WIN32_H */
|
|
@ -0,0 +1,35 @@
|
|||
# ***************************************************************************
|
||||
# * Project: c-ares
|
||||
# *
|
||||
# ***************************************************************************
|
||||
# awk script which fetches c-ares version number and string from input
|
||||
# file and writes them to STDOUT. Here you can get an awk version for Win32:
|
||||
# http://www.gknw.net/development/prgtools/awk-20070501.zip
|
||||
#
|
||||
BEGIN {
|
||||
if (match (ARGV[1], /ares_version.h/)) {
|
||||
while ((getline < ARGV[1]) > 0) {
|
||||
if (match ($0, /^#define ARES_COPYRIGHT "[^"]+"$/)) {
|
||||
libcares_copyright_str = substr($0, 25, length($0)-25);
|
||||
}
|
||||
else if (match ($0, /^#define ARES_VERSION_STR "[^"]+"$/)) {
|
||||
libcares_ver_str = substr($3, 2, length($3)-2);
|
||||
}
|
||||
else if (match ($0, /^#define ARES_VERSION_MAJOR [0-9]+$/)) {
|
||||
libcares_ver_major = substr($3, 1, length($3));
|
||||
}
|
||||
else if (match ($0, /^#define ARES_VERSION_MINOR [0-9]+$/)) {
|
||||
libcares_ver_minor = substr($3, 1, length($3));
|
||||
}
|
||||
else if (match ($0, /^#define ARES_VERSION_PATCH [0-9]+$/)) {
|
||||
libcares_ver_patch = substr($3, 1, length($3));
|
||||
}
|
||||
}
|
||||
libcares_ver = libcares_ver_major "," libcares_ver_minor "," libcares_ver_patch;
|
||||
print "LIBCARES_VERSION = " libcares_ver "";
|
||||
print "LIBCARES_VERSION_STR = " libcares_ver_str "";
|
||||
print "LIBCARES_COPYRIGHT_STR = " libcares_copyright_str "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,450 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1996,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#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 <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_ipv6.h"
|
||||
#include "inet_net_pton.h"
|
||||
|
||||
|
||||
const struct ares_in6_addr ares_in6addr_any = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } };
|
||||
|
||||
|
||||
#if !defined(HAVE_INET_NET_PTON) || !defined(HAVE_INET_NET_PTON_IPV6)
|
||||
|
||||
/*
|
||||
* static int
|
||||
* inet_net_pton_ipv4(src, dst, size)
|
||||
* convert IPv4 network number from presentation to network format.
|
||||
* accepts hex octets, hex strings, decimal octets, and /CIDR.
|
||||
* "size" is in bytes and describes "dst".
|
||||
* return:
|
||||
* number of bits, either imputed classfully or specified with /CIDR,
|
||||
* or -1 if some failure occurred (check errno). ENOENT means it was
|
||||
* not an IPv4 network specification.
|
||||
* note:
|
||||
* network byte order assumed. this means 192.5.5.240/28 has
|
||||
* 0b11110000 in its fourth octet.
|
||||
* note:
|
||||
* On Windows we store the error in the thread errno, not
|
||||
* in the winsock error code. This is to avoid loosing the
|
||||
* actual last winsock error. So use macro ERRNO to fetch the
|
||||
* errno this funtion sets when returning (-1), not SOCKERRNO.
|
||||
* author:
|
||||
* Paul Vixie (ISC), June 1996
|
||||
*/
|
||||
static int
|
||||
inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
|
||||
{
|
||||
static const char xdigits[] = "0123456789abcdef";
|
||||
static const char digits[] = "0123456789";
|
||||
int n, ch, tmp = 0, dirty, bits;
|
||||
const unsigned char *odst = dst;
|
||||
|
||||
ch = *src++;
|
||||
if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
|
||||
&& ISXDIGIT(src[1])) {
|
||||
/* Hexadecimal: Eat nybble string. */
|
||||
if (!size)
|
||||
goto emsgsize;
|
||||
dirty = 0;
|
||||
src++; /* skip x or X. */
|
||||
while ((ch = *src++) != '\0' && ISXDIGIT(ch)) {
|
||||
if (ISUPPER(ch))
|
||||
ch = tolower(ch);
|
||||
n = (int)(strchr(xdigits, ch) - xdigits);
|
||||
if (dirty == 0)
|
||||
tmp = n;
|
||||
else
|
||||
tmp = (tmp << 4) | n;
|
||||
if (++dirty == 2) {
|
||||
if (!size--)
|
||||
goto emsgsize;
|
||||
*dst++ = (unsigned char) tmp;
|
||||
dirty = 0;
|
||||
}
|
||||
}
|
||||
if (dirty) { /* Odd trailing nybble? */
|
||||
if (!size--)
|
||||
goto emsgsize;
|
||||
*dst++ = (unsigned char) (tmp << 4);
|
||||
}
|
||||
} else if (ISDIGIT(ch)) {
|
||||
/* Decimal: eat dotted digit string. */
|
||||
for (;;) {
|
||||
tmp = 0;
|
||||
do {
|
||||
n = (int)(strchr(digits, ch) - digits);
|
||||
tmp *= 10;
|
||||
tmp += n;
|
||||
if (tmp > 255)
|
||||
goto enoent;
|
||||
} while ((ch = *src++) != '\0' &&
|
||||
ISDIGIT(ch));
|
||||
if (!size--)
|
||||
goto emsgsize;
|
||||
*dst++ = (unsigned char) tmp;
|
||||
if (ch == '\0' || ch == '/')
|
||||
break;
|
||||
if (ch != '.')
|
||||
goto enoent;
|
||||
ch = *src++;
|
||||
if (!ISDIGIT(ch))
|
||||
goto enoent;
|
||||
}
|
||||
} else
|
||||
goto enoent;
|
||||
|
||||
bits = -1;
|
||||
if (ch == '/' &&
|
||||
ISDIGIT(src[0]) && dst > odst) {
|
||||
/* CIDR width specifier. Nothing can follow it. */
|
||||
ch = *src++; /* Skip over the /. */
|
||||
bits = 0;
|
||||
do {
|
||||
n = (int)(strchr(digits, ch) - digits);
|
||||
bits *= 10;
|
||||
bits += n;
|
||||
} while ((ch = *src++) != '\0' && ISDIGIT(ch));
|
||||
if (ch != '\0')
|
||||
goto enoent;
|
||||
if (bits > 32)
|
||||
goto emsgsize;
|
||||
}
|
||||
|
||||
/* Firey death and destruction unless we prefetched EOS. */
|
||||
if (ch != '\0')
|
||||
goto enoent;
|
||||
|
||||
/* If nothing was written to the destination, we found no address. */
|
||||
if (dst == odst)
|
||||
goto enoent;
|
||||
/* If no CIDR spec was given, infer width from net class. */
|
||||
if (bits == -1) {
|
||||
if (*odst >= 240) /* Class E */
|
||||
bits = 32;
|
||||
else if (*odst >= 224) /* Class D */
|
||||
bits = 8;
|
||||
else if (*odst >= 192) /* Class C */
|
||||
bits = 24;
|
||||
else if (*odst >= 128) /* Class B */
|
||||
bits = 16;
|
||||
else /* Class A */
|
||||
bits = 8;
|
||||
/* If imputed mask is narrower than specified octets, widen. */
|
||||
if (bits < ((dst - odst) * 8))
|
||||
bits = (int)(dst - odst) * 8;
|
||||
/*
|
||||
* If there are no additional bits specified for a class D
|
||||
* address adjust bits to 4.
|
||||
*/
|
||||
if (bits == 8 && *odst == 224)
|
||||
bits = 4;
|
||||
}
|
||||
/* Extend network to cover the actual mask. */
|
||||
while (bits > ((dst - odst) * 8)) {
|
||||
if (!size--)
|
||||
goto emsgsize;
|
||||
*dst++ = '\0';
|
||||
}
|
||||
return (bits);
|
||||
|
||||
enoent:
|
||||
SET_ERRNO(ENOENT);
|
||||
return (-1);
|
||||
|
||||
emsgsize:
|
||||
SET_ERRNO(EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int
|
||||
getbits(const char *src, int *bitsp)
|
||||
{
|
||||
static const char digits[] = "0123456789";
|
||||
int n;
|
||||
int val;
|
||||
char ch;
|
||||
|
||||
val = 0;
|
||||
n = 0;
|
||||
while ((ch = *src++) != '\0') {
|
||||
const char *pch;
|
||||
|
||||
pch = strchr(digits, ch);
|
||||
if (pch != NULL) {
|
||||
if (n++ != 0 && val == 0) /* no leading zeros */
|
||||
return (0);
|
||||
val *= 10;
|
||||
val += (pch - digits);
|
||||
if (val > 128) /* range */
|
||||
return (0);
|
||||
continue;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
if (n == 0)
|
||||
return (0);
|
||||
*bitsp = val;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
getv4(const char *src, unsigned char *dst, int *bitsp)
|
||||
{
|
||||
static const char digits[] = "0123456789";
|
||||
unsigned char *odst = dst;
|
||||
int n;
|
||||
unsigned int val;
|
||||
char ch;
|
||||
|
||||
val = 0;
|
||||
n = 0;
|
||||
while ((ch = *src++) != '\0') {
|
||||
const char *pch;
|
||||
|
||||
pch = strchr(digits, ch);
|
||||
if (pch != NULL) {
|
||||
if (n++ != 0 && val == 0) /* no leading zeros */
|
||||
return (0);
|
||||
val *= 10;
|
||||
val += (pch - digits);
|
||||
if (val > 255) /* range */
|
||||
return (0);
|
||||
continue;
|
||||
}
|
||||
if (ch == '.' || ch == '/') {
|
||||
if (dst - odst > 3) /* too many octets? */
|
||||
return (0);
|
||||
*dst++ = (unsigned char)val;
|
||||
if (ch == '/')
|
||||
return (getbits(src, bitsp));
|
||||
val = 0;
|
||||
n = 0;
|
||||
continue;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
if (n == 0)
|
||||
return (0);
|
||||
if (dst - odst > 3) /* too many octets? */
|
||||
return (0);
|
||||
*dst++ = (unsigned char)val;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size)
|
||||
{
|
||||
static const char xdigits_l[] = "0123456789abcdef",
|
||||
xdigits_u[] = "0123456789ABCDEF";
|
||||
unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
|
||||
const char *xdigits, *curtok;
|
||||
int ch, saw_xdigit;
|
||||
unsigned int val;
|
||||
int digits;
|
||||
int bits;
|
||||
size_t bytes;
|
||||
int words;
|
||||
int ipv4;
|
||||
|
||||
memset((tp = tmp), '\0', NS_IN6ADDRSZ);
|
||||
endp = tp + NS_IN6ADDRSZ;
|
||||
colonp = NULL;
|
||||
/* Leading :: requires some special handling. */
|
||||
if (*src == ':')
|
||||
if (*++src != ':')
|
||||
goto enoent;
|
||||
curtok = src;
|
||||
saw_xdigit = 0;
|
||||
val = 0;
|
||||
digits = 0;
|
||||
bits = -1;
|
||||
ipv4 = 0;
|
||||
while ((ch = *src++) != '\0') {
|
||||
const char *pch;
|
||||
|
||||
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
|
||||
pch = strchr((xdigits = xdigits_u), ch);
|
||||
if (pch != NULL) {
|
||||
val <<= 4;
|
||||
val |= (pch - xdigits);
|
||||
if (++digits > 4)
|
||||
goto enoent;
|
||||
saw_xdigit = 1;
|
||||
continue;
|
||||
}
|
||||
if (ch == ':') {
|
||||
curtok = src;
|
||||
if (!saw_xdigit) {
|
||||
if (colonp)
|
||||
goto enoent;
|
||||
colonp = tp;
|
||||
continue;
|
||||
} else if (*src == '\0')
|
||||
goto enoent;
|
||||
if (tp + NS_INT16SZ > endp)
|
||||
return (0);
|
||||
*tp++ = (unsigned char)((val >> 8) & 0xff);
|
||||
*tp++ = (unsigned char)(val & 0xff);
|
||||
saw_xdigit = 0;
|
||||
digits = 0;
|
||||
val = 0;
|
||||
continue;
|
||||
}
|
||||
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
|
||||
getv4(curtok, tp, &bits) > 0) {
|
||||
tp += NS_INADDRSZ;
|
||||
saw_xdigit = 0;
|
||||
ipv4 = 1;
|
||||
break; /* '\0' was seen by inet_pton4(). */
|
||||
}
|
||||
if (ch == '/' && getbits(src, &bits) > 0)
|
||||
break;
|
||||
goto enoent;
|
||||
}
|
||||
if (saw_xdigit) {
|
||||
if (tp + NS_INT16SZ > endp)
|
||||
goto enoent;
|
||||
*tp++ = (unsigned char)((val >> 8) & 0xff);
|
||||
*tp++ = (unsigned char)(val & 0xff);
|
||||
}
|
||||
if (bits == -1)
|
||||
bits = 128;
|
||||
|
||||
words = (bits + 15) / 16;
|
||||
if (words < 2)
|
||||
words = 2;
|
||||
if (ipv4)
|
||||
words = 8;
|
||||
endp = tmp + 2 * words;
|
||||
|
||||
if (colonp != NULL) {
|
||||
/*
|
||||
* Since some memmove()'s erroneously fail to handle
|
||||
* overlapping regions, we'll do the shift by hand.
|
||||
*/
|
||||
const ssize_t n = tp - colonp;
|
||||
ssize_t i;
|
||||
|
||||
if (tp == endp)
|
||||
goto enoent;
|
||||
for (i = 1; i <= n; i++) {
|
||||
*(endp - i) = *(colonp + n - i);
|
||||
*(colonp + n - i) = 0;
|
||||
}
|
||||
tp = endp;
|
||||
}
|
||||
if (tp != endp)
|
||||
goto enoent;
|
||||
|
||||
bytes = (bits + 7) / 8;
|
||||
if (bytes > size)
|
||||
goto emsgsize;
|
||||
memcpy(dst, tmp, bytes);
|
||||
return (bits);
|
||||
|
||||
enoent:
|
||||
SET_ERRNO(ENOENT);
|
||||
return (-1);
|
||||
|
||||
emsgsize:
|
||||
SET_ERRNO(EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* inet_net_pton(af, src, dst, size)
|
||||
* convert network number from presentation to network format.
|
||||
* accepts hex octets, hex strings, decimal octets, and /CIDR.
|
||||
* "size" is in bytes and describes "dst".
|
||||
* return:
|
||||
* number of bits, either imputed classfully or specified with /CIDR,
|
||||
* or -1 if some failure occurred (check errno). ENOENT means it was
|
||||
* not a valid network specification.
|
||||
* note:
|
||||
* On Windows we store the error in the thread errno, not
|
||||
* in the winsock error code. This is to avoid loosing the
|
||||
* actual last winsock error. So use macro ERRNO to fetch the
|
||||
* errno this funtion sets when returning (-1), not SOCKERRNO.
|
||||
* author:
|
||||
* Paul Vixie (ISC), June 1996
|
||||
*/
|
||||
int
|
||||
ares_inet_net_pton(int af, const char *src, void *dst, size_t size)
|
||||
{
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
return (inet_net_pton_ipv4(src, dst, size));
|
||||
case AF_INET6:
|
||||
return (inet_net_pton_ipv6(src, dst, size));
|
||||
default:
|
||||
SET_ERRNO(EAFNOSUPPORT);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_INET_PTON
|
||||
int ares_inet_pton(int af, const char *src, void *dst)
|
||||
{
|
||||
int result;
|
||||
size_t size;
|
||||
|
||||
if (af == AF_INET)
|
||||
size = sizeof(struct in_addr);
|
||||
else if (af == AF_INET6)
|
||||
size = sizeof(struct ares_in6_addr);
|
||||
else
|
||||
{
|
||||
SET_ERRNO(EAFNOSUPPORT);
|
||||
return -1;
|
||||
}
|
||||
result = ares_inet_net_pton(af, src, dst, size);
|
||||
if (result == -1 && ERRNO == ENOENT)
|
||||
return 0;
|
||||
return (result > -1 ? 1 : -1);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef __ARES_INET_NET_PTON_H
|
||||
#define __ARES_INET_NET_PTON_H
|
||||
|
||||
|
||||
/* Copyright (C) 2005 by Daniel Stenberg
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_INET_PTON
|
||||
#define ares_inet_pton(x,y,z) inet_pton(x,y,z)
|
||||
#else
|
||||
int ares_inet_pton(int af, const char *src, void *dst);
|
||||
#endif
|
||||
#if defined(HAVE_INET_NET_PTON) && defined(HAVE_INET_NET_PTON_IPV6)
|
||||
#define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z)
|
||||
#else
|
||||
int ares_inet_net_pton(int af, const char *src, void *dst, size_t size);
|
||||
#endif
|
||||
|
||||
#endif /* __ARES_INET_NET_PTON_H */
|
|
@ -0,0 +1,232 @@
|
|||
|
||||
/* Copyright (c) 1996 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#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 <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_ipv6.h"
|
||||
#include "inet_ntop.h"
|
||||
|
||||
|
||||
#ifndef HAVE_INET_NTOP
|
||||
|
||||
#ifdef SPRINTF_CHAR
|
||||
# define SPRINTF(x) strlen(sprintf/**/x)
|
||||
#else
|
||||
# define SPRINTF(x) ((size_t)sprintf x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* WARNING: Don't even consider trying to compile this on a system where
|
||||
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
|
||||
*/
|
||||
|
||||
static const char *inet_ntop4(const unsigned char *src, char *dst, size_t size);
|
||||
static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size);
|
||||
|
||||
/* char *
|
||||
* inet_ntop(af, src, dst, size)
|
||||
* convert a network format address to presentation format.
|
||||
* return:
|
||||
* pointer to presentation format address (`dst'), or NULL (see errno).
|
||||
* note:
|
||||
* On Windows we store the error in the thread errno, not
|
||||
* in the winsock error code. This is to avoid loosing the
|
||||
* actual last winsock error. So use macro ERRNO to fetch the
|
||||
* errno this funtion sets when returning NULL, not SOCKERRNO.
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
const char *
|
||||
ares_inet_ntop(int af, const void *src, char *dst, size_t size)
|
||||
{
|
||||
switch (af)
|
||||
{
|
||||
case AF_INET:
|
||||
return (inet_ntop4(src, dst, size));
|
||||
case AF_INET6:
|
||||
return (inet_ntop6(src, dst, size));
|
||||
default:
|
||||
SET_ERRNO(EAFNOSUPPORT);
|
||||
return (NULL);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* const char *
|
||||
* inet_ntop4(src, dst, size)
|
||||
* format an IPv4 address, more or less like inet_ntoa()
|
||||
* return:
|
||||
* `dst' (as a const)
|
||||
* notes:
|
||||
* (1) uses no statics
|
||||
* (2) takes a unsigned char* not an in_addr as input
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static const char *
|
||||
inet_ntop4(const unsigned char *src, char *dst, size_t size)
|
||||
{
|
||||
static const char fmt[] = "%u.%u.%u.%u";
|
||||
char tmp[sizeof "255.255.255.255"];
|
||||
|
||||
if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size)
|
||||
{
|
||||
SET_ERRNO(ENOSPC);
|
||||
return (NULL);
|
||||
}
|
||||
strcpy(dst, tmp);
|
||||
return (dst);
|
||||
}
|
||||
|
||||
/* const char *
|
||||
* inet_ntop6(src, dst, size)
|
||||
* convert IPv6 binary address into presentation (printable) format
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static const char *
|
||||
inet_ntop6(const unsigned char *src, char *dst, size_t size)
|
||||
{
|
||||
/*
|
||||
* Note that int32_t and int16_t need only be "at least" large enough
|
||||
* to contain a value of the specified size. On some systems, like
|
||||
* Crays, there is no such thing as an integer variable with 16 bits.
|
||||
* Keep this in mind if you think this function should have been coded
|
||||
* to use pointer overlays. All the world's not a VAX.
|
||||
*/
|
||||
char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
|
||||
char *tp;
|
||||
struct {
|
||||
long base;
|
||||
long len;
|
||||
} best, cur;
|
||||
unsigned long words[NS_IN6ADDRSZ / NS_INT16SZ];
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Preprocess:
|
||||
* Copy the input (bytewise) array into a wordwise array.
|
||||
* Find the longest run of 0x00's in src[] for :: shorthanding.
|
||||
*/
|
||||
memset(words, '\0', sizeof(words));
|
||||
for (i = 0; i < NS_IN6ADDRSZ; i++)
|
||||
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
|
||||
|
||||
best.base = -1;
|
||||
cur.base = -1;
|
||||
best.len = 0;
|
||||
cur.len = 0;
|
||||
|
||||
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
|
||||
{
|
||||
if (words[i] == 0)
|
||||
{
|
||||
if (cur.base == -1)
|
||||
cur.base = i, cur.len = 1;
|
||||
else
|
||||
cur.len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cur.base != -1)
|
||||
{
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
cur.base = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cur.base != -1)
|
||||
{
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
}
|
||||
if (best.base != -1 && best.len < 2)
|
||||
best.base = -1;
|
||||
|
||||
/*
|
||||
* Format the result.
|
||||
*/
|
||||
tp = tmp;
|
||||
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
|
||||
{
|
||||
/* Are we inside the best run of 0x00's? */
|
||||
if (best.base != -1 && i >= best.base &&
|
||||
i < (best.base + best.len))
|
||||
{
|
||||
if (i == best.base)
|
||||
*tp++ = ':';
|
||||
continue;
|
||||
}
|
||||
/* Are we following an initial run of 0x00s or any real hex? */
|
||||
if (i != 0)
|
||||
*tp++ = ':';
|
||||
/* Is this address an encapsulated IPv4? */
|
||||
if (i == 6 && best.base == 0 &&
|
||||
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
|
||||
{
|
||||
if (!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
|
||||
return (NULL);
|
||||
tp += strlen(tp);
|
||||
break;
|
||||
}
|
||||
tp += SPRINTF((tp, "%lx", words[i]));
|
||||
}
|
||||
|
||||
/* Was it a trailing run of 0x00's? */
|
||||
if (best.base != -1 && (best.base + best.len) == (NS_IN6ADDRSZ / NS_INT16SZ))
|
||||
*tp++ = ':';
|
||||
*tp++ = '\0';
|
||||
|
||||
/*
|
||||
* Check for overflow, copy, and we're done.
|
||||
*/
|
||||
if ((size_t)(tp - tmp) > size)
|
||||
{
|
||||
SET_ERRNO(ENOSPC);
|
||||
return (NULL);
|
||||
}
|
||||
strcpy(dst, tmp);
|
||||
return (dst);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef __ARES_INET_NTOP_H
|
||||
#define __ARES_INET_NTOP_H
|
||||
|
||||
|
||||
/* Copyright (C) 2005 by Dominick Meglio
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_INET_NTOP
|
||||
#define ares_inet_ntop(w,x,y,z) inet_ntop(w,x,y,z)
|
||||
#else
|
||||
const char *ares_inet_ntop(int af, const void *src, char *dst, size_t size);
|
||||
#endif
|
||||
|
||||
#endif /* __ARES_INET_NTOP_H */
|
|
@ -0,0 +1,193 @@
|
|||
|
||||
#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_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_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_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_ANY ns_t_any
|
||||
|
||||
#endif /* HAVE_ARPA_NAMESER_COMPAT_H */
|
||||
|
||||
#endif /* ARES_NAMESER_H */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue