Commit Graph

17 Commits

Author SHA1 Message Date
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 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 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
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
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 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 3cb1afe054 strlen: use size_t to receive the return 2011-06-04 20:14:38 +02:00
Daniel Stenberg d70721eb65 ares_set_servers_csv: remove unused variables 2010-12-27 13:19:37 +01:00
Yang Tse e3f7230dc2 atoi: remove atoi usage 2010-11-29 02:22:08 +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
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 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 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
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 63627fa5ab remove all $Id$ lines 2010-03-27 19:42:02 +01:00
Yang Tse 8fe746fcf2 Added IPv6 name servers support 2010-03-05 20:01:47 +00:00