clang-format

pull/733/head
Brad House 8 months ago
parent b2139f6c79
commit 9f4c474a7c
  1. 268
      include/ares.h
  2. 31
      include/ares_dns_record.h
  3. 1
      src/lib/ares__hosts_file.c
  4. 10
      src/lib/ares__htable.h
  5. 2
      src/lib/ares__htable_asvp.h
  6. 2
      src/lib/ares__htable_strvp.h
  7. 2
      src/lib/ares__htable_szvp.h
  8. 2
      src/lib/ares__llist.h
  9. 4
      src/lib/ares__slist.h
  10. 6
      src/lib/ares__threads.c
  11. 6
      src/lib/ares__threads.h
  12. 8
      src/lib/ares_create_query.c
  13. 2
      src/lib/ares_dns_mapping.c
  14. 14
      src/lib/ares_dns_private.h
  15. 22
      src/lib/ares_dns_record.c
  16. 10
      src/lib/ares_dns_write.c
  17. 8
      src/lib/ares_event.h
  18. 52
      src/lib/ares_getaddrinfo.c
  19. 11
      src/lib/ares_gethostbyaddr.c
  20. 4
      src/lib/ares_library_init.c
  21. 4
      src/lib/ares_parse_a_reply.c
  22. 4
      src/lib/ares_parse_aaaa_reply.c
  23. 20
      src/lib/ares_parse_ptr_reply.c
  24. 39
      src/lib/ares_private.h
  25. 9
      src/lib/ares_process.c
  26. 9
      src/lib/ares_qcache.c
  27. 25
      src/lib/ares_query.c
  28. 94
      src/lib/ares_search.c
  29. 23
      src/lib/ares_send.c
  30. 8
      src/lib/ares_update_servers.c

@ -120,34 +120,34 @@ extern "C" {
#endif
#ifdef __GNUC__
#define CARES_GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
# define CARES_GCC_VERSION \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#else
#define CARES_GCC_VERSION 0
# define CARES_GCC_VERSION 0
#endif
#ifndef __has_attribute
#define __has_attribute(x) 0
# define __has_attribute(x) 0
#endif
#ifdef CARES_NO_DEPRECATED
#define CARES_DEPRECATED
#define CARES_DEPRECATED_FOR(f)
# define CARES_DEPRECATED
# define CARES_DEPRECATED_FOR(f)
#else
#if CARES_GCC_VERSION >= 30200 || __has_attribute (__deprecated__)
#define CARES_DEPRECATED __attribute__((__deprecated__))
#else
#define CARES_DEPRECATED
#endif
# if CARES_GCC_VERSION >= 30200 || __has_attribute(__deprecated__)
# define CARES_DEPRECATED __attribute__((__deprecated__))
# else
# define CARES_DEPRECATED
# endif
#if CARES_GCC_VERSION >= 40500 || defined(__clang__)
#define CARES_DEPRECATED_FOR(f) __attribute__((deprecated("Use " #f " instead")))
#elif defined(_MSC_VER)
#define CARES_DEPRECATED_FOR(f) __declspec(deprecated("Use " #f " instead"))
#else
#define CARES_DEPRECATED_FOR(f) CARES_DEPRECATED
#endif
# if CARES_GCC_VERSION >= 40500 || defined(__clang__)
# define CARES_DEPRECATED_FOR(f) \
__attribute__((deprecated("Use " #f " instead")))
# elif defined(_MSC_VER)
# define CARES_DEPRECATED_FOR(f) __declspec(deprecated("Use " #f " instead"))
# else
# define CARES_DEPRECATED_FOR(f) CARES_DEPRECATED
# endif
#endif
typedef enum {
@ -408,32 +408,32 @@ struct ares_addr {
/* DNS record parser, writer, and helpers */
#include "ares_dns_record.h"
typedef void (*ares_callback)(void *arg, int status, int timeouts,
typedef void (*ares_callback)(void *arg, int status, int timeouts,
unsigned char *abuf, int alen);
typedef void (*ares_callback_dnsrec)(void *arg, ares_status_t status,
size_t timeouts,
typedef void (*ares_callback_dnsrec)(void *arg, ares_status_t status,
size_t timeouts,
const ares_dns_record_t *dnsrec);
typedef void (*ares_host_callback)(void *arg, int status, int timeouts,
typedef void (*ares_host_callback)(void *arg, int status, int timeouts,
struct hostent *hostent);
typedef void (*ares_nameinfo_callback)(void *arg, int status, int timeouts,
typedef void (*ares_nameinfo_callback)(void *arg, int status, int timeouts,
char *node, char *service);
typedef int (*ares_sock_create_callback)(ares_socket_t socket_fd, int type,
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,
typedef int (*ares_sock_config_callback)(ares_socket_t socket_fd, int type,
void *data);
typedef void (*ares_addrinfo_callback)(void *arg, int status, int timeouts,
typedef void (*ares_addrinfo_callback)(void *arg, int status, int timeouts,
struct ares_addrinfo *res);
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 (*afree)(void *ptr),
void *(*arealloc)(void *ptr,
size_t size));
@ -443,14 +443,14 @@ CARES_EXTERN int ares_library_init_android(jobject connectivity_manager);
CARES_EXTERN int ares_library_android_initialized(void);
#endif
CARES_EXTERN int ares_library_initialized(void);
CARES_EXTERN int ares_library_initialized(void);
CARES_EXTERN void ares_library_cleanup(void);
CARES_EXTERN void ares_library_cleanup(void);
CARES_EXTERN const char *ares_version(int *version);
CARES_EXTERN const char *ares_version(int *version);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_init_options)
int ares_init(ares_channel_t **channelptr);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_init_options) int ares_init(
ares_channel_t **channelptr);
CARES_EXTERN int ares_init_options(ares_channel_t **channelptr,
const struct ares_options *options,
@ -513,7 +513,7 @@ struct iovec;
struct ares_socket_functions {
ares_socket_t (*asocket)(int, int, int, void *);
int (*aclose)(ares_socket_t, void *);
int (*aclose)(ares_socket_t, void *);
int (*aconnect)(ares_socket_t, const struct sockaddr *, ares_socklen_t,
void *);
ares_ssize_t (*arecvfrom)(ares_socket_t, void *, size_t, int,
@ -522,13 +522,13 @@ struct ares_socket_functions {
};
CARES_EXTERN void
ares_set_socket_functions(ares_channel_t *channel,
const struct ares_socket_functions *funcs,
void *user_data);
ares_set_socket_functions(ares_channel_t *channel,
const struct ares_socket_functions *funcs,
void *user_data);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_send_dnsrec)
void ares_send(ares_channel_t *channel, const unsigned char *qbuf,
int qlen, ares_callback callback, void *arg);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_send_dnsrec) void ares_send(
ares_channel_t *channel, const unsigned char *qbuf, int qlen,
ares_callback callback, void *arg);
/*! Send a DNS query as an ares_dns_record_t with a callback containing the
* parsed DNS record.
@ -541,15 +541,14 @@ CARES_EXTERN CARES_DEPRECATED_FOR(ares_send_dnsrec)
* \param[out] qid Query ID
* \return One of the c-ares status codes.
*/
CARES_EXTERN ares_status_t ares_send_dnsrec(ares_channel_t *channel,
CARES_EXTERN ares_status_t ares_send_dnsrec(ares_channel_t *channel,
const ares_dns_record_t *dnsrec,
ares_callback_dnsrec callback,
ares_callback_dnsrec callback,
void *arg, unsigned short *qid);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_query_dnsrec)
void ares_query(ares_channel_t *channel, const char *name,
int dnsclass, int type, ares_callback callback,
void *arg);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_query_dnsrec) void ares_query(
ares_channel_t *channel, const char *name, int dnsclass, int type,
ares_callback callback, void *arg);
/*! Perform a DNS query with a callback containing the parsed DNS record.
*
@ -568,13 +567,11 @@ CARES_EXTERN ares_status_t ares_query_dnsrec(ares_channel_t *channel,
ares_dns_class_t dnsclass,
ares_dns_rec_type_t type,
ares_callback_dnsrec callback,
void *arg,
unsigned short *qid);
void *arg, unsigned short *qid);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_search_dnsrec)
void ares_search(ares_channel_t *channel, const char *name,
int dnsclass, int type, ares_callback callback,
void *arg);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_search_dnsrec) void ares_search(
ares_channel_t *channel, const char *name, int dnsclass, int type,
ares_callback callback, void *arg);
/*! Search for a complete DNS message.
*
@ -587,15 +584,14 @@ CARES_EXTERN CARES_DEPRECATED_FOR(ares_search_dnsrec)
* ARES_EFORMERR due to misuse, this error code will also be sent
* to the provided callback.
*/
CARES_EXTERN ares_status_t ares_search_dnsrec(ares_channel_t *channel,
CARES_EXTERN ares_status_t ares_search_dnsrec(ares_channel_t *channel,
const ares_dns_record_t *dnsrec,
ares_callback_dnsrec callback,
void *arg);
ares_callback_dnsrec callback,
void *arg);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_getaddrinfo)
void ares_gethostbyname(ares_channel_t *channel, const char *name,
int family, ares_host_callback callback,
void *arg);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_getaddrinfo) void ares_gethostbyname(
ares_channel_t *channel, const char *name, int family,
ares_host_callback callback, void *arg);
CARES_EXTERN int ares_gethostbyname_file(ares_channel_t *channel,
const char *name, int family,
@ -610,42 +606,42 @@ CARES_EXTERN void ares_getnameinfo(ares_channel_t *channel,
ares_socklen_t salen, int flags,
ares_nameinfo_callback callback, void *arg);
CARES_EXTERN CARES_DEPRECATED_FOR(ARES_OPT_EVENT_THREAD or ARES_OPT_SOCK_STATE_CB)
int ares_fds(ares_channel_t *channel, fd_set *read_fds, fd_set *write_fds);
CARES_EXTERN CARES_DEPRECATED_FOR(
ARES_OPT_EVENT_THREAD or
ARES_OPT_SOCK_STATE_CB) int ares_fds(ares_channel_t *channel,
fd_set *read_fds, fd_set *write_fds);
CARES_EXTERN CARES_DEPRECATED_FOR(ARES_OPT_EVENT_THREAD or ARES_OPT_SOCK_STATE_CB)
int ares_getsock(ares_channel_t *channel, ares_socket_t *socks, int numsocks);
CARES_EXTERN CARES_DEPRECATED_FOR(
ARES_OPT_EVENT_THREAD or
ARES_OPT_SOCK_STATE_CB) int ares_getsock(ares_channel_t *channel,
ares_socket_t *socks, int numsocks);
CARES_EXTERN struct timeval *ares_timeout(ares_channel_t *channel,
struct timeval *maxtv,
struct timeval *tv);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_process_fd)
void ares_process(ares_channel_t *channel, fd_set *read_fds,
fd_set *write_fds);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_process_fd) void ares_process(
ares_channel_t *channel, fd_set *read_fds, fd_set *write_fds);
CARES_EXTERN void ares_process_fd(ares_channel_t *channel,
ares_socket_t read_fd,
ares_socket_t write_fd);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_record_create)
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 CARES_DEPRECATED_FOR(ares_dns_record_create) 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 CARES_DEPRECATED_FOR(ares_dns_record_create)
int ares_mkquery(const char *name, int dnsclass, int type,
unsigned short id, int rd, unsigned char **buf,
int *buflen);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_record_create) int ares_mkquery(
const char *name, int dnsclass, int type, unsigned short id, int rd,
unsigned char **buf, int *buflen);
CARES_EXTERN int ares_expand_name(const unsigned char *encoded,
const unsigned char *abuf, int alen, char **s,
long *enclen);
CARES_EXTERN int ares_expand_name(const unsigned char *encoded,
const unsigned char *abuf, int alen, char **s,
long *enclen);
CARES_EXTERN int ares_expand_string(const unsigned char *encoded,
const unsigned char *abuf, int alen,
unsigned char **s, long *enclen);
CARES_EXTERN int ares_expand_string(const unsigned char *encoded,
const unsigned char *abuf, int alen,
unsigned char **s, long *enclen);
struct ares_addrttl {
struct in_addr ipaddr;
@ -772,64 +768,50 @@ struct ares_addrinfo_hints {
** so written.
*/
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse)
int ares_parse_a_reply(const unsigned char *abuf, int alen,
struct hostent **host,
struct ares_addrttl *addrttls,
int *naddrttls);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_a_reply(
const unsigned char *abuf, int alen, struct hostent **host,
struct ares_addrttl *addrttls, int *naddrttls);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse)
int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
struct hostent **host,
struct ares_addr6ttl *addrttls,
int *naddrttls);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_aaaa_reply(
const unsigned char *abuf, int alen, struct hostent **host,
struct ares_addr6ttl *addrttls, int *naddrttls);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse)
int ares_parse_caa_reply(const unsigned char *abuf, int alen,
struct ares_caa_reply **caa_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_caa_reply(
const unsigned char *abuf, int alen, struct ares_caa_reply **caa_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse)
int ares_parse_ptr_reply(const unsigned char *abuf, int alen,
const void *addr, int addrlen, int family,
struct hostent **host);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_ptr_reply(
const unsigned char *abuf, int alen, const void *addr, int addrlen,
int family, struct hostent **host);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse)
int ares_parse_ns_reply(const unsigned char *abuf, int alen,
struct hostent **host);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_ns_reply(
const unsigned char *abuf, int alen, struct hostent **host);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse)
int ares_parse_srv_reply(const unsigned char *abuf, int alen,
struct ares_srv_reply **srv_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_srv_reply(
const unsigned char *abuf, int alen, struct ares_srv_reply **srv_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse)
int ares_parse_mx_reply(const unsigned char *abuf, int alen,
struct ares_mx_reply **mx_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_mx_reply(
const unsigned char *abuf, int alen, struct ares_mx_reply **mx_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse)
int ares_parse_txt_reply(const unsigned char *abuf, int alen,
struct ares_txt_reply **txt_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_txt_reply(
const unsigned char *abuf, int alen, struct ares_txt_reply **txt_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse)
int ares_parse_txt_reply_ext(const unsigned char *abuf, int alen,
struct ares_txt_ext **txt_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_txt_reply_ext(
const unsigned char *abuf, int alen, struct ares_txt_ext **txt_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse)
int ares_parse_naptr_reply(const unsigned char *abuf, int alen,
struct ares_naptr_reply **naptr_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_naptr_reply(
const unsigned char *abuf, int alen, struct ares_naptr_reply **naptr_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse)
int ares_parse_soa_reply(const unsigned char *abuf, int alen,
struct ares_soa_reply **soa_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_soa_reply(
const unsigned char *abuf, int alen, struct ares_soa_reply **soa_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse)
int ares_parse_uri_reply(const unsigned char *abuf, int alen,
struct ares_uri_reply **uri_out);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_uri_reply(
const unsigned char *abuf, int alen, struct ares_uri_reply **uri_out);
CARES_EXTERN void ares_free_string(void *str);
CARES_EXTERN void ares_free_string(void *str);
CARES_EXTERN void ares_free_hostent(struct hostent *host);
CARES_EXTERN void ares_free_hostent(struct hostent *host);
CARES_EXTERN void ares_free_data(void *dataptr);
CARES_EXTERN void ares_free_data(void *dataptr);
CARES_EXTERN const char *ares_strerror(int code);
@ -856,28 +838,26 @@ struct ares_addr_port_node {
int tcp_port;
};
CARES_EXTERN CARES_DEPRECATED_FOR(ares_set_servers_csv)
int ares_set_servers(ares_channel_t *channel,
const struct ares_addr_node *servers);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_set_servers_csv) int ares_set_servers(
ares_channel_t *channel, const struct ares_addr_node *servers);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_set_servers_ports_csv)
int ares_set_servers_ports(ares_channel_t *channel,
const struct ares_addr_port_node *servers);
CARES_EXTERN
CARES_DEPRECATED_FOR(ares_set_servers_ports_csv) int ares_set_servers_ports(
ares_channel_t *channel, const struct ares_addr_port_node *servers);
/* Incoming string format: host[:port][,host[:port]]... */
CARES_EXTERN int ares_set_servers_csv(ares_channel_t *channel,
const char *servers);
CARES_EXTERN int ares_set_servers_ports_csv(ares_channel_t *channel,
const char *servers);
CARES_EXTERN char *ares_get_servers_csv(ares_channel_t *channel);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_get_servers_csv)
int ares_get_servers(ares_channel_t *channel,
struct ares_addr_node **servers);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_get_servers_ports_csv)
int ares_get_servers_ports(ares_channel_t *channel,
struct ares_addr_port_node **servers);
CARES_EXTERN int ares_set_servers_csv(ares_channel_t *channel,
const char *servers);
CARES_EXTERN int ares_set_servers_ports_csv(ares_channel_t *channel,
const char *servers);
CARES_EXTERN char *ares_get_servers_csv(ares_channel_t *channel);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_get_servers_csv) int ares_get_servers(
ares_channel_t *channel, struct ares_addr_node **servers);
CARES_EXTERN
CARES_DEPRECATED_FOR(ares_get_servers_ports_csv) int ares_get_servers_ports(
ares_channel_t *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);

@ -393,11 +393,11 @@ typedef enum {
/*! Parse Additional from RFC 1035 that allow name compression as RAW */
ARES_DNS_PARSE_AR_BASE_RAW = 1 << 2,
/*! Parse Answers from later RFCs (no name compression) RAW */
ARES_DNS_PARSE_AN_EXT_RAW = 1 << 3,
ARES_DNS_PARSE_AN_EXT_RAW = 1 << 3,
/*! Parse Authority from later RFCs (no name compression) as RAW */
ARES_DNS_PARSE_NS_EXT_RAW = 1 << 4,
ARES_DNS_PARSE_NS_EXT_RAW = 1 << 4,
/*! Parse Additional from later RFCs (no name compression) as RAW */
ARES_DNS_PARSE_AR_EXT_RAW = 1 << 5
ARES_DNS_PARSE_AR_EXT_RAW = 1 << 5
} ares_dns_parse_flags_t;
/*! String representation of DNS Record Type
@ -630,10 +630,8 @@ CARES_EXTERN ares_status_t ares_dns_record_query_add(ares_dns_record_t *dnsrec,
* \param[in] name Name to use as replacement.
* \return ARES_SUCCESS on success
*/
CARES_EXTERN ares_status_t
ares_dns_record_query_set_name(ares_dns_record_t *dnsrec,
size_t idx,
const char *name);
CARES_EXTERN ares_status_t ares_dns_record_query_set_name(
ares_dns_record_t *dnsrec, size_t idx, const char *name);
/*! Replace the question type with a different type. This may be used when
@ -644,10 +642,8 @@ CARES_EXTERN ares_status_t
* \param[in] qtype Record Type to use as replacement.
* \return ARES_SUCCESS on success
*/
CARES_EXTERN ares_status_t
ares_dns_record_query_set_type(ares_dns_record_t *dnsrec,
size_t idx,
ares_dns_rec_type_t qtype);
CARES_EXTERN ares_status_t ares_dns_record_query_set_type(
ares_dns_record_t *dnsrec, size_t idx, ares_dns_rec_type_t qtype);
/*! Get the count of queries in the DNS Record
*
@ -717,8 +713,9 @@ CARES_EXTERN ares_dns_rr_t *ares_dns_record_rr_get(ares_dns_record_t *dnsrec,
* \param[in] idx Index of resource record in section
* \return NULL on misuse, otherwise a const pointer to the resource record
*/
CARES_EXTERN const ares_dns_rr_t *ares_dns_record_rr_get_const(
const ares_dns_record_t *dnsrec, ares_dns_section_t sect, size_t idx);
CARES_EXTERN const ares_dns_rr_t *
ares_dns_record_rr_get_const(const ares_dns_record_t *dnsrec,
ares_dns_section_t sect, size_t idx);
/*! Remove the resource record based on the section and index
@ -728,9 +725,9 @@ CARES_EXTERN const ares_dns_rr_t *ares_dns_record_rr_get_const(
* \param[in] idx Index of resource record in section
* \return ARES_SUCCESS on success, otherwise an error code.
*/
CARES_EXTERN ares_status_t ares_dns_record_rr_del(ares_dns_record_t *dnsrec,
ares_dns_section_t sect,
size_t idx);
CARES_EXTERN ares_status_t ares_dns_record_rr_del(ares_dns_record_t *dnsrec,
ares_dns_section_t sect,
size_t idx);
/*! Retrieve the resource record Name/Hostname
@ -738,7 +735,7 @@ CARES_EXTERN ares_status_t ares_dns_record_rr_del(ares_dns_record_t *dnsrec,
* \param[in] rr Pointer to resource record
* \return Name
*/
CARES_EXTERN const char *ares_dns_rr_get_name(const ares_dns_rr_t *rr);
CARES_EXTERN const char *ares_dns_rr_get_name(const ares_dns_rr_t *rr);
/*! Retrieve the resource record type
*

@ -98,7 +98,6 @@ struct ares_hosts_entry {
ares__llist_t *hosts;
};
const void *ares_dns_pton(const char *ipaddr, struct ares_addr *addr,
size_t *out_len)
{

@ -58,21 +58,21 @@ typedef struct ares__htable ares__htable_t;
* but otherwise will not change between calls.
* \return hash
*/
typedef unsigned int (*ares__htable_hashfunc_t)(const void *key,
typedef unsigned int (*ares__htable_hashfunc_t)(const void *key,
unsigned int seed);
/*! Callback to free the bucket
*
* \param[in] bucket user provided bucket
*/
typedef void (*ares__htable_bucket_free_t)(void *bucket);
typedef void (*ares__htable_bucket_free_t)(void *bucket);
/*! Callback to extract the key from the user-provided bucket
*
* \param[in] bucket user provided bucket
* \return pointer to key held in bucket
*/
typedef const void *(*ares__htable_bucket_key_t)(const void *bucket);
typedef const void *(*ares__htable_bucket_key_t)(const void *bucket);
/*! Callback to compare two keys for equality
*
@ -80,7 +80,7 @@ typedef const void *(*ares__htable_bucket_key_t)(const void *bucket);
* \param[in] key2 second key
* \return ARES_TRUE if equal, ARES_FALSE if not
*/
typedef ares_bool_t (*ares__htable_key_eq_t)(const void *key1,
typedef ares_bool_t (*ares__htable_key_eq_t)(const void *key1,
const void *key2);
@ -88,7 +88,7 @@ typedef ares_bool_t (*ares__htable_key_eq_t)(const void *key1,
*
* \param[in] htable initialized hashtable
*/
void ares__htable_destroy(ares__htable_t *htable);
void ares__htable_destroy(ares__htable_t *htable);
/*! Create a new hashtable
*

@ -51,7 +51,7 @@ typedef struct ares__htable_asvp ares__htable_asvp_t;
*
* \param[in] val user-supplied value
*/
typedef void (*ares__htable_asvp_val_free_t)(void *val);
typedef void (*ares__htable_asvp_val_free_t)(void *val);
/*! Destroy hashtable
*

@ -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
*

@ -49,7 +49,7 @@ typedef struct ares__htable_szvp ares__htable_szvp_t;
*
* \param[in] val user-supplied value
*/
typedef void (*ares__htable_szvp_val_free_t)(void *val);
typedef void (*ares__htable_szvp_val_free_t)(void *val);
/*! Destroy hashtable
*

@ -52,7 +52,7 @@ typedef struct ares__llist_node ares__llist_node_t;
*
* \param[in] data user supplied data
*/
typedef void (*ares__llist_destructor_t)(void *data);
typedef void (*ares__llist_destructor_t)(void *data);
/*! Create a linked list object
*

@ -63,7 +63,7 @@ typedef struct ares__slist_node ares__slist_node_t;
*
* \param[in] data User-defined data to destroy
*/
typedef void (*ares__slist_destructor_t)(void *data);
typedef void (*ares__slist_destructor_t)(void *data);
/*! SkipList comparison function
*
@ -71,7 +71,7 @@ typedef void (*ares__slist_destructor_t)(void *data);
* \param[in] data2 Second user-defined data object
* \return < 0 if data1 < data1, > 0 if data1 > data2, 0 if data1 == data2
*/
typedef int (*ares__slist_cmp_t)(const void *data1, const void *data2);
typedef int (*ares__slist_cmp_t)(const void *data1, const void *data2);
/*! Create SkipList
*

@ -138,9 +138,9 @@ struct ares__thread {
HANDLE thread;
DWORD id;
void *(*func)(void *arg);
void *arg;
void *rv;
void *(*func)(void *arg);
void *arg;
void *rv;
};
/* Wrap for pthread compatibility */

@ -52,9 +52,9 @@ ares_status_t ares__thread_cond_timedwait(ares__thread_cond_t *cond,
struct ares__thread;
typedef struct ares__thread ares__thread_t;
typedef void *(*ares__thread_func_t)(void *arg);
ares_status_t ares__thread_create(ares__thread_t **thread,
ares__thread_func_t func, void *arg);
typedef void *(*ares__thread_func_t)(void *arg);
ares_status_t ares__thread_create(ares__thread_t **thread,
ares__thread_func_t func, void *arg);
ares_status_t ares__thread_join(ares__thread_t *thread, void **rv);
#endif

@ -46,10 +46,9 @@ static int ares_create_query_int(const char *name, int dnsclass, int type,
*bufp = NULL;
*buflenp = 0;
status = ares_dns_record_create_query(&dnsrec, name,
(ares_dns_class_t)dnsclass,
(ares_dns_rec_type_t)type,
id, rd_flag, (size_t)max_udp_size);
status = ares_dns_record_create_query(
&dnsrec, name, (ares_dns_class_t)dnsclass, (ares_dns_rec_type_t)type, id,
rd_flag, (size_t)max_udp_size);
if (status != ARES_SUCCESS) {
goto done;
}
@ -79,4 +78,3 @@ int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
{
return ares_create_query_int(name, dnsclass, type, id, rd, buf, buflen, 0);
}

@ -888,7 +888,7 @@ const char *ares_dns_rcode_tostr(ares_dns_rcode_t rcode)
* value. Used internally by ares_search() and ares_query().
*/
ares_status_t ares_dns_query_reply_tostatus(ares_dns_rcode_t rcode,
size_t ancount)
size_t ancount)
{
ares_status_t status = ARES_SUCCESS;

@ -61,13 +61,11 @@ void ares_dns_record_write_ttl_decrement(ares_dns_record_t *dnsrec,
* \param[in] max_udp_size Maximum size of a UDP packet for EDNS.
* \return ARES_SUCCESS on success, otherwise an error code.
*/
ares_status_t ares_dns_record_create_query(ares_dns_record_t **dnsrec,
const char *name,
ares_dns_class_t dnsclass,
ares_dns_rec_type_t type,
unsigned short id,
ares_dns_flags_t flags,
size_t max_udp_size);
ares_status_t
ares_dns_record_create_query(ares_dns_record_t **dnsrec, const char *name,
ares_dns_class_t dnsclass,
ares_dns_rec_type_t type, unsigned short id,
ares_dns_flags_t flags, size_t max_udp_size);
/*! Convert the RCODE and ANCOUNT from a DNS query reply into a status code.
*
@ -76,7 +74,7 @@ ares_status_t ares_dns_record_create_query(ares_dns_record_t **dnsrec,
* \return An appropriate status code.
*/
ares_status_t ares_dns_query_reply_tostatus(ares_dns_rcode_t rcode,
size_t ancount);
size_t ancount);
struct ares_dns_qd {
char *name;

@ -276,16 +276,15 @@ ares_status_t ares_dns_record_query_add(ares_dns_record_t *dnsrec,
return ARES_SUCCESS;
}
ares_status_t ares_dns_record_query_set_name(ares_dns_record_t *dnsrec,
size_t idx,
const char *name)
ares_status_t ares_dns_record_query_set_name(ares_dns_record_t *dnsrec,
size_t idx, const char *name)
{
char *orig_name = NULL;
if (dnsrec == NULL || idx >= dnsrec->qdcount || name == NULL) {
return ARES_EFORMERR;
}
orig_name = dnsrec->qd[idx].name;
orig_name = dnsrec->qd[idx].name;
dnsrec->qd[idx].name = ares_strdup(name);
if (dnsrec->qd[idx].name == NULL) {
dnsrec->qd[idx].name = orig_name;
@ -1352,13 +1351,11 @@ ares_bool_t ares_dns_has_opt_rr(const ares_dns_record_t *rec)
/* Construct a DNS record for a name with given class and type. Used internally
* by ares_search() and ares_create_query().
*/
ares_status_t ares_dns_record_create_query(ares_dns_record_t **dnsrec,
const char *name,
ares_dns_class_t dnsclass,
ares_dns_rec_type_t type,
unsigned short id,
ares_dns_flags_t flags,
size_t max_udp_size)
ares_status_t
ares_dns_record_create_query(ares_dns_record_t **dnsrec, const char *name,
ares_dns_class_t dnsclass,
ares_dns_rec_type_t type, unsigned short id,
ares_dns_flags_t flags, size_t max_udp_size)
{
ares_status_t status;
ares_dns_rr_t *rr = NULL;
@ -1434,8 +1431,9 @@ ares_dns_record_t *ares_dns_record_duplicate(const ares_dns_record_t *dnsrec)
ares_dns_record_t *out = NULL;
ares_status_t status;
if (dnsrec == NULL)
if (dnsrec == NULL) {
return NULL;
}
status = ares_dns_write(dnsrec, &data, &data_len);
if (status != ARES_SUCCESS) {

@ -832,9 +832,9 @@ static ares_status_t ares_dns_write_rr_raw_rr(ares__buf_t *buf,
}
static ares_status_t ares_dns_write_rr(const ares_dns_record_t *dnsrec,
ares__llist_t **namelist,
ares_dns_section_t section,
ares__buf_t *buf)
ares__llist_t **namelist,
ares_dns_section_t section,
ares__buf_t *buf)
{
size_t i;
@ -989,8 +989,7 @@ static ares_status_t ares_dns_write_rr(const ares_dns_record_t *dnsrec,
}
ares_status_t ares_dns_write(const ares_dns_record_t *dnsrec,
unsigned char **buf,
size_t *buf_len)
unsigned char **buf, size_t *buf_len)
{
ares__buf_t *b = NULL;
ares_status_t status;
@ -1053,4 +1052,3 @@ void ares_dns_record_write_ttl_decrement(ares_dns_record_t *dnsrec,
}
dnsrec->ttl_decrement = ttl_decrement;
}

@ -72,11 +72,11 @@ struct ares_event {
typedef struct {
const char *name;
ares_bool_t (*init)(ares_event_thread_t *e);
void (*destroy)(ares_event_thread_t *e);
void (*destroy)(ares_event_thread_t *e);
ares_bool_t (*event_add)(ares_event_t *event);
void (*event_del)(ares_event_t *event);
void (*event_mod)(ares_event_t *event, ares_event_flags_t new_flags);
size_t (*wait)(ares_event_thread_t *e, unsigned long timeout_ms);
void (*event_del)(ares_event_t *event);
void (*event_mod)(ares_event_t *event, ares_event_flags_t new_flags);
size_t (*wait)(ares_event_thread_t *e, unsigned long timeout_ms);
} ares_event_sys_t;
struct ares_event_thread {

@ -83,16 +83,16 @@ struct host_query {
/* Search order for names */
char **names;
size_t names_cnt;
size_t next_name_idx; /* next name index being attempted */
size_t next_name_idx; /* next name index being attempted */
struct ares_addrinfo *ai; /* store results between lookups */
unsigned short qid_a; /* qid for A request */
unsigned short qid_aaaa; /* qid for AAAA request */
struct ares_addrinfo *ai; /* store results between lookups */
unsigned short qid_a; /* qid for A request */
unsigned short qid_aaaa; /* qid for AAAA request */
size_t remaining; /* number of DNS answers waiting for */
size_t remaining; /* number of DNS answers waiting for */
/* Track nodata responses to possibly override final result */
size_t nodata_cnt;
size_t nodata_cnt;
};
static const struct ares_addrinfo_hints default_hints = {
@ -499,8 +499,8 @@ static void host_callback(void *arg, ares_status_t status, size_t timeouts,
if (dnsrec == NULL) {
addinfostatus = ARES_EBADRESP;
} else {
addinfostatus = ares__parse_into_addrinfo(dnsrec, ARES_TRUE,
hquery->port, hquery->ai);
addinfostatus =
ares__parse_into_addrinfo(dnsrec, ARES_TRUE, hquery->port, hquery->ai);
}
if (addinfostatus == ARES_SUCCESS) {
terminate_retries(hquery, ares_dns_record_get_id(dnsrec));
@ -530,8 +530,7 @@ static void host_callback(void *arg, ares_status_t status, size_t timeouts,
if (status == ARES_ENODATA || addinfostatus == ARES_ENODATA) {
hquery->nodata_cnt++;
}
next_lookup(hquery,
hquery->nodata_cnt ? ARES_ENODATA : status);
next_lookup(hquery, hquery->nodata_cnt ? ARES_ENODATA : status);
} else {
end_hquery(hquery, status);
}
@ -612,27 +611,28 @@ static void ares_getaddrinfo_int(ares_channel_t *channel, const char *name,
return;
}
hquery->port = port;
hquery->channel = channel;
hquery->hints = *hints;
hquery->sent_family = -1; /* nothing is sent yet */
hquery->callback = callback;
hquery->arg = arg;
hquery->ai = ai;
hquery->name = ares_strdup(name);
hquery->port = port;
hquery->channel = channel;
hquery->hints = *hints;
hquery->sent_family = -1; /* nothing is sent yet */
hquery->callback = callback;
hquery->arg = arg;
hquery->ai = ai;
hquery->name = ares_strdup(name);
if (hquery->name == NULL) {
hquery_free(hquery, ARES_TRUE);
callback(arg, ARES_ENOMEM, 0, NULL);
return;
}
status = ares__search_name_list(channel, name, &hquery->names, &hquery->names_cnt);
status =
ares__search_name_list(channel, name, &hquery->names, &hquery->names_cnt);
if (status != ARES_SUCCESS) {
hquery_free(hquery, ARES_TRUE);
callback(arg, (int)status, 0, NULL);
return;
}
hquery->next_name_idx = 0;
hquery->next_name_idx = 0;
hquery->lookups = ares_strdup(channel->lookups);
@ -662,7 +662,7 @@ void ares_getaddrinfo(ares_channel_t *channel, const char *name,
static ares_bool_t next_dns_lookup(struct host_query *hquery)
{
const char *name = NULL;
const char *name = NULL;
if (hquery->next_name_idx >= hquery->names_cnt) {
return ARES_FALSE;
@ -675,9 +675,8 @@ static ares_bool_t next_dns_lookup(struct host_query *hquery)
switch (hquery->hints.ai_family) {
case AF_INET:
hquery->remaining += 1;
ares_query_dnsrec(hquery->channel, name, ARES_CLASS_IN,
ARES_REC_TYPE_A, host_callback, hquery,
&hquery->qid_a);
ares_query_dnsrec(hquery->channel, name, ARES_CLASS_IN, ARES_REC_TYPE_A,
host_callback, hquery, &hquery->qid_a);
break;
case AF_INET6:
hquery->remaining += 1;
@ -687,9 +686,8 @@ static ares_bool_t next_dns_lookup(struct host_query *hquery)
break;
case AF_UNSPEC:
hquery->remaining += 2;
ares_query_dnsrec(hquery->channel, name, ARES_CLASS_IN,
ARES_REC_TYPE_A, host_callback, hquery,
&hquery->qid_a);
ares_query_dnsrec(hquery->channel, name, ARES_CLASS_IN, ARES_REC_TYPE_A,
host_callback, hquery, &hquery->qid_a);
ares_query_dnsrec(hquery->channel, name, ARES_CLASS_IN,
ARES_REC_TYPE_AAAA, host_callback, hquery,
&hquery->qid_aaaa);

@ -59,12 +59,11 @@ struct addr_query {
size_t timeouts;
};
static void next_lookup(struct addr_query *aquery);
static void addr_callback(void *arg, ares_status_t status,
size_t timeouts,
const ares_dns_record_t *dnsrec);
static void end_aquery(struct addr_query *aquery, ares_status_t status,
struct hostent *host);
static void next_lookup(struct addr_query *aquery);
static void addr_callback(void *arg, ares_status_t status, size_t timeouts,
const ares_dns_record_t *dnsrec);
static void end_aquery(struct addr_query *aquery, ares_status_t status,
struct hostent *host);
static ares_status_t file_lookup(ares_channel_t *channel,
const struct ares_addr *addr,
struct hostent **host);

@ -72,7 +72,7 @@ static void default_free(void *p)
#endif
void *(*ares_malloc)(size_t size) = default_malloc;
void *(*ares_realloc)(void *ptr, size_t size) = default_realloc;
void (*ares_free)(void *ptr) = default_free;
void (*ares_free)(void *ptr) = default_free;
void *ares_malloc_zero(size_t size)
{
@ -114,7 +114,7 @@ int ares_library_init(int flags)
}
int ares_library_init_mem(int flags, void *(*amalloc)(size_t size),
void (*afree)(void *ptr),
void (*afree)(void *ptr),
void *(*arealloc)(void *ptr, size_t size))
{
if (amalloc) {

@ -58,8 +58,8 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
struct ares_addrinfo ai;
char *question_hostname = NULL;
ares_status_t status;
size_t req_naddrttls = 0;
ares_dns_record_t *dnsrec = NULL;
size_t req_naddrttls = 0;
ares_dns_record_t *dnsrec = NULL;
if (alen < 0) {
return ARES_EBADRESP;

@ -60,8 +60,8 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
struct ares_addrinfo ai;
char *question_hostname = NULL;
ares_status_t status;
size_t req_naddrttls = 0;
ares_dns_record_t *dnsrec = NULL;
size_t req_naddrttls = 0;
ares_dns_record_t *dnsrec = NULL;
if (alen < 0) {
return ARES_EBADRESP;

@ -38,16 +38,15 @@
ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec,
const void *addr, int addrlen,
int family,
struct hostent **host)
int family, struct hostent **host)
{
ares_status_t status;
size_t ptrcount = 0;
struct hostent *hostent = NULL;
const char *hostname = NULL;
const char *ptrname = NULL;
size_t i;
size_t ancount;
ares_status_t status;
size_t ptrcount = 0;
struct hostent *hostent = NULL;
const char *hostname = NULL;
const char *ptrname = NULL;
size_t i;
size_t ancount;
*host = NULL;
@ -186,13 +185,12 @@ done:
return status;
}
int ares_parse_ptr_reply(const unsigned char *abuf, int alen_int,
const void *addr, int addrlen, int family,
struct hostent **host)
{
size_t alen;
ares_dns_record_t *dnsrec = NULL;
ares_dns_record_t *dnsrec = NULL;
ares_status_t status;
if (alen_int < 0) {

@ -318,12 +318,12 @@ struct ares_channeldata {
};
/* Does the domain end in ".onion" or ".onion."? Case-insensitive. */
ares_bool_t ares__is_onion_domain(const char *name);
ares_bool_t ares__is_onion_domain(const char *name);
/* Memory management functions */
extern void *(*ares_malloc)(size_t size);
extern void *(*ares_realloc)(void *ptr, size_t size);
extern void (*ares_free)(void *ptr);
extern void *(*ares_malloc)(size_t size);
extern void *(*ares_realloc)(void *ptr, size_t size);
extern void (*ares_free)(void *ptr);
void *ares_malloc_zero(size_t size);
void *ares_realloc_zero(void *ptr, size_t orig_size, size_t new_size);
@ -347,12 +347,12 @@ ares_status_t ares__requeue_query(struct query *query, struct timeval *now);
* \return ARES_SUCCESS on success, otherwise one of the other error codes.
*/
ares_status_t ares__search_name_list(const ares_channel_t *channel,
const char *name,
char ***names, size_t *names_len);
const char *name, char ***names,
size_t *names_len);
/*! Function to create callback arg for converting from ares_callback_dnsrec
* to ares_calback */
void *ares__dnsrec_convert_arg(ares_callback callback, void *arg);
void *ares__dnsrec_convert_arg(ares_callback callback, void *arg);
/*! Callback function used to convert from the ares_callback_dnsrec prototype to
* the ares_callback prototype, by writing the result and passing that to
@ -361,11 +361,11 @@ void *ares__dnsrec_convert_arg(ares_callback callback, void *arg);
void ares__dnsrec_convert_cb(void *arg, ares_status_t status, size_t timeouts,
const ares_dns_record_t *dnsrec);
void ares__close_connection(struct server_connection *conn);
void ares__close_sockets(struct server_state *server);
void ares__check_cleanup_conn(const ares_channel_t *channel,
struct server_connection *conn);
void ares__free_query(struct query *query);
void ares__close_connection(struct server_connection *conn);
void ares__close_sockets(struct server_state *server);
void ares__check_cleanup_conn(const ares_channel_t *channel,
struct server_connection *conn);
void ares__free_query(struct query *query);
ares_rand_state *ares__init_rand_state(void);
void ares__destroy_rand_state(ares_rand_state *state);
@ -453,8 +453,7 @@ ares_status_t ares__parse_into_addrinfo(const ares_dns_record_t *dnsrec,
struct ares_addrinfo *ai);
ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec,
const void *addr, int addrlen,
int family,
struct hostent **host);
int family, struct hostent **host);
ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family,
struct hostent **host);
@ -480,9 +479,9 @@ ares_ssize_t ares__socket_recvfrom(ares_channel_t *channel, ares_socket_t s,
ares_ssize_t ares__socket_recv(ares_channel_t *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_t *channel, ares_socket_t sockfd,
const struct sockaddr *addr, ares_socklen_t addrlen);
void ares__destroy_server(struct server_state *server);
int ares__connect_socket(ares_channel_t *channel, ares_socket_t sockfd,
const struct sockaddr *addr, ares_socklen_t addrlen);
void ares__destroy_server(struct server_state *server);
ares_status_t ares__servers_update(ares_channel_t *channel,
ares__llist_t *server_list,
@ -605,9 +604,9 @@ ares_status_t ares_qcache_insert(ares_channel_t *channel,
const struct timeval *now,
const struct query *query,
ares_dns_record_t *dnsrec);
ares_status_t ares_qcache_fetch(ares_channel_t *channel,
const struct timeval *now,
const ares_dns_record_t *dnsrec,
ares_status_t ares_qcache_fetch(ares_channel_t *channel,
const struct timeval *now,
const ares_dns_record_t *dnsrec,
const ares_dns_record_t **dnsrec_resp);
ares_status_t ares__channel_threading_init(ares_channel_t *channel);

@ -68,8 +68,7 @@ static ares_bool_t same_questions(const ares_dns_record_t *qrec,
static ares_bool_t same_address(const struct sockaddr *sa,
const struct ares_addr *aa);
static void end_query(ares_channel_t *channel, struct query *query,
ares_status_t status,
const ares_dns_record_t *dnsrec);
ares_status_t status, const ares_dns_record_t *dnsrec);
static void server_increment_failures(struct server_state *server)
{
@ -621,9 +620,9 @@ static ares_status_t process_answer(ares_channel_t *channel,
struct query *query;
/* Cache these as once ares__send_query() gets called, it may end up
* invalidating the connection all-together */
struct server_state *server = conn->server;
ares_dns_record_t *rdnsrec = NULL;
ares_dns_record_t *qdnsrec = NULL;
struct server_state *server = conn->server;
ares_dns_record_t *rdnsrec = NULL;
ares_dns_record_t *qdnsrec = NULL;
ares_status_t status;
ares_bool_t is_cached = ARES_FALSE;

@ -119,7 +119,7 @@ static char *ares__qcache_calc_key(const ares_dns_record_t *dnsrec)
* name lookup without performing a search. Strip this since its not part
* of a cached response. */
name_len = ares_strlen(name);
if (name_len && name[name_len-1] == '.') {
if (name_len && name[name_len - 1] == '.') {
name_len--;
}
@ -393,9 +393,9 @@ fail:
return ARES_ENOMEM;
}
ares_status_t ares_qcache_fetch(ares_channel_t *channel,
const struct timeval *now,
const ares_dns_record_t *dnsrec,
ares_status_t ares_qcache_fetch(ares_channel_t *channel,
const struct timeval *now,
const ares_dns_record_t *dnsrec,
const ares_dns_record_t **dnsrec_resp)
{
char *key = NULL;
@ -442,4 +442,3 @@ ares_status_t ares_qcache_insert(ares_channel_t *channel,
return ares__qcache_insert(channel->qcache, dnsrec, query->qbuf, query->qlen,
now);
}

@ -43,7 +43,7 @@ typedef struct {
} ares_query_dnsrec_arg_t;
static void ares_query_dnsrec_cb(void *arg, ares_status_t status,
size_t timeouts,
size_t timeouts,
const ares_dns_record_t *dnsrec)
{
ares_query_dnsrec_arg_t *qquery = arg;
@ -51,8 +51,8 @@ static void ares_query_dnsrec_cb(void *arg, ares_status_t status,
if (status != ARES_SUCCESS) {
qquery->callback(qquery->arg, status, timeouts, dnsrec);
} else {
size_t ancount;
ares_dns_rcode_t rcode;
size_t ancount;
ares_dns_rcode_t rcode;
/* Pull the response code and answer count from the packet and convert any
* errors.
*/
@ -67,8 +67,8 @@ static void ares_query_dnsrec_cb(void *arg, ares_status_t status,
static ares_status_t ares_query_int(ares_channel_t *channel, const char *name,
ares_dns_class_t dnsclass,
ares_dns_rec_type_t type,
ares_callback_dnsrec callback,
void *arg, unsigned short *qid)
ares_callback_dnsrec callback, void *arg,
unsigned short *qid)
{
ares_status_t status;
ares_dns_record_t *dnsrec = NULL;
@ -87,11 +87,9 @@ static ares_status_t ares_query_int(ares_channel_t *channel, const char *name,
flags |= ARES_FLAG_RD;
}
status = ares_dns_record_create_query(&dnsrec, name,
dnsclass,
type,
0, flags,
(size_t)(channel->flags & ARES_FLAG_EDNS)?channel->ednspsz : 0);
status = ares_dns_record_create_query(
&dnsrec, name, dnsclass, type, 0, flags,
(size_t)(channel->flags & ARES_FLAG_EDNS) ? channel->ednspsz : 0);
if (status != ARES_SUCCESS) {
callback(arg, status, 0, NULL);
return status;
@ -118,8 +116,8 @@ static ares_status_t ares_query_int(ares_channel_t *channel, const char *name,
ares_status_t ares_query_dnsrec(ares_channel_t *channel, const char *name,
ares_dns_class_t dnsclass,
ares_dns_rec_type_t type,
ares_callback_dnsrec callback,
void *arg, unsigned short *qid)
ares_callback_dnsrec callback, void *arg,
unsigned short *qid)
{
ares_status_t status;
@ -133,7 +131,6 @@ ares_status_t ares_query_dnsrec(ares_channel_t *channel, const char *name,
return status;
}
void ares_query(ares_channel_t *channel, const char *name, int dnsclass,
int type, ares_callback callback, void *arg)
{
@ -153,5 +150,3 @@ void ares_query(ares_channel_t *channel, const char *name, int dnsclass,
(ares_dns_rec_type_t)type, ares__dnsrec_convert_cb, carg,
NULL);
}

@ -37,27 +37,28 @@
struct search_query {
/* Arguments passed to ares_search_dnsrec() */
ares_channel_t *channel;
ares_callback_dnsrec callback;
void *arg;
ares_channel_t *channel;
ares_callback_dnsrec callback;
void *arg;
/* Duplicate of DNS record passed to ares_search_dnsrec() */
ares_dns_record_t *dnsrec;
ares_dns_record_t *dnsrec;
/* Search order for names */
char **names;
size_t names_cnt;
char **names;
size_t names_cnt;
/* State tracking progress through the search query */
size_t next_name_idx; /* next name index being attempted */
size_t timeouts; /* number of timeouts we saw for this request */
ares_bool_t ever_got_nodata; /* did we ever get ARES_ENODATA along the way? */
size_t next_name_idx; /* next name index being attempted */
size_t timeouts; /* number of timeouts we saw for this request */
ares_bool_t ever_got_nodata; /* did we ever get ARES_ENODATA along the way? */
};
static void squery_free(struct search_query *squery)
{
if (squery == NULL)
if (squery == NULL) {
return;
}
ares__strsplit_free(squery->names, squery->names_cnt);
ares_dns_record_destroy(squery->dnsrec);
ares_free(squery);
@ -76,9 +77,9 @@ static void end_squery(struct search_query *squery, ares_status_t status,
static void search_callback(void *arg, ares_status_t status, size_t timeouts,
const ares_dns_record_t *dnsrec);
static ares_status_t ares_search_next(ares_channel_t *channel,
static ares_status_t ares_search_next(ares_channel_t *channel,
struct search_query *squery,
ares_bool_t *skip_cleanup)
ares_bool_t *skip_cleanup)
{
ares_status_t status;
@ -89,15 +90,14 @@ static ares_status_t ares_search_next(ares_channel_t *channel,
return ARES_EFORMERR;
}
status =
ares_dns_record_query_set_name(squery->dnsrec, 0,
squery->names[squery->next_name_idx++]);
status = ares_dns_record_query_set_name(
squery->dnsrec, 0, squery->names[squery->next_name_idx++]);
if (status != ARES_SUCCESS) {
return status;
}
status = ares_send_dnsrec(channel, squery->dnsrec, search_callback, squery,
NULL);
status =
ares_send_dnsrec(channel, squery->dnsrec, search_callback, squery, NULL);
if (status != ARES_EFORMERR) {
*skip_cleanup = ARES_TRUE;
@ -164,12 +164,12 @@ static void search_callback(void *arg, ares_status_t status, size_t timeouts,
/* Determine if the domain should be looked up as-is, or if it is eligible
* for search by appending domains */
static ares_bool_t ares__search_eligible(const ares_channel_t *channel,
const char *name)
const char *name)
{
size_t len = ares_strlen(name);
size_t len = ares_strlen(name);
/* Name ends in '.', cannot search */
if (len && name[len-1] == '.') {
if (len && name[len - 1] == '.') {
return ARES_FALSE;
}
@ -180,10 +180,9 @@ static ares_bool_t ares__search_eligible(const ares_channel_t *channel,
return ARES_TRUE;
}
ares_status_t ares__search_name_list(const ares_channel_t *channel,
const char *name,
char ***names, size_t *names_len)
const char *name, char ***names,
size_t *names_len)
{
ares_status_t status;
char **list = NULL;
@ -204,8 +203,8 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel,
status = ARES_ENOMEM;
goto done;
}
list[0] = alias;
alias = NULL;
list[0] = alias;
alias = NULL;
goto done;
} else if (status != ARES_ENOTFOUND) {
goto done;
@ -219,7 +218,7 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel,
status = ARES_ENOMEM;
goto done;
}
list[0] = ares_strdup(name);
list[0] = ares_strdup(name);
if (list[0] == NULL) {
status = ARES_ENOMEM;
} else {
@ -255,7 +254,7 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel,
}
/* Append each search suffix to the name */
for (i=0; i<channel->ndomains; i++) {
for (i = 0; i < channel->ndomains; i++) {
status = ares__cat_domain(name, channel->domains[i], &list[idx]);
if (status != ARES_SUCCESS) {
goto done;
@ -286,14 +285,14 @@ done:
return status;
}
static ares_status_t ares_search_int(ares_channel_t *channel,
static ares_status_t ares_search_int(ares_channel_t *channel,
const ares_dns_record_t *dnsrec,
ares_callback_dnsrec callback, void *arg)
{
struct search_query *squery = NULL;
struct search_query *squery = NULL;
const char *name;
ares_status_t status = ARES_SUCCESS;
ares_bool_t skip_cleanup = ARES_FALSE;
ares_status_t status = ARES_SUCCESS;
ares_bool_t skip_cleanup = ARES_FALSE;
/* Extract the name for the search. Note that searches are only supported for
* DNS records containing a single query.
@ -337,8 +336,8 @@ static ares_status_t ares_search_int(ares_channel_t *channel,
squery->timeouts = 0;
squery->ever_got_nodata = ARES_FALSE;
status = ares__search_name_list(channel, name, &squery->names,
&squery->names_cnt);
status =
ares__search_name_list(channel, name, &squery->names, &squery->names_cnt);
if (status != ARES_SUCCESS) {
goto fail;
}
@ -359,7 +358,7 @@ fail:
}
/* Callback argument structure passed to ares__dnsrec_convert_cb(). */
typedef struct {
typedef struct {
ares_callback callback;
void *arg;
} dnsrec_convert_arg_t;
@ -369,8 +368,9 @@ typedef struct {
void *ares__dnsrec_convert_arg(ares_callback callback, void *arg)
{
dnsrec_convert_arg_t *carg = ares_malloc_zero(sizeof(*carg));
if (carg == NULL)
if (carg == NULL) {
return NULL;
}
carg->callback = callback;
carg->arg = arg;
return carg;
@ -406,11 +406,11 @@ void ares__dnsrec_convert_cb(void *arg, ares_status_t status, size_t timeouts,
void ares_search(ares_channel_t *channel, const char *name, int dnsclass,
int type, ares_callback callback, void *arg)
{
ares_status_t status;
ares_dns_record_t *dnsrec = NULL;
size_t max_udp_size;
ares_dns_flags_t rd_flag;
void *carg = NULL;
ares_status_t status;
ares_dns_record_t *dnsrec = NULL;
size_t max_udp_size;
ares_dns_flags_t rd_flag;
void *carg = NULL;
if (channel == NULL || name == NULL) {
return;
}
@ -426,12 +426,11 @@ void ares_search(ares_channel_t *channel, const char *name, int dnsclass,
return;
}
rd_flag = !(channel->flags & ARES_FLAG_NORECURSE) ? ARES_FLAG_RD: 0;
rd_flag = !(channel->flags & ARES_FLAG_NORECURSE) ? ARES_FLAG_RD : 0;
max_udp_size = (channel->flags & ARES_FLAG_EDNS) ? channel->ednspsz : 0;
status = ares_dns_record_create_query(&dnsrec, name,
(ares_dns_class_t)dnsclass,
(ares_dns_rec_type_t)type,
0, rd_flag, max_udp_size);
status = ares_dns_record_create_query(
&dnsrec, name, (ares_dns_class_t)dnsclass, (ares_dns_rec_type_t)type, 0,
rd_flag, max_udp_size);
if (status != ARES_SUCCESS) {
callback(arg, (int)status, 0, NULL, 0);
ares_free(carg);
@ -446,11 +445,11 @@ void ares_search(ares_channel_t *channel, const char *name, int dnsclass,
}
/* Search for a DNS record. Wrapper around ares_search_int(). */
ares_status_t ares_search_dnsrec(ares_channel_t *channel,
ares_status_t ares_search_dnsrec(ares_channel_t *channel,
const ares_dns_record_t *dnsrec,
ares_callback_dnsrec callback, void *arg)
{
ares_status_t status;
ares_status_t status;
if (channel == NULL || dnsrec == NULL || callback == NULL) {
return ARES_EFORMERR;
@ -463,7 +462,6 @@ ares_status_t ares_search_dnsrec(ares_channel_t *channel,
return status;
}
/* Concatenate two domains. */
ares_status_t ares__cat_domain(const char *name, const char *domain, char **s)
{

@ -48,14 +48,14 @@ static unsigned short generate_unique_qid(ares_channel_t *channel)
return id;
}
static ares_status_t ares_send_dnsrec_int(ares_channel_t *channel,
static ares_status_t ares_send_dnsrec_int(ares_channel_t *channel,
const ares_dns_record_t *dnsrec,
ares_callback_dnsrec callback,
ares_callback_dnsrec callback,
void *arg, unsigned short *qid)
{
struct query *query;
size_t packetsz;
struct timeval now = ares__tvnow();
struct timeval now = ares__tvnow();
ares_status_t status;
unsigned short id = generate_unique_qid(channel);
const ares_dns_record_t *dnsrec_resp = NULL;
@ -107,7 +107,8 @@ static ares_status_t ares_send_dnsrec_int(ares_channel_t *channel,
query->try_count = 0;
packetsz = (channel->flags & ARES_FLAG_EDNS) ? channel->ednspsz : PACKETSZ;
query->using_tcp = (channel->flags & ARES_FLAG_USEVC) || query->qlen > packetsz;
query->using_tcp =
(channel->flags & ARES_FLAG_USEVC) || query->qlen > packetsz;
query->error_status = ARES_SUCCESS;
query->timeouts = 0;
@ -143,11 +144,10 @@ static ares_status_t ares_send_dnsrec_int(ares_channel_t *channel,
return status;
}
ares_status_t ares_send_dnsrec(ares_channel_t *channel,
ares_status_t ares_send_dnsrec(ares_channel_t *channel,
const ares_dns_record_t *dnsrec,
ares_callback_dnsrec callback,
void *arg, unsigned short *qid)
ares_callback_dnsrec callback, void *arg,
unsigned short *qid)
{
ares_status_t status;
@ -164,13 +164,12 @@ ares_status_t ares_send_dnsrec(ares_channel_t *channel,
return status;
}
void ares_send(ares_channel_t *channel, const unsigned char *qbuf, int qlen,
ares_callback callback, void *arg)
{
ares_dns_record_t *dnsrec = NULL;
ares_status_t status;
void *carg = NULL;
ares_dns_record_t *dnsrec = NULL;
ares_status_t status;
void *carg = NULL;
if (channel == NULL) {
return;

@ -266,8 +266,8 @@ static ares_status_t parse_nameserver(ares__buf_t *buf, ares_sconfig_t *sconfig)
} else {
/* IPv6 */
const unsigned char ipv6_charset[] = "ABCDEFabcdef0123456789.:";
if (ares__buf_consume_charset(buf, ipv6_charset, sizeof(ipv6_charset)-1)
== 0) {
if (ares__buf_consume_charset(buf, ipv6_charset,
sizeof(ipv6_charset) - 1) == 0) {
return ARES_EBADSTR;
}
}
@ -318,8 +318,8 @@ static ares_status_t parse_nameserver(ares__buf_t *buf, ares_sconfig_t *sconfig)
ares__buf_tag(buf);
if (ares__buf_consume_charset(buf, iface_charset, sizeof(iface_charset)-1)
== 0) {
if (ares__buf_consume_charset(buf, iface_charset,
sizeof(iface_charset) - 1) == 0) {
return ARES_EBADSTR;
}

Loading…
Cancel
Save