2003-10-07 17:54:04 -04:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-09-04 17:56:14 -04:00
|
|
|
/* Copyright 1998, 2009 by the Massachusetts Institute of Technology.
|
2009-01-14 08:08:50 -05:00
|
|
|
* Copyright (C) 2007-2009 by Daniel Stenberg
|
2003-10-07 17:54:04 -04:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose and without
|
|
|
|
* fee is hereby granted, provided that the above copyright
|
|
|
|
* notice appear in all copies and that both that copyright
|
|
|
|
* notice and this permission notice appear in supporting
|
|
|
|
* documentation, and that the name of M.I.T. not be used in
|
|
|
|
* advertising or publicity pertaining to distribution of the
|
|
|
|
* software without specific, written prior permission.
|
|
|
|
* M.I.T. makes no representations about the suitability of
|
|
|
|
* this software for any purpose. It is provided "as is"
|
|
|
|
* without express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ARES__H
|
|
|
|
#define ARES__H
|
|
|
|
|
2009-05-17 20:21:02 -04:00
|
|
|
#include "ares_version.h" /* c-ares version defines */
|
|
|
|
#include "ares_build.h" /* c-ares build definitions */
|
|
|
|
#include "ares_rules.h" /* c-ares rules enforcement */
|
2009-04-28 12:47:33 -04:00
|
|
|
|
2007-11-08 13:13:54 -05:00
|
|
|
/*
|
|
|
|
* Define WIN32 when build target is Win32 API
|
|
|
|
*/
|
|
|
|
|
2009-10-28 21:02:54 -04:00
|
|
|
#if (defined(_WIN32) || defined(__WIN32__)) && \
|
|
|
|
!defined(WIN32) && !defined(__SYMBIAN32__)
|
|
|
|
# define WIN32
|
2007-11-08 13:13:54 -05:00
|
|
|
#endif
|
|
|
|
|
2003-10-07 17:54:04 -04:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2004-02-25 02:22:00 -05:00
|
|
|
/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
|
|
|
|
libc5-based Linux systems. Only include it on system that are known to
|
|
|
|
require it! */
|
2008-12-04 02:18:13 -05:00
|
|
|
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
|
|
|
|
defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY)
|
2004-02-23 11:20:31 -05:00
|
|
|
#include <sys/select.h>
|
|
|
|
#endif
|
2007-07-03 12:21:57 -04:00
|
|
|
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
|
|
|
|
#include <sys/bsdskt.h>
|
|
|
|
#endif
|
2004-02-23 11:20:31 -05:00
|
|
|
|
2004-08-20 09:45:26 -04:00
|
|
|
#if defined(WATT32)
|
2009-10-28 15:45:26 -04:00
|
|
|
# include <netinet/in.h>
|
|
|
|
# include <sys/socket.h>
|
|
|
|
# include <tcp.h>
|
2006-10-11 12:01:16 -04:00
|
|
|
#elif defined(WIN32)
|
2007-11-15 14:44:01 -05:00
|
|
|
# ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
# define WIN32_LEAN_AND_MEAN
|
|
|
|
# endif
|
|
|
|
# include <windows.h>
|
|
|
|
# include <winsock2.h>
|
|
|
|
# include <ws2tcpip.h>
|
2005-12-18 19:15:04 -05:00
|
|
|
#else
|
2009-10-28 15:45:26 -04:00
|
|
|
# include <sys/socket.h>
|
|
|
|
# include <netinet/in.h>
|
2003-10-07 17:54:04 -04:00
|
|
|
#endif
|
|
|
|
|
2004-11-11 07:25:40 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-10-28 15:45:26 -04:00
|
|
|
/*
|
|
|
|
** c-ares external API function linkage decorations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(CARES_STATICLIB) && \
|
2009-10-28 21:02:54 -04:00
|
|
|
(defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
|
2009-10-28 15:45:26 -04:00
|
|
|
/* __declspec function decoration for Win32 and Symbian DLL's */
|
2009-10-28 21:02:54 -04:00
|
|
|
# if defined(CARES_BUILDING_LIBRARY)
|
2009-10-28 15:45:26 -04:00
|
|
|
# define CARES_EXTERN __declspec(dllexport)
|
|
|
|
# else
|
|
|
|
# define CARES_EXTERN __declspec(dllimport)
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
/* visibility function decoration for other cases */
|
2009-10-31 00:16:40 -04:00
|
|
|
# if !defined(CARES_SYMBOL_HIDING) || \
|
2009-10-28 21:02:54 -04:00
|
|
|
defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
|
2009-10-28 15:45:26 -04:00
|
|
|
# define CARES_EXTERN
|
2009-10-28 21:02:54 -04:00
|
|
|
# else
|
2009-10-31 00:16:40 -04:00
|
|
|
# define CARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN
|
2009-10-28 15:45:26 -04:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2004-10-06 03:50:18 -04:00
|
|
|
#define ARES_SUCCESS 0
|
2003-10-07 17:54:04 -04:00
|
|
|
|
|
|
|
/* Server error codes (ARES_ENODATA indicates no relevant answer) */
|
2004-10-06 03:50:18 -04:00
|
|
|
#define ARES_ENODATA 1
|
|
|
|
#define ARES_EFORMERR 2
|
|
|
|
#define ARES_ESERVFAIL 3
|
|
|
|
#define ARES_ENOTFOUND 4
|
|
|
|
#define ARES_ENOTIMP 5
|
|
|
|
#define ARES_EREFUSED 6
|
2003-10-07 17:54:04 -04:00
|
|
|
|
|
|
|
/* Locally generated error codes */
|
2004-10-06 03:50:18 -04:00
|
|
|
#define ARES_EBADQUERY 7
|
|
|
|
#define ARES_EBADNAME 8
|
|
|
|
#define ARES_EBADFAMILY 9
|
|
|
|
#define ARES_EBADRESP 10
|
|
|
|
#define ARES_ECONNREFUSED 11
|
|
|
|
#define ARES_ETIMEOUT 12
|
|
|
|
#define ARES_EOF 13
|
|
|
|
#define ARES_EFILE 14
|
|
|
|
#define ARES_ENOMEM 15
|
|
|
|
#define ARES_EDESTRUCTION 16
|
|
|
|
#define ARES_EBADSTR 17
|
2003-10-07 17:54:04 -04:00
|
|
|
|
2005-05-16 14:06:54 -04:00
|
|
|
/* ares_getnameinfo error codes */
|
2005-08-18 04:48:31 -04:00
|
|
|
#define ARES_EBADFLAGS 18
|
2005-05-16 14:06:54 -04:00
|
|
|
|
2005-09-18 12:44:49 -04:00
|
|
|
/* ares_getaddrinfo error codes */
|
2005-12-22 10:27:41 -05:00
|
|
|
#define ARES_ENONAME 19
|
|
|
|
#define ARES_EBADHINTS 20
|
2005-09-18 12:44:49 -04:00
|
|
|
|
2009-05-26 14:00:14 -04:00
|
|
|
/* Uninitialized library error code */
|
2009-11-23 07:03:32 -05:00
|
|
|
#define ARES_ENOTINITIALIZED 21 /* introduced in 1.7.0 */
|
2009-05-26 14:00:14 -04:00
|
|
|
|
2009-05-17 13:11:28 -04:00
|
|
|
/* ares_library_init error codes */
|
2009-11-23 07:03:32 -05:00
|
|
|
#define ARES_ELOADIPHLPAPI 22 /* introduced in 1.7.0 */
|
|
|
|
#define ARES_EADDRGETNETWORKPARAMS 23 /* introduced in 1.7.0 */
|
2009-10-23 11:49:05 -04:00
|
|
|
|
|
|
|
/* More error codes */
|
2009-11-23 07:03:32 -05:00
|
|
|
#define ARES_ECANCELLED 24 /* introduced in 1.7.0 */
|
2009-05-17 13:11:28 -04:00
|
|
|
|
2003-10-07 17:54:04 -04:00
|
|
|
/* Flag values */
|
2004-10-06 03:50:18 -04:00
|
|
|
#define ARES_FLAG_USEVC (1 << 0)
|
|
|
|
#define ARES_FLAG_PRIMARY (1 << 1)
|
|
|
|
#define ARES_FLAG_IGNTC (1 << 2)
|
|
|
|
#define ARES_FLAG_NORECURSE (1 << 3)
|
|
|
|
#define ARES_FLAG_STAYOPEN (1 << 4)
|
|
|
|
#define ARES_FLAG_NOSEARCH (1 << 5)
|
|
|
|
#define ARES_FLAG_NOALIASES (1 << 6)
|
|
|
|
#define ARES_FLAG_NOCHECKRESP (1 << 7)
|
2003-10-07 17:54:04 -04:00
|
|
|
|
|
|
|
/* Option mask values */
|
2004-10-06 03:50:18 -04:00
|
|
|
#define ARES_OPT_FLAGS (1 << 0)
|
|
|
|
#define ARES_OPT_TIMEOUT (1 << 1)
|
|
|
|
#define ARES_OPT_TRIES (1 << 2)
|
|
|
|
#define ARES_OPT_NDOTS (1 << 3)
|
|
|
|
#define ARES_OPT_UDP_PORT (1 << 4)
|
|
|
|
#define ARES_OPT_TCP_PORT (1 << 5)
|
|
|
|
#define ARES_OPT_SERVERS (1 << 6)
|
|
|
|
#define ARES_OPT_DOMAINS (1 << 7)
|
|
|
|
#define ARES_OPT_LOOKUPS (1 << 8)
|
2006-05-03 02:11:44 -04:00
|
|
|
#define ARES_OPT_SOCK_STATE_CB (1 << 9)
|
2007-05-30 16:49:14 -04:00
|
|
|
#define ARES_OPT_SORTLIST (1 << 10)
|
2007-09-28 11:15:39 -04:00
|
|
|
#define ARES_OPT_SOCK_SNDBUF (1 << 11)
|
|
|
|
#define ARES_OPT_SOCK_RCVBUF (1 << 12)
|
2008-05-13 16:48:48 -04:00
|
|
|
#define ARES_OPT_TIMEOUTMS (1 << 13)
|
2008-11-01 14:35:19 -04:00
|
|
|
#define ARES_OPT_ROTATE (1 << 14)
|
2003-10-07 17:54:04 -04:00
|
|
|
|
2005-05-16 14:06:54 -04:00
|
|
|
/* Nameinfo flag values */
|
2005-08-18 04:48:31 -04:00
|
|
|
#define ARES_NI_NOFQDN (1 << 0)
|
|
|
|
#define ARES_NI_NUMERICHOST (1 << 1)
|
|
|
|
#define ARES_NI_NAMEREQD (1 << 2)
|
|
|
|
#define ARES_NI_NUMERICSERV (1 << 3)
|
|
|
|
#define ARES_NI_DGRAM (1 << 4)
|
|
|
|
#define ARES_NI_TCP 0
|
|
|
|
#define ARES_NI_UDP ARES_NI_DGRAM
|
|
|
|
#define ARES_NI_SCTP (1 << 5)
|
|
|
|
#define ARES_NI_DCCP (1 << 6)
|
|
|
|
#define ARES_NI_NUMERICSCOPE (1 << 7)
|
|
|
|
#define ARES_NI_LOOKUPHOST (1 << 8)
|
|
|
|
#define ARES_NI_LOOKUPSERVICE (1 << 9)
|
2005-05-16 14:06:54 -04:00
|
|
|
/* Reserved for future use */
|
2005-12-22 10:27:41 -05:00
|
|
|
#define ARES_NI_IDN (1 << 10)
|
|
|
|
#define ARES_NI_IDN_ALLOW_UNASSIGNED (1 << 11)
|
2005-09-18 12:44:49 -04:00
|
|
|
#define ARES_NI_IDN_USE_STD3_ASCII_RULES (1 << 12)
|
|
|
|
|
|
|
|
/* Addrinfo flag values */
|
2005-12-22 10:27:41 -05:00
|
|
|
#define ARES_AI_CANONNAME (1 << 0)
|
|
|
|
#define ARES_AI_NUMERICHOST (1 << 1)
|
|
|
|
#define ARES_AI_PASSIVE (1 << 2)
|
|
|
|
#define ARES_AI_NUMERICSERV (1 << 3)
|
|
|
|
#define ARES_AI_V4MAPPED (1 << 4)
|
|
|
|
#define ARES_AI_ALL (1 << 5)
|
|
|
|
#define ARES_AI_ADDRCONFIG (1 << 6)
|
2005-09-18 12:44:49 -04:00
|
|
|
/* Reserved for future use */
|
2005-12-22 10:27:41 -05:00
|
|
|
#define ARES_AI_IDN (1 << 10)
|
|
|
|
#define ARES_AI_IDN_ALLOW_UNASSIGNED (1 << 11)
|
2005-09-18 12:44:49 -04:00
|
|
|
#define ARES_AI_IDN_USE_STD3_ASCII_RULES (1 << 12)
|
2005-12-22 10:27:41 -05:00
|
|
|
#define ARES_AI_CANONIDN (1 << 13)
|
2005-09-18 12:44:49 -04:00
|
|
|
|
2005-12-22 10:27:41 -05:00
|
|
|
#define ARES_AI_MASK (ARES_AI_CANONNAME|ARES_AI_NUMERICHOST|ARES_AI_PASSIVE| \
|
|
|
|
ARES_AI_NUMERICSERV|ARES_AI_V4MAPPED|ARES_AI_ALL| \
|
|
|
|
ARES_AI_ADDRCONFIG)
|
|
|
|
#define ARES_GETSOCK_MAXNUM 16 /* ares_getsock() can return info about this
|
|
|
|
many sockets */
|
|
|
|
#define ARES_GETSOCK_READABLE(bits,num) (bits & (1<< (num)))
|
|
|
|
#define ARES_GETSOCK_WRITABLE(bits,num) (bits & (1 << ((num) + \
|
|
|
|
ARES_GETSOCK_MAXNUM)))
|
2005-05-16 14:06:54 -04:00
|
|
|
|
2009-05-17 13:11:28 -04:00
|
|
|
/* c-ares library initialization flag values */
|
|
|
|
#define ARES_LIB_INIT_NONE (0)
|
|
|
|
#define ARES_LIB_INIT_WIN32 (1 << 0)
|
|
|
|
#define ARES_LIB_INIT_ALL (ARES_LIB_INIT_WIN32)
|
|
|
|
|
2007-05-30 08:58:47 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Typedef our socket type
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ares_socket_typedef
|
|
|
|
#ifdef WIN32
|
|
|
|
typedef SOCKET ares_socket_t;
|
|
|
|
#define ARES_SOCKET_BAD INVALID_SOCKET
|
|
|
|
#else
|
|
|
|
typedef int ares_socket_t;
|
|
|
|
#define ARES_SOCKET_BAD -1
|
|
|
|
#endif
|
|
|
|
#define ares_socket_typedef
|
|
|
|
#endif /* ares_socket_typedef */
|
|
|
|
|
2006-05-03 02:11:44 -04:00
|
|
|
typedef void (*ares_sock_state_cb)(void *data,
|
2007-10-19 06:52:28 -04:00
|
|
|
ares_socket_t socket_fd,
|
2006-05-03 02:11:44 -04:00
|
|
|
int readable,
|
|
|
|
int writable);
|
|
|
|
|
2007-05-30 16:49:14 -04:00
|
|
|
struct apattern;
|
|
|
|
|
2008-12-03 04:59:50 -05:00
|
|
|
/* NOTE about the ares_options struct to users and developers.
|
|
|
|
|
|
|
|
This struct will remain looking like this. It will not be extended nor
|
|
|
|
shrunk in future releases, but all new options will be set by ares_set_*()
|
|
|
|
options instead of with the ares_init_options() function.
|
|
|
|
|
|
|
|
Eventually (in a galaxy far far away), all options will be settable by
|
|
|
|
ares_set_*() options and the ares_init_options() function will become
|
|
|
|
deprecated.
|
|
|
|
|
2008-12-03 05:03:07 -05:00
|
|
|
When new options are added to c-ares, they are not added to this
|
|
|
|
struct. And they are not "saved" with the ares_save_options() function but
|
|
|
|
instead we encourage the use of the ares_dup() function. Needless to say,
|
|
|
|
if you add config options to c-ares you need to make sure ares_dup()
|
|
|
|
duplicates this new option.
|
2008-12-03 04:59:50 -05:00
|
|
|
|
|
|
|
*/
|
2003-10-07 17:54:04 -04:00
|
|
|
struct ares_options {
|
|
|
|
int flags;
|
2008-05-13 16:48:48 -04:00
|
|
|
int timeout; /* in seconds or milliseconds, depending on options */
|
2003-10-07 17:54:04 -04:00
|
|
|
int tries;
|
|
|
|
int ndots;
|
|
|
|
unsigned short udp_port;
|
|
|
|
unsigned short tcp_port;
|
2007-09-28 11:15:39 -04:00
|
|
|
int socket_send_buffer_size;
|
|
|
|
int socket_receive_buffer_size;
|
2003-10-07 17:54:04 -04:00
|
|
|
struct in_addr *servers;
|
|
|
|
int nservers;
|
|
|
|
char **domains;
|
|
|
|
int ndomains;
|
|
|
|
char *lookups;
|
2006-05-03 02:11:44 -04:00
|
|
|
ares_sock_state_cb sock_state_cb;
|
|
|
|
void *sock_state_cb_data;
|
2007-05-30 16:49:14 -04:00
|
|
|
struct apattern *sortlist;
|
|
|
|
int nsort;
|
2003-10-07 17:54:04 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct hostent;
|
|
|
|
struct timeval;
|
2005-05-16 14:06:54 -04:00
|
|
|
struct sockaddr;
|
2003-10-07 17:54:04 -04:00
|
|
|
struct ares_channeldata;
|
2009-10-28 15:45:26 -04:00
|
|
|
|
2003-10-07 17:54:04 -04:00
|
|
|
typedef struct ares_channeldata *ares_channel;
|
2009-10-28 15:45:26 -04:00
|
|
|
|
|
|
|
typedef void (*ares_callback)(void *arg,
|
|
|
|
int status,
|
|
|
|
int timeouts,
|
|
|
|
unsigned char *abuf,
|
|
|
|
int alen);
|
|
|
|
|
|
|
|
typedef void (*ares_host_callback)(void *arg,
|
|
|
|
int status,
|
|
|
|
int timeouts,
|
2004-10-06 03:50:18 -04:00
|
|
|
struct hostent *hostent);
|
2009-10-28 15:45:26 -04:00
|
|
|
|
|
|
|
typedef void (*ares_nameinfo_callback)(void *arg,
|
|
|
|
int status,
|
|
|
|
int timeouts,
|
|
|
|
char *node,
|
|
|
|
char *service);
|
|
|
|
|
2008-12-04 07:53:03 -05:00
|
|
|
typedef int (*ares_sock_create_callback)(ares_socket_t socket_fd,
|
2009-10-28 15:45:26 -04:00
|
|
|
int type,
|
|
|
|
void *data);
|
|
|
|
|
|
|
|
CARES_EXTERN int ares_library_init(int flags);
|
|
|
|
|
|
|
|
CARES_EXTERN void ares_library_cleanup(void);
|
|
|
|
|
|
|
|
CARES_EXTERN const char *ares_version(int *version);
|
|
|
|
|
|
|
|
CARES_EXTERN int ares_init(ares_channel *channelptr);
|
|
|
|
|
|
|
|
CARES_EXTERN int ares_init_options(ares_channel *channelptr,
|
|
|
|
struct ares_options *options,
|
|
|
|
int optmask);
|
|
|
|
|
|
|
|
CARES_EXTERN int ares_save_options(ares_channel channel,
|
|
|
|
struct ares_options *options,
|
|
|
|
int *optmask);
|
|
|
|
|
|
|
|
CARES_EXTERN void ares_destroy_options(struct ares_options *options);
|
|
|
|
|
|
|
|
CARES_EXTERN int ares_dup(ares_channel *dest,
|
|
|
|
ares_channel src);
|
|
|
|
|
|
|
|
CARES_EXTERN void ares_destroy(ares_channel channel);
|
|
|
|
|
|
|
|
CARES_EXTERN void ares_cancel(ares_channel channel);
|
|
|
|
|
2009-11-20 09:11:06 -05:00
|
|
|
CARES_EXTERN void ares_set_socket_callback(ares_channel channel,
|
|
|
|
ares_sock_create_callback callback,
|
|
|
|
void *user_data);
|
2009-10-28 15:45:26 -04:00
|
|
|
|
|
|
|
CARES_EXTERN void ares_send(ares_channel channel,
|
|
|
|
const unsigned char *qbuf,
|
|
|
|
int qlen,
|
|
|
|
ares_callback callback,
|
|
|
|
void *arg);
|
|
|
|
|
|
|
|
CARES_EXTERN void ares_query(ares_channel channel,
|
|
|
|
const char *name,
|
|
|
|
int dnsclass,
|
|
|
|
int type,
|
|
|
|
ares_callback callback,
|
|
|
|
void *arg);
|
|
|
|
|
|
|
|
CARES_EXTERN void ares_search(ares_channel channel,
|
|
|
|
const char *name,
|
|
|
|
int dnsclass,
|
|
|
|
int type,
|
|
|
|
ares_callback callback,
|
|
|
|
void *arg);
|
|
|
|
|
|
|
|
CARES_EXTERN void ares_gethostbyname(ares_channel channel,
|
|
|
|
const char *name,
|
|
|
|
int family,
|
|
|
|
ares_host_callback callback,
|
|
|
|
void *arg);
|
|
|
|
|
|
|
|
CARES_EXTERN int ares_gethostbyname_file(ares_channel channel,
|
|
|
|
const char *name,
|
|
|
|
int family,
|
|
|
|
struct hostent **host);
|
|
|
|
|
|
|
|
CARES_EXTERN void ares_gethostbyaddr(ares_channel channel,
|
|
|
|
const void *addr,
|
|
|
|
int addrlen,
|
|
|
|
int family,
|
|
|
|
ares_host_callback callback,
|
|
|
|
void *arg);
|
|
|
|
|
|
|
|
CARES_EXTERN void ares_getnameinfo(ares_channel channel,
|
|
|
|
const struct sockaddr *sa,
|
|
|
|
ares_socklen_t salen,
|
|
|
|
int flags,
|
|
|
|
ares_nameinfo_callback callback,
|
|
|
|
void *arg);
|
|
|
|
|
|
|
|
CARES_EXTERN int ares_fds(ares_channel channel,
|
|
|
|
fd_set *read_fds,
|
|
|
|
fd_set *write_fds);
|
|
|
|
|
|
|
|
CARES_EXTERN int ares_getsock(ares_channel channel,
|
|
|
|
int *socks,
|
|
|
|
int numsocks);
|
|
|
|
|
|
|
|
CARES_EXTERN struct timeval *ares_timeout(ares_channel channel,
|
|
|
|
struct timeval *maxtv,
|
|
|
|
struct timeval *tv);
|
|
|
|
|
|
|
|
CARES_EXTERN void ares_process(ares_channel channel,
|
|
|
|
fd_set *read_fds,
|
|
|
|
fd_set *write_fds);
|
|
|
|
|
|
|
|
CARES_EXTERN void ares_process_fd(ares_channel channel,
|
|
|
|
ares_socket_t read_fd,
|
|
|
|
ares_socket_t write_fd);
|
|
|
|
|
|
|
|
CARES_EXTERN 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_string(const unsigned char *encoded,
|
|
|
|
const unsigned char *abuf,
|
|
|
|
int alen,
|
|
|
|
unsigned char **s,
|
|
|
|
long *enclen);
|
2007-11-15 03:36:25 -05:00
|
|
|
|
2009-01-14 08:08:50 -05:00
|
|
|
/*
|
2009-11-23 07:03:32 -05:00
|
|
|
* NOTE: before c-ares 1.7.0 we would most often use the system in6_addr
|
2009-01-14 08:08:50 -05:00
|
|
|
* struct below when ares itself was built, but many apps would use this
|
|
|
|
* private version since the header checked a HAVE_* define for it. Starting
|
2009-11-23 07:03:32 -05:00
|
|
|
* with 1.7.0 we always declare and use our own to stop relying on the
|
2009-01-14 08:08:50 -05:00
|
|
|
* system's one.
|
|
|
|
*/
|
|
|
|
struct ares_in6_addr {
|
2007-11-15 14:44:01 -05:00
|
|
|
union {
|
|
|
|
unsigned char _S6_u8[16];
|
|
|
|
} _S6_un;
|
|
|
|
};
|
|
|
|
|
2009-11-22 20:24:17 -05:00
|
|
|
struct ares_addrttl {
|
2007-11-15 03:36:25 -05:00
|
|
|
struct in_addr ipaddr;
|
|
|
|
int ttl;
|
|
|
|
};
|
2009-11-22 20:24:17 -05:00
|
|
|
|
|
|
|
struct ares_addr6ttl {
|
2009-01-14 08:08:50 -05:00
|
|
|
struct ares_in6_addr ip6addr;
|
2007-11-15 03:36:25 -05:00
|
|
|
int ttl;
|
|
|
|
};
|
|
|
|
|
2009-10-29 04:50:34 -04:00
|
|
|
struct ares_srv_reply {
|
2009-11-20 03:50:03 -05:00
|
|
|
struct ares_srv_reply *next;
|
|
|
|
char *host;
|
|
|
|
unsigned short priority;
|
|
|
|
unsigned short weight;
|
|
|
|
unsigned short port;
|
2009-09-04 17:56:14 -04:00
|
|
|
};
|
|
|
|
|
2009-10-29 04:59:40 -04:00
|
|
|
struct ares_txt_reply {
|
2009-11-20 03:50:03 -05:00
|
|
|
struct ares_txt_reply *next;
|
|
|
|
unsigned char *txt;
|
|
|
|
size_t length; /* length excludes null termination */
|
2009-10-29 04:59:40 -04:00
|
|
|
};
|
|
|
|
|
2007-11-15 03:36:25 -05:00
|
|
|
/*
|
|
|
|
** Parse the buffer, starting at *abuf and of length alen bytes, previously
|
|
|
|
** obtained from an ares_search call. Put the results in *host, if nonnull.
|
|
|
|
** Also, if addrttls is nonnull, put up to *naddrttls IPv4 addresses along with
|
|
|
|
** their TTLs in that array, and set *naddrttls to the number of addresses
|
|
|
|
** so written.
|
|
|
|
*/
|
2009-10-28 15:45:26 -04:00
|
|
|
|
|
|
|
CARES_EXTERN int ares_parse_a_reply(const unsigned char *abuf,
|
|
|
|
int alen,
|
|
|
|
struct hostent **host,
|
2009-11-22 20:24:17 -05:00
|
|
|
struct ares_addrttl *addrttls,
|
2009-10-28 15:45:26 -04:00
|
|
|
int *naddrttls);
|
|
|
|
|
|
|
|
CARES_EXTERN int ares_parse_aaaa_reply(const unsigned char *abuf,
|
|
|
|
int alen,
|
|
|
|
struct hostent **host,
|
2009-11-22 20:24:17 -05:00
|
|
|
struct ares_addr6ttl *addrttls,
|
2009-10-28 15:45:26 -04:00
|
|
|
int *naddrttls);
|
|
|
|
|
|
|
|
CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf,
|
|
|
|
int alen,
|
|
|
|
const void *addr,
|
|
|
|
int addrlen,
|
|
|
|
int family,
|
|
|
|
struct hostent **host);
|
|
|
|
|
|
|
|
CARES_EXTERN int ares_parse_ns_reply(const unsigned char *abuf,
|
|
|
|
int alen,
|
|
|
|
struct hostent **host);
|
|
|
|
|
|
|
|
CARES_EXTERN int ares_parse_srv_reply(const unsigned char* abuf,
|
|
|
|
int alen,
|
2009-11-20 04:06:33 -05:00
|
|
|
struct ares_srv_reply** srv_out);
|
2009-10-28 15:45:26 -04:00
|
|
|
|
2009-10-29 04:59:40 -04:00
|
|
|
CARES_EXTERN int ares_parse_txt_reply(const unsigned char* abuf,
|
|
|
|
int alen,
|
2009-11-20 04:06:33 -05:00
|
|
|
struct ares_txt_reply** txt_out);
|
2009-10-29 04:59:40 -04:00
|
|
|
|
2009-10-28 15:45:26 -04:00
|
|
|
CARES_EXTERN void ares_free_string(void *str);
|
|
|
|
|
|
|
|
CARES_EXTERN void ares_free_hostent(struct hostent *host);
|
|
|
|
|
2009-11-20 03:50:03 -05:00
|
|
|
CARES_EXTERN void ares_free_data(void *dataptr);
|
|
|
|
|
2009-10-28 15:45:26 -04:00
|
|
|
CARES_EXTERN const char *ares_strerror(int code);
|
2003-10-07 17:54:04 -04:00
|
|
|
|
2004-11-11 07:25:40 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-10-07 17:54:04 -04:00
|
|
|
#endif /* ARES__H */
|