clang-format

pull/595/head
Brad House 1 year ago
parent 699f469f18
commit 2cc2779fc9
  1. 25
      src/lib/ares__buf.c
  2. 14
      src/lib/ares__buf.h
  3. 14
      src/lib/ares__close_sockets.c
  4. 271
      src/lib/ares__hosts_file.c
  5. 7
      src/lib/ares__htable_strvp.c
  6. 4
      src/lib/ares__htable_strvp.h
  7. 5
      src/lib/ares__slist.c
  8. 9
      src/lib/ares__socket.c
  9. 3
      src/lib/ares__sortaddrinfo.c
  10. 2
      src/lib/ares_cancel.c
  11. 7
      src/lib/ares_destroy.c
  12. 6
      src/lib/ares_fds.c
  13. 21
      src/lib/ares_getaddrinfo.c
  14. 9
      src/lib/ares_gethostbyaddr.c
  15. 12
      src/lib/ares_gethostbyname.c
  16. 2
      src/lib/ares_getnameinfo.c
  17. 10
      src/lib/ares_getsock.c
  18. 30
      src/lib/ares_init.c
  19. 40
      src/lib/ares_options.c
  20. 147
      src/lib/ares_private.h
  21. 65
      src/lib/ares_process.c
  22. 183
      src/lib/ares_sysconfig.c
  23. 74
      src/lib/ares_sysconfig_files.c
  24. 171
      src/lib/ares_update_servers.c
  25. 2
      src/lib/config-win32.h

@ -45,7 +45,6 @@ struct ares__buf {
* SIZE_MAX if not set. */
};
/* Reserved characters for names that need to be escaped */
static ares_bool_t is_reservedch(int ch)
{
@ -107,7 +106,6 @@ ares_bool_t ares__is_hostnamech(int ch)
return ARES_FALSE;
}
ares__buf_t *ares__buf_create(void)
{
ares__buf_t *buf = ares_malloc_zero(sizeof(*buf));
@ -389,8 +387,9 @@ const unsigned char *ares__buf_tag_fetch(const ares__buf_t *buf, size_t *len)
size_t ares__buf_tag_length(const ares__buf_t *buf)
{
if (buf == NULL || buf->tag_offset == SIZE_MAX)
if (buf == NULL || buf->tag_offset == SIZE_MAX) {
return 0;
}
return buf->offset - buf->tag_offset;
}
@ -400,11 +399,13 @@ ares_status_t ares__buf_tag_fetch_bytes(const ares__buf_t *buf,
size_t ptr_len = 0;
const unsigned char *ptr = ares__buf_tag_fetch(buf, &ptr_len);
if (ptr == NULL || bytes == NULL || len == NULL)
if (ptr == NULL || bytes == NULL || len == NULL) {
return ARES_EFORMERR;
}
if (*len < ptr_len)
if (*len < ptr_len) {
return ARES_EFORMERR;
}
*len = ptr_len;
@ -421,23 +422,26 @@ ares_status_t ares__buf_tag_fetch_string(const ares__buf_t *buf, char *str,
ares_status_t status;
size_t i;
if (str == NULL || len == 0)
if (str == NULL || len == 0) {
return ARES_EFORMERR;
}
/* Space for NULL terminator */
out_len = len - 1;
status = ares__buf_tag_fetch_bytes(buf, (unsigned char *)str, &out_len);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
/* NULL terminate */
str[out_len] = 0;
/* Validate string is printable */
for (i=0; i<out_len; i++) {
if (!ares__isprint(str[i]))
for (i = 0; i < out_len; i++) {
if (!ares__isprint(str[i])) {
return ARES_EBADSTR;
}
}
return ARES_SUCCESS;
@ -573,7 +577,6 @@ ares_status_t ares__buf_fetch_bytes_into_buf(ares__buf_t *buf,
return ares__buf_consume(buf, len);
}
static ares_status_t ares__buf_fetch_dnsname_into_buf(ares__buf_t *buf,
ares__buf_t *dest,
size_t len,
@ -642,7 +645,7 @@ fail:
}
size_t ares__buf_consume_whitespace(ares__buf_t *buf,
ares_bool_t include_linefeed)
ares_bool_t include_linefeed)
{
size_t remaining_len = 0;
const unsigned char *ptr = ares__buf_fetch(buf, &remaining_len);

@ -181,7 +181,7 @@ const unsigned char *ares__buf_tag_fetch(const ares__buf_t *buf, size_t *len);
* \param[in] buf Initialized buffer object
* \return length
*/
size_t ares__buf_tag_length(const ares__buf_t *buf);
size_t ares__buf_tag_length(const ares__buf_t *buf);
/*! Fetch the bytes starting from the tagged position up to the _current_
* position using the provided buffer. It will not unset the tagged position.
@ -192,8 +192,8 @@ size_t ares__buf_tag_length(const ares__buf_t *buf);
* buffer.
* \return ARES_SUCCESS if fetched, ARES_EFORMERR if insufficient buffer size
*/
ares_status_t ares__buf_tag_fetch_bytes(const ares__buf_t *buf,
unsigned char *bytes, size_t *len);
ares_status_t ares__buf_tag_fetch_bytes(const ares__buf_t *buf,
unsigned char *bytes, size_t *len);
/*! Fetch the bytes starting from the tagged position up to the _current_
* position as a NULL-terminated string using the provided buffer. The data
@ -216,7 +216,7 @@ ares_status_t ares__buf_tag_fetch_string(const ares__buf_t *buf, char *str,
* \param[in] len Length to consume
* \return ARES_SUCCESS or one of the c-ares error codes
*/
ares_status_t ares__buf_consume(ares__buf_t *buf, size_t len);
ares_status_t ares__buf_consume(ares__buf_t *buf, size_t len);
/*! Fetch a 16bit Big Endian number from the buffer.
*
@ -287,8 +287,8 @@ ares_status_t ares__buf_fetch_str_dup(ares__buf_t *buf, size_t len, char **str);
* ARES_FALSE otherwise.
* \return number of whitespace characters consumed
*/
size_t ares__buf_consume_whitespace(ares__buf_t *buf,
ares_bool_t include_linefeed);
size_t ares__buf_consume_whitespace(ares__buf_t *buf,
ares_bool_t include_linefeed);
/*! Consume any non-whitespace character (anything other than 0x09, 0x0B, 0x0C,
@ -297,7 +297,7 @@ size_t ares__buf_consume_whitespace(ares__buf_t *buf,
* \param[in] buf Initialized buffer object
* \return number of characters consumed
*/
size_t ares__buf_consume_nonwhitespace(ares__buf_t *buf);
size_t ares__buf_consume_nonwhitespace(ares__buf_t *buf);
/*! Consume from the current position until the end of the line, and optionally
* the end of line character (0x0A) itself.

@ -33,8 +33,8 @@
static void ares__requeue_queries(struct server_connection *conn)
{
struct query *query;
struct timeval now = ares__tvnow();
struct query *query;
struct timeval now = ares__tvnow();
while ((query = ares__llist_first_val(conn->queries_to_conn)) != NULL) {
ares__requeue_query(query, &now);
@ -55,7 +55,7 @@ void ares__close_connection(struct server_connection *conn)
/* Reset any existing input and output buffer. */
ares__buf_consume(server->tcp_parser, ares__buf_len(server->tcp_parser));
ares__buf_consume(server->tcp_send, ares__buf_len(server->tcp_send));
server->tcp_conn = NULL;
server->tcp_conn = NULL;
}
/* Requeue queries to other connections */
@ -79,13 +79,14 @@ void ares__close_sockets(struct server_state *server)
}
}
void ares__check_cleanup_conn(ares_channel channel,
void ares__check_cleanup_conn(ares_channel channel,
struct server_connection *conn)
{
ares_bool_t do_cleanup = ARES_FALSE;
if (channel == NULL || conn == NULL)
if (channel == NULL || conn == NULL) {
return;
}
if (ares__llist_len(conn->queries_to_conn)) {
return;
@ -102,8 +103,9 @@ void ares__check_cleanup_conn(ares_channel channel,
do_cleanup = ARES_TRUE;
}
if (!do_cleanup)
if (!do_cleanup) {
return;
}
ares__close_connection(conn);
}

@ -44,7 +44,6 @@
#include <time.h>
#include "ares_platform.h"
/* HOSTS FILE PROCESSING OVERVIEW
* ==============================
* The hosts file on the system contains static entries to be processed locally
@ -92,15 +91,15 @@ struct ares_hosts_file {
ares__htable_strvp_t *hosthash;
};
struct ares_hosts_entry {
struct ares_hosts_entry {
size_t refcnt; /*! If the entry is stored multiple times in the
* ip address hash, we have to reference count it */
ares__llist_t *ips;
ares__llist_t *hosts;
};
static ares_status_t ares__read_file_into_buf(const char *filename, ares__buf_t *buf)
static ares_status_t ares__read_file_into_buf(const char *filename,
ares__buf_t *buf)
{
FILE *fp = NULL;
unsigned char *ptr = NULL;
@ -108,8 +107,9 @@ static ares_status_t ares__read_file_into_buf(const char *filename, ares__buf_t
size_t ptr_len = 0;
ares_status_t status;
if (filename == NULL || buf == NULL)
if (filename == NULL || buf == NULL) {
return ARES_EFORMERR;
}
fp = fopen(filename, "rb");
if (fp == NULL) {
@ -139,7 +139,7 @@ static ares_status_t ares__read_file_into_buf(const char *filename, ares__buf_t
goto done;
}
if (len == 0) {
if (len == 0) {
status = ARES_SUCCESS;
goto done;
}
@ -162,31 +162,32 @@ static ares_status_t ares__read_file_into_buf(const char *filename, ares__buf_t
status = ARES_SUCCESS;
done:
if (fp != NULL)
if (fp != NULL) {
fclose(fp);
}
return status;
}
static ares_bool_t ares__is_hostname(const char *str)
{
size_t i;
for (i=0; str[i] != 0; i++) {
if (!ares__is_hostnamech(str[i]))
for (i = 0; str[i] != 0; i++) {
if (!ares__is_hostnamech(str[i])) {
return ARES_FALSE;
}
}
return ARES_TRUE;
}
static const void *ares__parse_ipaddr(const char *ipaddr,
struct ares_addr *addr,
size_t *out_len)
static const void *ares__parse_ipaddr(const char *ipaddr,
struct ares_addr *addr, size_t *out_len)
{
const void *ptr = NULL;
size_t ptr_len = 0;
if (ipaddr == NULL || addr == NULL || out_len == NULL)
if (ipaddr == NULL || addr == NULL || out_len == NULL) {
return NULL;
}
*out_len = 0;
@ -200,13 +201,13 @@ static const void *ares__parse_ipaddr(const char *ipaddr,
ptr_len = sizeof(addr->addr.addr6);
} else if (addr->family == AF_UNSPEC) {
if (ares_inet_pton(AF_INET, ipaddr, &addr->addr.addr4) > 0) {
addr->family = AF_INET;
ptr = &addr->addr.addr4;
ptr_len = sizeof(addr->addr.addr4);
addr->family = AF_INET;
ptr = &addr->addr.addr4;
ptr_len = sizeof(addr->addr.addr4);
} else if (ares_inet_pton(AF_INET6, ipaddr, &addr->addr.addr6) > 0) {
addr->family = AF_INET6;
ptr = &addr->addr.addr6;
ptr_len = sizeof(addr->addr.addr6);
addr->family = AF_INET6;
ptr = &addr->addr.addr6;
ptr_len = sizeof(addr->addr.addr6);
}
}
@ -217,16 +218,17 @@ static const void *ares__parse_ipaddr(const char *ipaddr,
static ares_bool_t ares__normalize_ipaddr(const char *ipaddr, char *out,
size_t out_len)
{
struct ares_addr data;
const void *addr;
size_t addr_len = 0;
struct ares_addr data;
const void *addr;
size_t addr_len = 0;
memset(&data, 0, sizeof(data));
data.family = AF_UNSPEC;
addr = ares__parse_ipaddr(ipaddr, &data, &addr_len);
if (addr == NULL)
if (addr == NULL) {
return ARES_FALSE;
}
if (!ares_inet_ntop(data.family, addr, out, (ares_socklen_t)out_len)) {
return ARES_FALSE;
@ -237,15 +239,18 @@ static ares_bool_t ares__normalize_ipaddr(const char *ipaddr, char *out,
static void ares__hosts_entry_destroy(ares_hosts_entry_t *entry)
{
if (entry == NULL)
if (entry == NULL) {
return;
}
/* Honor reference counting */
if (entry->refcnt != 0)
if (entry->refcnt != 0) {
entry->refcnt--;
}
if (entry->refcnt > 0)
if (entry->refcnt > 0) {
return;
}
ares__llist_destroy(entry->hosts);
ares__llist_destroy(entry->ips);
@ -259,8 +264,9 @@ static void ares__hosts_entry_destroy_cb(void *entry)
void ares__hosts_file_destroy(ares_hosts_file_t *hf)
{
if (hf == NULL)
if (hf == NULL) {
return;
}
ares_free(hf->filename);
ares__htable_strvp_destroy(hf->hosthash);
@ -299,38 +305,40 @@ fail:
return NULL;
}
static ares_bool_t ares__hosts_entry_ipaddr_exists(
ares_hosts_entry_t *entry, const char *ipaddr)
static ares_bool_t ares__hosts_entry_ipaddr_exists(ares_hosts_entry_t *entry,
const char *ipaddr)
{
ares__llist_node_t *node;
for (node = ares__llist_node_first(entry->ips) ; node != NULL ;
for (node = ares__llist_node_first(entry->ips); node != NULL;
node = ares__llist_node_next(node)) {
const char *myaddr = ares__llist_node_val(node);
if (strcmp(myaddr, ipaddr) == 0)
if (strcmp(myaddr, ipaddr) == 0) {
return ARES_TRUE;
}
}
return ARES_FALSE;
}
static ares_bool_t ares__hosts_entry_host_exists(
ares_hosts_entry_t *entry, const char *host)
static ares_bool_t ares__hosts_entry_host_exists(ares_hosts_entry_t *entry,
const char *host)
{
ares__llist_node_t *node;
for (node = ares__llist_node_first(entry->ips) ; node != NULL ;
for (node = ares__llist_node_first(entry->ips); node != NULL;
node = ares__llist_node_next(node)) {
const char *myhost = ares__llist_node_val(node);
if (strcasecmp(myhost, host) == 0)
if (strcasecmp(myhost, host) == 0) {
return ARES_TRUE;
}
}
return ARES_FALSE;
}
static ares_status_t ares__hosts_file_merge_entry(
ares_hosts_entry_t *existing, ares_hosts_entry_t *entry)
static ares_status_t ares__hosts_file_merge_entry(ares_hosts_entry_t *existing,
ares_hosts_entry_t *entry)
{
ares__llist_node_t *node;
@ -373,40 +381,42 @@ typedef enum {
ARES_MATCH_HOST = 2
} ares_hosts_file_match_t;
static ares_hosts_file_match_t ares__hosts_file_match(
const ares_hosts_file_t *hf, ares_hosts_entry_t *entry,
ares_hosts_entry_t **match)
static ares_hosts_file_match_t
ares__hosts_file_match(const ares_hosts_file_t *hf, ares_hosts_entry_t *entry,
ares_hosts_entry_t **match)
{
ares__llist_node_t *node;
*match = NULL;
for (node = ares__llist_node_first(entry->ips) ; node != NULL ;
for (node = ares__llist_node_first(entry->ips); node != NULL;
node = ares__llist_node_next(node)) {
const char *ipaddr = ares__llist_node_val(node);
*match = ares__htable_strvp_get_direct(hf->iphash, ipaddr);
if (*match != NULL)
*match = ares__htable_strvp_get_direct(hf->iphash, ipaddr);
if (*match != NULL) {
return ARES_MATCH_IPADDR;
}
}
for (node = ares__llist_node_first(entry->hosts) ; node != NULL ;
for (node = ares__llist_node_first(entry->hosts); node != NULL;
node = ares__llist_node_next(node)) {
const char *host = ares__llist_node_val(node);
*match = ares__htable_strvp_get_direct(hf->hosthash, host);
if (*match != NULL)
*match = ares__htable_strvp_get_direct(hf->hosthash, host);
if (*match != NULL) {
return ARES_MATCH_HOST;
}
}
return ARES_MATCH_NONE;
}
/*! entry is invalidated upon calling this function, always, even on error */
static ares_status_t ares__hosts_file_add(ares_hosts_file_t *hosts,
static ares_status_t ares__hosts_file_add(ares_hosts_file_t *hosts,
ares_hosts_entry_t *entry)
{
ares_hosts_entry_t *match = NULL;
ares_status_t status = ARES_SUCCESS;
ares__llist_node_t *node;
ares_hosts_file_match_t matchtype;
ares_hosts_entry_t *match = NULL;
ares_status_t status = ARES_SUCCESS;
ares__llist_node_t *node;
ares_hosts_file_match_t matchtype;
matchtype = ares__hosts_file_match(hosts, entry, &match);
@ -438,8 +448,9 @@ static ares_status_t ares__hosts_file_add(ares_hosts_file_t *hosts,
/* first hostname match wins. If we detect a duplicate hostname for another
* ip it will automatically be added to the same entry */
if (ares__htable_strvp_get(hosts->hosthash, val, NULL))
if (ares__htable_strvp_get(hosts->hosthash, val, NULL)) {
continue;
}
if (!ares__htable_strvp_insert(hosts->hosthash, val, entry)) {
return ARES_ENOMEM;
@ -449,12 +460,13 @@ static ares_status_t ares__hosts_file_add(ares_hosts_file_t *hosts,
return ARES_SUCCESS;
}
static ares_status_t ares__parse_hosts_hostnames(ares__buf_t *buf,
static ares_status_t ares__parse_hosts_hostnames(ares__buf_t *buf,
ares_hosts_entry_t *entry)
{
entry->hosts = ares__llist_create(ares_free);
if (entry->hosts == NULL)
if (entry->hosts == NULL) {
return ARES_ENOMEM;
}
/* Parse hostnames and aliases */
while (ares__buf_len(buf)) {
@ -465,8 +477,9 @@ static ares_status_t ares__parse_hosts_hostnames(ares__buf_t *buf,
ares__buf_consume_whitespace(buf, ARES_FALSE);
if (ares__buf_len(buf) == 0)
if (ares__buf_len(buf) == 0) {
break;
}
/* See if it is a comment, if so stop processing */
if (ares__buf_begins_with(buf, &comment, 1)) {
@ -476,31 +489,36 @@ static ares_status_t ares__parse_hosts_hostnames(ares__buf_t *buf,
ares__buf_tag(buf);
/* Must be at end of line */
if (ares__buf_consume_nonwhitespace(buf) == 0)
if (ares__buf_consume_nonwhitespace(buf) == 0) {
break;
}
status = ares__buf_tag_fetch_string(buf, hostname, sizeof(hostname));
if (status != ARES_SUCCESS) {
/* Bad entry, just ignore as long as its not the first. If its the first,
* it must be valid */
if (ares__llist_len(entry->hosts) == 0)
if (ares__llist_len(entry->hosts) == 0) {
return ARES_EBADSTR;
}
continue;
}
/* Validate it is a valid hostname characterset */
if (!ares__is_hostname(hostname))
if (!ares__is_hostname(hostname)) {
continue;
}
/* Don't add a duplicate to the same entry */
if (ares__hosts_entry_host_exists(entry, hostname))
if (ares__hosts_entry_host_exists(entry, hostname)) {
continue;
}
/* Add to list */
temp = ares_strdup(hostname);
if (temp == NULL)
if (temp == NULL) {
return ARES_ENOMEM;
}
if (ares__llist_insert_last(entry->hosts, temp) == NULL) {
ares_free(temp);
@ -509,19 +527,19 @@ static ares_status_t ares__parse_hosts_hostnames(ares__buf_t *buf,
}
/* Must have at least 1 entry */
if (ares__llist_len(entry->hosts) == 0)
if (ares__llist_len(entry->hosts) == 0) {
return ARES_EBADSTR;
}
return ARES_SUCCESS;
}
static ares_status_t ares__parse_hosts_ipaddr(ares__buf_t *buf,
static ares_status_t ares__parse_hosts_ipaddr(ares__buf_t *buf,
ares_hosts_entry_t **entry_out)
{
char addr[INET6_ADDRSTRLEN];
char *temp;
ares_hosts_entry_t *entry = NULL;
ares_hosts_entry_t *entry = NULL;
ares_status_t status;
*entry_out = NULL;
@ -566,26 +584,26 @@ static ares_status_t ares__parse_hosts_ipaddr(ares__buf_t *buf,
return ARES_SUCCESS;
}
static ares_status_t ares__parse_hosts(const char *filename,
static ares_status_t ares__parse_hosts(const char *filename,
ares_hosts_file_t **out)
{
ares__buf_t *buf = NULL;
ares_status_t status = ARES_EBADRESP;
ares_hosts_file_t *hf = NULL;
ares_hosts_entry_t *entry = NULL;
ares__buf_t *buf = NULL;
ares_status_t status = ARES_EBADRESP;
ares_hosts_file_t *hf = NULL;
ares_hosts_entry_t *entry = NULL;
*out = NULL;
buf = ares__buf_create();
buf = ares__buf_create();
if (buf == NULL) {
status = ARES_ENOMEM;
goto done;
}
status = ares__read_file_into_buf(filename, buf);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
goto done;
}
hf = ares__hosts_file_create(filename);
if (hf == NULL) {
@ -613,8 +631,9 @@ static ares_status_t ares__parse_hosts(const char *filename,
/* Pull off ip address */
status = ares__parse_hosts_ipaddr(buf, &entry);
if (status == ARES_ENOMEM)
if (status == ARES_ENOMEM) {
goto done;
}
if (status != ARES_SUCCESS) {
/* Bad line, consume and go onto next */
ares__buf_consume_line(buf, ARES_TRUE);
@ -657,8 +676,7 @@ done:
return status;
}
static ares_bool_t ares__hosts_expired(const char *filename,
static ares_bool_t ares__hosts_expired(const char *filename,
const ares_hosts_file_t *hf)
{
time_t mod_ts = 0;
@ -677,8 +695,9 @@ static ares_bool_t ares__hosts_expired(const char *filename,
(void)filename;
#endif
if (hf == NULL)
if (hf == NULL) {
return ARES_TRUE;
}
/* Expire every 60s if we can't get a time */
if (mod_ts == 0) {
@ -686,20 +705,21 @@ static ares_bool_t ares__hosts_expired(const char *filename,
}
/* If filenames are different, its expired */
if (strcasecmp(hf->filename, filename) != 0)
if (strcasecmp(hf->filename, filename) != 0) {
return ARES_TRUE;
}
if (hf->ts <= mod_ts)
if (hf->ts <= mod_ts) {
return ARES_TRUE;
}
return ARES_FALSE;
}
static ares_status_t ares__hosts_path(ares_channel channel, ares_bool_t use_env,
char **path)
{
char *path_hosts = NULL;
char *path_hosts = NULL;
*path = NULL;
@ -766,16 +786,16 @@ static ares_status_t ares__hosts_path(ares_channel channel, ares_bool_t use_env,
return ARES_SUCCESS;
}
static ares_status_t ares__hosts_update(ares_channel channel,
ares_bool_t use_env)
ares_bool_t use_env)
{
ares_status_t status;
char *filename = NULL;
char *filename = NULL;
status = ares__hosts_path(channel, use_env, &filename);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
if (!ares__hosts_expired(filename, channel->hf)) {
ares_free(filename);
@ -800,25 +820,28 @@ ares_status_t ares__hosts_search_ipaddr(ares_channel channel,
*entry = NULL;
status = ares__hosts_update(channel, use_env);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
if (channel->hf == NULL)
if (channel->hf == NULL) {
return ARES_ENOTFOUND;
}
if (!ares__normalize_ipaddr(ipaddr, addr, sizeof(addr))) {
return ARES_EBADNAME;
}
*entry = ares__htable_strvp_get_direct(channel->hf->iphash, addr);
if (*entry == NULL)
if (*entry == NULL) {
return ARES_ENOTFOUND;
}
return ARES_SUCCESS;
}
ares_status_t ares__hosts_search_host(ares_channel channel,
ares_bool_t use_env, const char *host,
ares_status_t ares__hosts_search_host(ares_channel channel, ares_bool_t use_env,
const char *host,
const ares_hosts_entry_t **entry)
{
ares_status_t status;
@ -826,11 +849,13 @@ ares_status_t ares__hosts_search_host(ares_channel channel,
*entry = NULL;
status = ares__hosts_update(channel, use_env);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
if (channel->hf == NULL)
if (channel->hf == NULL) {
return ARES_ENOTFOUND;
}
*entry = ares__htable_strvp_get_direct(channel->hf->hosthash, host);
if (*entry == NULL) {
@ -841,8 +866,7 @@ ares_status_t ares__hosts_search_host(ares_channel channel,
}
ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry,
int family,
struct hostent **hostent)
int family, struct hostent **hostent)
{
ares_status_t status;
size_t naliases;
@ -861,18 +885,19 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry,
idx = 0;
for (node = ares__llist_node_first(entry->ips); node != NULL;
node = ares__llist_node_next(node)) {
struct ares_addr addr;
const void *ptr = NULL;
size_t ptr_len = 0;
const char *ipaddr = ares__llist_node_val(node);
char **temp = NULL;
struct ares_addr addr;
const void *ptr = NULL;
size_t ptr_len = 0;
const char *ipaddr = ares__llist_node_val(node);
char **temp = NULL;
memset(&addr, 0, sizeof(addr));
addr.family = family;
ptr = ares__parse_ipaddr(ipaddr, &addr, &ptr_len);
if (ptr == NULL)
ptr = ares__parse_ipaddr(ipaddr, &addr, &ptr_len);
if (ptr == NULL) {
continue;
}
/* If family == AF_UNSPEC, then we want to inherit this for future
* conversions as we can only support a single address class */
@ -882,8 +907,8 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry,
}
temp = ares_realloc_zero((*hostent)->h_addr_list,
(idx + 1) * sizeof(*(*hostent)->h_addr_list),
(idx + 2) * sizeof(*(*hostent)->h_addr_list));
(idx + 1) * sizeof(*(*hostent)->h_addr_list),
(idx + 2) * sizeof(*(*hostent)->h_addr_list));
if (temp == NULL) {
status = ARES_ENOMEM;
goto fail;
@ -917,15 +942,15 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry,
/* Copy aliases */
naliases = ares__llist_len(entry->hosts) - 1;
(*hostent)->h_aliases = ares_malloc_zero((naliases + 1) *
sizeof((*hostent)->h_aliases));
(*hostent)->h_aliases =
ares_malloc_zero((naliases + 1) * sizeof((*hostent)->h_aliases));
if ((*hostent)->h_aliases == NULL) {
status = ARES_ENOMEM;
goto fail;
}
/* Copy all entries to the alias except the first */
idx = 0;
idx = 0;
node = ares__llist_node_first(entry->hosts);
node = ares__llist_node_next(node);
while (node != NULL) {
@ -946,11 +971,12 @@ fail:
return status;
}
static ares_status_t ares__hosts_ai_append_cnames(
const ares_hosts_entry_t *entry, struct ares_addrinfo_cname **cnames_out)
static ares_status_t
ares__hosts_ai_append_cnames(const ares_hosts_entry_t *entry,
struct ares_addrinfo_cname **cnames_out)
{
struct ares_addrinfo_cname *cname = NULL;
struct ares_addrinfo_cname *cnames = NULL;
struct ares_addrinfo_cname *cname = NULL;
struct ares_addrinfo_cname *cnames = NULL;
const char *primaryhost;
ares__llist_node_t *node;
ares_status_t status;
@ -958,10 +984,10 @@ static ares_status_t ares__hosts_ai_append_cnames(
node = ares__llist_node_first(entry->hosts);
primaryhost = ares__llist_node_val(node);
/* Skip to next node to start with aliases */
node = ares__llist_node_next(node);
node = ares__llist_node_next(node);
while (node != NULL) {
const char *host = ares__llist_node_val(node);
const char *host = ares__llist_node_val(node);
cname = ares__append_addrinfo_cname(&cnames);
if (cname == NULL) {
@ -1011,15 +1037,14 @@ done:
}
ares_status_t ares__hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry,
const char *name,
int family,
unsigned short port,
ares_bool_t want_cnames,
const char *name, int family,
unsigned short port,
ares_bool_t want_cnames,
struct ares_addrinfo *ai)
{
ares_status_t status;
struct ares_addrinfo_cname *cnames = NULL;
struct ares_addrinfo_node *ainodes = NULL;
struct ares_addrinfo_cname *cnames = NULL;
struct ares_addrinfo_node *ainodes = NULL;
ares__llist_node_t *node;
switch (family) {
@ -1039,14 +1064,14 @@ ares_status_t ares__hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry,
for (node = ares__llist_node_first(entry->ips); node != NULL;
node = ares__llist_node_next(node)) {
struct ares_addr addr;
const void *ptr = NULL;
size_t ptr_len = 0;
const char *ipaddr = ares__llist_node_val(node);
struct ares_addr addr;
const void *ptr = NULL;
size_t ptr_len = 0;
const char *ipaddr = ares__llist_node_val(node);
memset(&addr, 0, sizeof(addr));
addr.family = family;
ptr = ares__parse_ipaddr(ipaddr, &addr, &ptr_len);
ptr = ares__parse_ipaddr(ipaddr, &addr, &ptr_len);
if (ptr == NULL) {
continue;

@ -113,8 +113,7 @@ fail:
}
ares_bool_t ares__htable_strvp_insert(ares__htable_strvp_t *htable,
const char *key,
void *val)
const char *key, void *val)
{
ares__htable_strvp_bucket_t *bucket = NULL;
@ -132,7 +131,7 @@ ares_bool_t ares__htable_strvp_insert(ares__htable_strvp_t *htable,
if (bucket->key == NULL) {
goto fail;
}
bucket->val = val;
bucket->val = val;
if (!ares__htable_insert(htable->hash, bucket)) {
goto fail;
@ -181,7 +180,7 @@ void *ares__htable_strvp_get_direct(const ares__htable_strvp_t *htable,
}
ares_bool_t ares__htable_strvp_remove(ares__htable_strvp_t *htable,
const char *key)
const char *key)
{
if (htable == NULL) {
return ARES_FALSE;

@ -49,7 +49,7 @@ typedef struct ares__htable_strvp ares__htable_strvp_t;
*
* \param[in] val user-supplied value
*/
typedef void (*ares__htable_strvp_val_free_t)(void *val);
typedef void (*ares__htable_strvp_val_free_t)(void *val);
/*! Destroy hashtable
*
@ -104,7 +104,7 @@ void *ares__htable_strvp_get_direct(const ares__htable_strvp_t *htable,
* \return ARES_TRUE if found, ARES_FALSE if not
*/
ares_bool_t ares__htable_strvp_remove(ares__htable_strvp_t *htable,
const char *key);
const char *key);
/*! Retrieve the number of keys stored in the hash table
*

@ -304,13 +304,13 @@ void *ares__slist_node_claim(ares__slist_node_t *node)
return val;
}
void ares__slist_node_reinsert(ares__slist_node_t *node)
{
ares__slist_t *list;
if (node == NULL)
if (node == NULL) {
return;
}
list = node->parent;
@ -318,7 +318,6 @@ void ares__slist_node_reinsert(ares__slist_node_t *node)
ares__slist_node_push(list, node);
}
ares__slist_node_t *ares__slist_node_find(const ares__slist_t *list,
const void *val)
{

@ -24,7 +24,7 @@
*
* SPDX-License-Identifier: MIT
*/
#include "ares_setup.h"
#include "ares_setup.h"
#ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
@ -254,7 +254,7 @@ ares_status_t ares__open_connection(ares_channel channel,
salen = sizeof(saddr.sa4);
memset(sa, 0, (size_t)salen);
saddr.sa4.sin_family = AF_INET;
saddr.sa4.sin_port = htons(is_tcp?server->tcp_port:server->udp_port);
saddr.sa4.sin_port = htons(is_tcp ? server->tcp_port : server->udp_port);
memcpy(&saddr.sa4.sin_addr, &server->addr.addr.addr4,
sizeof(saddr.sa4.sin_addr));
break;
@ -263,7 +263,7 @@ ares_status_t ares__open_connection(ares_channel channel,
salen = sizeof(saddr.sa6);
memset(sa, 0, (size_t)salen);
saddr.sa6.sin6_family = AF_INET6;
saddr.sa6.sin6_port = htons(is_tcp?server->tcp_port:server->udp_port);
saddr.sa6.sin6_port = htons(is_tcp ? server->tcp_port : server->udp_port);
memcpy(&saddr.sa6.sin6_addr, &server->addr.addr.addr6,
sizeof(saddr.sa6.sin6_addr));
break;
@ -371,7 +371,7 @@ ares_status_t ares__open_connection(ares_channel channel,
SOCK_STATE_CALLBACK(channel, s, 1, 0);
if (is_tcp) {
server->tcp_conn = conn;
server->tcp_conn = conn;
}
return ARES_SUCCESS;
@ -450,4 +450,3 @@ void ares_set_socket_functions(ares_channel channel,
channel->sock_funcs = funcs;
channel->sock_func_cb_data = data;
}

@ -70,7 +70,8 @@ struct addrinfo_sort_elem {
#define ARES_IPV6_ADDR_SCOPE_ORGLOCAL 0x08
#define ARES_IPV6_ADDR_SCOPE_GLOBAL 0x0e
#define ARES_IN_LOOPBACK(a) ((((long unsigned int)(a)) & 0xff000000) == 0x7f000000)
#define ARES_IN_LOOPBACK(a) \
((((long unsigned int)(a)) & 0xff000000) == 0x7f000000)
/* RFC 4193. */
#define ARES_IN6_IS_ADDR_ULA(a) (((a)->s6_addr[0] & 0xfe) == 0xfc)

@ -57,7 +57,7 @@ void ares_cancel(ares_channel channel)
node = ares__llist_node_first(list_copy);
while (node != NULL) {
struct query *query;
struct query *query;
struct server_connection *conn;
/* Cache next since this node is being deleted */

@ -32,7 +32,6 @@
#include "ares.h"
#include "ares_private.h"
void ares_destroy(ares_channel channel)
{
size_t i;
@ -93,11 +92,11 @@ void ares_destroy(ares_channel channel)
ares_free(channel);
}
void ares__destroy_server(struct server_state *server)
{
if (server == NULL)
if (server == NULL) {
return;
}
ares__close_sockets(server);
ares__llist_destroy(server->connections);
@ -108,7 +107,7 @@ void ares__destroy_server(struct server_state *server)
void ares__destroy_servers_state(ares_channel channel)
{
ares__slist_node_t *node;
ares__slist_node_t *node;
while ((node = ares__slist_node_first(channel->servers)) != NULL) {
struct server_state *server = ares__slist_node_claim(node);

@ -32,11 +32,11 @@
int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds)
{
ares_socket_t nfds;
ares__slist_node_t *snode;
ares_socket_t nfds;
ares__slist_node_t *snode;
/* Are there any active queries? */
size_t active_queries = ares__llist_len(channel->all_queries);
size_t active_queries = ares__llist_len(channel->all_queries);
nfds = 0;
for (snode = ares__slist_node_first(channel->servers); snode != NULL;

@ -108,8 +108,9 @@ struct ares_addrinfo_cname *
struct ares_addrinfo_cname *tail = ares_malloc_zero(sizeof(*tail));
struct ares_addrinfo_cname *last = *head;
if (tail == NULL)
if (tail == NULL) {
return NULL;
}
if (!last) {
*head = tail;
@ -147,8 +148,9 @@ struct ares_addrinfo_node *
struct ares_addrinfo_node *tail = ares_malloc_zero(sizeof(*tail));
struct ares_addrinfo_node *last = *head;
if (tail == NULL)
if (tail == NULL) {
return NULL;
}
if (!last) {
*head = tail;
@ -385,18 +387,18 @@ static ares_status_t file_lookup(struct host_query *hquery)
return ARES_ENOTFOUND;
}
status = ares__hosts_search_host(hquery->channel,
(hquery->hints.ai_flags & ARES_AI_ENVHOSTS)?ARES_TRUE:ARES_FALSE,
status = ares__hosts_search_host(
hquery->channel,
(hquery->hints.ai_flags & ARES_AI_ENVHOSTS) ? ARES_TRUE : ARES_FALSE,
hquery->name, &entry);
if (status != ARES_SUCCESS) {
goto done;
}
status = ares__hosts_entry_to_addrinfo(entry, hquery->name,
hquery->hints.ai_family,
hquery->port,
(hquery->hints.ai_flags & ARES_AI_CANONNAME)?ARES_TRUE:ARES_FALSE,
status = ares__hosts_entry_to_addrinfo(
entry, hquery->name, hquery->hints.ai_family, hquery->port,
(hquery->hints.ai_flags & ARES_AI_CANONNAME) ? ARES_TRUE : ARES_FALSE,
hquery->ai);
if (status != ARES_SUCCESS) {
@ -451,7 +453,8 @@ static void next_lookup(struct host_query *hquery, ares_status_t status)
}
}
static void terminate_retries(const struct host_query *hquery, unsigned short qid)
static void terminate_retries(const struct host_query *hquery,
unsigned short qid)
{
unsigned short term_qid =
(qid == hquery->qid_a) ? hquery->qid_aaaa : hquery->qid_a;

@ -189,20 +189,23 @@ static ares_status_t file_lookup(ares_channel channel,
ptr = &addr->addr.addr6;
}
if (ptr == NULL)
if (ptr == NULL) {
return ARES_ENOTFOUND;
}
if (!ares_inet_ntop(addr->family, ptr, ipaddr, sizeof(ipaddr))) {
return ARES_ENOTFOUND;
}
status = ares__hosts_search_ipaddr(channel, ARES_FALSE, ipaddr, &entry);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
status = ares__hosts_entry_to_hostent(entry, addr->family, host);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
return ARES_SUCCESS;
}

@ -230,13 +230,12 @@ static size_t get6_address_index(const struct ares_in6_addr *addr,
return i;
}
static ares_status_t ares__hostent_localhost(const char *name, int family,
struct hostent **host_out)
{
ares_status_t status;
struct ares_addrinfo *ai = NULL;
struct ares_addrinfo_hints hints;
ares_status_t status;
struct ares_addrinfo *ai = NULL;
struct ares_addrinfo_hints hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
@ -267,7 +266,6 @@ done:
int ares_gethostbyname_file(ares_channel channel, const char *name, int family,
struct hostent **host)
{
const ares_hosts_entry_t *entry;
ares_status_t status;
@ -275,8 +273,9 @@ int ares_gethostbyname_file(ares_channel channel, const char *name, int family,
if (channel == NULL || name == NULL || host == NULL) {
/* Anything will do, really. This seems fine, and is consistent with
other error cases. */
if (host != NULL)
if (host != NULL) {
*host = NULL;
}
return ARES_ENOTFOUND;
}
@ -308,4 +307,3 @@ done:
return (int)status;
}

@ -359,7 +359,7 @@ static void append_scopeid(const struct sockaddr_in6 *addr6, unsigned int flags,
}
# else
snprintf(&tmpbuf[1], sizeof(tmpbuf) - 1, "%lu",
(unsigned long)addr6->sin6_scope_id);
(unsigned long)addr6->sin6_scope_id);
(void)flags;
# endif
tmpbuf[IF_NAMESIZE + 1] = '\0';

@ -32,13 +32,13 @@
int ares_getsock(ares_channel channel, ares_socket_t *socks,
int numsocks) /* size of the 'socks' array */
{
ares__slist_node_t *snode;
size_t sockindex = 0;
unsigned int bitmap = 0;
unsigned int setbits = 0xffffffff;
ares__slist_node_t *snode;
size_t sockindex = 0;
unsigned int bitmap = 0;
unsigned int setbits = 0xffffffff;
/* Are there any active queries? */
size_t active_queries = ares__llist_len(channel->all_queries);
size_t active_queries = ares__llist_len(channel->all_queries);
if (numsocks <= 0) {
return 0;

@ -103,21 +103,26 @@ static int server_sort_cb(const void *data1, const void *data2)
const struct server_state *s1 = data1;
const struct server_state *s2 = data2;
if (s1->consec_failures < s2->consec_failures)
if (s1->consec_failures < s2->consec_failures) {
return -1;
if (s1->consec_failures > s2->consec_failures)
}
if (s1->consec_failures > s2->consec_failures) {
return 1;
if (s1->idx < s2->idx)
}
if (s1->idx < s2->idx) {
return -1;
if (s1->idx > s2->idx)
}
if (s1->idx > s2->idx) {
return 1;
}
return 0;
}
static void server_destroy_cb(void *data)
{
if (data == NULL)
if (data == NULL) {
return;
}
ares__destroy_server(data);
}
@ -126,7 +131,7 @@ static ares_status_t init_by_defaults(ares_channel channel)
char *hostname = NULL;
ares_status_t rc = ARES_SUCCESS;
#ifdef HAVE_GETHOSTNAME
const char *dot;
const char *dot;
#endif
if (channel->timeout == 0) {
@ -153,14 +158,16 @@ static ares_status_t init_by_defaults(ares_channel channel)
addr.addr.addr4.s_addr = htonl(INADDR_LOOPBACK);
rc = ares__sconfig_append(&sconfig, &addr, 0, 0);
if (rc != ARES_SUCCESS)
if (rc != ARES_SUCCESS) {
return rc;
}
rc = ares__servers_update(channel, sconfig, ARES_FALSE);
ares__llist_destroy(sconfig);
if (rc != ARES_SUCCESS)
if (rc != ARES_SUCCESS) {
return rc;
}
}
#if defined(USE_WINSOCK)
@ -303,8 +310,8 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
}
/* Initialize Server List */
channel->servers = ares__slist_create(channel->rand_state, server_sort_cb,
server_destroy_cb);
channel->servers =
ares__slist_create(channel->rand_state, server_sort_cb, server_destroy_cb);
if (channel->servers == NULL) {
status = ARES_ENOMEM;
goto done;
@ -449,7 +456,6 @@ int ares_dup(ares_channel *dest, ares_channel src)
return ARES_SUCCESS; /* everything went fine */
}
void ares_set_local_ip4(ares_channel channel, unsigned int local_ip)
{
channel->local_ip4 = local_ip;
@ -469,7 +475,6 @@ void ares_set_local_dev(ares_channel channel, const char *local_dev_name)
channel->local_dev_name[sizeof(channel->local_dev_name) - 1] = 0;
}
int ares_set_sortlist(ares_channel channel, const char *sortstr)
{
size_t nsort = 0;
@ -493,4 +498,3 @@ int ares_set_sortlist(ares_channel channel, const char *sortstr)
}
return (int)status;
}

@ -54,24 +54,25 @@ void ares_destroy_options(struct ares_options *options)
}
static struct in_addr *ares_save_opt_servers(ares_channel channel,
int *nservers)
int *nservers)
{
ares__slist_node_t *snode;
struct in_addr *out = ares_malloc_zero(ares__slist_len(channel->servers) *
sizeof(*out));
struct in_addr *out =
ares_malloc_zero(ares__slist_len(channel->servers) * sizeof(*out));
*nservers = 0;
if (out == NULL)
if (out == NULL) {
return NULL;
}
for (snode = ares__slist_node_first(channel->servers); snode != NULL;
snode = ares__slist_node_next(snode)) {
const struct server_state *server = ares__slist_node_val(snode);
if (server->addr.family != AF_INET)
if (server->addr.family != AF_INET) {
continue;
}
memcpy(&out[*nservers], &server->addr.addr.addr4, sizeof(*out));
(*nservers)++;
@ -80,7 +81,6 @@ static struct in_addr *ares_save_opt_servers(ares_channel channel,
return out;
}
/* Save options from initialized channel */
int ares_save_options(ares_channel channel, struct ares_options *options,
int *optmask)
@ -199,8 +199,8 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
}
}
if (channel->optmask & ARES_OPT_SOCK_SNDBUF &&
channel->socket_send_buffer_size > 0) {
if (channel->optmask & ARES_OPT_SOCK_SNDBUF &&
channel->socket_send_buffer_size > 0) {
options->socket_send_buffer_size = channel->socket_send_buffer_size;
}
@ -214,7 +214,7 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
}
if (channel->optmask & ARES_OPT_UDP_MAX_QUERIES) {
options->udp_max_queries = (int)channel->udp_max_queries;
options->udp_max_queries = (int)channel->udp_max_queries;
}
*optmask = (int)channel->optmask;
@ -222,17 +222,17 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
return ARES_SUCCESS;
}
static ares_status_t ares__init_options_servers(ares_channel channel,
static ares_status_t ares__init_options_servers(ares_channel channel,
const struct in_addr *servers,
size_t nservers)
size_t nservers)
{
ares__llist_t *slist;
ares_status_t status;
slist = ares_in_addr_to_server_config_llist(servers, nservers);
if (slist == NULL)
if (slist == NULL) {
return ARES_ENOMEM;
}
status = ares__servers_update(channel, slist, ARES_TRUE);
@ -247,8 +247,9 @@ ares_status_t ares__init_by_options(ares_channel channel,
{
size_t i;
if (channel == NULL)
if (channel == NULL) {
return ARES_ENODATA;
}
if (options == NULL) {
if (optmask != 0) {
@ -266,9 +267,9 @@ ares_status_t ares__init_by_options(ares_channel channel,
channel->timeout = (unsigned int)options->timeout;
} else if (optmask & ARES_OPT_TIMEOUT) {
/* Convert to milliseconds */
optmask |= ARES_OPT_TIMEOUTMS;
optmask &= ~(ARES_OPT_TIMEOUT);
channel->timeout = (unsigned int)options->timeout * 1000;
optmask |= ARES_OPT_TIMEOUTMS;
optmask &= ~(ARES_OPT_TIMEOUT);
channel->timeout = (unsigned int)options->timeout * 1000;
}
if (optmask & ARES_OPT_TRIES) {
@ -377,8 +378,9 @@ ares_status_t ares__init_by_options(ares_channel channel,
ares_status_t status;
status = ares__init_options_servers(channel, options->servers,
(size_t)options->nservers);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
}
channel->optmask = (unsigned int)optmask;

@ -93,7 +93,7 @@ W32_FUNC const char *_w32_GetHostsFile(void);
#elif defined(__riscos__)
# define PATH_RESOLV_CONF NULL
# define PATH_HOSTS "InetDBase:Hosts"
# define PATH_HOSTS "InetDBase:Hosts"
#elif defined(__HAIKU__)
@ -200,36 +200,36 @@ struct server_state {
/* State to represent a DNS query */
struct query {
/* Query ID from qbuf, for faster lookup, and current timeout */
unsigned short qid; /* host byte order */
struct timeval timeout;
ares_channel channel;
unsigned short qid; /* host byte order */
struct timeval timeout;
ares_channel channel;
/*
* Node object for each list entry the query belongs to in order to
* make removal operations O(1).
*/
ares__slist_node_t *node_queries_by_timeout;
ares__llist_node_t *node_queries_to_conn;
ares__llist_node_t *node_all_queries;
ares__slist_node_t *node_queries_by_timeout;
ares__llist_node_t *node_queries_to_conn;
ares__llist_node_t *node_all_queries;
/* connection handle query is associated with */
struct server_connection *conn;
/* Query buf with length at beginning, for TCP transmission */
unsigned char *tcpbuf;
size_t tcplen;
unsigned char *tcpbuf;
size_t tcplen;
/* Arguments passed to ares_send() (qbuf points into tcpbuf) */
const unsigned char *qbuf;
size_t qlen;
ares_callback callback;
void *arg;
const unsigned char *qbuf;
size_t qlen;
ares_callback callback;
void *arg;
/* Query status */
size_t try_count; /* Number of times we tried this query already. */
ares_bool_t using_tcp;
ares_status_t error_status;
size_t timeouts; /* number of timeouts we saw for this request */
size_t try_count; /* Number of times we tried this query already. */
ares_bool_t using_tcp;
ares_status_t error_status;
size_t timeouts; /* number of timeouts we saw for this request */
ares_bool_t no_retries; /* do not perform any additional retries, this is set
* when a query is to be canceled */
};
@ -359,7 +359,7 @@ ares_status_t ares_send_ex(ares_channel channel, const unsigned char *qbuf,
size_t qlen, ares_callback callback, void *arg);
void ares__close_connection(struct server_connection *conn);
void ares__close_sockets(struct server_state *server);
void ares__check_cleanup_conn(ares_channel channel,
void ares__check_cleanup_conn(ares_channel channel,
struct server_connection *conn);
ares_status_t ares__read_line(FILE *fp, char **buf, size_t *bufsize);
void ares__free_query(struct query *query);
@ -388,35 +388,35 @@ ares_status_t ares__init_by_options(ares_channel channel,
int optmask);
ares_status_t ares__init_by_sysconfig(ares_channel channel);
typedef struct {
ares__llist_t *sconfig;
struct apattern *sortlist;
size_t nsortlist;
char **domains;
size_t ndomains;
char *lookups;
size_t ndots;
size_t tries;
ares_bool_t rotate;
size_t timeout_ms;
ares__llist_t *sconfig;
struct apattern *sortlist;
size_t nsortlist;
char **domains;
size_t ndomains;
char *lookups;
size_t ndots;
size_t tries;
ares_bool_t rotate;
size_t timeout_ms;
} ares_sysconfig_t;
ares_status_t ares__init_by_environment(ares_sysconfig_t *sysconfig);
ares_status_t ares__init_sysconfig_files(ares_channel channel,
ares_sysconfig_t *sysconfig);
ares_status_t ares__parse_sortlist(struct apattern **sortlist, size_t *nsort,
const char *str);
ares_status_t ares__init_by_environment(ares_sysconfig_t *sysconfig);
ares_status_t ares__init_sysconfig_files(ares_channel channel,
ares_sysconfig_t *sysconfig);
ares_status_t ares__parse_sortlist(struct apattern **sortlist, size_t *nsort,
const char *str);
void ares__destroy_servers_state(ares_channel channel);
ares_status_t ares__single_domain(ares_channel channel, const char *name,
char **s);
ares_status_t ares__cat_domain(const char *name, const char *domain, char **s);
ares_status_t ares__sortaddrinfo(ares_channel channel,
struct ares_addrinfo_node *ai_node);
void ares__destroy_servers_state(ares_channel channel);
ares_status_t ares__single_domain(ares_channel channel, const char *name,
char **s);
ares_status_t ares__cat_domain(const char *name, const char *domain, char **s);
ares_status_t ares__sortaddrinfo(ares_channel channel,
struct ares_addrinfo_node *ai_node);
void ares__freeaddrinfo_nodes(struct ares_addrinfo_node *ai_node);
ares_bool_t ares__is_localhost(const char *name);
void ares__freeaddrinfo_nodes(struct ares_addrinfo_node *ai_node);
ares_bool_t ares__is_localhost(const char *name);
struct ares_addrinfo_node *
ares__append_addrinfo_node(struct ares_addrinfo_node **ai_node);
@ -457,49 +457,48 @@ ares_socket_t ares__open_socket(ares_channel channel, int af, int type,
int protocol);
ares_ssize_t ares__socket_write(ares_channel channel, ares_socket_t s,
const void *data, size_t len);
ares_ssize_t ares__socket_recvfrom(ares_channel channel, ares_socket_t s,
void *data, size_t data_len, int flags,
struct sockaddr *from,
ares_socklen_t *from_len);
ares_ssize_t ares__socket_recv(ares_channel channel, ares_socket_t s,
void *data, size_t data_len);
ares_ssize_t ares__socket_recvfrom(ares_channel channel, ares_socket_t s,
void *data, size_t data_len, int flags,
struct sockaddr *from,
ares_socklen_t *from_len);
ares_ssize_t ares__socket_recv(ares_channel channel, ares_socket_t s,
void *data, size_t data_len);
void ares__close_socket(ares_channel, ares_socket_t);
int ares__connect_socket(ares_channel channel, ares_socket_t sockfd,
const struct sockaddr *addr,
ares_socklen_t addrlen);
ares_bool_t ares__is_hostnamech(int ch);
void ares__destroy_server(struct server_state *server);
const struct sockaddr *addr, ares_socklen_t addrlen);
ares_bool_t ares__is_hostnamech(int ch);
void ares__destroy_server(struct server_state *server);
ares_status_t ares__servers_update(ares_channel channel,
ares_status_t ares__servers_update(ares_channel channel,
ares__llist_t *server_list,
ares_bool_t user_specified);
ares_status_t ares__sconfig_append(ares__llist_t **sconfig,
ares_bool_t user_specified);
ares_status_t ares__sconfig_append(ares__llist_t **sconfig,
const struct ares_addr *addr,
unsigned short udp_port,
unsigned short tcp_port);
unsigned short udp_port,
unsigned short tcp_port);
ares_status_t ares__sconfig_append_fromstr(ares__llist_t **sconfig,
const char *str);
ares__llist_t *ares_in_addr_to_server_config_llist(
const struct in_addr *servers, size_t nservers);
const char *str);
ares__llist_t *
ares_in_addr_to_server_config_llist(const struct in_addr *servers,
size_t nservers);
struct ares_hosts_entry;
typedef struct ares_hosts_entry ares_hosts_entry_t;
void ares__hosts_file_destroy(ares_hosts_file_t *hf);
ares_status_t ares__hosts_search_ipaddr(ares_channel channel,
ares_bool_t use_env, const char *ipaddr,
const ares_hosts_entry_t **entry);
ares_status_t ares__hosts_search_host(ares_channel channel,
ares_bool_t use_env, const char *host,
void ares__hosts_file_destroy(ares_hosts_file_t *hf);
ares_status_t ares__hosts_search_ipaddr(ares_channel channel,
ares_bool_t use_env, const char *ipaddr,
const ares_hosts_entry_t **entry);
ares_status_t ares__hosts_search_host(ares_channel channel, ares_bool_t use_env,
const char *host,
const ares_hosts_entry_t **entry);
ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry,
int family,
struct hostent **hostent);
int family,
struct hostent **hostent);
ares_status_t ares__hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry,
const char *name,
int family,
unsigned short port,
ares_bool_t want_cnames,
const char *name, int family,
unsigned short port,
ares_bool_t want_cnames,
struct ares_addrinfo *ai);
#define ARES_SWAP_BYTE(a, b) \
@ -516,8 +515,8 @@ ares_status_t ares__hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry,
} \
} while (0)
#define ARES_CONFIG_CHECK(x) \
(x && x->lookups && ares__slist_len(x->servers) > 0 && x->ndots > 0 && \
#define ARES_CONFIG_CHECK(x) \
(x && x->lookups && ares__slist_len(x->servers) > 0 && x->ndots > 0 && \
x->timeout > 0 && x->tries > 0)
size_t ares__round_up_pow2(size_t n);

@ -53,25 +53,23 @@ static void write_tcp_data(ares_channel channel, fd_set *write_fds,
static void read_packets(ares_channel channel, fd_set *read_fds,
ares_socket_t read_fd, struct timeval *now);
static void process_timeouts(ares_channel channel, struct timeval *now);
static ares_status_t process_answer(ares_channel channel,
const unsigned char *abuf,
size_t alen,
static ares_status_t process_answer(ares_channel channel,
const unsigned char *abuf, size_t alen,
struct server_connection *conn,
ares_bool_t tcp, struct timeval *now);
static void handle_conn_error(struct server_connection *conn,
ares_bool_t critical_failure);
static void handle_conn_error(struct server_connection *conn,
ares_bool_t critical_failure);
static ares_bool_t same_questions(const unsigned char *qbuf, size_t qlen,
const ares_dns_record_t *arec);
static ares_bool_t same_address(const struct sockaddr *sa,
static ares_bool_t same_address(const struct sockaddr *sa,
const struct ares_addr *aa);
static ares_bool_t has_opt_rr(ares_dns_record_t *arec);
static void end_query(ares_channel channel, struct query *query,
ares_status_t status, const unsigned char *abuf,
size_t alen);
static void server_increment_failures(struct server_state *server)
static void server_increment_failures(struct server_state *server)
{
ares__slist_node_t *node;
ares_channel channel = server->channel;
@ -84,14 +82,14 @@ static void server_increment_failures(struct server_state *server)
ares__slist_node_reinsert(node);
}
static void server_set_good(struct server_state *server)
{
ares__slist_node_t *node;
ares_channel channel = server->channel;
if (!server->consec_failures)
if (!server->consec_failures) {
return;
}
node = ares__slist_node_find(channel->servers, server);
if (node == NULL) {
@ -103,7 +101,8 @@ static void server_set_good(struct server_state *server)
}
/* return true if now is exactly check time or later */
ares_bool_t ares__timedout(const struct timeval *now, const struct timeval *check)
ares_bool_t ares__timedout(const struct timeval *now,
const struct timeval *check)
{
time_t secs = (now->tv_sec - check->tv_sec);
@ -178,13 +177,15 @@ static ares_bool_t try_again(int errnum)
#endif
#ifdef EWOULDBLOCK
if (errnum == EWOULDBLOCK)
if (errnum == EWOULDBLOCK) {
return ARES_TRUE;
}
#endif
#if defined EAGAIN && EAGAIN != EWOULDBLOCK
if (errnum == EAGAIN)
if (errnum == EAGAIN) {
return ARES_TRUE;
}
#endif
return ARES_FALSE;
@ -196,7 +197,7 @@ static ares_bool_t try_again(int errnum)
static void write_tcp_data(ares_channel channel, fd_set *write_fds,
ares_socket_t write_fd)
{
ares__slist_node_t *node;
ares__slist_node_t *node;
if (!write_fds && (write_fd == ARES_SOCKET_BAD)) {
/* no possible action */
@ -254,7 +255,6 @@ static void write_tcp_data(ares_channel channel, fd_set *write_fds,
}
}
/* If any TCP socket selects true for reading, read some data,
* allocate a buffer if we finish reading the length word, and process
* a packet if we finish reading one.
@ -359,7 +359,7 @@ static int socket_list_append(ares_socket_t **socketlist, ares_socket_t fd,
static ares_socket_t *channel_socket_list(ares_channel channel, size_t *num)
{
size_t alloc_cnt = 1 << 4;
ares_socket_t *out = ares_malloc(alloc_cnt * sizeof(*out));
ares_socket_t *out = ares_malloc(alloc_cnt * sizeof(*out));
ares__slist_node_t *snode;
*num = 0;
@ -373,8 +373,8 @@ static ares_socket_t *channel_socket_list(ares_channel channel, size_t *num)
struct server_state *server = ares__slist_node_val(snode);
ares__llist_node_t *node;
for (node = ares__llist_node_first(server->connections);
node != NULL; node = ares__llist_node_next(node)) {
for (node = ares__llist_node_first(server->connections); node != NULL;
node = ares__llist_node_next(node)) {
const struct server_connection *conn = ares__llist_node_val(node);
if (conn->fd == ARES_SOCKET_BAD) {
@ -558,9 +558,8 @@ static void process_timeouts(ares_channel channel, struct timeval *now)
/* Handle an answer from a server. This must NEVER cleanup the
* server connection! Return something other than ARES_SUCCESS to cause
* the connection to be terminated after this call. */
static ares_status_t process_answer(ares_channel channel,
const unsigned char *abuf,
size_t alen,
static ares_status_t process_answer(ares_channel channel,
const unsigned char *abuf, size_t alen,
struct server_connection *conn,
ares_bool_t tcp, struct timeval *now)
{
@ -684,9 +683,9 @@ cleanup:
}
static void handle_conn_error(struct server_connection *conn,
ares_bool_t critical_failure)
ares_bool_t critical_failure)
{
struct server_state *server = conn->server;
struct server_state *server = conn->server;
/* This will requeue any connections automatically */
ares__close_connection(conn);
@ -698,9 +697,8 @@ static void handle_conn_error(struct server_connection *conn,
ares_status_t ares__requeue_query(struct query *query, struct timeval *now)
{
ares_channel channel = query->channel;
size_t max_tries = ares__slist_len(channel->servers) *
channel->tries;
ares_channel channel = query->channel;
size_t max_tries = ares__slist_len(channel->servers) * channel->tries;
query->try_count++;
@ -709,14 +707,14 @@ ares_status_t ares__requeue_query(struct query *query, struct timeval *now)
}
/* If we are here, all attempts to perform query failed. */
if (query->error_status == ARES_SUCCESS)
if (query->error_status == ARES_SUCCESS) {
query->error_status = ARES_ETIMEOUT;
}
end_query(channel, query, query->error_status, NULL, 0);
return ARES_ETIMEOUT;
}
/* Pick a random server from the list, we first get a random number in the
* range of the number of servers, then scan until we find that server in
* the list */
@ -729,13 +727,12 @@ static struct server_state *ares__random_server(ares_channel channel)
ares__rand_bytes(channel->rand_state, &c, 1);
cnt = c;
idx = cnt % ares__slist_len(channel->servers);
cnt = c;
idx = cnt % ares__slist_len(channel->servers);
cnt = 0;
for (node = ares__slist_node_first(channel->servers); node != NULL;
node = ares__slist_node_next(node)) {
if (cnt == idx) {
return ares__slist_node_val(node);
}
@ -932,8 +929,6 @@ ares_status_t ares__send_query(struct query *query, struct timeval *now)
return ARES_SUCCESS;
}
static ares_bool_t same_questions(const unsigned char *qbuf, size_t qlen,
const ares_dns_record_t *arec)
{
@ -980,7 +975,7 @@ done:
return rv;
}
static ares_bool_t same_address(const struct sockaddr *sa,
static ares_bool_t same_address(const struct sockaddr *sa,
const struct ares_addr *aa)
{
const void *addr1;
@ -1061,5 +1056,3 @@ void ares__free_query(struct query *query)
ares_free(query);
}

@ -586,7 +586,6 @@ static ares_bool_t get_SuffixList_Windows(char **outptr)
return *outptr != NULL ? ARES_TRUE : ARES_FALSE;
}
static ares_status_t ares__init_sysconfig_windows(ares_sysconfig_t *sysconfig)
{
char *line = NULL;
@ -595,17 +594,19 @@ static ares_status_t ares__init_sysconfig_windows(ares_sysconfig_t *sysconfig)
if (get_DNS_Windows(&line)) {
status = ares__sconfig_append_fromstr(&sysconfig->sconfig, line);
ares_free(line);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
goto done;
}
}
if (get_SuffixList_Windows(&line)) {
sysconfig->domains = ares__strsplit(line, ", ", &sysconfig->ndomains);
sysconfig->domains = ares__strsplit(line, ", ", &sysconfig->ndomains);
if (sysconfig->domains == NULL) {
status = ARES_EFILE;
}
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
goto done;
}
}
done:
@ -616,13 +617,13 @@ done:
#if defined(__MVS__)
static ares_status_t ares__init_sysconfig_mvs(ares_sysconfig_t *sysconfig)
{
struct __res_state *res = 0;
size_t count4;
size_t count6;
int i;
__STATEEXTIPV6 *v6;
arse__llist_t *sconfig = NULL;
ares_status_t status;
struct __res_state *res = 0;
size_t count4;
size_t count6;
int i;
__STATEEXTIPV6 *v6;
arse__llist_t *sconfig = NULL;
ares_status_t status;
if (0 == res) {
int rc = res_init();
@ -653,12 +654,13 @@ static ares_status_t ares__init_sysconfig_mvs(ares_sysconfig_t *sysconfig)
addr.addr.addr4.s_addr = addr_in->sin_addr.s_addr;
addr.family = AF_INET;
status = ares__sconfig_append(&sysconfig->sconfig, &addr,
htons(addr_in->sin_port),
htons(addr_in->sin_port));
status =
ares__sconfig_append(&sysconfig->sconfig, &addr, htons(addr_in->sin_port),
htons(addr_in->sin_port));
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
}
for (i = 0; i < count6; i++) {
@ -669,12 +671,13 @@ static ares_status_t ares__init_sysconfig_mvs(ares_sysconfig_t *sysconfig)
memcpy(&(addr.addr.addr6), &(addr_in->sin6_addr),
sizeof(addr_in->sin6_addr));
status = ares__sconfig_append(&sysconfig->sconfig, &addr,
htons(addr_in->sin_port),
htons(addr_in->sin_port));
status =
ares__sconfig_append(&sysconfig->sconfig, &addr, htons(addr_in->sin_port),
htons(addr_in->sin_port));
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
}
return ARES_SUCCESS;
@ -689,7 +692,7 @@ static ares_status_t ares__init_sysconfig_riscos(ares_sysconfig_t *sysconfig)
/* Under RISC OS, name servers are listed in the
system variable Inet$Resolvers, space separated. */
line = getenv("Inet$Resolvers");
line = getenv("Inet$Resolvers");
if (line) {
char *resolvers = ares_strdup(line);
char *pos;
@ -730,13 +733,14 @@ static ares_status_t ares__init_sysconfig_watt32(ares_sysconfig_t *sysconfig)
for (i = 0; def_nameservers[i]; i++) {
struct ares_addr addr;
addr.family = AF_INET;
addr.family = AF_INET;
addr.addr.addr4.s_addr = htonl(def_nameservers[i]);
status = ares__sconfig_append(&sysconfig->sconfig, &addr, 0, 0);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
}
return ARES_SUCCESS;
@ -744,62 +748,62 @@ static ares_status_t ares__init_sysconfig_watt32(ares_sysconfig_t *sysconfig)
#endif
#if defined(ANDROID) || defined(__ANDROID__)
static ares_status_t ares__init_sysconfig_android(ares_sysconfig_t *sysconfig)
size_t i;
char **dns_servers;
char *domains;
size_t num_servers;
ares_status_t status = ARES_EFILE;
/* Use the Android connectivity manager to get a list
* of DNS servers. As of Android 8 (Oreo) net.dns#
* system properties are no longer available. Google claims this
* improves privacy. Apps now need the ACCESS_NETWORK_STATE
* permission and must use the ConnectivityManager which
* is Java only. */
dns_servers = ares_get_android_server_list(MAX_DNS_PROPERTIES, &num_servers);
if (dns_servers != NULL) {
for (i = 0; i < num_servers; i++) {
status = ares__sconfig_append_fromstr(&sysconfig->sconfig, dns_servers[i]);
if (status != ARES_SUCCESS) {
return status;
}
}
for (i = 0; i < num_servers; i++) {
ares_free(dns_servers[i]);
static ares_status_t
ares__init_sysconfig_android(ares_sysconfig_t *sysconfig) size_t i;
char **dns_servers;
char *domains;
size_t num_servers;
ares_status_t status = ARES_EFILE;
/* Use the Android connectivity manager to get a list
* of DNS servers. As of Android 8 (Oreo) net.dns#
* system properties are no longer available. Google claims this
* improves privacy. Apps now need the ACCESS_NETWORK_STATE
* permission and must use the ConnectivityManager which
* is Java only. */
dns_servers = ares_get_android_server_list(MAX_DNS_PROPERTIES, &num_servers);
if (dns_servers != NULL) {
for (i = 0; i < num_servers; i++) {
status = ares__sconfig_append_fromstr(&sysconfig->sconfig, dns_servers[i]);
if (status != ARES_SUCCESS) {
return status;
}
ares_free(dns_servers);
}
for (i = 0; i < num_servers; i++) {
ares_free(dns_servers[i]);
}
ares_free(dns_servers);
}
domains = ares_get_android_search_domains_list();
sysconfig->domains = ares__strsplit(domains, ", ", &sysconfig->ndomains);
ares_free(domains);
domains = ares_get_android_search_domains_list();
sysconfig->domains = ares__strsplit(domains, ", ", &sysconfig->ndomains);
ares_free(domains);
# ifdef HAVE___SYSTEM_PROPERTY_GET
/* Old way using the system property still in place as
* a fallback. Older android versions can still use this.
* it's possible for older apps not not have added the new
* permission and we want to try to avoid breaking those.
*
* We'll only run this if we don't have any dns servers
* because this will get the same ones (if it works). */
if (sysconfig->sconfig == NULL) {
char propname[PROP_NAME_MAX];
char propvalue[PROP_VALUE_MAX] = "";
for (i = 1; i <= MAX_DNS_PROPERTIES; i++) {
snprintf(propname, sizeof(propname), "%s%u", DNS_PROP_NAME_PREFIX, i);
if (__system_property_get(propname, propvalue) < 1) {
break;
}
status = ares__sconfig_append_fromstr(&sysconfig->sconfig, propvalue);
if (status != ARES_SUCCESS) {
return status;
}
/* Old way using the system property still in place as
* a fallback. Older android versions can still use this.
* it's possible for older apps not not have added the new
* permission and we want to try to avoid breaking those.
*
* We'll only run this if we don't have any dns servers
* because this will get the same ones (if it works). */
if (sysconfig->sconfig == NULL) {
char propname[PROP_NAME_MAX];
char propvalue[PROP_VALUE_MAX] = "";
for (i = 1; i <= MAX_DNS_PROPERTIES; i++) {
snprintf(propname, sizeof(propname), "%s%u", DNS_PROP_NAME_PREFIX, i);
if (__system_property_get(propname, propvalue) < 1) {
break;
}
status = ares__sconfig_append_fromstr(&sysconfig->sconfig, propvalue);
if (status != ARES_SUCCESS) {
return status;
}
}
}
# endif /* HAVE___SYSTEM_PROPERTY_GET */
return status;
return status;
}
#endif
@ -831,8 +835,7 @@ static ares_status_t ares__init_sysconfig_libresolv(ares_sysconfig_t *sysconfig)
ares_inet_ntop(family, &addr[i].sin.sin_addr, ipaddr, sizeof(ipaddr));
port = ntohs(addr[i].sin.sin_port);
} else if (family == AF_INET6) {
ares_inet_ntop(family, &addr[i].sin6.sin6_addr, ipaddr,
sizeof(ipaddr));
ares_inet_ntop(family, &addr[i].sin6.sin6_addr, ipaddr, sizeof(ipaddr));
port = ntohs(addr[i].sin6.sin6_port);
} else {
continue;
@ -887,8 +890,9 @@ static ares_status_t ares__init_sysconfig_libresolv(ares_sysconfig_t *sysconfig)
}
# ifdef __APPLE__
if (res.retry >= 0) {
sysconfig->timeout_ms /= ((unsigned int)res.retry + 1) *
(unsigned int)(res.nscount > 0 ? res.nscount : 1);
sysconfig->timeout_ms /=
((unsigned int)res.retry + 1) *
(unsigned int)(res.nscount > 0 ? res.nscount : 1);
}
# endif
}
@ -908,31 +912,34 @@ static void ares_sysconfig_free(ares_sysconfig_t *sysconfig)
memset(sysconfig, 0, sizeof(*sysconfig));
}
static ares_status_t ares_sysconfig_apply(ares_channel channel,
static ares_status_t ares_sysconfig_apply(ares_channel channel,
const ares_sysconfig_t *sysconfig)
{
ares_status_t status;
if (sysconfig->sconfig && !(channel->optmask & ARES_OPT_SERVERS)) {
status = ares__servers_update(channel, sysconfig->sconfig, ARES_FALSE);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
}
if (sysconfig->domains && !(channel->optmask & ARES_OPT_DOMAINS)) {
size_t i;
ares__strsplit_free(channel->domains, channel->ndomains);
channel->domains = ares_malloc_zero(sizeof(*channel->domains) *
sysconfig->ndomains);
if (channel->domains == NULL)
channel->domains =
ares_malloc_zero(sizeof(*channel->domains) * sysconfig->ndomains);
if (channel->domains == NULL) {
return ARES_ENOMEM;
}
channel->ndomains = sysconfig->ndomains;
for (i=0; i<channel->ndomains; i++) {
for (i = 0; i < channel->ndomains; i++) {
channel->domains[i] = ares_strdup(sysconfig->domains[i]);
if (channel->domains[i] == NULL)
if (channel->domains[i] == NULL) {
return ARES_ENOMEM;
}
}
}
@ -946,13 +953,13 @@ static ares_status_t ares_sysconfig_apply(ares_channel channel,
if (sysconfig->sortlist && !(channel->optmask & ARES_OPT_SORTLIST)) {
ares_free(channel->sortlist);
channel->sortlist = ares_malloc(sizeof(*channel->sortlist) *
sysconfig->nsortlist);
channel->sortlist =
ares_malloc(sizeof(*channel->sortlist) * sysconfig->nsortlist);
if (channel->sortlist == NULL) {
return ARES_ENOMEM;
}
memcpy(channel->sortlist, sysconfig->sortlist, sizeof(*channel->sortlist) *
sysconfig->nsortlist);
memcpy(channel->sortlist, sysconfig->sortlist,
sizeof(*channel->sortlist) * sysconfig->nsortlist);
channel->nsort = sysconfig->nsortlist;
}
@ -968,7 +975,7 @@ static ares_status_t ares_sysconfig_apply(ares_channel channel,
channel->timeout = sysconfig->timeout_ms;
}
if (!(channel->optmask & (ARES_OPT_ROTATE|ARES_OPT_NOROTATE))) {
if (!(channel->optmask & (ARES_OPT_ROTATE | ARES_OPT_NOROTATE))) {
channel->rotate = sysconfig->rotate;
}
@ -983,8 +990,9 @@ ares_status_t ares__init_by_sysconfig(ares_channel channel)
memset(&sysconfig, 0, sizeof(sysconfig));
status = ares__init_by_environment(&sysconfig);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
goto done;
}
#ifdef _WIN32
status = ares__init_sysconfig_windows(&sysconfig);
@ -1007,8 +1015,9 @@ ares_status_t ares__init_by_sysconfig(ares_channel channel)
}
status = ares_sysconfig_apply(channel, &sysconfig);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
goto done;
}
done:
ares_sysconfig_free(&sysconfig);

@ -66,7 +66,6 @@
#include "ares_platform.h"
#include "ares_private.h"
static int ip_addr(const char *ipbuf, ares_ssize_t len, struct in_addr *addr)
{
/* Four octets and three periods yields at most 15 characters. */
@ -117,7 +116,7 @@ static ares_bool_t sortlist_alloc(struct apattern **sortlist, size_t *nsort,
}
ares_status_t ares__parse_sortlist(struct apattern **sortlist, size_t *nsort,
const char *str)
const char *str)
{
struct apattern pat;
const char *q;
@ -171,7 +170,8 @@ ares_status_t ares__parse_sortlist(struct apattern **sortlist, size_t *nsort,
/* Lets see if it is CIDR */
/* First we'll try IPv6 */
if ((bits = ares_inet_net_pton(AF_INET6, ipbufpfx[0] ? ipbufpfx : ipbuf,
&pat.addr.addr6, sizeof(pat.addr.addr6))) > 0) {
&pat.addr.addr6, sizeof(pat.addr.addr6))) >
0) {
pat.type = PATTERN_CIDR;
pat.mask.bits = (unsigned short)bits;
pat.family = AF_INET6;
@ -231,10 +231,9 @@ ares_status_t ares__parse_sortlist(struct apattern **sortlist, size_t *nsort,
return ARES_SUCCESS;
}
static ares_status_t config_search(ares_sysconfig_t *sysconfig, const char *str)
{
if (sysconfig->domains && sysconfig->ndomains > 0) {
if (sysconfig->domains && sysconfig->ndomains > 0) {
/* if we already have some domains present, free them first */
ares__strsplit_free(sysconfig->domains, sysconfig->ndomains);
sysconfig->domains = NULL;
@ -242,15 +241,16 @@ static ares_status_t config_search(ares_sysconfig_t *sysconfig, const char *str)
}
sysconfig->domains = ares__strsplit(str, ", ", &sysconfig->ndomains);
if (sysconfig->domains == NULL)
if (sysconfig->domains == NULL) {
return ARES_ENOMEM;
}
return ARES_SUCCESS;
}
static ares_status_t config_domain(ares_sysconfig_t *sysconfig, char *str)
{
char *q;
char *q;
/* Set a single search domain. */
q = str;
@ -262,15 +262,14 @@ static ares_status_t config_domain(ares_sysconfig_t *sysconfig, char *str)
return config_search(sysconfig, str);
}
static ares_status_t config_lookup(ares_sysconfig_t *sysconfig, const char *str,
const char *bindch, const char *altbindch,
const char *filech)
{
char lookups[3];
char *l;
const char *p;
ares_bool_t found;
char lookups[3];
char *l;
const char *p;
ares_bool_t found;
if (altbindch == NULL) {
altbindch = bindch;
@ -303,7 +302,7 @@ static ares_status_t config_lookup(ares_sysconfig_t *sysconfig, const char *str,
if (!found) {
return ARES_ENOTINITIALIZED;
}
*l = '\0';
*l = '\0';
ares_free(sysconfig->lookups);
sysconfig->lookups = ares_strdup(lookups);
@ -325,8 +324,9 @@ static ares_status_t set_options(ares_sysconfig_t *sysconfig, const char *str)
const char *q;
const char *val;
if (str == NULL)
if (str == NULL) {
return ARES_SUCCESS;
}
p = str;
while (*p) {
@ -335,7 +335,7 @@ static ares_status_t set_options(ares_sysconfig_t *sysconfig, const char *str)
q++;
}
val = try_option(p, q, "ndots:");
if (val ) {
if (val) {
sysconfig->ndots = strtoul(val, NULL, 10);
}
@ -446,7 +446,6 @@ static char *try_config(char *s, const char *opt, char scc)
return p;
}
ares_status_t ares__init_by_environment(ares_sysconfig_t *sysconfig)
{
const char *localdomain;
@ -456,8 +455,9 @@ ares_status_t ares__init_by_environment(ares_sysconfig_t *sysconfig)
localdomain = getenv("LOCALDOMAIN");
if (localdomain) {
char *temp = ares_strdup(localdomain);
if (temp == NULL)
if (temp == NULL) {
return ARES_ENOMEM;
}
status = config_domain(sysconfig, temp);
ares_free(temp);
if (status != ARES_SUCCESS) {
@ -476,8 +476,7 @@ ares_status_t ares__init_by_environment(ares_sysconfig_t *sysconfig)
return ARES_SUCCESS;
}
ares_status_t ares__init_sysconfig_files(ares_channel channel,
ares_status_t ares__init_sysconfig_files(ares_channel channel,
ares_sysconfig_t *sysconfig)
{
char *p;
@ -502,12 +501,13 @@ ares_status_t ares__init_sysconfig_files(ares_channel channel,
status = config_domain(sysconfig, p);
} else if ((p = try_config(line, "lookup", ';'))) {
status = config_lookup(sysconfig, p, "bind", NULL, "file");
} else if ((p = try_config(line, "search", ';')) ) {
} else if ((p = try_config(line, "search", ';'))) {
status = config_search(sysconfig, p);
} else if ((p = try_config(line, "nameserver", ';'))) {
status = ares__sconfig_append_fromstr(&sysconfig->sconfig, p);
} else if ((p = try_config(line, "sortlist", ';'))) {
status = ares__parse_sortlist(&sysconfig->sortlist, &sysconfig->nsortlist, p);
status =
ares__parse_sortlist(&sysconfig->sortlist, &sysconfig->nsortlist, p);
} else if ((p = try_config(line, "options", ';'))) {
status = set_options(sysconfig, p);
} else {
@ -520,8 +520,9 @@ ares_status_t ares__init_sysconfig_files(ares_channel channel,
}
fclose(fp);
if (status != ARES_EOF)
if (status != ARES_EOF) {
goto done;
}
} else {
error = ERRNO;
switch (error) {
@ -541,15 +542,15 @@ ares_status_t ares__init_sysconfig_files(ares_channel channel,
/* Many systems (Solaris, Linux, BSD's) use nsswitch.conf */
fp = fopen("/etc/nsswitch.conf", "r");
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) ==
ARES_SUCCESS) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) {
if ((p = try_config(line, "hosts:", '\0'))) {
(void)config_lookup(sysconfig, p, "dns", "resolve", "files");
}
}
fclose(fp);
if (status != ARES_EOF)
if (status != ARES_EOF) {
goto done;
}
} else {
error = ERRNO;
switch (error) {
@ -559,28 +560,27 @@ ares_status_t ares__init_sysconfig_files(ares_channel channel,
default:
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error,
strerror(error)));
DEBUGF(fprintf(stderr, "Error opening file: %s\n",
"/etc/nsswitch.conf"));
DEBUGF(
fprintf(stderr, "Error opening file: %s\n", "/etc/nsswitch.conf"));
break;
}
/* ignore error, maybe we will get luck in next if clause */
}
/* Linux / GNU libc 2.x and possibly others have host.conf */
fp = fopen("/etc/host.conf", "r");
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) ==
ARES_SUCCESS) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) {
if ((p = try_config(line, "order", '\0'))) {
/* ignore errors */
(void)config_lookup(sysconfig, p, "bind", NULL, "hosts");
}
}
fclose(fp);
if (status != ARES_EOF)
if (status != ARES_EOF) {
goto done;
}
} else {
error = ERRNO;
switch (error) {
@ -590,8 +590,7 @@ ares_status_t ares__init_sysconfig_files(ares_channel channel,
default:
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error,
strerror(error)));
DEBUGF(
fprintf(stderr, "Error opening file: %s\n", "/etc/host.conf"));
DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/host.conf"));
break;
}
@ -602,16 +601,16 @@ ares_status_t ares__init_sysconfig_files(ares_channel channel,
/* Tru64 uses /etc/svc.conf */
fp = fopen("/etc/svc.conf", "r");
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) ==
ARES_SUCCESS) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) {
if ((p = try_config(line, "hosts=", '\0'))) {
/* ignore errors */
(void)config_lookup(sysconfig, p, "bind", NULL, "local");
}
}
fclose(fp);
if (status != ARES_EOF)
if (status != ARES_EOF) {
goto done;
}
} else {
error = ERRNO;
switch (error) {
@ -621,8 +620,7 @@ ares_status_t ares__init_sysconfig_files(ares_channel channel,
default:
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error,
strerror(error)));
DEBUGF(
fprintf(stderr, "Error opening file: %s\n", "/etc/svc.conf"));
DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/svc.conf"));
break;
}
/* ignore error */

@ -45,32 +45,32 @@ typedef struct {
static ares_bool_t ares__addr_match(const struct ares_addr *addr1,
const struct ares_addr *addr2)
{
if (addr1 == NULL && addr2 == NULL)
if (addr1 == NULL && addr2 == NULL) {
return ARES_TRUE;
}
if (addr1 == NULL || addr2 == NULL)
if (addr1 == NULL || addr2 == NULL) {
return ARES_FALSE;
}
if (addr1->family != addr2->family)
if (addr1->family != addr2->family) {
return ARES_FALSE;
}
if (addr1->family == AF_INET &&
memcmp(&addr1->addr.addr4, &addr2->addr.addr4, sizeof(addr1->addr.addr4))
== 0) {
if (addr1->family == AF_INET && memcmp(&addr1->addr.addr4, &addr2->addr.addr4,
sizeof(addr1->addr.addr4)) == 0) {
return ARES_TRUE;
}
if (addr1->family == AF_INET6 &&
memcmp(&addr1->addr.addr6._S6_un._S6_u8, &addr2->addr.addr6._S6_un._S6_u8,
sizeof(addr1->addr.addr6._S6_un._S6_u8))
== 0) {
sizeof(addr1->addr.addr6._S6_un._S6_u8)) == 0) {
return ARES_TRUE;
}
return ARES_FALSE;
}
/* Validate that the ip address matches the subnet (network base and network
* mask) specified. Addresses are specified in standard Network Byte Order as
* 16 bytes, and the netmask is 0 to 128 (bits).
@ -122,12 +122,14 @@ static ares_bool_t ares_server_blacklisted(const struct ares_addr *addr)
size_t i;
if (addr->family != AF_INET6)
if (addr->family != AF_INET6) {
return ARES_FALSE;
}
/* See if ipaddr matches any of the entries in the blacklist. */
for (i = 0; i < sizeof(blacklist_v6) / sizeof(*blacklist_v6); i++) {
if (ares_ipv6_subnet_matches(blacklist_v6[i].netbase, blacklist_v6[i].netmask,
if (ares_ipv6_subnet_matches(blacklist_v6[i].netbase,
blacklist_v6[i].netmask,
(const unsigned char *)&addr->addr.addr6)) {
return ARES_TRUE;
}
@ -229,21 +231,22 @@ static ares_status_t parse_dnsaddrport(const char *str, size_t len,
return ARES_SUCCESS;
}
ares_status_t ares__sconfig_append(ares__llist_t **sconfig,
ares_status_t ares__sconfig_append(ares__llist_t **sconfig,
const struct ares_addr *addr,
unsigned short udp_port,
unsigned short tcp_port)
unsigned short udp_port,
unsigned short tcp_port)
{
ares_sconfig_t *s;
ares_status_t status;
if (sconfig == NULL || addr == NULL)
if (sconfig == NULL || addr == NULL) {
return ARES_EFORMERR;
}
/* Silently skip blacklisted IPv6 servers. */
if (ares_server_blacklisted(addr))
if (ares_server_blacklisted(addr)) {
return ARES_SUCCESS;
}
s = ares_malloc_zero(sizeof(*s));
if (s == NULL) {
@ -275,7 +278,6 @@ fail:
return status;
}
/* Add the IPv4 or IPv6 nameservers in str (separated by commas or spaces) to
* the servers list, updating servers and nservers as required.
*
@ -293,12 +295,12 @@ fail:
* Returns an error code on failure, else ARES_SUCCESS.
*/
ares_status_t ares__sconfig_append_fromstr(ares__llist_t **sconfig,
const char *str)
const char *str)
{
struct ares_addr host;
const char *p;
const char *txtaddr;
ares_status_t status;
struct ares_addr host;
const char *p;
const char *txtaddr;
ares_status_t status;
/* On Windows, there may be more than one nameserver specified in the same
* registry key, so we parse input as a space or comma seperated list.
@ -337,17 +339,14 @@ ares_status_t ares__sconfig_append_fromstr(ares__llist_t **sconfig,
return ARES_SUCCESS;
}
static unsigned short ares__sconfig_get_port(ares_channel channel,
static unsigned short ares__sconfig_get_port(ares_channel channel,
const ares_sconfig_t *s,
ares_bool_t is_tcp)
ares_bool_t is_tcp)
{
unsigned short port = is_tcp?s->tcp_port:s->udp_port;
unsigned short port = is_tcp ? s->tcp_port : s->udp_port;
if (port == 0) {
port = is_tcp?channel->tcp_port:channel->udp_port;
port = is_tcp ? channel->tcp_port : channel->udp_port;
}
if (port == 0) {
@ -357,7 +356,7 @@ static unsigned short ares__sconfig_get_port(ares_channel channel,
return port;
}
static ares__slist_node_t *ares__server_find(ares_channel channel,
static ares__slist_node_t *ares__server_find(ares_channel channel,
const ares_sconfig_t *s)
{
ares__slist_node_t *node;
@ -366,21 +365,24 @@ static ares__slist_node_t *ares__server_find(ares_channel channel,
node = ares__slist_node_next(node)) {
const struct server_state *server = ares__slist_node_val(node);
if (!ares__addr_match(&server->addr, &s->addr))
if (!ares__addr_match(&server->addr, &s->addr)) {
continue;
}
if (server->tcp_port != ares__sconfig_get_port(channel, s, ARES_TRUE))
if (server->tcp_port != ares__sconfig_get_port(channel, s, ARES_TRUE)) {
continue;
}
if (server->udp_port != ares__sconfig_get_port(channel, s, ARES_FALSE))
if (server->udp_port != ares__sconfig_get_port(channel, s, ARES_FALSE)) {
continue;
}
return node;
}
return NULL;
}
static ares_bool_t ares__server_isdup(ares_channel channel,
static ares_bool_t ares__server_isdup(ares_channel channel,
ares__llist_node_t *s)
{
/* Scan backwards to see if this is a duplicate */
@ -389,19 +391,21 @@ static ares_bool_t ares__server_isdup(ares_channel channel,
for (prev = ares__llist_node_prev(s); prev != NULL;
prev = ares__llist_node_prev(prev)) {
const ares_sconfig_t *p = ares__llist_node_val(prev);
if (!ares__addr_match(&server->addr, &p->addr))
if (!ares__addr_match(&server->addr, &p->addr)) {
continue;
}
if (ares__sconfig_get_port(channel, server, ARES_TRUE) !=
ares__sconfig_get_port(channel, p, ARES_TRUE))
ares__sconfig_get_port(channel, p, ARES_TRUE)) {
continue;
}
if (ares__sconfig_get_port(channel, server, ARES_FALSE) !=
ares__sconfig_get_port(channel, p, ARES_FALSE))
ares__sconfig_get_port(channel, p, ARES_FALSE)) {
continue;
}
return ARES_TRUE;
}
@ -409,15 +413,16 @@ static ares_bool_t ares__server_isdup(ares_channel channel,
return ARES_FALSE;
}
static ares_status_t ares__server_create(ares_channel channel,
static ares_status_t ares__server_create(ares_channel channel,
const ares_sconfig_t *sconfig,
size_t idx)
size_t idx)
{
ares_status_t status;
struct server_state *server = ares_malloc_zero(sizeof(*server));
if (server == NULL)
if (server == NULL) {
return ARES_ENOMEM;
}
server->idx = idx;
server->channel = channel;
@ -467,24 +472,26 @@ done:
}
static ares_bool_t ares__server_in_newconfig(struct server_state *server,
ares__llist_t *srvlist)
ares__llist_t *srvlist)
{
ares__llist_node_t *node;
ares_channel channel = server->channel;
for (node = ares__llist_node_first(srvlist); node != NULL;
node = ares__llist_node_next(node)) {
const ares_sconfig_t *s = ares__llist_node_val(node);
if (!ares__addr_match(&server->addr, &s->addr))
if (!ares__addr_match(&server->addr, &s->addr)) {
continue;
}
if (server->tcp_port != ares__sconfig_get_port(channel, s, ARES_TRUE))
if (server->tcp_port != ares__sconfig_get_port(channel, s, ARES_TRUE)) {
continue;
}
if (server->udp_port != ares__sconfig_get_port(channel, s, ARES_FALSE))
if (server->udp_port != ares__sconfig_get_port(channel, s, ARES_FALSE)) {
continue;
}
return ARES_TRUE;
}
@ -492,7 +499,7 @@ static ares_bool_t ares__server_in_newconfig(struct server_state *server,
return ARES_FALSE;
}
static void ares__servers_remove_stale(ares_channel channel,
static void ares__servers_remove_stale(ares_channel channel,
ares__llist_t *srvlist)
{
ares__slist_node_t *snode = ares__slist_node_first(channel->servers);
@ -509,7 +516,6 @@ static void ares__servers_remove_stale(ares_channel channel,
}
}
static void ares__servers_trim_single(ares_channel channel)
{
while (ares__slist_len(channel->servers) > 1) {
@ -517,10 +523,9 @@ static void ares__servers_trim_single(ares_channel channel)
}
}
ares_status_t ares__servers_update(ares_channel channel,
ares_status_t ares__servers_update(ares_channel channel,
ares__llist_t *server_list,
ares_bool_t user_specified)
ares_bool_t user_specified)
{
ares__llist_node_t *node;
size_t idx = 0;
@ -534,7 +539,6 @@ ares_status_t ares__servers_update(ares_channel channel,
/* Add new entries */
for (node = ares__llist_node_first(server_list); node != NULL;
node = ares__llist_node_next(node)) {
const ares_sconfig_t *sconfig = ares__llist_node_val(node);
ares__slist_node_t *snode;
@ -555,8 +559,9 @@ ares_status_t ares__servers_update(ares_channel channel,
}
} else {
status = ares__server_create(channel, sconfig, idx);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
goto done;
}
}
idx++;
@ -580,45 +585,47 @@ done:
return status;
}
static ares__llist_t *ares_addr_node_to_server_config_llist(
const struct ares_addr_node *servers)
static ares__llist_t *
ares_addr_node_to_server_config_llist(const struct ares_addr_node *servers)
{
const struct ares_addr_node *node;
ares__llist_t *s;
if (servers == NULL)
if (servers == NULL) {
return NULL;
}
s = ares__llist_create(ares_free);
if (s == NULL)
if (s == NULL) {
return NULL;
}
for (node = servers; node != NULL; node = node->next) {
ares_sconfig_t *sconfig;
/* Invalid entry */
if (node->family != AF_INET && node->family != AF_INET6)
if (node->family != AF_INET && node->family != AF_INET6) {
continue;
}
sconfig = ares_malloc_zero(sizeof(*sconfig));
if (sconfig == NULL)
if (sconfig == NULL) {
goto fail;
}
sconfig->addr.family = node->family;
if (node->family == AF_INET) {
memcpy(&sconfig->addr.addr.addr4, &node->addr.addr4,
sizeof(sconfig->addr.addr.addr4));
sizeof(sconfig->addr.addr.addr4));
} else if (sconfig->addr.family == AF_INET6) {
memcpy(&sconfig->addr.addr.addr6, &node->addr.addr6,
sizeof(sconfig->addr.addr.addr6));
sizeof(sconfig->addr.addr.addr6));
}
if (ares__llist_insert_last(s, sconfig) == NULL) {
ares_free(sconfig);
goto fail;
}
}
return s;
@ -634,31 +641,35 @@ static ares__llist_t *ares_addr_port_node_to_server_config_llist(
const struct ares_addr_port_node *node;
ares__llist_t *s;
if (servers == NULL)
if (servers == NULL) {
return NULL;
}
s = ares__llist_create(ares_free);
if (s == NULL)
if (s == NULL) {
return NULL;
}
for (node = servers; node != NULL; node = node->next) {
ares_sconfig_t *sconfig;
/* Invalid entry */
if (node->family != AF_INET && node->family != AF_INET6)
if (node->family != AF_INET && node->family != AF_INET6) {
continue;
}
sconfig = ares_malloc_zero(sizeof(*sconfig));
if (sconfig == NULL)
if (sconfig == NULL) {
goto fail;
}
sconfig->addr.family = node->family;
if (node->family == AF_INET) {
memcpy(&sconfig->addr.addr.addr4, &node->addr.addr4,
sizeof(sconfig->addr.addr.addr4));
sizeof(sconfig->addr.addr.addr4));
} else if (sconfig->addr.family == AF_INET6) {
memcpy(&sconfig->addr.addr.addr6, &node->addr.addr6,
sizeof(sconfig->addr.addr.addr6));
sizeof(sconfig->addr.addr.addr6));
}
sconfig->tcp_port = (unsigned short)node->tcp_port;
@ -677,26 +688,29 @@ fail:
return NULL;
}
ares__llist_t *ares_in_addr_to_server_config_llist(
const struct in_addr *servers, size_t nservers)
ares__llist_t *
ares_in_addr_to_server_config_llist(const struct in_addr *servers,
size_t nservers)
{
size_t i;
ares__llist_t *s;
if (servers == NULL || nservers == 0)
if (servers == NULL || nservers == 0) {
return NULL;
}
s = ares__llist_create(ares_free);
if (s == NULL)
if (s == NULL) {
return NULL;
}
for (i=0; i<nservers; i++) {
for (i = 0; i < nservers; i++) {
ares_sconfig_t *sconfig;
sconfig = ares_malloc_zero(sizeof(*sconfig));
if (sconfig == NULL)
if (sconfig == NULL) {
goto fail;
}
sconfig->addr.family = AF_INET;
memcpy(&sconfig->addr.addr.addr4, &servers[i],
@ -818,7 +832,6 @@ int ares_get_servers_ports(ares_channel channel,
return (int)status;
}
int ares_set_servers(ares_channel channel, struct ares_addr_node *servers)
{
ares__llist_t *slist;
@ -840,7 +853,6 @@ int ares_set_servers(ares_channel channel, struct ares_addr_node *servers)
return (int)status;
}
int ares_set_servers_ports(ares_channel channel,
struct ares_addr_port_node *servers)
{
@ -863,7 +875,6 @@ int ares_set_servers_ports(ares_channel channel,
return (int)status;
}
/* Incomming string format: host[:port][,host[:port]]... */
/* IPv6 addresses with ports require square brackets [fe80::1]:53 */
static ares_status_t set_servers_csv(ares_channel channel, const char *_csv,

@ -85,7 +85,7 @@
#endif
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_STAT_H 1
/* ---------------------------------------------------------------- */
/* OTHER HEADER INFO */

Loading…
Cancel
Save