1324c9471Sopenharmony_ci
2324c9471Sopenharmony_ci/* Copyright 1998 by the Massachusetts Institute of Technology.
3324c9471Sopenharmony_ci * Copyright (C) 2007-2013 by Daniel Stenberg
4324c9471Sopenharmony_ci *
5324c9471Sopenharmony_ci * Permission to use, copy, modify, and distribute this
6324c9471Sopenharmony_ci * software and its documentation for any purpose and without
7324c9471Sopenharmony_ci * fee is hereby granted, provided that the above copyright
8324c9471Sopenharmony_ci * notice appear in all copies and that both that copyright
9324c9471Sopenharmony_ci * notice and this permission notice appear in supporting
10324c9471Sopenharmony_ci * documentation, and that the name of M.I.T. not be used in
11324c9471Sopenharmony_ci * advertising or publicity pertaining to distribution of the
12324c9471Sopenharmony_ci * software without specific, written prior permission.
13324c9471Sopenharmony_ci * M.I.T. makes no representations about the suitability of
14324c9471Sopenharmony_ci * this software for any purpose.  It is provided "as is"
15324c9471Sopenharmony_ci * without express or implied warranty.
16324c9471Sopenharmony_ci */
17324c9471Sopenharmony_ci
18324c9471Sopenharmony_ci#ifndef ARES__H
19324c9471Sopenharmony_ci#define ARES__H
20324c9471Sopenharmony_ci
21324c9471Sopenharmony_ci#include "ares_version.h"  /* c-ares version defines   */
22324c9471Sopenharmony_ci#include "ares_build.h"    /* c-ares build definitions */
23324c9471Sopenharmony_ci#include "ares_rules.h"    /* c-ares rules enforcement */
24324c9471Sopenharmony_ci
25324c9471Sopenharmony_ci/*
26324c9471Sopenharmony_ci * Define WIN32 when build target is Win32 API
27324c9471Sopenharmony_ci */
28324c9471Sopenharmony_ci
29324c9471Sopenharmony_ci#if (defined(_WIN32) || defined(__WIN32__)) && \
30324c9471Sopenharmony_ci   !defined(WIN32) && !defined(__SYMBIAN32__)
31324c9471Sopenharmony_ci#  define WIN32
32324c9471Sopenharmony_ci#endif
33324c9471Sopenharmony_ci
34324c9471Sopenharmony_ci#include <sys/types.h>
35324c9471Sopenharmony_ci
36324c9471Sopenharmony_ci/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
37324c9471Sopenharmony_ci   libc5-based Linux systems. Only include it on system that are known to
38324c9471Sopenharmony_ci   require it! */
39324c9471Sopenharmony_ci#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
40324c9471Sopenharmony_ci    defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \
41324c9471Sopenharmony_ci    defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \
42324c9471Sopenharmony_ci    defined(__QNXNTO__) || defined(__MVS__) || defined(__HAIKU__)
43324c9471Sopenharmony_ci#include <sys/select.h>
44324c9471Sopenharmony_ci#endif
45324c9471Sopenharmony_ci#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
46324c9471Sopenharmony_ci#include <sys/bsdskt.h>
47324c9471Sopenharmony_ci#endif
48324c9471Sopenharmony_ci
49324c9471Sopenharmony_ci#if defined(WATT32)
50324c9471Sopenharmony_ci#  include <netinet/in.h>
51324c9471Sopenharmony_ci#  include <sys/socket.h>
52324c9471Sopenharmony_ci#  include <tcp.h>
53324c9471Sopenharmony_ci#elif defined(_WIN32_WCE)
54324c9471Sopenharmony_ci#  ifndef WIN32_LEAN_AND_MEAN
55324c9471Sopenharmony_ci#    define WIN32_LEAN_AND_MEAN
56324c9471Sopenharmony_ci#  endif
57324c9471Sopenharmony_ci#  include <windows.h>
58324c9471Sopenharmony_ci#  include <winsock.h>
59324c9471Sopenharmony_ci#elif defined(WIN32)
60324c9471Sopenharmony_ci#  ifndef WIN32_LEAN_AND_MEAN
61324c9471Sopenharmony_ci#    define WIN32_LEAN_AND_MEAN
62324c9471Sopenharmony_ci#  endif
63324c9471Sopenharmony_ci#  include <windows.h>
64324c9471Sopenharmony_ci#  include <winsock2.h>
65324c9471Sopenharmony_ci#  include <ws2tcpip.h>
66324c9471Sopenharmony_ci#else
67324c9471Sopenharmony_ci#  include <sys/socket.h>
68324c9471Sopenharmony_ci#  include <netinet/in.h>
69324c9471Sopenharmony_ci#endif
70324c9471Sopenharmony_ci
71324c9471Sopenharmony_ci#if defined(ANDROID) || defined(__ANDROID__)
72324c9471Sopenharmony_ci#include <jni.h>
73324c9471Sopenharmony_ci#endif
74324c9471Sopenharmony_ci
75324c9471Sopenharmony_ci#ifdef  __cplusplus
76324c9471Sopenharmony_ciextern "C" {
77324c9471Sopenharmony_ci#endif
78324c9471Sopenharmony_ci
79324c9471Sopenharmony_ci/*
80324c9471Sopenharmony_ci** c-ares external API function linkage decorations.
81324c9471Sopenharmony_ci*/
82324c9471Sopenharmony_ci
83324c9471Sopenharmony_ci#ifdef CARES_STATICLIB
84324c9471Sopenharmony_ci#  define CARES_EXTERN
85324c9471Sopenharmony_ci#elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
86324c9471Sopenharmony_ci#  if defined(CARES_BUILDING_LIBRARY)
87324c9471Sopenharmony_ci#    define CARES_EXTERN  __declspec(dllexport)
88324c9471Sopenharmony_ci#  else
89324c9471Sopenharmony_ci#    define CARES_EXTERN  __declspec(dllimport)
90324c9471Sopenharmony_ci#  endif
91324c9471Sopenharmony_ci#elif defined(CARES_BUILDING_LIBRARY) && defined(CARES_SYMBOL_HIDING)
92324c9471Sopenharmony_ci#  define CARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN
93324c9471Sopenharmony_ci#else
94324c9471Sopenharmony_ci#  define CARES_EXTERN
95324c9471Sopenharmony_ci#endif
96324c9471Sopenharmony_ci
97324c9471Sopenharmony_ci
98324c9471Sopenharmony_ci#define ARES_SUCCESS            0
99324c9471Sopenharmony_ci
100324c9471Sopenharmony_ci/* Server error codes (ARES_ENODATA indicates no relevant answer) */
101324c9471Sopenharmony_ci#define ARES_ENODATA            1
102324c9471Sopenharmony_ci#define ARES_EFORMERR           2
103324c9471Sopenharmony_ci#define ARES_ESERVFAIL          3
104324c9471Sopenharmony_ci#define ARES_ENOTFOUND          4
105324c9471Sopenharmony_ci#define ARES_ENOTIMP            5
106324c9471Sopenharmony_ci#define ARES_EREFUSED           6
107324c9471Sopenharmony_ci
108324c9471Sopenharmony_ci/* Locally generated error codes */
109324c9471Sopenharmony_ci#define ARES_EBADQUERY          7
110324c9471Sopenharmony_ci#define ARES_EBADNAME           8
111324c9471Sopenharmony_ci#define ARES_EBADFAMILY         9
112324c9471Sopenharmony_ci#define ARES_EBADRESP           10
113324c9471Sopenharmony_ci#define ARES_ECONNREFUSED       11
114324c9471Sopenharmony_ci#define ARES_ETIMEOUT           12
115324c9471Sopenharmony_ci#define ARES_EOF                13
116324c9471Sopenharmony_ci#define ARES_EFILE              14
117324c9471Sopenharmony_ci#define ARES_ENOMEM             15
118324c9471Sopenharmony_ci#define ARES_EDESTRUCTION       16
119324c9471Sopenharmony_ci#define ARES_EBADSTR            17
120324c9471Sopenharmony_ci
121324c9471Sopenharmony_ci/* ares_getnameinfo error codes */
122324c9471Sopenharmony_ci#define ARES_EBADFLAGS          18
123324c9471Sopenharmony_ci
124324c9471Sopenharmony_ci/* ares_getaddrinfo error codes */
125324c9471Sopenharmony_ci#define ARES_ENONAME            19
126324c9471Sopenharmony_ci#define ARES_EBADHINTS          20
127324c9471Sopenharmony_ci
128324c9471Sopenharmony_ci/* Uninitialized library error code */
129324c9471Sopenharmony_ci#define ARES_ENOTINITIALIZED    21          /* introduced in 1.7.0 */
130324c9471Sopenharmony_ci
131324c9471Sopenharmony_ci/* ares_library_init error codes */
132324c9471Sopenharmony_ci#define ARES_ELOADIPHLPAPI           22     /* introduced in 1.7.0 */
133324c9471Sopenharmony_ci#define ARES_EADDRGETNETWORKPARAMS   23     /* introduced in 1.7.0 */
134324c9471Sopenharmony_ci
135324c9471Sopenharmony_ci/* More error codes */
136324c9471Sopenharmony_ci#define ARES_ECANCELLED         24          /* introduced in 1.7.0 */
137324c9471Sopenharmony_ci
138324c9471Sopenharmony_ci/* More ares_getaddrinfo error codes */
139324c9471Sopenharmony_ci#define ARES_ESERVICE           25          /* introduced in 1.?.0 */
140324c9471Sopenharmony_ci
141324c9471Sopenharmony_ci/* Flag values */
142324c9471Sopenharmony_ci#define ARES_FLAG_USEVC         (1 << 0)
143324c9471Sopenharmony_ci#define ARES_FLAG_PRIMARY       (1 << 1)
144324c9471Sopenharmony_ci#define ARES_FLAG_IGNTC         (1 << 2)
145324c9471Sopenharmony_ci#define ARES_FLAG_NORECURSE     (1 << 3)
146324c9471Sopenharmony_ci#define ARES_FLAG_STAYOPEN      (1 << 4)
147324c9471Sopenharmony_ci#define ARES_FLAG_NOSEARCH      (1 << 5)
148324c9471Sopenharmony_ci#define ARES_FLAG_NOALIASES     (1 << 6)
149324c9471Sopenharmony_ci#define ARES_FLAG_NOCHECKRESP   (1 << 7)
150324c9471Sopenharmony_ci#define ARES_FLAG_EDNS          (1 << 8)
151324c9471Sopenharmony_ci
152324c9471Sopenharmony_ci/* Option mask values */
153324c9471Sopenharmony_ci#define ARES_OPT_FLAGS          (1 << 0)
154324c9471Sopenharmony_ci#define ARES_OPT_TIMEOUT        (1 << 1)
155324c9471Sopenharmony_ci#define ARES_OPT_TRIES          (1 << 2)
156324c9471Sopenharmony_ci#define ARES_OPT_NDOTS          (1 << 3)
157324c9471Sopenharmony_ci#define ARES_OPT_UDP_PORT       (1 << 4)
158324c9471Sopenharmony_ci#define ARES_OPT_TCP_PORT       (1 << 5)
159324c9471Sopenharmony_ci#define ARES_OPT_SERVERS        (1 << 6)
160324c9471Sopenharmony_ci#define ARES_OPT_DOMAINS        (1 << 7)
161324c9471Sopenharmony_ci#define ARES_OPT_LOOKUPS        (1 << 8)
162324c9471Sopenharmony_ci#define ARES_OPT_SOCK_STATE_CB  (1 << 9)
163324c9471Sopenharmony_ci#define ARES_OPT_SORTLIST       (1 << 10)
164324c9471Sopenharmony_ci#define ARES_OPT_SOCK_SNDBUF    (1 << 11)
165324c9471Sopenharmony_ci#define ARES_OPT_SOCK_RCVBUF    (1 << 12)
166324c9471Sopenharmony_ci#define ARES_OPT_TIMEOUTMS      (1 << 13)
167324c9471Sopenharmony_ci#define ARES_OPT_ROTATE         (1 << 14)
168324c9471Sopenharmony_ci#define ARES_OPT_EDNSPSZ        (1 << 15)
169324c9471Sopenharmony_ci#define ARES_OPT_NOROTATE       (1 << 16)
170324c9471Sopenharmony_ci#define ARES_OPT_RESOLVCONF     (1 << 17)
171324c9471Sopenharmony_ci
172324c9471Sopenharmony_ci/* Nameinfo flag values */
173324c9471Sopenharmony_ci#define ARES_NI_NOFQDN                  (1 << 0)
174324c9471Sopenharmony_ci#define ARES_NI_NUMERICHOST             (1 << 1)
175324c9471Sopenharmony_ci#define ARES_NI_NAMEREQD                (1 << 2)
176324c9471Sopenharmony_ci#define ARES_NI_NUMERICSERV             (1 << 3)
177324c9471Sopenharmony_ci#define ARES_NI_DGRAM                   (1 << 4)
178324c9471Sopenharmony_ci#define ARES_NI_TCP                     0
179324c9471Sopenharmony_ci#define ARES_NI_UDP                     ARES_NI_DGRAM
180324c9471Sopenharmony_ci#define ARES_NI_SCTP                    (1 << 5)
181324c9471Sopenharmony_ci#define ARES_NI_DCCP                    (1 << 6)
182324c9471Sopenharmony_ci#define ARES_NI_NUMERICSCOPE            (1 << 7)
183324c9471Sopenharmony_ci#define ARES_NI_LOOKUPHOST              (1 << 8)
184324c9471Sopenharmony_ci#define ARES_NI_LOOKUPSERVICE           (1 << 9)
185324c9471Sopenharmony_ci/* Reserved for future use */
186324c9471Sopenharmony_ci#define ARES_NI_IDN                     (1 << 10)
187324c9471Sopenharmony_ci#define ARES_NI_IDN_ALLOW_UNASSIGNED    (1 << 11)
188324c9471Sopenharmony_ci#define ARES_NI_IDN_USE_STD3_ASCII_RULES (1 << 12)
189324c9471Sopenharmony_ci
190324c9471Sopenharmony_ci/* Addrinfo flag values */
191324c9471Sopenharmony_ci#define ARES_AI_CANONNAME               (1 << 0)
192324c9471Sopenharmony_ci#define ARES_AI_NUMERICHOST             (1 << 1)
193324c9471Sopenharmony_ci#define ARES_AI_PASSIVE                 (1 << 2)
194324c9471Sopenharmony_ci#define ARES_AI_NUMERICSERV             (1 << 3)
195324c9471Sopenharmony_ci#define ARES_AI_V4MAPPED                (1 << 4)
196324c9471Sopenharmony_ci#define ARES_AI_ALL                     (1 << 5)
197324c9471Sopenharmony_ci#define ARES_AI_ADDRCONFIG              (1 << 6)
198324c9471Sopenharmony_ci#define ARES_AI_NOSORT                  (1 << 7)
199324c9471Sopenharmony_ci#define ARES_AI_ENVHOSTS                (1 << 8)
200324c9471Sopenharmony_ci/* Reserved for future use */
201324c9471Sopenharmony_ci#define ARES_AI_IDN                     (1 << 10)
202324c9471Sopenharmony_ci#define ARES_AI_IDN_ALLOW_UNASSIGNED    (1 << 11)
203324c9471Sopenharmony_ci#define ARES_AI_IDN_USE_STD3_ASCII_RULES (1 << 12)
204324c9471Sopenharmony_ci#define ARES_AI_CANONIDN                (1 << 13)
205324c9471Sopenharmony_ci
206324c9471Sopenharmony_ci#define ARES_AI_MASK (ARES_AI_CANONNAME|ARES_AI_NUMERICHOST|ARES_AI_PASSIVE| \
207324c9471Sopenharmony_ci                      ARES_AI_NUMERICSERV|ARES_AI_V4MAPPED|ARES_AI_ALL| \
208324c9471Sopenharmony_ci                      ARES_AI_ADDRCONFIG)
209324c9471Sopenharmony_ci#define ARES_GETSOCK_MAXNUM 16 /* ares_getsock() can return info about this
210324c9471Sopenharmony_ci                                  many sockets */
211324c9471Sopenharmony_ci#define ARES_GETSOCK_READABLE(bits,num) ((bits) & (1 << (num)))
212324c9471Sopenharmony_ci#define ARES_GETSOCK_WRITABLE(bits,num) ((bits) & (1 << ((num) + \
213324c9471Sopenharmony_ci                                         (ARES_GETSOCK_MAXNUM))))
214324c9471Sopenharmony_ci
215324c9471Sopenharmony_ci/* c-ares library initialization flag values */
216324c9471Sopenharmony_ci#define ARES_LIB_INIT_NONE   (0)
217324c9471Sopenharmony_ci#define ARES_LIB_INIT_WIN32  (1 << 0)
218324c9471Sopenharmony_ci#define ARES_LIB_INIT_ALL    (ARES_LIB_INIT_WIN32)
219324c9471Sopenharmony_ci
220324c9471Sopenharmony_ci/*
221324c9471Sopenharmony_ci * Typedef our socket type
222324c9471Sopenharmony_ci */
223324c9471Sopenharmony_ci
224324c9471Sopenharmony_ci#ifndef ares_socket_typedef
225324c9471Sopenharmony_ci#ifdef WIN32
226324c9471Sopenharmony_citypedef SOCKET ares_socket_t;
227324c9471Sopenharmony_ci#define ARES_SOCKET_BAD INVALID_SOCKET
228324c9471Sopenharmony_ci#else
229324c9471Sopenharmony_citypedef int ares_socket_t;
230324c9471Sopenharmony_ci#define ARES_SOCKET_BAD     (-1)
231324c9471Sopenharmony_ci#endif
232324c9471Sopenharmony_ci#define ares_socket_typedef
233324c9471Sopenharmony_ci#endif /* ares_socket_typedef */
234324c9471Sopenharmony_ci
235324c9471Sopenharmony_citypedef void (*ares_sock_state_cb)(void *data,
236324c9471Sopenharmony_ci                                   ares_socket_t socket_fd,
237324c9471Sopenharmony_ci                                   int readable,
238324c9471Sopenharmony_ci                                   int writable);
239324c9471Sopenharmony_ci
240324c9471Sopenharmony_cistruct apattern;
241324c9471Sopenharmony_ci
242324c9471Sopenharmony_ci/* NOTE about the ares_options struct to users and developers.
243324c9471Sopenharmony_ci
244324c9471Sopenharmony_ci   This struct will remain looking like this. It will not be extended nor
245324c9471Sopenharmony_ci   shrunk in future releases, but all new options will be set by ares_set_*()
246324c9471Sopenharmony_ci   options instead of with the ares_init_options() function.
247324c9471Sopenharmony_ci
248324c9471Sopenharmony_ci   Eventually (in a galaxy far far away), all options will be settable by
249324c9471Sopenharmony_ci   ares_set_*() options and the ares_init_options() function will become
250324c9471Sopenharmony_ci   deprecated.
251324c9471Sopenharmony_ci
252324c9471Sopenharmony_ci   When new options are added to c-ares, they are not added to this
253324c9471Sopenharmony_ci   struct. And they are not "saved" with the ares_save_options() function but
254324c9471Sopenharmony_ci   instead we encourage the use of the ares_dup() function. Needless to say,
255324c9471Sopenharmony_ci   if you add config options to c-ares you need to make sure ares_dup()
256324c9471Sopenharmony_ci   duplicates this new option.
257324c9471Sopenharmony_ci
258324c9471Sopenharmony_ci */
259324c9471Sopenharmony_cistruct ares_options {
260324c9471Sopenharmony_ci  int flags;
261324c9471Sopenharmony_ci  int timeout; /* in seconds or milliseconds, depending on options */
262324c9471Sopenharmony_ci  int tries;
263324c9471Sopenharmony_ci  int ndots;
264324c9471Sopenharmony_ci  unsigned short udp_port;
265324c9471Sopenharmony_ci  unsigned short tcp_port;
266324c9471Sopenharmony_ci  int socket_send_buffer_size;
267324c9471Sopenharmony_ci  int socket_receive_buffer_size;
268324c9471Sopenharmony_ci  struct in_addr *servers;
269324c9471Sopenharmony_ci  int nservers;
270324c9471Sopenharmony_ci  char **domains;
271324c9471Sopenharmony_ci  int ndomains;
272324c9471Sopenharmony_ci  char *lookups;
273324c9471Sopenharmony_ci  ares_sock_state_cb sock_state_cb;
274324c9471Sopenharmony_ci  void *sock_state_cb_data;
275324c9471Sopenharmony_ci  struct apattern *sortlist;
276324c9471Sopenharmony_ci  int nsort;
277324c9471Sopenharmony_ci  int ednspsz;
278324c9471Sopenharmony_ci  char *resolvconf_path;
279324c9471Sopenharmony_ci};
280324c9471Sopenharmony_ci
281324c9471Sopenharmony_cistruct hostent;
282324c9471Sopenharmony_cistruct timeval;
283324c9471Sopenharmony_cistruct sockaddr;
284324c9471Sopenharmony_cistruct ares_channeldata;
285324c9471Sopenharmony_cistruct ares_addrinfo;
286324c9471Sopenharmony_cistruct ares_addrinfo_hints;
287324c9471Sopenharmony_ci
288324c9471Sopenharmony_citypedef struct ares_channeldata *ares_channel;
289324c9471Sopenharmony_ci
290324c9471Sopenharmony_citypedef void (*ares_callback)(void *arg,
291324c9471Sopenharmony_ci                              int status,
292324c9471Sopenharmony_ci                              int timeouts,
293324c9471Sopenharmony_ci                              unsigned char *abuf,
294324c9471Sopenharmony_ci                              int alen);
295324c9471Sopenharmony_ci
296324c9471Sopenharmony_citypedef void (*ares_host_callback)(void *arg,
297324c9471Sopenharmony_ci                                   int status,
298324c9471Sopenharmony_ci                                   int timeouts,
299324c9471Sopenharmony_ci                                   struct hostent *hostent);
300324c9471Sopenharmony_ci
301324c9471Sopenharmony_citypedef void (*ares_nameinfo_callback)(void *arg,
302324c9471Sopenharmony_ci                                       int status,
303324c9471Sopenharmony_ci                                       int timeouts,
304324c9471Sopenharmony_ci                                       char *node,
305324c9471Sopenharmony_ci                                       char *service);
306324c9471Sopenharmony_ci
307324c9471Sopenharmony_citypedef int  (*ares_sock_create_callback)(ares_socket_t socket_fd,
308324c9471Sopenharmony_ci                                          int type,
309324c9471Sopenharmony_ci                                          void *data);
310324c9471Sopenharmony_ci
311324c9471Sopenharmony_citypedef int  (*ares_sock_config_callback)(ares_socket_t socket_fd,
312324c9471Sopenharmony_ci                                          int type,
313324c9471Sopenharmony_ci                                          void *data);
314324c9471Sopenharmony_ci
315324c9471Sopenharmony_citypedef void (*ares_addrinfo_callback)(void *arg,
316324c9471Sopenharmony_ci                                   int status,
317324c9471Sopenharmony_ci                                   int timeouts,
318324c9471Sopenharmony_ci                                   struct ares_addrinfo *res);
319324c9471Sopenharmony_ci
320324c9471Sopenharmony_ciCARES_EXTERN int ares_library_init(int flags);
321324c9471Sopenharmony_ci
322324c9471Sopenharmony_ciCARES_EXTERN int ares_library_init_mem(int flags,
323324c9471Sopenharmony_ci                                       void *(*amalloc)(size_t size),
324324c9471Sopenharmony_ci                                       void (*afree)(void *ptr),
325324c9471Sopenharmony_ci                                       void *(*arealloc)(void *ptr, size_t size));
326324c9471Sopenharmony_ci
327324c9471Sopenharmony_ci#if defined(ANDROID) || defined(__ANDROID__)
328324c9471Sopenharmony_ciCARES_EXTERN void ares_library_init_jvm(JavaVM *jvm);
329324c9471Sopenharmony_ciCARES_EXTERN int ares_library_init_android(jobject connectivity_manager);
330324c9471Sopenharmony_ciCARES_EXTERN int ares_library_android_initialized(void);
331324c9471Sopenharmony_ci#endif
332324c9471Sopenharmony_ci
333324c9471Sopenharmony_ciCARES_EXTERN int ares_library_initialized(void);
334324c9471Sopenharmony_ci
335324c9471Sopenharmony_ciCARES_EXTERN void ares_library_cleanup(void);
336324c9471Sopenharmony_ci
337324c9471Sopenharmony_ciCARES_EXTERN const char *ares_version(int *version);
338324c9471Sopenharmony_ci
339324c9471Sopenharmony_ciCARES_EXTERN int ares_init(ares_channel *channelptr);
340324c9471Sopenharmony_ci
341324c9471Sopenharmony_ciCARES_EXTERN int ares_init_options(ares_channel *channelptr,
342324c9471Sopenharmony_ci                                   struct ares_options *options,
343324c9471Sopenharmony_ci                                   int optmask);
344324c9471Sopenharmony_ci
345324c9471Sopenharmony_ciCARES_EXTERN int ares_save_options(ares_channel channel,
346324c9471Sopenharmony_ci                                   struct ares_options *options,
347324c9471Sopenharmony_ci                                   int *optmask);
348324c9471Sopenharmony_ci
349324c9471Sopenharmony_ciCARES_EXTERN void ares_destroy_options(struct ares_options *options);
350324c9471Sopenharmony_ci
351324c9471Sopenharmony_ciCARES_EXTERN int ares_dup(ares_channel *dest,
352324c9471Sopenharmony_ci                          ares_channel src);
353324c9471Sopenharmony_ci
354324c9471Sopenharmony_ciCARES_EXTERN void ares_destroy(ares_channel channel);
355324c9471Sopenharmony_ci
356324c9471Sopenharmony_ciCARES_EXTERN void ares_cancel(ares_channel channel);
357324c9471Sopenharmony_ci
358324c9471Sopenharmony_ci/* These next 3 configure local binding for the out-going socket
359324c9471Sopenharmony_ci * connection.  Use these to specify source IP and/or network device
360324c9471Sopenharmony_ci * on multi-homed systems.
361324c9471Sopenharmony_ci */
362324c9471Sopenharmony_ciCARES_EXTERN void ares_set_local_ip4(ares_channel channel, unsigned int local_ip);
363324c9471Sopenharmony_ci
364324c9471Sopenharmony_ci/* local_ip6 should be 16 bytes in length */
365324c9471Sopenharmony_ciCARES_EXTERN void ares_set_local_ip6(ares_channel channel,
366324c9471Sopenharmony_ci                                     const unsigned char* local_ip6);
367324c9471Sopenharmony_ci
368324c9471Sopenharmony_ci/* local_dev_name should be null terminated. */
369324c9471Sopenharmony_ciCARES_EXTERN void ares_set_local_dev(ares_channel channel,
370324c9471Sopenharmony_ci                                     const char* local_dev_name);
371324c9471Sopenharmony_ci
372324c9471Sopenharmony_ciCARES_EXTERN void ares_set_socket_callback(ares_channel channel,
373324c9471Sopenharmony_ci                                           ares_sock_create_callback callback,
374324c9471Sopenharmony_ci                                           void *user_data);
375324c9471Sopenharmony_ci
376324c9471Sopenharmony_ciCARES_EXTERN void ares_set_socket_configure_callback(ares_channel channel,
377324c9471Sopenharmony_ci                                                     ares_sock_config_callback callback,
378324c9471Sopenharmony_ci                                                     void *user_data);
379324c9471Sopenharmony_ci
380324c9471Sopenharmony_ciCARES_EXTERN int ares_set_sortlist(ares_channel channel,
381324c9471Sopenharmony_ci                                   const char *sortstr);
382324c9471Sopenharmony_ci
383324c9471Sopenharmony_ciCARES_EXTERN void ares_getaddrinfo(ares_channel channel,
384324c9471Sopenharmony_ci                                   const char* node,
385324c9471Sopenharmony_ci                                   const char* service,
386324c9471Sopenharmony_ci                                   const struct ares_addrinfo_hints* hints,
387324c9471Sopenharmony_ci                                   ares_addrinfo_callback callback,
388324c9471Sopenharmony_ci                                   void* arg);
389324c9471Sopenharmony_ci
390324c9471Sopenharmony_ciCARES_EXTERN void ares_freeaddrinfo(struct ares_addrinfo* ai);
391324c9471Sopenharmony_ci
392324c9471Sopenharmony_ci/*
393324c9471Sopenharmony_ci * Virtual function set to have user-managed socket IO.
394324c9471Sopenharmony_ci * Note that all functions need to be defined, and when
395324c9471Sopenharmony_ci * set, the library will not do any bind nor set any
396324c9471Sopenharmony_ci * socket options, assuming the client handles these
397324c9471Sopenharmony_ci * through either socket creation or the
398324c9471Sopenharmony_ci * ares_sock_config_callback call.
399324c9471Sopenharmony_ci */
400324c9471Sopenharmony_cistruct iovec;
401324c9471Sopenharmony_cistruct ares_socket_functions {
402324c9471Sopenharmony_ci   ares_socket_t(*asocket)(int, int, int, void *);
403324c9471Sopenharmony_ci   int(*aclose)(ares_socket_t, void *);
404324c9471Sopenharmony_ci   int(*aconnect)(ares_socket_t, const struct sockaddr *, ares_socklen_t, void *);
405324c9471Sopenharmony_ci   ares_ssize_t(*arecvfrom)(ares_socket_t, void *, size_t, int, struct sockaddr *, ares_socklen_t *, void *);
406324c9471Sopenharmony_ci   ares_ssize_t(*asendv)(ares_socket_t, const struct iovec *, int, void *);
407324c9471Sopenharmony_ci};
408324c9471Sopenharmony_ci
409324c9471Sopenharmony_ciCARES_EXTERN void ares_set_socket_functions(ares_channel channel,
410324c9471Sopenharmony_ci					    const struct ares_socket_functions * funcs,
411324c9471Sopenharmony_ci					    void *user_data);
412324c9471Sopenharmony_ci
413324c9471Sopenharmony_ciCARES_EXTERN void ares_send(ares_channel channel,
414324c9471Sopenharmony_ci                            const unsigned char *qbuf,
415324c9471Sopenharmony_ci                            int qlen,
416324c9471Sopenharmony_ci                            ares_callback callback,
417324c9471Sopenharmony_ci                            void *arg);
418324c9471Sopenharmony_ci
419324c9471Sopenharmony_ciCARES_EXTERN void ares_query(ares_channel channel,
420324c9471Sopenharmony_ci                             const char *name,
421324c9471Sopenharmony_ci                             int dnsclass,
422324c9471Sopenharmony_ci                             int type,
423324c9471Sopenharmony_ci                             ares_callback callback,
424324c9471Sopenharmony_ci                             void *arg);
425324c9471Sopenharmony_ci
426324c9471Sopenharmony_ciCARES_EXTERN void ares_search(ares_channel channel,
427324c9471Sopenharmony_ci                              const char *name,
428324c9471Sopenharmony_ci                              int dnsclass,
429324c9471Sopenharmony_ci                              int type,
430324c9471Sopenharmony_ci                              ares_callback callback,
431324c9471Sopenharmony_ci                              void *arg);
432324c9471Sopenharmony_ci
433324c9471Sopenharmony_ciCARES_EXTERN void ares_gethostbyname(ares_channel channel,
434324c9471Sopenharmony_ci                                     const char *name,
435324c9471Sopenharmony_ci                                     int family,
436324c9471Sopenharmony_ci                                     ares_host_callback callback,
437324c9471Sopenharmony_ci                                     void *arg);
438324c9471Sopenharmony_ci
439324c9471Sopenharmony_ciCARES_EXTERN int ares_gethostbyname_file(ares_channel channel,
440324c9471Sopenharmony_ci                                         const char *name,
441324c9471Sopenharmony_ci                                         int family,
442324c9471Sopenharmony_ci                                         struct hostent **host);
443324c9471Sopenharmony_ci
444324c9471Sopenharmony_ciCARES_EXTERN void ares_gethostbyaddr(ares_channel channel,
445324c9471Sopenharmony_ci                                     const void *addr,
446324c9471Sopenharmony_ci                                     int addrlen,
447324c9471Sopenharmony_ci                                     int family,
448324c9471Sopenharmony_ci                                     ares_host_callback callback,
449324c9471Sopenharmony_ci                                     void *arg);
450324c9471Sopenharmony_ci
451324c9471Sopenharmony_ciCARES_EXTERN void ares_getnameinfo(ares_channel channel,
452324c9471Sopenharmony_ci                                   const struct sockaddr *sa,
453324c9471Sopenharmony_ci                                   ares_socklen_t salen,
454324c9471Sopenharmony_ci                                   int flags,
455324c9471Sopenharmony_ci                                   ares_nameinfo_callback callback,
456324c9471Sopenharmony_ci                                   void *arg);
457324c9471Sopenharmony_ci
458324c9471Sopenharmony_ciCARES_EXTERN int ares_fds(ares_channel channel,
459324c9471Sopenharmony_ci                          fd_set *read_fds,
460324c9471Sopenharmony_ci                          fd_set *write_fds);
461324c9471Sopenharmony_ci
462324c9471Sopenharmony_ciCARES_EXTERN int ares_getsock(ares_channel channel,
463324c9471Sopenharmony_ci                              ares_socket_t *socks,
464324c9471Sopenharmony_ci                              int numsocks);
465324c9471Sopenharmony_ci
466324c9471Sopenharmony_ciCARES_EXTERN struct timeval *ares_timeout(ares_channel channel,
467324c9471Sopenharmony_ci                                          struct timeval *maxtv,
468324c9471Sopenharmony_ci                                          struct timeval *tv);
469324c9471Sopenharmony_ci
470324c9471Sopenharmony_ciCARES_EXTERN void ares_process(ares_channel channel,
471324c9471Sopenharmony_ci                               fd_set *read_fds,
472324c9471Sopenharmony_ci                               fd_set *write_fds);
473324c9471Sopenharmony_ci
474324c9471Sopenharmony_ciCARES_EXTERN void ares_process_fd(ares_channel channel,
475324c9471Sopenharmony_ci                                  ares_socket_t read_fd,
476324c9471Sopenharmony_ci                                  ares_socket_t write_fd);
477324c9471Sopenharmony_ci
478324c9471Sopenharmony_ciCARES_EXTERN int ares_create_query(const char *name,
479324c9471Sopenharmony_ci                                   int dnsclass,
480324c9471Sopenharmony_ci                                   int type,
481324c9471Sopenharmony_ci                                   unsigned short id,
482324c9471Sopenharmony_ci                                   int rd,
483324c9471Sopenharmony_ci                                   unsigned char **buf,
484324c9471Sopenharmony_ci                                   int *buflen,
485324c9471Sopenharmony_ci                                   int max_udp_size);
486324c9471Sopenharmony_ci
487324c9471Sopenharmony_ciCARES_EXTERN int ares_mkquery(const char *name,
488324c9471Sopenharmony_ci                              int dnsclass,
489324c9471Sopenharmony_ci                              int type,
490324c9471Sopenharmony_ci                              unsigned short id,
491324c9471Sopenharmony_ci                              int rd,
492324c9471Sopenharmony_ci                              unsigned char **buf,
493324c9471Sopenharmony_ci                              int *buflen);
494324c9471Sopenharmony_ci
495324c9471Sopenharmony_ciCARES_EXTERN int ares_expand_name(const unsigned char *encoded,
496324c9471Sopenharmony_ci                                  const unsigned char *abuf,
497324c9471Sopenharmony_ci                                  int alen,
498324c9471Sopenharmony_ci                                  char **s,
499324c9471Sopenharmony_ci                                  long *enclen);
500324c9471Sopenharmony_ci
501324c9471Sopenharmony_ciCARES_EXTERN int ares_expand_string(const unsigned char *encoded,
502324c9471Sopenharmony_ci                                    const unsigned char *abuf,
503324c9471Sopenharmony_ci                                    int alen,
504324c9471Sopenharmony_ci                                    unsigned char **s,
505324c9471Sopenharmony_ci                                    long *enclen);
506324c9471Sopenharmony_ci
507324c9471Sopenharmony_ci/*
508324c9471Sopenharmony_ci * NOTE: before c-ares 1.7.0 we would most often use the system in6_addr
509324c9471Sopenharmony_ci * struct below when ares itself was built, but many apps would use this
510324c9471Sopenharmony_ci * private version since the header checked a HAVE_* define for it. Starting
511324c9471Sopenharmony_ci * with 1.7.0 we always declare and use our own to stop relying on the
512324c9471Sopenharmony_ci * system's one.
513324c9471Sopenharmony_ci */
514324c9471Sopenharmony_cistruct ares_in6_addr {
515324c9471Sopenharmony_ci  union {
516324c9471Sopenharmony_ci    unsigned char _S6_u8[16];
517324c9471Sopenharmony_ci  } _S6_un;
518324c9471Sopenharmony_ci};
519324c9471Sopenharmony_ci
520324c9471Sopenharmony_cistruct ares_addrttl {
521324c9471Sopenharmony_ci  struct in_addr ipaddr;
522324c9471Sopenharmony_ci  int            ttl;
523324c9471Sopenharmony_ci};
524324c9471Sopenharmony_ci
525324c9471Sopenharmony_cistruct ares_addr6ttl {
526324c9471Sopenharmony_ci  struct ares_in6_addr ip6addr;
527324c9471Sopenharmony_ci  int             ttl;
528324c9471Sopenharmony_ci};
529324c9471Sopenharmony_ci
530324c9471Sopenharmony_cistruct ares_caa_reply {
531324c9471Sopenharmony_ci  struct ares_caa_reply  *next;
532324c9471Sopenharmony_ci  int                     critical;
533324c9471Sopenharmony_ci  unsigned char          *property;
534324c9471Sopenharmony_ci  size_t                  plength;  /* plength excludes null termination */
535324c9471Sopenharmony_ci  unsigned char          *value;
536324c9471Sopenharmony_ci  size_t                  length;   /* length excludes null termination */
537324c9471Sopenharmony_ci};
538324c9471Sopenharmony_ci
539324c9471Sopenharmony_cistruct ares_srv_reply {
540324c9471Sopenharmony_ci  struct ares_srv_reply  *next;
541324c9471Sopenharmony_ci  char                   *host;
542324c9471Sopenharmony_ci  unsigned short          priority;
543324c9471Sopenharmony_ci  unsigned short          weight;
544324c9471Sopenharmony_ci  unsigned short          port;
545324c9471Sopenharmony_ci};
546324c9471Sopenharmony_ci
547324c9471Sopenharmony_cistruct ares_mx_reply {
548324c9471Sopenharmony_ci  struct ares_mx_reply   *next;
549324c9471Sopenharmony_ci  char                   *host;
550324c9471Sopenharmony_ci  unsigned short          priority;
551324c9471Sopenharmony_ci};
552324c9471Sopenharmony_ci
553324c9471Sopenharmony_cistruct ares_txt_reply {
554324c9471Sopenharmony_ci  struct ares_txt_reply  *next;
555324c9471Sopenharmony_ci  unsigned char          *txt;
556324c9471Sopenharmony_ci  size_t                  length;  /* length excludes null termination */
557324c9471Sopenharmony_ci};
558324c9471Sopenharmony_ci
559324c9471Sopenharmony_ci/* NOTE: This structure is a superset of ares_txt_reply
560324c9471Sopenharmony_ci */
561324c9471Sopenharmony_cistruct ares_txt_ext {
562324c9471Sopenharmony_ci  struct ares_txt_ext      *next;
563324c9471Sopenharmony_ci  unsigned char            *txt;
564324c9471Sopenharmony_ci  size_t                   length;
565324c9471Sopenharmony_ci  /* 1 - if start of new record
566324c9471Sopenharmony_ci   * 0 - if a chunk in the same record */
567324c9471Sopenharmony_ci  unsigned char            record_start;
568324c9471Sopenharmony_ci};
569324c9471Sopenharmony_ci
570324c9471Sopenharmony_cistruct ares_naptr_reply {
571324c9471Sopenharmony_ci  struct ares_naptr_reply *next;
572324c9471Sopenharmony_ci  unsigned char           *flags;
573324c9471Sopenharmony_ci  unsigned char           *service;
574324c9471Sopenharmony_ci  unsigned char           *regexp;
575324c9471Sopenharmony_ci  char                    *replacement;
576324c9471Sopenharmony_ci  unsigned short           order;
577324c9471Sopenharmony_ci  unsigned short           preference;
578324c9471Sopenharmony_ci};
579324c9471Sopenharmony_ci
580324c9471Sopenharmony_cistruct ares_soa_reply {
581324c9471Sopenharmony_ci  char        *nsname;
582324c9471Sopenharmony_ci  char        *hostmaster;
583324c9471Sopenharmony_ci  unsigned int serial;
584324c9471Sopenharmony_ci  unsigned int refresh;
585324c9471Sopenharmony_ci  unsigned int retry;
586324c9471Sopenharmony_ci  unsigned int expire;
587324c9471Sopenharmony_ci  unsigned int minttl;
588324c9471Sopenharmony_ci};
589324c9471Sopenharmony_ci
590324c9471Sopenharmony_cistruct ares_uri_reply {
591324c9471Sopenharmony_ci  struct ares_uri_reply  *next;
592324c9471Sopenharmony_ci  unsigned short          priority;
593324c9471Sopenharmony_ci  unsigned short          weight;
594324c9471Sopenharmony_ci  char                   *uri;
595324c9471Sopenharmony_ci  int                     ttl;
596324c9471Sopenharmony_ci};
597324c9471Sopenharmony_ci
598324c9471Sopenharmony_ci/*
599324c9471Sopenharmony_ci * Similar to addrinfo, but with extra ttl and missing canonname.
600324c9471Sopenharmony_ci */
601324c9471Sopenharmony_cistruct ares_addrinfo_node {
602324c9471Sopenharmony_ci  int                        ai_ttl;
603324c9471Sopenharmony_ci  int                        ai_flags;
604324c9471Sopenharmony_ci  int                        ai_family;
605324c9471Sopenharmony_ci  int                        ai_socktype;
606324c9471Sopenharmony_ci  int                        ai_protocol;
607324c9471Sopenharmony_ci  ares_socklen_t             ai_addrlen;
608324c9471Sopenharmony_ci  struct sockaddr           *ai_addr;
609324c9471Sopenharmony_ci  struct ares_addrinfo_node *ai_next;
610324c9471Sopenharmony_ci};
611324c9471Sopenharmony_ci
612324c9471Sopenharmony_ci/*
613324c9471Sopenharmony_ci * alias - label of the resource record.
614324c9471Sopenharmony_ci * name - value (canonical name) of the resource record.
615324c9471Sopenharmony_ci * See RFC2181 10.1.1. CNAME terminology.
616324c9471Sopenharmony_ci */
617324c9471Sopenharmony_cistruct ares_addrinfo_cname {
618324c9471Sopenharmony_ci  int                         ttl;
619324c9471Sopenharmony_ci  char                       *alias;
620324c9471Sopenharmony_ci  char                       *name;
621324c9471Sopenharmony_ci  struct ares_addrinfo_cname *next;
622324c9471Sopenharmony_ci};
623324c9471Sopenharmony_ci
624324c9471Sopenharmony_cistruct ares_addrinfo {
625324c9471Sopenharmony_ci  struct ares_addrinfo_cname *cnames;
626324c9471Sopenharmony_ci  struct ares_addrinfo_node  *nodes;
627324c9471Sopenharmony_ci  char                       *name;
628324c9471Sopenharmony_ci};
629324c9471Sopenharmony_ci
630324c9471Sopenharmony_cistruct ares_addrinfo_hints {
631324c9471Sopenharmony_ci  int ai_flags;
632324c9471Sopenharmony_ci  int ai_family;
633324c9471Sopenharmony_ci  int ai_socktype;
634324c9471Sopenharmony_ci  int ai_protocol;
635324c9471Sopenharmony_ci};
636324c9471Sopenharmony_ci
637324c9471Sopenharmony_ci/*
638324c9471Sopenharmony_ci** Parse the buffer, starting at *abuf and of length alen bytes, previously
639324c9471Sopenharmony_ci** obtained from an ares_search call.  Put the results in *host, if nonnull.
640324c9471Sopenharmony_ci** Also, if addrttls is nonnull, put up to *naddrttls IPv4 addresses along with
641324c9471Sopenharmony_ci** their TTLs in that array, and set *naddrttls to the number of addresses
642324c9471Sopenharmony_ci** so written.
643324c9471Sopenharmony_ci*/
644324c9471Sopenharmony_ci
645324c9471Sopenharmony_ciCARES_EXTERN int ares_parse_a_reply(const unsigned char *abuf,
646324c9471Sopenharmony_ci                                    int alen,
647324c9471Sopenharmony_ci                                    struct hostent **host,
648324c9471Sopenharmony_ci                                    struct ares_addrttl *addrttls,
649324c9471Sopenharmony_ci                                    int *naddrttls);
650324c9471Sopenharmony_ci
651324c9471Sopenharmony_ciCARES_EXTERN int ares_parse_aaaa_reply(const unsigned char *abuf,
652324c9471Sopenharmony_ci                                       int alen,
653324c9471Sopenharmony_ci                                       struct hostent **host,
654324c9471Sopenharmony_ci                                       struct ares_addr6ttl *addrttls,
655324c9471Sopenharmony_ci                                       int *naddrttls);
656324c9471Sopenharmony_ci
657324c9471Sopenharmony_ciCARES_EXTERN int ares_parse_caa_reply(const unsigned char* abuf,
658324c9471Sopenharmony_ci				      int alen,
659324c9471Sopenharmony_ci				      struct ares_caa_reply** caa_out);
660324c9471Sopenharmony_ci
661324c9471Sopenharmony_ciCARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf,
662324c9471Sopenharmony_ci                                      int alen,
663324c9471Sopenharmony_ci                                      const void *addr,
664324c9471Sopenharmony_ci                                      int addrlen,
665324c9471Sopenharmony_ci                                      int family,
666324c9471Sopenharmony_ci                                      struct hostent **host);
667324c9471Sopenharmony_ci
668324c9471Sopenharmony_ciCARES_EXTERN int ares_parse_ns_reply(const unsigned char *abuf,
669324c9471Sopenharmony_ci                                     int alen,
670324c9471Sopenharmony_ci                                     struct hostent **host);
671324c9471Sopenharmony_ci
672324c9471Sopenharmony_ciCARES_EXTERN int ares_parse_srv_reply(const unsigned char* abuf,
673324c9471Sopenharmony_ci                                      int alen,
674324c9471Sopenharmony_ci                                      struct ares_srv_reply** srv_out);
675324c9471Sopenharmony_ci
676324c9471Sopenharmony_ciCARES_EXTERN int ares_parse_mx_reply(const unsigned char* abuf,
677324c9471Sopenharmony_ci                                     int alen,
678324c9471Sopenharmony_ci                                     struct ares_mx_reply** mx_out);
679324c9471Sopenharmony_ci
680324c9471Sopenharmony_ciCARES_EXTERN int ares_parse_txt_reply(const unsigned char* abuf,
681324c9471Sopenharmony_ci                                      int alen,
682324c9471Sopenharmony_ci                                      struct ares_txt_reply** txt_out);
683324c9471Sopenharmony_ci
684324c9471Sopenharmony_ciCARES_EXTERN int ares_parse_txt_reply_ext(const unsigned char* abuf,
685324c9471Sopenharmony_ci                                          int alen,
686324c9471Sopenharmony_ci                                          struct ares_txt_ext** txt_out);
687324c9471Sopenharmony_ci
688324c9471Sopenharmony_ciCARES_EXTERN int ares_parse_naptr_reply(const unsigned char* abuf,
689324c9471Sopenharmony_ci                                        int alen,
690324c9471Sopenharmony_ci                                        struct ares_naptr_reply** naptr_out);
691324c9471Sopenharmony_ci
692324c9471Sopenharmony_ciCARES_EXTERN int ares_parse_soa_reply(const unsigned char* abuf,
693324c9471Sopenharmony_ci                                      int alen,
694324c9471Sopenharmony_ci                                      struct ares_soa_reply** soa_out);
695324c9471Sopenharmony_ci
696324c9471Sopenharmony_ciCARES_EXTERN int ares_parse_uri_reply(const unsigned char* abuf,
697324c9471Sopenharmony_ci                                      int alen,
698324c9471Sopenharmony_ci                                      struct ares_uri_reply** uri_out);
699324c9471Sopenharmony_ci
700324c9471Sopenharmony_ciCARES_EXTERN void ares_free_string(void *str);
701324c9471Sopenharmony_ci
702324c9471Sopenharmony_ciCARES_EXTERN void ares_free_hostent(struct hostent *host);
703324c9471Sopenharmony_ci
704324c9471Sopenharmony_ciCARES_EXTERN void ares_free_data(void *dataptr);
705324c9471Sopenharmony_ci
706324c9471Sopenharmony_ciCARES_EXTERN const char *ares_strerror(int code);
707324c9471Sopenharmony_ci
708324c9471Sopenharmony_cistruct ares_addr_node {
709324c9471Sopenharmony_ci  struct ares_addr_node *next;
710324c9471Sopenharmony_ci  int family;
711324c9471Sopenharmony_ci  union {
712324c9471Sopenharmony_ci    struct in_addr       addr4;
713324c9471Sopenharmony_ci    struct ares_in6_addr addr6;
714324c9471Sopenharmony_ci  } addr;
715324c9471Sopenharmony_ci};
716324c9471Sopenharmony_ci
717324c9471Sopenharmony_cistruct ares_addr_port_node {
718324c9471Sopenharmony_ci  struct ares_addr_port_node *next;
719324c9471Sopenharmony_ci  int family;
720324c9471Sopenharmony_ci  union {
721324c9471Sopenharmony_ci    struct in_addr       addr4;
722324c9471Sopenharmony_ci    struct ares_in6_addr addr6;
723324c9471Sopenharmony_ci  } addr;
724324c9471Sopenharmony_ci  int udp_port;
725324c9471Sopenharmony_ci  int tcp_port;
726324c9471Sopenharmony_ci};
727324c9471Sopenharmony_ci
728324c9471Sopenharmony_ciCARES_EXTERN int ares_set_servers(ares_channel channel,
729324c9471Sopenharmony_ci                                  struct ares_addr_node *servers);
730324c9471Sopenharmony_ciCARES_EXTERN int ares_set_servers_ports(ares_channel channel,
731324c9471Sopenharmony_ci                                        struct ares_addr_port_node *servers);
732324c9471Sopenharmony_ci
733324c9471Sopenharmony_ci/* Incomming string format: host[:port][,host[:port]]... */
734324c9471Sopenharmony_ciCARES_EXTERN int ares_set_servers_csv(ares_channel channel,
735324c9471Sopenharmony_ci                                      const char* servers);
736324c9471Sopenharmony_ciCARES_EXTERN int ares_set_servers_ports_csv(ares_channel channel,
737324c9471Sopenharmony_ci                                            const char* servers);
738324c9471Sopenharmony_ci
739324c9471Sopenharmony_ciCARES_EXTERN int ares_get_servers(ares_channel channel,
740324c9471Sopenharmony_ci                                  struct ares_addr_node **servers);
741324c9471Sopenharmony_ciCARES_EXTERN int ares_get_servers_ports(ares_channel channel,
742324c9471Sopenharmony_ci                                        struct ares_addr_port_node **servers);
743324c9471Sopenharmony_ci
744324c9471Sopenharmony_ciCARES_EXTERN const char *ares_inet_ntop(int af, const void *src, char *dst,
745324c9471Sopenharmony_ci                                        ares_socklen_t size);
746324c9471Sopenharmony_ci
747324c9471Sopenharmony_ciCARES_EXTERN int ares_inet_pton(int af, const char *src, void *dst);
748324c9471Sopenharmony_ci
749324c9471Sopenharmony_ci
750324c9471Sopenharmony_ci#ifdef  __cplusplus
751324c9471Sopenharmony_ci}
752324c9471Sopenharmony_ci#endif
753324c9471Sopenharmony_ci
754324c9471Sopenharmony_ci#endif /* ARES__H */
755