11cb0ef41Sopenharmony_ci/* MIT License
21cb0ef41Sopenharmony_ci *
31cb0ef41Sopenharmony_ci * Copyright (c) 1998 Massachusetts Institute of Technology
41cb0ef41Sopenharmony_ci * Copyright (c) 2010 Daniel Stenberg
51cb0ef41Sopenharmony_ci *
61cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
71cb0ef41Sopenharmony_ci * of this software and associated documentation files (the "Software"), to deal
81cb0ef41Sopenharmony_ci * in the Software without restriction, including without limitation the rights
91cb0ef41Sopenharmony_ci * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
101cb0ef41Sopenharmony_ci * copies of the Software, and to permit persons to whom the Software is
111cb0ef41Sopenharmony_ci * furnished to do so, subject to the following conditions:
121cb0ef41Sopenharmony_ci *
131cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice (including the next
141cb0ef41Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
151cb0ef41Sopenharmony_ci * Software.
161cb0ef41Sopenharmony_ci *
171cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
181cb0ef41Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
191cb0ef41Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
201cb0ef41Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
211cb0ef41Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
221cb0ef41Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
231cb0ef41Sopenharmony_ci * SOFTWARE.
241cb0ef41Sopenharmony_ci *
251cb0ef41Sopenharmony_ci * SPDX-License-Identifier: MIT
261cb0ef41Sopenharmony_ci */
271cb0ef41Sopenharmony_ci#ifndef __ARES_PRIVATE_H
281cb0ef41Sopenharmony_ci#define __ARES_PRIVATE_H
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci/*
311cb0ef41Sopenharmony_ci * Define WIN32 when build target is Win32 API
321cb0ef41Sopenharmony_ci */
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ci#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
351cb0ef41Sopenharmony_ci#  define WIN32
361cb0ef41Sopenharmony_ci#endif
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ci#ifdef HAVE_NETINET_IN_H
391cb0ef41Sopenharmony_ci#  include <netinet/in.h>
401cb0ef41Sopenharmony_ci#endif
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci#ifdef WATT32
431cb0ef41Sopenharmony_ci#  include <tcp.h>
441cb0ef41Sopenharmony_ci#  include <sys/ioctl.h>
451cb0ef41Sopenharmony_ci#endif
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ci#define DEFAULT_TIMEOUT 2000 /* milliseconds */
481cb0ef41Sopenharmony_ci#define DEFAULT_TRIES   3
491cb0ef41Sopenharmony_ci#ifndef INADDR_NONE
501cb0ef41Sopenharmony_ci#  define INADDR_NONE 0xffffffff
511cb0ef41Sopenharmony_ci#endif
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ci/* By using a double cast, we can get rid of the bogus warning of
541cb0ef41Sopenharmony_ci * warning: cast from 'const struct sockaddr *' to 'const struct sockaddr_in6 *'
551cb0ef41Sopenharmony_ci * increases required alignment from 1 to 4 [-Wcast-align]
561cb0ef41Sopenharmony_ci */
571cb0ef41Sopenharmony_ci#define CARES_INADDR_CAST(type, var) ((type)((void *)var))
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_ci#if defined(WIN32) && !defined(WATT32)
601cb0ef41Sopenharmony_ci
611cb0ef41Sopenharmony_ci#  define WIN_NS_9X     "System\\CurrentControlSet\\Services\\VxD\\MSTCP"
621cb0ef41Sopenharmony_ci#  define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters"
631cb0ef41Sopenharmony_ci#  define WIN_DNSCLIENT "Software\\Policies\\Microsoft\\System\\DNSClient"
641cb0ef41Sopenharmony_ci#  define WIN_NT_DNSCLIENT \
651cb0ef41Sopenharmony_ci    "Software\\Policies\\Microsoft\\Windows NT\\DNSClient"
661cb0ef41Sopenharmony_ci#  define NAMESERVER           "NameServer"
671cb0ef41Sopenharmony_ci#  define DHCPNAMESERVER       "DhcpNameServer"
681cb0ef41Sopenharmony_ci#  define DATABASEPATH         "DatabasePath"
691cb0ef41Sopenharmony_ci#  define WIN_PATH_HOSTS       "\\hosts"
701cb0ef41Sopenharmony_ci#  define SEARCHLIST_KEY       "SearchList"
711cb0ef41Sopenharmony_ci#  define PRIMARYDNSSUFFIX_KEY "PrimaryDNSSuffix"
721cb0ef41Sopenharmony_ci#  define INTERFACES_KEY       "Interfaces"
731cb0ef41Sopenharmony_ci#  define DOMAIN_KEY           "Domain"
741cb0ef41Sopenharmony_ci#  define DHCPDOMAIN_KEY       "DhcpDomain"
751cb0ef41Sopenharmony_ci#  define PATH_RESOLV_CONF     ""
761cb0ef41Sopenharmony_ci#elif defined(WATT32)
771cb0ef41Sopenharmony_ci
781cb0ef41Sopenharmony_ci#  define PATH_RESOLV_CONF "/dev/ENV/etc/resolv.conf"
791cb0ef41Sopenharmony_ciW32_FUNC const char *_w32_GetHostsFile(void);
801cb0ef41Sopenharmony_ci
811cb0ef41Sopenharmony_ci#elif defined(NETWARE)
821cb0ef41Sopenharmony_ci
831cb0ef41Sopenharmony_ci#  define PATH_RESOLV_CONF "sys:/etc/resolv.cfg"
841cb0ef41Sopenharmony_ci#  define PATH_HOSTS       "sys:/etc/hosts"
851cb0ef41Sopenharmony_ci
861cb0ef41Sopenharmony_ci#elif defined(__riscos__)
871cb0ef41Sopenharmony_ci
881cb0ef41Sopenharmony_ci#  define PATH_RESOLV_CONF ""
891cb0ef41Sopenharmony_ci#  define PATH_HOSTS       "InetDBase:Hosts"
901cb0ef41Sopenharmony_ci
911cb0ef41Sopenharmony_ci#elif defined(__HAIKU__)
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ci#  define PATH_RESOLV_CONF "/system/settings/network/resolv.conf"
941cb0ef41Sopenharmony_ci#  define PATH_HOSTS       "/system/settings/network/hosts"
951cb0ef41Sopenharmony_ci
961cb0ef41Sopenharmony_ci#else
971cb0ef41Sopenharmony_ci
981cb0ef41Sopenharmony_ci#  define PATH_RESOLV_CONF "/etc/resolv.conf"
991cb0ef41Sopenharmony_ci#  ifdef ETC_INET
1001cb0ef41Sopenharmony_ci#    define PATH_HOSTS "/etc/inet/hosts"
1011cb0ef41Sopenharmony_ci#  else
1021cb0ef41Sopenharmony_ci#    define PATH_HOSTS "/etc/hosts"
1031cb0ef41Sopenharmony_ci#  endif
1041cb0ef41Sopenharmony_ci
1051cb0ef41Sopenharmony_ci#endif
1061cb0ef41Sopenharmony_ci
1071cb0ef41Sopenharmony_ci#include "ares_ipv6.h"
1081cb0ef41Sopenharmony_ci
1091cb0ef41Sopenharmony_cistruct ares_rand_state;
1101cb0ef41Sopenharmony_citypedef struct ares_rand_state ares_rand_state;
1111cb0ef41Sopenharmony_ci
1121cb0ef41Sopenharmony_ci#include "ares__llist.h"
1131cb0ef41Sopenharmony_ci#include "ares__slist.h"
1141cb0ef41Sopenharmony_ci#include "ares__htable_strvp.h"
1151cb0ef41Sopenharmony_ci#include "ares__htable_szvp.h"
1161cb0ef41Sopenharmony_ci#include "ares__htable_asvp.h"
1171cb0ef41Sopenharmony_ci#include "ares__buf.h"
1181cb0ef41Sopenharmony_ci#include "ares_dns_private.h"
1191cb0ef41Sopenharmony_ci#include "ares__iface_ips.h"
1201cb0ef41Sopenharmony_ci#include "ares__threads.h"
1211cb0ef41Sopenharmony_ci
1221cb0ef41Sopenharmony_ci#ifndef HAVE_GETENV
1231cb0ef41Sopenharmony_ci#  include "ares_getenv.h"
1241cb0ef41Sopenharmony_ci#  define getenv(ptr) ares_getenv(ptr)
1251cb0ef41Sopenharmony_ci#endif
1261cb0ef41Sopenharmony_ci
1271cb0ef41Sopenharmony_ci#include "ares_str.h"
1281cb0ef41Sopenharmony_ci#include "ares_strsplit.h"
1291cb0ef41Sopenharmony_ci
1301cb0ef41Sopenharmony_ci#ifndef HAVE_STRCASECMP
1311cb0ef41Sopenharmony_ci#  include "ares_strcasecmp.h"
1321cb0ef41Sopenharmony_ci#  define strcasecmp(p1, p2) ares_strcasecmp(p1, p2)
1331cb0ef41Sopenharmony_ci#endif
1341cb0ef41Sopenharmony_ci
1351cb0ef41Sopenharmony_ci#ifndef HAVE_STRNCASECMP
1361cb0ef41Sopenharmony_ci#  include "ares_strcasecmp.h"
1371cb0ef41Sopenharmony_ci#  define strncasecmp(p1, p2, n) ares_strncasecmp(p1, p2, n)
1381cb0ef41Sopenharmony_ci#endif
1391cb0ef41Sopenharmony_ci
1401cb0ef41Sopenharmony_ci/********* EDNS defines section ******/
1411cb0ef41Sopenharmony_ci#define EDNSPACKETSZ                                          \
1421cb0ef41Sopenharmony_ci  1232 /* Reasonable UDP payload size, as agreed by operators \
1431cb0ef41Sopenharmony_ci          https://www.dnsflagday.net/2020/#faq */
1441cb0ef41Sopenharmony_ci#define MAXENDSSZ   4096 /* Maximum (local) limit for edns packet size */
1451cb0ef41Sopenharmony_ci#define EDNSFIXEDSZ 11   /* Size of EDNS header */
1461cb0ef41Sopenharmony_ci
1471cb0ef41Sopenharmony_ci/********* EDNS defines section ******/
1481cb0ef41Sopenharmony_ci
1491cb0ef41Sopenharmony_ci
1501cb0ef41Sopenharmony_cistruct query;
1511cb0ef41Sopenharmony_ci
1521cb0ef41Sopenharmony_cistruct server_state;
1531cb0ef41Sopenharmony_ci
1541cb0ef41Sopenharmony_cistruct server_connection {
1551cb0ef41Sopenharmony_ci  struct server_state *server;
1561cb0ef41Sopenharmony_ci  ares_socket_t        fd;
1571cb0ef41Sopenharmony_ci  ares_bool_t          is_tcp;
1581cb0ef41Sopenharmony_ci  /* total number of queries run on this connection since it was established */
1591cb0ef41Sopenharmony_ci  size_t               total_queries;
1601cb0ef41Sopenharmony_ci  /* list of outstanding queries to this connection */
1611cb0ef41Sopenharmony_ci  ares__llist_t       *queries_to_conn;
1621cb0ef41Sopenharmony_ci};
1631cb0ef41Sopenharmony_ci
1641cb0ef41Sopenharmony_cistruct server_state {
1651cb0ef41Sopenharmony_ci  /* Configuration */
1661cb0ef41Sopenharmony_ci  size_t                    idx; /* index for server in system configuration */
1671cb0ef41Sopenharmony_ci  struct ares_addr          addr;
1681cb0ef41Sopenharmony_ci  unsigned short            udp_port;        /* host byte order */
1691cb0ef41Sopenharmony_ci  unsigned short            tcp_port;        /* host byte order */
1701cb0ef41Sopenharmony_ci  char                      ll_iface[64];    /* IPv6 Link Local Interface */
1711cb0ef41Sopenharmony_ci  unsigned int              ll_scope;        /* IPv6 Link Local Scope */
1721cb0ef41Sopenharmony_ci
1731cb0ef41Sopenharmony_ci  size_t                    consec_failures; /* Consecutive query failure count
1741cb0ef41Sopenharmony_ci                                              * can be hard errors or timeouts
1751cb0ef41Sopenharmony_ci                                              */
1761cb0ef41Sopenharmony_ci  ares__llist_t            *connections;
1771cb0ef41Sopenharmony_ci  struct server_connection *tcp_conn;
1781cb0ef41Sopenharmony_ci
1791cb0ef41Sopenharmony_ci  /* TCP buffer since multiple responses can come back in one read, or partial
1801cb0ef41Sopenharmony_ci   * in a read */
1811cb0ef41Sopenharmony_ci  ares__buf_t              *tcp_parser;
1821cb0ef41Sopenharmony_ci
1831cb0ef41Sopenharmony_ci  /* TCP output queue */
1841cb0ef41Sopenharmony_ci  ares__buf_t              *tcp_send;
1851cb0ef41Sopenharmony_ci
1861cb0ef41Sopenharmony_ci  /* Link back to owning channel */
1871cb0ef41Sopenharmony_ci  ares_channel_t           *channel;
1881cb0ef41Sopenharmony_ci};
1891cb0ef41Sopenharmony_ci
1901cb0ef41Sopenharmony_ci/* State to represent a DNS query */
1911cb0ef41Sopenharmony_cistruct query {
1921cb0ef41Sopenharmony_ci  /* Query ID from qbuf, for faster lookup, and current timeout */
1931cb0ef41Sopenharmony_ci  unsigned short            qid; /* host byte order */
1941cb0ef41Sopenharmony_ci  struct timeval            timeout;
1951cb0ef41Sopenharmony_ci  ares_channel_t           *channel;
1961cb0ef41Sopenharmony_ci
1971cb0ef41Sopenharmony_ci  /*
1981cb0ef41Sopenharmony_ci   * Node object for each list entry the query belongs to in order to
1991cb0ef41Sopenharmony_ci   * make removal operations O(1).
2001cb0ef41Sopenharmony_ci   */
2011cb0ef41Sopenharmony_ci  ares__slist_node_t       *node_queries_by_timeout;
2021cb0ef41Sopenharmony_ci  ares__llist_node_t       *node_queries_to_conn;
2031cb0ef41Sopenharmony_ci  ares__llist_node_t       *node_all_queries;
2041cb0ef41Sopenharmony_ci
2051cb0ef41Sopenharmony_ci  /* connection handle query is associated with */
2061cb0ef41Sopenharmony_ci  struct server_connection *conn;
2071cb0ef41Sopenharmony_ci
2081cb0ef41Sopenharmony_ci  /* Arguments passed to ares_send() */
2091cb0ef41Sopenharmony_ci  unsigned char            *qbuf;
2101cb0ef41Sopenharmony_ci  size_t                    qlen;
2111cb0ef41Sopenharmony_ci
2121cb0ef41Sopenharmony_ci  ares_callback             callback;
2131cb0ef41Sopenharmony_ci  void                     *arg;
2141cb0ef41Sopenharmony_ci
2151cb0ef41Sopenharmony_ci  /* Query status */
2161cb0ef41Sopenharmony_ci  size_t        try_count; /* Number of times we tried this query already. */
2171cb0ef41Sopenharmony_ci  ares_bool_t   using_tcp;
2181cb0ef41Sopenharmony_ci  ares_status_t error_status;
2191cb0ef41Sopenharmony_ci  size_t        timeouts; /* number of timeouts we saw for this request */
2201cb0ef41Sopenharmony_ci  ares_bool_t no_retries; /* do not perform any additional retries, this is set
2211cb0ef41Sopenharmony_ci                           * when a query is to be canceled */
2221cb0ef41Sopenharmony_ci};
2231cb0ef41Sopenharmony_ci
2241cb0ef41Sopenharmony_cistruct apattern {
2251cb0ef41Sopenharmony_ci  struct ares_addr addr;
2261cb0ef41Sopenharmony_ci  unsigned char    mask;
2271cb0ef41Sopenharmony_ci};
2281cb0ef41Sopenharmony_ci
2291cb0ef41Sopenharmony_cistruct ares__qcache;
2301cb0ef41Sopenharmony_citypedef struct ares__qcache ares__qcache_t;
2311cb0ef41Sopenharmony_ci
2321cb0ef41Sopenharmony_cistruct ares_hosts_file;
2331cb0ef41Sopenharmony_citypedef struct ares_hosts_file ares_hosts_file_t;
2341cb0ef41Sopenharmony_ci
2351cb0ef41Sopenharmony_cistruct ares_channeldata {
2361cb0ef41Sopenharmony_ci  /* Configuration data */
2371cb0ef41Sopenharmony_ci  unsigned int          flags;
2381cb0ef41Sopenharmony_ci  size_t                timeout; /* in milliseconds */
2391cb0ef41Sopenharmony_ci  size_t                tries;
2401cb0ef41Sopenharmony_ci  size_t                ndots;
2411cb0ef41Sopenharmony_ci  size_t                maxtimeout;              /* in milliseconds */
2421cb0ef41Sopenharmony_ci  ares_bool_t           rotate;
2431cb0ef41Sopenharmony_ci  unsigned short        udp_port;                /* stored in network order */
2441cb0ef41Sopenharmony_ci  unsigned short        tcp_port;                /* stored in network order */
2451cb0ef41Sopenharmony_ci  int                   socket_send_buffer_size; /* setsockopt takes int */
2461cb0ef41Sopenharmony_ci  int                   socket_receive_buffer_size; /* setsockopt takes int */
2471cb0ef41Sopenharmony_ci  char                **domains;
2481cb0ef41Sopenharmony_ci  size_t                ndomains;
2491cb0ef41Sopenharmony_ci  struct apattern      *sortlist;
2501cb0ef41Sopenharmony_ci  size_t                nsort;
2511cb0ef41Sopenharmony_ci  char                 *lookups;
2521cb0ef41Sopenharmony_ci  size_t                ednspsz;
2531cb0ef41Sopenharmony_ci  unsigned int          qcache_max_ttl;
2541cb0ef41Sopenharmony_ci  ares_evsys_t          evsys;
2551cb0ef41Sopenharmony_ci  unsigned int          optmask;
2561cb0ef41Sopenharmony_ci
2571cb0ef41Sopenharmony_ci  /* For binding to local devices and/or IP addresses.  Leave
2581cb0ef41Sopenharmony_ci   * them null/zero for no binding.
2591cb0ef41Sopenharmony_ci   */
2601cb0ef41Sopenharmony_ci  char                  local_dev_name[32];
2611cb0ef41Sopenharmony_ci  unsigned int          local_ip4;
2621cb0ef41Sopenharmony_ci  unsigned char         local_ip6[16];
2631cb0ef41Sopenharmony_ci
2641cb0ef41Sopenharmony_ci  /* Thread safety lock */
2651cb0ef41Sopenharmony_ci  ares__thread_mutex_t *lock;
2661cb0ef41Sopenharmony_ci
2671cb0ef41Sopenharmony_ci  /* Conditional to wake waiters when queue is empty */
2681cb0ef41Sopenharmony_ci  ares__thread_cond_t  *cond_empty;
2691cb0ef41Sopenharmony_ci
2701cb0ef41Sopenharmony_ci  /* Server addresses and communications state. Sorted by least consecutive
2711cb0ef41Sopenharmony_ci   * failures, followed by the configuration order if failures are equal. */
2721cb0ef41Sopenharmony_ci  ares__slist_t        *servers;
2731cb0ef41Sopenharmony_ci
2741cb0ef41Sopenharmony_ci  /* random state to use when generating new ids and generating retry penalties
2751cb0ef41Sopenharmony_ci   */
2761cb0ef41Sopenharmony_ci  ares_rand_state      *rand_state;
2771cb0ef41Sopenharmony_ci
2781cb0ef41Sopenharmony_ci  /* All active queries in a single list */
2791cb0ef41Sopenharmony_ci  ares__llist_t        *all_queries;
2801cb0ef41Sopenharmony_ci  /* Queries bucketed by qid, for quickly dispatching DNS responses: */
2811cb0ef41Sopenharmony_ci  ares__htable_szvp_t  *queries_by_qid;
2821cb0ef41Sopenharmony_ci
2831cb0ef41Sopenharmony_ci  /* Queries bucketed by timeout, for quickly handling timeouts: */
2841cb0ef41Sopenharmony_ci  ares__slist_t        *queries_by_timeout;
2851cb0ef41Sopenharmony_ci
2861cb0ef41Sopenharmony_ci  /* Map linked list node member for connection to file descriptor.  We use
2871cb0ef41Sopenharmony_ci   * the node instead of the connection object itself so we can quickly look
2881cb0ef41Sopenharmony_ci   * up a connection and remove it if necessary (as otherwise we'd have to
2891cb0ef41Sopenharmony_ci   * scan all connections) */
2901cb0ef41Sopenharmony_ci  ares__htable_asvp_t  *connnode_by_socket;
2911cb0ef41Sopenharmony_ci
2921cb0ef41Sopenharmony_ci  ares_sock_state_cb    sock_state_cb;
2931cb0ef41Sopenharmony_ci  void                 *sock_state_cb_data;
2941cb0ef41Sopenharmony_ci
2951cb0ef41Sopenharmony_ci  ares_sock_create_callback           sock_create_cb;
2961cb0ef41Sopenharmony_ci  void                               *sock_create_cb_data;
2971cb0ef41Sopenharmony_ci
2981cb0ef41Sopenharmony_ci  ares_sock_config_callback           sock_config_cb;
2991cb0ef41Sopenharmony_ci  void                               *sock_config_cb_data;
3001cb0ef41Sopenharmony_ci
3011cb0ef41Sopenharmony_ci  const struct ares_socket_functions *sock_funcs;
3021cb0ef41Sopenharmony_ci  void                               *sock_func_cb_data;
3031cb0ef41Sopenharmony_ci
3041cb0ef41Sopenharmony_ci  /* Path for resolv.conf file, configurable via ares_options */
3051cb0ef41Sopenharmony_ci  char                               *resolvconf_path;
3061cb0ef41Sopenharmony_ci
3071cb0ef41Sopenharmony_ci  /* Path for hosts file, configurable via ares_options */
3081cb0ef41Sopenharmony_ci  char                               *hosts_path;
3091cb0ef41Sopenharmony_ci
3101cb0ef41Sopenharmony_ci  /* Maximum UDP queries per connection allowed */
3111cb0ef41Sopenharmony_ci  size_t                              udp_max_queries;
3121cb0ef41Sopenharmony_ci
3131cb0ef41Sopenharmony_ci  /* Cache of local hosts file */
3141cb0ef41Sopenharmony_ci  ares_hosts_file_t                  *hf;
3151cb0ef41Sopenharmony_ci
3161cb0ef41Sopenharmony_ci  /* Query Cache */
3171cb0ef41Sopenharmony_ci  ares__qcache_t                     *qcache;
3181cb0ef41Sopenharmony_ci};
3191cb0ef41Sopenharmony_ci
3201cb0ef41Sopenharmony_ci/* Does the domain end in ".onion" or ".onion."? Case-insensitive. */
3211cb0ef41Sopenharmony_ciares_bool_t   ares__is_onion_domain(const char *name);
3221cb0ef41Sopenharmony_ci
3231cb0ef41Sopenharmony_ci/* Memory management functions */
3241cb0ef41Sopenharmony_ciextern void  *(*ares_malloc)(size_t size);
3251cb0ef41Sopenharmony_ciextern void  *(*ares_realloc)(void *ptr, size_t size);
3261cb0ef41Sopenharmony_ciextern void   (*ares_free)(void *ptr);
3271cb0ef41Sopenharmony_civoid         *ares_malloc_zero(size_t size);
3281cb0ef41Sopenharmony_civoid         *ares_realloc_zero(void *ptr, size_t orig_size, size_t new_size);
3291cb0ef41Sopenharmony_ci
3301cb0ef41Sopenharmony_ci/* return true if now is exactly check time or later */
3311cb0ef41Sopenharmony_ciares_bool_t   ares__timedout(const struct timeval *now,
3321cb0ef41Sopenharmony_ci                             const struct timeval *check);
3331cb0ef41Sopenharmony_ci
3341cb0ef41Sopenharmony_ci/* Returns one of the normal ares status codes like ARES_SUCCESS */
3351cb0ef41Sopenharmony_ciares_status_t ares__send_query(struct query *query, struct timeval *now);
3361cb0ef41Sopenharmony_ciares_status_t ares__requeue_query(struct query *query, struct timeval *now);
3371cb0ef41Sopenharmony_ci
3381cb0ef41Sopenharmony_ci/* Identical to ares_query, but returns a normal ares return code like
3391cb0ef41Sopenharmony_ci * ARES_SUCCESS, and can be passed the qid by reference which will be
3401cb0ef41Sopenharmony_ci * filled in on ARES_SUCCESS */
3411cb0ef41Sopenharmony_ciares_status_t ares_query_qid(ares_channel_t *channel, const char *name,
3421cb0ef41Sopenharmony_ci                             int dnsclass, int type, ares_callback callback,
3431cb0ef41Sopenharmony_ci                             void *arg, unsigned short *qid);
3441cb0ef41Sopenharmony_ci/* Identical to ares_send() except returns normal ares return codes like
3451cb0ef41Sopenharmony_ci * ARES_SUCCESS */
3461cb0ef41Sopenharmony_ciares_status_t ares_send_ex(ares_channel_t *channel, const unsigned char *qbuf,
3471cb0ef41Sopenharmony_ci                           size_t qlen, ares_callback callback, void *arg,
3481cb0ef41Sopenharmony_ci                           unsigned short *qid);
3491cb0ef41Sopenharmony_civoid          ares__close_connection(struct server_connection *conn);
3501cb0ef41Sopenharmony_civoid          ares__close_sockets(struct server_state *server);
3511cb0ef41Sopenharmony_civoid          ares__check_cleanup_conn(const ares_channel_t     *channel,
3521cb0ef41Sopenharmony_ci                                       struct server_connection *conn);
3531cb0ef41Sopenharmony_ciares_status_t ares__read_line(FILE *fp, char **buf, size_t *bufsize);
3541cb0ef41Sopenharmony_civoid          ares__free_query(struct query *query);
3551cb0ef41Sopenharmony_ci
3561cb0ef41Sopenharmony_ciares_rand_state *ares__init_rand_state(void);
3571cb0ef41Sopenharmony_civoid             ares__destroy_rand_state(ares_rand_state *state);
3581cb0ef41Sopenharmony_civoid ares__rand_bytes(ares_rand_state *state, unsigned char *buf, size_t len);
3591cb0ef41Sopenharmony_ci
3601cb0ef41Sopenharmony_ciunsigned short ares__generate_new_id(ares_rand_state *state);
3611cb0ef41Sopenharmony_cistruct timeval ares__tvnow(void);
3621cb0ef41Sopenharmony_civoid           ares__timeval_remaining(struct timeval       *remaining,
3631cb0ef41Sopenharmony_ci                                       const struct timeval *now,
3641cb0ef41Sopenharmony_ci                                       const struct timeval *tout);
3651cb0ef41Sopenharmony_ciares_status_t  ares__expand_name_validated(const unsigned char *encoded,
3661cb0ef41Sopenharmony_ci                                           const unsigned char *abuf,
3671cb0ef41Sopenharmony_ci                                           size_t alen, char **s, size_t *enclen,
3681cb0ef41Sopenharmony_ci                                           ares_bool_t is_hostname);
3691cb0ef41Sopenharmony_ciares_status_t  ares__expand_name_for_response(const unsigned char *encoded,
3701cb0ef41Sopenharmony_ci                                              const unsigned char *abuf,
3711cb0ef41Sopenharmony_ci                                              size_t alen, char **s,
3721cb0ef41Sopenharmony_ci                                              size_t     *enclen,
3731cb0ef41Sopenharmony_ci                                              ares_bool_t is_hostname);
3741cb0ef41Sopenharmony_ciares_status_t  ares_expand_string_ex(const unsigned char *encoded,
3751cb0ef41Sopenharmony_ci                                     const unsigned char *abuf, size_t alen,
3761cb0ef41Sopenharmony_ci                                     unsigned char **s, size_t *enclen);
3771cb0ef41Sopenharmony_ciares_status_t  ares__init_servers_state(ares_channel_t *channel);
3781cb0ef41Sopenharmony_ciares_status_t  ares__init_by_options(ares_channel_t            *channel,
3791cb0ef41Sopenharmony_ci                                     const struct ares_options *options,
3801cb0ef41Sopenharmony_ci                                     int                        optmask);
3811cb0ef41Sopenharmony_ciares_status_t  ares__init_by_sysconfig(ares_channel_t *channel);
3821cb0ef41Sopenharmony_ci
3831cb0ef41Sopenharmony_citypedef struct {
3841cb0ef41Sopenharmony_ci  ares__llist_t   *sconfig;
3851cb0ef41Sopenharmony_ci  struct apattern *sortlist;
3861cb0ef41Sopenharmony_ci  size_t           nsortlist;
3871cb0ef41Sopenharmony_ci  char           **domains;
3881cb0ef41Sopenharmony_ci  size_t           ndomains;
3891cb0ef41Sopenharmony_ci  char            *lookups;
3901cb0ef41Sopenharmony_ci  size_t           ndots;
3911cb0ef41Sopenharmony_ci  size_t           tries;
3921cb0ef41Sopenharmony_ci  ares_bool_t      rotate;
3931cb0ef41Sopenharmony_ci  size_t           timeout_ms;
3941cb0ef41Sopenharmony_ci} ares_sysconfig_t;
3951cb0ef41Sopenharmony_ci
3961cb0ef41Sopenharmony_ciares_status_t ares__init_by_environment(ares_sysconfig_t *sysconfig);
3971cb0ef41Sopenharmony_ci
3981cb0ef41Sopenharmony_ciares_status_t ares__init_sysconfig_files(const ares_channel_t *channel,
3991cb0ef41Sopenharmony_ci                                         ares_sysconfig_t     *sysconfig);
4001cb0ef41Sopenharmony_ciares_status_t ares__parse_sortlist(struct apattern **sortlist, size_t *nsort,
4011cb0ef41Sopenharmony_ci                                   const char *str);
4021cb0ef41Sopenharmony_ci
4031cb0ef41Sopenharmony_civoid          ares__destroy_servers_state(ares_channel_t *channel);
4041cb0ef41Sopenharmony_ciares_status_t ares__single_domain(const ares_channel_t *channel,
4051cb0ef41Sopenharmony_ci                                  const char *name, char **s);
4061cb0ef41Sopenharmony_ciares_status_t ares__cat_domain(const char *name, const char *domain, char **s);
4071cb0ef41Sopenharmony_ciares_status_t ares__sortaddrinfo(ares_channel_t            *channel,
4081cb0ef41Sopenharmony_ci                                 struct ares_addrinfo_node *ai_node);
4091cb0ef41Sopenharmony_ci
4101cb0ef41Sopenharmony_civoid          ares__freeaddrinfo_nodes(struct ares_addrinfo_node *ai_node);
4111cb0ef41Sopenharmony_ciares_bool_t   ares__is_localhost(const char *name);
4121cb0ef41Sopenharmony_ci
4131cb0ef41Sopenharmony_cistruct ares_addrinfo_node    *
4141cb0ef41Sopenharmony_ci  ares__append_addrinfo_node(struct ares_addrinfo_node **ai_node);
4151cb0ef41Sopenharmony_civoid ares__addrinfo_cat_nodes(struct ares_addrinfo_node **head,
4161cb0ef41Sopenharmony_ci                              struct ares_addrinfo_node  *tail);
4171cb0ef41Sopenharmony_ci
4181cb0ef41Sopenharmony_civoid ares__freeaddrinfo_cnames(struct ares_addrinfo_cname *ai_cname);
4191cb0ef41Sopenharmony_ci
4201cb0ef41Sopenharmony_cistruct ares_addrinfo_cname *
4211cb0ef41Sopenharmony_ci  ares__append_addrinfo_cname(struct ares_addrinfo_cname **ai_cname);
4221cb0ef41Sopenharmony_ci
4231cb0ef41Sopenharmony_ciares_status_t ares_append_ai_node(int aftype, unsigned short port,
4241cb0ef41Sopenharmony_ci                                  unsigned int ttl, const void *adata,
4251cb0ef41Sopenharmony_ci                                  struct ares_addrinfo_node **nodes);
4261cb0ef41Sopenharmony_ci
4271cb0ef41Sopenharmony_civoid          ares__addrinfo_cat_cnames(struct ares_addrinfo_cname **head,
4281cb0ef41Sopenharmony_ci                                        struct ares_addrinfo_cname  *tail);
4291cb0ef41Sopenharmony_ci
4301cb0ef41Sopenharmony_ciares_status_t ares__parse_into_addrinfo(const unsigned char *abuf, size_t alen,
4311cb0ef41Sopenharmony_ci                                        ares_bool_t    cname_only_is_enodata,
4321cb0ef41Sopenharmony_ci                                        unsigned short port,
4331cb0ef41Sopenharmony_ci                                        struct ares_addrinfo *ai);
4341cb0ef41Sopenharmony_ci
4351cb0ef41Sopenharmony_ciares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family,
4361cb0ef41Sopenharmony_ci                                     struct hostent **host);
4371cb0ef41Sopenharmony_ciares_status_t ares__addrinfo2addrttl(const struct ares_addrinfo *ai, int family,
4381cb0ef41Sopenharmony_ci                                     size_t                req_naddrttls,
4391cb0ef41Sopenharmony_ci                                     struct ares_addrttl  *addrttls,
4401cb0ef41Sopenharmony_ci                                     struct ares_addr6ttl *addr6ttls,
4411cb0ef41Sopenharmony_ci                                     size_t               *naddrttls);
4421cb0ef41Sopenharmony_ciares_status_t ares__addrinfo_localhost(const char *name, unsigned short port,
4431cb0ef41Sopenharmony_ci                                       const struct ares_addrinfo_hints *hints,
4441cb0ef41Sopenharmony_ci                                       struct ares_addrinfo             *ai);
4451cb0ef41Sopenharmony_ciares_status_t ares__open_connection(ares_channel_t      *channel,
4461cb0ef41Sopenharmony_ci                                    struct server_state *server,
4471cb0ef41Sopenharmony_ci                                    ares_bool_t          is_tcp);
4481cb0ef41Sopenharmony_ciares_socket_t ares__open_socket(ares_channel_t *channel, int af, int type,
4491cb0ef41Sopenharmony_ci                                int protocol);
4501cb0ef41Sopenharmony_ciares_ssize_t  ares__socket_write(ares_channel_t *channel, ares_socket_t s,
4511cb0ef41Sopenharmony_ci                                 const void *data, size_t len);
4521cb0ef41Sopenharmony_ciares_ssize_t  ares__socket_recvfrom(ares_channel_t *channel, ares_socket_t s,
4531cb0ef41Sopenharmony_ci                                    void *data, size_t data_len, int flags,
4541cb0ef41Sopenharmony_ci                                    struct sockaddr *from,
4551cb0ef41Sopenharmony_ci                                    ares_socklen_t  *from_len);
4561cb0ef41Sopenharmony_ciares_ssize_t  ares__socket_recv(ares_channel_t *channel, ares_socket_t s,
4571cb0ef41Sopenharmony_ci                                void *data, size_t data_len);
4581cb0ef41Sopenharmony_civoid          ares__close_socket(ares_channel, ares_socket_t);
4591cb0ef41Sopenharmony_ciint         ares__connect_socket(ares_channel_t *channel, ares_socket_t sockfd,
4601cb0ef41Sopenharmony_ci                                 const struct sockaddr *addr, ares_socklen_t addrlen);
4611cb0ef41Sopenharmony_ciares_bool_t ares__is_hostnamech(int ch);
4621cb0ef41Sopenharmony_civoid        ares__destroy_server(struct server_state *server);
4631cb0ef41Sopenharmony_ci
4641cb0ef41Sopenharmony_ciares_status_t ares__servers_update(ares_channel_t *channel,
4651cb0ef41Sopenharmony_ci                                   ares__llist_t  *server_list,
4661cb0ef41Sopenharmony_ci                                   ares_bool_t     user_specified);
4671cb0ef41Sopenharmony_ciares_status_t ares__sconfig_append(ares__llist_t         **sconfig,
4681cb0ef41Sopenharmony_ci                                   const struct ares_addr *addr,
4691cb0ef41Sopenharmony_ci                                   unsigned short          udp_port,
4701cb0ef41Sopenharmony_ci                                   unsigned short          tcp_port,
4711cb0ef41Sopenharmony_ci                                   const char             *ll_iface);
4721cb0ef41Sopenharmony_ciares_status_t ares__sconfig_append_fromstr(ares__llist_t **sconfig,
4731cb0ef41Sopenharmony_ci                                           const char     *str,
4741cb0ef41Sopenharmony_ci                                           ares_bool_t     ignore_invalid);
4751cb0ef41Sopenharmony_ciares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers,
4761cb0ef41Sopenharmony_ci                                                  size_t          nservers,
4771cb0ef41Sopenharmony_ci                                                  ares__llist_t **llist);
4781cb0ef41Sopenharmony_ci
4791cb0ef41Sopenharmony_cistruct ares_hosts_entry;
4801cb0ef41Sopenharmony_citypedef struct ares_hosts_entry ares_hosts_entry_t;
4811cb0ef41Sopenharmony_ci
4821cb0ef41Sopenharmony_civoid                            ares__hosts_file_destroy(ares_hosts_file_t *hf);
4831cb0ef41Sopenharmony_ciares_status_t ares__hosts_search_ipaddr(ares_channel_t *channel,
4841cb0ef41Sopenharmony_ci                                        ares_bool_t use_env, const char *ipaddr,
4851cb0ef41Sopenharmony_ci                                        const ares_hosts_entry_t **entry);
4861cb0ef41Sopenharmony_ciares_status_t ares__hosts_search_host(ares_channel_t *channel,
4871cb0ef41Sopenharmony_ci                                      ares_bool_t use_env, const char *host,
4881cb0ef41Sopenharmony_ci                                      const ares_hosts_entry_t **entry);
4891cb0ef41Sopenharmony_ciares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry,
4901cb0ef41Sopenharmony_ci                                           int                       family,
4911cb0ef41Sopenharmony_ci                                           struct hostent          **hostent);
4921cb0ef41Sopenharmony_ciares_status_t ares__hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry,
4931cb0ef41Sopenharmony_ci                                            const char *name, int family,
4941cb0ef41Sopenharmony_ci                                            unsigned short        port,
4951cb0ef41Sopenharmony_ci                                            ares_bool_t           want_cnames,
4961cb0ef41Sopenharmony_ci                                            struct ares_addrinfo *ai);
4971cb0ef41Sopenharmony_ciares_bool_t   ares__isprint(int ch);
4981cb0ef41Sopenharmony_ci
4991cb0ef41Sopenharmony_ci
5001cb0ef41Sopenharmony_ci/*! Parse a compressed DNS name as defined in RFC1035 starting at the current
5011cb0ef41Sopenharmony_ci *  offset within the buffer.
5021cb0ef41Sopenharmony_ci *
5031cb0ef41Sopenharmony_ci *  It is assumed that either a const buffer is being used, or before
5041cb0ef41Sopenharmony_ci *  the message processing was started that ares__buf_reclaim() was called.
5051cb0ef41Sopenharmony_ci *
5061cb0ef41Sopenharmony_ci *  \param[in]  buf        Initialized buffer object
5071cb0ef41Sopenharmony_ci *  \param[out] name       Pointer passed by reference to be filled in with
5081cb0ef41Sopenharmony_ci *                         allocated string of the parsed name that must be
5091cb0ef41Sopenharmony_ci *                         ares_free()'d by the caller.
5101cb0ef41Sopenharmony_ci *  \param[in] is_hostname if ARES_TRUE, will validate the character set for
5111cb0ef41Sopenharmony_ci *                         a valid hostname or will return error.
5121cb0ef41Sopenharmony_ci *  \return ARES_SUCCESS on success
5131cb0ef41Sopenharmony_ci */
5141cb0ef41Sopenharmony_ciares_status_t ares__dns_name_parse(ares__buf_t *buf, char **name,
5151cb0ef41Sopenharmony_ci                                   ares_bool_t is_hostname);
5161cb0ef41Sopenharmony_ci
5171cb0ef41Sopenharmony_ci/*! Write the DNS name to the buffer in the DNS domain-name syntax as a
5181cb0ef41Sopenharmony_ci *  series of labels.  The maximum domain name length is 255 characters with
5191cb0ef41Sopenharmony_ci *  each label being a maximum of 63 characters.  If the validate_hostname
5201cb0ef41Sopenharmony_ci *  flag is set, it will strictly validate the character set.
5211cb0ef41Sopenharmony_ci *
5221cb0ef41Sopenharmony_ci *  \param[in,out]  buf   Initialized buffer object to write name to
5231cb0ef41Sopenharmony_ci *  \param[in,out]  list  Pointer passed by reference to maintain a list of
5241cb0ef41Sopenharmony_ci *                        domain name to indexes used for name compression.
5251cb0ef41Sopenharmony_ci *                        Pass NULL (not by reference) if name compression isn't
5261cb0ef41Sopenharmony_ci *                        desired.  Otherwise the list will be automatically
5271cb0ef41Sopenharmony_ci *                        created upon first entry.
5281cb0ef41Sopenharmony_ci *  \param[in]      validate_hostname Validate the hostname character set.
5291cb0ef41Sopenharmony_ci *  \param[in]      name              Name to write out, it may have escape
5301cb0ef41Sopenharmony_ci *                                    sequences.
5311cb0ef41Sopenharmony_ci *  \return ARES_SUCCESS on success, most likely ARES_EBADNAME if the name is
5321cb0ef41Sopenharmony_ci *          bad.
5331cb0ef41Sopenharmony_ci */
5341cb0ef41Sopenharmony_ciares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list,
5351cb0ef41Sopenharmony_ci                                   ares_bool_t validate_hostname,
5361cb0ef41Sopenharmony_ci                                   const char *name);
5371cb0ef41Sopenharmony_ci
5381cb0ef41Sopenharmony_ci/*! Check if the queue is empty, if so, wake any waiters.  This is only
5391cb0ef41Sopenharmony_ci *  effective if built with threading support.
5401cb0ef41Sopenharmony_ci *
5411cb0ef41Sopenharmony_ci *  Must be holding a channel lock when calling this function.
5421cb0ef41Sopenharmony_ci *
5431cb0ef41Sopenharmony_ci *  \param[in]  channel Initialized ares channel object
5441cb0ef41Sopenharmony_ci */
5451cb0ef41Sopenharmony_civoid          ares_queue_notify_empty(ares_channel_t *channel);
5461cb0ef41Sopenharmony_ci
5471cb0ef41Sopenharmony_ci
5481cb0ef41Sopenharmony_ci#define ARES_SWAP_BYTE(a, b)           \
5491cb0ef41Sopenharmony_ci  do {                                 \
5501cb0ef41Sopenharmony_ci    unsigned char swapByte = *(a);     \
5511cb0ef41Sopenharmony_ci    *(a)                   = *(b);     \
5521cb0ef41Sopenharmony_ci    *(b)                   = swapByte; \
5531cb0ef41Sopenharmony_ci  } while (0)
5541cb0ef41Sopenharmony_ci
5551cb0ef41Sopenharmony_ci#define SOCK_STATE_CALLBACK(c, s, r, w)                           \
5561cb0ef41Sopenharmony_ci  do {                                                            \
5571cb0ef41Sopenharmony_ci    if ((c)->sock_state_cb) {                                     \
5581cb0ef41Sopenharmony_ci      (c)->sock_state_cb((c)->sock_state_cb_data, (s), (r), (w)); \
5591cb0ef41Sopenharmony_ci    }                                                             \
5601cb0ef41Sopenharmony_ci  } while (0)
5611cb0ef41Sopenharmony_ci
5621cb0ef41Sopenharmony_ci#define ARES_CONFIG_CHECK(x)                                             \
5631cb0ef41Sopenharmony_ci  (x && x->lookups && ares__slist_len(x->servers) > 0 && x->ndots > 0 && \
5641cb0ef41Sopenharmony_ci   x->timeout > 0 && x->tries > 0)
5651cb0ef41Sopenharmony_ci
5661cb0ef41Sopenharmony_ciares_bool_t   ares__subnet_match(const struct ares_addr *addr,
5671cb0ef41Sopenharmony_ci                                 const struct ares_addr *subnet,
5681cb0ef41Sopenharmony_ci                                 unsigned char           netmask);
5691cb0ef41Sopenharmony_ciares_bool_t   ares__addr_is_linklocal(const struct ares_addr *addr);
5701cb0ef41Sopenharmony_ci
5711cb0ef41Sopenharmony_cisize_t        ares__round_up_pow2(size_t n);
5721cb0ef41Sopenharmony_cisize_t        ares__log2(size_t n);
5731cb0ef41Sopenharmony_cisize_t        ares__pow(size_t x, size_t y);
5741cb0ef41Sopenharmony_cisize_t        ares__count_digits(size_t n);
5751cb0ef41Sopenharmony_cisize_t        ares__count_hexdigits(size_t n);
5761cb0ef41Sopenharmony_ciunsigned char ares__count_bits_u8(unsigned char x);
5771cb0ef41Sopenharmony_civoid          ares__qcache_destroy(ares__qcache_t *cache);
5781cb0ef41Sopenharmony_ciares_status_t ares__qcache_create(ares_rand_state *rand_state,
5791cb0ef41Sopenharmony_ci                                  unsigned int     max_ttl,
5801cb0ef41Sopenharmony_ci                                  ares__qcache_t **cache_out);
5811cb0ef41Sopenharmony_civoid          ares__qcache_flush(ares__qcache_t *cache);
5821cb0ef41Sopenharmony_ciares_status_t ares_qcache_insert(ares_channel_t       *channel,
5831cb0ef41Sopenharmony_ci                                 const struct timeval *now,
5841cb0ef41Sopenharmony_ci                                 const struct query   *query,
5851cb0ef41Sopenharmony_ci                                 ares_dns_record_t    *dnsrec);
5861cb0ef41Sopenharmony_ciares_status_t ares_qcache_fetch(ares_channel_t       *channel,
5871cb0ef41Sopenharmony_ci                                const struct timeval *now,
5881cb0ef41Sopenharmony_ci                                const unsigned char *qbuf, size_t qlen,
5891cb0ef41Sopenharmony_ci                                unsigned char **abuf, size_t *alen);
5901cb0ef41Sopenharmony_ci
5911cb0ef41Sopenharmony_ciares_status_t ares__channel_threading_init(ares_channel_t *channel);
5921cb0ef41Sopenharmony_civoid          ares__channel_threading_destroy(ares_channel_t *channel);
5931cb0ef41Sopenharmony_civoid          ares__channel_lock(ares_channel_t *channel);
5941cb0ef41Sopenharmony_civoid          ares__channel_unlock(ares_channel_t *channel);
5951cb0ef41Sopenharmony_ci
5961cb0ef41Sopenharmony_cistruct ares_event_thread;
5971cb0ef41Sopenharmony_citypedef struct ares_event_thread ares_event_thread_t;
5981cb0ef41Sopenharmony_ci
5991cb0ef41Sopenharmony_civoid          ares_event_thread_destroy(ares_channel_t *channel);
6001cb0ef41Sopenharmony_ciares_status_t ares_event_thread_init(ares_channel_t *channel);
6011cb0ef41Sopenharmony_ci
6021cb0ef41Sopenharmony_ci
6031cb0ef41Sopenharmony_ci#ifdef _MSC_VER
6041cb0ef41Sopenharmony_citypedef __int64          ares_int64_t;
6051cb0ef41Sopenharmony_citypedef unsigned __int64 ares_uint64_t;
6061cb0ef41Sopenharmony_ci#else
6071cb0ef41Sopenharmony_citypedef long long          ares_int64_t;
6081cb0ef41Sopenharmony_citypedef unsigned long long ares_uint64_t;
6091cb0ef41Sopenharmony_ci#endif
6101cb0ef41Sopenharmony_ci
6111cb0ef41Sopenharmony_ci#ifdef _WIN32
6121cb0ef41Sopenharmony_ci#  define HOSTENT_ADDRTYPE_TYPE short
6131cb0ef41Sopenharmony_ci#  define HOSTENT_LENGTH_TYPE   short
6141cb0ef41Sopenharmony_ci#else
6151cb0ef41Sopenharmony_ci#  define HOSTENT_ADDRTYPE_TYPE int
6161cb0ef41Sopenharmony_ci#  define HOSTENT_LENGTH_TYPE   int
6171cb0ef41Sopenharmony_ci#endif
6181cb0ef41Sopenharmony_ci
6191cb0ef41Sopenharmony_ci#endif /* __ARES_PRIVATE_H */
620