Compare commits
164
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc6b8641c2 | ||
|
|
2811e30d49 | ||
|
|
55e2af978d | ||
|
|
742f56907a | ||
|
|
0b7a497ab7 | ||
|
|
ebe7b81453 | ||
|
|
3b1ff9da74 | ||
|
|
23b9ad9ede | ||
|
|
6917640336 | ||
|
|
bf45d4c7c1 | ||
|
|
10a1b7d509 | ||
|
|
fab050fe94 | ||
|
|
3e897ff27e | ||
|
|
e7fe2744db | ||
|
|
e41a39b022 | ||
|
|
6549138e8b | ||
|
|
f61151a091 | ||
|
|
63909b59a0 | ||
|
|
5b46450af4 | ||
|
|
f4fe7371fb | ||
|
|
18eeb34989 | ||
|
|
85c865e655 | ||
|
|
f0d04b2909 | ||
|
|
8d023b7d96 | ||
|
|
4ef6817c76 | ||
|
|
80bda0e9a0 | ||
|
|
385582bd14 | ||
|
|
7e17c22b0f | ||
|
|
ed7df969cd | ||
|
|
d8a0182af5 | ||
|
|
56cd98b9e4 | ||
|
|
e514088f96 | ||
|
|
2b6a1fbee7 | ||
|
|
11e37a92ef | ||
|
|
87d641a907 | ||
|
|
2bae2d56d7 | ||
|
|
53c2186e18 | ||
|
|
0c4c1ca9bc | ||
|
|
adc95e6bd6 | ||
|
|
03ba16fe7a | ||
|
|
3f301a6fe3 | ||
|
|
d4a549c78b | ||
|
|
6f1862f884 | ||
|
|
31ca57671e | ||
|
|
c9579872c8 | ||
|
|
86beb81892 | ||
|
|
ff1f7a1c3c | ||
|
|
b644412a66 | ||
|
|
5dc450a4b3 | ||
|
|
439eb45cc0 | ||
|
|
78f9ec5515 | ||
|
|
3478963873 | ||
|
|
830e8fe2b3 | ||
|
|
d3bccff740 | ||
|
|
9edf9411c7 | ||
|
|
d448d6604f | ||
|
|
92656bcc82 | ||
|
|
3231480a85 | ||
|
|
e26a678f26 | ||
|
|
25adcc413e | ||
|
|
a05f240dea | ||
|
|
83839fde7a | ||
|
|
0c423efd78 | ||
|
|
0ef56333a0 | ||
|
|
ce3f896572 | ||
|
|
f939efe7df | ||
|
|
a2c5b1d378 | ||
|
|
834c98e9d9 | ||
|
|
693e566b66 | ||
|
|
3ce586feb7 | ||
|
|
6589ebfd6a | ||
|
|
4a09121923 | ||
|
|
f2ae5d72da | ||
|
|
0c03bee6ed | ||
|
|
ffc7c52656 | ||
|
|
e3434ef33f | ||
|
|
a48447ee27 | ||
|
|
f9b9817d1d | ||
|
|
c778f0136b | ||
|
|
79dc327a2d | ||
|
|
5da3201a05 | ||
|
|
3907b6dc68 | ||
|
|
2aa07c7d02 | ||
|
|
b651f825d6 | ||
|
|
72555b6cad | ||
|
|
4a4f875c5a | ||
|
|
af3ee9a8ba | ||
|
|
148b6e93b9 | ||
|
|
59b3f81ab4 | ||
|
|
5f59b88431 | ||
|
|
b2dbc698ea | ||
|
|
ce1ea79943 | ||
|
|
8042524c70 | ||
|
|
ace90cce05 | ||
|
|
1b6905cc7f | ||
|
|
7972adc5d7 | ||
|
|
06d0f72e54 | ||
|
|
f1bcfa1122 | ||
|
|
d493e9b17c | ||
|
|
b619d13693 | ||
|
|
4ad3111a49 | ||
|
|
87ff25049c | ||
|
|
35609ceb41 | ||
|
|
e2c4b6f36c | ||
|
|
de04975c48 | ||
|
|
74ba881295 | ||
|
|
970dea47b7 | ||
|
|
46bb820be3 | ||
|
|
52c9bc57bd | ||
|
|
6aabc42e5f | ||
|
|
fa14ba7b11 | ||
|
|
68a938e771 | ||
|
|
02e1f7f9af | ||
|
|
5e5b2f4239 | ||
|
|
a37863498f | ||
|
|
e4e40161f8 | ||
|
|
ab78ef369d | ||
|
|
51dae48ecf | ||
|
|
48c0f703f6 | ||
|
|
250e7a20cc | ||
|
|
66f40230a0 | ||
|
|
c49a87eea5 | ||
|
|
affc63cba8 | ||
|
|
f945a0cfe3 | ||
|
|
52ecef76df | ||
|
|
fe34a70d6a | ||
|
|
36ca36eedd | ||
|
|
cbb466e813 | ||
|
|
ce3a0ee056 | ||
|
|
cac35ac5d8 | ||
|
|
bba4dc573f | ||
|
|
453578354f | ||
|
|
a0b24beb95 | ||
|
|
3d3ab03c6d | ||
|
|
9456c39934 | ||
|
|
296ced3a0d | ||
|
|
bd2c61353f | ||
|
|
7db1afd38f | ||
|
|
13dc4800b2 | ||
|
|
880ec44da9 | ||
|
|
ede0f84b8e | ||
|
|
2bc07b2e74 | ||
|
|
c1fe47f6d9 | ||
|
|
943e79f4bf | ||
|
|
7aabbefab1 | ||
|
|
09e64d7124 | ||
|
|
7df69c0f79 | ||
|
|
ee22246507 | ||
|
|
0004f498dc | ||
|
|
440110b303 | ||
|
|
bc529dd0c2 | ||
|
|
d5d3871335 | ||
|
|
4aa1fc4163 | ||
|
|
c8ec633bf5 | ||
|
|
83ab208e83 | ||
|
|
f19387dd72 | ||
|
|
efdd616118 | ||
|
|
30c9031afa | ||
|
|
742e234855 | ||
|
|
68b3c67e61 | ||
|
|
d69ae9c6f8 | ||
|
|
9540d48184 | ||
|
|
f8a2354016 | ||
|
|
1c948a70b1 |
+9
-37
@@ -24,12 +24,18 @@ ltmain.sh
|
||||
compile
|
||||
libcares.pc
|
||||
missing
|
||||
test-driver
|
||||
c-ares-*.tar.gz
|
||||
INSTALL
|
||||
install-sh
|
||||
*.o
|
||||
*.lo
|
||||
*.la
|
||||
*.gcno
|
||||
*.gcda
|
||||
*.gcov
|
||||
c-ares---coverage.info
|
||||
c-ares---coverage
|
||||
mkinstalldirs
|
||||
tags
|
||||
TAGS
|
||||
@@ -43,43 +49,9 @@ ares_config.h
|
||||
ares_config.h.in
|
||||
stamp-h1
|
||||
stamp-h2
|
||||
ares_cancel.pdf
|
||||
ares_destroy.pdf
|
||||
ares_destroy_options.pdf
|
||||
ares_dup.pdf
|
||||
ares_expand_name.pdf
|
||||
ares_expand_string.pdf
|
||||
ares_fds.pdf
|
||||
ares_free_data.pdf
|
||||
ares_free_hostent.pdf
|
||||
ares_free_string.pdf
|
||||
ares_get_servers.pdf
|
||||
ares_gethostbyaddr.pdf
|
||||
ares_gethostbyname.pdf
|
||||
ares_gethostbyname_file.pdf
|
||||
ares_getnameinfo.pdf
|
||||
ares_getsock.pdf
|
||||
ares_init.pdf
|
||||
ares_init_options.pdf
|
||||
ares_library_cleanup.pdf
|
||||
ares_library_init.pdf
|
||||
ares_mkquery.pdf
|
||||
ares_parse_a_reply.pdf
|
||||
ares_parse_aaaa_reply.pdf
|
||||
ares_parse_ns_reply.pdf
|
||||
ares_parse_ptr_reply.pdf
|
||||
ares_parse_srv_reply.pdf
|
||||
ares_parse_txt_reply.pdf
|
||||
ares_process.pdf
|
||||
ares_query.pdf
|
||||
ares_save_options.pdf
|
||||
ares_search.pdf
|
||||
ares_send.pdf
|
||||
ares_set_servers.pdf
|
||||
ares_set_socket_callback.pdf
|
||||
ares_strerror.pdf
|
||||
ares_timeout.pdf
|
||||
ares_version.pdf
|
||||
ares_*pdf
|
||||
CHANGES.dist
|
||||
c-ares-*.tar.gz.asc
|
||||
ares_parse_mx_reply.pdf
|
||||
/[0-9]*.patch
|
||||
*.kdev4
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
language: c++
|
||||
sudo: false
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- gcc-4.8
|
||||
- g++-4.8
|
||||
- lcov
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: BUILD_TYPE=normal
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=normal
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: BUILD_TYPE=coverage
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=ubsan
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=asan
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=lsan
|
||||
# - os: linux
|
||||
# compiler: clang
|
||||
# env: BUILD_TYPE=analyse
|
||||
- os: osx
|
||||
compiler: gcc
|
||||
env: BUILD_TYPE=normal
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=normal
|
||||
- os: osx
|
||||
compiler: clang
|
||||
language: objective-c
|
||||
env: BUILD_TYPE=ios
|
||||
install:
|
||||
- pip install --user 'requests[security]<2.9.1'
|
||||
- pip install --user cpp-coveralls
|
||||
before_script:
|
||||
- |
|
||||
if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$CXX" = "g++" ]; then
|
||||
export CXX="g++-4.8"
|
||||
export CC="gcc-4.8"
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "coverage" ]; then
|
||||
export CONFIG_OPTS="--enable-debug --disable-shared --enable-code-coverage"
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "asan" ]; then
|
||||
export CONFIG_OPTS=--enable-debug
|
||||
export CFLAGS=-fsanitize=address
|
||||
export CXXFLAGS=-fsanitize=address
|
||||
export LDFLAGS=-fsanitize=address
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "lsan" ]; then
|
||||
export CONFIG_OPTS=--enable-debug
|
||||
export CFLAGS=-fsanitize=leak
|
||||
export CXXFLAGS=-fsanitize=leak
|
||||
export LDFLAGS=-fsanitize=leak
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "ubsan" ]; then
|
||||
export CFLAGS="-fsanitize=undefined -fno-sanitize-recover"
|
||||
export LDFLAGS="-fsanitize=undefined"
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "analyse" ]; then
|
||||
export SCAN_WRAP="scan-build"
|
||||
export CONFIG_OPTS="--enable-debug"
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "ios" ]; then
|
||||
export CONFIG_OPTS=--host=arm-apple-darwin10
|
||||
export DEVPATH=`xcode-select -print-path`/Platforms/iPhoneOS.platform/Developer
|
||||
export IOSFLAGS="-isysroot $DEVPATH/SDKs/iPhoneOS.sdk -arch armv7 -miphoneos-version-min=8.0.0"
|
||||
export CFLAGS=$IOSFLAGS
|
||||
export CXXFLAGS=$IOSFLAGS
|
||||
export LDFLAGS=$IOSFLAGS
|
||||
fi
|
||||
script:
|
||||
- ./buildconf && $SCAN_WRAP ./configure --disable-symbol-hiding --enable-expose-statics --enable-maintainer-mode --enable-debug $CONFIG_OPTS && $SCAN_WRAP make
|
||||
- |
|
||||
if [ "$BUILD_TYPE" != "ios" ]; then
|
||||
./adig www.google.com
|
||||
./acountry www.google.com
|
||||
./ahost www.google.com
|
||||
cd test && make && ./arestest -v && cd ..
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "coverage" ]; then
|
||||
coveralls --gcov /usr/bin/gcov-4.8 --gcov-options '\-lp'
|
||||
fi
|
||||
@@ -2,9 +2,13 @@ c-ares is based on ares, and these are the people that have worked on it since
|
||||
the fork was made:
|
||||
|
||||
Albert Chin
|
||||
Alex Loukissas
|
||||
Alexander Klauer
|
||||
Alexander Lazic
|
||||
Alexey Simak
|
||||
Andreas Rieke
|
||||
Andrew Andkjar
|
||||
Andrew Ayer
|
||||
Andrew C. Morrow
|
||||
Ashish Sharma
|
||||
Ben Greear
|
||||
@@ -13,20 +17,27 @@ BogDan Vatra
|
||||
Brad House
|
||||
Brad Spencer
|
||||
Bram Matthys
|
||||
Chris Araman
|
||||
Dan Fandrich
|
||||
Daniel Johnson
|
||||
Daniel Stenberg
|
||||
David Drysdale
|
||||
David Stuart
|
||||
Denis Bilenko
|
||||
Dima Tisnek
|
||||
Dirk Manske
|
||||
Dominick Meglio
|
||||
Doug Goldstein
|
||||
Doug Kwan
|
||||
Duncan Wilcox
|
||||
Eino Tuominen
|
||||
Erik Kline
|
||||
Fedor Indutny
|
||||
Frederic Germain
|
||||
Geert Uytterhoeven
|
||||
George Neill
|
||||
Gisle Vanem
|
||||
Gregor Jasny
|
||||
Guenter Knauf
|
||||
Guilherme Balena Versiani
|
||||
Gunter Knauf
|
||||
@@ -34,25 +45,38 @@ Henrik Stoerner
|
||||
Jakub Hrozek
|
||||
James Bursa
|
||||
Jérémy Lal
|
||||
Keith Shaw
|
||||
Lei Shi
|
||||
Marko Kreen
|
||||
Michael Wallner
|
||||
Mike Crowe
|
||||
Nick Alcock
|
||||
Nick Mathewson
|
||||
Nicolas "Pixel" Noble
|
||||
Ning Dong
|
||||
Oleg Pudeyev
|
||||
Patrick Valsecchi
|
||||
Patrik Thunstrom
|
||||
Paul Saab
|
||||
Peter Pentchev
|
||||
Phil Blundell
|
||||
Poul Thomas Lomholt
|
||||
Ravi Pratap
|
||||
Robin Cornelius
|
||||
Saúl Ibarra Corretgé
|
||||
Sebastian at basti79.de
|
||||
Shmulik Regev
|
||||
Stefan Bühler
|
||||
Steinar H. Gunderson
|
||||
Svante Karlsson
|
||||
Tofu Linden
|
||||
Tom Hughes
|
||||
Tor Arntsen
|
||||
Viktor Szakats
|
||||
Vlad Dinulescu
|
||||
William Ahern
|
||||
Yang Tse
|
||||
hpopescu at ixiacom.com
|
||||
liren at vivisimo.com
|
||||
nordsturm
|
||||
saghul
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
Contributing to c-ares
|
||||
======================
|
||||
|
||||
To contribute patches to c-ares, please generate a GitHub pull request
|
||||
and follow these guidelines:
|
||||
|
||||
- Check that the Travis builds are green for your pull request.
|
||||
- Please update the test suite to add a test case for any new functionality.
|
||||
- Build the library with `./configure --enable-debug --enable-maintainer-mode` and
|
||||
ensure there are no new warnings.
|
||||
|
||||
To improve the chances of the c-ares maintainers responding to your request:
|
||||
|
||||
- Also send an email to the mailing list at `c-ares@cool.haxx.se` describing your change.
|
||||
- To follow any associated discussion, please subscribe to the [mailing list](http://cool.haxx.se/mailman/listinfo/c-ares).
|
||||
@@ -321,7 +321,7 @@ PORTS
|
||||
Useful URLs
|
||||
===========
|
||||
|
||||
c-ares http://c-ares.haxx.se/
|
||||
c-ares https://c-ares.haxx.se/
|
||||
|
||||
MingW http://www.mingw.org/
|
||||
MinGW-w64 http://mingw-w64.sourceforge.net/
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
# c-ares license
|
||||
|
||||
Copyright (c) 2007 - 2016, Daniel Stenberg with many contributors, see AUTHORS
|
||||
file.
|
||||
|
||||
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.
|
||||
+9
-2
@@ -55,16 +55,19 @@ EXTRA_DIST = AUTHORS CHANGES README.cares Makefile.inc Makefile.dj \
|
||||
Makefile.m32 Makefile.netware Makefile.msvc Makefile.Watcom $(man_MANS) \
|
||||
config-win32.h RELEASE-NOTES libcares.pc.in buildconf get_ver.awk maketgz \
|
||||
TODO ares_build.h.in $(PDFPAGES) cares.rc README.msvc $(MSVCFILES) \
|
||||
$(CSOURCES) $(HHEADERS) config-dos.h acountry.1 adig.1 ahost.1 INSTALL
|
||||
$(CSOURCES) $(HHEADERS) config-dos.h acountry.1 adig.1 ahost.1 INSTALL \
|
||||
README.md LICENSE.md
|
||||
|
||||
CLEANFILES = $(PDFPAGES) $(HTMLPAGES)
|
||||
|
||||
DISTCLEANFILES = ares_build.h
|
||||
|
||||
DIST_SUBDIRS = test
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libcares.pc
|
||||
|
||||
CARES_VERSION_INFO = -version-info 3:0:1
|
||||
CARES_VERSION_INFO = -version-info 4:0:2
|
||||
# This flag accepts an argument of the form current[:revision[:age]]. So,
|
||||
# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
|
||||
# 1.
|
||||
@@ -127,6 +130,10 @@ libcares_la_CFLAGS_EXTRA += $(CFLAG_CARES_SYMBOL_HIDING)
|
||||
libcares_la_CPPFLAGS_EXTRA += -DCARES_SYMBOL_HIDING
|
||||
endif
|
||||
|
||||
@CODE_COVERAGE_RULES@
|
||||
libcares_la_LDFLAGS += $(CODE_COVERAGE_LDFLAGS)
|
||||
libcares_la_CFLAGS_EXTRA += $(CODE_COVERAGE_CFLAGS)
|
||||
|
||||
libcares_la_CFLAGS = $(AM_CFLAGS) $(libcares_la_CFLAGS_EXTRA)
|
||||
|
||||
libcares_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcares_la_CPPFLAGS_EXTRA)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# c-ares Makefile for djgpp/gcc/Watt-32.
|
||||
# By Gisle Vanem <gvanem@broadpark.no> 2004.
|
||||
# By Gisle Vanem <gvanem@yahoo.no> 2004.
|
||||
#
|
||||
|
||||
|
||||
|
||||
+29
-1
@@ -46,7 +46,8 @@ CSOURCES = ares__close_sockets.c \
|
||||
bitncmp.c \
|
||||
inet_net_pton.c \
|
||||
inet_ntop.c \
|
||||
windows_port.c
|
||||
windows_port.c \
|
||||
amiga_port.c
|
||||
|
||||
HHEADERS = ares.h \
|
||||
ares_build.h \
|
||||
@@ -82,6 +83,7 @@ MANPAGES = ares_cancel.3 \
|
||||
ares_free_hostent.3 \
|
||||
ares_free_string.3 \
|
||||
ares_get_servers.3 \
|
||||
ares_get_servers_ports.3 \
|
||||
ares_gethostbyaddr.3 \
|
||||
ares_gethostbyname.3 \
|
||||
ares_gethostbyname_file.3 \
|
||||
@@ -107,8 +109,16 @@ MANPAGES = ares_cancel.3 \
|
||||
ares_save_options.3 \
|
||||
ares_search.3 \
|
||||
ares_send.3 \
|
||||
ares_set_local_dev.3 \
|
||||
ares_set_local_ip4.3 \
|
||||
ares_set_local_ip6.3 \
|
||||
ares_set_servers.3 \
|
||||
ares_set_servers_csv.3 \
|
||||
ares_set_servers_ports.3 \
|
||||
ares_set_servers_ports_csv.3 \
|
||||
ares_set_socket_callback.3 \
|
||||
ares_set_socket_configure_callback.3 \
|
||||
ares_set_sortlist.3 \
|
||||
ares_strerror.3 \
|
||||
ares_timeout.3 \
|
||||
ares_version.3 \
|
||||
@@ -126,6 +136,7 @@ HTMLPAGES = ares_cancel.html \
|
||||
ares_free_hostent.html \
|
||||
ares_free_string.html \
|
||||
ares_get_servers.html \
|
||||
ares_get_servers_ports.html \
|
||||
ares_gethostbyaddr.html \
|
||||
ares_gethostbyname.html \
|
||||
ares_gethostbyname_file.html \
|
||||
@@ -150,8 +161,16 @@ HTMLPAGES = ares_cancel.html \
|
||||
ares_save_options.html \
|
||||
ares_search.html \
|
||||
ares_send.html \
|
||||
ares_set_local_dev.html \
|
||||
ares_set_local_ip4.html \
|
||||
ares_set_local_ip6.html \
|
||||
ares_set_servers.html \
|
||||
ares_set_servers_csv.html \
|
||||
ares_set_servers_ports.html \
|
||||
ares_set_servers_ports_csv.html \
|
||||
ares_set_socket_callback.html \
|
||||
ares_set_socket_configure_callback.html \
|
||||
ares_set_sortlist.html \
|
||||
ares_strerror.html \
|
||||
ares_timeout.html \
|
||||
ares_version.html \
|
||||
@@ -169,6 +188,7 @@ PDFPAGES = ares_cancel.pdf \
|
||||
ares_free_hostent.pdf \
|
||||
ares_free_string.pdf \
|
||||
ares_get_servers.pdf \
|
||||
ares_get_servers_ports.pdf \
|
||||
ares_gethostbyaddr.pdf \
|
||||
ares_gethostbyname.pdf \
|
||||
ares_gethostbyname_file.pdf \
|
||||
@@ -193,8 +213,16 @@ PDFPAGES = ares_cancel.pdf \
|
||||
ares_save_options.pdf \
|
||||
ares_search.pdf \
|
||||
ares_send.pdf \
|
||||
ares_set_local_dev.pdf \
|
||||
ares_set_local_ip4.pdf \
|
||||
ares_set_local_ip6.pdf \
|
||||
ares_set_servers.pdf \
|
||||
ares_set_servers_csv.pdf \
|
||||
ares_set_servers_ports.pdf \
|
||||
ares_set_servers_ports_csv.pdf \
|
||||
ares_set_socket_callback.pdf \
|
||||
ares_set_socket_configure_callback.pdf \
|
||||
ares_set_sortlist.pdf \
|
||||
ares_strerror.pdf \
|
||||
ares_timeout.pdf \
|
||||
ares_version.pdf \
|
||||
|
||||
+6
-7
@@ -10,16 +10,16 @@
|
||||
|
||||
LIB = libcares.a
|
||||
|
||||
AR = ar
|
||||
CC = gcc
|
||||
LD = gcc
|
||||
RANLIB = ranlib
|
||||
AR = $(CROSSPREFIX)ar
|
||||
CC = $(CROSSPREFIX)gcc
|
||||
LD = $(CROSSPREFIX)gcc
|
||||
RANLIB = $(CROSSPREFIX)ranlib
|
||||
#RM = rm -f
|
||||
CP = cp -afv
|
||||
|
||||
CFLAGS = -O2 -Wall -I.
|
||||
CFLAGS = $(CARES_CFLAG_EXTRAS) -O2 -Wall -I.
|
||||
CFLAGS += -DCARES_STATICLIB
|
||||
LDFLAGS = -s
|
||||
LDFLAGS = $(CARES_LDFLAG_EXTRAS) -s
|
||||
LIBS = -lwsock32
|
||||
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
@@ -74,4 +74,3 @@ distclean: clean
|
||||
ifeq "$(wildcard ares_build.h.dist)" "ares_build.h.dist"
|
||||
$(RM) ares_build.h
|
||||
endif
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
AR = m68k-amigaos-ar
|
||||
CC = m68k-amigaos-gcc
|
||||
LD = m68k-amigaos-gcc
|
||||
RANLIB = m68k-amigaos-ranlib
|
||||
RM = rm -f
|
||||
CFLAGS = -O2 -Wall -I. -Iinclude -DHAVE_CONFIG_H -DCARES_STATICLIB -DAMIGA -DAOS3
|
||||
LDFLAGS = -noixemul -s
|
||||
LIBS = -lm
|
||||
|
||||
LIB = libcares.a
|
||||
LIBH = ares.h ares_build.h ares_rules.h
|
||||
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
include Makefile.inc
|
||||
|
||||
OBJLIB := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
|
||||
|
||||
all: $(LIB) dig host country doc
|
||||
|
||||
dig: adig.o ares_getopt.o $(LIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o dig adig.o ares_getopt.o $(LIB) $(LIBS)
|
||||
|
||||
host: ahost.o ares_getopt.o $(LIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o host ahost.o ares_getopt.o $(LIB) $(LIBS)
|
||||
|
||||
country: acountry.o ares_getopt.o $(LIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o country acountry.o ares_getopt.o $(LIB) $(LIBS)
|
||||
|
||||
$(LIB): $(OBJLIB)
|
||||
$(AR) cru $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
doc:
|
||||
./workman1 adig.1 >dig.txt
|
||||
./workman2 adig.1 >dig.help
|
||||
./workman1 ahost.1 >host.txt
|
||||
./workman2 ahost.1 >host.help
|
||||
./workman1 acountry.1 >country.txt
|
||||
./workman2 acountry.1 >country.help
|
||||
|
||||
tags:
|
||||
etags *.[ch]
|
||||
|
||||
$(OBJLIB): ares.h ares_dns.h ares_private.h ares_build.h ares_rules.h
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
|
||||
clean:
|
||||
$(RM) adig.o ahost.o acountry.o ares_getopt.o $(OBJLIB) $(LIB) dig host country dig.txt dig.help host.txt host.help country.txt country.help
|
||||
|
||||
distclean: clean
|
||||
$(RM) config.cache config.log config.status Makefile
|
||||
ifeq "$(wildcard ares_build.h.dist)" "ares_build.h.dist"
|
||||
$(RM) ares_build.h
|
||||
endif
|
||||
|
||||
+7
-65
@@ -18,12 +18,12 @@
|
||||
# Makefile for building c-ares libraries and sample programs with MSVC.
|
||||
#
|
||||
# Usage: nmake /f makefile.msvc CFG=<config> <target>
|
||||
#
|
||||
#
|
||||
# <config> must be one of: [ lib-release | lib-debug | dll-release | dll-debug }
|
||||
# <target> must be one of: [ ALL | c-ares | acountry | adig | ahost | clean }
|
||||
#
|
||||
#
|
||||
# If a <target> other than ALL or clean is given, <config> becomes mandatory.
|
||||
#
|
||||
#
|
||||
# If neither <config> nor <target> are specified this results in
|
||||
# all targets being built for all <config> c-ares library types.
|
||||
#
|
||||
@@ -71,68 +71,10 @@ RTLIBD = /MTd
|
||||
|
||||
USE_WATT32 = 0
|
||||
|
||||
# -------------------------------------------
|
||||
# Detect NMAKE version deducing MSVC version
|
||||
# -------------------------------------------
|
||||
|
||||
!IFNDEF _NMAKE_VER
|
||||
! MESSAGE Macro _NMAKE_VER not defined.
|
||||
! MESSAGE Use MSVC's NMAKE to process this makefile.
|
||||
! ERROR See previous message.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(_NMAKE_VER)" == "6.00.8168.0"
|
||||
CC_VERS_NUM = 60
|
||||
!ELSEIF "$(_NMAKE_VER)" == "6.00.9782.0"
|
||||
CC_VERS_NUM = 60
|
||||
!ELSEIF "$(_NMAKE_VER)" == "7.00.8882"
|
||||
CC_VERS_NUM = 70
|
||||
!ELSEIF "$(_NMAKE_VER)" == "7.00.9466"
|
||||
CC_VERS_NUM = 70
|
||||
!ELSEIF "$(_NMAKE_VER)" == "7.00.9955"
|
||||
CC_VERS_NUM = 70
|
||||
!ELSEIF "$(_NMAKE_VER)" == "7.10.2240.8"
|
||||
CC_VERS_NUM = 71
|
||||
!ELSEIF "$(_NMAKE_VER)" == "7.10.3077"
|
||||
CC_VERS_NUM = 71
|
||||
!ELSEIF "$(_NMAKE_VER)" == "8.00.40607.16"
|
||||
CC_VERS_NUM = 80
|
||||
!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.42"
|
||||
CC_VERS_NUM = 80
|
||||
!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.762"
|
||||
CC_VERS_NUM = 80
|
||||
!ELSEIF "$(_NMAKE_VER)" == "9.00.20706.01"
|
||||
CC_VERS_NUM = 90
|
||||
!ELSEIF "$(_NMAKE_VER)" == "9.00.21022.08"
|
||||
CC_VERS_NUM = 90
|
||||
!ELSEIF "$(_NMAKE_VER)" == "9.00.30729.01"
|
||||
CC_VERS_NUM = 90
|
||||
!ELSEIF "$(_NMAKE_VER)" == "10.00.20506.01"
|
||||
CC_VERS_NUM = 100
|
||||
!ELSEIF "$(_NMAKE_VER)" == "10.00.21003.01"
|
||||
CC_VERS_NUM = 100
|
||||
!ELSEIF "$(_NMAKE_VER)" == "10.00.30128.01"
|
||||
CC_VERS_NUM = 100
|
||||
!ELSEIF "$(_NMAKE_VER)" == "10.00.30319.01"
|
||||
CC_VERS_NUM = 100
|
||||
!ELSEIF "$(_NMAKE_VER)" == "10.00.40219.01"
|
||||
CC_VERS_NUM = 100
|
||||
!ELSEIF "$(_NMAKE_VER)" == "11.00.50522.1"
|
||||
CC_VERS_NUM = 110
|
||||
!ELSEIF "$(_NMAKE_VER)" == "11.00.50727.1"
|
||||
CC_VERS_NUM = 110
|
||||
!ELSEIF "$(_NMAKE_VER)" == "11.00.51106.1"
|
||||
CC_VERS_NUM = 110
|
||||
!ELSEIF "$(_NMAKE_VER)" == "11.00.60315.1"
|
||||
CC_VERS_NUM = 110
|
||||
!ELSE
|
||||
! MESSAGE Unknown value for _NMAKE_VER macro: "$(_NMAKE_VER)"
|
||||
! MESSAGE Please, report this condition on the c-ares development
|
||||
! MESSAGE mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/
|
||||
! ERROR See previous message.
|
||||
!ENDIF
|
||||
|
||||
CC_VERS_STR = msvc$(CC_VERS_NUM)
|
||||
# --------------------------------------------------------
|
||||
# Detect compiler version.
|
||||
# --------------------------------------------------------
|
||||
!INCLUDE .\msvc_ver.inc
|
||||
|
||||
# ----------------------------------------------------
|
||||
# Verify that current subdir is the c-ares source one
|
||||
|
||||
@@ -306,7 +306,6 @@ ifeq ($(LIBARCH),CLIB)
|
||||
@echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
|
||||
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
||||
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
|
||||
@echo $(DL)#define SIZEOF_SIZE_T 4$(DL) >> $@
|
||||
else
|
||||
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
|
||||
@echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
|
||||
@@ -349,8 +348,6 @@ else
|
||||
@echo $(DL)#define SEND_TYPE_ARG3 size_t$(DL) >> $@
|
||||
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
||||
@echo $(DL)#define SEND_TYPE_RETV ssize_t$(DL) >> $@
|
||||
@echo $(DL)#define SIZEOF_SIZE_T 8$(DL) >> $@
|
||||
@echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
|
||||
endif
|
||||
@echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
|
||||
@echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
|
||||
@@ -397,9 +394,6 @@ endif
|
||||
@echo $(DL)#define HAVE_UTIME_H 1$(DL) >> $@
|
||||
@echo $(DL)#define HAVE_WRITEV 1$(DL) >> $@
|
||||
@echo $(DL)#define RETSIGTYPE void$(DL) >> $@
|
||||
@echo $(DL)#define SIZEOF_INT 4$(DL) >> $@
|
||||
@echo $(DL)#define SIZEOF_SHORT 2$(DL) >> $@
|
||||
@echo $(DL)#define SIZEOF_STRUCT_IN_ADDR 4$(DL) >> $@
|
||||
@echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
|
||||
@echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
|
||||
ifdef NW_WINSOCK
|
||||
@@ -431,11 +425,8 @@ ares_build.h: Makefile.netware FORCE
|
||||
@echo $(DL)#define __CARES_BUILD_H$(DL) >> $@
|
||||
ifeq ($(LIBARCH),CLIB)
|
||||
@echo $(DL)#define CARES_TYPEOF_ARES_SOCKLEN_T int$(DL) >> $@
|
||||
@echo $(DL)#define CARES_SIZEOF_ARES_SOCKLEN_T 4$(DL) >> $@
|
||||
else
|
||||
@echo $(DL)#define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int$(DL) >> $@
|
||||
@echo $(DL)#define CARES_SIZEOF_ARES_SOCKLEN_T 4$(DL) >> $@
|
||||
endif
|
||||
@echo $(DL)#define CARES_SIZEOF_LONG 4$(DL) >> $@
|
||||
@echo $(DL)typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;$(DL) >> $@
|
||||
@echo $(DL)#endif /* __CARES_BUILD_H */$(DL) >> $@
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
Short: Command line DNS tools
|
||||
Author: Daniel Stenberg, Greg Hudson and others
|
||||
Uploader: Carsten Larsen (carsten larsen mail com)
|
||||
Type: comm/tcp
|
||||
Version: 1.12.0
|
||||
Architecture: m68k-amigaos
|
||||
URL: http://c-ares.haxx.se/
|
||||
|
||||
|
||||
ABOUT
|
||||
|
||||
Utilities from the c-ares asynchronous resolver library.
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
c-ares is 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.
|
||||
|
||||
USAGE
|
||||
|
||||
Look up the DNS A or AAAA record associated with HOST (a hostname or an
|
||||
IP address).
|
||||
|
||||
Send queries to DNS servers about NAME and print received information,
|
||||
where NAME is a valid DNS name (e.g. www.example.com, 1.2.3.10.in-
|
||||
addr.arpa).
|
||||
|
||||
Print the country where HOST (an IPv4 address or hostname) is located.
|
||||
|
||||
The full source code is available in the 'c-ares' release archives, and
|
||||
in a git repository: http://github.com/c-ares/c-ares
|
||||
|
||||
BUGS
|
||||
|
||||
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.
|
||||
|
||||
c-ares is of course distributed under the same MIT-style license as the
|
||||
original ares.
|
||||
|
||||
+16
-8
@@ -1,13 +1,21 @@
|
||||
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 based on ares 1.1.1 (written by Greg Hudson). Daniel Stenberg
|
||||
decided to fork and release a separate project since the original 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.
|
||||
This package is dubbed 'c-ares' since Daniel wanted this for use within the
|
||||
curl project (hence the letter C) and it makes a nice pun. 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.
|
||||
The original libares was distributed at
|
||||
ftp://athena-dist.mit.edu:pub/ATHENA/ares (which seems to not be alive
|
||||
anymore). A local copy of the original ares package is kept here:
|
||||
https://c-ares.haxx.se/download/ares-1.1.1.tar.gz
|
||||
|
||||
AmigaOS versions are distributed at:
|
||||
http://aminet.net/package/comm/tcp/c-ares
|
||||
|
||||
and
|
||||
http://aminet.net/package/dev/gcc/c-ares-src
|
||||
|
||||
+21
-15
@@ -1,6 +1,11 @@
|
||||
c-ares
|
||||
======
|
||||
|
||||
[](https://travis-ci.org/c-ares/c-ares)
|
||||
[](https://ci.appveyor.com/project/c-ares/c-ares)
|
||||
[](https://coveralls.io/github/c-ares/c-ares?branch=master)
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/291)
|
||||
|
||||
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
|
||||
@@ -8,7 +13,7 @@ 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
|
||||
git repository: http://github.com/c-ares/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
|
||||
@@ -18,34 +23,34 @@ 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/
|
||||
https://c-ares.haxx.se/
|
||||
|
||||
|
||||
NOTES FOR C-ARES HACKERS
|
||||
Notes for c-ares hackers
|
||||
------------------------
|
||||
|
||||
* The distributed ares_build.h file is only intended to be used on systems
|
||||
* 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
|
||||
* 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.
|
||||
appropriate `buildconf*` script to set up `ares_build.h` and other local files
|
||||
before being able to compile 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
|
||||
* 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.
|
||||
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
|
||||
* 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
|
||||
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,
|
||||
* 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
|
||||
@@ -56,3 +61,4 @@ NOTES FOR C-ARES HACKERS
|
||||
|
||||
* Comments must be written in the old-style /* unnested C-fashion */
|
||||
|
||||
* Try to keep line lengths below 80 columns.
|
||||
+37
-26
@@ -1,35 +1,46 @@
|
||||
c-ares version 1.10.0
|
||||
c-ares version 1.12.0
|
||||
|
||||
Changes:
|
||||
|
||||
o Added ares_create_query(), to be used instead of ares_mkquery()
|
||||
o ares_inet_ntop() and ares_inet_pton() are now recognized c-ares functions
|
||||
|
||||
o api: add ARES_OPT_NOROTATE optmask value
|
||||
|
||||
Bug fixes:
|
||||
|
||||
o include the ares_parse_soa_reply.* files in the tarball
|
||||
o read_udp_packets: bail out loop on bad sockets
|
||||
o get_DNS_AdaptersAddresses: fix IPv6 parsing
|
||||
o adig: perror() doesn't work for socket errors on windows
|
||||
o ares_parse_aaaa_reply: fix memory leak
|
||||
o setup_once.h: HP-UX <sys/socket.h> issue workaround
|
||||
o configure: several fixes
|
||||
o config-dos.h: define strerror() to strerror_s_() for High-C
|
||||
o config-dos.h: define HAVE_CLOSE_S for MSDOS/Watt-32
|
||||
o ares_build.h.dist: enhance non-configure GCC ABI detection logic
|
||||
o ares.h: stricter CARES_EXTERN linkage decorations logic
|
||||
o ares_cancel(): cancel requests safely
|
||||
o protocol parsing: check input data stricter
|
||||
o library init: be recursive, reference count inits/cleanups
|
||||
o ares_parse_txt_reply: return a ares_txt_reply node for each sub-string
|
||||
o ares_set_servers_csv: fixed IPv6 address parsing
|
||||
o build: fix build on msvc11
|
||||
o CVE-2016-5180: ares_create_query single byte out of buffer write [4]
|
||||
o configure: acknowledge --disable-tests [1]
|
||||
o man pages: fix typos detected by Lintian
|
||||
o test: add missing #includes for dns-proto.cc
|
||||
o test: avoid in6addr_* constants
|
||||
o test: Build with MinGW on AppVeyor
|
||||
o Makefile.m32: add support for extra flags
|
||||
o Makefile.m32: add support for CROSSPREFIX
|
||||
o configure: check if tests can get built before enabled
|
||||
o ares_library_cleanup: reset ares_realloc too
|
||||
o ahost.c: add cast to fix C++ compile
|
||||
o test: Only pass unused args to GoogleTest
|
||||
o build: commonize MSVC version detection
|
||||
o msvc_ver.inc: support Visual Studio 2015 Update 1, 2, 3
|
||||
o test: for AF_UNSPEC, return CNAME only for AAAA, but valid A record
|
||||
o ares_getnameinfo: explicitly clear struct servent before use
|
||||
o test: Update fuzzing function prototype
|
||||
o init: fix nsort initialization
|
||||
o test: add fuzzing check script to tests
|
||||
o web: http => https
|
||||
o read_tcp_data: remove superfluous NULL check
|
||||
o LICENSE.md: add a stand-alone license file
|
||||
o SECURITY.md: suggested "security process" for the project
|
||||
o ares_init_options: only propagate init failures from options [2]
|
||||
o headers: remove checks for and defines of variable sizes
|
||||
o test: fix gMock to work with gcc >= 6.x [3]
|
||||
|
||||
Thanks go to these friendly people for their efforts and contributions:
|
||||
|
||||
Eugeny Gladkih, Yang Tse, Gisle Vanem, Guenter Knauf, Horatiu Popescu,
|
||||
Alexander Klauer, Patrick Valsecchi, Paul Saab, Keith Shaw,
|
||||
Alex Loukissas
|
||||
|
||||
Alexander Drachevskiy, Brad House, Chris Araman, Daniel Stenberg,
|
||||
David Drysdale, Gregor Jasny, Svante Karlsson, Viktor Szakats
|
||||
|
||||
Have fun!
|
||||
References to bug reports and discussions on issues:
|
||||
|
||||
[1] = https://github.com/c-ares/c-ares/issues/44
|
||||
[2] = https://github.com/c-ares/c-ares/issues/60
|
||||
[3] = https://github.com/google/googletest/issues/705#issuecomment-235067917
|
||||
[4] = https://c-ares.haxx.se/adv_20160929.html
|
||||
|
||||
@@ -1743,24 +1743,6 @@ cat >>confdefs.h <<_EOF
|
||||
_EOF
|
||||
])
|
||||
|
||||
|
||||
dnl CARES_CONFIGURE_LONG
|
||||
dnl -------------------------------------------------
|
||||
dnl Find out the size of long as reported by sizeof() and define
|
||||
dnl CARES_SIZEOF_LONG as appropriate to be used in template file
|
||||
dnl ares_build.h.in to properly configure the library.
|
||||
dnl The size of long is a build time characteristic and as such
|
||||
dnl must be recorded in ares_build.h
|
||||
|
||||
AC_DEFUN([CARES_CONFIGURE_LONG], [
|
||||
if test -z "$ac_cv_sizeof_long" ||
|
||||
test "$ac_cv_sizeof_long" -eq "0"; then
|
||||
AC_MSG_ERROR([cannot find out size of long.])
|
||||
fi
|
||||
CARES_DEFINE_UNQUOTED([CARES_SIZEOF_LONG], [$ac_cv_sizeof_long])
|
||||
])
|
||||
|
||||
|
||||
dnl CARES_CONFIGURE_ARES_SOCKLEN_T
|
||||
dnl -------------------------------------------------
|
||||
dnl Find out suitable ares_socklen_t data type definition and size, making
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
.TH ACOUNTRY "1" "April 2011" "c-ares utilities"
|
||||
.TH COUNTRY "1" "April 2011" "c-ares utilities"
|
||||
.SH NAME
|
||||
acountry \- print the country where an IPv4 address or host is located
|
||||
country \- print the country where an IPv4 address or host is located
|
||||
.SH SYNOPSIS
|
||||
.B acountry
|
||||
.B country
|
||||
[\fIOPTION\fR]... \fIHOST\fR...
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
|
||||
+30
-12
@@ -15,7 +15,7 @@
|
||||
*
|
||||
* Ref: http://countries.nerd.dk/more.html
|
||||
*
|
||||
* Written by G. Vanem <gvanem@broadpark.no> 2006, 2007
|
||||
* Written by G. Vanem <gvanem@yahoo.no> 2006, 2007
|
||||
*
|
||||
* NB! This program may not be big-endian aware.
|
||||
*
|
||||
@@ -41,8 +41,8 @@
|
||||
#if defined(WIN32) && !defined(WATT32)
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
@@ -69,10 +69,21 @@
|
||||
#define INADDR_NONE 0xffffffff
|
||||
#endif
|
||||
|
||||
static const char *usage = "acountry [-vh?] {host|addr} ...\n";
|
||||
const char *vers = "\0$VER: country 1.12 (29.09.2016) c-ares " ARES_VERSION_STR;
|
||||
|
||||
static const char *usage =
|
||||
#ifdef ANSI_CONSOLE
|
||||
"\33[33mcountry version " ARES_VERSION_STR " (c) " ARES_COPYRIGHT "\33[31m\n"
|
||||
#else
|
||||
"country version " ARES_VERSION_STR " (c) " ARES_COPYRIGHT "\n"
|
||||
#endif
|
||||
"Usage: country [options] { host | addr } ...\n"
|
||||
"\t-v: Be more verbose. Print extra information\n"
|
||||
"\t-h: Display this help and exit\n";
|
||||
|
||||
static const char nerd_fmt[] = "%u.%u.%u.%u.zz.countries.nerd.dk";
|
||||
static const char *nerd_ver1 = nerd_fmt + 14;
|
||||
static const char *nerd_ver2 = nerd_fmt + 11;
|
||||
static const char *nerd_ver1 = nerd_fmt + 14; /* .countries.nerd.dk */
|
||||
static const char *nerd_ver2 = nerd_fmt + 11; /* .zz.countries.nerd.dk */
|
||||
static int verbose = 0;
|
||||
|
||||
#define TRACE(fmt) do { \
|
||||
@@ -99,6 +110,8 @@ int main(int argc, char **argv)
|
||||
ares_channel channel;
|
||||
int ch, status;
|
||||
|
||||
prog = argv[0];
|
||||
|
||||
#if defined(WIN32) && !defined(WATT32)
|
||||
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
|
||||
WSADATA wsaData;
|
||||
@@ -161,11 +174,12 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
// NOTICE: Not endian neutral
|
||||
sprintf(buf, nerd_fmt,
|
||||
(unsigned int)(addr.s_addr >> 24),
|
||||
(unsigned int)((addr.s_addr >> 16) & 255),
|
||||
(unsigned int)(addr.s_addr & 255),
|
||||
(unsigned int)((addr.s_addr >> 8) & 255),
|
||||
(unsigned int)(addr.s_addr & 255));
|
||||
(unsigned int)((addr.s_addr >> 16) & 255),
|
||||
(unsigned int)(addr.s_addr >> 24));
|
||||
TRACE(("Looking up %s...", buf));
|
||||
fflush(stdout);
|
||||
ares_gethostbyname(channel, buf, AF_INET, callback, buf);
|
||||
@@ -200,7 +214,9 @@ static void wait_ares(ares_channel channel)
|
||||
if (nfds == 0)
|
||||
break;
|
||||
tvp = ares_timeout(channel, NULL, &tv);
|
||||
select(nfds, &read_fds, &write_fds, NULL, tvp);
|
||||
nfds = select(nfds, &read_fds, &write_fds, NULL, tvp);
|
||||
if (nfds < 0)
|
||||
continue;
|
||||
ares_process(channel, &read_fds, &write_fds);
|
||||
}
|
||||
}
|
||||
@@ -523,7 +539,7 @@ static int is_addr(char *str, char **end)
|
||||
int a0, a1, a2, a3, num, rc = 0, length = 0;
|
||||
|
||||
num = sscanf(str,"%3d.%3d.%3d.%3d%n",&a0,&a1,&a2,&a3,&length);
|
||||
if( (num == 4) &&
|
||||
if( (num == 4 || num == 5) &&
|
||||
BYTE_OK(a0) && BYTE_OK(a1) && BYTE_OK(a2) && BYTE_OK(a3) &&
|
||||
length >= (3+4))
|
||||
{
|
||||
@@ -559,9 +575,10 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
|
||||
if (ver_1)
|
||||
{
|
||||
const char *dot = strchr(cname, '.');
|
||||
if ((z0 != 'z' && z1 != 'z') || dot != cname+4)
|
||||
if (dot != cname+4)
|
||||
{
|
||||
printf("Unexpected CNAME %s (ver_1)\n", cname);
|
||||
free(ccopy);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -572,12 +589,14 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
|
||||
if (z0 != 'z' && z1 != 'z')
|
||||
{
|
||||
printf("Unexpected CNAME %s (ver_2)\n", cname);
|
||||
free(ccopy);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unexpected CNAME %s (ver?)\n", cname);
|
||||
free(ccopy);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -614,4 +633,3 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
|
||||
}
|
||||
free(ccopy);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
.TH ADIG "1" "April 2011" "c-ares utilities"
|
||||
.TH DIG "1" "April 2011" "c-ares utilities"
|
||||
.SH NAME
|
||||
adig \- print information collected from Domain Name System (DNS) servers
|
||||
dig \- print information collected from Domain Name System (DNS) servers
|
||||
.SH SYNOPSIS
|
||||
.B adig
|
||||
.B dig
|
||||
[\fIOPTION\fR]... \fINAME\fR...
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
|
||||
@@ -178,6 +178,8 @@ static void destroy_addr_list(struct ares_addr_node *head);
|
||||
static void append_addr_list(struct ares_addr_node **head,
|
||||
struct ares_addr_node *node);
|
||||
|
||||
const char *vers = "\0$VER: dig 1.12 (29.09.2016) c-ares " ARES_VERSION_STR;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ares_channel channel;
|
||||
@@ -195,6 +197,8 @@ int main(int argc, char **argv)
|
||||
WSAStartup(wVersionRequested, &wsaData);
|
||||
#endif
|
||||
|
||||
prog = argv[0];
|
||||
|
||||
status = ares_library_init(ARES_LIB_INIT_ALL);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
@@ -795,9 +799,24 @@ static const char *class_name(int dnsclass)
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: adig [-f flag] [-s server] [-c class] "
|
||||
"[-t type] [-p port] name ...\n");
|
||||
exit(1);
|
||||
fprintf(stderr,
|
||||
#ifdef ANSI_CONSOLE
|
||||
"\33[33mdig version " ARES_VERSION_STR " (c) " ARES_COPYRIGHT "\33[31m\n"
|
||||
#else
|
||||
"dig version " ARES_VERSION_STR " (c) " ARES_COPYRIGHT "\n"
|
||||
#endif
|
||||
"Usage: dig [options] name\n"
|
||||
"\t-s <server>: connect to specified DNS server. Default is 8.8.8.8.\n"
|
||||
"\t-f <class>: set the query class: NY, CHAOS, HS, IN (default)\n"
|
||||
"\t-f <flag>: add a flag: igntc, noaliases, norecurse, primary, stayopen, usevc\n"
|
||||
"\t-t <type>: query records of specified type, default is A. Possible values:\n"
|
||||
"\t AAAA, AFSDB, ANY, AXFR, CNAME, GPOS, HINFO, ISDN, KEY,LOC,\n"
|
||||
"\t MAILA, MAILB, MB, MD, MF, MG, MINFO, MR, MX, NAPTR, NS, NSAP\n"
|
||||
"\t NSAP_PTR, NULL, PTR, PX, RP, RT, SIG, SOA, SRV, TXT, WKS, X25\n"
|
||||
"\t-p <port>: use specified TCP port to connect to DNS server\n"
|
||||
"\t-U <port>: use specified UDP port to connect to DNS server\n"
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void destroy_addr_list(struct ares_addr_node *head)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
.TH AHOST "1" "April 2011" "c-ares utilities"
|
||||
.TH HOST "1" "April 2011" "c-ares utilities"
|
||||
.SH NAME
|
||||
ahost \- print the A or AAAA record associated with a hostname or IP address
|
||||
host \- print the A or AAAA record associated with a hostname or IP address
|
||||
.SH SYNOPSIS
|
||||
.B ahost
|
||||
.B host
|
||||
[\fIOPTION\fR]... \fIHOST\fR...
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -21,8 +21,18 @@ Print some extra debugging output.
|
||||
Display this help and exit.
|
||||
.TP
|
||||
\fB\-t\fR type
|
||||
If type is "aa", print the A record (default).
|
||||
If type is "a", print the A record (default).
|
||||
If type is "aaaa", print the AAAA record.
|
||||
If type is "u", look for either AAAA or A record (in that order).
|
||||
.TP
|
||||
\fB\-s\fR \fIdomain\fP
|
||||
Specify the \fIdomain\fP to search instead of using the default values from
|
||||
.br
|
||||
/etc/resolv.conf. This option only has an effect on platforms that use
|
||||
.br
|
||||
/etc/resolv.conf
|
||||
for DNS configuration; it has no effect on other platforms (such as Win32
|
||||
or Android).
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to the c-ares mailing list:
|
||||
\fBhttp://cool.haxx.se/mailman/listinfo/c-ares\fR
|
||||
|
||||
@@ -50,8 +50,12 @@
|
||||
static void callback(void *arg, int status, int timeouts, struct hostent *host);
|
||||
static void usage(void);
|
||||
|
||||
const char *vers = "\0$VER: host 1.12 (29.09.2016) c-ares " ARES_VERSION_STR;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct ares_options options;
|
||||
int optmask = 0;
|
||||
ares_channel channel;
|
||||
int status, nfds, c, addr_family = AF_INET;
|
||||
fd_set read_fds, write_fds;
|
||||
@@ -59,12 +63,16 @@ int main(int argc, char **argv)
|
||||
struct in_addr addr4;
|
||||
struct ares_in6_addr addr6;
|
||||
|
||||
prog = argv[0];
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
|
||||
WSADATA wsaData;
|
||||
WSAStartup(wVersionRequested, &wsaData);
|
||||
#endif
|
||||
|
||||
memset(&options, 0, sizeof(options));
|
||||
|
||||
status = ares_library_init(ARES_LIB_INIT_ALL);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
@@ -72,7 +80,7 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ((c = ares_getopt(argc,argv,"dt:h")) != -1)
|
||||
while ((c = ares_getopt(argc,argv,"dt:hs:")) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
@@ -81,11 +89,20 @@ int main(int argc, char **argv)
|
||||
dbug_init();
|
||||
#endif
|
||||
break;
|
||||
case 's':
|
||||
optmask |= ARES_OPT_DOMAINS;
|
||||
options.ndomains++;
|
||||
options.domains = (char **)realloc(options.domains,
|
||||
options.ndomains * sizeof(char *));
|
||||
options.domains[options.ndomains - 1] = strdup(optarg);
|
||||
break;
|
||||
case 't':
|
||||
if (!strcasecmp(optarg,"a"))
|
||||
addr_family = AF_INET;
|
||||
else if (!strcasecmp(optarg,"aaaa"))
|
||||
addr_family = AF_INET6;
|
||||
else if (!strcasecmp(optarg,"u"))
|
||||
addr_family = AF_UNSPEC;
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
@@ -101,7 +118,7 @@ int main(int argc, char **argv)
|
||||
if (argc < 1)
|
||||
usage();
|
||||
|
||||
status = ares_init(&channel);
|
||||
status = ares_init_options(&channel, &options, optmask);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "ares_init: %s\n", ares_strerror(status));
|
||||
@@ -130,13 +147,16 @@ int main(int argc, char **argv)
|
||||
/* Wait for all queries to complete. */
|
||||
for (;;)
|
||||
{
|
||||
int res;
|
||||
FD_ZERO(&read_fds);
|
||||
FD_ZERO(&write_fds);
|
||||
nfds = ares_fds(channel, &read_fds, &write_fds);
|
||||
if (nfds == 0)
|
||||
break;
|
||||
tvp = ares_timeout(channel, NULL, &tv);
|
||||
select(nfds, &read_fds, &write_fds, NULL, tvp);
|
||||
res = select(nfds, &read_fds, &write_fds, NULL, tvp);
|
||||
if (-1 == res)
|
||||
break;
|
||||
ares_process(channel, &read_fds, &write_fds);
|
||||
}
|
||||
|
||||
@@ -185,6 +205,16 @@ static void callback(void *arg, int status, int timeouts, struct hostent *host)
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: ahost [-t {a|aaaa}] {host|addr} ...\n");
|
||||
exit(1);
|
||||
fprintf(stderr,
|
||||
#ifdef ANSI_CONSOLE
|
||||
"\33[33mhost version " ARES_VERSION_STR " (c) " ARES_COPYRIGHT "\33[31m\n"
|
||||
#else
|
||||
"host version " ARES_VERSION_STR " (c) " ARES_COPYRIGHT "\n"
|
||||
#endif
|
||||
"Usage: host [-t type] { host | addr } ...\n"
|
||||
"\t-ta: print the A record (default)\n"
|
||||
"\t-tu: look for either AAAA or A record\n"
|
||||
"\t-taaaa: print the AAAA record\n"
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
#include "ares_setup.h"
|
||||
#if defined(AOS3) || defined(AROS)
|
||||
|
||||
/*
|
||||
* Written by Carsten Larsen.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/timer_protos.h>
|
||||
#include <clib/utility_protos.h>
|
||||
#include <clib/alib_protos.h>
|
||||
|
||||
#define OPEN_ERROR "Cannot open %s.\n"
|
||||
#define OPEN_VER_ERROR "Cannot open %s (%d.0)\n"
|
||||
#define DOSLIB_NAME "dos.library"
|
||||
#define DOSLIB_REV 37L
|
||||
#define BSDLIB_NAME "bsdsocket.library"
|
||||
#define BSDLIB_REV 03L
|
||||
#define LIB_ERROR 5
|
||||
|
||||
#ifdef AOS3
|
||||
#define IPTR ULONG
|
||||
#endif
|
||||
|
||||
#ifdef AOS3
|
||||
int h_errno;
|
||||
#endif
|
||||
|
||||
struct Library* DOSBase = NULL;
|
||||
struct Library* SocketBase = NULL;
|
||||
|
||||
char *prog;
|
||||
|
||||
void amiga_open_error(char *name)
|
||||
{
|
||||
printf(OPEN_ERROR, name);
|
||||
}
|
||||
|
||||
void amiga_open_lib_error(char *name, int version)
|
||||
{
|
||||
printf(OPEN_VER_ERROR, name, version);
|
||||
}
|
||||
|
||||
void ares_amiga_cleanup()
|
||||
{
|
||||
if (SocketBase != NULL) {
|
||||
CloseLibrary(SocketBase);
|
||||
SocketBase = NULL;
|
||||
}
|
||||
|
||||
if (DOSBase != NULL) {
|
||||
CloseLibrary(DOSBase);
|
||||
DOSBase = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int ares_amiga_init()
|
||||
{
|
||||
if((DOSBase = OpenLibrary((STRPTR)DOSLIB_NAME, DOSLIB_REV)) == NULL) {
|
||||
amiga_open_lib_error(DOSLIB_NAME, DOSLIB_REV);
|
||||
return LIB_ERROR;
|
||||
}
|
||||
|
||||
if((SocketBase = OpenLibrary((STRPTR)BSDLIB_NAME, BSDLIB_REV)) == NULL) {
|
||||
amiga_open_lib_error(BSDLIB_NAME, BSDLIB_REV);
|
||||
return LIB_ERROR;
|
||||
} else {
|
||||
SocketBaseTags(
|
||||
SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (IPTR) &errno,
|
||||
SBTM_SETVAL(SBTC_HERRNOLONGPTR), (IPTR) &h_errno,
|
||||
SBTM_SETVAL(SBTC_LOGTAGPTR), (IPTR) &prog,
|
||||
TAG_DONE );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
platform:
|
||||
- x64
|
||||
- x86
|
||||
build_script:
|
||||
- if "%platform%" == "x86" call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat"
|
||||
- if "%platform%" == "x64" "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
|
||||
- if "%platform%" == "x64" call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
|
||||
- copy ares_build.h.dist ares_build.h
|
||||
- nmake /f Makefile.msvc
|
||||
- cd test
|
||||
- nmake /f Makefile.msvc vtest
|
||||
@@ -158,6 +158,7 @@ extern "C" {
|
||||
#define ARES_OPT_TIMEOUTMS (1 << 13)
|
||||
#define ARES_OPT_ROTATE (1 << 14)
|
||||
#define ARES_OPT_EDNSPSZ (1 << 15)
|
||||
#define ARES_OPT_NOROTATE (1 << 16)
|
||||
|
||||
/* Nameinfo flag values */
|
||||
#define ARES_NI_NOFQDN (1 << 0)
|
||||
@@ -203,7 +204,8 @@ extern "C" {
|
||||
/* 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)
|
||||
#define ARES_LIB_INIT_AMIGA (2 << 0)
|
||||
#define ARES_LIB_INIT_ALL (ARES_LIB_INIT_WIN32 | ARES_LIB_INIT_AMIGA)
|
||||
|
||||
|
||||
/*
|
||||
@@ -294,8 +296,19 @@ typedef int (*ares_sock_create_callback)(ares_socket_t socket_fd,
|
||||
int type,
|
||||
void *data);
|
||||
|
||||
typedef int (*ares_sock_config_callback)(ares_socket_t socket_fd,
|
||||
int type,
|
||||
void *data);
|
||||
|
||||
CARES_EXTERN int ares_library_init(int flags);
|
||||
|
||||
CARES_EXTERN int ares_library_init_mem(int flags,
|
||||
void *(*amalloc)(size_t size),
|
||||
void (*afree)(void *ptr),
|
||||
void *(*arealloc)(void *ptr, size_t size));
|
||||
|
||||
CARES_EXTERN int ares_library_initialized(void);
|
||||
|
||||
CARES_EXTERN void ares_library_cleanup(void);
|
||||
|
||||
CARES_EXTERN const char *ares_version(int *version);
|
||||
@@ -337,6 +350,13 @@ CARES_EXTERN void ares_set_socket_callback(ares_channel channel,
|
||||
ares_sock_create_callback callback,
|
||||
void *user_data);
|
||||
|
||||
CARES_EXTERN void ares_set_socket_configure_callback(ares_channel channel,
|
||||
ares_sock_config_callback callback,
|
||||
void *user_data);
|
||||
|
||||
CARES_EXTERN int ares_set_sortlist(ares_channel channel,
|
||||
const char *sortstr);
|
||||
|
||||
CARES_EXTERN void ares_send(ares_channel channel,
|
||||
const unsigned char *qbuf,
|
||||
int qlen,
|
||||
@@ -474,6 +494,17 @@ struct ares_txt_reply {
|
||||
size_t length; /* length excludes null termination */
|
||||
};
|
||||
|
||||
/* NOTE: This structure is a superset of ares_txt_reply
|
||||
*/
|
||||
struct ares_txt_ext {
|
||||
struct ares_txt_ext *next;
|
||||
unsigned char *txt;
|
||||
size_t length;
|
||||
/* 1 - if start of new record
|
||||
* 0 - if a chunk in the same record */
|
||||
unsigned char record_start;
|
||||
};
|
||||
|
||||
struct ares_naptr_reply {
|
||||
struct ares_naptr_reply *next;
|
||||
unsigned char *flags;
|
||||
@@ -537,6 +568,10 @@ CARES_EXTERN int ares_parse_txt_reply(const unsigned char* abuf,
|
||||
int alen,
|
||||
struct ares_txt_reply** txt_out);
|
||||
|
||||
CARES_EXTERN int ares_parse_txt_reply_ext(const unsigned char* abuf,
|
||||
int alen,
|
||||
struct ares_txt_ext** txt_out);
|
||||
|
||||
CARES_EXTERN int ares_parse_naptr_reply(const unsigned char* abuf,
|
||||
int alen,
|
||||
struct ares_naptr_reply** naptr_out);
|
||||
@@ -553,7 +588,6 @@ 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;
|
||||
@@ -563,15 +597,32 @@ struct ares_addr_node {
|
||||
} addr;
|
||||
};
|
||||
|
||||
struct ares_addr_port_node {
|
||||
struct ares_addr_port_node *next;
|
||||
int family;
|
||||
union {
|
||||
struct in_addr addr4;
|
||||
struct ares_in6_addr addr6;
|
||||
} addr;
|
||||
int udp_port;
|
||||
int tcp_port;
|
||||
};
|
||||
|
||||
CARES_EXTERN int ares_set_servers(ares_channel channel,
|
||||
struct ares_addr_node *servers);
|
||||
CARES_EXTERN int ares_set_servers_ports(ares_channel channel,
|
||||
struct ares_addr_port_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_set_servers_ports_csv(ares_channel channel,
|
||||
const char* servers);
|
||||
|
||||
CARES_EXTERN int ares_get_servers(ares_channel channel,
|
||||
struct ares_addr_node **servers);
|
||||
CARES_EXTERN int ares_get_servers_ports(ares_channel channel,
|
||||
struct ares_addr_port_node **servers);
|
||||
|
||||
CARES_EXTERN const char *ares_inet_ntop(int af, const void *src, char *dst,
|
||||
ares_socklen_t size);
|
||||
|
||||
@@ -30,14 +30,14 @@ void ares__close_sockets(ares_channel channel, struct server_state *server)
|
||||
sendreq = server->qhead;
|
||||
server->qhead = sendreq->next;
|
||||
if (sendreq->data_storage != NULL)
|
||||
free(sendreq->data_storage);
|
||||
free(sendreq);
|
||||
ares_free(sendreq->data_storage);
|
||||
ares_free(sendreq);
|
||||
}
|
||||
server->qtail = NULL;
|
||||
|
||||
/* Reset any existing input buffer. */
|
||||
if (server->tcp_buffer)
|
||||
free(server->tcp_buffer);
|
||||
ares_free(server->tcp_buffer);
|
||||
server->tcp_buffer = NULL;
|
||||
server->tcp_lenbuf_pos = 0;
|
||||
|
||||
|
||||
+15
-15
@@ -94,7 +94,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
p++;
|
||||
if (!*p)
|
||||
/* Ignore line if reached end of line. */
|
||||
continue;
|
||||
continue; /* LCOV_EXCL_LINE: trailing whitespace already stripped */
|
||||
|
||||
/* Pointer to start of host name. */
|
||||
txthost = p;
|
||||
@@ -164,7 +164,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
*/
|
||||
|
||||
/* Allocate memory for the hostent structure. */
|
||||
hostent = malloc(sizeof(struct hostent));
|
||||
hostent = ares_malloc(sizeof(struct hostent));
|
||||
if (!hostent)
|
||||
break;
|
||||
|
||||
@@ -173,16 +173,16 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
hostent->h_addr_list = NULL;
|
||||
|
||||
/* Copy official host name. */
|
||||
hostent->h_name = strdup(txthost);
|
||||
hostent->h_name = ares_strdup(txthost);
|
||||
if (!hostent->h_name)
|
||||
break;
|
||||
|
||||
/* Copy network address. */
|
||||
hostent->h_addr_list = malloc(2 * sizeof(char *));
|
||||
hostent->h_addr_list = ares_malloc(2 * sizeof(char *));
|
||||
if (!hostent->h_addr_list)
|
||||
break;
|
||||
hostent->h_addr_list[1] = NULL;
|
||||
hostent->h_addr_list[0] = malloc(addrlen);
|
||||
hostent->h_addr_list[0] = ares_malloc(addrlen);
|
||||
if (!hostent->h_addr_list[0])
|
||||
break;
|
||||
if (addr.family == AF_INET)
|
||||
@@ -191,7 +191,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
memcpy(hostent->h_addr_list[0], &addr.addrV6, sizeof(addr.addrV6));
|
||||
|
||||
/* Copy aliases. */
|
||||
hostent->h_aliases = malloc((naliases + 1) * sizeof(char *));
|
||||
hostent->h_aliases = ares_malloc((naliases + 1) * sizeof(char *));
|
||||
if (!hostent->h_aliases)
|
||||
break;
|
||||
alias = hostent->h_aliases;
|
||||
@@ -207,7 +207,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
while (*q && ISSPACE(*q))
|
||||
q++;
|
||||
*p = '\0';
|
||||
if ((*alias = strdup(txtalias)) == NULL)
|
||||
if ((*alias = ares_strdup(txtalias)) == NULL)
|
||||
break;
|
||||
alias++;
|
||||
txtalias = *q ? q : NULL;
|
||||
@@ -221,7 +221,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
hostent->h_length = aresx_uztoss(addrlen);
|
||||
|
||||
/* Free line buffer. */
|
||||
free(line);
|
||||
ares_free(line);
|
||||
|
||||
/* Return hostent successfully */
|
||||
*host = hostent;
|
||||
@@ -231,7 +231,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
|
||||
/* If allocated, free line buffer. */
|
||||
if (line)
|
||||
free(line);
|
||||
ares_free(line);
|
||||
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
@@ -239,20 +239,20 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
if (hostent)
|
||||
{
|
||||
if (hostent->h_name)
|
||||
free((char *) hostent->h_name);
|
||||
ares_free((char *) hostent->h_name);
|
||||
if (hostent->h_aliases)
|
||||
{
|
||||
for (alias = hostent->h_aliases; *alias; alias++)
|
||||
free(*alias);
|
||||
free(hostent->h_aliases);
|
||||
ares_free(*alias);
|
||||
ares_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);
|
||||
ares_free(hostent->h_addr_list[0]);
|
||||
ares_free(hostent->h_addr_list);
|
||||
}
|
||||
free(hostent);
|
||||
ares_free(hostent);
|
||||
}
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
|
||||
+7
-3
@@ -36,7 +36,7 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
|
||||
|
||||
if (*buf == NULL)
|
||||
{
|
||||
*buf = malloc(128);
|
||||
*buf = ares_malloc(128);
|
||||
if (!*buf)
|
||||
return ARES_ENOMEM;
|
||||
*bufsize = 128;
|
||||
@@ -59,9 +59,13 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
|
||||
continue;
|
||||
|
||||
/* Allocate more space. */
|
||||
newbuf = realloc(*buf, *bufsize * 2);
|
||||
newbuf = ares_realloc(*buf, *bufsize * 2);
|
||||
if (!newbuf)
|
||||
return ARES_ENOMEM;
|
||||
{
|
||||
ares_free(*buf);
|
||||
*buf = NULL;
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
*buf = newbuf;
|
||||
*bufsize *= 2;
|
||||
}
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ struct timeval ares__tvnow(void)
|
||||
*/
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
else
|
||||
(void)gettimeofday(&now, NULL);
|
||||
(void)gettimeofday(&now, NULL); /* LCOV_EXCL_LINE */
|
||||
#else
|
||||
else {
|
||||
now.tv_sec = (long)time(NULL);
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/* ares_build.h. Generated from ares_build.h.in by configure. */
|
||||
#ifndef __CARES_BUILD_H
|
||||
#define __CARES_BUILD_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.
|
||||
*/
|
||||
|
||||
/* ================================================================ */
|
||||
/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */
|
||||
/* ================================================================ */
|
||||
|
||||
/*
|
||||
* NOTE 1:
|
||||
* -------
|
||||
*
|
||||
* Nothing in this file is intended to be modified or adjusted by the
|
||||
* c-ares library user nor by the c-ares library builder.
|
||||
*
|
||||
* If you think that something actually needs to be changed, adjusted
|
||||
* or fixed in this file, then, report it on the c-ares development
|
||||
* mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/
|
||||
*
|
||||
* This header file shall only export symbols which are 'cares' or 'CARES'
|
||||
* prefixed, otherwise public name space would be polluted.
|
||||
*
|
||||
* NOTE 2:
|
||||
* -------
|
||||
*
|
||||
* Right now you might be staring at file ares_build.h.in or ares_build.h,
|
||||
* this is due to the following reason:
|
||||
*
|
||||
* 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, which is generated
|
||||
* from the ares_build.h.in template file.
|
||||
*
|
||||
*/
|
||||
|
||||
/* ================================================================ */
|
||||
/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */
|
||||
/* ================================================================ */
|
||||
|
||||
#ifdef CARES_TYPEOF_ARES_SOCKLEN_T
|
||||
# error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
|
||||
Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined
|
||||
#endif
|
||||
|
||||
/* ================================================================ */
|
||||
/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */
|
||||
/* ================================================================ */
|
||||
|
||||
/* 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 */
|
||||
#ifdef CARES_PULL_WS2TCPIP_H
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file sys/types.h must be included by the external interface. */
|
||||
/* #undef CARES_PULL_SYS_TYPES_H */
|
||||
#ifdef CARES_PULL_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file sys/socket.h must be included by the external interface. */
|
||||
/* #undef CARES_PULL_SYS_SOCKET_H */
|
||||
#ifdef CARES_PULL_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* Integral data type used for ares_socklen_t. */
|
||||
#define CARES_TYPEOF_ARES_SOCKLEN_T int
|
||||
|
||||
/* Data type definition of ares_socklen_t. */
|
||||
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
|
||||
|
||||
#endif /* __CARES_BUILD_H */
|
||||
+4
-4
@@ -216,12 +216,12 @@
|
||||
/* ===================================== */
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
# if defined(__ILP32__) || \
|
||||
defined(__i386__) || defined(__ppc__) || defined(__arm__)
|
||||
# define CARES_SIZEOF_LONG 4
|
||||
# elif defined(__LP64__) || \
|
||||
# if defined(__LP64__) || \
|
||||
defined(__x86_64__) || defined(__ppc64__)
|
||||
# define CARES_SIZEOF_LONG 8
|
||||
# elif defined(__ILP32__) || \
|
||||
defined(__i386__) || defined(__ppc__) || defined(__arm__)
|
||||
# define CARES_SIZEOF_LONG 4
|
||||
# endif
|
||||
# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
|
||||
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
|
||||
|
||||
@@ -50,21 +50,11 @@
|
||||
/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */
|
||||
/* ================================================================ */
|
||||
|
||||
#ifdef CARES_SIZEOF_LONG
|
||||
# error "CARES_SIZEOF_LONG shall not be defined except in ares_build.h"
|
||||
Error Compilation_aborted_CARES_SIZEOF_LONG_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CARES_TYPEOF_ARES_SOCKLEN_T
|
||||
# error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
|
||||
Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CARES_SIZEOF_ARES_SOCKLEN_T
|
||||
# error "CARES_SIZEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
|
||||
Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_already_defined
|
||||
#endif
|
||||
|
||||
/* ================================================================ */
|
||||
/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */
|
||||
/* ================================================================ */
|
||||
@@ -95,15 +85,9 @@
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#undef CARES_SIZEOF_LONG
|
||||
|
||||
/* Integral data type used for ares_socklen_t. */
|
||||
#undef CARES_TYPEOF_ARES_SOCKLEN_T
|
||||
|
||||
/* The size of `ares_socklen_t', as computed by sizeof. */
|
||||
#undef CARES_SIZEOF_ARES_SOCKLEN_T
|
||||
|
||||
/* Data type definition of ares_socklen_t. */
|
||||
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
|
||||
|
||||
|
||||
+8
-7
@@ -23,14 +23,15 @@ ares_cancel \- Cancel a resolve
|
||||
.B void ares_cancel(ares_channel \fIchannel\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The \fBares_cancel\fP function cancels all lookups/requests made on the the
|
||||
name service channel identified by \fIchannel\fP. \fBares_cancel\fP invokes
|
||||
the callbacks for each pending query on the channel, passing a status of
|
||||
The \fBares_cancel(3)\fP function cancels all lookups/requests made on the the
|
||||
name service channel identified by \fIchannel\fP. \fBares_cancel(3)\fP
|
||||
invokes the callbacks for each pending query on the channel, passing a status
|
||||
of
|
||||
.BR ARES_ECANCELLED .
|
||||
These calls give the callbacks a chance to clean up any state which
|
||||
might have been stored in their arguments. If such a callback invocation adds
|
||||
a new request to the channel, that request will \fInot\fP be cancelled by the
|
||||
current invocation of \fBares_cancel\fP.
|
||||
These calls give the callbacks a chance to clean up any state which might have
|
||||
been stored in their arguments. If such a callback invocation adds a new
|
||||
request to the channel, that request will \fInot\fP be cancelled by the
|
||||
current invocation of \fBares_cancel(3)\fP.
|
||||
.SH SEE ALSO
|
||||
.BR ares_init (3)
|
||||
.BR ares_destroy (3)
|
||||
|
||||
+502
@@ -0,0 +1,502 @@
|
||||
/* 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 */
|
||||
#define ARES_BIG_ENDIAN 1
|
||||
|
||||
/* when building as static part of libcurl */
|
||||
/* #undef BUILDING_LIBCURL */
|
||||
|
||||
/* Defined for build that exposes internal static functions for testing. */
|
||||
/* #undef CARES_EXPOSE_STATICS */
|
||||
|
||||
/* Defined for build with symbol hiding. */
|
||||
/* #undef CARES_SYMBOL_HIDING */
|
||||
|
||||
/* Definition to make a library symbol externally visible. */
|
||||
/* #undef CARES_SYMBOL_SCOPE_EXTERN */
|
||||
|
||||
/* Use resolver library to configure cares */
|
||||
/* #undef CARES_USE_LIBRESOLV */
|
||||
|
||||
/* if a /etc/inet dir is being used */
|
||||
/* #undef ETC_INET */
|
||||
|
||||
/* Define to the type of arg 2 for gethostname. */
|
||||
#define GETHOSTNAME_TYPE_ARG2 int
|
||||
|
||||
/* Define to the type qualifier of arg 1 for getnameinfo. */
|
||||
/* #undef GETNAMEINFO_QUAL_ARG1 */
|
||||
|
||||
/* Define to the type of arg 1 for getnameinfo. */
|
||||
/* #undef GETNAMEINFO_TYPE_ARG1 */
|
||||
|
||||
/* Define to the type of arg 2 for getnameinfo. */
|
||||
/* #undef GETNAMEINFO_TYPE_ARG2 */
|
||||
|
||||
/* Define to the type of args 4 and 6 for getnameinfo. */
|
||||
/* #undef GETNAMEINFO_TYPE_ARG46 */
|
||||
|
||||
/* Define to the type of arg 7 for getnameinfo. */
|
||||
/* #undef GETNAMEINFO_TYPE_ARG7 */
|
||||
|
||||
/* 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. */
|
||||
/* #undef HAVE_AF_INET6 */
|
||||
|
||||
/* 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. */
|
||||
/* #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 if the compiler supports basic C++11 syntax */
|
||||
/* #undef HAVE_CXX11 */
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
|
||||
/* 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. */
|
||||
/* #undef HAVE_FCNTL */
|
||||
|
||||
/* 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. */
|
||||
/* #undef HAVE_FCNTL_O_NONBLOCK */
|
||||
|
||||
/* Define to 1 if you have the freeaddrinfo function. */
|
||||
/* #undef HAVE_FREEADDRINFO */
|
||||
|
||||
/* Define to 1 if you have a working getaddrinfo function. */
|
||||
/* #undef HAVE_GETADDRINFO */
|
||||
|
||||
/* Define to 1 if the getaddrinfo function is threadsafe. */
|
||||
/* #undef HAVE_GETADDRINFO_THREADSAFE */
|
||||
|
||||
/* Define to 1 if you have the getenv function. */
|
||||
#define HAVE_GETENV 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. */
|
||||
/* #undef HAVE_GETNAMEINFO */
|
||||
|
||||
/* 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. */
|
||||
/* #undef HAVE_IF_INDEXTONAME */
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_net_pton function. */
|
||||
/* #undef HAVE_INET_NET_PTON */
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_ntop function. */
|
||||
/* #undef HAVE_INET_NTOP */
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_pton function. */
|
||||
/* #undef HAVE_INET_PTON */
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
/* #undef HAVE_INTTYPES_H */
|
||||
|
||||
/* 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. */
|
||||
/* #undef HAVE_PF_INET6 */
|
||||
|
||||
/* 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. */
|
||||
/* #undef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID */
|
||||
|
||||
/* 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. */
|
||||
/* #undef HAVE_STDINT_H */
|
||||
|
||||
/* 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. */
|
||||
#define HAVE_STRICMP 1
|
||||
|
||||
/* 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. */
|
||||
/* #undef HAVE_STRUCT_ADDRINFO */
|
||||
|
||||
/* Define to 1 if you have struct in6_addr. */
|
||||
/* #undef HAVE_STRUCT_IN6_ADDR */
|
||||
|
||||
/* Define to 1 if you have struct sockaddr_in6. */
|
||||
/* #undef HAVE_STRUCT_SOCKADDR_IN6 */
|
||||
|
||||
/* if struct sockaddr_storage is defined */
|
||||
/* #undef HAVE_STRUCT_SOCKADDR_STORAGE */
|
||||
|
||||
/* 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. */
|
||||
/* #undef HAVE_SYS_SELECT_H */
|
||||
|
||||
/* 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. */
|
||||
/* #undef HAVE_WRITEV */
|
||||
|
||||
/* Define to 1 if you have the ws2tcpip.h header file. */
|
||||
/* #undef HAVE_WS2TCPIP_H */
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* 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 */
|
||||
|
||||
/* cpu-machine-OS */
|
||||
#define OS "m68k-unknown-amigaos"
|
||||
|
||||
/* 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.12.0"
|
||||
|
||||
/* 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.12.0"
|
||||
|
||||
/* a suitable file/device to read random data from */
|
||||
/* #undef RANDOM_FILE */
|
||||
|
||||
/* Define to the type qualifier pointed by arg 5 for recvfrom. */
|
||||
#define RECVFROM_QUAL_ARG5
|
||||
|
||||
/* 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 int
|
||||
|
||||
/* 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
|
||||
|
||||
/* 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. */
|
||||
#define USE_BLOCKING_SOCKETS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.12.0"
|
||||
|
||||
/* Define to avoid automatic inclusion of winsock.h */
|
||||
/* #undef WIN32_LEAN_AND_MEAN */
|
||||
|
||||
/* 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
|
||||
|
||||
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||
# define _DARWIN_USE_64_BIT_INODE 1
|
||||
#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. */
|
||||
#define in_addr_t unsigned long
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* the signed version of size_t */
|
||||
/* #undef ssize_t */
|
||||
+32
-37
@@ -18,45 +18,39 @@
|
||||
ares_create_query \- Compose a single-question DNS query buffer
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B int ares_create_query(const char *\fIname\fP, int \fIdnsclass\fP,\
|
||||
int \fItype\fP,
|
||||
.B unsigned short \fIid\fP, int \fIrd\fP,\
|
||||
unsigned char **\fIbuf\fP,
|
||||
.B int *\fIbuflen\fP, int \fImax_udp_size\fP)
|
||||
#include <ares.h>
|
||||
|
||||
int ares_create_query(const char *\fIname\fP,
|
||||
int \fIdnsclass\fP,
|
||||
int \fItype\fP,
|
||||
unsigned short \fIid\fP,
|
||||
int \fIrd\fP,
|
||||
unsigned char **\fIbuf\fP,
|
||||
int *\fIbuflen\fP,
|
||||
int \fImax_udp_size\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.B ares_create_query
|
||||
function composes a DNS query with a single question.
|
||||
The parameter
|
||||
.I name
|
||||
gives the query name as a NUL-terminated C string of period-separated
|
||||
labels optionally ending with a period; periods and backslashes within
|
||||
a label must be escaped with a backlash. The parameters
|
||||
.I dnsclass
|
||||
and
|
||||
.I type
|
||||
give the class and type of the query using the values defined in
|
||||
.BR <arpa/nameser.h> .
|
||||
The parameter
|
||||
.I id
|
||||
gives a 16-bit identifier for the query. The parameter
|
||||
.I rd
|
||||
should be nonzero if recursion is desired, zero if not. The query
|
||||
will be placed in an allocated buffer, a pointer to which will be
|
||||
stored in the variable pointed to by
|
||||
.IR buf ,
|
||||
and the length of which will be stored in the variable pointed to by
|
||||
.IR buflen .
|
||||
The \fIares_create_query(3)\fP function composes a DNS query with a single
|
||||
question. The parameter \fIname\fP gives the query name as a NUL-terminated C
|
||||
string of period-separated labels optionally ending with a period; periods and
|
||||
backslashes within a label must be escaped with a backlash.
|
||||
|
||||
The parameters \fIdnsclass\fP and \fItype\fP give the class and type of the
|
||||
query using the values defined in \fB<arpa/nameser.h>\fP.
|
||||
|
||||
The parameter \fIid\fP gives a 16-bit identifier for the query.
|
||||
|
||||
The parameter \fIrd\fP should be nonzero if recursion is desired, zero if not.
|
||||
|
||||
The query will be placed in an allocated buffer, a pointer to which will be
|
||||
stored in the variable pointed to by \fIbuf\fP, and the length of which will
|
||||
be stored in the variable pointed to by \fIbuflen\fP.
|
||||
|
||||
It is the caller's responsibility to free this buffer using
|
||||
\fIares_free_string(3)\fP when it is no longer needed.
|
||||
The parameter
|
||||
.I max_udp_size
|
||||
should be nonzero to activate EDNS. Usage of \fIares_create_query(3)\fP\ with
|
||||
.I max_udp_size
|
||||
set to zero is equivalent to \fIares_mkquery(3)\fP.
|
||||
\fIares_free_string(3)\fP when it is no longer needed. The parameter
|
||||
\fImax_udp_size\fP should be nonzero to activate EDNS. Usage of
|
||||
\fIares_create_query(3)\fP\ with \fImax_udp_size\fP set to zero is equivalent
|
||||
to using \fIares_mkquery(3)\fP.
|
||||
.SH RETURN VALUES
|
||||
.B ares_create_query
|
||||
can return any of the following values:
|
||||
@@ -77,5 +71,6 @@ Memory was exhausted.
|
||||
Added in c-ares 1.10.0
|
||||
.SH SEE ALSO
|
||||
.BR ares_expand_name (3),
|
||||
.BR ares_free_string (3)
|
||||
.BR ares_free_string (3),
|
||||
.BR ares_mkquery (3)
|
||||
.SH AUTHOR
|
||||
|
||||
+39
-45
@@ -85,57 +85,31 @@
|
||||
*/
|
||||
|
||||
int ares_create_query(const char *name, int dnsclass, int type,
|
||||
unsigned short id, int rd, unsigned char **buf,
|
||||
int *buflen, int max_udp_size)
|
||||
unsigned short id, int rd, unsigned char **bufp,
|
||||
int *buflenp, int max_udp_size)
|
||||
{
|
||||
int len;
|
||||
size_t len;
|
||||
unsigned char *q;
|
||||
const char *p;
|
||||
size_t buflen;
|
||||
unsigned char *buf;
|
||||
|
||||
/* Set our results early, in case we bail out early with an error. */
|
||||
*buflen = 0;
|
||||
*buf = NULL;
|
||||
*buflenp = 0;
|
||||
*bufp = 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.
|
||||
/* Allocate a memory area for the maximum size this packet might need. +2
|
||||
* is for the length byte and zero termination if no dots or ecscaping is
|
||||
* used.
|
||||
*/
|
||||
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 + (max_udp_size ? EDNSFIXEDSZ : 0);
|
||||
*buf = malloc(*buflen);
|
||||
if (!*buf)
|
||||
return ARES_ENOMEM;
|
||||
len = strlen(name) + 2 + HFIXEDSZ + QFIXEDSZ +
|
||||
(max_udp_size ? EDNSFIXEDSZ : 0);
|
||||
buf = ares_malloc(len);
|
||||
if (!buf)
|
||||
return ARES_ENOMEM;
|
||||
|
||||
/* Set up the header. */
|
||||
q = *buf;
|
||||
q = buf;
|
||||
memset(q, 0, HFIXEDSZ);
|
||||
DNS_HEADER_SET_QID(q, id);
|
||||
DNS_HEADER_SET_OPCODE(q, QUERY);
|
||||
@@ -159,8 +133,10 @@ int ares_create_query(const char *name, int dnsclass, int type,
|
||||
q += HFIXEDSZ;
|
||||
while (*name)
|
||||
{
|
||||
if (*name == '.')
|
||||
if (*name == '.') {
|
||||
free (buf);
|
||||
return ARES_EBADNAME;
|
||||
}
|
||||
|
||||
/* Count the number of bytes in this label. */
|
||||
len = 0;
|
||||
@@ -170,8 +146,10 @@ int ares_create_query(const char *name, int dnsclass, int type,
|
||||
p++;
|
||||
len++;
|
||||
}
|
||||
if (len > MAXLABEL)
|
||||
if (len > MAXLABEL) {
|
||||
free (buf);
|
||||
return ARES_EBADNAME;
|
||||
}
|
||||
|
||||
/* Encode the length and copy the data. */
|
||||
*q++ = (unsigned char)len;
|
||||
@@ -195,14 +173,30 @@ int ares_create_query(const char *name, int dnsclass, int type,
|
||||
DNS_QUESTION_SET_TYPE(q, type);
|
||||
DNS_QUESTION_SET_CLASS(q, dnsclass);
|
||||
|
||||
q += QFIXEDSZ;
|
||||
if (max_udp_size)
|
||||
{
|
||||
q += QFIXEDSZ;
|
||||
memset(q, 0, EDNSFIXEDSZ);
|
||||
q++;
|
||||
DNS_RR_SET_TYPE(q, T_OPT);
|
||||
DNS_RR_SET_CLASS(q, max_udp_size);
|
||||
q += (EDNSFIXEDSZ-1);
|
||||
}
|
||||
buflen = (q - buf);
|
||||
|
||||
/* 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."). */
|
||||
if (buflen > (MAXCDNAME + HFIXEDSZ + QFIXEDSZ +
|
||||
(max_udp_size ? EDNSFIXEDSZ : 0))) {
|
||||
free (buf);
|
||||
return ARES_EBADNAME;
|
||||
}
|
||||
|
||||
/* we know this fits in an int at this point */
|
||||
*buflenp = (int) buflen;
|
||||
*bufp = buf;
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
+32
-12
@@ -67,7 +67,7 @@ void ares_free_data(void *dataptr)
|
||||
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);
|
||||
ares_free(ptr->data.mx_reply.host);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_SRV_REPLY:
|
||||
@@ -75,15 +75,16 @@ void ares_free_data(void *dataptr)
|
||||
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);
|
||||
ares_free(ptr->data.srv_reply.host);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_TXT_REPLY:
|
||||
case ARES_DATATYPE_TXT_EXT:
|
||||
|
||||
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);
|
||||
ares_free(ptr->data.txt_reply.txt);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_ADDR_NODE:
|
||||
@@ -92,32 +93,38 @@ void ares_free_data(void *dataptr)
|
||||
ares_free_data(ptr->data.addr_node.next);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_ADDR_PORT_NODE:
|
||||
|
||||
if (ptr->data.addr_port_node.next)
|
||||
ares_free_data(ptr->data.addr_port_node.next);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_NAPTR_REPLY:
|
||||
|
||||
if (ptr->data.naptr_reply.next)
|
||||
ares_free_data(ptr->data.naptr_reply.next);
|
||||
if (ptr->data.naptr_reply.flags)
|
||||
free(ptr->data.naptr_reply.flags);
|
||||
ares_free(ptr->data.naptr_reply.flags);
|
||||
if (ptr->data.naptr_reply.service)
|
||||
free(ptr->data.naptr_reply.service);
|
||||
ares_free(ptr->data.naptr_reply.service);
|
||||
if (ptr->data.naptr_reply.regexp)
|
||||
free(ptr->data.naptr_reply.regexp);
|
||||
ares_free(ptr->data.naptr_reply.regexp);
|
||||
if (ptr->data.naptr_reply.replacement)
|
||||
free(ptr->data.naptr_reply.replacement);
|
||||
ares_free(ptr->data.naptr_reply.replacement);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_SOA_REPLY:
|
||||
if (ptr->data.soa_reply.nsname)
|
||||
free(ptr->data.soa_reply.nsname);
|
||||
ares_free(ptr->data.soa_reply.nsname);
|
||||
if (ptr->data.soa_reply.hostmaster)
|
||||
free(ptr->data.soa_reply.hostmaster);
|
||||
ares_free(ptr->data.soa_reply.hostmaster);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
free(ptr);
|
||||
ares_free(ptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +143,7 @@ void *ares_malloc_data(ares_datatype type)
|
||||
{
|
||||
struct ares_data *ptr;
|
||||
|
||||
ptr = malloc(sizeof(struct ares_data));
|
||||
ptr = ares_malloc(sizeof(struct ares_data));
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
@@ -156,6 +163,10 @@ void *ares_malloc_data(ares_datatype type)
|
||||
ptr->data.srv_reply.port = 0;
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_TXT_EXT:
|
||||
ptr->data.txt_ext.record_start = 0;
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case ARES_DATATYPE_TXT_REPLY:
|
||||
ptr->data.txt_reply.next = NULL;
|
||||
ptr->data.txt_reply.txt = NULL;
|
||||
@@ -169,6 +180,15 @@ void *ares_malloc_data(ares_datatype type)
|
||||
sizeof(ptr->data.addr_node.addrV6));
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_ADDR_PORT_NODE:
|
||||
ptr->data.addr_port_node.next = NULL;
|
||||
ptr->data.addr_port_node.family = 0;
|
||||
ptr->data.addr_port_node.udp_port = 0;
|
||||
ptr->data.addr_port_node.tcp_port = 0;
|
||||
memset(&ptr->data.addr_port_node.addrV6, 0,
|
||||
sizeof(ptr->data.addr_port_node.addrV6));
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_NAPTR_REPLY:
|
||||
ptr->data.naptr_reply.next = NULL;
|
||||
ptr->data.naptr_reply.flags = NULL;
|
||||
@@ -190,7 +210,7 @@ void *ares_malloc_data(ares_datatype type)
|
||||
break;
|
||||
|
||||
default:
|
||||
free(ptr);
|
||||
ares_free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -18,6 +18,7 @@ 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_TXT_EXT, /* struct ares_txt_ext - introduced in 1.11.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 */
|
||||
ARES_DATATYPE_NAPTR_REPLY,/* struct ares_naptr_reply - introduced in 1.7.6 */
|
||||
@@ -28,6 +29,7 @@ typedef enum {
|
||||
ARES_DATATYPE_HOSTENT, /* struct hostent */
|
||||
ARES_DATATYPE_OPTIONS, /* struct ares_options */
|
||||
#endif
|
||||
ARES_DATATYPE_ADDR_PORT_NODE, /* struct ares_addr_port_node - introduced in 1.11.0 */
|
||||
ARES_DATATYPE_LAST /* not used - introduced in 1.7.0 */
|
||||
} ares_datatype;
|
||||
|
||||
@@ -55,12 +57,14 @@ 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;
|
||||
struct ares_naptr_reply naptr_reply;
|
||||
struct ares_soa_reply soa_reply;
|
||||
struct ares_txt_reply txt_reply;
|
||||
struct ares_txt_ext txt_ext;
|
||||
struct ares_srv_reply srv_reply;
|
||||
struct ares_addr_node addr_node;
|
||||
struct ares_addr_port_node addr_port_node;
|
||||
struct ares_mx_reply mx_reply;
|
||||
struct ares_naptr_reply naptr_reply;
|
||||
struct ares_soa_reply soa_reply;
|
||||
} data;
|
||||
};
|
||||
|
||||
|
||||
+8
-12
@@ -23,18 +23,14 @@ ares_destroy \- Destroy a resolver channel
|
||||
.B void ares_destroy(ares_channel \fIchannel\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.B ares_destroy
|
||||
function destroys the name service channel identified by
|
||||
.IR channel ,
|
||||
freeing all memory and closing all sockets used by the channel.
|
||||
.B ares_destroy
|
||||
invokes the callbacks for each pending query on the channel, passing a
|
||||
status of
|
||||
.BR ARES_EDESTRUCTION .
|
||||
These calls give the callbacks a chance to clean up any state which
|
||||
might have been stored in their arguments. A callback must not add new
|
||||
requests to a channel being destroyed.
|
||||
The \fBares_destroy(3)\fP function destroys the name service channel
|
||||
identified by \fIchannel\fP, freeing all memory and closing all sockets used
|
||||
by the channel.
|
||||
|
||||
\fBares_destroy(3)\fP invokes the callbacks for each pending query on the
|
||||
channel, passing a status of \IARES_EDESTRUCTION\fP. These calls give the
|
||||
callbacks a chance to clean up any state which might have been stored in their
|
||||
arguments. A callback must not add new requests to a channel being destroyed.
|
||||
.SH SEE ALSO
|
||||
.BR ares_init (3),
|
||||
.BR ares_cancel (3)
|
||||
|
||||
+11
-11
@@ -27,15 +27,15 @@ void ares_destroy_options(struct ares_options *options)
|
||||
int i;
|
||||
|
||||
if(options->servers)
|
||||
free(options->servers);
|
||||
ares_free(options->servers);
|
||||
for (i = 0; i < options->ndomains; i++)
|
||||
free(options->domains[i]);
|
||||
ares_free(options->domains[i]);
|
||||
if(options->domains)
|
||||
free(options->domains);
|
||||
ares_free(options->domains);
|
||||
if(options->sortlist)
|
||||
free(options->sortlist);
|
||||
ares_free(options->sortlist);
|
||||
if(options->lookups)
|
||||
free(options->lookups);
|
||||
ares_free(options->lookups);
|
||||
}
|
||||
|
||||
void ares_destroy(ares_channel channel)
|
||||
@@ -75,17 +75,17 @@ void ares_destroy(ares_channel channel)
|
||||
|
||||
if (channel->domains) {
|
||||
for (i = 0; i < channel->ndomains; i++)
|
||||
free(channel->domains[i]);
|
||||
free(channel->domains);
|
||||
ares_free(channel->domains[i]);
|
||||
ares_free(channel->domains);
|
||||
}
|
||||
|
||||
if(channel->sortlist)
|
||||
free(channel->sortlist);
|
||||
ares_free(channel->sortlist);
|
||||
|
||||
if (channel->lookups)
|
||||
free(channel->lookups);
|
||||
ares_free(channel->lookups);
|
||||
|
||||
free(channel);
|
||||
ares_free(channel);
|
||||
}
|
||||
|
||||
void ares__destroy_servers_state(ares_channel channel)
|
||||
@@ -101,7 +101,7 @@ void ares__destroy_servers_state(ares_channel channel)
|
||||
ares__close_sockets(channel, server);
|
||||
assert(ares__is_list_empty(&server->queries_to_server));
|
||||
}
|
||||
free(channel->servers);
|
||||
ares_free(channel->servers);
|
||||
channel->servers = NULL;
|
||||
}
|
||||
channel->nservers = -1;
|
||||
|
||||
@@ -23,12 +23,9 @@ ares_destroy_options \- Destroy options initialized with ares_save_options
|
||||
.B void ares_destroy_options(struct ares_options *\fIoptions\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.B ares_destroy_options
|
||||
function destroys the options struct identified by
|
||||
.IR options ,
|
||||
freeing all memory allocated by ares_save_options.
|
||||
|
||||
The \fBares_destroy_options(3)\fP function destroys the options struct
|
||||
identified by \Ioptions\fP, freeing all memory allocated by
|
||||
\fBares_save_options(3)\fP.
|
||||
.SH SEE ALSO
|
||||
.BR ares_save_options (3),
|
||||
.BR ares_init_options (3)
|
||||
|
||||
+18
@@ -16,6 +16,9 @@
|
||||
* without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include <sys/endian.h>
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Macro DNS__16BIT reads a network short (16 bit) given in network
|
||||
* byte order, and returns its value as an unsigned short.
|
||||
@@ -40,6 +43,7 @@
|
||||
((p)[1] = (unsigned char)(((v) >> 16) & 0xff)), \
|
||||
((p)[2] = (unsigned char)(((v) >> 8) & 0xff)), \
|
||||
((p)[3] = (unsigned char)((v) & 0xff)))
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* we cannot use this approach on systems where we can't access 16/32 bit
|
||||
@@ -50,6 +54,20 @@
|
||||
#define DNS__SET32BIT(p, v) *(unsigned long*)(p) = htonl(v)
|
||||
#endif
|
||||
|
||||
/* use use this approach on systems where we can't access 16/32 bit
|
||||
data on un-aligned addresses */
|
||||
#ifdef ARES_BIG_ENDIAN
|
||||
#define DNS__16BIT(p) be16dec(p)
|
||||
#define DNS__32BIT(p) be32dec(p)
|
||||
#define DNS__SET16BIT(p, v) be16enc(p,v)
|
||||
#define DNS__SET32BIT(p, v) be32enc
|
||||
#else
|
||||
#define DNS__16BIT(p) le16dec(p)
|
||||
#define DNS__32BIT(p) le32dec(p)
|
||||
#define DNS__SET16BIT(p, v) le16enc(p,v)
|
||||
#define DNS__SET32BIT(p, v) le32enc
|
||||
#endif
|
||||
|
||||
/* Macros for parsing a DNS header */
|
||||
#define DNS_HEADER_QID(h) DNS__16BIT(h)
|
||||
#define DNS_HEADER_QR(h) (((h)[2] >> 7) & 0x1)
|
||||
|
||||
+1
-5
@@ -28,16 +28,12 @@ for name service lookups. If it returns successfully, \fBares_dup(3)\fP will
|
||||
set the variable pointed to by \fIdest\fP to a handle used to identify the
|
||||
name service channel. The caller should invoke \fIares_destroy(3)\fP on the
|
||||
handle when the channel is no longer needed.
|
||||
|
||||
The \fBares_dup_options\fP function also initializes a name service channel,
|
||||
with additional options set exactly as the \fIsource\fP channel has them
|
||||
configured.
|
||||
.SH SEE ALSO
|
||||
.BR ares_destroy(3),
|
||||
.BR ares_init(3),
|
||||
.BR ares_library_init(3)
|
||||
.SH AVAILABILITY
|
||||
ares_dup(3) was added in c-ares 1.6.0
|
||||
\fIares_dup(3)\fP was added in c-ares 1.6.0
|
||||
.SH AUTHOR
|
||||
Daniel Stenberg
|
||||
|
||||
|
||||
+13
-5
@@ -74,7 +74,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
|
||||
if (nlen.sig < 0)
|
||||
return ARES_EBADNAME;
|
||||
|
||||
*s = malloc(nlen.uns + 1);
|
||||
*s = ares_malloc(nlen.uns + 1);
|
||||
if (!*s)
|
||||
return ARES_ENOMEM;
|
||||
q = *s;
|
||||
@@ -129,7 +129,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
|
||||
if (q > *s)
|
||||
*(q - 1) = 0;
|
||||
else
|
||||
*q = 0; /* zero terminate */
|
||||
*q = 0; /* zero terminate; LCOV_EXCL_LINE: empty names exit above */
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
|
||||
static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
||||
int alen)
|
||||
{
|
||||
int n = 0, offset, indir = 0;
|
||||
int n = 0, offset, indir = 0, top;
|
||||
|
||||
/* Allow the caller to pass us abuf + alen and have us check for it. */
|
||||
if (encoded >= abuf + alen)
|
||||
@@ -148,7 +148,8 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
||||
|
||||
while (*encoded)
|
||||
{
|
||||
if ((*encoded & INDIR_MASK) == INDIR_MASK)
|
||||
top = (*encoded & INDIR_MASK);
|
||||
if (top == INDIR_MASK)
|
||||
{
|
||||
/* Check the offset and go there. */
|
||||
if (encoded + 1 >= abuf + alen)
|
||||
@@ -164,7 +165,7 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
||||
if (++indir > alen)
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
else if (top == 0x00)
|
||||
{
|
||||
offset = *encoded;
|
||||
if (encoded + offset + 1 >= abuf + alen)
|
||||
@@ -177,6 +178,13 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
||||
}
|
||||
n++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* RFC 1035 4.1.4 says other options (01, 10) for top 2
|
||||
* bits are reserved.
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* If there were any labels at all, then the number of dots is one
|
||||
|
||||
@@ -54,7 +54,7 @@ int ares_expand_string(const unsigned char *encoded,
|
||||
|
||||
encoded++;
|
||||
|
||||
*s = malloc(elen.uns+1);
|
||||
*s = ares_malloc(elen.uns+1);
|
||||
if (*s == NULL)
|
||||
return ARES_ENOMEM;
|
||||
q = *s;
|
||||
|
||||
+6
-6
@@ -30,12 +30,12 @@ void ares_free_hostent(struct hostent *host)
|
||||
if (!host)
|
||||
return;
|
||||
|
||||
free((char *)(host->h_name));
|
||||
ares_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,
|
||||
ares_free(*p);
|
||||
ares_free(host->h_aliases);
|
||||
ares_free(host->h_addr_list[0]); /* no matter if there is one or many entries,
|
||||
there is only one malloc for all of them */
|
||||
free(host->h_addr_list);
|
||||
free(host);
|
||||
ares_free(host->h_addr_list);
|
||||
ares_free(host);
|
||||
}
|
||||
|
||||
+2
-3
@@ -23,9 +23,8 @@ ares_free_string \- Free strings allocated by ares functions
|
||||
.B void ares_free_string(void *\fIstr\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.I ares_free_string
|
||||
function frees a string allocated by an ares function.
|
||||
The \fIares_free_string(3)\fP function frees a string allocated by an ares
|
||||
function.
|
||||
.SH SEE ALSO
|
||||
.BR ares_mkquery (3)
|
||||
.BR ares_expand_string (3)
|
||||
|
||||
+1
-1
@@ -21,5 +21,5 @@
|
||||
|
||||
void ares_free_string(void *str)
|
||||
{
|
||||
free(str);
|
||||
ares_free(str);
|
||||
}
|
||||
|
||||
+13
-7
@@ -16,12 +16,13 @@
|
||||
.\"
|
||||
.TH ARES_GET_SERVERS 3 "5 March 2010"
|
||||
.SH NAME
|
||||
ares_get_servers \- Retrieve name servers from an initialized ares_channel
|
||||
ares_get_servers, ares_get_servers_ports \- Retrieve name servers from an initialized ares_channel
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B int ares_get_servers(ares_channel \fIchannel\fP, struct ares_addr_node **\fIservers\fP)
|
||||
.B int ares_get_servers_ports(ares_channel \fIchannel\fP, struct ares_addr_port_node **\fIservers\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The \fBares_get_servers(3)\fP function retrieves name servers configuration
|
||||
@@ -32,8 +33,13 @@ as a linked list of ares_addr_node structs storing a pointer to the first
|
||||
node at the address specified by
|
||||
.IR servers .
|
||||
|
||||
The \fBares_get_servers_ports(3)\fP function also retrieves any per-server
|
||||
port information that may have been previously configured, returning a linked
|
||||
list of ares_addr_port structures.
|
||||
|
||||
Function caller may traverse the returned name server linked list, or may use
|
||||
it directly as suitable input for the \fBares_set_servers(3)\fP function, but
|
||||
it directly as suitable input for the \fBares_set_servers(3)\fP /
|
||||
\fBares_set_servers_ports(3)\fP functions, but
|
||||
shall not shrink or extend the list on its own.
|
||||
|
||||
Each node of the name server linked list is stored in memory dynamically
|
||||
@@ -47,17 +53,16 @@ optmask \fBARES_OPT_SERVERS\fP functionally obsolete except for
|
||||
IPv4-only name server usage.
|
||||
|
||||
.SH RETURN VALUES
|
||||
.B ares_get_servers(3)
|
||||
may return any of the following values:
|
||||
This function may return any of the following values:
|
||||
.TP 15
|
||||
.B ARES_SUCCESS
|
||||
The name servers configuration was successfuly retrieved
|
||||
The name servers configuration was successfully retrieved
|
||||
.TP 15
|
||||
.B ARES_ENOMEM
|
||||
The memory was exhausted
|
||||
.TP 15
|
||||
.B ARES_ENODATA
|
||||
The channel data identified by
|
||||
The channel data identified by
|
||||
.IR channel
|
||||
was invalid.
|
||||
.SH SEE ALSO
|
||||
@@ -65,7 +70,8 @@ was invalid.
|
||||
.BR ares_init_options (3),
|
||||
.BR ares_save_options(3)
|
||||
.SH AVAILABILITY
|
||||
ares_get_servers(3) was added in c-ares 1.7.1
|
||||
\fBares_get_servers(3)\fP was added in c-ares 1.7.1;
|
||||
\fBares_get_servers_ports(3)\fP was added in c-ares 1.11.0.
|
||||
.SH AUTHOR
|
||||
Implementation of this function and associated library internals are based
|
||||
on code, comments and feedback provided in November and December of 2008 by
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.so man3/ares_get_servers.3
|
||||
@@ -79,7 +79,7 @@ void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
|
||||
return;
|
||||
}
|
||||
|
||||
aquery = malloc(sizeof(struct addr_query));
|
||||
aquery = ares_malloc(sizeof(struct addr_query));
|
||||
if (!aquery)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
||||
@@ -169,7 +169,7 @@ static void end_aquery(struct addr_query *aquery, int status,
|
||||
aquery->callback(aquery->arg, status, aquery->timeouts, host);
|
||||
if (host)
|
||||
ares_free_hostent(host);
|
||||
free(aquery);
|
||||
ares_free(aquery);
|
||||
}
|
||||
|
||||
static int file_lookup(struct ares_addr *addr, struct hostent **host)
|
||||
|
||||
+12
-9
@@ -99,18 +99,18 @@ void ares_gethostbyname(ares_channel channel, const char *name, int family,
|
||||
return;
|
||||
|
||||
/* Allocate and fill in the host query structure. */
|
||||
hquery = malloc(sizeof(struct host_query));
|
||||
hquery = ares_malloc(sizeof(struct host_query));
|
||||
if (!hquery)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
||||
return;
|
||||
}
|
||||
hquery->channel = channel;
|
||||
hquery->name = strdup(name);
|
||||
hquery->name = ares_strdup(name);
|
||||
hquery->want_family = family;
|
||||
hquery->sent_family = -1; /* nothing is sent yet */
|
||||
if (!hquery->name) {
|
||||
free(hquery);
|
||||
ares_free(hquery);
|
||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
||||
return;
|
||||
}
|
||||
@@ -188,11 +188,14 @@ static void host_callback(void *arg, int status, int timeouts,
|
||||
else if (hquery->sent_family == AF_INET6)
|
||||
{
|
||||
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
|
||||
if ((status == ARES_ENODATA || status == ARES_EBADRESP) &&
|
||||
hquery->want_family == AF_UNSPEC) {
|
||||
if ((status == ARES_ENODATA || status == ARES_EBADRESP ||
|
||||
(status == ARES_SUCCESS && host && host->h_addr_list[0] == NULL)) &&
|
||||
hquery->want_family == AF_UNSPEC) {
|
||||
/* 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. */
|
||||
if (host)
|
||||
ares_free_hostent(host);
|
||||
hquery->sent_family = AF_INET;
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_A,
|
||||
host_callback, hquery);
|
||||
@@ -224,8 +227,8 @@ static void end_hquery(struct host_query *hquery, int status,
|
||||
hquery->callback(hquery->arg, status, hquery->timeouts, host);
|
||||
if (host)
|
||||
ares_free_hostent(host);
|
||||
free(hquery->name);
|
||||
free(hquery);
|
||||
ares_free(hquery->name);
|
||||
ares_free(hquery);
|
||||
}
|
||||
|
||||
/* If the name looks like an IP address, fake up a host entry, end the
|
||||
@@ -284,7 +287,7 @@ static int fake_hostent(const char *name, int family,
|
||||
addrs[0] = (char *)&in6;
|
||||
}
|
||||
/* Duplicate the name, to avoid a constness violation. */
|
||||
hostent.h_name = strdup(name);
|
||||
hostent.h_name = ares_strdup(name);
|
||||
if (!hostent.h_name)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
||||
@@ -298,7 +301,7 @@ static int fake_hostent(const char *name, int family,
|
||||
hostent.h_addr_list = addrs;
|
||||
callback(arg, ARES_SUCCESS, 0, &hostent);
|
||||
|
||||
free((char *)(hostent.h_name));
|
||||
ares_free((char *)(hostent.h_name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,6 @@ will be
|
||||
.BR NULL .
|
||||
.SH SEE ALSO
|
||||
.BR ares_process (3),
|
||||
.BR ares_getaddrinfo (3)
|
||||
.SH AUTHOR
|
||||
Dominick Meglio
|
||||
.br
|
||||
|
||||
+24
-17
@@ -77,7 +77,7 @@ static char *lookup_service(unsigned short port, int flags,
|
||||
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);
|
||||
STATIC_TESTABLE char *ares_striendstr(const char *s1, const char *s2);
|
||||
|
||||
void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
||||
ares_socklen_t salen,
|
||||
@@ -163,7 +163,7 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
||||
/* This is where a DNS lookup becomes necessary */
|
||||
else
|
||||
{
|
||||
niquery = malloc(sizeof(struct nameinfo_query));
|
||||
niquery = ares_malloc(sizeof(struct nameinfo_query));
|
||||
if (!niquery)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, NULL);
|
||||
@@ -234,7 +234,7 @@ static void nameinfo_callback(void *arg, int status, int timeouts,
|
||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts,
|
||||
(char *)(host->h_name),
|
||||
service);
|
||||
free(niquery);
|
||||
ares_free(niquery);
|
||||
return;
|
||||
}
|
||||
/* We couldn't find the host, but it's OK, we can use the IP */
|
||||
@@ -265,11 +265,11 @@ static void nameinfo_callback(void *arg, int status, int timeouts,
|
||||
}
|
||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, ipbuf,
|
||||
service);
|
||||
free(niquery);
|
||||
ares_free(niquery);
|
||||
return;
|
||||
}
|
||||
niquery->callback(niquery->arg, status, niquery->timeouts, NULL, NULL);
|
||||
free(niquery);
|
||||
ares_free(niquery);
|
||||
}
|
||||
|
||||
static char *lookup_service(unsigned short port, int flags,
|
||||
@@ -281,6 +281,8 @@ static char *lookup_service(unsigned short port, int flags,
|
||||
struct servent se;
|
||||
#endif
|
||||
char tmpbuf[4096];
|
||||
char *name;
|
||||
size_t name_len;
|
||||
|
||||
if (port)
|
||||
{
|
||||
@@ -297,12 +299,13 @@ static char *lookup_service(unsigned short port, int flags,
|
||||
else
|
||||
proto = "tcp";
|
||||
#ifdef HAVE_GETSERVBYPORT_R
|
||||
memset(&se, 0, sizeof(se));
|
||||
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;
|
||||
sep = NULL; /* LCOV_EXCL_LINE: buffer large so this never fails */
|
||||
#elif GETSERVBYPORT_R_ARGS == 5
|
||||
sep = getservbyport_r(port, proto, &se, (void *)tmpbuf,
|
||||
sizeof(tmpbuf));
|
||||
@@ -323,17 +326,23 @@ static char *lookup_service(unsigned short port, int flags,
|
||||
#endif
|
||||
}
|
||||
if (sep && sep->s_name)
|
||||
/* get service name */
|
||||
strcpy(tmpbuf, sep->s_name);
|
||||
{
|
||||
/* get service name */
|
||||
name = sep->s_name;
|
||||
}
|
||||
else
|
||||
/* get port as a string */
|
||||
sprintf(tmpbuf, "%u", (unsigned int)ntohs(port));
|
||||
if (strlen(tmpbuf) < buflen)
|
||||
{
|
||||
/* get port as a string */
|
||||
sprintf(tmpbuf, "%u", (unsigned int)ntohs(port));
|
||||
name = tmpbuf;
|
||||
}
|
||||
name_len = strlen(name);
|
||||
if (name_len < buflen)
|
||||
/* return it if buffer big enough */
|
||||
strcpy(buf, tmpbuf);
|
||||
memcpy(buf, name, name_len + 1);
|
||||
else
|
||||
/* avoid reusing previous one */
|
||||
buf[0] = '\0';
|
||||
buf[0] = '\0'; /* LCOV_EXCL_LINE: no real service names are too big */
|
||||
return buf;
|
||||
}
|
||||
buf[0] = '\0';
|
||||
@@ -383,7 +392,7 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags,
|
||||
#endif
|
||||
|
||||
/* Determines if s1 ends with the string in s2 (case-insensitive) */
|
||||
static char *ares_striendstr(const char *s1, const char *s2)
|
||||
STATIC_TESTABLE char *ares_striendstr(const char *s1, const char *s2)
|
||||
{
|
||||
const char *c1, *c2, *c1_begin;
|
||||
int lo1, lo2;
|
||||
@@ -409,7 +418,5 @@ static char *ares_striendstr(const char *s1, const char *s2)
|
||||
c2++;
|
||||
}
|
||||
}
|
||||
if (c2 == c1 && c2 == NULL)
|
||||
return (char *)c1_begin;
|
||||
return NULL;
|
||||
return (char *)c1_begin;
|
||||
}
|
||||
|
||||
+3
-5
@@ -30,9 +30,7 @@ int ares_getsock(ares_channel channel,
|
||||
/* 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++)
|
||||
for (i = 0; i < channel->nservers; i++)
|
||||
{
|
||||
server = &channel->servers[i];
|
||||
/* We only need to register interest in UDP sockets if we have
|
||||
@@ -40,7 +38,7 @@ int ares_getsock(ares_channel channel,
|
||||
*/
|
||||
if (active_queries && server->udp_socket != ARES_SOCKET_BAD)
|
||||
{
|
||||
if(sockindex >= numsocks)
|
||||
if(sockindex >= numsocks || sockindex >= ARES_GETSOCK_MAXNUM)
|
||||
break;
|
||||
socks[sockindex] = server->udp_socket;
|
||||
bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex);
|
||||
@@ -52,7 +50,7 @@ int ares_getsock(ares_channel channel,
|
||||
*/
|
||||
if (server->tcp_socket != ARES_SOCKET_BAD)
|
||||
{
|
||||
if(sockindex >= numsocks)
|
||||
if(sockindex >= numsocks || sockindex >= ARES_GETSOCK_MAXNUM)
|
||||
break;
|
||||
socks[sockindex] = server->tcp_socket;
|
||||
bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex);
|
||||
|
||||
+14
-156
@@ -16,167 +16,24 @@
|
||||
.\"
|
||||
.TH ARES_INIT 3 "5 March 2010"
|
||||
.SH NAME
|
||||
ares_init, ares_init_options \- Initialize a resolver channel
|
||||
ares_init \- Initialize a resolver channel
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B int ares_init(ares_channel *\fIchannelptr\fP)
|
||||
.B int ares_init_options(ares_channel *\fIchannelptr\fP,
|
||||
.B struct ares_options *\fIoptions\fP, int \fIoptmask\fP)
|
||||
.PP
|
||||
.B cc file.c -lcares
|
||||
#include <ares.h>
|
||||
|
||||
int ares_init(ares_channel *\fIchannelptr\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The \fBares_init\fP function initializes a communications channel for name
|
||||
service lookups. If it returns successfully, \fBares_init\fP will set the
|
||||
The \fBares_init(3)\fP function initializes a communications channel for name
|
||||
service lookups. If it returns successfully, \fBares_init(3)\fP will set the
|
||||
variable pointed to by \fIchannelptr\fP to a handle used to identify the name
|
||||
service channel. The caller should invoke
|
||||
.BR ares_destroy (3)
|
||||
on the handle when the channel is no longer needed.
|
||||
.PP
|
||||
The \fBares_init_options\fP function also initializes a name service channel,
|
||||
with additional options useful for applications requiring more control over
|
||||
name service configuration. The \fIoptmask\fP parameter specifies which fields
|
||||
in the structure pointed to by \fIoptions\fP are set, as follows:
|
||||
.TP 18
|
||||
.B ARES_OPT_FLAGS
|
||||
.B int \fIflags\fP;
|
||||
.br
|
||||
Flags controlling the behavior of the resolver. See below for a
|
||||
description of possible flag values.
|
||||
.TP 18
|
||||
.B ARES_OPT_TIMEOUT
|
||||
.B int \fItimeout\fP;
|
||||
.br
|
||||
The number of seconds each name server is given to respond to a query on the
|
||||
first try. (After the first try, the timeout algorithm becomes more
|
||||
complicated, but scales linearly with the value of \fItimeout\fP.) The
|
||||
default is five seconds. This option is being deprecated by
|
||||
\fIARES_OPT_TIMEOUTMS\fP starting in c-ares 1.5.2.
|
||||
.TP 18
|
||||
.B ARES_OPT_TIMEOUTMS
|
||||
.B int \fItimeout\fP;
|
||||
.br
|
||||
The number of milliseconds each name server is given to respond to a query on
|
||||
the first try. (After the first try, the timeout algorithm becomes more
|
||||
complicated, but scales linearly with the value of \fItimeout\fP.) The
|
||||
default is five seconds. Note that this option is specified with the same
|
||||
struct field as the former \fIARES_OPT_TIMEOUT\fP, it is but the option bits
|
||||
that tell c-ares how to interpret the number. This option was added in c-ares
|
||||
1.5.2.
|
||||
.TP 18
|
||||
.B ARES_OPT_TRIES
|
||||
.B int \fItries\fP;
|
||||
.br
|
||||
The number of tries the resolver will try contacting each name server
|
||||
before giving up. The default is four tries.
|
||||
.TP 18
|
||||
.B ARES_OPT_NDOTS
|
||||
.B int \fIndots\fP;
|
||||
.br
|
||||
The number of dots which must be present in a domain name for it to be
|
||||
queried for "as is" prior to querying for it with the default domain
|
||||
extensions appended. The default value is 1 unless set otherwise by
|
||||
resolv.conf or the RES_OPTIONS environment variable.
|
||||
.TP 18
|
||||
.B ARES_OPT_PORT
|
||||
.B unsigned short \fIport\fP;
|
||||
.br
|
||||
The port to use for queries (both TCP and UDP), in network byte order.
|
||||
The default value is 53 (in network byte order), the standard name
|
||||
service port.
|
||||
.TP 18
|
||||
.B ARES_OPT_SERVERS
|
||||
.B struct in_addr *\fIservers\fP;
|
||||
.br
|
||||
.B int \fInservers\fP;
|
||||
.br
|
||||
The list of IPv4 servers to contact, instead of the servers specified in
|
||||
resolv.conf or the local named. In order to allow specification of either
|
||||
IPv4 or IPv6 name servers, the
|
||||
.BR ares_set_servers(3)
|
||||
function must be used instead.
|
||||
.TP 18
|
||||
.B ARES_OPT_DOMAINS
|
||||
.B char **\fIdomains\fP;
|
||||
.br
|
||||
.B int \fIndomains\fP;
|
||||
.br
|
||||
The domains to search, instead of the domains specified in resolv.conf
|
||||
or the domain derived from the kernel hostname variable.
|
||||
.TP 18
|
||||
.B ARES_OPT_LOOKUPS
|
||||
.B char *\fIlookups\fP;
|
||||
.br
|
||||
The lookups to perform for host queries.
|
||||
.I lookups
|
||||
should be set to a string of the characters "b" or "f", where "b"
|
||||
indicates a DNS lookup and "f" indicates a lookup in the hosts file.
|
||||
.TP 18
|
||||
.B ARES_OPT_SOCK_STATE_CB
|
||||
.B void (*\fIsock_state_cb\fP)(void *data, int s, int read, int write);
|
||||
.br
|
||||
.B void *\fIsock_state_cb_data\fP;
|
||||
.br
|
||||
A callback function to be invoked when a socket changes state.
|
||||
.I s
|
||||
will be passed the socket whose state has changed;
|
||||
.I read
|
||||
will be set to true if the socket should listen for read events, and
|
||||
.I write
|
||||
will be set to true if the socket should listen for write events.
|
||||
The value of
|
||||
.I sock_state_cb_data
|
||||
will be passed as the
|
||||
.I data
|
||||
argument.
|
||||
.PP
|
||||
The
|
||||
.I flags
|
||||
field should be the bitwise or of some subset of the following values:
|
||||
.TP 23
|
||||
.B ARES_FLAG_USEVC
|
||||
Always use TCP queries (the "virtual circuit") instead of UDP
|
||||
queries. Normally, TCP is only used if a UDP query yields a truncated
|
||||
result.
|
||||
.TP 23
|
||||
.B ARES_FLAG_PRIMARY
|
||||
Only query the first server in the list of servers to query.
|
||||
.TP 23
|
||||
.B ARES_FLAG_IGNTC
|
||||
If a truncated response to a UDP query is received, do not fall back
|
||||
to TCP; simply continue on with the truncated response.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NORECURSE
|
||||
Do not set the "recursion desired" bit on outgoing queries, so that the name
|
||||
server being contacted will not try to fetch the answer from other servers if
|
||||
it doesn't know the answer locally. Be aware that ares will not do the
|
||||
recursion for you. Recursion must be handled by the application calling ares
|
||||
if \fIARES_FLAG_NORECURSE\fP is set.
|
||||
.TP 23
|
||||
.B ARES_FLAG_STAYOPEN
|
||||
Do not close communications sockets when the number of active queries
|
||||
drops to zero.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NOSEARCH
|
||||
Do not use the default search domains; only query hostnames as-is or
|
||||
as aliases.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NOALIASES
|
||||
Do not honor the HOSTALIASES environment variable, which normally
|
||||
specifies a file of hostname translations.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NOCHECKRESP
|
||||
Do not discard responses with the SERVFAIL, NOTIMP, or REFUSED
|
||||
response code or responses whose questions don't match the questions
|
||||
in the request. Primarily useful for writing clients which might be
|
||||
used to test or debug name servers.
|
||||
service channel. The caller should invoke \fIares_destroy(3)\fP on the handle
|
||||
when the channel is no longer needed.
|
||||
|
||||
The \fIares_init_options(3)\fP function is provide to offer more init
|
||||
alternatives.
|
||||
.SH RETURN VALUES
|
||||
.I ares_init
|
||||
or
|
||||
.I ares_init_options
|
||||
can return any of the following values:
|
||||
\fIares_init(3)\fP can return any of the following values:
|
||||
.TP 14
|
||||
.B ARES_SUCCESS
|
||||
Initialization succeeded.
|
||||
@@ -206,11 +63,12 @@ directives override one another. If more that one instance of either
|
||||
.I domain
|
||||
or
|
||||
.I search
|
||||
directives is specified, the last occurence wins. For more information,
|
||||
directives is specified, the last occurrence wins. For more information,
|
||||
please see the
|
||||
.BR resolv.conf (5)
|
||||
manual page.
|
||||
.SH SEE ALSO
|
||||
.BR ares_init_options(3),
|
||||
.BR ares_destroy(3),
|
||||
.BR ares_dup(3),
|
||||
.BR ares_library_init(3),
|
||||
|
||||
+297
-146
File diff suppressed because it is too large
Load Diff
+262
-1
@@ -1 +1,262 @@
|
||||
.so man3/ares_init.3
|
||||
.\"
|
||||
.\" 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.
|
||||
.\"
|
||||
.TH ARES_INIT 3 "5 March 2010"
|
||||
.SH NAME
|
||||
ares_init_options \- Initialize a resolver channel
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
#include <ares.h>
|
||||
|
||||
int ares_init_options(ares_channel *\fIchannelptr\fP,
|
||||
struct ares_options *\fIoptions\fP,
|
||||
int \fIoptmask\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The \fBares_init_options(3)\fP function initializes a communications channel
|
||||
for name service lookups. If it returns successfully,
|
||||
\fBares_init_options(3)\fP will set the variable pointed to by
|
||||
\fIchannelptr\fP to a handle used to identify the name service channel. The
|
||||
caller should invoke \fIares_destroy(3)\fP on the handle when the channel is
|
||||
no longer needed.
|
||||
|
||||
The \fIoptmask\fP parameter generally specifies which fields in the structure pointed to
|
||||
by \fIoptions\fP are set, as follows:
|
||||
.TP 18
|
||||
.B ARES_OPT_FLAGS
|
||||
.B int \fIflags\fP;
|
||||
.br
|
||||
Flags controlling the behavior of the resolver. See below for a
|
||||
description of possible flag values.
|
||||
.TP 18
|
||||
.B ARES_OPT_TIMEOUT
|
||||
.B int \fItimeout\fP;
|
||||
.br
|
||||
The number of seconds each name server is given to respond to a query on the
|
||||
first try. (After the first try, the timeout algorithm becomes more
|
||||
complicated, but scales linearly with the value of \fItimeout\fP.) The
|
||||
default is five seconds. This option is being deprecated by
|
||||
\fIARES_OPT_TIMEOUTMS\fP starting in c-ares 1.5.2.
|
||||
.TP 18
|
||||
.B ARES_OPT_TIMEOUTMS
|
||||
.B int \fItimeout\fP;
|
||||
.br
|
||||
The number of milliseconds each name server is given to respond to a query on
|
||||
the first try. (After the first try, the timeout algorithm becomes more
|
||||
complicated, but scales linearly with the value of \fItimeout\fP.) The
|
||||
default is five seconds. Note that this option is specified with the same
|
||||
struct field as the former \fIARES_OPT_TIMEOUT\fP, it is but the option bits
|
||||
that tell c-ares how to interpret the number. This option was added in c-ares
|
||||
1.5.2.
|
||||
.TP 18
|
||||
.B ARES_OPT_TRIES
|
||||
.B int \fItries\fP;
|
||||
.br
|
||||
The number of tries the resolver will try contacting each name server
|
||||
before giving up. The default is four tries.
|
||||
.TP 18
|
||||
.B ARES_OPT_NDOTS
|
||||
.B int \fIndots\fP;
|
||||
.br
|
||||
The number of dots which must be present in a domain name for it to be
|
||||
queried for "as is" prior to querying for it with the default domain
|
||||
extensions appended. The default value is 1 unless set otherwise by
|
||||
resolv.conf or the RES_OPTIONS environment variable.
|
||||
.TP 18
|
||||
.B ARES_OPT_UDP_PORT
|
||||
.B unsigned short \fIudp_port\fP;
|
||||
.br
|
||||
The port to use for queries over UDP, in network byte order.
|
||||
The default value is 53 (in network byte order), the standard name
|
||||
service port.
|
||||
.TP 18
|
||||
.B ARES_OPT_TCP_PORT
|
||||
.B unsigned short \fItcp_port\fP;
|
||||
.br
|
||||
The port to use for queries over TCP, in network byte order.
|
||||
The default value is 53 (in network byte order), the standard name
|
||||
service port.
|
||||
.TP 18
|
||||
.B ARES_OPT_SERVERS
|
||||
.B struct in_addr *\fIservers\fP;
|
||||
.br
|
||||
.B int \fInservers\fP;
|
||||
.br
|
||||
The list of IPv4 servers to contact, instead of the servers specified in
|
||||
resolv.conf or the local named. In order to allow specification of either
|
||||
IPv4 or IPv6 name servers, the
|
||||
.BR ares_set_servers(3)
|
||||
function must be used instead.
|
||||
.TP 18
|
||||
.B ARES_OPT_DOMAINS
|
||||
.B char **\fIdomains\fP;
|
||||
.br
|
||||
.B int \fIndomains\fP;
|
||||
.br
|
||||
The domains to search, instead of the domains specified in resolv.conf
|
||||
or the domain derived from the kernel hostname variable.
|
||||
.TP 18
|
||||
.B ARES_OPT_LOOKUPS
|
||||
.B char *\fIlookups\fP;
|
||||
.br
|
||||
The lookups to perform for host queries.
|
||||
.I lookups
|
||||
should be set to a string of the characters "b" or "f", where "b"
|
||||
indicates a DNS lookup and "f" indicates a lookup in the hosts file.
|
||||
.TP 18
|
||||
.B ARES_OPT_SOCK_STATE_CB
|
||||
.B void (*\fIsock_state_cb\fP)(void *data, int s, int read, int write);
|
||||
.br
|
||||
.B void *\fIsock_state_cb_data\fP;
|
||||
.br
|
||||
A callback function to be invoked when a socket changes state.
|
||||
.I s
|
||||
will be passed the socket whose state has changed;
|
||||
.I read
|
||||
will be set to true if the socket should listen for read events, and
|
||||
.I write
|
||||
will be set to true if the socket should listen for write events.
|
||||
The value of
|
||||
.I sock_state_cb_data
|
||||
will be passed as the
|
||||
.I data
|
||||
argument.
|
||||
.TP 18
|
||||
.B ARES_OPT_SORTLIST
|
||||
.B struct apattern *\fIsortlist\fP;
|
||||
.br
|
||||
.B int \fInsort\fP;
|
||||
.br
|
||||
A list of IP address ranges that specifies the order of preference that
|
||||
results from \fIares_gethostbyname\fP should be returned in. Note that
|
||||
this can only be used with a sortlist retrieved via
|
||||
\fBares_save_options(3)\fP (because
|
||||
.B struct apattern
|
||||
is opaque); to set a fresh sort list, use \fBares_set_sortlist(3)\fP.
|
||||
.TP 18
|
||||
.B ARES_OPT_SOCK_SNDBUF
|
||||
.B int \fIsocket_send_buffer_size\fP;
|
||||
.br
|
||||
The send buffer size to set for the socket.
|
||||
.TP 18
|
||||
.B ARES_OPT_SOCK_RCVBUF
|
||||
.B int \fIsocket_receive_buffer_size\fP;
|
||||
.br
|
||||
The receive buffer size to set for the socket.
|
||||
.TP 18
|
||||
.B ARES_OPT_EDNSPSZ
|
||||
.B int \fIednspsz\fP;
|
||||
.br
|
||||
The message size to be advertized in EDNS; only takes effect if the
|
||||
.B ARES_FLAG_EDNS
|
||||
flag is set.
|
||||
.br
|
||||
.PP
|
||||
The \fIoptmask\fP parameter also includes options without a corresponding
|
||||
field in the
|
||||
.B ares_options
|
||||
structure, as follows:
|
||||
.TP 23
|
||||
.B ARES_OPT_ROTATE
|
||||
Perform round-robin selection of the nameservers configured for the channel
|
||||
for each resolution.
|
||||
.TP 23
|
||||
.B ARES_OPT_NOROTATE
|
||||
Do not perform round-robin nameserver selection; always use the list of
|
||||
nameservers in the same order.
|
||||
.PP
|
||||
The
|
||||
.I flags
|
||||
field should be the bitwise or of some subset of the following values:
|
||||
.TP 23
|
||||
.B ARES_FLAG_USEVC
|
||||
Always use TCP queries (the "virtual circuit") instead of UDP
|
||||
queries. Normally, TCP is only used if a UDP query yields a truncated
|
||||
result.
|
||||
.TP 23
|
||||
.B ARES_FLAG_PRIMARY
|
||||
Only query the first server in the list of servers to query.
|
||||
.TP 23
|
||||
.B ARES_FLAG_IGNTC
|
||||
If a truncated response to a UDP query is received, do not fall back
|
||||
to TCP; simply continue on with the truncated response.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NORECURSE
|
||||
Do not set the "recursion desired" bit on outgoing queries, so that the name
|
||||
server being contacted will not try to fetch the answer from other servers if
|
||||
it doesn't know the answer locally. Be aware that ares will not do the
|
||||
recursion for you. Recursion must be handled by the application calling ares
|
||||
if \fIARES_FLAG_NORECURSE\fP is set.
|
||||
.TP 23
|
||||
.B ARES_FLAG_STAYOPEN
|
||||
Do not close communications sockets when the number of active queries
|
||||
drops to zero.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NOSEARCH
|
||||
Do not use the default search domains; only query hostnames as-is or
|
||||
as aliases.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NOALIASES
|
||||
Do not honor the HOSTALIASES environment variable, which normally
|
||||
specifies a file of hostname translations.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NOCHECKRESP
|
||||
Do not discard responses with the SERVFAIL, NOTIMP, or REFUSED
|
||||
response code or responses whose questions don't match the questions
|
||||
in the request. Primarily useful for writing clients which might be
|
||||
used to test or debug name servers.
|
||||
.TP 23
|
||||
.B ARES_FLAG_EDNS
|
||||
Include an EDNS pseudo-resource record (RFC 2671) in generated requests.
|
||||
.SH RETURN VALUES
|
||||
\fBares_init_options(3)\fP can return any of the following values:
|
||||
.TP 14
|
||||
.B ARES_SUCCESS
|
||||
Initialization succeeded.
|
||||
.TP 14
|
||||
.B ARES_EFILE
|
||||
A configuration file could not be read.
|
||||
.TP 14
|
||||
.B ARES_ENOMEM
|
||||
The process's available memory was exhausted.
|
||||
.TP 14
|
||||
.B ARES_ENOTINITIALIZED
|
||||
c-ares library initialization not yet performed.
|
||||
.SH NOTES
|
||||
When initializing from
|
||||
.B /etc/resolv.conf,
|
||||
\fBares_init_options(3)\fP reads the \fIdomain\fP and \fIsearch\fP directives
|
||||
to allow lookups of short names relative to the domains specified. The
|
||||
\fIdomain\fP and \fIsearch\fP directives override one another. If more that
|
||||
one instance of either \fIdomain\fP or \fIsearch\fP directives is specified,
|
||||
the last occurrence wins. For more information, please see the
|
||||
.BR resolv.conf (5)
|
||||
manual page.
|
||||
.SH SEE ALSO
|
||||
.BR ares_init(3),
|
||||
.BR ares_destroy(3),
|
||||
.BR ares_dup(3),
|
||||
.BR ares_library_init(3),
|
||||
.BR ares_save_options(3),
|
||||
.BR ares_set_servers(3),
|
||||
.BR ares_set_sortlist(3)
|
||||
.SH AUTHOR
|
||||
Greg Hudson, MIT Information Systems
|
||||
.br
|
||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.br
|
||||
Copyright (C) 2004-2010 by Daniel Stenberg.
|
||||
|
||||
|
||||
+4
-4
@@ -47,16 +47,16 @@ struct addrinfo
|
||||
#endif
|
||||
|
||||
#ifndef NS_IN6ADDRSZ
|
||||
#if SIZEOF_STRUCT_IN6_ADDR == 0
|
||||
#ifndef HAVE_STRUCT_IN6_ADDR
|
||||
/* 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
|
||||
#define NS_IN6ADDRSZ sizeof(struct in6_addr)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NS_INADDRSZ
|
||||
#define NS_INADDRSZ SIZEOF_STRUCT_IN_ADDR
|
||||
#define NS_INADDRSZ sizeof(struct in_addr)
|
||||
#endif
|
||||
|
||||
#ifndef NS_INT16SZ
|
||||
@@ -71,7 +71,7 @@ struct addrinfo
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Defined in ares_net_pton.c for no particular reason. */
|
||||
/* Defined in inet_net_pton.c for no particular reason. */
|
||||
extern const struct ares_in6_addr ares_in6addr_any; /* :: */
|
||||
|
||||
|
||||
|
||||
+14
-5
@@ -19,11 +19,14 @@
|
||||
ares_library_init \- c-ares library initialization
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B int ares_library_init(int \fIflags\fP)
|
||||
.PP
|
||||
.B cc file.c -lcares
|
||||
#include <ares.h>
|
||||
|
||||
int ares_library_init(int \fIflags\fP)
|
||||
|
||||
int ares_library_init_mem(int \fIflags\fP,
|
||||
void *(*\fIamalloc\fP)(size_t),
|
||||
void (*\fIafree\fP)(void *ptr),
|
||||
void (*\fIarealloc\fP)(void *ptr, size_t size))
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -51,6 +54,12 @@ ORing the values together. In normal operation you should specify
|
||||
\fIARES_LIB_INIT_ALL\fP. Don't use any other value unless you are
|
||||
familiar with it and trying to control some internal c-ares feature.
|
||||
.PP
|
||||
The
|
||||
.B ares_library_init_mem
|
||||
function allows the caller to provide memory management functions that the
|
||||
c-ares library will be use instead of \fImalloc(3)\fP, \fIfree(3)\fP and
|
||||
\fIrealloc(3)\fP.
|
||||
.PP
|
||||
.B This function is not thread safe.
|
||||
You have to call it once the program has started, but this call must be done
|
||||
before the program starts any other thread. This is required to avoid
|
||||
|
||||
+40
-6
@@ -34,6 +34,11 @@ fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses = ZERO_NULL;
|
||||
static unsigned int ares_initialized;
|
||||
static int ares_init_flags;
|
||||
|
||||
/* library-private global vars with visibility across the whole library */
|
||||
void *(*ares_malloc)(size_t size) = malloc;
|
||||
void *(*ares_realloc)(void *ptr, size_t size) = realloc;
|
||||
void (*ares_free)(void *ptr) = free;
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
static HMODULE hnd_iphlpapi;
|
||||
static HMODULE hnd_advapi32;
|
||||
@@ -45,7 +50,7 @@ static int ares_win32_init(void)
|
||||
#ifdef USE_WINSOCK
|
||||
|
||||
hnd_iphlpapi = 0;
|
||||
hnd_iphlpapi = LoadLibrary("iphlpapi.dll");
|
||||
hnd_iphlpapi = LoadLibraryW(L"iphlpapi.dll");
|
||||
if (!hnd_iphlpapi)
|
||||
return ARES_ELOADIPHLPAPI;
|
||||
|
||||
@@ -73,7 +78,7 @@ static int ares_win32_init(void)
|
||||
*/
|
||||
|
||||
hnd_advapi32 = 0;
|
||||
hnd_advapi32 = LoadLibrary("advapi32.dll");
|
||||
hnd_advapi32 = LoadLibraryW(L"advapi32.dll");
|
||||
if (hnd_advapi32)
|
||||
{
|
||||
ares_fpSystemFunction036 = (fpSystemFunction036_t)
|
||||
@@ -106,12 +111,19 @@ int ares_library_init(int flags)
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
ares_initialized++;
|
||||
|
||||
|
||||
if (flags & ARES_LIB_INIT_AMIGA)
|
||||
{
|
||||
res = ares_amiga_init();
|
||||
if (res != ARES_SUCCESS)
|
||||
return res;
|
||||
}
|
||||
|
||||
if (flags & ARES_LIB_INIT_WIN32)
|
||||
{
|
||||
res = ares_win32_init();
|
||||
if (res != ARES_SUCCESS)
|
||||
return res;
|
||||
return res; /* LCOV_EXCL_LINE: can't test Win32 init failure */
|
||||
}
|
||||
|
||||
ares_init_flags = flags;
|
||||
@@ -119,6 +131,20 @@ int ares_library_init(int flags)
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
int ares_library_init_mem(int flags,
|
||||
void *(*amalloc)(size_t size),
|
||||
void (*afree)(void *ptr),
|
||||
void *(*arealloc)(void *ptr, size_t size))
|
||||
{
|
||||
if (amalloc)
|
||||
ares_malloc = amalloc;
|
||||
if (arealloc)
|
||||
ares_realloc = arealloc;
|
||||
if (afree)
|
||||
ares_free = afree;
|
||||
return ares_library_init(flags);
|
||||
}
|
||||
|
||||
|
||||
void ares_library_cleanup(void)
|
||||
{
|
||||
@@ -131,7 +157,13 @@ void ares_library_cleanup(void)
|
||||
if (ares_init_flags & ARES_LIB_INIT_WIN32)
|
||||
ares_win32_cleanup();
|
||||
|
||||
if (ares_init_flags & ARES_LIB_INIT_AMIGA)
|
||||
ares_amiga_cleanup();
|
||||
|
||||
ares_init_flags = ARES_LIB_INIT_NONE;
|
||||
ares_malloc = malloc;
|
||||
ares_realloc = realloc;
|
||||
ares_free = free;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,8 +172,10 @@ int ares_library_initialized(void)
|
||||
#ifdef USE_WINSOCK
|
||||
if (!ares_initialized)
|
||||
return ARES_ENOTINITIALIZED;
|
||||
#endif
|
||||
#ifdef AOS3
|
||||
if (!ares_initialized)
|
||||
return ARES_ENOTINITIALIZED;
|
||||
#endif
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+18
-41
@@ -1,5 +1,5 @@
|
||||
|
||||
/* Copyright (C) 2010-2012 by Daniel Stenberg
|
||||
/* Copyright (C) 2010-2013 by Daniel Stenberg
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -21,6 +21,10 @@
|
||||
# include <assert.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#if defined(__INTEL_COMPILER) && defined(__unix__)
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
@@ -36,49 +40,22 @@
|
||||
|
||||
#include "ares_nowarn.h"
|
||||
|
||||
#if (SIZEOF_SHORT == 2)
|
||||
#ifndef HAVE_LIMITS_H
|
||||
/* systems without <limits.h> we guess have 16 bit shorts, 32bit ints and
|
||||
32bit longs */
|
||||
# define CARES_MASK_SSHORT 0x7FFF
|
||||
# define CARES_MASK_USHORT 0xFFFF
|
||||
#elif (SIZEOF_SHORT == 4)
|
||||
# define CARES_MASK_SSHORT 0x7FFFFFFF
|
||||
# define CARES_MASK_USHORT 0xFFFFFFFF
|
||||
#elif (SIZEOF_SHORT == 8)
|
||||
# define CARES_MASK_SSHORT 0x7FFFFFFFFFFFFFFF
|
||||
# define CARES_MASK_USHORT 0xFFFFFFFFFFFFFFFF
|
||||
# define CARES_MASK_SINT 0x7FFFFFFF
|
||||
# define CARES_MASK_UINT 0xFFFFFFFF
|
||||
# define CARES_MASK_SLONG 0x7FFFFFFFL
|
||||
# define CARES_MASK_ULONG 0xFFFFFFFFUL
|
||||
#else
|
||||
# error "SIZEOF_SHORT not defined"
|
||||
#endif
|
||||
|
||||
#if (SIZEOF_INT == 2)
|
||||
# define CARES_MASK_SINT 0x7FFF
|
||||
# define CARES_MASK_UINT 0xFFFF
|
||||
#elif (SIZEOF_INT == 4)
|
||||
# define CARES_MASK_SINT 0x7FFFFFFF
|
||||
# define CARES_MASK_UINT 0xFFFFFFFF
|
||||
#elif (SIZEOF_INT == 8)
|
||||
# define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFF
|
||||
# define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFF
|
||||
#elif (SIZEOF_INT == 16)
|
||||
# define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
# define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
#else
|
||||
# error "SIZEOF_INT not defined"
|
||||
#endif
|
||||
|
||||
#if (CARES_SIZEOF_LONG == 2)
|
||||
# define CARES_MASK_SLONG 0x7FFFL
|
||||
# define CARES_MASK_ULONG 0xFFFFUL
|
||||
#elif (CARES_SIZEOF_LONG == 4)
|
||||
# define CARES_MASK_SLONG 0x7FFFFFFFL
|
||||
# define CARES_MASK_ULONG 0xFFFFFFFFUL
|
||||
#elif (CARES_SIZEOF_LONG == 8)
|
||||
# define CARES_MASK_SLONG 0x7FFFFFFFFFFFFFFFL
|
||||
# define CARES_MASK_ULONG 0xFFFFFFFFFFFFFFFFUL
|
||||
#elif (CARES_SIZEOF_LONG == 16)
|
||||
# define CARES_MASK_SLONG 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL
|
||||
# define CARES_MASK_ULONG 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFUL
|
||||
#else
|
||||
# error "CARES_SIZEOF_LONG not defined"
|
||||
# define CARES_MASK_SSHORT SHRT_MAX
|
||||
# define CARES_MASK_USHORT USHRT_MAX
|
||||
# define CARES_MASK_SINT INT_MAX
|
||||
# define CARES_MASK_UINT UINT_MAX
|
||||
# define CARES_MASK_SLONG LONG_MAX
|
||||
# define CARES_MASK_ULONG ULONG_MAX
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
+142
-18
@@ -83,6 +83,62 @@ int ares_get_servers(ares_channel channel,
|
||||
return status;
|
||||
}
|
||||
|
||||
int ares_get_servers_ports(ares_channel channel,
|
||||
struct ares_addr_port_node **servers)
|
||||
{
|
||||
struct ares_addr_port_node *srvr_head = NULL;
|
||||
struct ares_addr_port_node *srvr_last = NULL;
|
||||
struct ares_addr_port_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_PORT_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;
|
||||
srvr_curr->udp_port = ntohs((unsigned short)channel->servers[i].addr.udp_port);
|
||||
srvr_curr->tcp_port = ntohs((unsigned short)channel->servers[i].addr.tcp_port);
|
||||
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)
|
||||
@@ -92,7 +148,7 @@ int ares_set_servers(ares_channel channel,
|
||||
int i;
|
||||
|
||||
if (ares_library_initialized() != ARES_SUCCESS)
|
||||
return ARES_ENOTINITIALIZED;
|
||||
return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
|
||||
|
||||
if (!channel)
|
||||
return ARES_ENODATA;
|
||||
@@ -107,7 +163,7 @@ int ares_set_servers(ares_channel channel,
|
||||
if (num_srvrs > 0)
|
||||
{
|
||||
/* Allocate storage for servers state */
|
||||
channel->servers = malloc(num_srvrs * sizeof(struct server_state));
|
||||
channel->servers = ares_malloc(num_srvrs * sizeof(struct server_state));
|
||||
if (!channel->servers)
|
||||
{
|
||||
return ARES_ENOMEM;
|
||||
@@ -117,6 +173,57 @@ int ares_set_servers(ares_channel channel,
|
||||
for (i = 0, srvr = servers; srvr; i++, srvr = srvr->next)
|
||||
{
|
||||
channel->servers[i].addr.family = srvr->family;
|
||||
channel->servers[i].addr.udp_port = 0;
|
||||
channel->servers[i].addr.tcp_port = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
int ares_set_servers_ports(ares_channel channel,
|
||||
struct ares_addr_port_node *servers)
|
||||
{
|
||||
struct ares_addr_port_node *srvr;
|
||||
int num_srvrs = 0;
|
||||
int i;
|
||||
|
||||
if (ares_library_initialized() != ARES_SUCCESS)
|
||||
return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
|
||||
|
||||
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 = ares_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;
|
||||
channel->servers[i].addr.udp_port = htons((unsigned short)srvr->udp_port);
|
||||
channel->servers[i].addr.tcp_port = htons((unsigned short)srvr->tcp_port);
|
||||
if (srvr->family == AF_INET)
|
||||
memcpy(&channel->servers[i].addr.addrV4, &srvr->addrV4,
|
||||
sizeof(srvr->addrV4));
|
||||
@@ -133,8 +240,8 @@ int ares_set_servers(ares_channel channel,
|
||||
|
||||
/* Incomming string format: host[:port][,host[:port]]... */
|
||||
/* IPv6 addresses with ports require square brackets [fe80::1%lo0]:53 */
|
||||
int ares_set_servers_csv(ares_channel channel,
|
||||
const char* _csv)
|
||||
static int set_servers_csv(ares_channel channel,
|
||||
const char* _csv, int use_port)
|
||||
{
|
||||
size_t i;
|
||||
char* csv = NULL;
|
||||
@@ -142,11 +249,11 @@ int ares_set_servers_csv(ares_channel channel,
|
||||
char* start_host;
|
||||
int cc = 0;
|
||||
int rv = ARES_SUCCESS;
|
||||
struct ares_addr_node *servers = NULL;
|
||||
struct ares_addr_node *last = NULL;
|
||||
struct ares_addr_port_node *servers = NULL;
|
||||
struct ares_addr_port_node *last = NULL;
|
||||
|
||||
if (ares_library_initialized() != ARES_SUCCESS)
|
||||
return ARES_ENOTINITIALIZED;
|
||||
return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
|
||||
|
||||
if (!channel)
|
||||
return ARES_ENODATA;
|
||||
@@ -157,7 +264,10 @@ int ares_set_servers_csv(ares_channel channel,
|
||||
if (i == 0)
|
||||
return ARES_SUCCESS; /* blank all servers */
|
||||
|
||||
csv = malloc(i + 2);
|
||||
csv = ares_malloc(i + 2);
|
||||
if (!csv)
|
||||
return ARES_ENOMEM;
|
||||
|
||||
strcpy(csv, _csv);
|
||||
if (csv[i-1] != ',') { /* make parsing easier by ensuring ending ',' */
|
||||
csv[i] = ',';
|
||||
@@ -179,9 +289,10 @@ int ares_set_servers_csv(ares_channel channel,
|
||||
else if (*ptr == ',') {
|
||||
char* pp = ptr - 1;
|
||||
char* p = ptr;
|
||||
int port = 0;
|
||||
struct in_addr in4;
|
||||
struct ares_in6_addr in6;
|
||||
struct ares_addr_node *s = NULL;
|
||||
struct ares_addr_port_node *s = NULL;
|
||||
|
||||
*ptr = 0; /* null terminate host:port string */
|
||||
/* Got an entry..see if the port was specified. */
|
||||
@@ -210,7 +321,7 @@ int ares_set_servers_csv(ares_channel channel,
|
||||
if (*pp == ']')
|
||||
p++; /* move p before ':' */
|
||||
/* p will point to the start of the port */
|
||||
(void)strtol(p, NULL, 10);
|
||||
port = (int)strtol(p, NULL, 10);
|
||||
*pp = 0; /* null terminate host */
|
||||
}
|
||||
}
|
||||
@@ -224,7 +335,7 @@ int ares_set_servers_csv(ares_channel channel,
|
||||
goto out;
|
||||
}
|
||||
/* was ipv6, add new server */
|
||||
s = malloc(sizeof(*s));
|
||||
s = ares_malloc(sizeof(*s));
|
||||
if (!s) {
|
||||
rv = ARES_ENOMEM;
|
||||
goto out;
|
||||
@@ -234,7 +345,7 @@ int ares_set_servers_csv(ares_channel channel,
|
||||
}
|
||||
else {
|
||||
/* was ipv4, add new server */
|
||||
s = malloc(sizeof(*s));
|
||||
s = ares_malloc(sizeof(*s));
|
||||
if (!s) {
|
||||
rv = ARES_ENOMEM;
|
||||
goto out;
|
||||
@@ -243,8 +354,8 @@ int ares_set_servers_csv(ares_channel channel,
|
||||
memcpy(&s->addr, &in4, sizeof(struct in_addr));
|
||||
}
|
||||
if (s) {
|
||||
/* TODO: Add port to ares_addr_node and assign it here. */
|
||||
|
||||
s->udp_port = use_port ? port: 0;
|
||||
s->tcp_port = s->udp_port;
|
||||
s->next = NULL;
|
||||
if (last) {
|
||||
last->next = s;
|
||||
@@ -263,16 +374,29 @@ int ares_set_servers_csv(ares_channel channel,
|
||||
}
|
||||
}
|
||||
|
||||
rv = ares_set_servers(channel, servers);
|
||||
rv = ares_set_servers_ports(channel, servers);
|
||||
|
||||
out:
|
||||
if (csv)
|
||||
free(csv);
|
||||
ares_free(csv);
|
||||
while (servers) {
|
||||
struct ares_addr_node *s = servers;
|
||||
struct ares_addr_port_node *s = servers;
|
||||
servers = servers->next;
|
||||
free(s);
|
||||
ares_free(s);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int ares_set_servers_csv(ares_channel channel,
|
||||
const char* _csv)
|
||||
{
|
||||
return set_servers_csv(channel, _csv, FALSE);
|
||||
}
|
||||
|
||||
int ares_set_servers_ports_csv(ares_channel channel,
|
||||
const char* _csv)
|
||||
{
|
||||
return set_servers_csv(channel, _csv, TRUE);
|
||||
}
|
||||
|
||||
|
||||
+27
-27
@@ -85,7 +85,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||
return status;
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free(hostname);
|
||||
ares_free(hostname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
@@ -94,17 +94,17 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||
{
|
||||
/* Allocate addresses and aliases; ancount gives an upper bound for
|
||||
both. */
|
||||
addrs = malloc(ancount * sizeof(struct in_addr));
|
||||
addrs = ares_malloc(ancount * sizeof(struct in_addr));
|
||||
if (!addrs)
|
||||
{
|
||||
free(hostname);
|
||||
ares_free(hostname);
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
aliases = malloc((ancount + 1) * sizeof(char *));
|
||||
aliases = ares_malloc((ancount + 1) * sizeof(char *));
|
||||
if (!aliases)
|
||||
{
|
||||
free(hostname);
|
||||
free(addrs);
|
||||
ares_free(hostname);
|
||||
ares_free(addrs);
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||
aptr += len;
|
||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||
aptr += RRFIXEDSZ;
|
||||
if (aptr + rr_len > abuf + alen)
|
||||
{
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
@@ -150,22 +150,22 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||
if (addrs)
|
||||
{
|
||||
if (aptr + sizeof(struct in_addr) > abuf + alen)
|
||||
{
|
||||
free(rr_name);
|
||||
{ /* LCOV_EXCL_START: already checked above */
|
||||
ares_free(rr_name);
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
} /* LCOV_EXCL_STOP */
|
||||
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)
|
||||
{
|
||||
free(rr_name);
|
||||
{ /* LCOV_EXCL_START: already checked above */
|
||||
ares_free(rr_name);
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
} /* LCOV_EXCL_STOP */
|
||||
memcpy(&at->ipaddr, aptr, sizeof(struct in_addr));
|
||||
at->ttl = rr_ttl;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||
if (aliases)
|
||||
aliases[naliases] = rr_name;
|
||||
else
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
naliases++;
|
||||
|
||||
/* Decode the RR data and replace the hostname with it. */
|
||||
@@ -187,7 +187,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||
&len);
|
||||
if (status != ARES_SUCCESS)
|
||||
break;
|
||||
free(hostname);
|
||||
ares_free(hostname);
|
||||
hostname = rr_data;
|
||||
|
||||
/* Take the min of the TTLs we see in the CNAME chain. */
|
||||
@@ -195,14 +195,14 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||
cname_ttl = rr_ttl;
|
||||
}
|
||||
else
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
|
||||
aptr += rr_len;
|
||||
if (aptr > abuf + alen)
|
||||
{
|
||||
{ /* LCOV_EXCL_START: already checked above */
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
} /* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (status == ARES_SUCCESS && naddrs == 0 && naliases == 0)
|
||||
@@ -228,10 +228,10 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||
if (host)
|
||||
{
|
||||
/* Allocate memory to build the host entry. */
|
||||
hostent = malloc(sizeof(struct hostent));
|
||||
hostent = ares_malloc(sizeof(struct hostent));
|
||||
if (hostent)
|
||||
{
|
||||
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
|
||||
hostent->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *));
|
||||
if (hostent->h_addr_list)
|
||||
{
|
||||
/* Fill in the hostent and return successfully. */
|
||||
@@ -243,11 +243,11 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||
hostent->h_addr_list[i] = (char *) &addrs[i];
|
||||
hostent->h_addr_list[naddrs] = NULL;
|
||||
if (!naddrs && addrs)
|
||||
free(addrs);
|
||||
ares_free(addrs);
|
||||
*host = hostent;
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
free(hostent);
|
||||
ares_free(hostent);
|
||||
}
|
||||
status = ARES_ENOMEM;
|
||||
}
|
||||
@@ -255,10 +255,10 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||
if (aliases)
|
||||
{
|
||||
for (i = 0; i < naliases; i++)
|
||||
free(aliases[i]);
|
||||
free(aliases);
|
||||
ares_free(aliases[i]);
|
||||
ares_free(aliases);
|
||||
}
|
||||
free(addrs);
|
||||
free(hostname);
|
||||
ares_free(addrs);
|
||||
ares_free(hostname);
|
||||
return status;
|
||||
}
|
||||
|
||||
+27
-27
@@ -87,7 +87,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||
return status;
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free(hostname);
|
||||
ares_free(hostname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
@@ -95,17 +95,17 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||
/* Allocate addresses and aliases; ancount gives an upper bound for both. */
|
||||
if (host)
|
||||
{
|
||||
addrs = malloc(ancount * sizeof(struct ares_in6_addr));
|
||||
addrs = ares_malloc(ancount * sizeof(struct ares_in6_addr));
|
||||
if (!addrs)
|
||||
{
|
||||
free(hostname);
|
||||
ares_free(hostname);
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
aliases = malloc((ancount + 1) * sizeof(char *));
|
||||
aliases = ares_malloc((ancount + 1) * sizeof(char *));
|
||||
if (!aliases)
|
||||
{
|
||||
free(hostname);
|
||||
free(addrs);
|
||||
ares_free(hostname);
|
||||
ares_free(addrs);
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||
aptr += len;
|
||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||
aptr += RRFIXEDSZ;
|
||||
if (aptr + rr_len > abuf + alen)
|
||||
{
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
@@ -150,22 +150,22 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||
if (addrs)
|
||||
{
|
||||
if (aptr + sizeof(struct ares_in6_addr) > abuf + alen)
|
||||
{
|
||||
free(rr_name);
|
||||
{ /* LCOV_EXCL_START: already checked above */
|
||||
ares_free(rr_name);
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
} /* LCOV_EXCL_STOP */
|
||||
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)
|
||||
{
|
||||
free(rr_name);
|
||||
{ /* LCOV_EXCL_START: already checked above */
|
||||
ares_free(rr_name);
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
} /* LCOV_EXCL_STOP */
|
||||
memcpy(&at->ip6addr, aptr, sizeof(struct ares_in6_addr));
|
||||
at->ttl = rr_ttl;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||
if (aliases)
|
||||
aliases[naliases] = rr_name;
|
||||
else
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
naliases++;
|
||||
|
||||
/* Decode the RR data and replace the hostname with it. */
|
||||
@@ -187,7 +187,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||
&len);
|
||||
if (status != ARES_SUCCESS)
|
||||
break;
|
||||
free(hostname);
|
||||
ares_free(hostname);
|
||||
hostname = rr_data;
|
||||
|
||||
/* Take the min of the TTLs we see in the CNAME chain. */
|
||||
@@ -195,14 +195,14 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||
cname_ttl = rr_ttl;
|
||||
}
|
||||
else
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
|
||||
aptr += rr_len;
|
||||
if (aptr > abuf + alen)
|
||||
{
|
||||
{ /* LCOV_EXCL_START: already checked above */
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
} /* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* the check for naliases to be zero is to make sure CNAME responses
|
||||
@@ -228,10 +228,10 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||
if (host)
|
||||
{
|
||||
/* Allocate memory to build the host entry. */
|
||||
hostent = malloc(sizeof(struct hostent));
|
||||
hostent = ares_malloc(sizeof(struct hostent));
|
||||
if (hostent)
|
||||
{
|
||||
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
|
||||
hostent->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *));
|
||||
if (hostent->h_addr_list)
|
||||
{
|
||||
/* Fill in the hostent and return successfully. */
|
||||
@@ -243,11 +243,11 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||
hostent->h_addr_list[i] = (char *) &addrs[i];
|
||||
hostent->h_addr_list[naddrs] = NULL;
|
||||
if (!naddrs && addrs)
|
||||
free(addrs);
|
||||
ares_free(addrs);
|
||||
*host = hostent;
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
free(hostent);
|
||||
ares_free(hostent);
|
||||
}
|
||||
status = ARES_ENOMEM;
|
||||
}
|
||||
@@ -255,10 +255,10 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||
if (aliases)
|
||||
{
|
||||
for (i = 0; i < naliases; i++)
|
||||
free(aliases[i]);
|
||||
free(aliases);
|
||||
ares_free(aliases[i]);
|
||||
ares_free(aliases);
|
||||
}
|
||||
free(addrs);
|
||||
free(hostname);
|
||||
ares_free(addrs);
|
||||
ares_free(hostname);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen,
|
||||
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free (hostname);
|
||||
ares_free (hostname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
@@ -143,7 +143,7 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen,
|
||||
}
|
||||
|
||||
/* Don't lose memory in the next iteration */
|
||||
free (rr_name);
|
||||
ares_free (rr_name);
|
||||
rr_name = NULL;
|
||||
|
||||
/* Move on to the next record */
|
||||
@@ -151,9 +151,9 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen,
|
||||
}
|
||||
|
||||
if (hostname)
|
||||
free (hostname);
|
||||
ares_free (hostname);
|
||||
if (rr_name)
|
||||
free (rr_name);
|
||||
ares_free (rr_name);
|
||||
|
||||
/* clean up on error */
|
||||
if (status != ARES_SUCCESS)
|
||||
|
||||
@@ -81,7 +81,7 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen,
|
||||
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free (hostname);
|
||||
ares_free (hostname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
@@ -160,7 +160,7 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen,
|
||||
}
|
||||
|
||||
/* Don't lose memory in the next iteration */
|
||||
free (rr_name);
|
||||
ares_free (rr_name);
|
||||
rr_name = NULL;
|
||||
|
||||
/* Move on to the next record */
|
||||
@@ -168,9 +168,9 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen,
|
||||
}
|
||||
|
||||
if (hostname)
|
||||
free (hostname);
|
||||
ares_free (hostname);
|
||||
if (rr_name)
|
||||
free (rr_name);
|
||||
ares_free (rr_name);
|
||||
|
||||
/* clean up on error */
|
||||
if (status != ARES_SUCCESS)
|
||||
|
||||
+19
-19
@@ -73,16 +73,16 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
|
||||
return status;
|
||||
if ( aptr + len + QFIXEDSZ > abuf + alen )
|
||||
{
|
||||
free( hostname );
|
||||
ares_free( hostname );
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
|
||||
/* Allocate nameservers array; ancount gives an upper bound */
|
||||
nameservers = malloc( ( ancount + 1 ) * sizeof( char * ) );
|
||||
nameservers = ares_malloc( ( ancount + 1 ) * sizeof( char * ) );
|
||||
if ( !nameservers )
|
||||
{
|
||||
free( hostname );
|
||||
ares_free( hostname );
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
nameservers_num = 0;
|
||||
@@ -98,7 +98,7 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
|
||||
if ( aptr + RRFIXEDSZ > abuf + alen )
|
||||
{
|
||||
status = ARES_EBADRESP;
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
break;
|
||||
}
|
||||
rr_type = DNS_RR_TYPE( aptr );
|
||||
@@ -107,7 +107,7 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
|
||||
aptr += RRFIXEDSZ;
|
||||
if (aptr + rr_len > abuf + alen)
|
||||
{
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
@@ -119,33 +119,33 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
|
||||
&len);
|
||||
if ( status != ARES_SUCCESS )
|
||||
{
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
break;
|
||||
}
|
||||
|
||||
nameservers[nameservers_num] = malloc(strlen(rr_data)+1);
|
||||
nameservers[nameservers_num] = ares_malloc(strlen(rr_data)+1);
|
||||
|
||||
if (nameservers[nameservers_num]==NULL)
|
||||
{
|
||||
free(rr_name);
|
||||
free(rr_data);
|
||||
ares_free(rr_name);
|
||||
ares_free(rr_data);
|
||||
status=ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
strcpy(nameservers[nameservers_num],rr_data);
|
||||
free(rr_data);
|
||||
ares_free(rr_data);
|
||||
|
||||
nameservers_num++;
|
||||
}
|
||||
|
||||
free( rr_name );
|
||||
ares_free( rr_name );
|
||||
|
||||
aptr += rr_len;
|
||||
if ( aptr > abuf + alen )
|
||||
{
|
||||
{ /* LCOV_EXCL_START: already checked above */
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
} /* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if ( status == ARES_SUCCESS && nameservers_num == 0 )
|
||||
@@ -156,10 +156,10 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
|
||||
{
|
||||
/* We got our answer. Allocate memory to build the host entry. */
|
||||
nameservers[nameservers_num] = NULL;
|
||||
hostent = malloc( sizeof( struct hostent ) );
|
||||
hostent = ares_malloc( sizeof( struct hostent ) );
|
||||
if ( hostent )
|
||||
{
|
||||
hostent->h_addr_list = malloc( 1 * sizeof( char * ) );
|
||||
hostent->h_addr_list = ares_malloc( 1 * sizeof( char * ) );
|
||||
if ( hostent->h_addr_list )
|
||||
{
|
||||
/* Fill in the hostent and return successfully. */
|
||||
@@ -171,13 +171,13 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
|
||||
*host = hostent;
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
free( hostent );
|
||||
ares_free( hostent );
|
||||
}
|
||||
status = ARES_ENOMEM;
|
||||
}
|
||||
for ( i = 0; i < nameservers_num; i++ )
|
||||
free( nameservers[i] );
|
||||
free( nameservers );
|
||||
free( hostname );
|
||||
ares_free( nameservers[i] );
|
||||
ares_free( nameservers );
|
||||
ares_free( hostname );
|
||||
return status;
|
||||
}
|
||||
|
||||
+29
-29
@@ -73,17 +73,17 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
||||
return status;
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free(ptrname);
|
||||
ares_free(ptrname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
|
||||
/* Examine each answer resource record (RR) in turn. */
|
||||
hostname = NULL;
|
||||
aliases = malloc(alias_alloc * sizeof(char *));
|
||||
aliases = ares_malloc(alias_alloc * sizeof(char *));
|
||||
if (!aliases)
|
||||
{
|
||||
free(ptrname);
|
||||
ares_free(ptrname);
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
for (i = 0; i < (int)ancount; i++)
|
||||
@@ -95,7 +95,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
||||
aptr += len;
|
||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
||||
aptr += RRFIXEDSZ;
|
||||
if (aptr + rr_len > abuf + alen)
|
||||
{
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
@@ -118,16 +118,16 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
||||
&len);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
break;
|
||||
}
|
||||
if (hostname)
|
||||
free(hostname);
|
||||
ares_free(hostname);
|
||||
hostname = rr_data;
|
||||
aliases[aliascnt] = malloc((strlen(rr_data)+1) * sizeof(char));
|
||||
aliases[aliascnt] = ares_malloc((strlen(rr_data)+1) * sizeof(char));
|
||||
if (!aliases[aliascnt])
|
||||
{
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
status = ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
@@ -136,9 +136,9 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
||||
if (aliascnt >= alias_alloc) {
|
||||
char **ptr;
|
||||
alias_alloc *= 2;
|
||||
ptr = realloc(aliases, alias_alloc * sizeof(char *));
|
||||
ptr = ares_realloc(aliases, alias_alloc * sizeof(char *));
|
||||
if(!ptr) {
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
status = ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
@@ -153,20 +153,20 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
||||
&len);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
break;
|
||||
}
|
||||
free(ptrname);
|
||||
ares_free(ptrname);
|
||||
ptrname = rr_data;
|
||||
}
|
||||
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
aptr += rr_len;
|
||||
if (aptr > abuf + alen)
|
||||
{
|
||||
{ /* LCOV_EXCL_START: already checked above */
|
||||
status = ARES_EBADRESP;
|
||||
break;
|
||||
}
|
||||
} /* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (status == ARES_SUCCESS && !hostname)
|
||||
@@ -174,16 +174,16 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
/* We got our answer. Allocate memory to build the host entry. */
|
||||
hostent = malloc(sizeof(struct hostent));
|
||||
hostent = ares_malloc(sizeof(struct hostent));
|
||||
if (hostent)
|
||||
{
|
||||
hostent->h_addr_list = malloc(2 * sizeof(char *));
|
||||
hostent->h_addr_list = ares_malloc(2 * sizeof(char *));
|
||||
if (hostent->h_addr_list)
|
||||
{
|
||||
hostent->h_addr_list[0] = malloc(addrlen);
|
||||
hostent->h_addr_list[0] = ares_malloc(addrlen);
|
||||
if (hostent->h_addr_list[0])
|
||||
{
|
||||
hostent->h_aliases = malloc((aliascnt+1) * sizeof (char *));
|
||||
hostent->h_aliases = ares_malloc((aliascnt+1) * sizeof (char *));
|
||||
if (hostent->h_aliases)
|
||||
{
|
||||
/* Fill in the hostent and return successfully. */
|
||||
@@ -196,24 +196,24 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
||||
memcpy(hostent->h_addr_list[0], addr, addrlen);
|
||||
hostent->h_addr_list[1] = NULL;
|
||||
*host = hostent;
|
||||
free(aliases);
|
||||
free(ptrname);
|
||||
ares_free(aliases);
|
||||
ares_free(ptrname);
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
free(hostent->h_addr_list[0]);
|
||||
ares_free(hostent->h_addr_list[0]);
|
||||
}
|
||||
free(hostent->h_addr_list);
|
||||
ares_free(hostent->h_addr_list);
|
||||
}
|
||||
free(hostent);
|
||||
ares_free(hostent);
|
||||
}
|
||||
status = ARES_ENOMEM;
|
||||
}
|
||||
for (i=0 ; i<aliascnt ; i++)
|
||||
if (aliases[i])
|
||||
free(aliases[i]);
|
||||
free(aliases);
|
||||
ares_free(aliases[i]);
|
||||
ares_free(aliases);
|
||||
if (hostname)
|
||||
free(hostname);
|
||||
free(ptrname);
|
||||
ares_free(hostname);
|
||||
ares_free(ptrname);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,10 @@ ares_parse_soa_reply(const unsigned char *abuf, int alen,
|
||||
/* allocate result struct */
|
||||
soa = ares_malloc_data(ARES_DATATYPE_SOA_REPLY);
|
||||
if (!soa)
|
||||
return ARES_ENOMEM;
|
||||
{
|
||||
status = ARES_ENOMEM;
|
||||
goto failed_stat;
|
||||
}
|
||||
|
||||
/* nsname */
|
||||
status = ares__expand_name_for_response(aptr, abuf, alen, &soa->nsname, &len);
|
||||
@@ -109,8 +112,8 @@ ares_parse_soa_reply(const unsigned char *abuf, int alen,
|
||||
soa->expire = DNS__32BIT(aptr + 3 * 4);
|
||||
soa->minttl = DNS__32BIT(aptr + 4 * 4);
|
||||
|
||||
free(qname);
|
||||
free(rr_name);
|
||||
ares_free(qname);
|
||||
ares_free(rr_name);
|
||||
|
||||
*soa_out = soa;
|
||||
|
||||
@@ -122,9 +125,9 @@ failed:
|
||||
failed_stat:
|
||||
ares_free_data(soa);
|
||||
if (qname)
|
||||
free(qname);
|
||||
ares_free(qname);
|
||||
if (rr_name)
|
||||
free(rr_name);
|
||||
ares_free(rr_name);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,
|
||||
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free (hostname);
|
||||
ares_free (hostname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
@@ -152,7 +152,7 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,
|
||||
}
|
||||
|
||||
/* Don't lose memory in the next iteration */
|
||||
free (rr_name);
|
||||
ares_free (rr_name);
|
||||
rr_name = NULL;
|
||||
|
||||
/* Move on to the next record */
|
||||
@@ -160,9 +160,9 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,
|
||||
}
|
||||
|
||||
if (hostname)
|
||||
free (hostname);
|
||||
ares_free (hostname);
|
||||
if (rr_name)
|
||||
free (rr_name);
|
||||
ares_free (rr_name);
|
||||
|
||||
/* clean up on error */
|
||||
if (status != ARES_SUCCESS)
|
||||
|
||||
+44
-4
@@ -22,13 +22,16 @@ ares_parse_txt_reply \- Parse a reply to a DNS query of type TXT
|
||||
.PP
|
||||
.B int ares_parse_txt_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP,
|
||||
.B struct ares_txt_reply **\fItxt_out\fP);
|
||||
.PP
|
||||
.B int ares_parse_txt_reply_ext(const unsigned char* \fIabuf\fP, int \fIalen\fP,
|
||||
.B struct ares_txt_ext **\fItxt_out\fP);
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.B ares_parse_txt_reply
|
||||
.BR "ares_parse_txt_reply" " (" "ares_parse_txt_reply_ext" ")"
|
||||
function parses the response to a query of type TXT into a
|
||||
linked list (one element per sub-string) of
|
||||
.I struct ares_txt_reply
|
||||
.IR "struct ares_txt_reply" " (" "struct ares_txt_ext" ")"
|
||||
The parameters
|
||||
.I abuf
|
||||
and
|
||||
@@ -55,8 +58,44 @@ struct ares_txt_reply {
|
||||
.fi
|
||||
.in
|
||||
.PP
|
||||
The structure
|
||||
.I ares_txt_ext
|
||||
contains the following fields:
|
||||
.sp
|
||||
.in +4n
|
||||
.nf
|
||||
struct ares_txt_ext {
|
||||
struct ares_txt_ext *next;
|
||||
unsigned int length;
|
||||
unsigned char *txt;
|
||||
unsigned char record_start;
|
||||
};
|
||||
.fi
|
||||
.in
|
||||
.PP
|
||||
The
|
||||
.I record_start
|
||||
field in
|
||||
.I struct ares_txt_ext
|
||||
is 1 if this structure is a start of a TXT record, and 0 if the structure is a
|
||||
continuation of a previous record. The linked list of the
|
||||
.I struct ares_txt_ext
|
||||
will have at least one item with
|
||||
.I record_start
|
||||
equal to 1, and may have some items with
|
||||
.I record_start
|
||||
equal to 0 between them.
|
||||
.PP
|
||||
These sequences of
|
||||
.I struct ares_txt_ext
|
||||
(starting from the item with
|
||||
.I record_start
|
||||
equal to 1, and ending right before the record start item) may be treated as
|
||||
either components of a single TXT record or as a multi-parted TXT record,
|
||||
depending on particular use case.
|
||||
.PP
|
||||
.SH RETURN VALUES
|
||||
.B ares_parse_txt_reply
|
||||
.BR "ares_parse_txt_reply" " (" "ares_parse_txt_reply_ext" ")"
|
||||
can return any of the following values:
|
||||
.TP 15
|
||||
.B ARES_SUCCESS
|
||||
@@ -77,4 +116,5 @@ This function was first introduced in c-ares version 1.7.0.
|
||||
.BR ares_free_data (3)
|
||||
.SH AUTHOR
|
||||
Written by Jakub Hrozek <jhrozek@redhat.com>, on behalf of Red Hat, Inc http://www.redhat.com
|
||||
|
||||
.PP
|
||||
Amended by Fedor Indutny <fedor@indutny.com>, on behalf of PayPal, Inc https://www.paypal.com
|
||||
|
||||
+38
-14
@@ -44,9 +44,9 @@
|
||||
#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)
|
||||
static int
|
||||
ares__parse_txt_reply (const unsigned char *abuf, int alen,
|
||||
int ex, void **txt_out)
|
||||
{
|
||||
size_t substr_len;
|
||||
unsigned int qdcount, ancount, i;
|
||||
@@ -55,9 +55,9 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
|
||||
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;
|
||||
struct ares_txt_ext *txt_head = NULL;
|
||||
struct ares_txt_ext *txt_last = NULL;
|
||||
struct ares_txt_ext *txt_curr;
|
||||
|
||||
/* Set *txt_out to NULL for all failure cases. */
|
||||
*txt_out = NULL;
|
||||
@@ -82,7 +82,7 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
|
||||
|
||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free (hostname);
|
||||
ares_free (hostname);
|
||||
return ARES_EBADRESP;
|
||||
}
|
||||
aptr += len + QFIXEDSZ;
|
||||
@@ -133,10 +133,9 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
|
||||
break;
|
||||
}
|
||||
|
||||
++strptr;
|
||||
|
||||
/* Allocate storage for this TXT answer appending it to the list */
|
||||
txt_curr = ares_malloc_data(ARES_DATATYPE_TXT_REPLY);
|
||||
txt_curr = ares_malloc_data(ex ? ARES_DATATYPE_TXT_EXT :
|
||||
ARES_DATATYPE_TXT_REPLY);
|
||||
if (!txt_curr)
|
||||
{
|
||||
status = ARES_ENOMEM;
|
||||
@@ -152,13 +151,17 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
|
||||
}
|
||||
txt_last = txt_curr;
|
||||
|
||||
if (ex)
|
||||
txt_curr->record_start = (strptr == aptr);
|
||||
txt_curr->length = substr_len;
|
||||
txt_curr->txt = malloc (substr_len + 1/* Including null byte */);
|
||||
txt_curr->txt = ares_malloc (substr_len + 1/* Including null byte */);
|
||||
if (txt_curr->txt == NULL)
|
||||
{
|
||||
status = ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
|
||||
++strptr;
|
||||
memcpy ((char *) txt_curr->txt, strptr, substr_len);
|
||||
|
||||
/* Make sure we NULL-terminate */
|
||||
@@ -168,8 +171,14 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
|
||||
}
|
||||
}
|
||||
|
||||
/* Propagate any failures */
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
/* Don't lose memory in the next iteration */
|
||||
free (rr_name);
|
||||
ares_free (rr_name);
|
||||
rr_name = NULL;
|
||||
|
||||
/* Move on to the next record */
|
||||
@@ -177,9 +186,9 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
|
||||
}
|
||||
|
||||
if (hostname)
|
||||
free (hostname);
|
||||
ares_free (hostname);
|
||||
if (rr_name)
|
||||
free (rr_name);
|
||||
ares_free (rr_name);
|
||||
|
||||
/* clean up on error */
|
||||
if (status != ARES_SUCCESS)
|
||||
@@ -194,3 +203,18 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
ares_parse_txt_reply (const unsigned char *abuf, int alen,
|
||||
struct ares_txt_reply **txt_out)
|
||||
{
|
||||
return ares__parse_txt_reply(abuf, alen, 0, (void **) txt_out);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ares_parse_txt_reply_ext (const unsigned char *abuf, int alen,
|
||||
struct ares_txt_ext **txt_out)
|
||||
{
|
||||
return ares__parse_txt_reply(abuf, alen, 1, (void **) txt_out);
|
||||
}
|
||||
|
||||
+21
-14
@@ -43,6 +43,13 @@
|
||||
#define INADDR_NONE 0xffffffff
|
||||
#endif
|
||||
|
||||
#ifdef CARES_EXPOSE_STATICS
|
||||
/* Make some internal functions visible for testing */
|
||||
#define STATIC_TESTABLE
|
||||
#else
|
||||
#define STATIC_TESTABLE static
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && !defined(WATT32)
|
||||
|
||||
#define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP"
|
||||
@@ -86,10 +93,7 @@
|
||||
# define getenv(ptr) ares_getenv(ptr)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
# include "ares_strdup.h"
|
||||
# define strdup(ptr) ares_strdup(ptr)
|
||||
#endif
|
||||
#include "ares_strdup.h"
|
||||
|
||||
#ifndef HAVE_STRCASECMP
|
||||
# include "ares_strcasecmp.h"
|
||||
@@ -119,6 +123,8 @@ struct ares_addr {
|
||||
struct in_addr addr4;
|
||||
struct ares_in6_addr addr6;
|
||||
} addr;
|
||||
int udp_port; /* stored in network order */
|
||||
int tcp_port; /* stored in network order */
|
||||
};
|
||||
#define addrV4 addr.addr4
|
||||
#define addrV6 addr.addr6
|
||||
@@ -251,8 +257,8 @@ struct ares_channeldata {
|
||||
int tries;
|
||||
int ndots;
|
||||
int rotate; /* if true, all servers specified are used */
|
||||
int udp_port;
|
||||
int tcp_port;
|
||||
int udp_port; /* stored in network order */
|
||||
int tcp_port; /* stored in network order */
|
||||
int socket_send_buffer_size;
|
||||
int socket_receive_buffer_size;
|
||||
char **domains;
|
||||
@@ -305,19 +311,20 @@ struct ares_channeldata {
|
||||
|
||||
ares_sock_create_callback sock_create_cb;
|
||||
void *sock_create_cb_data;
|
||||
|
||||
ares_sock_config_callback sock_config_cb;
|
||||
void *sock_config_cb_data;
|
||||
};
|
||||
|
||||
/* Memory management functions */
|
||||
extern void *(*ares_malloc)(size_t size);
|
||||
extern void *(*ares_realloc)(void *ptr, size_t size);
|
||||
extern void (*ares_free)(void *ptr);
|
||||
|
||||
/* 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__send_query(ares_channel channel, struct query *query,
|
||||
struct timeval *now);
|
||||
void ares__close_sockets(ares_channel channel, struct server_state *server);
|
||||
|
||||
+84
-55
@@ -1,6 +1,6 @@
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2004-2013 by Daniel Stenberg
|
||||
* Copyright (C) 2004-2016 by Daniel Stenberg
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -102,8 +102,7 @@ int ares__timedout(struct timeval *now,
|
||||
}
|
||||
|
||||
/* add the specific number of milliseconds to the time in the first argument */
|
||||
int ares__timeadd(struct timeval *now,
|
||||
int millisecs)
|
||||
static void timeadd(struct timeval *now, int millisecs)
|
||||
{
|
||||
now->tv_sec += millisecs/1000;
|
||||
now->tv_usec += (millisecs%1000)*1000;
|
||||
@@ -112,19 +111,8 @@ int ares__timeadd(struct timeval *now,
|
||||
++(now->tv_sec);
|
||||
now->tv_usec -= 1000000;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* return time offset between now and (future) check, in milliseconds */
|
||||
long ares__timeoffset(struct timeval *now,
|
||||
struct timeval *check)
|
||||
{
|
||||
return (check->tv_sec - now->tv_sec)*1000 +
|
||||
(check->tv_usec - now->tv_usec)/1000;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* generic process function
|
||||
*/
|
||||
@@ -239,7 +227,7 @@ static void write_tcp_data(ares_channel channel,
|
||||
n++;
|
||||
|
||||
/* Allocate iovecs so we can send all our data at once. */
|
||||
vec = malloc(n * sizeof(struct iovec));
|
||||
vec = ares_malloc(n * sizeof(struct iovec));
|
||||
if (vec)
|
||||
{
|
||||
/* Fill in the iovecs and send. */
|
||||
@@ -251,7 +239,7 @@ static void write_tcp_data(ares_channel channel,
|
||||
n++;
|
||||
}
|
||||
wcount = (ssize_t)writev(server->tcp_socket, vec, (int)n);
|
||||
free(vec);
|
||||
ares_free(vec);
|
||||
if (wcount < 0)
|
||||
{
|
||||
if (!try_again(SOCKERRNO))
|
||||
@@ -293,8 +281,8 @@ static void advance_tcp_send_queue(ares_channel channel, int whichserver,
|
||||
num_bytes -= sendreq->len;
|
||||
server->qhead = sendreq->next;
|
||||
if (sendreq->data_storage)
|
||||
free(sendreq->data_storage);
|
||||
free(sendreq);
|
||||
ares_free(sendreq->data_storage);
|
||||
ares_free(sendreq);
|
||||
if (server->qhead == NULL) {
|
||||
SOCK_STATE_CALLBACK(channel, server->tcp_socket, 1, 0);
|
||||
server->qtail = NULL;
|
||||
@@ -373,9 +361,12 @@ static void read_tcp_data(ares_channel channel, fd_set *read_fds,
|
||||
*/
|
||||
server->tcp_length = server->tcp_lenbuf[0] << 8
|
||||
| server->tcp_lenbuf[1];
|
||||
server->tcp_buffer = malloc(server->tcp_length);
|
||||
if (!server->tcp_buffer)
|
||||
server->tcp_buffer = ares_malloc(server->tcp_length);
|
||||
if (!server->tcp_buffer) {
|
||||
handle_error(channel, i, now);
|
||||
return; /* bail out on malloc failure. TODO: make this
|
||||
function return error codes */
|
||||
}
|
||||
server->tcp_buffer_pos = 0;
|
||||
}
|
||||
}
|
||||
@@ -400,8 +391,7 @@ static void read_tcp_data(ares_channel channel, fd_set *read_fds,
|
||||
*/
|
||||
process_answer(channel, server->tcp_buffer, server->tcp_length,
|
||||
i, 1, now);
|
||||
if (server->tcp_buffer)
|
||||
free(server->tcp_buffer);
|
||||
ares_free(server->tcp_buffer);
|
||||
server->tcp_buffer = NULL;
|
||||
server->tcp_lenbuf_pos = 0;
|
||||
server->tcp_buffer_pos = 0;
|
||||
@@ -575,14 +565,15 @@ static void process_answer(ares_channel channel, unsigned char *abuf,
|
||||
packetsz = channel->ednspsz;
|
||||
if (rcode == NOTIMP || rcode == FORMERR || rcode == SERVFAIL)
|
||||
{
|
||||
int qlen = alen - EDNSFIXEDSZ;
|
||||
int qlen = (query->tcplen - 2) - EDNSFIXEDSZ;
|
||||
channel->flags ^= ARES_FLAG_EDNS;
|
||||
query->tcplen -= EDNSFIXEDSZ;
|
||||
query->qlen -= EDNSFIXEDSZ;
|
||||
query->tcpbuf[0] = (unsigned char)((qlen >> 8) & 0xff);
|
||||
query->tcpbuf[1] = (unsigned char)(qlen & 0xff);
|
||||
DNS_HEADER_SET_ARCOUNT(query->tcpbuf + 2, 0);
|
||||
query->tcpbuf = realloc(query->tcpbuf, query->tcplen);
|
||||
query->tcpbuf = ares_realloc(query->tcpbuf, query->tcplen);
|
||||
query->qbuf = query->tcpbuf + 2;
|
||||
ares__send_query(channel, query, now);
|
||||
return;
|
||||
}
|
||||
@@ -781,12 +772,13 @@ void ares__send_query(ares_channel channel, struct query *query,
|
||||
return;
|
||||
}
|
||||
}
|
||||
sendreq = calloc(1, sizeof(struct send_request));
|
||||
sendreq = ares_malloc(sizeof(struct send_request));
|
||||
if (!sendreq)
|
||||
{
|
||||
end_query(channel, query, ARES_ENOMEM, NULL, 0);
|
||||
return;
|
||||
}
|
||||
memset(sendreq, 0, sizeof(struct send_request));
|
||||
/* To make the common case fast, we avoid copies by using the query's
|
||||
* tcpbuf for as long as the query is alive. In the rare case where the
|
||||
* query ends while it's queued for transmission, then we give the
|
||||
@@ -831,8 +823,7 @@ void ares__send_query(ares_channel channel, struct query *query,
|
||||
timeplus = channel->timeout << (query->try_count / channel->nservers);
|
||||
timeplus = (timeplus * (9 + (rand () & 7))) / 16;
|
||||
query->timeout = *now;
|
||||
ares__timeadd(&query->timeout,
|
||||
timeplus);
|
||||
timeadd(&query->timeout, timeplus);
|
||||
/* Keep track of queries bucketed by timeout, so we can process
|
||||
* timeout events quickly.
|
||||
*/
|
||||
@@ -856,7 +847,7 @@ void ares__send_query(ares_channel channel, struct query *query,
|
||||
* portable.
|
||||
*/
|
||||
static int setsocknonblock(ares_socket_t sockfd, /* operate on this */
|
||||
int nonblock /* TRUE or FALSE */)
|
||||
int nonblock /* TRUE or FALSE */)
|
||||
{
|
||||
#if defined(USE_BLOCKING_SOCKETS)
|
||||
|
||||
@@ -870,7 +861,7 @@ static int setsocknonblock(ares_socket_t sockfd, /* operate on this */
|
||||
if (FALSE != nonblock)
|
||||
return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
|
||||
else
|
||||
return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));
|
||||
return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK)); /* LCOV_EXCL_LINE */
|
||||
|
||||
#elif defined(HAVE_IOCTL_FIONBIO)
|
||||
|
||||
@@ -913,12 +904,12 @@ static int configure_socket(ares_socket_t s, int family, ares_channel channel)
|
||||
struct sockaddr_in6 sa6;
|
||||
} local;
|
||||
|
||||
setsocknonblock(s, TRUE);
|
||||
(void)setsocknonblock(s, TRUE);
|
||||
|
||||
#if defined(FD_CLOEXEC) && !defined(MSDOS)
|
||||
/* Configure the socket fd as close-on-exec. */
|
||||
if (fcntl(s, F_SETFD, FD_CLOEXEC) == -1)
|
||||
return -1;
|
||||
//if (fcntl(s, F_SETFD, FD_CLOEXEC) == -1)
|
||||
// return -1; /* LCOV_EXCL_LINE */
|
||||
#endif
|
||||
|
||||
/* Set the socket's send and receive buffer sizes. */
|
||||
@@ -935,13 +926,13 @@ static int configure_socket(ares_socket_t s, int family, ares_channel channel)
|
||||
return -1;
|
||||
|
||||
#ifdef SO_BINDTODEVICE
|
||||
if (channel->local_dev_name[0]) {
|
||||
if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE,
|
||||
channel->local_dev_name, sizeof(channel->local_dev_name))) {
|
||||
// if (channel->local_dev_name[0]) {
|
||||
// if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE,
|
||||
// channel->local_dev_name, sizeof(channel->local_dev_name))) {
|
||||
/* Only root can do this, and usually not fatal if it doesn't work, so */
|
||||
/* just continue on. */
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
#endif
|
||||
|
||||
if (family == AF_INET) {
|
||||
@@ -986,7 +977,11 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
|
||||
salen = sizeof(saddr.sa4);
|
||||
memset(sa, 0, salen);
|
||||
saddr.sa4.sin_family = AF_INET;
|
||||
saddr.sa4.sin_port = aresx_sitous(channel->tcp_port);
|
||||
if (server->addr.tcp_port) {
|
||||
saddr.sa4.sin_port = aresx_sitous(server->addr.tcp_port);
|
||||
} else {
|
||||
saddr.sa4.sin_port = aresx_sitous(channel->tcp_port);
|
||||
}
|
||||
memcpy(&saddr.sa4.sin_addr, &server->addr.addrV4,
|
||||
sizeof(server->addr.addrV4));
|
||||
break;
|
||||
@@ -995,12 +990,16 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
|
||||
salen = sizeof(saddr.sa6);
|
||||
memset(sa, 0, salen);
|
||||
saddr.sa6.sin6_family = AF_INET6;
|
||||
saddr.sa6.sin6_port = aresx_sitous(channel->tcp_port);
|
||||
if (server->addr.tcp_port) {
|
||||
saddr.sa6.sin6_port = aresx_sitous(server->addr.tcp_port);
|
||||
} else {
|
||||
saddr.sa6.sin6_port = aresx_sitous(channel->tcp_port);
|
||||
}
|
||||
memcpy(&saddr.sa6.sin6_addr, &server->addr.addrV6,
|
||||
sizeof(server->addr.addrV6));
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
return -1; /* LCOV_EXCL_LINE */
|
||||
}
|
||||
|
||||
/* Acquire a socket. */
|
||||
@@ -1031,6 +1030,17 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (channel->sock_config_cb)
|
||||
{
|
||||
int err = channel->sock_config_cb(s, SOCK_STREAM,
|
||||
channel->sock_config_cb_data);
|
||||
if (err < 0)
|
||||
{
|
||||
sclose(s);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
/* Connect to the server. */
|
||||
if (connect(s, sa, salen) == -1)
|
||||
{
|
||||
@@ -1078,7 +1088,11 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
|
||||
salen = sizeof(saddr.sa4);
|
||||
memset(sa, 0, salen);
|
||||
saddr.sa4.sin_family = AF_INET;
|
||||
saddr.sa4.sin_port = aresx_sitous(channel->udp_port);
|
||||
if (server->addr.udp_port) {
|
||||
saddr.sa4.sin_port = aresx_sitous(server->addr.udp_port);
|
||||
} else {
|
||||
saddr.sa4.sin_port = aresx_sitous(channel->udp_port);
|
||||
}
|
||||
memcpy(&saddr.sa4.sin_addr, &server->addr.addrV4,
|
||||
sizeof(server->addr.addrV4));
|
||||
break;
|
||||
@@ -1087,12 +1101,16 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
|
||||
salen = sizeof(saddr.sa6);
|
||||
memset(sa, 0, salen);
|
||||
saddr.sa6.sin6_family = AF_INET6;
|
||||
saddr.sa6.sin6_port = aresx_sitous(channel->udp_port);
|
||||
if (server->addr.udp_port) {
|
||||
saddr.sa6.sin6_port = aresx_sitous(server->addr.udp_port);
|
||||
} else {
|
||||
saddr.sa6.sin6_port = aresx_sitous(channel->udp_port);
|
||||
}
|
||||
memcpy(&saddr.sa6.sin6_addr, &server->addr.addrV6,
|
||||
sizeof(server->addr.addrV6));
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
return -1; /* LCOV_EXCL_LINE */
|
||||
}
|
||||
|
||||
/* Acquire a socket. */
|
||||
@@ -1107,6 +1125,17 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (channel->sock_config_cb)
|
||||
{
|
||||
int err = channel->sock_config_cb(s, SOCK_DGRAM,
|
||||
channel->sock_config_cb_data);
|
||||
if (err < 0)
|
||||
{
|
||||
sclose(s);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
/* Connect to the server. */
|
||||
if (connect(s, sa, salen) == -1)
|
||||
{
|
||||
@@ -1169,7 +1198,7 @@ static int same_questions(const unsigned char *qbuf, int qlen,
|
||||
q.p += q.namelen;
|
||||
if (q.p + QFIXEDSZ > qbuf + qlen)
|
||||
{
|
||||
free(q.name);
|
||||
ares_free(q.name);
|
||||
return 0;
|
||||
}
|
||||
q.type = DNS_QUESTION_TYPE(q.p);
|
||||
@@ -1184,14 +1213,14 @@ static int same_questions(const unsigned char *qbuf, int qlen,
|
||||
if (ares_expand_name(a.p, abuf, alen, &a.name, &a.namelen)
|
||||
!= ARES_SUCCESS)
|
||||
{
|
||||
free(q.name);
|
||||
ares_free(q.name);
|
||||
return 0;
|
||||
}
|
||||
a.p += a.namelen;
|
||||
if (a.p + QFIXEDSZ > abuf + alen)
|
||||
{
|
||||
free(q.name);
|
||||
free(a.name);
|
||||
ares_free(q.name);
|
||||
ares_free(a.name);
|
||||
return 0;
|
||||
}
|
||||
a.type = DNS_QUESTION_TYPE(a.p);
|
||||
@@ -1202,13 +1231,13 @@ static int same_questions(const unsigned char *qbuf, int qlen,
|
||||
if (strcasecmp(q.name, a.name) == 0 && q.type == a.type
|
||||
&& q.dnsclass == a.dnsclass)
|
||||
{
|
||||
free(a.name);
|
||||
ares_free(a.name);
|
||||
break;
|
||||
}
|
||||
free(a.name);
|
||||
ares_free(a.name);
|
||||
}
|
||||
|
||||
free(q.name);
|
||||
ares_free(q.name);
|
||||
if (j == a.qdcount)
|
||||
return 0;
|
||||
}
|
||||
@@ -1237,7 +1266,7 @@ static int same_address(struct sockaddr *sa, struct ares_addr *aa)
|
||||
return 1; /* match */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break; /* LCOV_EXCL_LINE */
|
||||
}
|
||||
}
|
||||
return 0; /* different */
|
||||
@@ -1274,7 +1303,7 @@ static void end_query (ares_channel channel, struct query *query, int status,
|
||||
* to the query's tcpbuf and handle these cases, we just give
|
||||
* such sendreqs their own copy of the query packet.
|
||||
*/
|
||||
sendreq->data_storage = malloc(sendreq->len);
|
||||
sendreq->data_storage = ares_malloc(sendreq->len);
|
||||
if (sendreq->data_storage != NULL)
|
||||
{
|
||||
memcpy(sendreq->data_storage, sendreq->data, sendreq->len);
|
||||
@@ -1324,7 +1353,7 @@ void ares__free_query(struct query *query)
|
||||
query->callback = NULL;
|
||||
query->arg = NULL;
|
||||
/* Deallocate the memory associated with the query */
|
||||
free(query->tcpbuf);
|
||||
free(query->server_info);
|
||||
free(query);
|
||||
ares_free(query->tcpbuf);
|
||||
ares_free(query->server_info);
|
||||
ares_free(query);
|
||||
}
|
||||
|
||||
+3
-3
@@ -121,7 +121,7 @@ void ares_query(ares_channel channel, const char *name, int dnsclass,
|
||||
&qlen, (channel->flags & ARES_FLAG_EDNS) ? channel->ednspsz : 0);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
if (qbuf != NULL) free(qbuf);
|
||||
if (qbuf != NULL) ares_free(qbuf);
|
||||
callback(arg, status, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ void ares_query(ares_channel channel, const char *name, int dnsclass,
|
||||
channel->next_id = generate_unique_id(channel);
|
||||
|
||||
/* Allocate and fill in the query structure. */
|
||||
qquery = malloc(sizeof(struct qquery));
|
||||
qquery = ares_malloc(sizeof(struct qquery));
|
||||
if (!qquery)
|
||||
{
|
||||
ares_free_string(qbuf);
|
||||
@@ -182,5 +182,5 @@ static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf,
|
||||
}
|
||||
qquery->callback(qquery->arg, status, timeouts, abuf, alen);
|
||||
}
|
||||
free(qquery);
|
||||
ares_free(qquery);
|
||||
}
|
||||
|
||||
+1
-20
@@ -68,21 +68,11 @@
|
||||
* 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.
|
||||
*/
|
||||
@@ -91,15 +81,6 @@
|
||||
|
||||
#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
|
||||
@@ -108,7 +89,7 @@ typedef char
|
||||
|
||||
typedef char
|
||||
__cares_rule_02__
|
||||
[CareschkszEQ(ares_socklen_t, CARES_SIZEOF_ARES_SOCKLEN_T)];
|
||||
[CareschkszEQ(ares_socklen_t, sizeof(CARES_TYPEOF_ARES_SOCKLEN_T))];
|
||||
|
||||
/*
|
||||
* Verify at compile time that the size of ares_socklen_t as reported
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ to free any associated memory.
|
||||
can return any of the following values:
|
||||
.TP 15
|
||||
.B ARES_SUCCESS
|
||||
The channel data was successfuly stored
|
||||
The channel data was successfully stored
|
||||
.TP 15
|
||||
.B ARES_ENOMEM
|
||||
The memory was exhausted
|
||||
|
||||
+19
-19
@@ -44,7 +44,7 @@ static void search_callback(void *arg, int status, int timeouts,
|
||||
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);
|
||||
STATIC_TESTABLE 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)
|
||||
@@ -66,24 +66,24 @@ void ares_search(ares_channel channel, const char *name, int dnsclass,
|
||||
if (s)
|
||||
{
|
||||
ares_query(channel, s, dnsclass, type, callback, arg);
|
||||
free(s);
|
||||
ares_free(s);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Allocate a search_query structure to hold the state necessary for
|
||||
* doing multiple lookups.
|
||||
*/
|
||||
squery = malloc(sizeof(struct search_query));
|
||||
squery = ares_malloc(sizeof(struct search_query));
|
||||
if (!squery)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
squery->channel = channel;
|
||||
squery->name = strdup(name);
|
||||
squery->name = ares_strdup(name);
|
||||
if (!squery->name)
|
||||
{
|
||||
free(squery);
|
||||
ares_free(squery);
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
@@ -123,13 +123,13 @@ void ares_search(ares_channel channel, const char *name, int dnsclass,
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
ares_query(channel, s, dnsclass, type, search_callback, squery);
|
||||
free(s);
|
||||
ares_free(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* failed, free the malloc()ed memory */
|
||||
free(squery->name);
|
||||
free(squery);
|
||||
ares_free(squery->name);
|
||||
ares_free(squery);
|
||||
callback(arg, status, 0, NULL, 0);
|
||||
}
|
||||
}
|
||||
@@ -177,7 +177,7 @@ static void search_callback(void *arg, int status, int timeouts,
|
||||
squery->next_domain++;
|
||||
ares_query(channel, s, squery->dnsclass, squery->type,
|
||||
search_callback, squery);
|
||||
free(s);
|
||||
ares_free(s);
|
||||
}
|
||||
}
|
||||
else if (squery->status_as_is == -1)
|
||||
@@ -201,8 +201,8 @@ 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);
|
||||
ares_free(squery->name);
|
||||
ares_free(squery);
|
||||
}
|
||||
|
||||
/* Concatenate two domains. */
|
||||
@@ -211,7 +211,7 @@ 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);
|
||||
*s = ares_malloc(nlen + 1 + dlen + 1);
|
||||
if (!*s)
|
||||
return ARES_ENOMEM;
|
||||
memcpy(*s, name, nlen);
|
||||
@@ -225,7 +225,7 @@ static int cat_domain(const char *name, const char *domain, char **s)
|
||||
* 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)
|
||||
STATIC_TESTABLE int single_domain(ares_channel channel, const char *name, char **s)
|
||||
{
|
||||
size_t len = strlen(name);
|
||||
const char *hostaliases;
|
||||
@@ -239,9 +239,9 @@ static int single_domain(ares_channel channel, const char *name, char **s)
|
||||
/* If the name contains a trailing dot, then the single query is the name
|
||||
* sans the trailing dot.
|
||||
*/
|
||||
if (name[len - 1] == '.')
|
||||
if ((len > 0) && (name[len - 1] == '.'))
|
||||
{
|
||||
*s = strdup(name);
|
||||
*s = ares_strdup(name);
|
||||
return (*s) ? ARES_SUCCESS : ARES_ENOMEM;
|
||||
}
|
||||
|
||||
@@ -268,18 +268,18 @@ static int single_domain(ares_channel channel, const char *name, char **s)
|
||||
q = p + 1;
|
||||
while (*q && !ISSPACE(*q))
|
||||
q++;
|
||||
*s = malloc(q - p + 1);
|
||||
*s = ares_malloc(q - p + 1);
|
||||
if (*s)
|
||||
{
|
||||
memcpy(*s, p, q - p);
|
||||
(*s)[q - p] = 0;
|
||||
}
|
||||
free(line);
|
||||
ares_free(line);
|
||||
fclose(fp);
|
||||
return (*s) ? ARES_SUCCESS : ARES_ENOMEM;
|
||||
}
|
||||
}
|
||||
free(line);
|
||||
ares_free(line);
|
||||
fclose(fp);
|
||||
if (status != ARES_SUCCESS && status != ARES_EOF)
|
||||
return status;
|
||||
@@ -307,7 +307,7 @@ static int single_domain(ares_channel channel, const char *name, char **s)
|
||||
if (channel->flags & ARES_FLAG_NOSEARCH || channel->ndomains == 0)
|
||||
{
|
||||
/* No domain search to do; just try the name as-is. */
|
||||
*s = strdup(name);
|
||||
*s = ares_strdup(name);
|
||||
return (*s) ? ARES_SUCCESS : ARES_ENOMEM;
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -47,25 +47,25 @@ void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
|
||||
}
|
||||
|
||||
/* Allocate space for query and allocated fields. */
|
||||
query = malloc(sizeof(struct query));
|
||||
query = ares_malloc(sizeof(struct query));
|
||||
if (!query)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
query->tcpbuf = malloc(qlen + 2);
|
||||
query->tcpbuf = ares_malloc(qlen + 2);
|
||||
if (!query->tcpbuf)
|
||||
{
|
||||
free(query);
|
||||
ares_free(query);
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
query->server_info = malloc(channel->nservers *
|
||||
sizeof(query->server_info[0]));
|
||||
query->server_info = ares_malloc(channel->nservers *
|
||||
sizeof(query->server_info[0]));
|
||||
if (!query->server_info)
|
||||
{
|
||||
free(query->tcpbuf);
|
||||
free(query);
|
||||
ares_free(query->tcpbuf);
|
||||
ares_free(query);
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ ares_set_local_dev \- Bind to a specific network device when creating sockets.
|
||||
The \fBares_set_local_dev\fP function causes all future sockets
|
||||
to be bound to this device with SO_BINDTODEVICE. This forces communications
|
||||
to go over a certain interface, which can be useful on multi-homed machines.
|
||||
This option is only supported on Linux, and root priviledges are required
|
||||
This option is only supported on Linux, and root privileges are required
|
||||
for the option to work. If SO_BINDTODEVICE is not supported or the
|
||||
setsocktop call fails (probably because of permissions), the error is
|
||||
silently ignored.
|
||||
|
||||
+19
-11
@@ -15,12 +15,13 @@
|
||||
.\"
|
||||
.TH ARES_SET_SERVERS 3 "5 March 2010"
|
||||
.SH NAME
|
||||
ares_set_servers \- Initialize an ares_channel name servers configuration
|
||||
ares_set_servers, ares_set_servers_ports \- Initialize an ares_channel name servers configuration
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B int ares_set_servers(ares_channel \fIchannel\fP, struct ares_addr_node *\fIservers\fP)
|
||||
.B int ares_set_servers_ports(ares_channel \fIchannel\fP, struct ares_addr_port_node *\fIservers\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The \fBares_set_servers(3)\fP function initializes name servers configuration
|
||||
@@ -30,19 +31,25 @@ from a
|
||||
.IR servers
|
||||
pointer to a linked list of ares_addr_node structs holding name servers
|
||||
address data.
|
||||
|
||||
.PP
|
||||
The name server linked list pointer argument may be the result of a previous
|
||||
call to \fBares_get_servers(3)\fP or a linked list of ares_addr_node structs
|
||||
setup by other means.
|
||||
|
||||
call to \fBares_get_servers(3)\fP or a linked list of \fBares_addr_node\fP structs
|
||||
set up by other means.
|
||||
.PP
|
||||
The \fBares_set_servers(3)\fP function also allows the specification of UDP and
|
||||
TCP ports to be used for communication on a per-server basis. The provided
|
||||
linked list argument may be the result of a previous call to
|
||||
\fBares_get_servers_ports(3)\fP or a linked list of \fBares_addr_port_node\fP structs
|
||||
set up by other means.
|
||||
.PP
|
||||
This function replaces any potentially previously configured name servers
|
||||
with the ones given in the linked list. So, in order to configure a channel
|
||||
with more than one name server all the desired ones must be specified in a
|
||||
with more than one name server all the desired ones must be specified in a
|
||||
single list.
|
||||
|
||||
\fBares_set_servers(3)\fP does not take ownership of the linked list argument.
|
||||
.PP
|
||||
The function does not take ownership of the linked list argument.
|
||||
The caller is responsible for freeing the linked list when no longer needed.
|
||||
|
||||
.PP
|
||||
This function is capable of handling IPv4 and IPv6 name server
|
||||
addresses simultaneously, rendering \fBares_init_options(3)\fP with
|
||||
optmask \fBARES_OPT_SERVERS\fP functionally obsolete except for
|
||||
@@ -53,7 +60,7 @@ IPv4-only name server usage.
|
||||
may return any of the following values:
|
||||
.TP 15
|
||||
.B ARES_SUCCESS
|
||||
The name servers configuration was successfuly initialized.
|
||||
The name servers configuration was successfully initialized.
|
||||
.TP 15
|
||||
.B ARES_ENOMEM
|
||||
The process's available memory was exhausted.
|
||||
@@ -71,7 +78,8 @@ c-ares library initialization not yet performed.
|
||||
.BR ares_init_options (3),
|
||||
.BR ares_dup(3)
|
||||
.SH AVAILABILITY
|
||||
ares_set_servers(3) was added in c-ares 1.7.1
|
||||
\fBares_set_servers(3)\fP was added in c-ares 1.7.1;
|
||||
\fBares_set_servers_ports(3)\fP was added in c-ares 1.11.0.
|
||||
.SH AUTHOR
|
||||
Implementation of this function and associated library internals are based
|
||||
on code, comments and feedback provided in November and December of 2008 by
|
||||
|
||||
+30
-9
@@ -15,29 +15,50 @@
|
||||
.\"
|
||||
.TH ARES_SET_SERVERS_CSV 3 "30 June 2010"
|
||||
.SH NAME
|
||||
ares_set_servers_csv \- Set list of DNS servers to be used.
|
||||
ares_set_servers_csv, ares_set_servers_ports_csv \- Set list of DNS servers to be used.
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B void ares_set_servers_csv(ares_channel \fIchannel\fP, const char* \fIservers\fP)
|
||||
.B int ares_set_servers_csv(ares_channel \fIchannel\fP, const char* \fIservers\fP)
|
||||
.B int ares_set_servers_ports_csv(ares_channel \fIchannel\fP, const char* \fIservers\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The \fBares_set_servers_csv\fP function sets the list of DNS servers
|
||||
that ARES will query. The format of the servers option is:
|
||||
The \fBares_set_servers_csv\fP and \fBares_set_servers_ports_csv\fPfunctions set
|
||||
the list of DNS servers that ARES will query. The format of the servers option is:
|
||||
|
||||
host[:port][,host[:port]]...
|
||||
|
||||
For example:
|
||||
|
||||
192.168.1.100,192.168.1.101,3.4.5.6
|
||||
.PP
|
||||
The \fBares_set_servers_csv\fP function will ignore any port values specified in
|
||||
the input string, whereare the \fBares_set_servers_ports_csv\fP function will
|
||||
apply any specified port values as the UDP and TCP port to be used for that
|
||||
particular nameserver.
|
||||
|
||||
.SH RETURN VALUES
|
||||
.B ares_set_servers_csv(3)
|
||||
This function may return any of the following values:
|
||||
.TP 15
|
||||
.B ARES_SUCCESS
|
||||
The name servers configuration was successfully initialized.
|
||||
.TP 15
|
||||
.B ARES_ENOMEM
|
||||
The process's available memory was exhausted.
|
||||
.TP 15
|
||||
.B ARES_ENODATA
|
||||
The channel data identified by
|
||||
.IR channel
|
||||
was invalid.
|
||||
.TP 15
|
||||
.B ARES_ENOTINITIALIZED
|
||||
c-ares library initialization not yet performed.
|
||||
.SH SEE ALSO
|
||||
.BR ares_set_servers (3)
|
||||
.SH NOTES
|
||||
The port option is currently ignored by c-ares internals
|
||||
and the standard port is always used.
|
||||
|
||||
This function was added in c-ares 1.7.2
|
||||
.SH AVAILABILITY
|
||||
\fBares_set_servers_csv\fP was added in c-ares 1.7.2;
|
||||
\fBares_set_servers_ports_csv\fP was added in c-ares 1.11.0.
|
||||
.SH AUTHOR
|
||||
Ben Greear
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.so man3/ares_set_servers.3
|
||||
@@ -0,0 +1 @@
|
||||
.so man3/ares_set_servers_csv.3
|
||||
@@ -6,6 +6,10 @@ ares_set_socket_callback \- Set a socket creation callback
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B typedef int (*ares_sock_create_callback)(ares_socket_t \fIsocket_fd\fP,
|
||||
int \fItype\fP,
|
||||
void *\fIuserdata\fP)
|
||||
.PP
|
||||
.B void ares_set_socket_callback(ares_channel \fIchannel\fP,
|
||||
ares_sock_create_callback \fIcallback\fP,
|
||||
void *\fIuserdata\fP)
|
||||
@@ -17,10 +21,10 @@ ares_set_socket_callback \- Set a socket creation callback
|
||||
This function sets a \fIcallback\fP in the given ares channel handle. This
|
||||
callback function will be invoked after the socket has been created, and
|
||||
connected to the remote server. The callback must return ARES_SUCCESS if
|
||||
things are fine, or use the standard ares error codes to signal errors
|
||||
back. Returned errors will abort the ares operation.
|
||||
things are fine, or return -1 to signal an error. A returned error will
|
||||
abort the ares operation.
|
||||
.SH SEE ALSO
|
||||
.BR ares_init_options (3)
|
||||
.BR ares_init_options (3), ares_set_socket_configure_callback (3)
|
||||
.SH AVAILABILITY
|
||||
ares_set_socket_callback(3) was added in c-ares 1.6.0
|
||||
.SH AUTHOR
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
.\"
|
||||
.TH ARES_SET_SOCKET_CONFIGURE_CALLBACK 3 "6 Feb 2016"
|
||||
.SH NAME
|
||||
ares_set_socket_configure_callback \- Set a socket configuration callback
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B typedef int (*ares_sock_config_callback)(ares_socket_t \fIsocket_fd\fP,
|
||||
int \fItype\fP,
|
||||
void *\fIuserdata\fP)
|
||||
.PP
|
||||
.B void ares_set_socket_configure_callback(ares_channel \fIchannel\fP,
|
||||
ares_sock_config_callback \fIcallback\fP,
|
||||
void *\fIuserdata\fP)
|
||||
.PP
|
||||
.B cc file.c -lcares
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
This function sets a \fIcallback\fP in the given ares channel handle. This
|
||||
callback function will be invoked after the socket has been created, but
|
||||
before it has been connected to the remote server, which is an ideal time
|
||||
to configure various socket options. The callback must return ARES_SUCCESS
|
||||
if things are fine, or return -1 to signal an error. A returned error will
|
||||
abort the ares operation.
|
||||
.SH SEE ALSO
|
||||
.BR ares_init_options (3), ares_set_socket_callback (3)
|
||||
.SH AVAILABILITY
|
||||
ares_set_socket_configure_callback(3) was added in c-ares 1.11.0
|
||||
.SH AUTHOR
|
||||
Andrew Ayer
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
.\"
|
||||
.\" 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.
|
||||
.\"
|
||||
.TH ARES_SET_SORTLIST 3 "23 November 2015"
|
||||
.SH NAME
|
||||
ares_set_sortlist \- Initialize an ares_channel sortlist configuration
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B int ares_set_sortlist(ares_channel \fIchannel\fP, const char *\fIsortstr\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The \fBares_set_sortlist(3)\fP function initializes an address sortlist configuration
|
||||
for the channel data identified by
|
||||
.IR channel ,
|
||||
so that addresses returned by \fBares_gethostbyname(3)\fP are sorted according to the
|
||||
sortlist. The provided
|
||||
.IR sortstr
|
||||
string that holds a space separated list of IP-address-netmask pairs. The
|
||||
netmask is optional but follows the address after a slash if present. For example,
|
||||
"130.155.160.0/255.255.240.0 130.155.0.0".
|
||||
|
||||
This function replaces any potentially previously configured address sortlist
|
||||
with the ones given in the configuration string.
|
||||
|
||||
.SH RETURN VALUES
|
||||
.B ares_set_sortlist(3)
|
||||
may return any of the following values:
|
||||
.TP 15
|
||||
.B ARES_SUCCESS
|
||||
The sortlist configuration was successfully initialized.
|
||||
.TP 15
|
||||
.B ARES_ENOMEM
|
||||
The process's available memory was exhausted.
|
||||
.TP 15
|
||||
.B ARES_ENODATA
|
||||
The channel data identified by
|
||||
.IR channel
|
||||
was invalid.
|
||||
.TP 15
|
||||
.B ARES_ENOTINITIALIZED
|
||||
c-ares library initialization not yet performed.
|
||||
.SH SEE ALSO
|
||||
.BR ares_init_options (3),
|
||||
.BR ares_dup(3)
|
||||
.SH AVAILABILITY
|
||||
ares_set_sortlist(3) was added in c-ares 1.11.0
|
||||
@@ -38,6 +38,10 @@
|
||||
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#ifdef AMIGA
|
||||
#include "config-amiga.h"
|
||||
#endif
|
||||
|
||||
/* ================================================================ */
|
||||
/* Definition of preprocessor macros/symbols which modify compiler */
|
||||
/* behaviour or generated code characteristics must be done here, */
|
||||
|
||||
+21
-14
@@ -17,26 +17,33 @@
|
||||
|
||||
#include "ares_setup.h"
|
||||
#include "ares_strdup.h"
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
char *ares_strdup(const char *s1)
|
||||
{
|
||||
size_t sz;
|
||||
char * s2;
|
||||
#ifdef HAVE_STRDUP
|
||||
if (ares_malloc == malloc)
|
||||
return strdup(s1);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
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;
|
||||
if(s1) {
|
||||
sz = strlen(s1);
|
||||
if(sz < (size_t)-1) {
|
||||
sz++;
|
||||
if(sz < ((size_t)-1) / sizeof(char)) {
|
||||
s2 = ares_malloc(sz * sizeof(char));
|
||||
if(s2) {
|
||||
memcpy(s2, s1, sz * sizeof(char));
|
||||
return s2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (char *)NULL;
|
||||
}
|
||||
return (char *)NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
extern char *ares_strdup(const char *s1);
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CARES_STRDUP_H */
|
||||
|
||||
+8
-1
@@ -23,6 +23,13 @@
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
/* return time offset between now and (future) check, in milliseconds */
|
||||
static long timeoffset(struct timeval *now, struct timeval *check)
|
||||
{
|
||||
return (check->tv_sec - now->tv_sec)*1000 +
|
||||
(check->tv_usec - now->tv_usec)/1000;
|
||||
}
|
||||
|
||||
/* 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
|
||||
@@ -53,7 +60,7 @@ struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv,
|
||||
query = list_node->data;
|
||||
if (query->timeout.tv_sec == 0)
|
||||
continue;
|
||||
offset = ares__timeoffset(&now, &query->timeout);
|
||||
offset = timeoffset(&now, &query->timeout);
|
||||
if (offset < 0)
|
||||
offset = 0;
|
||||
if (min_offset == -1 || offset < min_offset)
|
||||
|
||||
+3
-3
@@ -3,15 +3,15 @@
|
||||
#define ARES__VERSION_H
|
||||
|
||||
/* This is the global package copyright */
|
||||
#define ARES_COPYRIGHT "2004 - 2013 Daniel Stenberg, <daniel@haxx.se>."
|
||||
#define ARES_COPYRIGHT "2004 - 2016 Daniel Stenberg, <daniel@haxx.se>."
|
||||
|
||||
#define ARES_VERSION_MAJOR 1
|
||||
#define ARES_VERSION_MINOR 10
|
||||
#define ARES_VERSION_MINOR 12
|
||||
#define ARES_VERSION_PATCH 0
|
||||
#define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\
|
||||
(ARES_VERSION_MINOR<<8)|\
|
||||
(ARES_VERSION_PATCH))
|
||||
#define ARES_VERSION_STR "1.10.0-DEV"
|
||||
#define ARES_VERSION_STR "1.12.0"
|
||||
|
||||
#if (ARES_VERSION >= 0x010700)
|
||||
# define CARES_HAVE_ARES_LIBRARY_INIT 1
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt)
|
||||
return (0);
|
||||
|
||||
/* Allocate a temporary buffer to hold the data */
|
||||
buffer = malloc(bytes);
|
||||
buffer = ares_malloc(bytes);
|
||||
if (!buffer)
|
||||
{
|
||||
SET_ERRNO(ENOMEM);
|
||||
@@ -71,7 +71,7 @@ ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt)
|
||||
/* Send buffer contents */
|
||||
result = swrite(s, buffer, bytes);
|
||||
|
||||
free(buffer);
|
||||
ares_free(buffer);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* bitncmp(l, r, n)
|
||||
* compare bit masks l and r, for n bits.
|
||||
* return:
|
||||
* -1, 1, or 0 in the libc tradition.
|
||||
* <0, >0, or 0 in the libc tradition.
|
||||
* note:
|
||||
* network byte order assumed. this means 192.5.5.240/28 has
|
||||
* 0x11110000 in its fourth octet.
|
||||
|
||||
@@ -74,25 +74,25 @@ want_lt_minor=4
|
||||
want_lt_patch=2
|
||||
want_lt_version=1.4.2
|
||||
|
||||
# This approach that tries 'glibtool' first is intended for systems that
|
||||
# have GNU libtool named as 'glibtool' and libtool not being GNU's.
|
||||
# This approach that tries 'glibtoolize first is intended for systems that
|
||||
# have GNU libtool named as 'glibtoolize' and libtoolize not being GNU's.
|
||||
|
||||
libtool=`findtool glibtool 2>/dev/null`
|
||||
if test ! -x "$libtool"; then
|
||||
libtool=`findtool ${LIBTOOL:-libtool}`
|
||||
libtoolize=`findtool glibtoolize 2>/dev/null`
|
||||
if test ! -x "$libtoolize"; then
|
||||
libtoolize=`findtool ${LIBTOOLIZE:-libtoolize}`
|
||||
fi
|
||||
if test -z "$libtool"; then
|
||||
echo "buildconf: libtool not found."
|
||||
echo " You need GNU libtool $want_lt_version or newer installed."
|
||||
if test -z "$libtoolize"; then
|
||||
echo "buildconf: libtoolize not found."
|
||||
echo " You need GNU libtoolize $want_lt_version or newer installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
lt_pver=`$libtool --version 2>/dev/null|head -n 1`
|
||||
lt_pver=`$libtoolize --version 2>/dev/null|head -n 1`
|
||||
lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
|
||||
lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
|
||||
if test -z "$lt_version"; then
|
||||
echo "buildconf: libtool not found."
|
||||
echo " You need GNU libtool $want_lt_version or newer installed."
|
||||
echo "buildconf: libtoolize not found."
|
||||
echo " You need GNU libtoolize $want_lt_version or newer installed."
|
||||
exit 1
|
||||
fi
|
||||
old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
|
||||
@@ -122,23 +122,8 @@ else
|
||||
lt_status="good"
|
||||
fi
|
||||
if test "$lt_status" != "good"; then
|
||||
echo "buildconf: libtool version $lt_version found."
|
||||
echo " You need GNU libtool $want_lt_version or newer installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# GNU libtoolize check
|
||||
#
|
||||
if test -z "$LIBTOOLIZE"; then
|
||||
# use (g)libtoolize from same location as (g)libtool
|
||||
libtoolize="${libtool}ize"
|
||||
else
|
||||
libtoolize=`findtool $LIBTOOLIZE`
|
||||
fi
|
||||
if test ! -f "$libtoolize"; then
|
||||
echo "buildconf: libtoolize not found."
|
||||
echo " You need GNU libtoolize $want_lt_version or newer installed."
|
||||
echo "buildconf: libtoolize version $lt_version found."
|
||||
echo " You need GNU libtoolize $want_lt_version or newer installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -304,4 +289,9 @@ fi
|
||||
# Finished successfully.
|
||||
#
|
||||
echo "buildconf: OK"
|
||||
|
||||
if test -f "test/buildconf"; then
|
||||
cd test && ./buildconf
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
Short: Asynchronous DNS resolver library (src)
|
||||
Author: Daniel Stenberg, Greg Hudson and others
|
||||
Uploader: Carsten Larsen (carsten larsen mail com)
|
||||
Type: dev/gcc
|
||||
Version: 1.12.0
|
||||
Architecture: generic
|
||||
URL: http://c-ares.haxx.se/
|
||||
|
||||
|
||||
ABOUT
|
||||
|
||||
Source code for c-ares asynchronous resolver library.
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
c-ares is 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.
|
||||
|
||||
BUGS
|
||||
|
||||
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.
|
||||
|
||||
c-ares is of course distributed under the same MIT-style license as the
|
||||
original ares.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user