Compare commits

...
515 Commits
Author SHA1 Message Date
Carsten Larsen cc6b8641c2 Updated documentation 2017-04-12 01:32:45 +02:00
Carsten Larsen 2811e30d49 Release 1.12.0 2017-04-12 01:21:06 +02:00
Clifford Marshall 55e2af978d Update README.md 2016-03-28 16:00:08 +02:00
rainlance 742f56907a AmigaOS changes 2016-03-05 09:59:40 +01:00
Viktor Szakats 0b7a497ab7 Makefile.m32: add support for CROSSPREFIX 2016-03-03 14:18:48 +00:00
Viktor Szakats ebe7b81453 Makefile.m32: add support for extra flags
Allow specification of CARES_{LD,C}FLAG_EXTRAS envvars
for mingw
2016-03-03 14:18:09 +00:00
David Drysdale 3b1ff9da74 test: Build with MinGW on AppVeyor 2016-03-03 13:57:45 +00:00
David Drysdale 23b9ad9ede test: avoid in6addr_* constants
These aren't available on MinGW, so use explicit addresses instead.
2016-03-03 13:57:16 +00:00
David Drysdale 6917640336 test: add missing #includes for dns-proto.cc 2016-03-03 13:57:16 +00:00
Gregor Jasny bf45d4c7c1 Fix man page typos detected by Lintian 2016-02-21 15:44:50 +00:00
Daniel Stenberg 10a1b7d509 configure: acknowledge --disable-tests
Fixes #44
2016-02-19 11:51:32 +01:00
Daniel Stenberg fab050fe94 AUTHORS: added contributors from the 1.11.0 release 2016-02-19 10:22:04 +01:00
Daniel Stenberg 3e897ff27e bump: start working on the next version 2016-02-19 10:18:29 +01:00
Daniel Stenberg e7fe2744db RELEASE-NOTES: final edits for 1.11.0 2016-02-19 10:07:50 +01:00
David Drysdale e41a39b022 ares_dup.3: remove mention of nonexistent function
ares_dup_options() doesn't exist, so don't document it.
2016-02-15 09:22:00 +00:00
David Drysdale 6549138e8b test: skip repeated build steps
Top-level buildconf/configure now triggers for the
test/ subdir too, so don't need to do explicitly.
2016-02-13 11:51:19 +00:00
David Drysdale f61151a091 test: namespaces unavailable when cross-compiling 2016-02-13 11:51:19 +00:00
Daniel Stenberg 63909b59a0 configure: only run configure in test when NOT cross-compiling
... as the tests won't run cross-compiled anyway
2016-02-13 11:40:00 +01:00
David Drysdale 5b46450af4 test: prefer ON_CALL to EXPECT_CALL to reduce flakes
For UDP tests, there's a chance of a retry.  EXPECT_CALL only
expects a single request to arrive at the server; ON_CALL allows
for a UDP retry and repeats the same answer.

Note that ON_CALL and EXPECT_CALL can't be mixed in the same
test, and that tests that have a varied sequence of responses
for the same repeated request still have to use EXPECT_CALL.
2016-02-13 10:07:19 +00:00
Daniel Stenberg f4fe7371fb configure: run configure in 'test' too
Having the test dir completely stand-alone causes too many issues for
users and devs. It still needs to be built specifically.
2016-02-13 10:58:51 +01:00
Daniel Stenberg 18eeb34989 configure: build silently by default 2016-02-13 10:57:38 +01:00
Daniel Stenberg 85c865e655 buildconf: run test/buildconf too if present 2016-02-13 10:56:55 +01:00
Daniel Stenberg f0d04b2909 test/configure: build silently by default 2016-02-13 10:56:28 +01:00
Gregor Jasny 8d023b7d96 dist: Distribute README.md
Closes #42
2016-02-13 10:35:31 +01:00
Daniel Stenberg 4ef6817c76 Makefile.am: distribute the test dir too 2016-02-11 15:09:13 +01:00
Daniel Stenberg 80bda0e9a0 RELEASE-NOTES: synced with 385582bd14 2016-02-11 14:49:48 +01:00
Nicolas \"Pixel\" Noble 385582bd14 ares_win32_init: make LoadLibrary work when using UNICODE too
Closes #17
2016-02-11 12:24:22 +01:00
David Drysdale 7e17c22b0f Use "resolve" as synonym of "dns" in nsswitch.conf
Modern Linux systems may have libnss_resolve from systemd as the
resolver, which is then configured in /etc/nsswitch.conf with
the "resolve" keyword rather than "dns".

Fixes #33
2016-02-11 11:14:40 +00:00
David Drysdale ed7df969cd ares_set_socket_callback: make manpage match code
The code in ares_process.c that invokes the socket creation/connection
callback only checks for rc < 0, not for standard ares error codes.
2016-02-11 11:14:27 +00:00
David Drysdale d8a0182af5 Merge pull request #36 from AGWA-forks/master
Add ares_set_socket_configure_callback()
2016-02-11 09:53:23 +00:00
David Drysdale 56cd98b9e4 test: Update init tests to match behaviour
Unreadable config files are now treated the same way
as absent config files.
2016-02-11 09:29:31 +00:00
Fedor Indutny e514088f96 Ignore fopen errors to use default values
After 46bb820be3 `init_by_resolv_conf`
errors are no longer swallowed in `ares_init_options`. This has exposed
a previously unknown bug in `lookups` initialization code.

If there is no lookup configuration in `resolv.conf`,
`init_by_resolv_conf` will attempt to read it from other files available
on the system. However, some of these files may have restricted
permissions (like `600`), which will lead to `EACCESS` errno, which in
turn is handled like a fatal error by `init_by_resolv_conf`.

However, it sounds illogical that this error should be handled as a
fatal. There is a `init_by_defaults` call that overrides `lookups` with
default value, and certainly possible absence of lookup information is
the reason why this function exists in a first place!

I suggest handling any `fopen` errors as non-fatal ones, allowing to
pick up the `lookups` value from different config files, or to pick up
default value.
2016-02-11 08:38:02 +00:00
Andrew Ayer 2b6a1fbee7 Document callback type in man page for ares_set_socket_callback 2016-02-09 10:08:23 -08:00
Andrew Ayer 11e37a92ef Add ares_set_socket_configure_callback()
This function sets a callback that is invoked after the socket is
created, but before the connection is established.  This is an ideal
time to customize various socket options.
2016-02-09 10:05:04 -08:00
David Drysdale 87d641a907 test: ares_set_socket_callback failure behaviour 2016-02-09 16:14:37 +00:00
David Drysdale 2bae2d56d7 test: Check ares_parse_txt_reply_ext() entrypoint 2016-02-04 10:09:22 +00:00
Fedor Indutny 53c2186e18 txt: introduce ares_parse_txt_reply_ext
Introduce `ares_txt_ext` structure with an extra `record_start`
field, which indicates a start of a new TXT record, thus allowing to
differentiate the chunks in the same record, from a chunks in a
different record.

Introduce a new API method: `ares_parse_txt_reply_ext` that works with
this kind of struct.
2016-02-04 10:00:59 +00:00
David Drysdale 0c4c1ca9bc doc: Update missed repo references 2016-02-02 11:33:16 +00:00
David Drysdale adc95e6bd6 doc: Update docs on contributing 2016-02-02 11:31:13 +00:00
David Drysdale 03ba16fe7a test: Run command line tools in Travis
Do a quick execution of each of the command line tools
in the continuous integration build, so that any (say)
sanitizer failures show up.
2016-02-02 11:02:28 +00:00
David Drysdale 3f301a6fe3 acountry: drop inert test
If ver_1 is true, then z0 and z1 must both be 'z', and so
(z0 != 'z' && z1 != 'z') can never be true.

CID 56879, pointed out by Coverity.
2016-02-02 10:56:54 +00:00
David Drysdale d4a549c78b doc: update badge locations to master repo 2016-02-02 10:48:15 +00:00
David Drysdale 6f1862f884 test: Enable maintainer mode + debug in Travis 2016-02-02 10:33:27 +00:00
David Drysdale 31ca57671e test: Add an iOS build target 2016-02-02 10:13:49 +00:00
David Drysdale c9579872c8 test: Ignore SIGPIPE in tests 2016-02-02 10:13:49 +00:00
David Drysdale 86beb81892 test: More initialization tests 2016-02-02 10:13:49 +00:00
David Drysdale ff1f7a1c3c test: Improve containerized test mechanism
Aim is to ensure that code coverage information can escape the
container.  To do this:
 - Enter a new mount namespace too, so that we can...
 - Bind mount the expected source directory into the container
 - Share memory with the sub-process so coverage information is
   shared too.
2016-02-02 10:13:49 +00:00
David Drysdale b644412a66 test: Make contained tests easier to write 2016-02-02 10:13:49 +00:00
David Drysdale 5dc450a4b3 test: Add framework for containerized testing
On Linux we can potentially use user and UTS namespaces to run  a test
in a pseudo-container with:
 - arbitrary filesystem (e.g. /etc/resolv.conf, /etc/nsswitch.conf, /etc/hosts)
 - arbitrary hostname/domainname.

Include a first pass at the framework code to allow this, along with a
first test case that uses the container.
2016-02-02 10:13:49 +00:00
David Drysdale 439eb45cc0 test: Use a longer timeout for less flakiness
Having occasional test failures from timeout before multiple
queries can complete, so up the default timeout for the test
from 100ms to 1500ms.
2016-02-02 10:13:49 +00:00
David Drysdale 78f9ec5515 test: Make failure tests more robust
Different platforms will do different numbers of allocations
in the processing of a given API call; just check that the
return code is either success or ENOMEM, and free off any
returned state in the former case.

Also cope with ECONNREFUSED as well as ENOTFOUND.
2016-02-02 10:13:48 +00:00
David Drysdale 3478963873 test: Get test code building under Windows
- Initial nmake file based off library nmake file
 - Cast socket call arguments to (char *)
 - Use wrapper sclose() that maps to closesocket() or close()
 - Build a config.h indicating presence of headers
 - Conditionally include netdb.h
 - Remove unnecessary include of sys/socket.h
 - Force longer bitmask for allocation failure tracking
 - Call WSAStartup() / WSACleanup() in main()
 - Set TCP_NODELAY for mock server
 - Turn on tests in AppVeyor build
2016-02-02 10:13:48 +00:00
David Drysdale 830e8fe2b3 test: Disable tests that manipulate env on Windows 2016-02-02 10:13:48 +00:00
David Drysdale d3bccff740 test: Move file lists into Makefile.inc
In preparation for a Win32 build of the test suite.
2016-02-02 10:13:48 +00:00
David Drysdale 9edf9411c7 test: Add a simple multi-server test
Check rotate option does something
2016-02-02 10:13:48 +00:00
David Drysdale d448d6604f test: Allow for multiple mock servers
- Update the MockServer to allow separate specification of
   UDP and TCP ports
 - Have an array of mock servers listening on consecutive
   sets of ports.
 - Rename Process(fd) to ProcessFD(fd) to avoid confusion.
 - Initialize channel by using the new ares_set_servers_ports()
   entrypoint, so multiple ports on the same loopback address
   can be used.
2016-02-02 10:13:48 +00:00
David Drysdale 92656bcc82 test: Update test for set/get_servers variants
Ports are significant in the _ports_ variant functions, so update test to cope.
2016-02-02 10:13:48 +00:00
David Drysdale 3231480a85 test: Make GetNameServers() utility function port-aware
Also make it generally available.
2016-02-02 10:13:48 +00:00
David Drysdale e26a678f26 test: more testing, including of internal static functions 2016-02-02 10:13:48 +00:00
David Drysdale 25adcc413e test: more tests, especially fallback processing
- Make mock server listen on UDP + TCP in parallel.
 - Test UDP->TCP fallback on truncation
 - Test EDNS->no-EDNS fallback
 - Test some environment init options
 - Test nonsense reply

test: short response
2016-02-02 10:13:48 +00:00
David Drysdale a05f240dea test: more tests, particularly of initialization 2016-02-02 10:13:48 +00:00
David Drysdale 83839fde7a test: Run mock tests over both TCP and UDP
With the exception of a few tests that make use of the timed
retry aspect of UDP.
2016-02-02 10:13:48 +00:00
David Drysdale 0c423efd78 test: Run mock tests over both IPv4 and IPv6 2016-02-02 10:13:48 +00:00
David Drysdale 0ef56333a0 test: Add more tests for edge cases 2016-02-02 10:13:48 +00:00
David Drysdale ce3f896572 test: more nooks and crannies of pton functions 2016-02-02 10:13:48 +00:00
David Drysdale f939efe7df test: More tests for PTR parsing 2016-02-02 10:13:48 +00:00
David Drysdale a2c5b1d378 test: Use of HOSTALIAS environment variable 2016-02-02 10:13:48 +00:00
David Drysdale 834c98e9d9 test: Add RAII utility classes for testing
- TempFile holds specific contents
 - EnvValue sets an environment variable
2016-02-02 10:13:48 +00:00
David Drysdale 693e566b66 test: More search domain scenarios 2016-02-02 10:13:47 +00:00
David Drysdale 3ce586feb7 test: Remove duplicate flags from Makefile.am 2016-02-02 10:13:47 +00:00
David Drysdale 6589ebfd6a test: Make test code leak-free 2016-02-02 10:13:47 +00:00
David Drysdale 4a09121923 test: More tests
- test use of sortlist
 - test gethostbyname(AF_UNSPEC)
2016-02-02 10:13:47 +00:00
David Drysdale f2ae5d72da test: Test ares_gethostbyname_file() 2016-02-02 10:13:47 +00:00
David Drysdale 0c03bee6ed test: Add more tests of ares_getnameinfo() 2016-02-02 10:13:47 +00:00
David Drysdale ffc7c52656 test: Tweak tests, add alloc failure test 2016-02-02 10:13:47 +00:00
David Drysdale e3434ef33f test: Test init with options 2016-02-02 10:13:47 +00:00
David Drysdale a48447ee27 test: More tests
- ares_inet_net_pton() variants
 - ares_getsock() variants
2016-02-02 10:13:47 +00:00
David Drysdale f9b9817d1d test: Expose ProcessWork() function 2016-02-02 10:13:47 +00:00
David Drysdale c778f0136b test: More parsing tests
Including:
 - Split each parse function test set out into separate files.
 - Add an allocation failure test for each parsing function.
 - Add error check test for each parsing function.
2016-02-02 10:13:47 +00:00
David Drysdale 79dc327a2d test: Add various additional tests 2016-02-02 10:13:47 +00:00
David Drysdale 5da3201a05 test: More tests
Include tests of internal functions, based on the value of the
CARES_SYMBOL_HIDING macro; need to configure the library with
--disable-symbol-hiding to enable these tests.
2016-02-02 10:13:47 +00:00
David Drysdale 3907b6dc68 test: Allow command line override of mock server port 2016-02-02 10:13:47 +00:00
David Drysdale 2aa07c7d02 test: Add README.md documentation 2016-02-02 10:13:47 +00:00
David Drysdale b651f825d6 test: Temporarily avoid latest Python requests package
Currently get error from Travis on this install step, and downgrading one
version appears to fix the problem.

"Could not find any downloads that satisfy the requirement pyOpenSSL>=0.13
(from requests[security])"
2016-02-02 10:13:47 +00:00
David Drysdale 72555b6cad test: Add AppVeyor config file for Windows build 2016-02-02 10:13:47 +00:00
David Drysdale 4a4f875c5a test: Add configuration for a Travis build
Cover Linux & OSX on the container infrastructure, but install
a later G++ to satisfy the tests' need for C++11.

Use a build matrix to include a variety of build variants:
 - ASAN
 - UBSAN
 - LSAN
 - Coverage via coveralls.io

test: invoke ASAN and coverage in Travis build

Also shift to use explicit build matrix

test: Use coveralls.io for coverage tracking

test: Add a build with UBSAN

Also expand and re-order the setting of environment variables
for easier modification.

test: Add LSAN build to Travis config
2016-02-02 10:13:47 +00:00
David Drysdale af3ee9a8ba test: Add initial unit tests for c-ares library
The tests are written in C++11, using the GoogleTest and GoogleMock
frameworks.  They have their own independent autoconf setup, so that
users of the library need not have a C++ compiler just to get c-ares
working (however, the test/configure.ac file does assume the use of
a shared top-level m4/ directory).  However, this autoconf setup has
only been tested on Linux and OSX so far.

Run with "./arestest", or "./arestest -v" to see extra debug info.
The GoogleTest options for running specific tests are also
available (e.g. "./arestest --gtest_filter=*Live*").

The tests are nowhere near complete yet (currently hitting around
60% coverage as reported by gcov), but they do include examples
of a few different styles of testing:

 - There are live tests (ares-test-live.cc), which assume that the
   current machine has a valid DNS setup and connection to the
   internet; these tests issue queries for real domains but don't
   particularly check what gets returned.  The tests will fail on
   an offline machine.

 - There a few mock tests (ares-test-mock.cc) that set up a fake DNS
   server and inject its port into the c-ares library configuration.
   These tests allow specific response messages to be crafted and
   injected, and so are likely to be used for many more tests in
   future.

    - To make this generation/injection easier, the dns-proto.h file
      includes C++ helper classes for building DNS packets.

 - Other library entrypoints that don't require network activity
   (e.g. ares_parse_*_reply) are tested directly.

 - There are few tests of library-internal functions that are not
   normally visible to API users (in ares-test-internal.cc).

 - A couple of the tests use a helper method of the test fixture to
   inject memory allocation failures, using the earlier change to the
   library to allow override of malloc/realloc/free.

 - There is also an entrypoint to allow Clang's libfuzzer to drive
   the packet parsing code in ares_parse_*_reply, together with a
   standalone wrapper for it (./aresfuzz) to allow use of afl-fuzz
   for further fuzz testing.
2016-02-02 10:13:46 +00:00
David Drysdale 148b6e93b9 test: Add local copy of GoogleMock/GoogleTest 1.7.0
Don't check in gtest/m4 files, as they are unused and interfere
with the top-level configure process.
2016-02-02 10:13:46 +00:00
David Drysdale 59b3f81ab4 doc: Show build badges in README.md
Note that these URLs will need to be updated if/when the test branch
gets pulled into the master repo/branch.
2016-02-02 10:13:46 +00:00
David Drysdale 5f59b88431 doc: Convert README to README.md
Gives better display on GitHub
2016-02-02 10:13:46 +00:00
David Drysdale b2dbc698ea doc: Update in preparation for next release
Assume 1.11.0 is next (as there are various API additions).
Also add myself to AUTHORS.
2016-02-02 10:13:46 +00:00
David Drysdale ce1ea79943 build: Allow header compilation by Windows C++ compiler 2016-02-02 10:13:46 +00:00
David Drysdale 8042524c70 build: Expose whether symbol hiding is on
Adding the CARES_SYMBOL_HIDING definition allows the test suite to
detect whether internal symbols are available or not.
2016-02-02 10:13:46 +00:00
David Drysdale ace90cce05 build: Add autoconf macros for C++11 code using pthreads
Pull in testing macros from the GNU autoconf archive to allow
configure scripts to test for and setup use of a C++11 compiler
(AX_CXX_COMPILE_STDCXX_11) and the pthreads library (AX_PTHREAD).

Note that these macros are not used by the main library autoconf,
just by the tests (which share the same m4/ directory).
2016-02-02 10:13:46 +00:00
David Drysdale 1b6905cc7f build: Add a code coverage option
Configure with:
  ./configure --enable-code-coverage
Show coverage output with:
  make code-coverage-capture

Built on m4/ax_code_coverage.m4 from the GNU autoconf archive
to provide the macros to check for presence of gcov + lcov;
upstream macro modified to:
 - Remove use of $(AM_DEFAULT_VERBOSITY) , as earlier versions of
   autoconf (such as the one used by default on Travis) do not have this.
 - Rather than automatically defining CODE_COVERAGE_RULES to be a set
   of makefile rules that use ifeq/endif (which is GNU make-specific),
   instead only define CODE_COVERAGE_RULES if coverages is turned on,
   and in that case don't use conditionals in the makefile.
2016-02-02 10:13:46 +00:00
David Drysdale 7972adc5d7 api: Add entrypoints to allow use of per-server ports
Add user-visible entrypoints ares_{get,set}_servers_ports(3), which
take struct ares_addr_port_node rather than struct ares_addr_node.
This structure includes a UDP and TCP port number; if this is set
to zero, the channel-wide port values are used as before.

Similarly, add a new ares_set_servers_ports_csv(3) entrypoint, which
is analogous to ares_set_servers(3) except it doesn't ignore any
specified port information; instead, any per-server specified port
is used as both the UDP and TCP port for that server.

The internal struct ares_addr is extended to hold the UDP/TCP ports,
stored in network order, with the convention that a value of zero
indicates that the channel-wide UDP/TCP port should be used.

For the internal implementation of ares_dup(3), shift to use the
_ports() version of the get/set functions, so port information is
transferred correctly to the new channel.

Update manpages, and add missing ares_set_servers_csv to the lists
while we're at it
2016-02-02 10:13:46 +00:00
David Drysdale 06d0f72e54 api: Add ares_set_sortlist(3) entrypoint
Allow explicit configuration of the channel's sortlist, by
specifying a string in the same format as the equivalent
/etc/resolv.conf option.

This allows library users to perform the same configuration
that is available via /etc/resolv.conf, but without needing
to change that file.
2016-02-02 10:05:07 +00:00
David Drysdale f1bcfa1122 api: Allow injection of user-specified malloc/free functions
Add a new ares_library_init_mem() initialization function for the
library which allows the library user to specify their own malloc,
realloc & free equivalents for use library-wide.

Store these function pointers in library-wide global variables,
defaulting to libc's malloc(), realloc() and free().

Change all calls to malloc, realloc and free to use the function pointer
instead.  Also ensure that ares_strdup() is always available
(even if the local environment includes strdup(3)), and change the
library code to always use it.

Convert calls to calloc() to use ares_malloc() + memset
2016-02-02 10:05:07 +00:00
David Drysdale d493e9b17c api: Add option to expose some internal functions
Purely for testing, add --enable-expose-statics option to configure
which converts some static internal functions to be externally visible.
2016-02-02 10:05:07 +00:00
David Drysdale b619d13693 api: Expose the ares_library_initialized() function 2016-02-02 10:05:07 +00:00
David Drysdale 4ad3111a49 ahost: Allow repeated -s <domain> options
This also removes a potential leak where later -s options would
replace earlier ones without freeing the relevant string.
2016-02-02 10:05:07 +00:00
David Drysdale 87ff25049c Mark unhittable lines
Add comments for the benefit of the lcov tool, marking
lines that cannot be hit.  Typically these are fall-back
protection arms that are already covered by earlier checks,
and so it's not worth taking out the unhittable code (in case
someone changes the code between the two places in future).
2016-02-02 10:05:07 +00:00
David Drysdale 35609ceb41 ares_set_servers_csv.3: make return type match code 2016-01-24 09:05:40 +00:00
David Drysdale e2c4b6f36c bitncmp: update comment to match code behaviour 2016-01-24 09:05:40 +00:00
David Drysdale de04975c48 ares_striendstr: fix so non-NULL return can happen
This looks to have been broken since it was first introduced in 2005 in
commit aba0b775ea ("Added ares_getnameinfo which mimics the
getnameinfo API")
2016-01-24 09:05:40 +00:00
David Drysdale 74ba881295 config_sortlist: free any existing sortlist on (re)alloc failure
If we get an allocation failure on 2nd or later entry in the sortlist, the
code would return ENOMEM but still leave the initial entries allocated.
Ensure that *sortlist is set to NULL whenever ENOMEM is returned.
2016-01-24 09:05:40 +00:00
David Drysdale 970dea47b7 ares_dup: clear new channel on failure
If the attempt to transfer IPv6 servers from the old to the new channel
fails, the previous code would still return a channel to the user even though
an error return code was generated.  This makes it likely that users would
leak the channel, so explicitly clear the channel in this case.
2016-01-24 09:05:40 +00:00
David Drysdale 46bb820be3 ares_init_options: don't lose init failure
If (say) init_by_options() fails, the subsequent call to 
init_by_defaults() was overwriting the return code with
success.  Still call init_by_defaults() regardless, but track
its return value separately
2016-01-24 09:05:40 +00:00
David Drysdale 52c9bc57bd ares_gethostbyname: don't leak valid-but-empty hostent
If an AF_UNSPEC query gets a valid response to its AAAA query,
but which has no IPv6 addresses in it, then the code chains on to
a A record query.  However, the hostent from the AAAA response
was being leaked along the way (because it gets replaced before
the follow-on end_hquery() invocation).
2016-01-24 09:05:40 +00:00
David Drysdale 6aabc42e5f ares_parse_txt_reply: propagate errors from per-substring loop
If we get an allocation failure when processing a particular substring in a
TXT record, that failure is silently lost; fix that by propagating errors from
the inner loop to the outer loop.
2016-01-24 09:05:40 +00:00
David Drysdale fa14ba7b11 process_answer: fix things up correctly when removing EDNS option
When a server rejects an EDNS-equipped request, we retry without
the EDNS option.  However, in TCP mode, the 2-byte length prefix was
being calculated wrong -- it was built from the answer length rather than
the length of the original request.

Also, it is theoretically possible that the call to realloc() might change
the data pointed to; to allow for this, qbuf also needs updating.

(Both these fixes were actually included in a patchset sent on the mailing
list in Oct 2012, but were included with other functional changes that
didn't get merged:
http://c-ares.haxx.se/mail/c-ares-archive-2012-10/0004.shtml)
2016-01-24 09:05:40 +00:00
David Drysdale 68a938e771 ares__read_line: clear buf pointer on realloc failure 2016-01-24 09:05:40 +00:00
David Drysdale 02e1f7f9af ares_expand_name: check for valid bits in label length
The top two bits of the label length indicate whether this is a
label length (00) or an index to a name elsewhere in the message
(11).  RFC1035 4.1.4 says that the other possible values for the
top two bits (01, 10) are reserved for future use.
2016-01-24 09:05:40 +00:00
Gregor Jasny 5e5b2f4239 Fix typos detected by lintian
Closes #32
2016-01-23 23:42:13 +01:00
Gregor Jasny a37863498f Distribute all man pages 2016-01-23 23:42:10 +01:00
Daniel Stenberg e4e40161f8 README.cares: s/I/Daniel
... and add a pointer to an existing version of the original area 1.1.1
package.a
2016-01-18 13:58:31 +01:00
Daniel Stenberg ab78ef369d read_tcp_data: don't try to use NULL pointer after malloc failure
CID 56884, pointed out by Coverity. We really should make this function
return an error code so that a malloc() failure can return back a major
failure.
2016-01-18 13:12:38 +01:00
Daniel Stenberg 51dae48ecf configure_socket: explicitly ignore return code
CID 56889 in Coverity pointed out the return code from setsocknonblock()
is ignored, and this added typecast to (void) makes it explicit.
2016-01-18 13:08:17 +01:00
Daniel Stenberg 48c0f703f6 ahost: check the select() return code
Fixes CID 137189, pointed out by Coverity
2016-01-18 13:04:48 +01:00
David Drysdale 250e7a20cc Fix buildconf on platforms using glibtoolize
Commit c49a87eea5 changed buildconf to only check for
libtoolize, but missed a line
2016-01-18 11:03:15 +00:00
David Drysdale 66f40230a0 Don't exit loop early leaving uninitialized entries
Update for commit affc63cba8.

The original patch from Gregor Jasny did not have the break
statement; I incorrectly added it to prevent continuing the loop.
However, the later entries in the array would then be left
uninitialized, causing problems for later cleanup.

So fix to match Gregor's original patch, with apologies.
2016-01-18 10:00:59 +00:00
Daniel Stenberg c49a87eea5 buildconf: remove check for libtool, it only requires libtoolize 2016-01-18 00:03:06 +01:00
Gregor Jasny affc63cba8 Use libresolv to initialize cares on iPhone targets
On iPhone targets like iOS, watchOS or tvOS the file
/etc/resolv.conf cannot be used to configure cares.

Instead the resolver library is queried for configuration
values.

CC: Yury Kirpichev <ykirpichev@yandex-team.ru>
2016-01-17 16:45:04 +00:00
Daniel Stenberg f945a0cfe3 README: updated to new repo URL 2016-01-17 16:31:35 +01:00
Lei Shi 52ecef76df Fixing slow DNS lookup issue
This patch is fixing the dns lookup issue due to dummy dns information
of a disconnected adapter(in my case is a bluetooth adapter). I changed
the dns lookup policy to try GetNetworkParams first because the
GetNetworkParams provides the most reliable dns information (lots of
checks were done by system). I also filter out inoperable adapter in
DNS_AdaptersAddresses in case GetNetworkParams fail.
2016-01-14 11:32:18 +00:00
David Drysdale fe34a70d6a Merge pull request #30 from p-push/vs-2015
Support Visual Studio 2015
2016-01-04 07:22:59 +00:00
Gisle Vanem 36ca36eedd Support Visual Studio 2015 2016-01-03 15:41:57 -05:00
Andrew Andkjar cbb466e813 added another version case to Makefile.msvc
nmake version 11.00.61030.0 resolves to CC_VERS_NUM = 110
2015-11-11 09:56:06 +00:00
David Drysdale ce3a0ee056 Merge pull request #26 from bitbouncer/vs-2013
added define for visual studio 2013
2015-09-16 10:51:30 +01:00
svante karlsson cac35ac5d8 added define for visual studio 2013 2015-06-25 10:32:03 +02:00
Jakub Hrozek bba4dc573f ares__read_line: free buf on realloc failure 2014-11-06 10:21:54 +01:00
Jakub Hrozek 453578354f Destroy options if ares_save_options fails
It's possible that, if ares_save_options failed, the opts structure
would contain some allocated memory. Calling ares_destroy_options in
this case is safe, because ares_save_options zeroes out the memory
initially.
2014-11-06 10:21:54 +01:00
David Drysdale a0b24beb95 Continue loop if space for hostname not large enough
When attempting to build a search domain from the local hostname
(used as a fallback when no other methods have given a search
domain), the code doubles the buffer size on each loop iteration.

However, the loop previously had a WHILE_FALSE terminator so the continue
statement exited the loop rather than going round again.
2014-11-06 10:14:08 +01:00
Daniel Stenberg 3d3ab03c6d ares_getnameinfo.3: there is no ares_getaddrinfo 2014-10-30 11:05:34 +01:00
Gregor Jasny 9456c39934 Prevent tmpbuf from overrunning
Fix Coverity error CID 56886.

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
2014-09-30 16:49:56 +01:00
Gregor Jasny 296ced3a0d Re-start loop if select fails
Fix Coverity error CID 56882

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
2014-09-30 16:49:55 +01:00
Gregor Jasny bd2c61353f Free temporary variable in error path
Fix Coverity CID 56890

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
2014-09-30 16:49:51 +01:00
Gregor Jasny 7db1afd38f Fix integer shift overflow if both tcp_socket and udp_socket are set
The problem occurs if at the start of the loop the sockindex is at the
last valid ARES_GETSOCK_MAXNUM position. If then both udp_socket and
tcp_socket are valid, sockindex gets incremented for UDP first and
points one entry behind the array for the tcp block.
So the fix is to check after every increment of sockindex if it is still
valid.

Fix Coverity error CID 56878

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
2014-09-30 16:49:49 +01:00
Gregor Jasny 13dc4800b2 Null check before dereference
Fix Coverity error CID 56880

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
2014-09-30 16:49:46 +01:00
Gisle Vanem 880ec44da9 Comment in ares_ipv6.h 2014-07-28 20:27:51 +02:00
David Drysdale ede0f84b8e CONTRIBUTING: add file to indicate mailing list is preferred 2014-07-25 09:28:46 +01:00
David Drysdale 2bc07b2e74 Add -t u option to ahost
Add an option to allow specification of the AF_UNSPEC
address family.
2014-07-24 16:39:13 +01:00
Jakub Hrozek c1fe47f6d9 host_callback: Fall back to AF_INET on searching with AF_UNSPEC
Previously, when an ares_gethostbyname() searched with AF_UNSPEC and the
first AF_INET6 call only returned CNAMEs, the host_callback never
retried AF_INET.

This patch makes sure than on ARES_SUCCESS, the result of AF_INET6 is
taken as authoritative only if the result contains some addresses.
2014-07-24 16:12:39 +02:00
David Drysdale 943e79f4bf Move memset call below platform-specific declarations
A GitHub commenter [1] says that my recent change to ahost.c has
problems compiling on Windows + C89 platforms.

[1]  https://github.com/bagder/c-ares/commit/ee22246507c9#commitcomment-6587616
2014-07-23 18:03:45 +02:00
David Drysdale 7aabbefab1 Update ahost man page to describe -s option.
Commit ee22246507 added the -s <domain> option to the
ahost command, but neglected to update the man page to
describe it.

Also fix typo in description of -t option.
2014-07-01 10:47:56 +02:00
Jakub Hrozek 09e64d7124 ares_parse_soa_reply: Do not leak rr_name on allocation failure
If ares_malloc_data failed, already allocated rr_name would go out of
scope.
2014-05-22 16:35:58 +02:00
David Drysdale 7df69c0f79 Don't override explicitly specified search domains
Only set search domains from /etc/resolv.conf if there isn't a value
already present in the channel.
2014-05-22 16:24:24 +02:00
David Drysdale ee22246507 Allow specification of search domain in ahost
Add the "-s domain" command line option to override the search
domains.
2014-05-22 16:21:56 +02:00
Daniel Stenberg 0004f498dc Revert "ares_parse_aaaa_reply: fix leak when reply contains 1 alias and no address"
This reverts commit 440110b303.
2014-05-12 20:00:36 +02:00
Frederic Germain 440110b303 ares_parse_aaaa_reply: fix leak when reply contains 1 alias and no address 2014-05-07 13:47:22 +02:00
Doug Kwan bc529dd0c2 ares_build.h: fix building on 64-bit powerpc
There are two issues.

1. gcc actually does not use __ppc__ and __ppc64__ but __PPC__ and
__PPC64__.  The tests of __ILP32__ and __LP64__ are sufficient for gcc.

2. clang defines __GNU__ and defines both __ppc64__ and __ppc__ when
targeting ppc64.  This makes CARES_SIZEOF_LONG to be 4 on a ppc64 system
when building with clang.

My patch is two change the order of the checks so that we check the
64-bit case first.
2014-02-16 22:54:45 +01:00
Daniel Stenberg d5d3871335 refresh: updated now with automake 1.14 2013-11-15 23:52:39 +01:00
David Drysdale 4aa1fc4163 single_domain: Invalid memory access for empty string input
We noticed a small buglet in ares_search() when it gets an empty string
as input -- the single_domain() utility function in ares_search.c
accesses invalid memory (before the start of the string).
2013-11-12 17:40:42 -08:00
Guenter Knauf c8ec633bf5 Fixed warning 'type specifier missing'. 2013-08-31 22:40:22 +02:00
Tor Arntsen 83ab208e83 ares_rules.h: CARES_SIZEOF_LONG doesn't exist anymore, don't test for it
It was removed in f19387dd72
2013-08-30 23:03:07 +02:00
Daniel Stenberg f19387dd72 nowarn: use <limits.h> instead of configure for size of long
This makes the header file much more multi-arch friendly and can be used
as-is with both 32 bit and 64 bit builds.
2013-08-27 13:36:41 +02:00
Daniel Stenberg efdd616118 timeoffset: made static and private
ares__timeoffset() was only used once within this single source file
2013-08-27 13:06:57 +02:00
Daniel Stenberg 30c9031afa timeadd: make static
ares__timeadd() was only ever used from within the same source
2013-08-27 13:02:35 +02:00
Yang Tse 742e234855 xc-am-iface.m4: comments refinement 2013-07-18 16:03:21 +02:00
Yang Tse 68b3c67e61 configure: fix 'subdir-objects' distclean related issue
See XC_AMEND_DISTCLEAN comments for details.
2013-07-18 04:20:31 +02:00
Yang Tse d69ae9c6f8 configure: automake 1.14 compatibility tweak (use XC_AUTOMAKE) 2013-07-09 00:10:38 +02:00
Yang Tse 9540d48184 xc-am-iface.m4: provide XC_AUTOMAKE macro 2013-07-09 00:07:27 +02:00
Daniel Stenberg f8a2354016 gitignore: ignore all ares_*pdf but also CHANGES.dist 2013-05-12 16:10:47 +02:00
Daniel Stenberg 1c948a70b1 bump: start working towards 1.10.1 2013-05-12 16:09:32 +02:00
Daniel Stenberg 46fa9cad79 RELEASE-NOTES: two more bug fixes 2013-05-12 15:35:42 +02:00
Keith Shaw 09be3edf3a ares_set_servers_csv: fixed IPv6 address parsing
Fixed bug that caused the last part of an IPv6 address to be parsed as
the port number when the last part is all numeric.
2013-05-12 15:23:43 +02:00
Daniel Stenberg 03e2fd085c nroff: fix two syntax mistakes
ares_parse_a_reply and ares_parse_aaaa_reply both had two \fB instead of
\fP

Reported-by: Alexander Klauer
Bug: http://c-ares.haxx.se/mail/c-ares-archive-2013-03/0010.shtml
2013-05-02 23:11:13 +02:00
Alex Loukissas df55bfac79 build: fix build on msvc11 2013-05-02 22:46:48 +02:00
Daniel Stenberg 3f0ec4733e Makefile.am: increment -version-info for 1.10.0 release 2013-04-23 16:44:56 +02:00
Daniel Stenberg 76ef032fd0 README: remove unnecessary comment 2013-04-23 00:33:24 +02:00
Daniel Stenberg 58a822231c ares_version.h: copyright end range year is now 2013 2013-04-23 00:32:51 +02:00
Daniel Stenberg c727dcb924 RELEASE-NOTES: synced with fb0737f3a0 2013-04-23 00:31:14 +02:00
Paul Saab fb0737f3a0 ares_parse_aaaa_reply: Plug memory leak
This change is similar to ares_parse_a_reply.c in commit
bffd67f16a
2013-04-22 23:54:40 +02:00
Patrick Valsecchi b5135bbc66 ares_parse_txt_reply: return a ares_txt_reply node for each sub-string
Previously, the function would wrongly return all substrings merged into
one.
2013-04-22 23:32:02 +02:00
Alexander Klauer 9a92b80191 library init: documentation update
This commit updates the documentation of ares_library_init() and
ares_library_cleanup() with regard to the newly introduced reference
counting of initializations and deinitializations.
2013-04-22 23:26:01 +02:00
Alexander Klauer 2e0c3076e5 library init: be recursive
Previously, a single call to ares_library_cleanup() would deinitialise
the c-ares library, regardless of how many times ares_library_init() was
called. This behaviour may cause problems in programs linking two or
more libraries which, in turn, use c-ares. The present commit fixes this
problem, deinitializing the library only after a number of calls to
ares_library_cleanup() matching the number of calls to
ares_library_init().
2013-04-22 23:24:50 +02:00
Patrick Valsecchi 148c8e0353 protocol parsing: check input data stricter
... so that bad length fields aren't blindly accepted

Bug: http://c-ares.haxx.se/mail/c-ares-archive-2013-04/0016.shtml
2013-04-15 22:28:01 +02:00
Guenter Knauf 2004a7a111 Create ares_build.h when buidling from Git. 2013-04-11 14:08:51 +02:00
Guenter Knauf c95041c6a1 Added -DCARES_STATICLIB to CFLAGS.
Currently this static makefile does only support building the
static library libcares.a.
2013-04-09 17:47:56 +02:00
Alexander Klauer 483d49d060 .gitignore: ignore patch files
This commit adds a line to .gitignore to the effect that patch files
generated by 'git format-patch' are excluded from the repository.
2013-04-08 22:16:48 +02:00
Alexander Klauer 1317a1c94b ares_destroy() documentation: no new requests
Clarify that no new requests may be added to a resolver channel that is
currently being destroyed.
2013-04-08 22:16:48 +02:00
Alexander Klauer fa19279bba Documentation: properly document ARES_ECANCELLED
This commit clarifies the behaviour of ares_cancel() with respect to
callbacks and adds missing documentation of ARES_ECANCELLED to the man
pages of the affected functions.
2013-04-08 22:16:48 +02:00
Alexander Klauer 54faf09da6 ares_cancel(): cancel requests safely
An invocation of ares_cancel() walks through the request list, calling
the callbacks of all pending requests on a channel. Previously, if such
a callback added a new request to the channel, the request list might
not end up empty, causing an abort by assertion failure. The present
commit ensures that precisely all requests present upon entry of
ares_cancel() are cancelled, and that adding new requests through
callbacks is safe.
2013-04-08 22:16:48 +02:00
Yang Tse 127d4cb357 ares.h: stricter CARES_EXTERN linkage decorations logic
No API change involved.
2013-03-10 21:28:35 +01:00
Yang Tse 8f3f059f33 ares_build.h.dist: enhance non-configure GCC ABI detection logic
GCC specific adjustments:

- check __ILP32__ before 32 and 64bit processor architectures in
  order to detect ILP32 programming model on 64 bit processors
  which, of course, also support LP64 programming model, when using
  gcc 4.7 or newer.

- keep 32bit processor architecture checks in order to support gcc
  versions older than 4.7 which don't define __ILP32__

- check __LP64__ for gcc 3.3 and newer, while keeping 64bit processor
  architecture checks for older versions which don't define __LP64__
2013-03-10 21:28:35 +01:00
Daniel Stenberg 57203b14df ares.h: there is no ares_free_soa function 2013-03-09 16:48:28 +01:00
Yang Tse a2881fee6b Makefile.am: empty AM_LDFLAGS definition for automake 1.7 compatibility 2013-03-09 13:58:35 +01:00
Yang Tse 60cad73007 ares_inet_ntop.3: s/socklen_t/ares_socklen_t 2013-03-08 14:13:21 +01:00
Yang Tse 715b499c79 configure: use XC_LIBTOOL for portability across libtool versions 2013-03-08 13:22:33 +01:00
Yang Tse f454e82dc7 xc-lt-iface.m4: provide XC_LIBTOOL macro 2013-03-08 13:22:31 +01:00
Yang Tse 320c4eb659 Makefile.am: use AM_CPPFLAGS instead of INCLUDES 2013-02-19 14:14:09 +01:00
Yang Tse 9ed49f3e17 inet_ntop.c: s/socklen_t/ares_socklen_t 2013-02-19 13:54:28 +01:00
Yang Tse b82874ad6f inet_ntop.c: s/socklen_t/ares_socklen_t for portability 2013-02-19 13:27:33 +01:00
Daniel Stenberg ecf6f65b43 ares.h: s/socklen_t/ares_socklen_t for portability 2013-02-19 13:00:36 +01:00
Daniel Stenberg f4dce2e9f0 ares_inet_ntop.3: 4th argument is socklen_t! 2013-02-17 19:18:54 +01:00
Daniel Stenberg 07bbbd85c3 spell inet correctly! 2013-02-17 17:51:37 +01:00
Daniel Stenberg cf7ad9758d ares_inet_pton/ntop: cleanup
Make sure that the symbols are always exported and present in c-ares.

Make the headers prefixed with 'ares'.

Removed the inet_ntop.h version as it no longer features any content.
2013-02-17 17:44:02 +01:00
Daniel Stenberg ee9a1c2457 ares_inet_ntop/ares_inet_pton: added man pages 2013-02-17 17:44:02 +01:00
Gisle Vanem 8d013420a0 curl_setup_once.h: definition of HAVE_CLOSE_S defines sclose() to close_s() 2013-02-15 02:36:20 +01:00
Gisle Vanem c28e6d98db config-dos.h: define HAVE_CLOSE_S for MSDOS/Watt-32 2013-02-15 02:36:19 +01:00
Gisle Vanem e9bca998f9 config-dos.h: define strerror() to strerror_s_() for High-C 2013-02-15 02:36:11 +01:00
Daniel Stenberg 050663271e ares_get_datatype: removed unused function
it was also wrongly named as internal functions require two underscores
2013-02-13 14:58:04 +01:00
Daniel Stenberg 2a3a63ae1f ares__bitncmp: use two underscores for private functions
It used a single one previously making it look like a public one
2013-02-13 14:58:04 +01:00
Daniel Stenberg 9c03cc118c ares__generate_new_id: moved to ares_query.c
... and ares__rc4 is turned into a local static function.
2013-02-13 14:58:04 +01:00
Daniel Stenberg 3217c7eef2 ares__swap_lists: make private and static
... since there's only one user, make it static within ares_process.c
2013-02-13 14:58:04 +01:00
Yang Tse be6e6984b5 Makefile.msvc: add four VS version strings 2013-02-13 13:03:44 +01:00
Daniel Stenberg df72bed2e3 ares_expand_name.3: clarify how to free the data 2013-02-13 11:01:50 +01:00
Yang Tse 75a8407985 zz40-xc-ovr.m4: fix 'wc' detection - follow-up 2
- Fix a pair of single quotes to double quotes.

URL: http://curl.haxx.se/mail/lib-2013-01/0355.html
Reported by: Tor Arntsen
2013-01-30 16:58:46 +01:00
Yang Tse b6dd41b6ef zz40-xc-ovr.m4: fix 'wc' detection - follow-up
- Take into account that 'wc' may return leading spaces and/or tabs.

- Set initial IFS to space, tab and newline.
2013-01-30 15:46:50 +01:00
Yang Tse 422717ba6f zz40-xc-ovr.m4: fix 'wc' detection
- Take into account that 'wc' may return leading spaces.

- Set internationalization behavior variables.

Tor Arntsen analyzed and reported the issue.

URL: http://curl.haxx.se/mail/lib-2013-01/0351.html
2013-01-30 12:25:53 +01:00
Yang Tse e03b5288ec zz40-xc-ovr.m4: check another three basic utilities 2013-01-29 20:49:16 +01:00
Yang Tse ddc7ab6713 zz40-xc-ovr.m4: 1.0 interface stabilization
- Stabilization results in 4 public interface m4 macros:
  XC_CONFIGURE_PREAMBLE
  XC_CONFIGURE_PREAMBLE_VER_MAJOR
  XC_CONFIGURE_PREAMBLE_VER_MINOR
  XC_CHECK_PATH_SEPARATOR
- Avoid one level of internal indirection
- Update comments
- Drop XC_OVR_ZZ40 macro
2013-01-28 21:28:42 +01:00
Yang Tse 18b7d9a9f4 zz40-xc-ovr.m4: emit witness message in configure BODY
This avoids witness message in output when running configure --help,
while sending the message to config.log for other configure runs.
2013-01-26 03:49:30 +01:00
Yang Tse e916c68de7 zz40-xc-ovr.m4: truly do version conditional overriding
- version conditional overriding
- catch unexpanded XC macros
- fix double words in comments
2013-01-25 19:20:28 +01:00
Yang Tse 0110c7f6ee zz40-xc-ovr.m4: fix variable assignment of subshell output bashism
Tor Arntsen analyzed and reported the issue.

URL: http://curl.haxx.se/mail/lib-2013-01/0306.html
2013-01-25 14:22:43 +01:00
Yang Tse 44635a5ec0 zz40-xc-ovr.m4: reinstate strict AC_REQUIRE macro dependencies 2013-01-25 12:21:47 +01:00
Yang Tse 186c57182e zz40-xc-ovr.m4: avoid double single-quote usage 2013-01-25 05:16:18 +01:00
Yang Tse b157f4a0be zz40-xc-ovr.m4: parentheses balancing of 'case' statements
m4 quadrigraph shell comment technique allows proper autoconf
parentheses balancing in shell 'case' statements. The presence
of unbalanced parentheses may otherwise trigger expansion bugs.
2013-01-25 00:46:58 +01:00
Yang Tse 15177a631e zz40-xc-ovr.m4: internals overhauling
- Update comments
- Execute commands in subshells
- Faster path separator check
- Fix missing 'test' command
- Rename private macros
- Minimize AC_REQUIRE usage
2013-01-24 20:39:08 +01:00
Yang Tse 971bdfedb2 zz40-xc-ovr.m4: redirect errors and warnings to stderr 2013-01-23 21:54:06 +01:00
Yang Tse 14e78ad68b configure: use XC_CONFIGURE_PREAMBLE early checks
Some basic checks we make were placed early enough in generated
configure script when using autoconf 2.5X versions. Newer autoconf
versions expand these checks much further into the configure script,
rendering them useless. Using XC_CONFIGURE_PREAMBLE fixes placement
of early intended checks across all our autoconf supported versions.
2013-01-23 18:20:33 +01:00
Yang Tse b74bcad714 zz40-xc-ovr.m4: provide XC_CONFIGURE_PREAMBLE macro 2013-01-23 18:20:22 +01:00
Yang Tse 037656b2d8 configure: autotools compatibility fixes - step I
Fix proper macro expansion order across autotools versions for
C compiler and preprocessor program checks.
2013-01-23 16:44:25 +01:00
Yang Tse dc6c864108 configure: fix automake 1.13 compatibility
Tested with:

buildconf: autoconf version 2.69
buildconf: autom4te version 2.69
buildconf: autoheader version 2.69
buildconf: automake version 1.13.1
buildconf: aclocal version 1.13.1
buildconf: libtool version 2.4
buildconf: GNU m4 version 1.4.16
2013-01-23 16:16:13 +01:00
Yang Tse 4718066ea4 ares_private.h: use again memdebug.h instead of curl_memdebug.h 2013-01-04 12:30:52 +01:00
Yang Tse a664066899 configure.ac: replace AM_CONFIG_HEADER with AC_CONFIG_HEADERS
automake 1.13 errors if AM_CONFIG_HEADER is used in configure script.
2013-01-01 19:27:30 +01:00
Yang Tse 70ac469a0c cares-override.m4: provide AC_CONFIG_MACRO_DIR definition conditionally
Provide a 'traceable' AC_CONFIG_MACRO_DIR definition only when using
an autoconf version that does not provide it, instead of what we were
doing up to now of providing and overriding AC_CONFIG_MACRO_DIR for
all autoconf versions.
2013-01-01 18:21:34 +01:00
Yang Tse 5b5066d6bc ares_private.h: use curl_memdebug.h instead of memdebug.h 2012-12-28 20:18:14 +01:00
Yang Tse a056480169 vc6cares.dsp: add ares_create_query.c and ares_parse_soa_reply.c 2012-12-18 13:54:27 +01:00
Yang Tse b214c21cf6 cares-functions.m4: improve gethostname arg 2 data type check 2012-12-17 16:32:24 +01:00
Yang Tse c220b29b3c setup_once.h: HP-UX specific 'bool', 'false' and 'true' definitions.
Also reverts commit bceb40095a
2012-12-17 02:09:22 +01:00
Yang Tse 84eb2dc220 configure: check if compiler halts on function prototype mismatch 2012-12-16 18:50:58 +01:00
Yang Tse 9da14a847f cares-functions.m4: add gethostname arg 2 data type check and definition 2012-12-15 17:46:49 +01:00
Yang Tse a28e44c344 cares-functions.m4: update thread-safeness detection of getaddrinfo()
Take in account that POSIX standard Issue 7 drops h_errno support. Now, we also
consider getaddrinfo() to be thread-safe when (_POSIX_C_SOURCE >= 200809L) or
(_XOPEN_SOURCE >= 700) independently of whether h_errno exists or not.

Take in account that h_errno might be a modifiable lvalue not defined as
a C preprocessor macro.
2012-12-15 17:36:09 +01:00
Yang Tse 4ed0fc2d44 setup_once.h: HP-UX <sys/socket.h> issue workaround
Issue: When building a 32bit target with large file support HP-UX
<sys/socket.h> header file may simultaneously provide two different
sets of declarations for sendfile and sendpath functions, one with
static and another with external linkage. Given that we do not use
mentioned functions we really don't care which linkage is the
appropriate one, but on the other hand, the double declaration emmits
warnings when using the HP-UX compiler and errors when using modern
gcc versions resulting in fatal compilation errors.

Mentioned issue is now fixed as long as we don't use sendfile nor
sendpath functions.
2012-12-14 19:39:21 +01:00
Yang Tse 0c677f578e setup_once.h: refactor inclusion of <unistd.h> and <sys/socket.h>
Inclusion of these two header files now done in setup_once.h
2012-12-14 18:36:59 +01:00
Yang Tse a1035276c1 Header inclusion clean-up
Remove header inclusions already done in setup_once.h
2012-12-14 18:25:56 +01:00
Yang Tse bceb40095a setup_once.h: HP-UX specific TRUE and FALSE definitions
Some HP-UX system headers require TRUE defined to 1 and FALSE to 0.
2012-12-12 16:39:07 +01:00
Yang Tse 98b52964cf ares_timeout.c: fix compiler warning 2012-12-10 16:12:49 +01:00
Yang Tse 93a09eabeb ares_create_query.c: IRIX compilation fix 2012-11-23 14:28:37 +01:00
Yang Tse a5ce39391c c-ares/nameser.h: add some T_* defines for ns_t_* values 2012-11-23 14:23:34 +01:00
Daniel Stenberg 1e4f2d28fc Revert "ares_parse_aaaa_reply: fix memory leak"
This reverts commit 50f25d8a4b.
2012-11-07 22:54:50 +01:00
Daniel Stenberg 50f25d8a4b ares_parse_aaaa_reply: fix memory leak
an allocated buffer was not freed in the successful case.
2012-10-02 22:36:05 +02:00
Gisle Vanem 805c736e36 adig: perror() doesn't work for socket errors on windows
... so print the SOCKERRNO instead
2012-08-24 23:17:26 +02:00
Daniel Stenberg 65ac7e706d get_DNS_AdaptersAddresses: fix IPv6 parsing
Use of the wrong define made the function not parse IPv6 addresses
properly.

Bug: http://c-ares.haxx.se/mail/c-ares-archive-2012-06/0028.shtml
Reported by: Saúl Ibarra Corretgé
2012-08-23 00:11:30 +02:00
Daniel Stenberg 2b897074cb version: bumped to 1.10.0
Due to the newly added function: ares_create_query()
2012-08-21 23:00:25 +02:00
Daniel Stenberg a1314e492d AUTHORS: synced with 83093ac450
Added 21 authors since this document was last updated
2012-08-21 22:59:05 +02:00
Daniel Stenberg 83093ac450 ares_create_query.3: mention when this is added 2012-08-17 23:14:24 +02:00
hpopescu@ixiacom.com 90364defb0 Added new feature (rfc2671) 2012-08-17 00:54:47 +02:00
Daniel Stenberg e447bc5c60 code police: fix indents, < 80 columns, reflowed comments 2012-07-26 20:03:20 +02:00
Guenter Knauf 8283fb15e6 Cleaned up version awk script. 2012-07-11 23:40:20 +02:00
Gisle Vanem 4d91235900 read_udp_packets: bail out loop on bad sockets
I can see that recvfrom() in ares_process.c many times is called with
'udp_socket' == ARES_SOCKET_BAD. The code takes care not to call
recv/recvfrom with ARES_SOCKET_BAD in the outer-loop. So should the
inner-loop.
2012-06-30 23:44:00 +02:00
Yang Tse 54751f4d33 cares-compilers.m4: remove -Wstrict-aliasing=3 from clang
Currently it is unknown if there is any version of clang that
actually supports -Wstrict-aliasing. What is known is that there
are several that don't support it.
2012-06-29 16:40:29 +02:00
Yang Tse bc0c3c62cc cares-compilers.m4: -Wstrict-aliasing=3 for warning enabled gcc and clang builds 2012-06-26 21:24:08 +02:00
Daniel Stenberg a85ba35816 version: work towards 1.9.2 (at least) 2012-06-18 23:43:21 +02:00
Daniel Stenberg b743f875d3 RELEASE-NOTES: 1.9.1 coming up 2012-06-18 22:23:58 +02:00
Daniel Stenberg 3b649328be ares_version.h: next version is 1.9.0 2012-06-16 23:17:57 +02:00
Marko Kreen 6e44d64429 ares_data.h: ARES_DATATYPE_SOA_REPLY is added in 1.9.0 2012-06-16 23:12:04 +02:00
Daniel Stenberg cc067c21fe RELEASE-NOTES: synced with 979bf951d
Next release deemed to become 1.9.0 due to the new function
2012-06-15 13:40:37 +02:00
Marko Kreen 979bf951d3 SOA parser added
I need to do SOA queries, so here is a parser for them.

- ares_soa_reply: new struct
- ares_malloc_data/ares_free_soa: ARES_DATATYPE_SOA_REPLY
- ares_parse_soa_reply: actual function
2012-06-15 13:32:48 +02:00
Yang Tse 38b69b7269 Kill compiler warning 2012-06-14 21:19:48 +02:00
Yang Tse 1972aad19e Fix libcares.pc generation for static MingW* cross builds 2012-05-25 23:59:28 +02:00
Nick Alcock 9bd38a4a6e Fix UDP and TCP port byte order in saved options.
The UDP and TCP port are stored in network byte order in the
ares_channeldata, but are passed in to ares_init_options() in host byte
order.  Thus we must return them from ares_save_options() in host byte
order too, or a duplicated channel will convert them again, leading to a
nonfunctional channel and a mysterious connection refused error from
ares_gethostbyname().  This breaks ares_dup(), thus the curl easy API
when c-ares is used by curl, and thus all the curl easy API's users.
2012-05-21 22:40:45 +02:00
Yang Tse 7ec5e8e656 version: start working on 1.8.1-DEV 2012-04-28 11:45:01 +02:00
Daniel Stenberg f037316e4b RELEASE-NOTES: call next 1.8 instead
Since we added a function, let's use a stricter bumping scheme
2012-04-27 22:04:41 +02:00
Yang Tse 88d6dfb3d4 INSTALL: some adjustments 2012-04-25 17:56:00 +02:00
Daniel Stenberg d9ff559036 GIT-INFO: mention buildconf 2012-04-25 17:00:09 +02:00
Yang Tse 82a1c1c989 INSTALL: remove more sections that don't apply to c-ares 2012-04-25 16:38:18 +02:00
Yang Tse 38a9933a6d ares_timeout.c: fix compiler warning 2012-04-25 15:49:26 +02:00
Ben Noordhuis f7b66af200 Makefile.m32: fix mingw32 build
* add . to include path so ares_build.h is picked up
* make ar configurable to ease cross-compiling
2012-04-25 14:42:21 +02:00
Daniel Stenberg 031040f893 RELEASE-NOTES: added what's happened since 1.7.5 2012-04-22 17:29:34 +02:00
Guenter Knauf 28354d9ad2 Updated copyright year. 2012-04-22 13:09:39 +02:00
Yang Tse 7ce8fe781a ares_init.c: Further refactoring of Windows system's DNS fetching code 2012-04-21 14:17:44 +02:00
Guenter Knauf 05346c25cb Android: small changes to dns property part.
Prefix prop vars; kill var; use DNS_PROP_NAME_PREFIX macro.
2012-04-20 20:42:41 +02:00
Guenter Knauf b3afe9cbde Handle CNAME-only in ares_parse_aaaa_reply().
posted to the c-ares list by Peter Griess <pg@std.in>.
2012-04-19 19:27:02 +02:00
Guenter Knauf 2c67ce6459 Add support for multiple DNS servers on Android.
Before, c-ares always used the first DNS server on Android, causing
network problems if this DNS server was not available.

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
2012-04-19 19:16:27 +02:00
Guenter Knauf 80de4a7295 Added INSTALL so it gets into tarballs. 2012-04-19 10:05:03 +02:00
Guenter Knauf 5e80852e4c Added some more ifdefs to silent compiler warnings. 2012-04-17 16:57:40 +02:00
Yang Tse 017132bf43 INSTALL: remove a non c-ares section 2012-04-17 13:53:08 +02:00
Yang Tse 2c77c33daa cares-compilers.m4: -Wno-pedantic-ms-format for Windows gcc 4.5 builds
When building a Windows target with gcc 4.5 or newer and strict compiler
warnings enabled use -Wno-pedantic-ms-format in addition to other flags.
2012-04-17 13:30:02 +02:00
Yang Tse 81db5a00e4 setup_once.h: tighten requirements for stdbool.h header inclusion
Include stdbool.h only when it is available and configure is capable of
detecting a proper 'bool' data type when the header is included.
2012-04-17 13:30:01 +02:00
Yang Tse cb71b6bd5a configure: NATIVE_WINDOWS no longer defined in config file 2012-04-17 13:30:00 +02:00
Yang Tse f6b4cacfae cares-compilers.m4: double underscore decoration for visibility attribute 2012-04-17 13:30:00 +02:00
Yang Tse fc2c91c206 build adjustments: CARES_SYMBOL_HIDING no longer defined in config files
configure script now provides conditional definitions for Makefile.am
that result in CARES_SYMBOL_HIDING being defined by resulting makefiles
when appropriate.
2012-04-17 13:29:59 +02:00
Yang Tse 41191cdd54 configure: Windows cross-compilation fixes
CARES_BUILDING_LIBRARY and CARES_STATICLIB no longer defined in ares_config.h,
configure will generate appropriate conditionals so that mentioned symbols
get defined and used in Makefile derived from Makefile.am at compilation time.
2012-04-17 13:29:58 +02:00
Guenter Knauf 7e2f70a08c Added INSTALL file adapted from libcurl.
Not yet ready, and needs further edits.
2012-04-17 09:35:41 +02:00
Yang Tse 4980cc99e2 ares_init.c: get_iphlpapi_dns_info() refactoring 2012-04-16 22:10:23 +02:00
Guenter Knauf 8b79584e01 Kill some more compiler warnings. 2012-04-16 15:33:14 +02:00
Guenter Knauf 27a478c7a3 Kill compiler warning about unused var. 2012-04-16 15:24:14 +02:00
Guenter Knauf 58e62c5879 Fixed my last commit: wrong preprocessor directive. 2012-04-16 11:27:16 +02:00
Guenter Knauf 7d3f341156 Check for __ANDROID__ in addition to ANDROID macro. 2012-04-16 10:34:05 +02:00
Guenter Knauf 995fa144d9 Check for __ANDROID__ in addition to ANDROID macro.
Posted to c-ares list by Wayne.
2012-04-16 10:19:07 +02:00
Guenter Knauf 0d6ef42b5f Fix for Android to disable useless arpa/nameser.h. 2012-04-14 13:30:29 +02:00
Guenter Knauf 4ef145cede Fix for Android to include sys/select.h for fd_set. 2012-04-14 12:27:08 +02:00
Yang Tse 41f8ff5070 ares_data.c: some NAPTR related fixes 2012-03-17 02:45:03 +01:00
Daniel Stenberg 506d586276 port numbers: convert them to network order!
When the config options ARES_OPT_UDP_PORT or ARES_OPT_TCP_PORT are used,
make sure to convert them to network byte order!

Bug: http://c-ares.haxx.se/mail/c-ares-archive-2012-02/0004.shtml
2012-03-16 16:06:03 +01:00
Daniel Stenberg 1c26242c52 white space cleanup
- Keep code within 80 columns

- Removed funny spaces after open paren and before closing paren
2012-02-25 22:36:50 +01:00
Poul Thomas Lomholt 73dc26a9fc get_iphlpapi_dns_info: fix buffer overrun
I experienced a buffer overrun exception in c-ares on Windows and
tracked it down to be an error in the calculation of the 'left' variable
in get_iphlpapi_dns_info().

I changed the variable type of 'left' to a _signed_ type because of the
subtraction arithmetic; not sure if a long is the best choice
2012-02-25 22:32:24 +01:00
Daniel Stenberg 90a150f045 Merge pull request #7 from saghul/naptr
Added support for parsing NAPTR records
2012-02-24 13:18:26 -08:00
saghul 6bab0393c4 Added support for parsing NAPTR records 2012-02-23 23:15:07 +01:00
Yang Tse 4ab65461b6 ares_init.c: fix compiler warning on winsock builds 2012-01-19 20:20:56 +01:00
Yang Tse f1a1df1e6c configure: libtool 1.5 tweaks 2011-12-20 14:02:57 +01:00
Daniel Stenberg 6ae9e71df4 ares_timeout.3: fix the NAME section
It was clearly a copy n' paste error
2011-12-19 22:58:22 +01:00
Albert Chin f394cd55c8 configure - m4: make CURL_CHECK_DEF ignore leading whitespace on symbol def
When using Sun C compiler the preprocessor somehow inserts an extra space
in front of replaced symbol, breaking CURL_CHECK_DEF macro. To workaround
this, macro CURL_CHECK_DEF now ignores all leading whitespace in front of
symbol substitution result.
2011-09-27 21:59:27 +02:00
Yang Tse 3d84eb3bbc ares_init.c: fix segfault triggered in ares_init_options() upon previous
failure of init_by_defaults() and incomplete cleanup there.
2011-09-07 00:30:53 +02:00
Yang Tse 66e91438c5 ares_process.c: fix compiler warning 2011-09-06 02:20:43 +02:00
Yang Tse a831da792d fix MSVC compiler warning 'conditional expression is constant' 2011-09-04 17:23:39 +02:00
Yang Tse bab721cb1c setup_once.h cleanup and sync 2011-09-04 17:09:36 +02:00
Denis Bilenko 1f8f14d21e ares_getnameinfo: fix random results with c-ares 1.7.5
In ares_getnameinfo memcpy did not copy enough bytes, causing
it to return arbitrary memory contents as a result.
2011-08-24 18:37:11 +02:00
Yang Tse c8d8ca2606 warnings: fix another 'conversion may lose significant bits' compiler warning 2011-08-21 19:56:06 +02:00
Yang Tse 1089cf6052 ares_dns.h: adjust DNS__16BIT and DNS__32BIT macro definitions
Fixing compiler warnings existing definitions triggered on these.
2011-08-21 19:18:53 +02:00
Yang Tse b816675c0f ares_destroy.c: fix segfault in ares_destroy_options() 2011-08-21 16:42:44 +02:00
Daniel Stenberg d0c3cb6840 ares_parse_srv_reply: silence compiler warnings
... by adding ugly typecasts.
2011-08-21 15:43:36 +02:00
Daniel Stenberg 2d9a5acff5 CHANGES: generate from script
The CHANGES file is now generated automatically with 'git2changes.pl',
invoked by the maketgz script which is used to build release archives.

The former human edited CHANGES file was renamed to CHANGES.0 in git.
2011-08-21 15:40:14 +02:00
Yang Tse 440b5d488a Makefile.netware: SIZEOF_SHORT definition 2011-08-21 01:59:14 +02:00
Yang Tse 14eb79f660 warnings: fix some 'conversion may lose significant bits' compiler warnings 2011-08-20 23:05:14 +02:00
Yang Tse 34d5d76969 configure: fix symbol hiding usability check
A more thorough test is done now in order to determine visibility attribute
usability, given that some compilers don't support visibility attribute on
all configurations.
2011-08-20 20:11:00 +02:00
Daniel Stenberg f11c2c2891 1.7.6: start working... 2011-08-16 23:02:39 +02:00
Daniel Stenberg 622313ab3b CHANGES: synced for 1.7.5 release 2011-08-16 22:41:44 +02:00
Daniel Stenberg c4d3cb8c3a RELEASE-NOTES: synced with bb4096effe 2011-08-16 22:32:41 +02:00
Jakub Hrozek bb4096effe Only fall back to AF_INET searches when looking for AF_UNSPEC addresses 2011-08-15 13:34:20 +02:00
Gisle Vanem 1b9c2a3ea3 ares_iphlpapi.h: Watcom C fix
Added "!defined(_WS2DEF_)" since Watcom doesn't have
  a per type guard for the typedefs 'CSADDR_INFO' (that MingW has) or
  'SOCKET_ADDRESS' (that MSVC has). But we can use the header-guard for
  <ws2def.h> instead.
2011-08-10 03:31:39 +02:00
Gisle Vanem 5da497e0e8 Makefile.Watcom:
* The 'NTDDI_VERSION' needs to be raised to 0x05010000
    in order for SOCKADDR_STORAGE etc. to be typedefed.
  * Replaced '-dUSE_WATT32' with '-dWATT32'.
  * Added $(DEMOS) to the 'all' target and removed the 'demos'
    target to be consistent with e.g. Makefile.msvc etc.
  * 'ENABLE_IPV6' is no longer used. Hence removed the '%use_ipv6' construct.
  * object-file order seems to be important (Watcom v.19). Hence
    'ares_getopt.obj' must be put after the .obj that references getopt().
2011-08-10 03:29:02 +02:00
Yang Tse a94b4e53d1 cares-compilers.m4: CARES_CONVERT_INCLUDE_TO_ISYSTEM adjustments
Add CARES_CHECK_COMPILER as a requirement.

Ensure macro does nothing unless GNU_C or CLANG compiler is used.

This should allow usage of this macro in unforeseen placements.
2011-08-08 18:33:05 +02:00
Yang Tse a8f62e82bf config-win32.h: comments adjustments - followup 2011-08-06 19:25:21 +02:00
Yang Tse 3d7af9782e config-win32.h: comments adjustments 2011-08-06 19:18:16 +02:00
Tom Hughes bffd67f16a ares_parse_a_reply: fix memleak 2011-08-05 23:22:26 +02:00
Yang Tse f2ea96b1b7 cares-functions.m4 serial # bump 2011-07-29 20:31:56 +02:00
Yang Tse 2039e81e45 Revert "configure: additional flag checks for fcntl() and socket()"
This reverts commit 5f2a3b0e48.
2011-07-29 20:20:44 +02:00
Yang Tse 5f2a3b0e48 configure: additional flag checks for fcntl() and socket() 2011-07-29 18:25:34 +02:00
Yang Tse 08e721e004 xc-translit.m4 fix quoting 2011-06-21 00:06:00 +02:00
Yang Tse 88d314548e configure: avoid direct usage of AS_TR_* macros 2011-06-17 21:01:40 +02:00
Yang Tse 4701b0c47a xc-translit.m4 provides transliteration macros with well defined behavior. 2011-06-17 20:59:58 +02:00
Jakub Hrozek 159b82c056 Revert "Only fall back to AF_INET searches when looking for AF_UNSPEC addresses"
This reverts commit b5823d6570.

This patch was not reviewed properly before pushing
2011-06-15 10:56:05 +02:00
Jakub Hrozek ce03c818f4 Revert "Do not use sized constants in public headers"
This reverts commit 22c01e96f7.

This is a Red Hat specific patch that does not belong into upstream
2011-06-15 10:55:29 +02:00
Jakub Hrozek 22c527cc87 Use correct sizeof in ares_getnameinfo() 2011-06-14 19:04:23 +02:00
Jakub Hrozek 09f8a05573 Do not leak rr_name on failures inside ares_parse_ptr_reply 2011-06-14 16:52:32 +02:00
Jakub Hrozek a1116723d4 Do not leak rr_name on failures inside ares_parse_a_reply 2011-06-14 16:48:26 +02:00
Jakub Hrozek 18b6d475dc Do not leak rr_name on failures inside ares_parse_aaaa_reply 2011-06-14 16:46:13 +02:00
Jakub Hrozek 978a929b40 Do not leak rr_name on failures inside ares_parse_ns_reply 2011-06-14 16:41:29 +02:00
Jakub Hrozek 8e457f2c41 Fix incorrect sizeof() in ares_save_options 2011-06-14 16:41:29 +02:00
Jakub Hrozek 654733a399 Fix incorrect allocation in ares_parse_ptr_reply() 2011-06-14 16:41:29 +02:00
Jakub Hrozek b5823d6570 Only fall back to AF_INET searches when looking for AF_UNSPEC addresses 2011-06-14 16:41:29 +02:00
Jakub Hrozek 22c01e96f7 Do not use sized constants in public headers 2011-06-14 16:41:29 +02:00
Jakub Hrozek adf75c56c4 ares_free_hostent(NULL) should be a noop 2011-06-13 22:47:35 +02:00
Yang Tse e67edcd18d configure: fix recvfrom 5th arg type qualifier detection (followup) 2011-06-08 15:55:48 +02:00
Yang Tse 700b928544 configure: fix recvfrom 5th arg type qualifier detection
Additionally remove whitespace from EOL
2011-06-08 13:38:10 +02:00
Daniel Stenberg 3cb1afe054 strlen: use size_t to receive the return 2011-06-04 20:14:38 +02:00
Yang Tse 45ec020795 xlc: avoid preprocessor definition usage when linking 2011-06-04 04:26:40 +02:00
Yang Tse f9b24e590c ares_nowarn: icc 9.1 workaround 2011-06-01 12:13:05 +02:00
Yang Tse 56c77364d5 ares_nowarn: header inclusion fix 2011-05-27 06:55:50 +02:00
Yang Tse 22a52102d6 ares_init: make ares_private.h last included header again 2011-05-26 17:32:43 +02:00
Yang Tse f413fce823 compiler warning: fix
Fix compiler warning: conversion may lose significant bits
2011-05-26 16:06:40 +02:00
Yang Tse 5ef8f5ead2 compiler warning: fix
Fix compiler warning: variable was set but never used

Fix compiler warning: clobber ignored
2011-05-25 11:19:10 +02:00
Yang Tse e1c9539962 ares_iphlpapi: fix compiler warnings 2011-05-21 03:53:32 +02:00
Yang Tse ef5390e6bb winsock: compilation fixes
Provide winsock iphlpapi alternative definitions to prevent compilation
failures when using a variety of winsock header implementations.
2011-05-20 16:43:25 +02:00
David Stuart 6518b56a5e IPv6-on-windows: find DNS servers correctly 2011-05-17 11:53:13 +02:00
Daniel Stenberg d60f07d094 man pages: docs for the c-ares utility programs 2011-05-09 11:47:43 +02:00
Daniel Stenberg a268ae6a78 ares_parse_ns_reply.c: remove CVSism 2011-04-30 00:17:03 +02:00
Yang Tse 8520a37f62 build: fix header inclusion 2011-03-27 10:37:03 +02:00
Yang Tse 74f1bd8c22 getservbyport replacement for Win CE 2011-03-27 04:27:49 +02:00
Yang Tse 5e5c0132e6 renamed getplatform() to ares__getplatform() to avoid namespace pollution 2011-03-25 17:57:02 +01:00
Yang Tse e49ce8f973 configure: fix libtool warning
Recent versions of libtool are now tracing usage of AC_CONFIG_MACRO_DIR
macro and warn heavily when not used in configure script along with
ACLOCAL_AMFLAGS in Makefile.am.  So in order to make libtool happy
while keeping backwards compatibility this is added.
2011-03-25 13:13:55 +01:00
Yang Tse 2c2e2d839e adig: RFC4034 resource record type detection
Can be tested with: adig -s 8.8.8.8 -t ANY example.com
2011-03-24 20:25:49 +01:00
Yang Tse ebc9a9d958 nameser.h: RFC4034 resource record type definitions 2011-03-24 20:24:42 +01:00
Yang Tse 5b6a188909 build: move platform stuff to ares_platform.c and ares_platform.h 2011-03-24 11:31:50 +01:00
Yang Tse bd066ab8ef build: find out windows platform using GetVersionEx() 2011-03-23 20:53:28 +01:00
Yang Tse 822fd0f877 build: use getenv() replacement function for systems which lack it 2011-03-23 13:44:42 +01:00
Yang Tse 3abad87d88 setup_once: system error codes for Windows CE 2011-03-22 20:51:15 +01:00
Yang Tse c7ce7c7d45 ares_search: use ERRNO macro for portability sake 2011-03-22 20:50:42 +01:00
Yang Tse 9099a9eb0c System's errno.h inclusion cleanup follow-up.
System's errno.h is conditionally included from setup_once.h
2011-03-22 17:19:37 +01:00
Yang Tse d81cae7a67 Windows CE specific adjustment
All versions of Windows CE support Winsock 1.1
2011-03-22 14:28:47 +01:00
Yang Tse 8c503ddf79 System's errno.h inclusion cleanup.
System's errno.h is conditionally included from setup_once.h
2011-03-22 14:02:23 +01:00
Yang Tse ef8e2ad601 ares_init: fix gethostname error detection on winsock platforms 2011-03-22 13:43:34 +01:00
Yang Tse cd753ffe14 configure: r-enable temporarily disabled detection of system's inet_ntop()
Detection was temporarily disabled in commit 674e044ccb
2011-03-22 12:56:30 +01:00
Daniel Stenberg 1bd524dd4a configure: stop using the deprecated AM_INIT_AUTOMAKE syntax 2011-03-15 11:29:12 +01:00
Gisle Vanem 0f226fb8e4 Watt-32: use errno
Make sure Watt-32 programs use 'errno' even on Win32 targets
2011-03-15 11:29:12 +01:00
Guenter Knauf ffb7697ac8 Removed commented CLFAGS no longer needed. 2011-02-18 19:58:09 +01:00
Guenter Knauf 6e3e66dc5c Fixed CFLAGS for NetWare.
Added -m32 to enable compilation with x86_64 compilers;
added conditional to set -fpcc-struct-return only for gcc compiler.
2011-02-18 19:03:50 +01:00
Gisle Vanem 9a11973403 Watt32: fix server init
Somewhere in the process, programs using the Watt-32 tcp/ip stack
stopped working.
2011-02-18 13:59:00 +01:00
Dima Tisnek e14f136aa3 config_sortlist: (win32) missing else
Without an else there, contents of "pat" that could have been
successfully set just above, may be clobbered by successive unsuccessful
calls to "xxx_pton" or "ip_addr".
2011-02-16 23:44:36 +01:00
Yang Tse dec9f79d0a Makefile.msvc: add a couple of VS version strings 2011-01-17 21:06:38 +01:00
Yang Tse e5fe34eea6 Makefile.msvc: add a couple of VS version strings 2011-01-17 20:44:23 +01:00
Yang Tse 5a21ba2b66 build: add install target to Makefile.msvc 2011-01-17 19:37:21 +01:00
Daniel Stenberg d70721eb65 ares_set_servers_csv: remove unused variables 2010-12-27 13:19:37 +01:00
Daniel Stenberg bd6636c138 init_by_resolv_conf: fix compiler warnings
The code received the return codes in the 'status' variable without
using it. Instead we just ignore those particular errors.
2010-12-27 13:18:54 +01:00
Daniel Stenberg 39d7f64361 getv4: Value stored to 'dst' is never read 2010-12-27 13:13:19 +01:00
Daniel Stenberg 366cd6d54d advance_tcp_send_queue: avoid NULL ptr dereference
If given a too large 'num_bytes' value, it would cause a NULL ptr
dereference. Instead the code will now break out of the loop at the end
of the list.
2010-12-27 13:10:48 +01:00
Peter Pentchev 766a5aaf86 configure: fix a bashism 2010-12-19 23:20:58 +01:00
Daniel Stenberg 2d5ed6400b cleanup: avoid unsafe typecasts
Avoid the risk of reading 16bit data from an unaligned address by using
a macro that is adapted for this.
2010-12-18 22:20:16 +01:00
Stefan Bühler 70b726c334 ares_expand_name: Fix encoded length for indirect root 2010-12-18 17:23:04 +01:00
Yang Tse a44f4c33e9 build: add some explicit file references to VS project files 2010-12-18 04:57:47 +01:00
Yang Tse 1cfd800d4a config-win32: provide HAVE_ASSERT_H definition 2010-12-17 18:42:59 +01:00
Yang Tse 7a4ec5ce61 build: include ares_nowarn in sample program VS project files 2010-12-17 02:03:38 +01:00
Yang Tse e566cc100f build: include ares_nowarn among SAMPLESOURCES and SAMPLEHEADERS 2010-12-16 23:09:04 +01:00
Yang Tse 674e044ccb configure: temporarily disable detection of system's inet_ntop()
This is done to allow compilation of ares_inet_ntop() by some daily
builds picky compilers that otherwise do not need this function.
2010-12-16 21:47:19 +01:00
Yang Tse d8c830f33e changes: mention last fix 2010-12-16 21:34:59 +01:00
Yang Tse 3670427a0b ares_inet_ntop: remove definition and usage of macro SPRINTF
Existing definition of SPRINTF always resulted in sprintf() being used,
and sprintf() returning 'int' is already used throughout the library.
2010-12-16 21:27:56 +01:00
Yang Tse 52f493c931 ares_inet_ntop: reapply changes from previous c-ares version (III)
- Replace 'u_char' with 'unsigned char'.
- Replace 'u_int' with 'unsigned int'.
- use macros ERRNO and SET_ERRNO() for errno handling.
2010-12-16 21:12:14 +01:00
Yang Tse 2c9bdd7856 ares_inet_ntop: reapply changes from previous c-ares version (II)
- Remove rcsid.
- Adjust header file inclusions.
- ares_inet_ntop used only on systems without a proper inet_ntop function.
2010-12-16 20:45:34 +01:00
Yang Tse fd6f4dbe1e ares_inet_ntop: reapply changes from previous c-ares version (I)
- Replace tabs with spaces.
- Use ANSI C style for function declarations and definitions.
- Use sizeof with parentheses.
2010-12-16 20:32:08 +01:00
Yang Tse 0d738bab0d ares_inet_ntop: fix off by one error triggering out of bounds write
ares_inet_ntop would trigger an out of bounds write when the representation
of the address required 15 characters, due to not taking in account null
termination character.

Full import of inet_ntop.c from bind-9.5.3rc1 to pull additional fixes.
2010-12-16 19:46:23 +01:00
Yang Tse b9959cbf36 ares_nowarn: add conditional inclusion of assert.h header 2010-12-16 18:39:31 +01:00
Yang Tse f5e0858d2f fix compiler warning: conversion may lose significant bits 2010-12-16 17:18:57 +01:00
Yang Tse e03a65c3d9 ares_inet_net_pton: fix non-rejection of some malformed literals
ares_inet_net_pton would return wrong values when excessively large,
and invalid, netmasks are used. Fixes are from bind-9.5.3rc1,
issue also described in the WLB-2008080064 advisory.
2010-12-15 02:44:07 +01:00
Yang Tse 2c26d7d254 setup_once: provide ISASCII macro 2010-12-15 02:26:51 +01:00
Yang Tse 623f3cb531 configure: inet_net_pton function check adjustments
Define HAVE_INET_NET_PTON only when system's inet_net_pton function is IPv6
capable and is not affected by the WLB-2008080064 advisory.

HAVE_INET_NET_PTON_IPV6 is no longer defined nor used.
2010-12-15 02:22:04 +01:00
Yang Tse b2dafb6974 ares_init: fix detection of semicolon comments in resolv.conf
File resolv.conf may either use a hash '#' or a semicolon ';' character as an
indication that the rest of the line is a comment.  This fixes not recognizing
the semicolon as a valid comment indicator in resolv.conf.
2010-12-10 21:19:51 +01:00
Yang Tse 0b497f70e1 version: start working on 1.7.5 2010-12-10 21:04:11 +01:00
Daniel Stenberg b354607aed release-preps: CHANGES and RELEASE-NOTES synced 2010-12-08 15:19:13 +01:00
Daniel Stenberg 0ae8dbb22d ares_set_local_*: added in 1.7.4, not before 2010-12-08 15:17:15 +01:00
Yang Tse 4d061e6b23 build: provide SIZEOF_SIZE_T definition for non-configure builds 2010-12-03 04:41:16 +01:00
Yang Tse 09331032a0 build: config.dos renamed to config-dos.h 2010-12-03 04:35:05 +01:00
Yang Tse a04dbb4323 build: provide SIZEOF_SIZE_T netware definition 2010-12-02 20:53:12 +01:00
Yang Tse fb4df6febc ares_gethostbyaddr: fix compiler warning: conversion may lose significant bits 2010-12-02 19:45:00 +01:00
Yang Tse 618e34bcf6 configure: undo using autobuilds to temporarily verify strict aliasing warnings. 2010-12-02 19:08:46 +01:00
Yang Tse a1c27d5480 fix compiler warning: rounding, sign extension, or loss of accuracy may result 2010-12-02 18:49:15 +01:00
Ben Noordhuis 2c63440127 ares_parse_a_reply: fix CNAME response parsing
Reply to a CNAME query doesn't contain addresses, causing
ares_parse_a_reply() to bail out with ARES_ENODATA

Bug: http://groups.google.com/group/nodejs/browse_thread/thread/a1268c9ea5e9ad9b
2010-12-02 10:48:50 +01:00
Yang Tse 41b8a1bfd0 fix compiler warning: conversion may lose significant bits 2010-12-01 23:36:19 +01:00
Yang Tse e3f7230dc2 atoi: remove atoi usage 2010-11-29 02:22:08 +01:00
Yang Tse 0ea27cdbbf ares_init: fix compiler warning: conversion may lose significant bits 2010-11-28 20:56:17 +01:00
Yang Tse e3813e6d24 configure: fix autoconf warning 2010-11-25 03:07:29 +01:00
Yang Tse e9e8b6e864 inet_pton: fix compiler warning 2010-11-25 02:19:36 +01:00
Yang Tse 4d44b54c75 configure: use autobuilds to temporarily verify strict aliasing warnings.
Temporarily, When cross-compiling with gcc 3.0 or later, enable strict aliasing
rules and warnings. Given that cross-compiled targets autobuilds do not run the
test-suite, there is no risk of running code that violates strict aliasing rules
2010-11-18 17:11:38 +01:00
Yang Tse 461fa89e0a ares_getnameinfo: Partially revert commit 85520d66e0
Upon socket address family and length validation failure return ARES_ENOTIMP
in callback again, this is the error code documented in man page and used
mostly all over the library.
2010-11-16 20:15:55 +01:00
Yang Tse 85520d66e0 ares_getnameinfo: Validate socket address family and length.
Validate socket address family and that the socket address length is appropriate
for the specified family. Failure is reported with ARES_EBADFAMILY in callback.
2010-11-16 19:41:03 +01:00
Yang Tse 690f9a726c ares_getnameinfo: fix two compiler warnings 2010-11-16 19:08:07 +01:00
Yang Tse 137a440a36 Added another VS10 version string 2010-11-16 03:33:54 +01:00
Yang Tse 10ae9e4ec2 Fix GCC 4 compiler warning 'dereferencing type-punned pointer might break strict-aliasing rules'. 2010-11-14 04:42:10 +01:00
Yang Tse 4ab5eb6631 Revert commit 494274e653 2010-11-13 14:06:44 +01:00
Yang Tse 0b504d7065 configure: fix autoconf 2.68 warning: no AC_LANG_SOURCE call detected in body 2010-11-13 04:15:16 +01:00
Yang Tse dac69d52c2 Fix compiler warning: array subscript has type 'char' 2010-11-12 19:46:13 +01:00
Yang Tse 494274e653 Fix GCC 4 compiler warning 'dereferencing type-punned pointer might break strict-aliasing rules'. 2010-11-12 19:00:29 +01:00
Yang Tse 747981be8e Revert following commits:
07bc7ea795
  3392a50ea3
  9912637d32

The purpose of the whole patch was to silence a compiler warning triggered
with GCC 4 on file ares_process.c  The specific compiler warning was
'dereferencing type-punned pointer might break strict-aliasing rules'.

A simpler patch will follow to equally silence the warning.
2010-11-12 18:53:58 +01:00
Yang Tse b8044334f0 ares_options: reorder header inclusions to make inclusion of
ares_private.h the last included one again.
2010-11-12 16:34:34 +01:00
Patrik Thunstrom e9386cfd9f adig: fix NAPTR parsing
I ran across a small "issue" in your adig example.

It is simply the last part of the NAPTR record, the replacement element,
which is not a string, as currently handled in adig, but a domain name.
2010-11-12 14:09:00 +01:00
Daniel Stenberg 6cc3521ec9 ares_save_options: assignments instead of memcpy 2010-10-05 19:42:39 +02:00
Daniel Stenberg 803e2a28b7 init_by_options: don't copy an empty sortlist
If there aren't any sort items to copy, don't bother. Without this
little precaution it would do a malloc(0) which causes undefined
behaviors and is frowned upon by curl's memdebug-system.
2010-10-05 19:40:35 +02:00
Guenter Knauf 679c1032cb Minor Watcom makefile tweaks. 2010-10-03 22:56:12 +02:00
Mike Crowe fa0dd472cd Fix lookup with HOSTALIASES set.
ares__read_line returns ARES_EOF when it reaches the end of the
file. This will happen every time when reading to the end of the
HOSTALIASES file. Unfortunately single_domain treats this error as
being fatal.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
2010-09-30 00:23:08 +02:00
Ben Greear 293cd31700 Add missing break that caused get_ares_servers to fail.
Reported-by: Ning Dong <flintning@163.com>
Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-08-24 16:52:29 -07:00
Yang Tse e43e69718f configure: werror related adjustments 2010-08-11 14:08:18 +02:00
Guenter Knauf 5e7a4dc5d7 Added copyright string to ares_version.h and make use of it in other files. 2010-08-08 11:18:38 +02:00
Guenter Knauf e6b38cdbd2 Block created ares_build.h for NetWare to avoid usage from other platforms. 2010-08-08 10:26:04 +02:00
Guenter Knauf d8ed817b99 Fix to overwrite default libname. 2010-08-07 18:35:47 +02:00
Guenter Knauf b33f331a4f Some more Watcom makefile massage ... 2010-08-06 03:53:03 +02:00
Guenter Knauf 17d4e513d4 Some more Watcom makefile massage ... 2010-08-06 03:48:25 +02:00
Ben Greear 9912637d32 sock-addr-storage: Detect and deal with lack of .ss_family member.
AIX, at least, does not have sockaddr_storage.ss_family member.
Detect this in the configure logic and use proper #ifdefs in the
ares_process logic.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Tested-by: Tor Arntsen <tor@spacetec.no>
2010-08-04 07:42:01 -07:00
Guenter Knauf a00e234001 Added Watcom makefile based on libcurl's Makefile.Watcom. 2010-08-03 01:21:56 +02:00
Ben Greear 3392a50ea3 typo: Fix compile bug for platforms that don't have sockaddr_storage.
Bug was introduced by me in previous commit.

Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-31 12:21:08 -07:00
Ben Greear 07bc7ea795 Fix aliasing warning in gcc 4.4.4 (at least).
Should be no functional change, though the code gets a bit
ugglier.

Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-31 07:11:27 -07:00
Daniel Stenberg cef3a4c7aa ares_set_servers_csv: use ISDIGIT
The IS*() set of macros are preferred to the regular is*() functions as
they help us avoid the most common pitfalls.
2010-07-31 00:16:39 +02:00
Ben Greear 8d33804971 cast arg to isdigit to int
Looks like it might silence a warning on Netware build.

Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-30 15:11:54 -07:00
Ben Greear f575aea364 remove all uses of uint32_t
Previous fix forgot a few.

Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-30 10:09:57 -07:00
Ben Greear 03c1378e84 fix signed v/s unsigned casts warning in ares_gethostbyaddr.c
Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-30 09:30:49 -07:00
Ben Greear 1ac83339e3 local-bind-fixup: Fix inet_pton warning.
Conditionally include <arpa/inet.h> for inet_pton
headers.

Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-30 00:10:16 -07:00
Ben Greear 45557a138e build: Enable compiling with -Werror.
This helps find compile warnings because they simply break
the build.

To use:
./configure --enable-warnings --enable-werror

Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-29 23:43:02 -07:00
Ben Greear 3e33e2c2ba ipv6: Fix some build issues related to the local-bind feature.
Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-29 22:31:56 -07:00
Guenter Knauf 28ff9336d5 Replaced uint32_t with unsigned int to fix broken builds on a couple of platforms. 2010-07-29 23:27:46 +02:00
Ben Greear e3b04e5a47 local-bind: Support binding to local interface/IPs
Add 3 new functions to set the local binding for the out-going
socket connection, and add ares_set_servers_csv() to set a
list of servers at once as a comma-separated string.

Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-18 23:58:39 +02:00
Daniel Stenberg 45a09b7efb version: now start on 1.7.4 2010-07-18 23:54:22 +02:00
Andrew C. Morrow d6b8698941 fix memory leak in ares_getnameinfo 2010-06-16 15:44:19 +08:00
Daniel Stenberg 954ec10e5a changelogs: updated for 1.7.3 2010-06-11 16:58:28 +02:00
BogDan Vatra b13c6552f8 init: allow c-ares to work on Android OS 2010-06-11 10:47:00 +02:00
Daniel Stenberg 359936ceca changelog: fill in the 1.7.2 changes 2010-06-11 10:37:37 +02:00
Daniel Stenberg 955038ea68 added another pdf to ignore 2010-06-11 08:23:14 +02:00
Yang Tse 5209cf03a1 add ares_parse_mx_reply.c to VS dsp file 2010-06-11 01:56:12 +02:00
Daniel Stenberg 9cb25ea5f7 tarball: add $(CSOURCES) $(HHEADERS) to EXTRA_DIST
It's not clear to me why we need this, but we apparently may
otherwise not get all files bundled in the dist tarball.
2010-06-10 23:22:59 +02:00
Daniel Stenberg 50f99d46cc version: start working on 1.7.3 2010-06-10 11:47:23 +02:00
Daniel Stenberg 890a143722 RELEASE-NOTES: 1.7.2 details added 2010-06-10 11:43:57 +02:00
Jakub Hrozek 125b1a8619 ares_init: Last, not first instance of domain or search should win 2010-06-02 23:12:04 +02:00
Daniel Stenberg 0e8dc6f18e style: make code less than 80 columns wide 2010-06-02 23:10:21 +02:00
Tor Arntsen cd59ae213f improve alternative definition of bool to use enum instead of unsigned char 2010-05-31 14:08:35 +02:00
Yang Tse be68a8ed0d fix VS2010 compiler warnings 2010-05-31 13:53:37 +02:00
Jérémy Lal 63918fca76 added ares_parse_mx_reply 2010-04-18 00:29:26 +02:00
Daniel Stenberg f28874d323 repair the file mode 2010-03-27 19:43:33 +01:00
Daniel Stenberg 63627fa5ab remove all $Id$ lines 2010-03-27 19:42:02 +01:00
Daniel Stenberg cd6b2b8659 remove all .cvsignore files 2010-03-27 19:36:38 +01:00
Daniel Stenberg 6e0ab38229 spell fix
reported by Gregor Jasny on the mailing list
2010-03-25 14:06:26 +01:00
Peter Pentchev a83d892bb2 Fix a couple of typos and grammar nits. 2010-03-25 13:00:17 +01:00
Daniel Stenberg 5e22223332 ignore the GPG signature files too 2010-03-23 14:56:21 +01:00
Daniel Stenberg e965d83c78 start the journey towards 1.7.2 2010-03-23 14:56:04 +01:00
Daniel Stenberg 7403f443ac no longer CVS tagging 2010-03-23 14:49:52 +01:00
Daniel Stenberg 36e2f2b54f ignore generated PDFs 2010-03-23 14:49:41 +01:00
Daniel Stenberg 5923ba2a53 1.7.1 2010-03-23 14:47:56 +01:00
Daniel Stenberg 8c4fc9ee71 made README the primary readme file
... and did README.cares to contain a historic reason etc.
2010-03-23 14:12:50 +01:00
Daniel Stenberg eb9ce5145b s/CVS/git 2010-03-23 14:04:26 +01:00
Daniel Stenberg 941bb3aaba git now, not CVS 2010-03-23 14:00:48 +01:00
Daniel Stenberg f8d181ddf6 ignore lots of generated files 2010-03-23 13:51:47 +01:00
Daniel Johnson 25116bbc54 Fix warnings for clang 2010-03-23 13:43:34 +01:00
Yang Tse 7ce764fe7c replaced intel compiler option -no-ansi-alias with -fno-strict-aliasing 2010-03-17 10:44:28 +00:00
Yang Tse 1cb7bccb6a update outdated serial number 2010-03-17 10:39:07 +00:00
Yang Tse 907b09ccd0 fix compiler warning 2010-03-11 18:53:42 +00:00
Yang Tse 3081404dec watt32 compilation fix 2010-03-09 17:59:35 +00:00
Yang Tse 05b07653e5 Added another VS10 version string 2010-03-06 10:52:56 +00:00
Yang Tse c431501153 fix line break 2010-03-06 02:33:25 +00:00
Yang Tse e51156c080 removed usage of 's6_addr', fixing compilation issue triggered with no
longer using 'in6_addr' but only our 'ares_in6_addr' struct
2010-03-06 01:23:09 +00:00
Daniel Stenberg 0a076df87f Daniel Johnson provided fixes for building with the clang compiler 2010-03-05 22:53:31 +00:00
Yang Tse 8fe746fcf2 Added IPv6 name servers support 2010-03-05 20:01:47 +00:00
Gisle Vanem 249fc61b8c Ops!. Readded ares_nowarn.h. 2010-03-05 18:45:17 +00:00
Gisle Vanem 53bf47a140 Added ares_nowarn.c. 2010-03-05 18:21:56 +00:00
Yang Tse b6ffa03a21 Added SIZEOF_INT and SIZEOF_SHORT definitions for non-configure systems 2010-02-28 02:51:35 +00:00
Yang Tse 62f43da764 Added ares_nowarn.* to VC6 project file 2010-02-28 02:50:51 +00:00
Yang Tse 561d3d8356 Added SIZEOF_INT definition 2010-02-26 17:48:18 +00:00
Yang Tse 86718e2f52 fix compiler warning 2010-02-26 16:42:33 +00:00
Yang Tse 78414c0f3a fix compiler warning 2010-02-23 18:46:27 +00:00
Yang Tse 157d68729f fix compiler warning 2010-02-21 19:59:09 +00:00
Daniel Stenberg d2f21d37b1 ares_reinit()
- To allow an app to force a re-read of /etc/resolv.conf etc, pretty much
  like the res_init() resolver function offers
2010-02-17 22:15:23 +00:00
Daniel Stenberg 8b6f71ce95 - Tommie Gannert pointed out a silly bug in ares_process_fd() since it didn't
check for broken connections like ares_process() did. Based on that, I
  merged the two functions into a single generic one with two front-ends.
2010-01-28 22:03:48 +00:00
Yang Tse 004c2e3400 VMS specific preprocessor symbol checking adjustments 2009-12-30 17:59:56 +00:00
Yang Tse 92dcb407d6 Mention last changes 2009-12-29 02:32:12 +00:00
Yang Tse 58d9b0c1bd - Fix configure_socket() to use ares_socket_t instead of int data type. 2009-12-29 02:04:17 +00:00
Yang Tse bb3f003b83 - Where run-time error checks enabling compiler option /GZ was used it is now
replaced with equivalent /RTCsu for Visual Studio 2003 and newer versions.

- Compiler option /GX is now replaced with equivalent /EHsc for all versions.
2009-12-29 01:51:57 +00:00
Yang Tse c2d3f7986b - Ingmar Runge noticed that Windows config-win32.h configuration file
did not include a definition for HAVE_CLOSESOCKET which resulted in
  function close() being inappropriately used to close sockets.
2009-12-21 16:55:39 +00:00
Daniel Stenberg df279b133c start working on 1.7.1 2009-11-30 22:39:04 +00:00
493 changed files with 221838 additions and 4240 deletions
-35
View File
@@ -1,35 +0,0 @@
*.html
*.lo
*.pdf
.deps
.libs
MSVC*
Makefile
Makefile.in
aclocal.m4
acountry
adig
ahost
ares_build.h
ares_config.h
ares_config.h.in
ares_version.h.dist
autom4te.cache
compile
config.guess
config.h
config.h.in
config.log
config.lt
config.status
config.sub
configure
depcomp
libcares.la
libcares.pc
libtool
ltmain.sh
man3
missing
msvc*
stamp-h*
+57
View File
@@ -0,0 +1,57 @@
.deps
.libs
*.lib
*.pdb
*.dll
*.exe
*.obj
.*.swp
Debug
Release
*.exp
Makefile
Makefile.in
aclocal.m4
autom4te.cache
config.guess
config.log
config.status
config.sub
configure
depcomp
libtool
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
*~
aclocal.m4.bak
acountry
adig
ahost
ares_build.h
ares_config.h
ares_config.h.in
stamp-h1
stamp-h2
ares_*pdf
CHANGES.dist
c-ares-*.tar.gz.asc
ares_parse_mx_reply.pdf
/[0-9]*.patch
*.kdev4
+102
View File
@@ -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
+45
View File
@@ -1,37 +1,82 @@
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
Ben Noordhuis
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
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
+3829 -969
View File
File diff suppressed because it is too large Load Diff
+1218
View File
File diff suppressed because it is too large Load Diff
+15
View File
@@ -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).
-7
View File
@@ -1,7 +0,0 @@
CVS-INFO
This file is only present in the CVS - never in release archives. It is used
as a sentinel file in buildconf.bat in order to differentiate a CVS checkout
from release and daily snapshot archives.
+9
View File
@@ -0,0 +1,9 @@
GIT-INFO
This file is only present in git - never in release archives. It is used as a
sentinel file in buildconf.bat in order to differentiate a git checkout from
release and daily snapshot archives.
On *nix-like systems, run the ./buildconf script first to generate a fresh
configure script.
+328
View File
@@ -0,0 +1,328 @@
** This file is adapted from libcurl and not yet fully rewritten for c-ares! **
___ __ _ _ __ ___ ___
/ __| ___ / _` | '__/ _ \/ __|
| (_ |___| (_| | | | __/\__ \
\___| \__,_|_| \___||___/
How To Compile
Installing Binary Packages
==========================
Lots of people download binary distributions of c-ares. This document
does not describe how to install c-ares using such a binary package.
This document describes how to compile, build and install c-ares from
source code.
Building from git
=================
If you get your code off a git repository, see the GIT-INFO file in the
root directory for specific instructions on how to proceed.
UNIX
====
A normal unix installation is made in three or four steps (after you've
unpacked the source archive):
./configure
make
make ahost adig acountry (optional)
make install
You probably need to be root when doing the last command.
If you have checked out the sources from the git repository, read the
GIT-INFO on how to proceed.
Get a full listing of all available configure options by invoking it like:
./configure --help
If you want to install c-ares in a different file hierarchy than /usr/local,
you need to specify that already when running configure:
./configure --prefix=/path/to/c-ares/tree
If you happen to have write permission in that directory, you can do 'make
install' without being root. An example of this would be to make a local
install in your own home directory:
./configure --prefix=$HOME
make
make install
MORE OPTIONS
------------
To force configure to use the standard cc compiler if both cc and gcc are
present, run configure like
CC=cc ./configure
or
env CC=cc ./configure
To force a static library compile, disable the shared library creation
by running configure like:
./configure --disable-shared
If you're a c-ares developer and use gcc, you might want to enable more
debug options with the --enable-debug option.
SPECIAL CASES
-------------
Some versions of uClibc require configuring with CPPFLAGS=-D_GNU_SOURCE=1
to get correct large file support.
The Open Watcom C compiler on Linux requires configuring with the variables:
./configure CC=owcc AR="$WATCOM/binl/wlib" AR_FLAGS=-q \
RANLIB=/bin/true STRIP="$WATCOM/binl/wstrip" CFLAGS=-Wextra
Win32
=====
Building Windows DLLs and C run-time (CRT) linkage issues
---------------------------------------------------------
As a general rule, building a DLL with static CRT linkage is highly
discouraged, and intermixing CRTs in the same app is something to
avoid at any cost.
Reading and comprehension of Microsoft Knowledge Base articles
KB94248 and KB140584 is a must for any Windows developer. Especially
important is full understanding if you are not going to follow the
advice given above.
KB94248 - How To Use the C Run-Time
http://support.microsoft.com/kb/94248/en-us
KB140584 - How to link with the correct C Run-Time (CRT) library
http://support.microsoft.com/kb/140584/en-us
KB190799 - Potential Errors Passing CRT Objects Across DLL Boundaries
http://msdn.microsoft.com/en-us/library/ms235460
If your app is misbehaving in some strange way, or it is suffering
from memory corruption, before asking for further help, please try
first to rebuild every single library your app uses as well as your
app using the debug multithreaded dynamic C runtime.
MingW32
-------
Make sure that MinGW32's bin dir is in the search path, for example:
set PATH=c:\mingw32\bin;%PATH%
then run 'make -f Makefile.m32' in the root dir.
Cygwin
------
Almost identical to the unix installation. Run the configure script in the
c-ares root with 'sh configure'. Make sure you have the sh executable in
/bin/ or you'll see the configure fail toward the end.
Run 'make'
Dev-Cpp
-------
See the separate INSTALL.devcpp file for details.
MSVC 6 caveats
--------------
If you use MSVC 6 it is required that you use the February 2003 edition PSDK:
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm
MSVC from command line
----------------------
Run the 'vcvars32.bat' file to get a proper environment. The
vcvars32.bat file is part of the Microsoft development environment and
you may find it in 'C:\Program Files\Microsoft Visual Studio\vc98\bin'
provided that you installed Visual C/C++ 6 in the default directory.
Further details in README.msvc
MSVC IDES
---------
Details in README.msvc
Important static c-ares usage note
----------------------------------
When building an application that uses the static c-ares library, you must
add '-DCARES_STATICLIB' to your CFLAGS. Otherwise the linker will look for
dynamic import symbols.
IBM OS/2
========
Building under OS/2 is not much different from building under unix.
You need:
- emx 0.9d
- GNU make
- GNU patch
- ksh
- GNU bison
- GNU file utilities
- GNU sed
- autoconf 2.13
If during the linking you get an error about _errno being an undefined
symbol referenced from the text segment, you need to add -D__ST_MT_ERRNO__
in your definitions.
If you're getting huge binaries, probably your makefiles have the -g in
CFLAGS.
QNX
===
(This section was graciously brought to us by David Bentham)
As QNX is targeted for resource constrained environments, the QNX headers
set conservative limits. This includes the FD_SETSIZE macro, set by default
to 32. Socket descriptors returned within the c-ares library may exceed this,
resulting in memory faults/SIGSEGV crashes when passed into select(..)
calls using fd_set macros.
A good all-round solution to this is to override the default when building
c-ares, by overriding CFLAGS during configure, example
# configure CFLAGS='-DFD_SETSIZE=64 -g -O2'
RISC OS
=======
The library can be cross-compiled using gccsdk as follows:
CC=riscos-gcc AR=riscos-ar RANLIB='riscos-ar -s' ./configure \
--host=arm-riscos-aof --without-random --disable-shared
make
where riscos-gcc and riscos-ar are links to the gccsdk tools.
You can then link your program with c-ares/lib/.libs/libcares.a
NetWare
=======
To compile libcares.a / libcares.lib you need:
- either any gcc / nlmconv, or CodeWarrior 7 PDK 4 or later.
- gnu make and awk running on the platform you compile on;
native Win32 versions can be downloaded from:
http://www.gknw.net/development/prgtools/
- recent Novell LibC SDK available from:
http://developer.novell.com/ndk/libc.htm
- or recent Novell CLib SDK available from:
http://developer.novell.com/ndk/clib.htm
Set a search path to your compiler, linker and tools; on Linux make
sure that the var OSTYPE contains the string 'linux'; set the var
NDKBASE to point to the base of your Novell NDK; and then type
'make -f Makefile.netware' from the top source directory;
Android
=======
Method using a configure cross-compile (tested with Android NDK r7b):
- prepare the toolchain of the Android NDK for standalone use; this can
be done by invoking the script:
./tools/make-standalone-toolchain.sh
which creates a usual cross-compile toolchain. Lets assume that you put
this toolchain below /opt then invoke configure with something like:
export PATH=/opt/arm-linux-androideabi-4.4.3/bin:$PATH
./configure --host=arm-linux-androideabi [more configure options]
make
- if you want to compile directly from our GIT repo you might run into
this issue with older automake stuff:
checking host system type...
Invalid configuration `arm-linux-androideabi':
system `androideabi' not recognized
configure: error: /bin/sh ./config.sub arm-linux-androideabi failed
this issue can be fixed with using more recent versions of config.sub
and config.guess which can be obtained here:
http://git.savannah.gnu.org/gitweb/?p=config.git;a=tree
you need to replace your system-own versions which usually can be
found in your automake folder:
find /usr -name config.sub
CROSS COMPILE
=============
(This section was graciously brought to us by Jim Duey, with additions by
Dan Fandrich)
Download and unpack the c-ares package.
'cd' to the new directory. (e.g. cd c-ares-1.7.6)
Set environment variables to point to the cross-compile toolchain and call
configure with any options you need. Be sure and specify the '--host' and
'--build' parameters at configuration time. The following script is an
example of cross-compiling for the IBM 405GP PowerPC processor using the
toolchain from MonteVista for Hardhat Linux.
(begin script)
#! /bin/sh
export PATH=$PATH:/opt/hardhat/devkit/ppc/405/bin
export CPPFLAGS="-I/opt/hardhat/devkit/ppc/405/target/usr/include"
export AR=ppc_405-ar
export AS=ppc_405-as
export LD=ppc_405-ld
export RANLIB=ppc_405-ranlib
export CC=ppc_405-gcc
export NM=ppc_405-nm
./configure --target=powerpc-hardhat-linux \
--host=powerpc-hardhat-linux \
--build=i586-pc-linux-gnu \
--prefix=/opt/hardhat/devkit/ppc/405/target/usr/local \
--exec-prefix=/usr/local
(end script)
You may also need to provide a parameter like '--with-random=/dev/urandom'
to configure as it cannot detect the presence of a random number
generating device for a target system. The '--prefix' parameter
specifies where c-ares will be installed. If 'configure' completes
successfully, do 'make' and 'make install' as usual.
In some cases, you may be able to simplify the above commands to as
little as:
./configure --host=ARCH-OS
PORTS
=====
This is a probably incomplete list of known hardware and operating systems
that c-ares has been compiled for. If you know a system c-ares compiles and
runs on, that isn't listed, please let us know!
- Alpha Tru64 v5.0 5.1
- ARM Android 1.5, 2.1, 2.3
- MIPS IRIX 6.2, 6.5
- Power AIX 3.2.5, 4.2, 4.3.1, 4.3.2, 5.1, 5.2
- i386 Linux 1.3, 2.0, 2.2, 2.3, 2.4, 2.6
- i386 Novell NetWare
- i386 Windows 95, 98, ME, NT, 2000, XP, 2003
- x86_64 Linux
Useful URLs
===========
c-ares https://c-ares.haxx.se/
MingW http://www.mingw.org/
MinGW-w64 http://mingw-w64.sourceforge.net/
OpenWatcom http://www.openwatcom.org/
+15
View File
@@ -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.
+164
View File
@@ -0,0 +1,164 @@
#
# Watcom / OpenWatcom / Win32 makefile for cares.
# Quick hack by Guenter; comments to: /dev/nul
#
!ifndef %watcom
!error WATCOM environment variable not set!
!else
SYS_INCL = -I$(%watcom)\h\nt -I$(%watcom)\h
SYS_LIBS = $(%watcom)\lib386\nt;$(%watcom)\lib386
!endif
!ifdef %libname
LIBNAME = $(%libname)
!else
LIBNAME = cares
!endif
TARGETS = $(LIBNAME).dll $(LIBNAME)_imp.lib $(LIBNAME).lib
DEMOS = adig.exe ahost.exe acountry.exe
CC = wcc386
LD = wlink
AR = wlib
RC = wrc
!ifdef __LOADDLL__
! loaddll wcc386 wccd386
! loaddll wpp386 wppd386
! loaddll wlib wlibd
!endif
!if $(__VERSION__) < 1250
RM = del /q /f 2>NUL
!else
RM = rm -f
!endif
MD = mkdir
RD = rmdir /q /s 2>NUL
CP = copy
CFLAGS = -3r -mf -hc -zff -zgf -zq -zm -zc -s -fr=con -w2 -fpi -oilrtfm &
-wcd=201 -bt=nt -d+ -dWIN32 -dCARES_BUILDING_LIBRARY &
-dNTDDI_VERSION=0x05010000 -I. $(SYS_INCL)
LFLAGS = option quiet, map, caseexact, eliminate
!ifdef %debug
DEBUG = -dDEBUG=1 -dDEBUGBUILD
CFLAGS += -d3 $(DEBUG)
LFLAGS += debug all
!else
CFLAGS += -d0
!endif
CFLAGS += -d_WIN32_WINNT=0x0501
#
# Change to suite.
#
!ifdef %use_watt32
CFLAGS += -dWATT32 -I$(%watt_root)\inc
!endif
OBJ_BASE = WC_Win32.obj
LINK_ARG = $(OBJ_BASE)\dyn\wlink.arg
LIB_ARG = $(OBJ_BASE)\stat\wlib.arg
# In order to process Makefile.inc wmake must be called with -u switch!
!ifneq __MAKEOPTS__ -u
!error You MUST call wmake with the -u switch!
!else
!include Makefile.inc
!endif
OBJS = $(CSOURCES:.c=.obj)
OBJS = $OBJ_DIR\$(OBJS: = $OBJ_DIR\)
#
# Use $(OBJS) as a template to generate $(OBJS_STAT) and $(OBJS_DYN).
#
OBJ_DIR = $(OBJ_BASE)\stat
OBJS_STAT = $+ $(OBJS) $-
OBJ_DIR = $(OBJ_BASE)\dyn
OBJS_DYN = $+ $(OBJS) $-
ARESBUILDH = ares_build.h
RESOURCE = $(OBJ_BASE)\dyn\cares.res
all: $(ARESBUILDH) $(OBJ_BASE) $(TARGETS) $(DEMOS) .SYMBOLIC
@echo Welcome to cares
$(OBJ_BASE):
-$(MD) $^@
-$(MD) $^@\stat
-$(MD) $^@\dyn
-$(MD) $^@\demos
$(ARESBUILDH): .EXISTSONLY
$(CP) $^@.dist $^@
$(LIBNAME).dll: $(OBJS_DYN) $(RESOURCE) $(LINK_ARG)
$(LD) name $^@ @$]@
$(LIBNAME).lib: $(OBJS_STAT) $(LIB_ARG)
$(AR) -q -b -c $^@ @$]@
adig.exe: $(OBJ_BASE)\demos\adig.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib
$(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib
ahost.exe: $(OBJ_BASE)\demos\ahost.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib
$(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib
acountry.exe: $(OBJ_BASE)\demos\acountry.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib
$(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib
clean: .SYMBOLIC
-$(RM) $(OBJS_STAT)
-$(RM) $(OBJS_DYN)
-$(RM) $(RESOURCE) $(LINK_ARG) $(LIB_ARG)
vclean realclean: clean .SYMBOLIC
-$(RM) $(TARGETS) $(LIBNAME).map
-$(RM) $(DEMOS) $(DEMOS:.exe=.map)
-$(RD) $(OBJ_BASE)\stat
-$(RD) $(OBJ_BASE)\dyn
-$(RD) $(OBJ_BASE)\demos
-$(RD) $(OBJ_BASE)
.ERASE
$(RESOURCE): cares.rc .AUTODEPEND
$(RC) $(DEBUG) -q -r -zm -I..\include $(SYS_INCL) $[@ -fo=$^@
.ERASE
.c{$(OBJ_BASE)\dyn}.obj:
$(CC) $(CFLAGS) -bd $[@ -fo=$^@
.ERASE
.c{$(OBJ_BASE)\stat}.obj:
$(CC) $(CFLAGS) -DCARES_STATICLIB $[@ -fo=$^@
.ERASE
.c{$(OBJ_BASE)\demos}.obj:
$(CC) $(CFLAGS) -DCARES_STATICLIB $[@ -fo=$^@
$(LINK_ARG): $(__MAKEFILES__)
%create $^@
@%append $^@ system nt dll
@%append $^@ file { $(OBJS_DYN) }
@%append $^@ option res=$(RESOURCE), implib=$(LIBNAME)_imp.lib
@%append $^@ $(LFLAGS)
@%append $^@ libpath $(SYS_LIBS)
# @%append $^@ library clib3r.lib
!ifdef %use_watt32
@%append $^@ library $(%watt_root)\lib\wattcpw_imp.lib
!else
@%append $^@ library ws2_32.lib
!endif
$(LIB_ARG): $(__MAKEFILES__)
%create $^@
@for %f in ($(OBJS_STAT)) do @%append $^@ +- %f
+58 -16
View File
@@ -22,16 +22,16 @@ ACLOCAL_AMFLAGS = -I m4
# $(top_srcdir) is for c-ares's ares_setup.h and other "c-ares-private" files
if CURLDEBUG
INCLUDES = -I$(top_builddir)/../include/curl \
-I$(top_builddir)/../include \
-I$(top_srcdir)/../include \
-I$(top_builddir)/../lib \
-I$(top_srcdir)/../lib \
-I$(top_builddir) \
-I$(top_srcdir)
AM_CPPFLAGS = -I$(top_builddir)/../include/curl \
-I$(top_builddir)/../include \
-I$(top_srcdir)/../include \
-I$(top_builddir)/../lib \
-I$(top_srcdir)/../lib \
-I$(top_builddir) \
-I$(top_srcdir)
else
INCLUDES = -I$(top_builddir) \
-I$(top_srcdir)
AM_CPPFLAGS = -I$(top_builddir) \
-I$(top_srcdir)
endif
lib_LTLIBRARIES = libcares.la
@@ -52,18 +52,22 @@ noinst_PROGRAMS =$(PROGS)
# adig and ahost are just sample programs and thus not mentioned with the
# regular sources and headers
EXTRA_DIST = AUTHORS CHANGES README.cares Makefile.inc Makefile.dj \
Makefile.m32 Makefile.netware Makefile.msvc $(man_MANS) $(MSVCFILES) \
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
TODO ares_build.h.in $(PDFPAGES) cares.rc README.msvc $(MSVCFILES) \
$(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
VER=-version-info 2:0:0
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.
@@ -92,12 +96,47 @@ VER=-version-info 2:0:0
# set age to 0. (c:r:a=0)
#
if NO_UNDEFINED
# The -no-undefined flag is crucial for this to build fine on some platforms
UNDEF = -no-undefined
AM_LDFLAGS =
libcares_la_LDFLAGS_EXTRA =
if CARES_LT_SHLIB_USE_VERSION_INFO
libcares_la_LDFLAGS_EXTRA += $(CARES_VERSION_INFO)
endif
libcares_la_LDFLAGS = $(UNDEF) $(VER)
if CARES_LT_SHLIB_USE_NO_UNDEFINED
libcares_la_LDFLAGS_EXTRA += -no-undefined
endif
if CARES_LT_SHLIB_USE_MIMPURE_TEXT
libcares_la_LDFLAGS_EXTRA += -mimpure-text
endif
libcares_la_LDFLAGS = $(AM_LDFLAGS) $(libcares_la_LDFLAGS_EXTRA)
# Add -Werror if defined
CFLAGS += @CARES_CFLAG_EXTRAS@
if USE_CPPFLAG_CARES_STATICLIB
AM_CPPFLAGS += $(CPPFLAG_CARES_STATICLIB)
endif
libcares_la_CFLAGS_EXTRA =
libcares_la_CPPFLAGS_EXTRA = -DCARES_BUILDING_LIBRARY
if DOING_CARES_SYMBOL_HIDING
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)
# Makefile.inc provides the CSOURCES and HHEADERS defines
include Makefile.inc
@@ -113,14 +152,17 @@ libcares_la_HEADERS = ares.h ares_version.h ares_dns.h \
ahost_SOURCES = ahost.c $(SAMPLESOURCES) $(SAMPLEHEADERS)
ahost_LDADD = $(top_builddir)/libcares.la
ahost_CFLAGS = $(AM_CFLAGS)
ahost_CPPFLAGS = $(AM_CPPFLAGS)
adig_SOURCES = adig.c $(SAMPLESOURCES) $(SAMPLEHEADERS)
adig_LDADD = $(top_builddir)/libcares.la
adig_CFLAGS = $(AM_CFLAGS)
adig_CPPFLAGS = $(AM_CPPFLAGS)
acountry_SOURCES = acountry.c $(SAMPLESOURCES) $(SAMPLEHEADERS)
acountry_LDADD = $(top_builddir)/libcares.la
acountry_CFLAGS = $(AM_CFLAGS)
acountry_CPPFLAGS = $(AM_CPPFLAGS)
SOURCEDMANDIR = man3
SOURCEDMANPAGES = ares_init.3
+2 -3
View File
@@ -1,8 +1,7 @@
#
# c-ares Makefile for djgpp/gcc/Watt-32.
# By Gisle Vanem <gvanem@broadpark.no> 2004.
# By Gisle Vanem <gvanem@yahoo.no> 2004.
#
# $Id$
TOPDIR = ..
@@ -45,7 +44,7 @@ all: $(OBJ_DIR) ares_config.h libcares.a ahost.exe adig.exe acountry.exe
libcares.a: $(OBJECTS)
ar rs $@ $?
ares_config.h: config.dos
ares_config.h: config-dos.h
$(COPY) $^ $@
ahost.exe: ahost.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK)
+71 -12
View File
@@ -11,6 +11,7 @@ CSOURCES = ares__close_sockets.c \
ares_fds.c \
ares_free_hostent.c \
ares_free_string.c \
ares_getenv.c \
ares_gethostbyaddr.c \
ares_gethostbyname.c \
ares_getnameinfo.c \
@@ -19,12 +20,19 @@ CSOURCES = ares__close_sockets.c \
ares_library_init.c \
ares_llist.c \
ares_mkquery.c \
ares_create_query.c \
ares_nowarn.c \
ares_options.c \
ares_parse_a_reply.c \
ares_parse_aaaa_reply.c \
ares_parse_mx_reply.c \
ares_parse_naptr_reply.c \
ares_parse_ns_reply.c \
ares_parse_ptr_reply.c \
ares_parse_soa_reply.c \
ares_parse_srv_reply.c \
ares_parse_txt_reply.c \
ares_platform.c \
ares_process.c \
ares_query.c \
ares_search.c \
@@ -38,15 +46,21 @@ 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 \
ares_data.h \
ares_dns.h \
ares_getenv.h \
ares_inet_net_pton.h \
ares_iphlpapi.h \
ares_ipv6.h \
ares_library_init.h \
ares_llist.h \
ares_nowarn.h \
ares_platform.h \
ares_private.h \
ares_rules.h \
ares_strcasecmp.h \
@@ -54,8 +68,6 @@ HHEADERS = ares.h \
ares_version.h \
ares_writev.h \
bitncmp.h \
inet_net_pton.h \
inet_ntop.h \
nameser.h \
ares_setup.h \
setup_once.h
@@ -70,6 +82,8 @@ MANPAGES = ares_cancel.3 \
ares_free_data.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 \
@@ -80,10 +94,14 @@ MANPAGES = ares_cancel.3 \
ares_library_cleanup.3 \
ares_library_init.3 \
ares_mkquery.3 \
ares_create_query.3 \
ares_parse_a_reply.3 \
ares_parse_aaaa_reply.3 \
ares_parse_mx_reply.3 \
ares_parse_naptr_reply.3 \
ares_parse_ns_reply.3 \
ares_parse_ptr_reply.3 \
ares_parse_soa_reply.3 \
ares_parse_srv_reply.3 \
ares_parse_txt_reply.3 \
ares_process.3 \
@@ -91,10 +109,21 @@ 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
ares_version.3 \
ares_inet_pton.3 \
ares_inet_ntop.3
HTMLPAGES = ares_cancel.html \
ares_destroy.html \
@@ -106,6 +135,8 @@ HTMLPAGES = ares_cancel.html \
ares_free_data.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 \
@@ -116,10 +147,13 @@ HTMLPAGES = ares_cancel.html \
ares_library_cleanup.html \
ares_library_init.html \
ares_mkquery.html \
ares_create_query.html \
ares_parse_a_reply.html \
ares_parse_aaaa_reply.html \
ares_parse_mx_reply.html \
ares_parse_ns_reply.html \
ares_parse_ptr_reply.html \
ares_parse_soa_reply.html \
ares_parse_srv_reply.html \
ares_parse_txt_reply.html \
ares_process.html \
@@ -127,10 +161,21 @@ 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
ares_version.html \
ares_inet_pton.html \
ares_inet_ntop.html
PDFPAGES = ares_cancel.pdf \
ares_destroy.pdf \
@@ -142,6 +187,8 @@ PDFPAGES = ares_cancel.pdf \
ares_free_data.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 \
@@ -152,10 +199,13 @@ PDFPAGES = ares_cancel.pdf \
ares_library_cleanup.pdf \
ares_library_init.pdf \
ares_mkquery.pdf \
ares_create_query.pdf \
ares_parse_a_reply.pdf \
ares_parse_aaaa_reply.pdf \
ares_parse_mx_reply.pdf \
ares_parse_ns_reply.pdf \
ares_parse_ptr_reply.pdf \
ares_parse_soa_reply.pdf \
ares_parse_srv_reply.pdf \
ares_parse_txt_reply.pdf \
ares_process.pdf \
@@ -163,17 +213,26 @@ 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
ares_version.pdf \
ares_inet_pton.pdf \
ares_inet_ntop.pdf
SAMPLESOURCES = ares_getopt.c \
ares_strcasecmp.c \
inet_net_pton.c \
inet_ntop.c
ares_nowarn.c \
ares_strcasecmp.c
SAMPLEHEADERS = ares_getopt.h \
ares_strcasecmp.h \
inet_net_pton.h \
inet_ntop.h
ares_nowarn.h \
ares_strcasecmp.h
+15 -8
View File
@@ -1,5 +1,4 @@
#############################################################
# $Id$
#
## Makefile for building libcares.a with MingW32 (GCC-3.2)
## Use: make -f Makefile.m32 [demos]
@@ -11,13 +10,16 @@
LIB = libcares.a
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
LDFLAGS = -s
CFLAGS = $(CARES_CFLAG_EXTRAS) -O2 -Wall -I.
CFLAGS += -DCARES_STATICLIB
LDFLAGS = $(CARES_LDFLAG_EXTRAS) -s
LIBS = -lwsock32
# Makefile.inc provides the CSOURCES and HHEADERS defines
@@ -27,7 +29,7 @@ OBJLIB := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
$(LIB): $(OBJLIB)
ar cru $@ $^
$(AR) cru $@ $^
$(RANLIB) $@
all: $(LIB) demos
@@ -45,6 +47,9 @@ $(OBJLIB): ares.h ares_dns.h ares_private.h ares_build.h ares_rules.h
.c.o:
$(CC) $(CFLAGS) -c $<
ares_build.h:
$(CP) ares_build.h.dist ares_build.h
check:
install:
@@ -66,4 +71,6 @@ clean:
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
+57
View File
@@ -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
+51 -47
View File
@@ -1,6 +1,5 @@
# $Id$
# Copyright (C) 2009 by Daniel Stenberg
# Copyright (C) 2009-2013 by Daniel Stenberg
#
# Permission to use, copy, modify, and distribute this
# software and its documentation for any purpose and without
@@ -19,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.
#
@@ -72,46 +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.9466"
CC_VERS_NUM = 70
!ELSEIF "$(_NMAKE_VER)" == "7.00.9955"
CC_VERS_NUM = 70
!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.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
!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
@@ -136,6 +99,22 @@ BASE_DIR = .\$(CC_VERS_STR)
SRCDIR = .
# -----------------------------
# Default installation subdirs
# -----------------------------
!IFNDEF INSTALL_DIR
INSTALL_DIR = .
!ENDIF
!IFNDEF INSTALL_DIR_LIB
INSTALL_DIR_LIB = $(INSTALL_DIR)\lib
!ENDIF
!IFNDEF INSTALL_DIR_INC
INSTALL_DIR_INC = $(INSTALL_DIR)\include
!ENDIF
# -------------------------
# Configuration validation
# -------------------------
@@ -222,13 +201,19 @@ PDBTYPE_CONSOLIDATE = /pdbtype:consolidate
!UNDEF PDBTYPE_CONSOLIDATE
!ENDIF
!IF $(CC_VERS_NUM) <= 70
RT_ERROR_CHECKING = /GZ
!ELSE
RT_ERROR_CHECKING = /RTCsu
!ENDIF
# ----------------------------
# Assorted commands and flags
# ----------------------------
CC_CMD_REL = cl.exe /nologo $(RTLIB) /DNDEBUG /O2
CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi /GZ
CC_CFLAGS = $(CFLAGS) /I. /W3 /GX /FD
CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi $(RT_ERROR_CHECKING)
CC_CFLAGS = $(CFLAGS) /I. /W3 /EHsc /FD
RC_CMD_REL = rc.exe /l 0x409 /d "NDEBUG"
RC_CMD_DBG = rc.exe /l 0x409 /d "_DEBUG"
@@ -388,6 +373,12 @@ ALL:
clean:
@-RMDIR /S /Q $(BASE_DIR) >NUL 2>&1
install:
@$(MAKE) /nologo /f .\Makefile.msvc CFG=lib-release install
@$(MAKE) /nologo /f .\Makefile.msvc CFG=lib-debug install
@$(MAKE) /nologo /f .\Makefile.msvc CFG=dll-release install
@$(MAKE) /nologo /f .\Makefile.msvc CFG=dll-debug install
!ENDIF
# ---------------------------------------------------------------------
@@ -447,6 +438,19 @@ clean:
@-RMDIR /S /Q $(PROG2_OUTDIR) >NUL 2>&1
@-RMDIR /S /Q $(PROG3_OUTDIR) >NUL 2>&1
install:
@if not exist $(CARES_OUTDIR)\$(CARES_TARGET) \
$(MAKE) /f .\Makefile.msvc CFG=$(CFG) c-ares
@if not exist "$(INSTALL_DIR)" mkdir "$(INSTALL_DIR)"
@if not exist "$(INSTALL_DIR_LIB)" mkdir "$(INSTALL_DIR_LIB)"
@if not exist "$(INSTALL_DIR_INC)" mkdir "$(INSTALL_DIR_INC)"
@copy /y $(CARES_OUTDIR)\*.* "$(INSTALL_DIR_LIB)" >NUL
@copy /y $(SRCDIR)\ares.h "$(INSTALL_DIR_INC)" >NUL
@copy /y $(SRCDIR)\ares_build.h "$(INSTALL_DIR_INC)" >NUL
@copy /y $(SRCDIR)\ares_rules.h "$(INSTALL_DIR_INC)" >NUL
@copy /y $(SRCDIR)\ares_version.h "$(INSTALL_DIR_INC)" >NUL
@echo Installed c-ares $(CFG)
!ENDIF
$(BASE_DIR):
+13 -10
View File
@@ -1,5 +1,4 @@
#################################################################
# $Id$
#
## Makefile for building libcares (NetWare version - gnu make)
## Use: make -f Makefile.netware
@@ -21,7 +20,7 @@ endif
TARGETS = adig.nlm ahost.nlm acountry.nlm
LTARGET = libcares.$(LIBEXT)
VERSION = $(LIBCARES_VERSION)
COPYR = Copyright (C) 1996 - 2008, Daniel Stenberg, <daniel@haxx.se>
COPYR = $(LIBCARES_COPYRIGHT_STR)
DESCR = cURL $(subst .def,,$(notdir $@)) $(LIBCARES_VERSION_STR) - http://curl.haxx.se
MTSAFE = YES
STACK = 64000
@@ -104,8 +103,12 @@ AR = ar
ARFLAGS = -cq
LIBEXT = a
RANLIB = ranlib
CFLAGS += -fno-builtin -fpcc-struct-return -fno-strict-aliasing
CFLAGS += -Wall -Wno-format -Wno-uninitialized # -pedantic
CFLAGS += -m32
CFLAGS += -fno-builtin -fno-strict-aliasing
ifeq ($(findstring gcc,$(CC)),gcc)
CFLAGS += -fpcc-struct-return
endif
CFLAGS += -Wall # -pedantic
ifeq ($(LIBARCH),LIBC)
PRELUDE = $(SDK_LIBC)/imports/libcpre.gcc.o
else
@@ -143,7 +146,7 @@ ifeq ($(MTSAFE),NO)
XDCOPT = -u
endif
ifeq ($(findstring linux,$(OSTYPE)),linux)
ifeq ($(findstring /sh,$(SHELL)),/sh)
DL = '
#-include $(NDKBASE)/nlmconv/ncpfs.inc
endif
@@ -345,12 +348,13 @@ 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_STRUCT_IN6_ADDR 16$(DL) >> $@
endif
@echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
@echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
@echo $(DL)#define HAVE_ERRNO_H 1$(DL) >> $@
@echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
@echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
@echo $(DL)#define HAVE_GETENV 1$(DL) >> $@
@echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@
@echo $(DL)#define HAVE_GETHOSTBYNAME 1$(DL) >> $@
@echo $(DL)#define HAVE_GETHOSTNAME 1$(DL) >> $@
@@ -390,7 +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_STRUCT_IN_ADDR 4$(DL) >> $@
@echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
@echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
ifdef NW_WINSOCK
@@ -415,15 +418,15 @@ ares_build.h: Makefile.netware FORCE
@echo $(DL)** Do not edit this file - it is created by make!$(DL) >> $@
@echo $(DL)** All your changes will be lost!!$(DL) >> $@
@echo $(DL)*/$(DL) >> $@
@echo $(DL)#ifndef NETWARE$(DL) >> $@
@echo $(DL)#error This $(notdir $@) is created for NetWare platform!$(DL) >> $@
@echo $(DL)#endif$(DL) >> $@
@echo $(DL)#ifndef __CARES_BUILD_H$(DL) >> $@
@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) >> $@
-46
View File
@@ -1,46 +0,0 @@
This is c-ares, a forked version of the original ares. The original ares
README follows below, the c-ares specific details are in README.cares
====================================================================
This is ares, an asynchronous resolver library. It is intended for
applications which need to perform DNS queries without blocking, or
need to perform multiple DNS queries in parallel. The primary
examples of such applications are servers which communicate with
multiple clients and programs with graphical user interfaces.
This library implementation is not especially portable to crufty old
systems like SunOS 4. It assumes a compiler which can handle ANSI C
syntax, a system malloc which properly handles realloc(NULL, foo) and
free(NULL), and a reasonably up-to-date <arpa/nameser.h>.
I have attempted to preserve the externally visible behavior of the
BIND resolver in nearly all respects. The API of the library is, of
course, very different from the synchronous BIND API; instead of
invoking a function like res_send() and getting a return value back
indicating the number of bytes in the response, you invoke a function
like ares_send() and give it a callback function to invoke when the
response arrives. You then have to select() on the file descriptors
indicated by ares_fds(), with a timeout given by ares_timeout(). You
call ares_process() when select() returns.
Some features are missing from the current version of ares, relative
to the BIND resolver:
* There is no IPV6 support. [not true for c-ares]
* There is no hostname verification.
* There is no logging of unexpected events.
* There is no debugging-oriented logging.
* There is no YP support.
libares requires an ANSI compiler to compile and use. To build the
library, just run "./configure" and "make". To install it, run "make
install". Run "./configure --help" to see a list of options you can
provide to configure to change how the library builds. libares has no
data files, so you can move the include file and library around freely
without leaving behind any dependencies on old paths. Building the
library will also build the "adig" program, a little toy for trying
out the library. It doesn't get installed.
libares is distributed at athena-dist.mit.edu:pub/ATHENA/ares. Please
send bug reports and comments to ghudson@mit.edu.
+42
View File
@@ -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.
+14 -56
View File
@@ -1,63 +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 full source code is available in the 'c-ares' release archives, and in the
'ares' subdir of the curl CVS source repository.
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
If you find bugs, correct flaws, have questions or have comments in general in
regard to c-ares (or by all means the original ares too), get in touch with us
on the c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares
c-ares is of course distributed under the same MIT-style license as the
original ares.
You'll find all c-ares details and news here:
http://c-ares.haxx.se/
NOTES FOR C-ARES HACKERS
The following notes apply to c-ares version 1.7.0 and later.
* The distributed ares_build.h file is only intended to be used on systems
which can not run the also distributed configure script.
* The distributed ares_build.h file is generated as a copy of ares_build.h.dist
when the c-ares source code distribution archive file is originally created.
* If you check out from CVS on a non-configure platform, you must run the
appropriate buildconf* script to set up ares_build.h and other local files
before being able of compiling the library.
* On systems capable of running the configure script, the configure process
will overwrite the distributed ares_build.h file with one that is suitable
and specific to the library being configured and built, this new file is
generated from the ares_build.h.in template file.
* If you intend to distribute an already compiled c-ares library you _MUST_
also distribute along with it the generated ares_build.h which has been
used to compile it. Otherwise the library will be of no use for the users of
the library that you have built. It is _your_ responsability to provide this
file. No one at the c-ares project can know how you have built the library.
* File ares_build.h includes platform and configuration dependent info,
and must not be modified by anyone. Configure script generates it for you.
* We cannot assume anything else but very basic compiler features being
present. While c-ares requires an ANSI C compiler to build, some of the
earlier ANSI compilers clearly can't deal with some preprocessor operators.
* Newlines must remain unix-style for older compilers' sake.
* Comments must be written in the old-style /* unnested C-fashion */
AmigaOS versions are distributed at:
http://aminet.net/package/comm/tcp/c-ares
and
http://aminet.net/package/dev/gcc/c-ares-src
+64
View File
@@ -0,0 +1,64 @@
c-ares
======
[![Build Status](https://travis-ci.org/c-ares/c-ares.svg?branch=master)](https://travis-ci.org/c-ares/c-ares)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/03i7151772eq3wn3/branch/master?svg=true)](https://ci.appveyor.com/project/c-ares/c-ares)
[![Coverage Status](https://coveralls.io/repos/c-ares/c-ares/badge.svg?branch=master&service=github)](https://coveralls.io/github/c-ares/c-ares?branch=master)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/291/badge)](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
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/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
on the c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares
c-ares is of course distributed under the same MIT-style license as the
original ares.
You'll find all c-ares details and news here:
https://c-ares.haxx.se/
Notes for c-ares hackers
------------------------
* The distributed `ares_build.h` file is only intended to be used on systems
which can not run the also distributed configure script.
* The distributed `ares_build.h` file is generated as a copy of `ares_build.h.dist`
when the c-ares source code distribution archive file is originally created.
* If you check out from git on a non-configure platform, you must run the
appropriate `buildconf*` script to set up `ares_build.h` and other local files
before being able 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
and specific to the library being configured and built, this new file is
generated from the `ares_build.h.in` template file.
* If you intend to distribute an already compiled c-ares library you **MUST**
also distribute along with it the generated `ares_build.h` which has been
used to compile it. Otherwise the library will be of no use for the users of
the library that you have built. It is **your** responsibility to provide this
file. No one at the c-ares project can know how you have built the library.
* File `ares_build.h` includes platform and configuration dependent info,
and must not be modified by anyone. Configure script generates it for you.
* We cannot assume anything else but very basic compiler features being
present. While c-ares requires an ANSI C compiler to build, some of the
earlier ANSI compilers clearly can't deal with some preprocessor operators.
* Newlines must remain unix-style for older compilers' sake.
* Comments must be written in the old-style /* unnested C-fashion */
* Try to keep line lengths below 80 columns.
+24 -1
View File
@@ -1,4 +1,3 @@
$Id$
___ __ _ _ __ ___ ___
@@ -41,6 +40,30 @@
library version it is using.
How to install using MSVC from the command line
-----------------------------------------------
In order to allow easy usage of c-ares libraries it may be convenient to
install c-ares libraries and header files to a common subdirectory tree.
Once that c-ares libraries have been built using procedure described above,
use same command prompt window to define environment variable INSTALL_DIR
to designate the top subdirectory where installation of c-ares libraries and
header files will be done.
> set INSTALL_DIR=c:\c-ares
Afterwards, run following command to actually perform the installation:
> nmake -f Makefile.msvc install
Installation procedure will copy c-ares libraries to subdirectory 'lib' and
c-ares header files to subdirectory 'include' below the INSTALL_DIR subdir.
When environment variable INSTALL_DIR is not defined, installation is done
to c-ares source folder where Makefile.msvc file is located.
How to build using Visual Studio 6 IDE
--------------------------------------
+40 -30
View File
@@ -1,36 +1,46 @@
This is what's new and changed in the c-ares 1.7.0 release:
c-ares version 1.12.0
Changed:
Changes:
o in6_addr is not used in ares.h anymore, but a private ares_in6_addr is
instead declared and used
o ares_gethostbyname() now supports 'AF_UNSPEC' as a family for resolving
either AF_INET6 or AF_INET
o a build-time configured ares_socklen_t is now used instead of socklen_t
o new ares_library_init() and ares_library_cleanup() functions
o new --enable-curldebug configure option
o ARES_ECANCELLED is now sent as reason for ares_cancel()
o added ares_parse_srv_reply()
o added ares_parse_txt_reply()
o added ares_free_data()
o new --enable-symbol-hiding configure option
o new Makefile.msvc for any MSVC compiler or MS Visual Studio version
o addrttl and addr6ttl structs renamed to ares_addrttl and ares_addr6ttl
o naming convention for libraries built with MSVC, see README.msvc
Fixed:
o ares_parse_*_reply() functions now return ARES_EBADRESP instead of
ARES_EBADNAME if the name in the response failed to decode
o only expose/export symbols starting with 'ares_'
o fix \Device\TCP handle leaks triggered by buggy iphlpapi.dll
o init without internet gone no longer fails
o out of bounds memory overwrite triggered with malformed /etc/hosts file
o function prototypes in man pages out of sync with ares.h
o api: add ARES_OPT_NOROTATE optmask value
Bug fixes:
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:
Phil Blundell, Japheth Cleaver, Yang Tse, Gregor Jasny, Joshua Kwan,
Timo Teras, Jakub Hrozek, John Engelhart, Larry Lansing
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
+5
View File
@@ -1,6 +1,11 @@
TODO
====
ares_reinit()
- To allow an app to force a re-read of /etc/resolv.conf etc, pretty much
like the res_init() resolver function offers
ares_gethostbyname
- When built to support IPv6, it needs to also support PF_UNSPEC or similar,
+46 -56
View File
@@ -30,7 +30,7 @@ CURL_DEF_TOKEN $1
],[
tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
"$GREP" CURL_DEF_TOKEN 2>/dev/null | \
"$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
"$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
"$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
tmp_exp=""
@@ -145,7 +145,7 @@ AC_DEFUN([CARES_CHECK_AIX_ALL_SOURCE], [
dnl CURL_CHECK_HEADER_WINDOWS
dnl -------------------------------------------------
dnl Check for compilable and valid windows.h header
dnl Check for compilable and valid windows.h header
AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
@@ -207,18 +207,13 @@ AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
])
fi
])
case "$ac_cv_native_windows" in
yes)
AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
[Define to 1 if you are building a native Windows target.])
;;
esac
AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$ac_cv_native_windows" = xyes)
])
dnl CURL_CHECK_HEADER_WINSOCK
dnl -------------------------------------------------
dnl Check for compilable and valid winsock.h header
dnl Check for compilable and valid winsock.h header
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
@@ -255,7 +250,7 @@ AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
dnl CURL_CHECK_HEADER_WINSOCK2
dnl -------------------------------------------------
dnl Check for compilable and valid winsock2.h header
dnl Check for compilable and valid winsock2.h header
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
@@ -433,13 +428,13 @@ AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
dnl CURL_CHECK_FUNC_GETNAMEINFO
dnl -------------------------------------------------
dnl Test if the getnameinfo function is available,
dnl Test if the getnameinfo function is available,
dnl and check the types of five of its arguments.
dnl If the function succeeds HAVE_GETNAMEINFO will be
dnl defined, defining the types of the arguments in
dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
dnl and also defining the type qualifier of first
dnl and also defining the type qualifier of first
dnl argument in GETNAMEINFO_QUAL_ARG1.
AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
@@ -523,7 +518,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#undef inline
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@@ -534,7 +529,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
#endif
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#include <winsock2.h>
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
@@ -634,7 +629,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
dnl TYPE_SOCKADDR_STORAGE
dnl -------------------------------------------------
dnl Check for struct sockaddr_storage. Most IPv6-enabled
dnl Check for struct sockaddr_storage. Most IPv6-enabled
dnl hosts have it, but AIX 4.3 is one known exception.
AC_DEFUN([TYPE_SOCKADDR_STORAGE],
@@ -680,7 +675,7 @@ AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
netdb.h netinet/in.h arpa/inet.h)
#
AC_CACHE_CHECK([for working NI_WITHSCOPEID],
AC_CACHE_CHECK([for working NI_WITHSCOPEID],
[ac_cv_working_ni_withscopeid], [
AC_RUN_IFELSE([
AC_LANG_PROGRAM([[
@@ -772,11 +767,11 @@ AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
dnl CURL_CHECK_FUNC_RECV
dnl -------------------------------------------------
dnl Test if the socket recv() function is available,
dnl and check its return type and the types of its
dnl arguments. If the function succeeds HAVE_RECV
dnl will be defined, defining the types of the arguments
dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
dnl Test if the socket recv() function is available,
dnl and check its return type and the types of its
dnl arguments. If the function succeeds HAVE_RECV
dnl will be defined, defining the types of the arguments
dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
dnl and RECV_TYPE_ARG4, defining the type of the function
dnl return value in RECV_TYPE_RETV.
@@ -788,7 +783,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
AC_MSG_CHECKING([for recv])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
#undef inline
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@@ -832,7 +827,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
if test "$curl_cv_func_recv_args" = "unknown"; then
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#undef inline
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@@ -905,13 +900,13 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
dnl CURL_CHECK_FUNC_SEND
dnl -------------------------------------------------
dnl Test if the socket send() function is available,
dnl and check its return type and the types of its
dnl arguments. If the function succeeds HAVE_SEND
dnl will be defined, defining the types of the arguments
dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
dnl Test if the socket send() function is available,
dnl and check its return type and the types of its
dnl arguments. If the function succeeds HAVE_SEND
dnl will be defined, defining the types of the arguments
dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
dnl and SEND_TYPE_ARG4, defining the type of the function
dnl return value in SEND_TYPE_RETV, and also defining the
dnl return value in SEND_TYPE_RETV, and also defining the
dnl type qualifier of second argument in SEND_QUAL_ARG2.
AC_DEFUN([CURL_CHECK_FUNC_SEND], [
@@ -922,7 +917,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
AC_MSG_CHECKING([for send])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
#undef inline
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@@ -966,7 +961,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
if test "$curl_cv_func_send_args" = "unknown"; then
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#undef inline
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@@ -1090,7 +1085,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
AC_MSG_CHECKING([for recvfrom])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
#undef inline
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@@ -1131,12 +1126,12 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
for recvfrom_arg2 in 'char *' 'void *'; do
for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
for recvfrom_arg4 in 'int' 'unsigned int'; do
for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
for recvfrom_arg5 in 'struct sockaddr *' 'void *' 'const struct sockaddr *'; do
for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
if test "$curl_cv_func_recvfrom_args" = "unknown"; then
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#undef inline
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@@ -1199,7 +1194,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
shift
#
recvfrom_ptrt_arg2=$[2]
recvfrom_ptrt_arg5=$[5]
recvfrom_qual_ptrt_arg5=$[5]
recvfrom_ptrt_arg6=$[6]
#
AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
@@ -1221,12 +1216,25 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
;;
esac
#
case "$recvfrom_qual_ptrt_arg5" in
const*)
recvfrom_qual_arg5=const
recvfrom_ptrt_arg5=`echo $recvfrom_qual_ptrt_arg5 | sed 's/^const //'`
;;
*)
recvfrom_qual_arg5=
recvfrom_ptrt_arg5=$recvfrom_qual_ptrt_arg5
;;
esac
#
recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
#
AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
[Define to the type pointed by arg 2 for recvfrom.])
AC_DEFINE_UNQUOTED(RECVFROM_QUAL_ARG5, $recvfrom_qual_arg5,
[Define to the type qualifier pointed by arg 5 for recvfrom.])
AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
[Define to the type pointed by arg 5 for recvfrom.])
AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
@@ -1273,7 +1281,7 @@ AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#undef inline
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@@ -1324,7 +1332,7 @@ AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#undef inline
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@@ -1735,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
@@ -1884,7 +1874,7 @@ dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
AC_DEFUN([CARES_CHECK_STRUCT], [
AC_MSG_CHECKING([for struct $2])
AC_TRY_COMPILE([$1],
AC_TRY_COMPILE([$1],
[
struct $2 struct_instance;
], ac_struct="yes", ac_found="no")
+53
View File
@@ -0,0 +1,53 @@
.TH COUNTRY "1" "April 2011" "c-ares utilities"
.SH NAME
country \- print the country where an IPv4 address or host is located
.SH SYNOPSIS
.B country
[\fIOPTION\fR]... \fIHOST\fR...
.SH DESCRIPTION
.PP
.\" Add any additional description here
.PP
Print the country where HOST (an IPv4 address or hostname) is located,
using the countries.nerd.dk DNS domain to identify the country.
.PP
This utility comes with the \fBc\-ares\fR asynchronous resolver library.
.SH OPTIONS
.TP
\fB\-d\fR
Print some extra debugging output.
.TP
\fB\-h\fR, \fB\-\-help\fR
Display this help and exit.
.TP
\fB\-v\fR
Be more verbose. Print extra information.
.SH "REPORTING BUGS"
Report bugs to the c-ares mailing list:
\fBhttp://cool.haxx.se/mailman/listinfo/c-ares\fR
.SH "SEE ALSO"
.PP
adig(1), ahost(1).
.PP
The DNSBL countries.nerd.dk
.br
\fBhttp://countries.nerd.dk/\fR
.SH COPYRIGHT
This utility is based on code/ideas contained in sofware written by Greg Hudson (ares)
carrying the following notice:
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.br
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.
.br
No further copyright claims are being made by the author(s) of this utility.
.SH AUTHOR
Gisle Vanem
+38 -31
View File
@@ -1,5 +1,4 @@
/*
* $Id$
*
* IP-address/hostname to country converter.
*
@@ -16,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.
*
@@ -35,14 +34,6 @@
#include "ares_setup.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
@@ -50,16 +41,14 @@
#if defined(WIN32) && !defined(WATT32)
#include <winsock.h>
#else
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#include "ares.h"
#include "ares_getopt.h"
#include "inet_net_pton.h"
#include "inet_ntop.h"
#include "ares_nowarn.h"
#ifndef HAVE_STRDUP
# include "ares_strdup.h"
@@ -80,16 +69,27 @@
#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 { \
if (verbose > 0) \
printf fmt ; \
} while (0)
} WHILE_FALSE
static void wait_ares(ares_channel channel);
static void callback(void *arg, int status, int timeouts, struct hostent *host);
@@ -110,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;
@@ -172,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);
@@ -211,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);
}
}
@@ -534,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,8 +564,8 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
unsigned long ip;
ip = ntohl(addr.s_addr);
z0 = tolower(cname[0]);
z1 = tolower(cname[1]);
z0 = TOLOWER(cname[0]);
z1 = TOLOWER(cname[1]);
ccopy = strdup(cname);
dot_4 = NULL;
@@ -570,32 +575,35 @@ 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;
}
}
else if (ver_2)
{
z0 = tolower(dot_4[1]);
z1 = tolower(dot_4[2]);
z0 = TOLOWER(dot_4[1]);
z1 = TOLOWER(dot_4[2]);
if (z0 != 'z' && z1 != 'z')
{
printf("Unexpected CNAME %s (ver_2)\n", cname);
free(ccopy);
return;
}
}
else
{
printf("Unexpected CNAME %s (ver?)\n", cname);
free(ccopy);
return;
}
if (ver_1)
{
ccode_A2[0] = (char)tolower(cname[2]);
ccode_A2[1] = (char)tolower(cname[3]);
ccode_A2[0] = (char)TOLOWER(cname[2]);
ccode_A2[1] = (char)TOLOWER(cname[3]);
ccode_A2[2] = '\0';
}
else
@@ -625,4 +633,3 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
}
free(ccopy);
}
+71
View File
@@ -0,0 +1,71 @@
.TH DIG "1" "April 2011" "c-ares utilities"
.SH NAME
dig \- print information collected from Domain Name System (DNS) servers
.SH SYNOPSIS
.B dig
[\fIOPTION\fR]... \fINAME\fR...
.SH DESCRIPTION
.PP
.\" Add any additional description here
.PP
Send queries to DNS servers about \fINAME\fR and print received
information, where \fINAME\fR is a valid DNS name (e.g. www.example.com,
1.2.3.10.in-addr.arpa).
.PP
This utility comes with the \fBc\-ares\fR asynchronous resolver library.
.SH OPTIONS
.TP
\fB\-c\fR class
Set the query class.
Possible values for class are
NY, CHAOS, HS, IN (default).
.TP
\fB\-d\fR
Print some extra debugging output.
.TP
\fB\-f\fR flag
Add a flag.
Possible values for flag are
igntc, noaliases, norecurse, primary, stayopen, usevc.
.TP
\fB\-h\fR, \fB\-\-help\fR
Display this help and exit.
.TP
\fB\-T\fR port
Use specified TCP port to connect to DNS server.
.TP
\fB\-s\fR server
Connect to specified DNS server, instead of the system's default one(s).
.TP
\fB\-t\fR type
Query records of specified type.
Possible values for type are
A (default), AAAA, AFSDB, ANY, AXFR, CNAME, GPOS, HINFO, ISDN, KEY, LOC, MAILA,
MAILB, MB, MD, MF, MG, MINFO, MR, MX, NAPTR, NS, NSAP, NSAP_PTR, NULL,
PTR, PX, RP, RT, SIG, SOA, SRV, TXT, WKS, X25,
.TP
\fB\-U\fR port
Use specified UDP port to connect to DNS server.
.SH "REPORTING BUGS"
Report bugs to the c-ares mailing list:
\fBhttp://cool.haxx.se/mailman/listinfo/c-ares\fR
.SH "SEE ALSO"
.PP
acountry(1), ahost(1).
.SH COPYRIGHT
This utility is based on code/ideas contained in sofware written by Greg Hudson (ares)
carrying the following notice:
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.br
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.
.br
No further copyright claims are being made by the author(s) of this utility.
+153 -58
View File
@@ -1,6 +1,5 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
* $Id$
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -17,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
@@ -38,27 +34,14 @@
# include <arpa/nameser_compat.h>
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include "ares.h"
#include "ares_dns.h"
#include "inet_ntop.h"
#include "inet_net_pton.h"
#include "ares_getopt.h"
#include "ares_nowarn.h"
#ifndef HAVE_STRDUP
# include "ares_strdup.h"
@@ -79,14 +62,26 @@
#undef WIN32 /* Redefined in MingW headers */
#endif
/* Mac OS X portability check */
#ifndef T_SRV
#define T_SRV 33 /* server selection */
# define T_SRV 33 /* Server selection */
#endif
/* AIX portability check */
#ifndef T_NAPTR
#define T_NAPTR 35 /* naming authority pointer */
# define T_NAPTR 35 /* Naming authority pointer */
#endif
#ifndef T_DS
# define T_DS 43 /* Delegation Signer (RFC4034) */
#endif
#ifndef T_SSHFP
# define T_SSHFP 44 /* SSH Key Fingerprint (RFC4255) */
#endif
#ifndef T_RRSIG
# define T_RRSIG 46 /* Resource Record Signature (RFC4034) */
#endif
#ifndef T_NSEC
# define T_NSEC 47 /* Next Secure (RFC4034) */
#endif
#ifndef T_DNSKEY
# define T_DNSKEY 48 /* DNS Public Key (RFC4034) */
#endif
struct nv {
@@ -147,6 +142,11 @@ static const struct nv types[] = {
{ "MAILB", T_MAILB },
{ "MAILA", T_MAILA },
{ "NAPTR", T_NAPTR },
{ "DS", T_DS },
{ "SSHFP", T_SSHFP },
{ "RRSIG", T_RRSIG },
{ "NSEC", T_NSEC },
{ "DNSKEY", T_DNSKEY },
{ "ANY", T_ANY }
};
static const int ntypes = sizeof(types) / sizeof(types[0]);
@@ -164,8 +164,6 @@ static const char *rcodes[] = {
"(unknown)", "(unknown)", "(unknown)", "(unknown)", "NOCHANGE"
};
static struct in_addr inaddr;
static void callback(void *arg, int status, int timeouts,
unsigned char *abuf, int alen);
static const unsigned char *display_question(const unsigned char *aptr,
@@ -176,6 +174,11 @@ static const unsigned char *display_rr(const unsigned char *aptr,
static const char *type_name(int type);
static const char *class_name(int dnsclass);
static void usage(void);
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)
{
@@ -186,6 +189,7 @@ int main(int argc, char **argv)
struct hostent *hostent;
fd_set read_fds, write_fds;
struct timeval *tvp, tv;
struct ares_addr_node *srvr, *servers = NULL;
#ifdef USE_WINSOCK
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
@@ -193,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)
{
@@ -227,27 +233,56 @@ int main(int argc, char **argv)
break;
case 's':
/* Add a server, and specify servers in the option mask. */
if (ares_inet_pton(AF_INET, optarg, &inaddr) <= 0)
{
hostent = gethostbyname(optarg);
if (!hostent || hostent->h_addrtype != AF_INET)
{
fprintf(stderr, "adig: server %s not found.\n", optarg);
return 1;
}
memcpy(&inaddr, hostent->h_addr, sizeof(struct in_addr));
}
options.servers = realloc(options.servers, (options.nservers + 1)
* sizeof(struct in_addr));
if (!options.servers)
/* User-specified name servers override default ones. */
srvr = malloc(sizeof(struct ares_addr_node));
if (!srvr)
{
fprintf(stderr, "Out of memory!\n");
destroy_addr_list(servers);
return 1;
}
memcpy(&options.servers[options.nservers], &inaddr,
sizeof(struct in_addr));
options.nservers++;
append_addr_list(&servers, srvr);
if (ares_inet_pton(AF_INET, optarg, &srvr->addr.addr4) > 0)
srvr->family = AF_INET;
else if (ares_inet_pton(AF_INET6, optarg, &srvr->addr.addr6) > 0)
srvr->family = AF_INET6;
else
{
hostent = gethostbyname(optarg);
if (!hostent)
{
fprintf(stderr, "adig: server %s not found.\n", optarg);
destroy_addr_list(servers);
return 1;
}
switch (hostent->h_addrtype)
{
case AF_INET:
srvr->family = AF_INET;
memcpy(&srvr->addr.addr4, hostent->h_addr,
sizeof(srvr->addr.addr4));
break;
case AF_INET6:
srvr->family = AF_INET6;
memcpy(&srvr->addr.addr6, hostent->h_addr,
sizeof(srvr->addr.addr6));
break;
default:
fprintf(stderr,
"adig: server %s unsupported address family.\n", optarg);
destroy_addr_list(servers);
return 1;
}
}
/* Notice that calling ares_init_options() without servers in the
* options struct and with ARES_OPT_SERVERS set simultaneously in
* the options mask, results in an initialization with no servers.
* When alternative name servers have been specified these are set
* later calling ares_set_servers() overriding any existing server
* configuration. To prevent initial configuration with default
* servers that will be discarded later, ARES_OPT_SERVERS is set.
* If this flag is not set here the result shall be the same but
* ares_init_options() will do needless work. */
optmask |= ARES_OPT_SERVERS;
break;
@@ -308,6 +343,18 @@ int main(int argc, char **argv)
return 1;
}
if(servers)
{
status = ares_set_servers(channel, servers);
destroy_addr_list(servers);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_init_options: %s\n",
ares_strerror(status));
return 1;
}
}
/* Initiate the queries, one per command-line argument. If there is
* only one query to do, supply NULL as the callback argument;
* otherwise, supply the query name as an argument so we can
@@ -331,9 +378,9 @@ int main(int argc, char **argv)
break;
tvp = ares_timeout(channel, NULL, &tv);
count = select(nfds, &read_fds, &write_fds, NULL, tvp);
if (count < 0 && SOCKERRNO != EINVAL)
if (count < 0 && (status = SOCKERRNO) != EINVAL)
{
perror("select");
printf("select fail: %d", status);
return 1;
}
ares_process(channel, &read_fds, &write_fds);
@@ -590,7 +637,7 @@ static const unsigned char *display_rr(const unsigned char *aptr,
*/
if (dlen < 2)
return NULL;
printf("\t%d", DNS__16BIT(aptr));
printf("\t%d", (int)DNS__16BIT(aptr));
status = ares_expand_name(aptr + 2, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS)
return NULL;
@@ -617,10 +664,10 @@ static const unsigned char *display_rr(const unsigned char *aptr,
p += len;
if (p + 20 > aptr + dlen)
return NULL;
printf("\t\t\t\t\t\t( %lu %lu %lu %lu %lu )",
(unsigned long)DNS__32BIT(p), (unsigned long)DNS__32BIT(p+4),
(unsigned long)DNS__32BIT(p+8), (unsigned long)DNS__32BIT(p+12),
(unsigned long)DNS__32BIT(p+16));
printf("\t\t\t\t\t\t( %u %u %u %u %u )",
DNS__32BIT(p), DNS__32BIT(p+4),
DNS__32BIT(p+8), DNS__32BIT(p+12),
DNS__32BIT(p+16));
break;
case T_TXT:
@@ -664,9 +711,9 @@ static const unsigned char *display_rr(const unsigned char *aptr,
* priority, weight, and port, followed by a domain name.
*/
printf("\t%d", DNS__16BIT(aptr));
printf(" %d", DNS__16BIT(aptr + 2));
printf(" %d", DNS__16BIT(aptr + 4));
printf("\t%d", (int)DNS__16BIT(aptr));
printf(" %d", (int)DNS__16BIT(aptr + 2));
printf(" %d", (int)DNS__16BIT(aptr + 4));
status = ares_expand_name(aptr + 6, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS)
@@ -677,8 +724,8 @@ static const unsigned char *display_rr(const unsigned char *aptr,
case T_NAPTR:
printf("\t%d", DNS__16BIT(aptr)); /* order */
printf(" %d\n", DNS__16BIT(aptr + 2)); /* preference */
printf("\t%d", (int)DNS__16BIT(aptr)); /* order */
printf(" %d\n", (int)DNS__16BIT(aptr + 2)); /* preference */
p = aptr + 4;
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
@@ -702,13 +749,20 @@ static const unsigned char *display_rr(const unsigned char *aptr,
ares_free_string(name.as_char);
p += len;
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t\t\t\t\t\t%s", name.as_char);
ares_free_string(name.as_char);
break;
case T_DS:
case T_SSHFP:
case T_RRSIG:
case T_NSEC:
case T_DNSKEY:
printf("\t[RR type parsing unavailable]");
break;
default:
printf("\t[Unknown RR; cannot parse]");
@@ -745,7 +799,48 @@ 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)
{
while(head)
{
struct ares_addr_node *detached = head;
head = head->next;
free(detached);
}
}
static void append_addr_list(struct ares_addr_node **head,
struct ares_addr_node *node)
{
struct ares_addr_node *last;
node->next = NULL;
if(*head)
{
last = *head;
while(last->next)
last = last->next;
last->next = node;
}
else
*head = node;
}
+58
View File
@@ -0,0 +1,58 @@
.TH HOST "1" "April 2011" "c-ares utilities"
.SH NAME
host \- print the A or AAAA record associated with a hostname or IP address
.SH SYNOPSIS
.B host
[\fIOPTION\fR]... \fIHOST\fR...
.SH DESCRIPTION
.PP
.\" Add any additional description here
.PP
Look up the DNS A or AAAA record associated with HOST (a hostname or an
IP address).
.PP
This utility comes with the \fBc\-ares\fR asynchronous resolver library.
.SH OPTIONS
.TP
\fB\-d\fR
Print some extra debugging output.
.TP
\fB\-h\fR, \fB\-\-help\fR
Display this help and exit.
.TP
\fB\-t\fR type
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
.SH "SEE ALSO"
.PP
acountry(1), adig(1).
.SH COPYRIGHT
This utility is based on code/ideas contained in sofware written by Greg Hudson (ares)
carrying the following notice:
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.br
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.
.br
No further copyright claims are being made by the author(s) of this utility.
+38 -20
View File
@@ -1,6 +1,5 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
* $Id$
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -18,31 +17,20 @@
#include "ares_setup.h"
#if !defined(WIN32) || defined(WATT32)
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_dns.h"
#include "inet_ntop.h"
#include "inet_net_pton.h"
#include "ares_getopt.h"
#include "ares_ipv6.h"
#include "ares_nowarn.h"
#ifndef HAVE_STRDUP
# include "ares_strdup.h"
@@ -62,14 +50,20 @@
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;
struct timeval *tvp, tv;
struct in_addr addr4;
struct in6_addr addr6;
struct ares_in6_addr addr6;
prog = argv[0];
#ifdef USE_WINSOCK
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
@@ -77,6 +71,8 @@ int main(int argc, char **argv)
WSAStartup(wVersionRequested, &wsaData);
#endif
memset(&options, 0, sizeof(options));
status = ares_library_init(ARES_LIB_INIT_ALL);
if (status != ARES_SUCCESS)
{
@@ -84,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)
{
@@ -93,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;
@@ -113,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));
@@ -142,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);
}
@@ -197,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);
}
+82
View File
@@ -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
+11
View File
@@ -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
+159 -16
View File
@@ -1,7 +1,6 @@
/* $Id$ */
/* Copyright 1998, 2009 by the Massachusetts Institute of Technology.
* Copyright (C) 2007-2009 by Daniel Stenberg
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2007-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -38,7 +37,8 @@
libc5-based Linux systems. Only include it on system that are known to
require it! */
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY)
defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \
defined(ANDROID) || defined(__ANDROID__)
#include <sys/select.h>
#endif
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
@@ -49,6 +49,12 @@
# include <netinet/in.h>
# include <sys/socket.h>
# include <tcp.h>
#elif defined(_WIN32_WCE)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# include <winsock.h>
#elif defined(WIN32)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
@@ -69,22 +75,18 @@ extern "C" {
** c-ares external API function linkage decorations.
*/
#if !defined(CARES_STATICLIB) && \
(defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
/* __declspec function decoration for Win32 and Symbian DLL's */
#ifdef CARES_STATICLIB
# define CARES_EXTERN
#elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
# if defined(CARES_BUILDING_LIBRARY)
# define CARES_EXTERN __declspec(dllexport)
# else
# define CARES_EXTERN __declspec(dllimport)
# endif
#elif defined(CARES_BUILDING_LIBRARY) && defined(CARES_SYMBOL_HIDING)
# define CARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN
#else
/* visibility function decoration for other cases */
# if !defined(CARES_SYMBOL_HIDING) || \
defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
# define CARES_EXTERN
# else
# define CARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN
# endif
# define CARES_EXTERN
#endif
@@ -137,6 +139,7 @@ extern "C" {
#define ARES_FLAG_NOSEARCH (1 << 5)
#define ARES_FLAG_NOALIASES (1 << 6)
#define ARES_FLAG_NOCHECKRESP (1 << 7)
#define ARES_FLAG_EDNS (1 << 8)
/* Option mask values */
#define ARES_OPT_FLAGS (1 << 0)
@@ -154,6 +157,8 @@ extern "C" {
#define ARES_OPT_SOCK_RCVBUF (1 << 12)
#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)
@@ -199,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)
/*
@@ -259,6 +265,7 @@ struct ares_options {
void *sock_state_cb_data;
struct apattern *sortlist;
int nsort;
int ednspsz;
};
struct hostent;
@@ -289,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);
@@ -314,10 +332,31 @@ CARES_EXTERN void ares_destroy(ares_channel channel);
CARES_EXTERN void ares_cancel(ares_channel channel);
/* These next 3 configure local binding for the out-going socket
* connection. Use these to specify source IP and/or network device
* on multi-homed systems.
*/
CARES_EXTERN void ares_set_local_ip4(ares_channel channel, unsigned int local_ip);
/* local_ip6 should be 16 bytes in length */
CARES_EXTERN void ares_set_local_ip6(ares_channel channel,
const unsigned char* local_ip6);
/* local_dev_name should be null terminated. */
CARES_EXTERN void ares_set_local_dev(ares_channel channel,
const char* local_dev_name);
CARES_EXTERN void ares_set_socket_callback(ares_channel channel,
ares_sock_create_callback callback,
void *user_data);
CARES_EXTERN void ares_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,
@@ -368,7 +407,7 @@ CARES_EXTERN int ares_fds(ares_channel channel,
fd_set *write_fds);
CARES_EXTERN int ares_getsock(ares_channel channel,
int *socks,
ares_socket_t *socks,
int numsocks);
CARES_EXTERN struct timeval *ares_timeout(ares_channel channel,
@@ -383,6 +422,15 @@ CARES_EXTERN void ares_process_fd(ares_channel channel,
ares_socket_t read_fd,
ares_socket_t write_fd);
CARES_EXTERN 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);
CARES_EXTERN int ares_mkquery(const char *name,
int dnsclass,
int type,
@@ -434,12 +482,49 @@ struct ares_srv_reply {
unsigned short port;
};
struct ares_mx_reply {
struct ares_mx_reply *next;
char *host;
unsigned short priority;
};
struct ares_txt_reply {
struct ares_txt_reply *next;
unsigned char *txt;
size_t length; /* length excludes null termination */
};
/* 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;
unsigned char *service;
unsigned char *regexp;
char *replacement;
unsigned short order;
unsigned short preference;
};
struct ares_soa_reply {
char *nsname;
char *hostmaster;
unsigned int serial;
unsigned int refresh;
unsigned int retry;
unsigned int expire;
unsigned int minttl;
};
/*
** Parse the buffer, starting at *abuf and of length alen bytes, previously
** obtained from an ares_search call. Put the results in *host, if nonnull.
@@ -475,10 +560,26 @@ CARES_EXTERN int ares_parse_srv_reply(const unsigned char* abuf,
int alen,
struct ares_srv_reply** srv_out);
CARES_EXTERN int ares_parse_mx_reply(const unsigned char* abuf,
int alen,
struct ares_mx_reply** mx_out);
CARES_EXTERN int ares_parse_txt_reply(const unsigned char* abuf,
int alen,
struct ares_txt_reply** txt_out);
CARES_EXTERN 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);
CARES_EXTERN int ares_parse_soa_reply(const unsigned char* abuf,
int alen,
struct ares_soa_reply** soa_out);
CARES_EXTERN void ares_free_string(void *str);
CARES_EXTERN void ares_free_hostent(struct hostent *host);
@@ -487,6 +588,48 @@ CARES_EXTERN void ares_free_data(void *dataptr);
CARES_EXTERN const char *ares_strerror(int code);
struct ares_addr_node {
struct ares_addr_node *next;
int family;
union {
struct in_addr addr4;
struct ares_in6_addr addr6;
} 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);
CARES_EXTERN int ares_inet_pton(int af, const char *src, void *dst);
#ifdef __cplusplus
}
#endif
+3 -9
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
@@ -17,11 +16,6 @@
#include "ares_setup.h"
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "ares.h"
#include "ares_private.h"
@@ -36,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;
+24 -27
View File
@@ -1,6 +1,5 @@
/* $Id$ */
/* Copyright 1998, 2009 by the Massachusetts Institute of Technology.
/* Copyright 1998, 2011 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -17,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
@@ -31,7 +27,8 @@
#endif
#include "ares.h"
#include "inet_net_pton.h"
#include "ares_inet_net_pton.h"
#include "ares_nowarn.h"
#include "ares_private.h"
int ares__get_hostent(FILE *fp, int family, struct hostent **host)
@@ -97,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;
@@ -146,7 +143,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
{
/* Actual network address family and length. */
addr.family = AF_INET;
addrlen = sizeof(struct in_addr);
addrlen = sizeof(addr.addrV4);
}
}
if ((family == AF_INET6) || ((family == AF_UNSPEC) && (!addrlen)))
@@ -155,7 +152,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
{
/* Actual network address family and length. */
addr.family = AF_INET6;
addrlen = sizeof(struct in6_addr);
addrlen = sizeof(addr.addrV6);
}
}
if (!addrlen)
@@ -167,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;
@@ -176,25 +173,25 @@ 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)
memcpy(hostent->h_addr_list[0], &addr.addrV4, sizeof(struct in_addr));
memcpy(hostent->h_addr_list[0], &addr.addrV4, sizeof(addr.addrV4));
else
memcpy(hostent->h_addr_list[0], &addr.addrV6, sizeof(struct in6_addr));
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;
@@ -210,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;
@@ -220,11 +217,11 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
break;
/* Copy actual network address family and length. */
hostent->h_addrtype = addr.family;
hostent->h_length = (int)addrlen;
hostent->h_addrtype = aresx_sitoss(addr.family);
hostent->h_length = aresx_uztoss(addrlen);
/* Free line buffer. */
free(line);
ares_free(line);
/* Return hostent successfully */
*host = hostent;
@@ -234,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)
{
@@ -242,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;
}
+14 -8
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
@@ -16,10 +15,9 @@
*/
#include "ares_setup.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_nowarn.h"
#include "ares_private.h"
/* This is an internal function. Its contract is to read a line from
@@ -38,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;
@@ -46,7 +44,9 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
for (;;)
{
if (!fgets(*buf + offset, (int)(*bufsize - offset), fp))
int bytestoread = aresx_uztosi(*bufsize - offset);
if (!fgets(*buf + offset, bytestoread, fp))
return (offset != 0) ? 0 : (ferror(fp)) ? ARES_EFILE : ARES_EOF;
len = offset + strlen(*buf + offset);
if ((*buf)[len - 1] == '\n')
@@ -55,11 +55,17 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
break;
}
offset = len;
if(len < *bufsize - 1)
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 -2
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright (C) 2008 by Daniel Stenberg et al
*
@@ -57,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);
+95
View File
@@ -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 */
+8 -7
View File
@@ -1,9 +1,8 @@
#ifndef __CARES_BUILD_H
#define __CARES_BUILD_H
/* $Id$ */
/* Copyright (C) 2009 by Daniel Stenberg et al
/* Copyright (C) 2009 - 2013 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
@@ -65,7 +64,7 @@
* created.
*
* File ares_build.h.dist is not included in the distribution archive.
* File ares_build.h is not present in the CVS tree.
* File ares_build.h is not present in the git tree.
*
* The distributed ares_build.h file is only intended to be used on systems
* which can not run the also distributed configure script.
@@ -75,7 +74,7 @@
* and specific to the library being configured and built, which is generated
* from the ares_build.h.in template file.
*
* If you check out from CVS on a non-configure platform, you must run the
* 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.
*
*/
@@ -217,10 +216,12 @@
/* ===================================== */
#elif defined(__GNUC__)
# if defined(__i386__) || defined(__ppc__)
# define CARES_SIZEOF_LONG 4
# elif defined(__x86_64__) || defined(__ppc64__)
# 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
-17
View File
@@ -1,7 +1,6 @@
#ifndef __CARES_BUILD_H
#define __CARES_BUILD_H
/* $Id$ */
/* Copyright (C) 2009 by Daniel Stenberg et al
*
@@ -51,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 */
/* ================================================================ */
@@ -96,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 -6
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
@@ -24,12 +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.
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)
+22 -23
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright (C) 2004 by Daniel Stenberg et al
*
@@ -15,7 +14,7 @@
#include "ares_setup.h"
#include <assert.h>
#include <stdlib.h>
#include "ares.h"
#include "ares_private.h"
@@ -27,33 +26,33 @@
void ares_cancel(ares_channel channel)
{
struct query *query;
struct list_node list_head_copy;
struct list_node* list_head;
struct list_node* list_node;
int i;
list_head = &(channel->all_queries);
for (list_node = list_head->next; list_node != list_head; )
if (!ares__is_list_empty(&(channel->all_queries)))
{
query = list_node->data;
list_node = list_node->next; /* since we're deleting the query */
query->callback(query->arg, ARES_ECANCELLED, 0, NULL, 0);
ares__free_query(query);
/* Swap list heads, so that only those queries which were present on entry
* into this function are cancelled. New queries added by callbacks of
* queries being cancelled will not be cancelled themselves.
*/
list_head = &(channel->all_queries);
list_head_copy.prev = list_head->prev;
list_head_copy.next = list_head->next;
list_head_copy.prev->next = &list_head_copy;
list_head_copy.next->prev = &list_head_copy;
list_head->prev = list_head;
list_head->next = list_head;
for (list_node = list_head_copy.next; list_node != &list_head_copy; )
{
query = list_node->data;
list_node = list_node->next; /* since we're deleting the query */
query->callback(query->arg, ARES_ECANCELLED, 0, NULL, 0);
ares__free_query(query);
}
}
#ifndef NDEBUG
/* Freeing the query should remove it from all the lists in which it sits,
* so all query lists should be empty now.
*/
assert(ares__is_list_empty(&(channel->all_queries)));
for (i = 0; i < ARES_QID_TABLE_SIZE; i++)
{
assert(ares__is_list_empty(&(channel->queries_by_qid[i])));
}
for (i = 0; i < ARES_TIMEOUT_TABLE_SIZE; i++)
{
assert(ares__is_list_empty(&(channel->queries_by_timeout[i])));
}
#endif
if (!(channel->flags & ARES_FLAG_STAYOPEN))
if (!(channel->flags & ARES_FLAG_STAYOPEN) && ares__is_list_empty(&(channel->all_queries)))
{
if (channel->servers)
{
+502
View File
@@ -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 */
+76
View File
@@ -0,0 +1,76 @@
.\"
.\" 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.
.\"
.TH ARES_CREATE_QUERY 3 "17 Aug 2012"
.SH NAME
ares_create_query \- Compose a single-question DNS query buffer
.SH SYNOPSIS
.nf
#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 \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
\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:
.TP 15
.B ARES_SUCCESS
Construction of the DNS query succeeded.
.TP 15
.B ARES_EBADNAME
The query name
.I name
could not be encoded as a domain name, either because it contained a
zero-length label or because it contained a label of more than 63
characters.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH AVAILABILITY
Added in c-ares 1.10.0
.SH SEE ALSO
.BR ares_expand_name (3),
.BR ares_free_string (3),
.BR ares_mkquery (3)
.SH AUTHOR
+202
View File
@@ -0,0 +1,202 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#include "ares_setup.h"
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include "ares.h"
#include "ares_dns.h"
#include "ares_private.h"
#ifndef T_OPT
# define T_OPT 41 /* EDNS0 option (meta-RR) */
#endif
/* Header format, from RFC 1035:
* 1 1 1 1 1 1
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | ID |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |QR| Opcode |AA|TC|RD|RA| Z | RCODE |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | QDCOUNT |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | ANCOUNT |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | NSCOUNT |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | ARCOUNT |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
*
* AA, TC, RA, and RCODE are only set in responses. Brief description
* of the remaining fields:
* ID Identifier to match responses with queries
* QR Query (0) or response (1)
* Opcode For our purposes, always QUERY
* RD Recursion desired
* Z Reserved (zero)
* QDCOUNT Number of queries
* ANCOUNT Number of answers
* NSCOUNT Number of name server records
* ARCOUNT Number of additional records
*
* Question format, from RFC 1035:
* 1 1 1 1 1 1
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | |
* / QNAME /
* / /
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | QTYPE |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | QCLASS |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
*
* The query name is encoded as a series of labels, each represented
* as a one-byte length (maximum 63) followed by the text of the
* label. The list is terminated by a label of length zero (which can
* be thought of as the root domain).
*/
int ares_create_query(const char *name, int dnsclass, int type,
unsigned short id, int rd, unsigned char **bufp,
int *buflenp, int max_udp_size)
{
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. */
*buflenp = 0;
*bufp = NULL;
/* 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.
*/
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;
memset(q, 0, HFIXEDSZ);
DNS_HEADER_SET_QID(q, id);
DNS_HEADER_SET_OPCODE(q, QUERY);
if (rd) {
DNS_HEADER_SET_RD(q, 1);
}
else {
DNS_HEADER_SET_RD(q, 0);
}
DNS_HEADER_SET_QDCOUNT(q, 1);
if (max_udp_size) {
DNS_HEADER_SET_ARCOUNT(q, 1);
}
/* A name of "." is a screw case for the loop below, so adjust it. */
if (strcmp(name, ".") == 0)
name++;
/* Start writing out the name after the header. */
q += HFIXEDSZ;
while (*name)
{
if (*name == '.') {
free (buf);
return ARES_EBADNAME;
}
/* Count the number of bytes in this label. */
len = 0;
for (p = name; *p && *p != '.'; p++)
{
if (*p == '\\' && *(p + 1) != 0)
p++;
len++;
}
if (len > MAXLABEL) {
free (buf);
return ARES_EBADNAME;
}
/* Encode the length and copy the data. */
*q++ = (unsigned char)len;
for (p = name; *p && *p != '.'; p++)
{
if (*p == '\\' && *(p + 1) != 0)
p++;
*q++ = *p;
}
/* Go to the next label and repeat, unless we hit the end. */
if (!*p)
break;
name = p + 1;
}
/* Add the zero-length label at the end. */
*q++ = 0;
/* Finish off the question with the type and class. */
DNS_QUESTION_SET_TYPE(q, type);
DNS_QUESTION_SET_CLASS(q, dnsclass);
q += QFIXEDSZ;
if (max_udp_size)
{
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;
}
+106 -28
View File
@@ -1,6 +1,5 @@
/* $Id$ */
/* Copyright (C) 2009 by Daniel Stenberg
/* Copyright (C) 2009-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -34,6 +33,7 @@
** of c-ares functions returning pointers that must be free'ed using this
** function is:
**
** ares_get_servers()
** ares_parse_srv_reply()
** ares_parse_txt_reply()
*/
@@ -45,34 +45,86 @@ void ares_free_data(void *dataptr)
if (!dataptr)
return;
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:1684)
/* 1684: conversion from pointer to same-sized integral type */
#endif
ptr = (void *)((char *)dataptr - offsetof(struct ares_data, data));
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
if (ptr->mark != ARES_DATATYPE_MARK)
return;
switch (ptr->type)
{
case ARES_DATATYPE_MX_REPLY:
if (ptr->data.mx_reply.next)
ares_free_data(ptr->data.mx_reply.next);
if (ptr->data.mx_reply.host)
ares_free(ptr->data.mx_reply.host);
break;
case ARES_DATATYPE_SRV_REPLY:
if (ptr->data.srv_reply.next)
ares_free_data(ptr->data.srv_reply.next);
if (ptr->data.srv_reply.host)
free(ptr->data.srv_reply.host);
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:
if (ptr->data.addr_node.next)
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)
ares_free(ptr->data.naptr_reply.flags);
if (ptr->data.naptr_reply.service)
ares_free(ptr->data.naptr_reply.service);
if (ptr->data.naptr_reply.regexp)
ares_free(ptr->data.naptr_reply.regexp);
if (ptr->data.naptr_reply.replacement)
ares_free(ptr->data.naptr_reply.replacement);
break;
case ARES_DATATYPE_SOA_REPLY:
if (ptr->data.soa_reply.nsname)
ares_free(ptr->data.soa_reply.nsname);
if (ptr->data.soa_reply.hostmaster)
ares_free(ptr->data.soa_reply.hostmaster);
break;
default:
return;
}
free(ptr);
ares_free(ptr);
}
@@ -91,12 +143,18 @@ 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;
switch (type)
{
case ARES_DATATYPE_MX_REPLY:
ptr->data.mx_reply.next = NULL;
ptr->data.mx_reply.host = NULL;
ptr->data.mx_reply.priority = 0;
break;
case ARES_DATATYPE_SRV_REPLY:
ptr->data.srv_reply.next = NULL;
ptr->data.srv_reply.host = NULL;
@@ -105,14 +163,54 @@ 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;
ptr->data.txt_reply.length = 0;
ptr->data.txt_reply.length = 0;
break;
case ARES_DATATYPE_ADDR_NODE:
ptr->data.addr_node.next = NULL;
ptr->data.addr_node.family = 0;
memset(&ptr->data.addr_node.addrV6, 0,
sizeof(ptr->data.addr_node.addrV6));
break;
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;
ptr->data.naptr_reply.service = NULL;
ptr->data.naptr_reply.regexp = NULL;
ptr->data.naptr_reply.replacement = NULL;
ptr->data.naptr_reply.order = 0;
ptr->data.naptr_reply.preference = 0;
break;
case ARES_DATATYPE_SOA_REPLY:
ptr->data.soa_reply.nsname = NULL;
ptr->data.soa_reply.hostmaster = NULL;
ptr->data.soa_reply.serial = 0;
ptr->data.soa_reply.refresh = 0;
ptr->data.soa_reply.retry = 0;
ptr->data.soa_reply.expire = 0;
ptr->data.soa_reply.minttl = 0;
break;
default:
free(ptr);
ares_free(ptr);
return NULL;
}
@@ -121,23 +219,3 @@ void *ares_malloc_data(ares_datatype type)
return &ptr->data;
}
/*
** ares_get_datatype() - c-ares internal helper function.
**
** This function returns the ares_datatype of the data stored in a
** private ares_data struct when given the public API pointer.
*/
ares_datatype ares_get_datatype(void * dataptr)
{
struct ares_data *ptr;
ptr = (void *)((char *)dataptr - offsetof(struct ares_data, data));
if (ptr->mark == ARES_DATATYPE_MARK)
return ptr->type;
return ARES_DATATYPE_UNKNOWN;
}
+15 -5
View File
@@ -1,6 +1,5 @@
/* $Id$ */
/* Copyright (C) 2009 by Daniel Stenberg
/* Copyright (C) 2009-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -19,12 +18,18 @@ 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 */
ARES_DATATYPE_SOA_REPLY, /* struct ares_soa_reply - introduced in 1.9.0 */
#if 0
ARES_DATATYPE_ADDR6TTL, /* struct ares_addrttl */
ARES_DATATYPE_ADDRTTL, /* struct ares_addr6ttl */
ARES_DATATYPE_HOSTENT, /* struct hostent */
ARES_DATATYPE_OPTIONS, /* struct ares_options */
#endif
ARES_DATATYPE_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;
@@ -52,11 +57,16 @@ 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_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;
};
void *ares_malloc_data(ares_datatype type);
ares_datatype ares_get_datatype(void * dataptr);
+8 -12
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
@@ -24,17 +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.
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)
+36 -21
View File
@@ -1,6 +1,6 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2004-2011 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -16,8 +16,9 @@
*/
#include "ares_setup.h"
#include <assert.h>
#include <stdlib.h>
#include "ares.h"
#include "ares_private.h"
@@ -25,13 +26,16 @@ void ares_destroy_options(struct ares_options *options)
{
int i;
free(options->servers);
if(options->servers)
ares_free(options->servers);
for (i = 0; i < options->ndomains; i++)
free(options->domains[i]);
free(options->domains);
ares_free(options->domains[i]);
if(options->domains)
ares_free(options->domains);
if(options->sortlist)
free(options->sortlist);
free(options->lookups);
ares_free(options->sortlist);
if(options->lookups)
ares_free(options->lookups);
}
void ares_destroy(ares_channel channel)
@@ -67,27 +71,38 @@ void ares_destroy(ares_channel channel)
}
#endif
if (channel->servers) {
for (i = 0; i < channel->nservers; i++)
{
struct server_state *server = &channel->servers[i];
ares__close_sockets(channel, server);
assert(ares__is_list_empty(&(server->queries_to_server)));
}
free(channel->servers);
}
ares__destroy_servers_state(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)
{
struct server_state *server;
int i;
if (channel->servers)
{
for (i = 0; i < channel->nservers; i++)
{
server = &channel->servers[i];
ares__close_sockets(channel, server);
assert(ares__is_list_empty(&server->queries_to_server));
}
ares_free(channel->servers);
channel->servers = NULL;
}
channel->nservers = -1;
}
+3 -7
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
@@ -24,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)
+42 -12
View File
@@ -1,6 +1,7 @@
/* $Id$ */
#ifndef HEADER_CARES_DNS_H
#define HEADER_CARES_DNS_H
/* Copyright 1998 by the Massachusetts Institute of Technology.
/* Copyright 1998, 2011 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -15,12 +16,26 @@
* without express or implied warranty.
*/
#ifndef ARES__DNS_H
#define ARES__DNS_H
#include <sys/endian.h>
#define DNS__16BIT(p) (((p)[0] << 8) | (p)[1])
#define DNS__32BIT(p) (((p)[0] << 24) | ((p)[1] << 16) | \
((p)[2] << 8) | (p)[3])
#if 0
/*
* Macro DNS__16BIT reads a network short (16 bit) given in network
* byte order, and returns its value as an unsigned short.
*/
#define DNS__16BIT(p) ((unsigned short)((unsigned int) 0xffff & \
(((unsigned int)((unsigned char)(p)[0]) << 8U) | \
((unsigned int)((unsigned char)(p)[1])))))
/*
* Macro DNS__32BIT reads a network long (32 bit) given in network
* byte order, and returns its value as an unsigned int.
*/
#define DNS__32BIT(p) ((unsigned int) \
(((unsigned int)((unsigned char)(p)[0]) << 24U) | \
((unsigned int)((unsigned char)(p)[1]) << 16U) | \
((unsigned int)((unsigned char)(p)[2]) << 8U) | \
((unsigned int)((unsigned char)(p)[3]))))
#define DNS__SET16BIT(p, v) (((p)[0] = (unsigned char)(((v) >> 8) & 0xff)), \
((p)[1] = (unsigned char)((v) & 0xff)))
@@ -28,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
@@ -38,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)
@@ -83,9 +113,9 @@
#define DNS_RR_LEN(r) DNS__16BIT((r) + 8)
/* Macros for constructing the fixed part of a DNS resource record */
#define DNS_RR_SET_TYPE(r) DNS__SET16BIT(r, v)
#define DNS_RR_SET_CLASS(r) DNS__SET16BIT((r) + 2, v)
#define DNS_RR_SET_TTL(r) DNS__SET32BIT((r) + 4, v)
#define DNS_RR_SET_LEN(r) DNS__SET16BIT((r) + 8, v)
#define DNS_RR_SET_TYPE(r, v) DNS__SET16BIT(r, v)
#define DNS_RR_SET_CLASS(r, v) DNS__SET16BIT((r) + 2, v)
#define DNS_RR_SET_TTL(r, v) DNS__SET32BIT((r) + 4, v)
#define DNS_RR_SET_LEN(r, v) DNS__SET16BIT((r) + 8, v)
#endif /* ARES__DNS_H */
#endif /* HEADER_CARES_DNS_H */
+1 -6
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright (C) 2004-2009 by Daniel Stenberg
.\"
@@ -29,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
+3 -2
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
@@ -44,6 +43,8 @@ The length of the encoded name is stored in the variable pointed to by
.I enclen
so that the caller can advance past the encoded domain name to read
further data in the message.
Use \fIares_free_string(3)\fP to free the allocated hostname.
.SH RETURN VALUES
.B ares_expand_name
can return any of the following values:
@@ -57,7 +58,7 @@ The encoded domain name was malformed and could not be expanded.
.B ARES_ENOMEM
Memory was exhausted.
.SH SEE ALSO
.BR ares_mkquery (3)
.BR ares_mkquery (3), ares_free_string (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
+33 -18
View File
@@ -1,6 +1,5 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
/* Copyright 1998, 2011 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -17,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
@@ -32,8 +28,8 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdlib.h>
#include "ares.h"
#include "ares_nowarn.h"
#include "ares_private.h" /* for the memdebug */
static int name_length(const unsigned char *encoded, const unsigned char *abuf,
@@ -69,22 +65,33 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
int len, indir = 0;
char *q;
const unsigned char *p;
union {
ssize_t sig;
size_t uns;
} nlen;
len = name_length(encoded, abuf, alen);
if (len < 0)
nlen.sig = name_length(encoded, abuf, alen);
if (nlen.sig < 0)
return ARES_EBADNAME;
*s = malloc(((size_t)len) + 1);
*s = ares_malloc(nlen.uns + 1);
if (!*s)
return ARES_ENOMEM;
q = *s;
if (len == 0) {
if (nlen.uns == 0) {
/* RFC2181 says this should be ".": the root of the DNS tree.
* Since this function strips trailing dots though, it becomes ""
*/
q[0] = '\0';
*enclen = 1; /* the caller should move one byte to get past this */
/* indirect root label (like 0xc0 0x0c) is 2 bytes long (stupid, but
valid) */
if ((*encoded & INDIR_MASK) == INDIR_MASK)
*enclen = 2L;
else
*enclen = 1L; /* the caller should move one byte to get past this */
return ARES_SUCCESS;
}
@@ -96,7 +103,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
{
if (!indir)
{
*enclen = p + 2 - encoded;
*enclen = aresx_uztosl(p + 2U - encoded);
indir = 1;
}
p = abuf + ((*p & ~INDIR_MASK) << 8 | *(p + 1));
@@ -116,13 +123,13 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
}
}
if (!indir)
*enclen = p + 1 - encoded;
*enclen = aresx_uztosl(p + 1U - encoded);
/* Nuke the trailing period if we wrote one. */
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;
}
@@ -133,15 +140,16 @@ 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)
if (encoded >= abuf + alen)
return -1;
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)
@@ -157,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)
@@ -170,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
-1
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
+11 -13
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
@@ -17,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
@@ -29,8 +25,6 @@
# include "nameser.h"
#endif
#include <string.h>
#include <stdlib.h>
#include "ares.h"
#include "ares_private.h" /* for the memdebug */
@@ -46,26 +40,30 @@ int ares_expand_string(const unsigned char *encoded,
long *enclen)
{
unsigned char *q;
long len;
union {
ssize_t sig;
size_t uns;
} elen;
if (encoded == abuf+alen)
return ARES_EBADSTR;
len = *encoded;
if (encoded+len+1 > abuf+alen)
elen.uns = *encoded;
if (encoded+elen.sig+1 > abuf+alen)
return ARES_EBADSTR;
encoded++;
*s = malloc(len+1);
*s = ares_malloc(elen.uns+1);
if (*s == NULL)
return ARES_ENOMEM;
q = *s;
strncpy((char *)q, (char *)encoded, len);
q[len] = '\0';
strncpy((char *)q, (char *)encoded, elen.uns);
q[elen.uns] = '\0';
*s = q;
*enclen = len+1;
*enclen = (long)(elen.sig+1);
return ARES_SUCCESS;
}
-1
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
+1 -5
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
@@ -17,11 +16,8 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include "ares.h"
#include "ares_nowarn.h"
#include "ares_private.h"
int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds)
+23 -5
View File
@@ -1,7 +1,6 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\" Copyright (C) 2004-2009 by Daniel Stenberg
.\" Copyright (C) 2004-2010 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
@@ -15,7 +14,7 @@
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_FREE_DATA 3 "23 Nov 2009"
.TH ARES_FREE_DATA 3 "5 March 2010"
.SH NAME
ares_free_data \- Free data allocated by several c-ares functions
.SH SYNOPSIS
@@ -34,27 +33,46 @@ function frees one or more data structures allocated and returned
by several c-ares functions. Specifically the data returned by the
following list of functions must be deallocated using this function.
.TP 5
.B ares_get_servers(3)
When used to free the data returned by ares_get_servers(3) this
will free the whole linked list of ares_addr_node structures returned
by ares_get_servers(3).
.TP
.B ares_parse_srv_reply(3)
When used to free the data returned by ares_parse_srv_reply(3) this
will free the whole linked list of ares_srv_reply structures returned
by ares_parse_srv_reply(3), along with any additional storage
associated with those structures.
.TP
.B ares_parse_mx_reply(3)
When used to free the data returned by ares_parse_mx_reply(3) this
will free the whole linked list of ares_mx_reply structures returned
by ares_parse_mx_reply(3), along with any additional storage
associated with those structures.
.TP
.B ares_parse_txt_reply(3)
When used to free the data returned by ares_parse_txt_reply(3) this
will free the whole linked list of ares_txt_reply structures returned
by ares_parse_txt_reply(3), along with any additional storage
associated with those structures.
.TP
.B ares_parse_soa_reply(3)
When used to free the data returned by ares_parse_soa_reply(3) this
will free the ares_soa_reply structure, along with any additional storage
associated with those structure.
.SH RETURN VALUE
The ares_free_data() function does not return a value.
.SH AVAILABILITY
This function was first introduced in c-ares version 1.7.0.
.SH SEE ALSO
.BR ares_get_servers(3),
.BR ares_parse_srv_reply(3),
.BR ares_parse_txt_reply(3)
.BR ares_parse_mx_reply(3),
.BR ares_parse_txt_reply(3),
.BR ares_parse_soa_reply(3)
.SH AUTHOR
Yang Tse
.PP
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2004-2009 by Daniel Stenberg.
Copyright (C) 2004-2010 by Daniel Stenberg.
-1
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
+9 -8
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
@@ -16,7 +15,6 @@
*/
#include "ares_setup.h"
#include <stdlib.h>
#ifdef HAVE_NETDB_H
#include <netdb.h>
@@ -29,12 +27,15 @@ void ares_free_hostent(struct hostent *host)
{
char **p;
free((char *)(host->h_name));
if (!host)
return;
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 -4
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 2000 by the Massachusetts Institute of Technology.
.\"
@@ -24,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)
+2 -3
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright 2000 by the Massachusetts Institute of Technology.
*
@@ -16,11 +15,11 @@
*/
#include "ares_setup.h"
#include <stdlib.h>
#include "ares.h"
#include "ares_private.h"
void ares_free_string(void *str)
{
free(str);
ares_free(str);
}
+84
View File
@@ -0,0 +1,84 @@
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\" Copyright (C) 2008-2010 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_GET_SERVERS 3 "5 March 2010"
.SH NAME
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
from the
channel data identified by
.IR channel ,
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 /
\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
allocated and managed by c-ares. It is the caller's responsibility to free
the resulting linked list, using \fBares_free_data(3)\fP , once the caller
does not need it any longer.
This function is capable of handling IPv4 and IPv6 name server
addresses simultaneously, rendering \fBares_save_options(3)\fP with
optmask \fBARES_OPT_SERVERS\fP functionally obsolete except for
IPv4-only name server usage.
.SH RETURN VALUES
This function may return any of the following values:
.TP 15
.B ARES_SUCCESS
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
.IR channel
was invalid.
.SH SEE ALSO
.BR ares_set_servers (3),
.BR ares_init_options (3),
.BR ares_save_options(3)
.SH AVAILABILITY
\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
Daniel Stenberg, Gregor Jasny, Phil Blundell and Yang Tse, December 2009
by Cedric Bail, February 2010 by Jakub Hrozek. On March 2010 Yang Tse
shuffled all the bits and this function popped out.
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2008-2010 by Daniel Stenberg
+1
View File
@@ -0,0 +1 @@
.so man3/ares_get_servers.3
+13 -10
View File
@@ -1,9 +1,6 @@
#ifndef __ARES_INET_NTOP_H
#define __ARES_INET_NTOP_H
/* $Id$ */
/* Copyright (C) 2005 by Dominick Meglio
/* 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
@@ -18,10 +15,16 @@
* without express or implied warranty.
*/
#ifdef HAVE_INET_NTOP
#define ares_inet_ntop(w,x,y,z) inet_ntop(w,x,y,z)
#else
const char *ares_inet_ntop(int af, const void *src, char *dst, size_t size);
#endif
#include "ares_setup.h"
#include "ares_getenv.h"
#endif /* __ARES_INET_NTOP_H */
#ifndef HAVE_GETENV
char *ares_getenv(const char *name)
{
#ifdef _WIN32_WCE
return NULL;
#endif
}
#endif
+26
View File
@@ -0,0 +1,26 @@
#ifndef HEADER_CARES_GETENV_H
#define HEADER_CARES_GETENV_H
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#include "ares_setup.h"
#ifndef HAVE_GETENV
extern char *ares_getenv(const char *name);
#endif
#endif /* HEADER_CARES_GETENV_H */
+3 -1
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
@@ -71,6 +70,9 @@ was not found.
.B ARES_ENOMEM
Memory was exhausted.
.TP 19
.B ARES_ECANCELLED
The query was cancelled.
.TP 19
.B ARES_EDESTRUCTION
The name service channel
.I channel
+32 -29
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
@@ -16,9 +15,6 @@
*/
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
@@ -37,12 +33,9 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "inet_net_pton.h"
#include "ares_inet_net_pton.h"
#include "ares_platform.h"
#include "ares_private.h"
#ifdef WATT32
@@ -79,14 +72,14 @@ void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
return;
}
if ((family == AF_INET && addrlen != sizeof(struct in_addr)) ||
(family == AF_INET6 && addrlen != sizeof(struct in6_addr)))
if ((family == AF_INET && addrlen != sizeof(aquery->addr.addrV4)) ||
(family == AF_INET6 && addrlen != sizeof(aquery->addr.addrV6)))
{
callback(arg, ARES_ENOTIMP, 0, NULL);
return;
}
aquery = malloc(sizeof(struct addr_query));
aquery = ares_malloc(sizeof(struct addr_query));
if (!aquery)
{
callback(arg, ARES_ENOMEM, 0, NULL);
@@ -94,9 +87,9 @@ void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
}
aquery->channel = channel;
if (family == AF_INET)
memcpy(&aquery->addr.addrV4, addr, sizeof(struct in_addr));
memcpy(&aquery->addr.addrV4, addr, sizeof(aquery->addr.addrV4));
else
memcpy(&aquery->addr.addrV6, addr, sizeof(struct in6_addr));
memcpy(&aquery->addr.addrV6, addr, sizeof(aquery->addr.addrV6));
aquery->addr.family = family;
aquery->callback = callback;
aquery->arg = arg;
@@ -152,13 +145,13 @@ static void addr_callback(void *arg, int status, int timeouts,
{
if (aquery->addr.family == AF_INET)
{
addrlen = sizeof(struct in_addr);
addrlen = sizeof(aquery->addr.addrV4);
status = ares_parse_ptr_reply(abuf, alen, &aquery->addr.addrV4,
(int)addrlen, AF_INET, &host);
}
else
{
addrlen = sizeof(struct in6_addr);
addrlen = sizeof(aquery->addr.addrV6);
status = ares_parse_ptr_reply(abuf, alen, &aquery->addr.addrV6,
(int)addrlen, AF_INET6, &host);
}
@@ -176,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)
@@ -187,12 +180,18 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
#ifdef WIN32
char PATH_HOSTS[MAX_PATH];
if (IS_NT()) {
win_platform platform;
PATH_HOSTS[0] = '\0';
platform = ares__getplatform();
if (platform == WIN_NT) {
char tmp[MAX_PATH];
HKEY hkeyHosts;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts)
== ERROR_SUCCESS)
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ,
&hkeyHosts) == ERROR_SUCCESS)
{
DWORD dwLength = MAX_PATH;
RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp,
@@ -201,8 +200,10 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
RegCloseKey(hkeyHosts);
}
}
else
else if (platform == WIN_9X)
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
else
return ARES_ENOTFOUND;
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
@@ -241,12 +242,14 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
}
if (addr->family == AF_INET)
{
if (memcmp((*host)->h_addr, &addr->addrV4, sizeof(struct in_addr)) == 0)
if (memcmp((*host)->h_addr, &addr->addrV4,
sizeof(addr->addrV4)) == 0)
break;
}
else if (addr->family == AF_INET6)
{
if (memcmp((*host)->h_addr, &addr->addrV6, sizeof(struct in6_addr)) == 0)
if (memcmp((*host)->h_addr, &addr->addrV6,
sizeof(addr->addrV6)) == 0)
break;
}
ares_free_hostent(*host);
@@ -264,15 +267,15 @@ static void ptr_rr_name(char *name, const struct ares_addr *addr)
if (addr->family == AF_INET)
{
unsigned long laddr = ntohl(addr->addrV4.s_addr);
int a1 = (int)((laddr >> 24) & 0xff);
int a2 = (int)((laddr >> 16) & 0xff);
int a3 = (int)((laddr >> 8) & 0xff);
int a4 = (int)(laddr & 0xff);
sprintf(name, "%d.%d.%d.%d.in-addr.arpa", a4, a3, a2, a1);
unsigned long a1 = (laddr >> 24UL) & 0xFFUL;
unsigned long a2 = (laddr >> 16UL) & 0xFFUL;
unsigned long a3 = (laddr >> 8UL) & 0xFFUL;
unsigned long a4 = laddr & 0xFFUL;
sprintf(name, "%lu.%lu.%lu.%lu.in-addr.arpa", a4, a3, a2, a1);
}
else
{
unsigned char *bytes = (unsigned char *)&addr->addrV6.s6_addr;
unsigned char *bytes = (unsigned char *)&addr->addrV6;
/* There are too many arguments to do this in one line using
* minimally C89-compliant compilers */
sprintf(name,
+3 -1
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
@@ -75,6 +74,9 @@ was not found.
.B ARES_ENOMEM
Memory was exhausted.
.TP 19
.B ARES_ECANCELLED
The query was cancelled.
.TP 19
.B ARES_EDESTRUCTION
The name service channel
.I channel
+57 -50
View File
@@ -1,6 +1,5 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
/* Copyright 1998, 2011, 2013 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -17,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
@@ -38,17 +34,15 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include "ares.h"
#include "inet_net_pton.h"
#include "ares_inet_net_pton.h"
#include "bitncmp.h"
#include "ares_platform.h"
#include "ares_nowarn.h"
#include "ares_private.h"
#ifdef WATT32
@@ -81,7 +75,7 @@ static void sort6_addresses(struct hostent *host,
const struct apattern *sortlist, int nsort);
static int get_address_index(const struct in_addr *addr,
const struct apattern *sortlist, int nsort);
static int get6_address_index(const struct in6_addr *addr,
static int get6_address_index(const struct ares_in6_addr *addr,
const struct apattern *sortlist, int nsort);
void ares_gethostbyname(ares_channel channel, const char *name, int family,
@@ -105,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;
}
@@ -151,8 +145,8 @@ static void next_lookup(struct host_query *hquery, int status_code)
}
else {
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
hquery);
ares_search(hquery->channel, hquery->name, C_IN, T_A,
host_callback, hquery);
}
return;
@@ -194,10 +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) {
/* The query returned something but either there were no AAAA records (e.g. just CNAME)
or the response was malformed. Try looking up A instead.
We should possibly limit this attempt-next logic to AF_UNSPEC lookups only. */
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);
@@ -208,10 +206,11 @@ static void host_callback(void *arg, int status, int timeouts,
}
end_hquery(hquery, status, host);
}
else if ((status == ARES_ENODATA || status == ARES_EBADRESP || status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
else if ((status == ARES_ENODATA || status == ARES_EBADRESP ||
status == ARES_ETIMEOUT) && (hquery->sent_family == AF_INET6 &&
hquery->want_family == AF_UNSPEC))
{
/* The AAAA query yielded no useful result. Now look up an A instead.
We should possibly limit this attempt-next logic to AF_UNSPEC lookups only. */
/* The AAAA query yielded no useful result. Now look up an A instead. */
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
hquery);
@@ -228,22 +227,22 @@ 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
* query immediately, and return true. Otherwise return false.
*/
static int fake_hostent(const char *name, int family, ares_host_callback callback,
void *arg)
static int fake_hostent(const char *name, int family,
ares_host_callback callback, void *arg)
{
struct hostent hostent;
char *aliases[1] = { NULL };
char *addrs[2];
int result = 0;
struct in_addr in;
struct in6_addr in6;
struct ares_in6_addr in6;
if (family == AF_INET || family == AF_INET6)
{
@@ -284,11 +283,11 @@ static int fake_hostent(const char *name, int family, ares_host_callback callbac
}
else if (family == AF_INET6)
{
hostent.h_length = (int)sizeof(struct in6_addr);
hostent.h_length = (int)sizeof(struct ares_in6_addr);
addrs[0] = (char *)&in6;
}
/* Duplicate the name, to avoid a constness violation. */
hostent.h_name = strdup(name);
hostent.h_name = ares_strdup(name);
if (!hostent.h_name)
{
callback(arg, ARES_ENOMEM, 0, NULL);
@@ -298,11 +297,11 @@ static int fake_hostent(const char *name, int family, ares_host_callback callbac
/* Fill in the rest of the host structure and terminate the query. */
addrs[1] = NULL;
hostent.h_aliases = aliases;
hostent.h_addrtype = family;
hostent.h_addrtype = aresx_sitoss(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;
}
@@ -342,12 +341,18 @@ static int file_lookup(const char *name, int family, struct hostent **host)
#ifdef WIN32
char PATH_HOSTS[MAX_PATH];
if (IS_NT()) {
win_platform platform;
PATH_HOSTS[0] = '\0';
platform = ares__getplatform();
if (platform == WIN_NT) {
char tmp[MAX_PATH];
HKEY hkeyHosts;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts)
== ERROR_SUCCESS)
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ,
&hkeyHosts) == ERROR_SUCCESS)
{
DWORD dwLength = MAX_PATH;
RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp,
@@ -356,8 +361,10 @@ static int file_lookup(const char *name, int family, struct hostent **host)
RegCloseKey(hkeyHosts);
}
}
else
else if (platform == WIN_9X)
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
else
return ARES_ENOTFOUND;
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
@@ -408,8 +415,8 @@ static int file_lookup(const char *name, int family, struct hostent **host)
return status;
}
static void sort_addresses(struct hostent *host, const struct apattern *sortlist,
int nsort)
static void sort_addresses(struct hostent *host,
const struct apattern *sortlist, int nsort)
{
struct in_addr a1, a2;
int i1, i2, ind1, ind2;
@@ -456,18 +463,18 @@ static int get_address_index(const struct in_addr *addr,
}
else
{
if (!ares_bitncmp(&addr->s_addr, &sortlist[i].addrV4.s_addr,
sortlist[i].mask.bits))
if (!ares__bitncmp(&addr->s_addr, &sortlist[i].addrV4.s_addr,
sortlist[i].mask.bits))
break;
}
}
return i;
}
static void sort6_addresses(struct hostent *host, const struct apattern *sortlist,
int nsort)
static void sort6_addresses(struct hostent *host,
const struct apattern *sortlist, int nsort)
{
struct in6_addr a1, a2;
struct ares_in6_addr a1, a2;
int i1, i2, ind1, ind2;
/* This is a simple insertion sort, not optimized at all. i1 walks
@@ -477,24 +484,24 @@ static void sort6_addresses(struct hostent *host, const struct apattern *sortlis
*/
for (i1 = 0; host->h_addr_list[i1]; i1++)
{
memcpy(&a1, host->h_addr_list[i1], sizeof(struct in6_addr));
memcpy(&a1, host->h_addr_list[i1], sizeof(struct ares_in6_addr));
ind1 = get6_address_index(&a1, sortlist, nsort);
for (i2 = i1 - 1; i2 >= 0; i2--)
{
memcpy(&a2, host->h_addr_list[i2], sizeof(struct in6_addr));
memcpy(&a2, host->h_addr_list[i2], sizeof(struct ares_in6_addr));
ind2 = get6_address_index(&a2, sortlist, nsort);
if (ind2 <= ind1)
break;
memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct in6_addr));
memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct ares_in6_addr));
}
memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct in6_addr));
memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct ares_in6_addr));
}
}
/* Find the first entry in sortlist which matches addr. Return nsort
* if none of them match.
*/
static int get6_address_index(const struct in6_addr *addr,
static int get6_address_index(const struct ares_in6_addr *addr,
const struct apattern *sortlist,
int nsort)
{
@@ -504,8 +511,8 @@ static int get6_address_index(const struct in6_addr *addr,
{
if (sortlist[i].family != AF_INET6)
continue;
if (!ares_bitncmp(&addr->s6_addr, &sortlist[i].addrV6.s6_addr, sortlist[i].mask.bits))
break;
if (!ares__bitncmp(addr, &sortlist[i].addrV6, sortlist[i].mask.bits))
break;
}
return i;
}
-1
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
+3 -2
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 2005 by Dominick Meglio.
.\"
@@ -110,6 +109,9 @@ was not found.
.B ARES_ENOMEM
Memory was exhausted.
.TP 19
.B ARES_ECANCELLED
The query was cancelled.
.TP 19
.B ARES_EDESTRUCTION
The name service channel
.I channel
@@ -143,7 +145,6 @@ will be
.BR NULL .
.SH SEE ALSO
.BR ares_process (3),
.BR ares_getaddrinfo (3)
.SH AUTHOR
Dominick Meglio
.br
+67 -54
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright 2005 by Dominick Meglio
*
@@ -23,9 +22,6 @@
# endif
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
@@ -48,17 +44,9 @@
#include <net/if.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_ipv6.h"
#include "inet_ntop.h"
#include "ares_nowarn.h"
#include "ares_private.h"
struct nameinfo_query {
@@ -74,19 +62,22 @@ struct nameinfo_query {
};
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
#define IPBUFSIZ 40+IF_NAMESIZE
#define IPBUFSIZ \
(sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") + IF_NAMESIZE)
#else
#define IPBUFSIZ 40
#define IPBUFSIZ \
(sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"))
#endif
static void nameinfo_callback(void *arg, int status, int timeouts, struct hostent *host);
static void nameinfo_callback(void *arg, int status, int timeouts,
struct hostent *host);
static char *lookup_service(unsigned short port, int flags,
char *buf, size_t buflen);
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int scopeid,
char *buf, size_t buflen);
#endif
static char *ares_striendstr(const char *s1, const char *s2);
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,
@@ -97,13 +88,15 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
struct nameinfo_query *niquery;
unsigned int port = 0;
/* Verify the buffer size */
if (salen == sizeof(struct sockaddr_in))
/* Validate socket address family and length */
if ((sa->sa_family == AF_INET) &&
(salen == sizeof(struct sockaddr_in)))
{
addr = (struct sockaddr_in *)sa;
port = addr->sin_port;
}
else if (salen == sizeof(struct sockaddr_in6))
else if ((sa->sa_family == AF_INET6) &&
(salen == sizeof(struct sockaddr_in6)))
{
addr6 = (struct sockaddr_in6 *)sa;
port = addr6->sin6_port;
@@ -170,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);
@@ -183,22 +176,25 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
if (sa->sa_family == AF_INET)
{
niquery->family = AF_INET;
memcpy(&niquery->addr.addr4, addr, sizeof(addr));
ares_gethostbyaddr(channel, &addr->sin_addr, sizeof(struct in_addr), AF_INET,
memcpy(&niquery->addr.addr4, addr, sizeof(niquery->addr.addr4));
ares_gethostbyaddr(channel, &addr->sin_addr,
sizeof(struct in_addr), AF_INET,
nameinfo_callback, niquery);
}
else
{
niquery->family = AF_INET6;
memcpy(&niquery->addr.addr6, addr6, sizeof(addr6));
ares_gethostbyaddr(channel, &addr6->sin6_addr, sizeof(struct in6_addr), AF_INET6,
memcpy(&niquery->addr.addr6, addr6, sizeof(niquery->addr.addr6));
ares_gethostbyaddr(channel, &addr6->sin6_addr,
sizeof(struct ares_in6_addr), AF_INET6,
nameinfo_callback, niquery);
}
}
}
}
static void nameinfo_callback(void *arg, int status, int timeouts, struct hostent *host)
static void nameinfo_callback(void *arg, int status, int timeouts,
struct hostent *host)
{
struct nameinfo_query *niquery = (struct nameinfo_query *) arg;
char srvbuf[33];
@@ -217,8 +213,8 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
service = lookup_service(niquery->addr.addr6.sin6_port,
niquery->flags, srvbuf, sizeof(srvbuf));
}
/* NOFQDN means we have to strip off the domain name portion.
We do this by determining our own domain name, then searching the string
/* NOFQDN means we have to strip off the domain name portion. We do
this by determining our own domain name, then searching the string
for this domain name and removing it.
*/
#ifdef HAVE_GETHOSTNAME
@@ -227,7 +223,7 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
char buf[255];
char *domain;
gethostname(buf, 255);
if ((domain = strchr(buf, '.')))
if ((domain = strchr(buf, '.')) != NULL)
{
char *end = ares_striendstr(host->h_name, domain);
if (end)
@@ -235,8 +231,10 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
}
}
#endif
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, (char *)(host->h_name),
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts,
(char *)(host->h_name),
service);
ares_free(niquery);
return;
}
/* We couldn't find the host, but it's OK, we can use the IP */
@@ -244,12 +242,15 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
{
char ipbuf[IPBUFSIZ];
if (niquery->family == AF_INET)
ares_inet_ntop(AF_INET, &niquery->addr.addr4.sin_addr, ipbuf, IPBUFSIZ);
ares_inet_ntop(AF_INET, &niquery->addr.addr4.sin_addr, ipbuf,
IPBUFSIZ);
else
{
ares_inet_ntop(AF_INET6, &niquery->addr.addr6.sin6_addr, ipbuf, IPBUFSIZ);
ares_inet_ntop(AF_INET6, &niquery->addr.addr6.sin6_addr, ipbuf,
IPBUFSIZ);
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
append_scopeid(&niquery->addr.addr6, niquery->flags, ipbuf, sizeof(ipbuf));
append_scopeid(&niquery->addr.addr6, niquery->flags, ipbuf,
sizeof(ipbuf));
#endif
}
/* They want a service too */
@@ -262,11 +263,13 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
service = lookup_service(niquery->addr.addr6.sin6_port,
niquery->flags, srvbuf, sizeof(srvbuf));
}
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, ipbuf, service);
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, ipbuf,
service);
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,
@@ -278,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)
{
@@ -294,13 +299,16 @@ 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;
if (getservbyport_r(port, proto, &se, (void *)tmpbuf,
sizeof(tmpbuf), &sep) != 0)
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));
sep = getservbyport_r(port, proto, &se, (void *)tmpbuf,
sizeof(tmpbuf));
#elif GETSERVBYPORT_R_ARGS == 4
if (getservbyport_r(port, proto, &se, (void *)tmpbuf) != 0)
sep = NULL;
@@ -318,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';
@@ -342,11 +356,12 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags,
#ifdef HAVE_IF_INDEXTONAME
int is_ll, is_mcll;
#endif
char fmt_u[] = "%u";
char fmt_lu[] = "%lu";
static const char fmt_u[] = "%u";
static const char fmt_lu[] = "%lu";
char tmpbuf[IF_NAMESIZE + 2];
size_t bufl;
char *fmt = (sizeof(addr6->sin6_scope_id) > sizeof(unsigned int))?fmt_lu:fmt_u;
const char *fmt = (sizeof(addr6->sin6_scope_id) > sizeof(unsigned int))?
fmt_lu:fmt_u;
tmpbuf[0] = '%';
@@ -377,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;
@@ -393,8 +408,8 @@ static char *ares_striendstr(const char *s1, const char *s2)
c2 = s2;
while (c2 < s2+s2_len)
{
lo1 = tolower(*c1);
lo2 = tolower(*c2);
lo1 = TOLOWER(*c1);
lo2 = TOLOWER(*c2);
if (lo1 != lo2)
return NULL;
else
@@ -403,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;
}
-1
View File
@@ -3,7 +3,6 @@
* on 2007-04-11. Lifted from version 5.2 of the 'Open Mash' project with
* the modified BSD license, BSD license without the advertising clause.
*
* $Id$
*/
/*
+5 -6
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by Daniel Stenberg
.\"
@@ -14,25 +13,25 @@
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_GETSOCK 3 "22 December 2005"
.TH ARES_GETSOCK 3 "11 March 2010"
.SH NAME
ares_getsock \- get file descriptors to wait on
ares_getsock \- get socket descriptors to wait on
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_getsock(ares_channel \fIchannel\fP, int *\fIsocks\fP,
.B int ares_getsock(ares_channel \fIchannel\fP, ares_socket_t *\fIsocks\fP,
.B int \fInumsocks\fP);
.fi
.SH DESCRIPTION
The
.B ares_getsock
function retrieves the set of file descriptors which the calling
function retrieves the set of socket descriptors which the calling
application should wait on for reading and/or writing for the
processing of name service queries pending on the name service channel
identified by
.IR channel .
File descriptors will be set in the integer array pointed to by
Socket descriptors will be set in the socket descriptor array pointed to by
\fIsocks\fP.
\fInumsocks\fP is the size of the given array in number of ints.
+5 -14
View File
@@ -1,6 +1,5 @@
/* $Id$ */
/* Copyright (C) 2005 - 2007, Daniel Stenberg
/* Copyright (C) 2005 - 2010, Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
@@ -15,15 +14,11 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include "ares.h"
#include "ares_private.h"
int ares_getsock(ares_channel channel,
int *s,
ares_socket_t *socks,
int numsocks) /* size of the 'socks' array */
{
struct server_state *server;
@@ -32,14 +27,10 @@ int ares_getsock(ares_channel channel,
int bitmap = 0;
unsigned int setbits = 0xffffffff;
ares_socket_t *socks = (ares_socket_t *)s;
/* 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
@@ -47,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);
@@ -59,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);
+5 -12
View File
@@ -1,9 +1,7 @@
#ifndef __ARES_INET_NET_PTON_H
#define __ARES_INET_NET_PTON_H
#ifndef HEADER_CARES_INET_NET_PTON_H
#define HEADER_CARES_INET_NET_PTON_H
/* $Id$ */
/* Copyright (C) 2005 by Daniel Stenberg
/* Copyright (C) 2005-2013 by Daniel Stenberg et al
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -18,15 +16,10 @@
* without express or implied warranty.
*/
#ifdef HAVE_INET_PTON
#define ares_inet_pton(x,y,z) inet_pton(x,y,z)
#else
int ares_inet_pton(int af, const char *src, void *dst);
#endif
#if defined(HAVE_INET_NET_PTON) && defined(HAVE_INET_NET_PTON_IPV6)
#ifdef HAVE_INET_NET_PTON
#define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z)
#else
int ares_inet_net_pton(int af, const char *src, void *dst, size_t size);
#endif
#endif /* __ARES_INET_NET_PTON_H */
#endif /* HEADER_CARES_INET_NET_PTON_H */
+47
View File
@@ -0,0 +1,47 @@
.\"
.\" Copyright (C) 2013 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_INET_NTOP 3 "17 Feb 2013"
.SH NAME
ares_inet_ntop \- convert a network format address to presentation format
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B const char *
.B ares_inet_ntop(int af, const void *src, char *dst, ares_socklen_t size);
.fi
.SH DESCRIPTION
This is a portable version with the identical functionality of the commonly
available \fIinet_ntop\fP.
The ares_inet_ntop() function converts a numeric address into a text string
suitable for presentation. The \fBaf\fP argument shall specify the family of
the address. This can be AF_INET or AF_INET6. The \fBsrc\fP argument points
to a buffer holding an IPv4 address if the af argument is AF_INET, or an IPv6
address if the af argument is AF_INET6; the address must be in network byte
order. The \fBdst\fP argument points to a buffer where the function stores the
resulting text string; it shall not be NULL. The \fBsize\fP argument specifies
the size of this buffer, which shall be large enough to hold the text string
(INET_ADDRSTRLEN (16) characters for IPv4, INET6_ADDRSTRLEN (46) characters
for IPv6).
.SH SEE ALSO
.BR ares_init(3),
.BR ares_inet_pton(3)
.SH AVAILABILITY
made properly publicly available in c-ares for real in version 1.10.0
.SH AUTHOR
Daniel Stenberg
+43
View File
@@ -0,0 +1,43 @@
.\"
.\" Copyright (C) 2013 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_INET_PTON 3 "17 Feb 2013"
.SH NAME
ares_inet_pton \- convert an IPv4 or IPv6 address from text to binary form
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B const char *ares_inet_pton(int af, const char *src, void *dst);
.fi
.SH DESCRIPTION
This is a portable version with the identical functionality of the commonly
available \fIinet_pton\fP.
The ares_inet_pton() function converts the address in its standard text
presentation form into its numeric binary form. The \fBaf\fP argument shall
specify the family of the address. The AF_INET and AF_INET6 address families
shall be supported. The \fBsrc\fP argument points to the string being passed
in. The \fBdst\fP argument points to a buffer into which the function stores
the numeric address; this shall be large enough to hold the numeric address
(32 bits for AF_INET, 128 bits for AF_INET6).
.SH SEE ALSO
.BR ares_init(3),
.BR ares_inet_ntop(3)
.SH AVAILABILITY
made properly publicly available in c-ares for real in version 1.10.0
.SH AUTHOR
Daniel Stenberg
+39 -157
View File
@@ -1,7 +1,6 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\" Copyright (C) 2004-2009 by Daniel Stenberg
.\" Copyright (C) 2004-2010 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
@@ -15,166 +14,26 @@
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_INIT 3 "26 May 2009"
.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 servers to contact, instead of the servers specified in
resolv.conf or the local named.
.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.
@@ -187,13 +46,36 @@ 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,
.BR ares_init (3)
reads the
.I domain
and
.I search
directives to allow lookups of short names relative to the domains
specified. The
.I domain
and
.I search
directives override one another. If more that one instance of either
.I domain
or
.I search
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)
.BR ares_library_init(3),
.BR ares_set_servers(3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2004-2009 by Daniel Stenberg.
Copyright (C) 2004-2010 by Daniel Stenberg.
+1021 -455
View File
File diff suppressed because it is too large Load Diff
+262 -2
View File
@@ -1,2 +1,262 @@
.so man3/ares_init.3
.\" $Id$
.\"
.\" 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.
+221
View File
@@ -0,0 +1,221 @@
#ifndef HEADER_CARES_IPHLPAPI_H
#define HEADER_CARES_IPHLPAPI_H
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2004 - 2011 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.
*/
#if defined(USE_WINSOCK)
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 22
#endif
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 65
#endif
/* ---------------------------------- */
#if !defined(_WS2DEF_) && \
!defined(__CSADDR_DEFINED__) && \
!defined(__CSADDR_T_DEFINED)
/* ---------------------------------- */
typedef struct _SOCKET_ADDRESS {
LPSOCKADDR lpSockaddr;
INT iSockaddrLength;
} SOCKET_ADDRESS, *PSOCKET_ADDRESS;
typedef struct _CSADDR_INFO {
SOCKET_ADDRESS LocalAddr;
SOCKET_ADDRESS RemoteAddr;
INT iSocketType;
INT iProtocol;
} CSADDR_INFO, *PCSADDR_INFO;
/* --------------------------------- */
#endif /* ! _WS2DEF_ && \ */
/* ! __CSADDR_DEFINED__ && \ */
/* ! __CSADDR_T_DEFINED */
/* --------------------------------- */
/* ------------------------------- */
#if !defined(IP_ADAPTER_DDNS_ENABLED)
/* ------------------------------- */
#define IP_ADAPTER_ADDRESS_DNS_ELIGIBLE 0x0001
#define IP_ADAPTER_ADDRESS_TRANSIENT 0x0002
#define IP_ADAPTER_DDNS_ENABLED 0x0001
#define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX 0x0002
#define IP_ADAPTER_DHCP_ENABLED 0x0004
#define IP_ADAPTER_RECEIVE_ONLY 0x0008
#define IP_ADAPTER_NO_MULTICAST 0x0010
#define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x0020
#define GAA_FLAG_SKIP_UNICAST 0x0001
#define GAA_FLAG_SKIP_ANYCAST 0x0002
#define GAA_FLAG_SKIP_MULTICAST 0x0004
#define GAA_FLAG_SKIP_DNS_SERVER 0x0008
#define GAA_FLAG_INCLUDE_PREFIX 0x0010
#define GAA_FLAG_SKIP_FRIENDLY_NAME 0x0020
typedef enum {
IpPrefixOriginOther = 0,
IpPrefixOriginManual,
IpPrefixOriginWellKnown,
IpPrefixOriginDhcp,
IpPrefixOriginRouterAdvertisement
} IP_PREFIX_ORIGIN;
typedef enum {
IpSuffixOriginOther = 0,
IpSuffixOriginManual,
IpSuffixOriginWellKnown,
IpSuffixOriginDhcp,
IpSuffixOriginLinkLayerAddress,
IpSuffixOriginRandom
} IP_SUFFIX_ORIGIN;
typedef enum {
IpDadStateInvalid = 0,
IpDadStateTentative,
IpDadStateDuplicate,
IpDadStateDeprecated,
IpDadStatePreferred
} IP_DAD_STATE;
typedef enum {
IfOperStatusUp = 1,
IfOperStatusDown,
IfOperStatusTesting,
IfOperStatusUnknown,
IfOperStatusDormant,
IfOperStatusNotPresent,
IfOperStatusLowerLayerDown
} IF_OPER_STATUS;
typedef enum {
ScopeLevelInterface = 0x0001,
ScopeLevelLink = 0x0002,
ScopeLevelSubnet = 0x0003,
ScopeLevelAdmin = 0x0004,
ScopeLevelSite = 0x0005,
ScopeLevelOrganization = 0x0008,
ScopeLevelGlobal = 0x000E
} SCOPE_LEVEL;
typedef struct _IP_ADAPTER_UNICAST_ADDRESS {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Flags;
} s;
} u;
struct _IP_ADAPTER_UNICAST_ADDRESS *Next;
SOCKET_ADDRESS Address;
IP_PREFIX_ORIGIN PrefixOrigin;
IP_SUFFIX_ORIGIN SuffixOrigin;
IP_DAD_STATE DadState;
ULONG ValidLifetime;
ULONG PreferredLifetime;
ULONG LeaseLifetime;
} IP_ADAPTER_UNICAST_ADDRESS, *PIP_ADAPTER_UNICAST_ADDRESS;
typedef struct _IP_ADAPTER_ANYCAST_ADDRESS {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Flags;
} s;
} u;
struct _IP_ADAPTER_ANYCAST_ADDRESS *Next;
SOCKET_ADDRESS Address;
} IP_ADAPTER_ANYCAST_ADDRESS, *PIP_ADAPTER_ANYCAST_ADDRESS;
typedef struct _IP_ADAPTER_MULTICAST_ADDRESS {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Flags;
} s;
} u;
struct _IP_ADAPTER_MULTICAST_ADDRESS *Next;
SOCKET_ADDRESS Address;
} IP_ADAPTER_MULTICAST_ADDRESS, *PIP_ADAPTER_MULTICAST_ADDRESS;
typedef struct _IP_ADAPTER_DNS_SERVER_ADDRESS {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Reserved;
} s;
} u;
struct _IP_ADAPTER_DNS_SERVER_ADDRESS *Next;
SOCKET_ADDRESS Address;
} IP_ADAPTER_DNS_SERVER_ADDRESS, *PIP_ADAPTER_DNS_SERVER_ADDRESS;
typedef struct _IP_ADAPTER_PREFIX {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Flags;
} s;
} u;
struct _IP_ADAPTER_PREFIX *Next;
SOCKET_ADDRESS Address;
ULONG PrefixLength;
} IP_ADAPTER_PREFIX, *PIP_ADAPTER_PREFIX;
typedef struct _IP_ADAPTER_ADDRESSES {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD IfIndex;
} s;
} u;
struct _IP_ADAPTER_ADDRESSES *Next;
PCHAR AdapterName;
PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress;
PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress;
PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress;
PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress;
PWCHAR DnsSuffix;
PWCHAR Description;
PWCHAR FriendlyName;
BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH];
DWORD PhysicalAddressLength;
DWORD Flags;
DWORD Mtu;
DWORD IfType;
IF_OPER_STATUS OperStatus;
DWORD Ipv6IfIndex;
DWORD ZoneIndices[16];
PIP_ADAPTER_PREFIX FirstPrefix;
} IP_ADAPTER_ADDRESSES, *PIP_ADAPTER_ADDRESSES;
/* -------------------------------- */
#endif /* ! IP_ADAPTER_DDNS_ENABLED */
/* -------------------------------- */
#endif /* USE_WINSOCK */
#endif /* HEADER_CARES_IPHLPAPI_H */
+12 -18
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright (C) 2005 by Dominick Meglio
*
@@ -22,23 +21,14 @@
#define PF_INET6 AF_INET6
#endif
#if !defined(HAVE_STRUCT_IN6_ADDR) && !defined(s6_addr)
struct in6_addr {
union {
unsigned char _S6_u8[16];
} _S6_un;
};
#define s6_addr _S6_un._S6_u8
#endif
#ifndef HAVE_STRUCT_SOCKADDR_IN6
struct sockaddr_in6
{
unsigned short sin6_family;
unsigned short sin6_port;
unsigned long sin6_flowinfo;
struct in6_addr sin6_addr;
unsigned int sin6_scope_id;
unsigned short sin6_family;
unsigned short sin6_port;
unsigned long sin6_flowinfo;
struct ares_in6_addr sin6_addr;
unsigned int sin6_scope_id;
};
#endif
@@ -57,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
@@ -81,4 +71,8 @@ struct addrinfo
#endif
#endif
/* Defined in inet_net_pton.c for no particular reason. */
extern const struct ares_in6_addr ares_in6addr_any; /* :: */
#endif /* ARES_IPV6_H */
+17 -5
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\" Copyright (C) 2004-2009 by Daniel Stenberg
@@ -31,12 +30,20 @@ ares_library_cleanup \- c-ares library deinitialization
The
.B ares_library_cleanup
function uninitializes the c-ares library, freeing all resources
previously aquired by \fIares_library_init(3)\fP when the library
was initialized.
previously acquired by \fIares_library_init(3)\fP when the library
was initialized, provided there was only one single previous call to
\fIares_library_init(3)\fP. If there was more than one previous call to
\fIares_library_init(3)\fP, this function uninitializes the c-ares
library only if it is the call matching the call to
\fIares_library_init(3)\fP which initialized the library
(usually the very first call to \fIares_library_init(3)\fP).
Other calls to \fIares_library_cleanup(3)\fP have no effect other than
decrementing an internal counter.
.PP
This function must be called when the program using c-ares will
no longer need any c-ares function. Once the program has called
\fIares_library_cleanup(3)\fP it shall not make any further call to any
\fIares_library_cleanup(3)\fP sufficiently often such that the
library is uninitialised, it shall not make any further call to any
c-ares function.
.PP
This function does not cancel any pending c-ares lookups or requests
@@ -55,7 +62,12 @@ the DllMain function. Doing so will produce deadlocks and other problems.
.SH AVAILABILITY
This function was first introduced in c-ares version 1.7.0 along with the
definition of preprocessor symbol \fICARES_HAVE_ARES_LIBRARY_CLEANUP\fP as an
indication of the availability of this function.
indication of the availability of this function. Reference counting in
\fIares_library_init()\fP and \fIares_library_cleanup()\fP, which requires
calls to the former function to match calls to the latter, is present since
c-ares version 1.10.0.
Earlier versions would deinitialize the library on the first call
to \fIares_library_cleanup()\fP.
.PP
Since the introduction of this function, it is absolutely mandatory to call it
for any Win32/64 program using c-ares.
+26 -12
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\" Copyright (C) 2004-2009 by Daniel Stenberg
@@ -20,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
@@ -34,13 +36,15 @@ function performs initializations internally required by the c-ares
library that must take place before any other function provided by
c-ares can be used in a program.
.PP
This function must be called one time within the life of a program,
This function must be called at least once within the life of a program,
before the program actually executes any other c-ares library function.
Initializations done by this function remain effective until a
call to \fIares_library_cleanup(3)\fP is performed.
Initializations done by this function remain effective until a number of
calls to \fIares_library_cleanup(3)\fP equal to the number of calls to
this function are performed.
.PP
Successive calls to this function do nothing, only the first call done
when c-ares is in an uninitialized state is actually effective.
Successive calls to this function do nothing further, only the first
call done when c-ares is in an uninitialized state is actually
effective.
.PP
The
.I flags
@@ -50,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
@@ -78,7 +88,11 @@ non-zero error number will be returned to indicate the error. Except for
.SH AVAILABILITY
This function was first introduced in c-ares version 1.7.0 along with the
definition of preprocessor symbol \fICARES_HAVE_ARES_LIBRARY_INIT\fP as an
indication of the availability of this function.
indication of the availability of this function. Its recursive behavior,
which requires a matching number of calls to \fIares_library_cleanup()\fP
in order to deinitialize the library, is present since c-ares version
1.10.0. Earlier versions would deinitialize the library on the first call
to \fIares_library_cleanup()\fP.
.PP
Since the introduction of this function it is absolutely mandatory to
call it for any Win32/64 program using c-ares.
+56 -8
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2004-2009 by Daniel Stenberg
@@ -27,6 +26,7 @@
#ifdef USE_WINSOCK
fpGetNetworkParams_t ares_fpGetNetworkParams = ZERO_NULL;
fpSystemFunction036_t ares_fpSystemFunction036 = ZERO_NULL;
fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses = ZERO_NULL;
#endif
/* library-private global vars with source visibility restricted to this file */
@@ -34,6 +34,11 @@ fpSystemFunction036_t ares_fpSystemFunction036 = 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;
@@ -57,6 +62,15 @@ static int ares_win32_init(void)
return ARES_EADDRGETNETWORKPARAMS;
}
ares_fpGetAdaptersAddresses = (fpGetAdaptersAddresses_t)
GetProcAddress(hnd_iphlpapi, "GetAdaptersAddresses");
if (!ares_fpGetAdaptersAddresses)
{
/* This can happen on clients before WinXP, I don't
think it should be an error, unless we don't want to
support Windows 2000 anymore */
}
/*
* When advapi32.dll is unavailable or advapi32.dll has no SystemFunction036,
* also known as RtlGenRandom, which is the case for Windows versions prior
@@ -64,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)
@@ -92,14 +106,24 @@ int ares_library_init(int flags)
int res;
if (ares_initialized)
return ARES_SUCCESS;
{
ares_initialized++;
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;
@@ -107,17 +131,39 @@ 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)
{
if (!ares_initialized)
return;
ares_initialized--;
if (ares_initialized)
return;
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;
}
@@ -126,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;
}
+4 -2
View File
@@ -1,10 +1,9 @@
#ifndef HEADER_CARES_LIBRARY_INIT_H
#define HEADER_CARES_LIBRARY_INIT_H
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2004-2009 by Daniel Stenberg
* Copyright (C) 2004-2011 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -24,15 +23,18 @@
#ifdef USE_WINSOCK
#include <iphlpapi.h>
#include <ares_iphlpapi.h>
typedef DWORD (WINAPI *fpGetNetworkParams_t) (FIXED_INFO*, DWORD*);
typedef BOOLEAN (APIENTRY *fpSystemFunction036_t) (void*, ULONG);
typedef ULONG (WINAPI *fpGetAdaptersAddresses_t) ( ULONG, ULONG, void*, IP_ADAPTER_ADDRESSES*, ULONG* );
/* Forward-declaration of variables defined in ares_library_init.c */
/* that are global and unique instances for whole c-ares library. */
extern fpGetNetworkParams_t ares_fpGetNetworkParams;
extern fpSystemFunction036_t ares_fpSystemFunction036;
extern fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses;
#endif /* USE_WINSOCK */
-24
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
@@ -62,26 +61,3 @@ void ares__remove_from_list(struct list_node* node) {
}
}
/* Swap the contents of two lists */
void ares__swap_lists(struct list_node* head_a,
struct list_node* head_b) {
int is_a_empty = ares__is_list_empty(head_a);
int is_b_empty = ares__is_list_empty(head_b);
struct list_node old_a = *head_a;
struct list_node old_b = *head_b;
if (is_a_empty) {
ares__init_list_head(head_b);
} else {
*head_b = old_a;
old_a.next->prev = head_b;
old_a.prev->next = head_b;
}
if (is_b_empty) {
ares__init_list_head(head_a);
} else {
*head_a = old_b;
old_b.next->prev = head_a;
old_b.prev->next = head_a;
}
}
-4
View File
@@ -1,7 +1,6 @@
#ifndef __ARES_LLIST_H
#define __ARES_LLIST_H
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
@@ -37,7 +36,4 @@ void ares__insert_in_list(struct list_node* new_node,
void ares__remove_from_list(struct list_node* node);
void ares__swap_lists(struct list_node* head_a,
struct list_node* head_b);
#endif /* __ARES_LLIST_H */
+7 -1
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998, 2000 by the Massachusetts Institute of Technology.
.\"
@@ -26,6 +25,8 @@ ares_mkquery \- Compose a single-question DNS query buffer
.B int *\fIbuflen\fP)
.fi
.SH DESCRIPTION
Deprecated function. See \fIares_create_query(3)\fP instead!
The
.B ares_mkquery
function composes a DNS query with a single question.
@@ -51,6 +52,11 @@ and the length of which will be stored in the variable pointed to by
.IR buflen .
It is the caller's responsibility to free this buffer using
\fIares_free_string(3)\fP when it is no longer needed.
Usage of \fIares_mkquery(3)\fP is deprecated, whereas the function is
equivalent to \fIares_create_query(3)\fP with \fBmax_udp_size\fP set to
0.
.SH RETURN VALUES
.B ares_mkquery
can return any of the following values:
+1 -173
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
@@ -16,181 +15,10 @@
*/
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_private.h"
/* Header format, from RFC 1035:
* 1 1 1 1 1 1
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | ID |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |QR| Opcode |AA|TC|RD|RA| Z | RCODE |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | QDCOUNT |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | ANCOUNT |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | NSCOUNT |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | ARCOUNT |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
*
* AA, TC, RA, and RCODE are only set in responses. Brief description
* of the remaining fields:
* ID Identifier to match responses with queries
* QR Query (0) or response (1)
* Opcode For our purposes, always QUERY
* RD Recursion desired
* Z Reserved (zero)
* QDCOUNT Number of queries
* ANCOUNT Number of answers
* NSCOUNT Number of name server records
* ARCOUNT Number of additional records
*
* Question format, from RFC 1035:
* 1 1 1 1 1 1
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | |
* / QNAME /
* / /
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | QTYPE |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | QCLASS |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
*
* The query name is encoded as a series of labels, each represented
* as a one-byte length (maximum 63) followed by the text of the
* label. The list is terminated by a label of length zero (which can
* be thought of as the root domain).
*/
int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
int rd, unsigned char **buf, int *buflen)
{
int len;
unsigned char *q;
const char *p;
/* Set our results early, in case we bail out early with an error. */
*buflen = 0;
*buf = NULL;
/* Compute the length of the encoded name so we can check buflen.
* Start counting at 1 for the zero-length label at the end. */
len = 1;
for (p = name; *p; p++)
{
if (*p == '\\' && *(p + 1) != 0)
p++;
len++;
}
/* If there are n periods in the name, there are n + 1 labels, and
* thus n + 1 length fields, unless the name is empty or ends with a
* period. So add 1 unless name is empty or ends with a period.
*/
if (*name && *(p - 1) != '.')
len++;
/* Immediately reject names that are longer than the maximum of 255
* bytes that's specified in RFC 1035 ("To simplify implementations,
* the total length of a domain name (i.e., label octets and label
* length octets) is restricted to 255 octets or less."). We aren't
* doing this just to be a stickler about RFCs. For names that are
* too long, 'dnscache' closes its TCP connection to us immediately
* (when using TCP) and ignores the request when using UDP, and
* BIND's named returns ServFail (TCP or UDP). Sending a request
* that we know will cause 'dnscache' to close the TCP connection is
* painful, since that makes any other outstanding requests on that
* connection fail. And sending a UDP request that we know
* 'dnscache' will ignore is bad because resources will be tied up
* until we time-out the request.
*/
if (len > MAXCDNAME)
return ARES_EBADNAME;
*buflen = len + HFIXEDSZ + QFIXEDSZ;
*buf = malloc(*buflen);
if (!*buf)
return ARES_ENOMEM;
/* Set up the header. */
q = *buf;
memset(q, 0, HFIXEDSZ);
DNS_HEADER_SET_QID(q, id);
DNS_HEADER_SET_OPCODE(q, QUERY);
if (rd) {
DNS_HEADER_SET_RD(q, 1);
}
else {
DNS_HEADER_SET_RD(q, 0);
}
DNS_HEADER_SET_QDCOUNT(q, 1);
/* A name of "." is a screw case for the loop below, so adjust it. */
if (strcmp(name, ".") == 0)
name++;
/* Start writing out the name after the header. */
q += HFIXEDSZ;
while (*name)
{
if (*name == '.')
return ARES_EBADNAME;
/* Count the number of bytes in this label. */
len = 0;
for (p = name; *p && *p != '.'; p++)
{
if (*p == '\\' && *(p + 1) != 0)
p++;
len++;
}
if (len > MAXLABEL)
return ARES_EBADNAME;
/* Encode the length and copy the data. */
*q++ = (unsigned char)len;
for (p = name; *p && *p != '.'; p++)
{
if (*p == '\\' && *(p + 1) != 0)
p++;
*q++ = *p;
}
/* Go to the next label and repeat, unless we hit the end. */
if (!*p)
break;
name = p + 1;
}
/* Add the zero-length label at the end. */
*q++ = 0;
/* Finish off the question with the type and class. */
DNS_QUESTION_SET_TYPE(q, type);
DNS_QUESTION_SET_CLASS(q, dnsclass);
return ARES_SUCCESS;
return ares_create_query(name, dnsclass, type, id, rd, buf, buflen, 0);
}
+260
View File
@@ -0,0 +1,260 @@
/* Copyright (C) 2010-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#include "ares_setup.h"
#ifdef HAVE_ASSERT_H
# include <assert.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#if defined(__INTEL_COMPILER) && defined(__unix__)
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#endif /* __INTEL_COMPILER && __unix__ */
#define BUILDING_ARES_NOWARN_C 1
#include "ares_nowarn.h"
#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
# define CARES_MASK_SINT 0x7FFFFFFF
# define CARES_MASK_UINT 0xFFFFFFFF
# define CARES_MASK_SLONG 0x7FFFFFFFL
# define CARES_MASK_ULONG 0xFFFFFFFFUL
#else
# 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
/*
** unsigned size_t to signed long
*/
long aresx_uztosl(size_t uznum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
return (long)(uznum & (size_t) CARES_MASK_SLONG);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/*
** unsigned size_t to signed int
*/
int aresx_uztosi(size_t uznum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
return (int)(uznum & (size_t) CARES_MASK_SINT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/*
** unsigned size_t to signed short
*/
short aresx_uztoss(size_t uznum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
return (short)(uznum & (size_t) CARES_MASK_SSHORT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/*
** signed int to signed short
*/
short aresx_sitoss(int sinum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(sinum >= 0);
return (short)(sinum & (int) CARES_MASK_SSHORT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/*
** signed long to signed int
*/
int aresx_sltosi(long slnum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(slnum >= 0);
return (int)(slnum & (long) CARES_MASK_SINT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/*
** signed ssize_t to signed int
*/
int aresx_sztosi(ssize_t sznum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(sznum >= 0);
return (int)(sznum & (ssize_t) CARES_MASK_SINT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/*
** signed ssize_t to unsigned int
*/
unsigned int aresx_sztoui(ssize_t sznum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(sznum >= 0);
return (unsigned int)(sznum & (ssize_t) CARES_MASK_UINT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/*
** signed int to unsigned short
*/
unsigned short aresx_sitous(int sinum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(sinum >= 0);
return (unsigned short)(sinum & (int) CARES_MASK_USHORT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
#if defined(__INTEL_COMPILER) && defined(__unix__)
int aresx_FD_ISSET(int fd, fd_set *fdset)
{
#pragma warning(push)
#pragma warning(disable:1469) /* clobber ignored */
return FD_ISSET(fd, fdset);
#pragma warning(pop)
}
void aresx_FD_SET(int fd, fd_set *fdset)
{
#pragma warning(push)
#pragma warning(disable:1469) /* clobber ignored */
FD_SET(fd, fdset);
#pragma warning(pop)
}
void aresx_FD_ZERO(fd_set *fdset)
{
#pragma warning(push)
#pragma warning(disable:593) /* variable was set but never used */
FD_ZERO(fdset);
#pragma warning(pop)
}
unsigned short aresx_htons(unsigned short usnum)
{
#if (__INTEL_COMPILER == 910) && defined(__i386__)
return (unsigned short)(((usnum << 8) & 0xFF00) | ((usnum >> 8) & 0x00FF));
#else
#pragma warning(push)
#pragma warning(disable:810) /* conversion may lose significant bits */
return htons(usnum);
#pragma warning(pop)
#endif
}
unsigned short aresx_ntohs(unsigned short usnum)
{
#if (__INTEL_COMPILER == 910) && defined(__i386__)
return (unsigned short)(((usnum << 8) & 0xFF00) | ((usnum >> 8) & 0x00FF));
#else
#pragma warning(push)
#pragma warning(disable:810) /* conversion may lose significant bits */
return ntohs(usnum);
#pragma warning(pop)
#endif
}
#endif /* __INTEL_COMPILER && __unix__ */
+61
View File
@@ -0,0 +1,61 @@
#ifndef HEADER_CARES_NOWARN_H
#define HEADER_CARES_NOWARN_H
/* Copyright (C) 2010-2012 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.
*/
long aresx_uztosl(size_t uznum);
int aresx_uztosi(size_t uznum);
short aresx_uztoss(size_t uznum);
short aresx_sitoss(int sinum);
int aresx_sltosi(long slnum);
int aresx_sztosi(ssize_t sznum);
unsigned int aresx_sztoui(ssize_t sznum);
unsigned short aresx_sitous(int sinum);
#if defined(__INTEL_COMPILER) && defined(__unix__)
int aresx_FD_ISSET(int fd, fd_set *fdset);
void aresx_FD_SET(int fd, fd_set *fdset);
void aresx_FD_ZERO(fd_set *fdset);
unsigned short aresx_htons(unsigned short usnum);
unsigned short aresx_ntohs(unsigned short usnum);
#ifndef BUILDING_ARES_NOWARN_C
# undef FD_ISSET
# define FD_ISSET(a,b) aresx_FD_ISSET((a),(b))
# undef FD_SET
# define FD_SET(a,b) aresx_FD_SET((a),(b))
# undef FD_ZERO
# define FD_ZERO(a) aresx_FD_ZERO((a))
# undef htons
# define htons(a) aresx_htons((a))
# undef ntohs
# define ntohs(a) aresx_ntohs((a))
#endif
#endif /* __INTEL_COMPILER && __unix__ */
#endif /* HEADER_CARES_NOWARN_H */
+402
View File
@@ -0,0 +1,402 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2008-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#include "ares_setup.h"
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#include "ares.h"
#include "ares_data.h"
#include "ares_inet_net_pton.h"
#include "ares_private.h"
int ares_get_servers(ares_channel channel,
struct ares_addr_node **servers)
{
struct ares_addr_node *srvr_head = NULL;
struct ares_addr_node *srvr_last = NULL;
struct ares_addr_node *srvr_curr;
int status = ARES_SUCCESS;
int i;
if (!channel)
return ARES_ENODATA;
for (i = 0; i < channel->nservers; i++)
{
/* Allocate storage for this server node appending it to the list */
srvr_curr = ares_malloc_data(ARES_DATATYPE_ADDR_NODE);
if (!srvr_curr)
{
status = ARES_ENOMEM;
break;
}
if (srvr_last)
{
srvr_last->next = srvr_curr;
}
else
{
srvr_head = srvr_curr;
}
srvr_last = srvr_curr;
/* Fill this server node data */
srvr_curr->family = channel->servers[i].addr.family;
if (srvr_curr->family == AF_INET)
memcpy(&srvr_curr->addrV4, &channel->servers[i].addr.addrV4,
sizeof(srvr_curr->addrV4));
else
memcpy(&srvr_curr->addrV6, &channel->servers[i].addr.addrV6,
sizeof(srvr_curr->addrV6));
}
if (status != ARES_SUCCESS)
{
if (srvr_head)
{
ares_free_data(srvr_head);
srvr_head = NULL;
}
}
*servers = srvr_head;
return status;
}
int ares_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)
{
struct ares_addr_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 = 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));
else
memcpy(&channel->servers[i].addr.addrV6, &srvr->addrV6,
sizeof(srvr->addrV6));
}
/* Initialize servers state remaining data */
ares__init_servers_state(channel);
}
return ARES_SUCCESS;
}
/* Incomming string format: host[:port][,host[:port]]... */
/* IPv6 addresses with ports require square brackets [fe80::1%lo0]:53 */
static int set_servers_csv(ares_channel channel,
const char* _csv, int use_port)
{
size_t i;
char* csv = NULL;
char* ptr;
char* start_host;
int cc = 0;
int rv = ARES_SUCCESS;
struct ares_addr_port_node *servers = NULL;
struct ares_addr_port_node *last = NULL;
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);
i = strlen(_csv);
if (i == 0)
return ARES_SUCCESS; /* blank all servers */
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] = ',';
csv[i+1] = 0;
}
start_host = csv;
for (ptr = csv; *ptr; ptr++) {
if (*ptr == ':') {
/* count colons to determine if we have an IPv6 number or IPv4 with
port */
cc++;
}
else if (*ptr == '[') {
/* move start_host if an open square bracket is found wrapping an IPv6
address */
start_host = ptr + 1;
}
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_port_node *s = NULL;
*ptr = 0; /* null terminate host:port string */
/* Got an entry..see if the port was specified. */
if (cc > 0) {
while (pp > start_host) {
/* a single close square bracket followed by a colon, ']:' indicates
an IPv6 address with port */
if ((*pp == ']') && (*p == ':'))
break; /* found port */
/* a single colon, ':' indicates an IPv4 address with port */
if ((*pp == ':') && (cc == 1))
break; /* found port */
if (!(ISDIGIT(*pp) || (*pp == ':'))) {
/* Found end of digits before we found :, so wasn't a port */
/* must allow ':' for IPv6 case of ']:' indicates we found a port */
pp = p = ptr;
break;
}
pp--;
p--;
}
if ((pp != start_host) && ((pp + 1) < ptr)) {
/* Found it. Parse over the port number */
/* when an IPv6 address is wrapped with square brackets the port
starts at pp + 2 */
if (*pp == ']')
p++; /* move p before ':' */
/* p will point to the start of the port */
port = (int)strtol(p, NULL, 10);
*pp = 0; /* null terminate host */
}
}
/* resolve host, try ipv4 first, rslt is in network byte order */
rv = ares_inet_pton(AF_INET, start_host, &in4);
if (!rv) {
/* Ok, try IPv6 then */
rv = ares_inet_pton(AF_INET6, start_host, &in6);
if (!rv) {
rv = ARES_EBADSTR;
goto out;
}
/* was ipv6, add new server */
s = ares_malloc(sizeof(*s));
if (!s) {
rv = ARES_ENOMEM;
goto out;
}
s->family = AF_INET6;
memcpy(&s->addr, &in6, sizeof(struct ares_in6_addr));
}
else {
/* was ipv4, add new server */
s = ares_malloc(sizeof(*s));
if (!s) {
rv = ARES_ENOMEM;
goto out;
}
s->family = AF_INET;
memcpy(&s->addr, &in4, sizeof(struct in_addr));
}
if (s) {
s->udp_port = use_port ? port: 0;
s->tcp_port = s->udp_port;
s->next = NULL;
if (last) {
last->next = s;
/* need to move last to maintain the linked list */
last = last->next;
}
else {
servers = s;
last = s;
}
}
/* Set up for next one */
start_host = ptr + 1;
cc = 0;
}
}
rv = ares_set_servers_ports(channel, servers);
out:
if (csv)
ares_free(csv);
while (servers) {
struct ares_addr_port_node *s = servers;
servers = servers->next;
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);
}
+1 -2
View File
@@ -1,4 +1,3 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
@@ -23,7 +22,7 @@ ares_parse_a_reply \- Parse a reply to a DNS query of type A
.PP
.B int ares_parse_a_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
.B struct hostent **\fIhost\fP,
.B struct ares_addrttl *\fIaddrttls\fB, int *\fInaddrttls\fB);
.B struct ares_addrttl *\fIaddrttls\fP, int *\fInaddrttls\fP);
.fi
.SH DESCRIPTION
The

Some files were not shown because too many files have changed in this diff Show More