Blame ares.h

Packit 514978
Packit 514978
/* Copyright 1998 by the Massachusetts Institute of Technology.
Packit 514978
 * Copyright (C) 2007-2013 by Daniel Stenberg
Packit 514978
 *
Packit 514978
 * Permission to use, copy, modify, and distribute this
Packit 514978
 * software and its documentation for any purpose and without
Packit 514978
 * fee is hereby granted, provided that the above copyright
Packit 514978
 * notice appear in all copies and that both that copyright
Packit 514978
 * notice and this permission notice appear in supporting
Packit 514978
 * documentation, and that the name of M.I.T. not be used in
Packit 514978
 * advertising or publicity pertaining to distribution of the
Packit 514978
 * software without specific, written prior permission.
Packit 514978
 * M.I.T. makes no representations about the suitability of
Packit 514978
 * this software for any purpose.  It is provided "as is"
Packit 514978
 * without express or implied warranty.
Packit 514978
 */
Packit 514978
Packit 514978
#ifndef ARES__H
Packit 514978
#define ARES__H
Packit 514978
Packit 514978
#include "ares_version.h"  /* c-ares version defines   */
Packit 514978
#include "ares_build.h"    /* c-ares build definitions */
Packit 514978
#include "ares_rules.h"    /* c-ares rules enforcement */
Packit 514978
Packit 514978
/*
Packit 514978
 * Define WIN32 when build target is Win32 API
Packit 514978
 */
Packit 514978
Packit 514978
#if (defined(_WIN32) || defined(__WIN32__)) && \
Packit 514978
   !defined(WIN32) && !defined(__SYMBIAN32__)
Packit 514978
#  define WIN32
Packit 514978
#endif
Packit 514978
Packit 514978
#include <sys/types.h>
Packit 514978
Packit 514978
/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
Packit 514978
   libc5-based Linux systems. Only include it on system that are known to
Packit 514978
   require it! */
Packit 514978
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
Packit 514978
    defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \
Packit 514978
    defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \
Packit 514978
    defined(__QNXNTO__)
Packit 514978
#include <sys/select.h>
Packit 514978
#endif
Packit 514978
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
Packit 514978
#include <sys/bsdskt.h>
Packit 514978
#endif
Packit 514978
Packit 514978
#if defined(WATT32)
Packit 514978
#  include <netinet/in.h>
Packit 514978
#  include <sys/socket.h>
Packit 514978
#  include <tcp.h>
Packit 514978
#elif defined(_WIN32_WCE)
Packit 514978
#  ifndef WIN32_LEAN_AND_MEAN
Packit 514978
#    define WIN32_LEAN_AND_MEAN
Packit 514978
#  endif
Packit 514978
#  include <windows.h>
Packit 514978
#  include <winsock.h>
Packit 514978
#elif defined(WIN32)
Packit 514978
#  ifndef WIN32_LEAN_AND_MEAN
Packit 514978
#    define WIN32_LEAN_AND_MEAN
Packit 514978
#  endif
Packit 514978
#  include <windows.h>
Packit 514978
#  include <winsock2.h>
Packit 514978
#  include <ws2tcpip.h>
Packit 514978
#else
Packit 514978
#  include <sys/socket.h>
Packit 514978
#  include <netinet/in.h>
Packit 514978
#endif
Packit 514978
Packit 514978
#ifdef  __cplusplus
Packit 514978
extern "C" {
Packit 514978
#endif
Packit 514978
Packit 514978
/*
Packit 514978
** c-ares external API function linkage decorations.
Packit 514978
*/
Packit 514978
Packit 514978
#ifdef CARES_STATICLIB
Packit 514978
#  define CARES_EXTERN
Packit 514978
#elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
Packit 514978
#  if defined(CARES_BUILDING_LIBRARY)
Packit 514978
#    define CARES_EXTERN  __declspec(dllexport)
Packit 514978
#  else
Packit 514978
#    define CARES_EXTERN  __declspec(dllimport)
Packit 514978
#  endif
Packit 514978
#elif defined(CARES_BUILDING_LIBRARY) && defined(CARES_SYMBOL_HIDING)
Packit 514978
#  define CARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN
Packit 514978
#else
Packit 514978
#  define CARES_EXTERN
Packit 514978
#endif
Packit 514978
Packit 514978
Packit 514978
#define ARES_SUCCESS            0
Packit 514978
Packit 514978
/* Server error codes (ARES_ENODATA indicates no relevant answer) */
Packit 514978
#define ARES_ENODATA            1
Packit 514978
#define ARES_EFORMERR           2
Packit 514978
#define ARES_ESERVFAIL          3
Packit 514978
#define ARES_ENOTFOUND          4
Packit 514978
#define ARES_ENOTIMP            5
Packit 514978
#define ARES_EREFUSED           6
Packit 514978
Packit 514978
/* Locally generated error codes */
Packit 514978
#define ARES_EBADQUERY          7
Packit 514978
#define ARES_EBADNAME           8
Packit 514978
#define ARES_EBADFAMILY         9
Packit 514978
#define ARES_EBADRESP           10
Packit 514978
#define ARES_ECONNREFUSED       11
Packit 514978
#define ARES_ETIMEOUT           12
Packit 514978
#define ARES_EOF                13
Packit 514978
#define ARES_EFILE              14
Packit 514978
#define ARES_ENOMEM             15
Packit 514978
#define ARES_EDESTRUCTION       16
Packit 514978
#define ARES_EBADSTR            17
Packit 514978
Packit 514978
/* ares_getnameinfo error codes */
Packit 514978
#define ARES_EBADFLAGS          18
Packit 514978
Packit 514978
/* ares_getaddrinfo error codes */
Packit 514978
#define ARES_ENONAME            19
Packit 514978
#define ARES_EBADHINTS          20
Packit 514978
Packit 514978
/* Uninitialized library error code */
Packit 514978
#define ARES_ENOTINITIALIZED    21          /* introduced in 1.7.0 */
Packit 514978
Packit 514978
/* ares_library_init error codes */
Packit 514978
#define ARES_ELOADIPHLPAPI           22     /* introduced in 1.7.0 */
Packit 514978
#define ARES_EADDRGETNETWORKPARAMS   23     /* introduced in 1.7.0 */
Packit 514978
Packit 514978
/* More error codes */
Packit 514978
#define ARES_ECANCELLED         24          /* introduced in 1.7.0 */
Packit 514978
Packit 514978
/* Flag values */
Packit 514978
#define ARES_FLAG_USEVC         (1 << 0)
Packit 514978
#define ARES_FLAG_PRIMARY       (1 << 1)
Packit 514978
#define ARES_FLAG_IGNTC         (1 << 2)
Packit 514978
#define ARES_FLAG_NORECURSE     (1 << 3)
Packit 514978
#define ARES_FLAG_STAYOPEN      (1 << 4)
Packit 514978
#define ARES_FLAG_NOSEARCH      (1 << 5)
Packit 514978
#define ARES_FLAG_NOALIASES     (1 << 6)
Packit 514978
#define ARES_FLAG_NOCHECKRESP   (1 << 7)
Packit 514978
#define ARES_FLAG_EDNS          (1 << 8)
Packit 514978
Packit 514978
/* Option mask values */
Packit 514978
#define ARES_OPT_FLAGS          (1 << 0)
Packit 514978
#define ARES_OPT_TIMEOUT        (1 << 1)
Packit 514978
#define ARES_OPT_TRIES          (1 << 2)
Packit 514978
#define ARES_OPT_NDOTS          (1 << 3)
Packit 514978
#define ARES_OPT_UDP_PORT       (1 << 4)
Packit 514978
#define ARES_OPT_TCP_PORT       (1 << 5)
Packit 514978
#define ARES_OPT_SERVERS        (1 << 6)
Packit 514978
#define ARES_OPT_DOMAINS        (1 << 7)
Packit 514978
#define ARES_OPT_LOOKUPS        (1 << 8)
Packit 514978
#define ARES_OPT_SOCK_STATE_CB  (1 << 9)
Packit 514978
#define ARES_OPT_SORTLIST       (1 << 10)
Packit 514978
#define ARES_OPT_SOCK_SNDBUF    (1 << 11)
Packit 514978
#define ARES_OPT_SOCK_RCVBUF    (1 << 12)
Packit 514978
#define ARES_OPT_TIMEOUTMS      (1 << 13)
Packit 514978
#define ARES_OPT_ROTATE         (1 << 14)
Packit 514978
#define ARES_OPT_EDNSPSZ        (1 << 15)
Packit 514978
#define ARES_OPT_NOROTATE       (1 << 16)
Packit 514978
Packit 514978
/* Nameinfo flag values */
Packit 514978
#define ARES_NI_NOFQDN                  (1 << 0)
Packit 514978
#define ARES_NI_NUMERICHOST             (1 << 1)
Packit 514978
#define ARES_NI_NAMEREQD                (1 << 2)
Packit 514978
#define ARES_NI_NUMERICSERV             (1 << 3)
Packit 514978
#define ARES_NI_DGRAM                   (1 << 4)
Packit 514978
#define ARES_NI_TCP                     0
Packit 514978
#define ARES_NI_UDP                     ARES_NI_DGRAM
Packit 514978
#define ARES_NI_SCTP                    (1 << 5)
Packit 514978
#define ARES_NI_DCCP                    (1 << 6)
Packit 514978
#define ARES_NI_NUMERICSCOPE            (1 << 7)
Packit 514978
#define ARES_NI_LOOKUPHOST              (1 << 8)
Packit 514978
#define ARES_NI_LOOKUPSERVICE           (1 << 9)
Packit 514978
/* Reserved for future use */
Packit 514978
#define ARES_NI_IDN                     (1 << 10)
Packit 514978
#define ARES_NI_IDN_ALLOW_UNASSIGNED    (1 << 11)
Packit 514978
#define ARES_NI_IDN_USE_STD3_ASCII_RULES (1 << 12)
Packit 514978
Packit 514978
/* Addrinfo flag values */
Packit 514978
#define ARES_AI_CANONNAME               (1 << 0)
Packit 514978
#define ARES_AI_NUMERICHOST             (1 << 1)
Packit 514978
#define ARES_AI_PASSIVE                 (1 << 2)
Packit 514978
#define ARES_AI_NUMERICSERV             (1 << 3)
Packit 514978
#define ARES_AI_V4MAPPED                (1 << 4)
Packit 514978
#define ARES_AI_ALL                     (1 << 5)
Packit 514978
#define ARES_AI_ADDRCONFIG              (1 << 6)
Packit 514978
/* Reserved for future use */
Packit 514978
#define ARES_AI_IDN                     (1 << 10)
Packit 514978
#define ARES_AI_IDN_ALLOW_UNASSIGNED    (1 << 11)
Packit 514978
#define ARES_AI_IDN_USE_STD3_ASCII_RULES (1 << 12)
Packit 514978
#define ARES_AI_CANONIDN                (1 << 13)
Packit 514978
Packit 514978
#define ARES_AI_MASK (ARES_AI_CANONNAME|ARES_AI_NUMERICHOST|ARES_AI_PASSIVE| \
Packit 514978
                      ARES_AI_NUMERICSERV|ARES_AI_V4MAPPED|ARES_AI_ALL| \
Packit 514978
                      ARES_AI_ADDRCONFIG)
Packit 514978
#define ARES_GETSOCK_MAXNUM 16 /* ares_getsock() can return info about this
Packit 514978
                                  many sockets */
Packit 514978
#define ARES_GETSOCK_READABLE(bits,num) (bits & (1<< (num)))
Packit 514978
#define ARES_GETSOCK_WRITABLE(bits,num) (bits & (1 << ((num) + \
Packit 514978
                                         ARES_GETSOCK_MAXNUM)))
Packit 514978
Packit 514978
/* c-ares library initialization flag values */
Packit 514978
#define ARES_LIB_INIT_NONE   (0)
Packit 514978
#define ARES_LIB_INIT_WIN32  (1 << 0)
Packit 514978
#define ARES_LIB_INIT_ALL    (ARES_LIB_INIT_WIN32)
Packit 514978
Packit 514978
Packit 514978
/*
Packit 514978
 * Typedef our socket type
Packit 514978
 */
Packit 514978
Packit 514978
#ifndef ares_socket_typedef
Packit 514978
#ifdef WIN32
Packit 514978
typedef SOCKET ares_socket_t;
Packit 514978
#define ARES_SOCKET_BAD INVALID_SOCKET
Packit 514978
#else
Packit 514978
typedef int ares_socket_t;
Packit 514978
#define ARES_SOCKET_BAD -1
Packit 514978
#endif
Packit 514978
#define ares_socket_typedef
Packit 514978
#endif /* ares_socket_typedef */
Packit 514978
Packit 514978
typedef void (*ares_sock_state_cb)(void *data,
Packit 514978
                                   ares_socket_t socket_fd,
Packit 514978
                                   int readable,
Packit 514978
                                   int writable);
Packit 514978
Packit 514978
struct apattern;
Packit 514978
Packit 514978
/* NOTE about the ares_options struct to users and developers.
Packit 514978
Packit 514978
   This struct will remain looking like this. It will not be extended nor
Packit 514978
   shrunk in future releases, but all new options will be set by ares_set_*()
Packit 514978
   options instead of with the ares_init_options() function.
Packit 514978
Packit 514978
   Eventually (in a galaxy far far away), all options will be settable by
Packit 514978
   ares_set_*() options and the ares_init_options() function will become
Packit 514978
   deprecated.
Packit 514978
Packit 514978
   When new options are added to c-ares, they are not added to this
Packit 514978
   struct. And they are not "saved" with the ares_save_options() function but
Packit 514978
   instead we encourage the use of the ares_dup() function. Needless to say,
Packit 514978
   if you add config options to c-ares you need to make sure ares_dup()
Packit 514978
   duplicates this new option.
Packit 514978
Packit 514978
 */
Packit 514978
struct ares_options {
Packit 514978
  int flags;
Packit 514978
  int timeout; /* in seconds or milliseconds, depending on options */
Packit 514978
  int tries;
Packit 514978
  int ndots;
Packit 514978
  unsigned short udp_port;
Packit 514978
  unsigned short tcp_port;
Packit 514978
  int socket_send_buffer_size;
Packit 514978
  int socket_receive_buffer_size;
Packit 514978
  struct in_addr *servers;
Packit 514978
  int nservers;
Packit 514978
  char **domains;
Packit 514978
  int ndomains;
Packit 514978
  char *lookups;
Packit 514978
  ares_sock_state_cb sock_state_cb;
Packit 514978
  void *sock_state_cb_data;
Packit 514978
  struct apattern *sortlist;
Packit 514978
  int nsort;
Packit 514978
  int ednspsz;
Packit 514978
};
Packit 514978
Packit 514978
struct hostent;
Packit 514978
struct timeval;
Packit 514978
struct sockaddr;
Packit 514978
struct ares_channeldata;
Packit 514978
Packit 514978
typedef struct ares_channeldata *ares_channel;
Packit 514978
Packit 514978
typedef void (*ares_callback)(void *arg,
Packit 514978
                              int status,
Packit 514978
                              int timeouts,
Packit 514978
                              unsigned char *abuf,
Packit 514978
                              int alen);
Packit 514978
Packit 514978
typedef void (*ares_host_callback)(void *arg,
Packit 514978
                                   int status,
Packit 514978
                                   int timeouts,
Packit 514978
                                   struct hostent *hostent);
Packit 514978
Packit 514978
typedef void (*ares_nameinfo_callback)(void *arg,
Packit 514978
                                       int status,
Packit 514978
                                       int timeouts,
Packit 514978
                                       char *node,
Packit 514978
                                       char *service);
Packit 514978
Packit 514978
typedef int  (*ares_sock_create_callback)(ares_socket_t socket_fd,
Packit 514978
                                          int type,
Packit 514978
                                          void *data);
Packit 514978
Packit 514978
typedef int  (*ares_sock_config_callback)(ares_socket_t socket_fd,
Packit 514978
                                          int type,
Packit 514978
                                          void *data);
Packit 514978
Packit 514978
CARES_EXTERN int ares_library_init(int flags);
Packit 514978
Packit 514978
CARES_EXTERN int ares_library_init_mem(int flags,
Packit 514978
                                       void *(*amalloc)(size_t size),
Packit 514978
                                       void (*afree)(void *ptr),
Packit 514978
                                       void *(*arealloc)(void *ptr, size_t size));
Packit 514978
Packit 514978
CARES_EXTERN int ares_library_initialized(void);
Packit 514978
Packit 514978
CARES_EXTERN void ares_library_cleanup(void);
Packit 514978
Packit 514978
CARES_EXTERN const char *ares_version(int *version);
Packit 514978
Packit 514978
CARES_EXTERN int ares_init(ares_channel *channelptr);
Packit 514978
Packit 514978
CARES_EXTERN int ares_init_options(ares_channel *channelptr,
Packit 514978
                                   struct ares_options *options,
Packit 514978
                                   int optmask);
Packit 514978
Packit 514978
CARES_EXTERN int ares_save_options(ares_channel channel,
Packit 514978
                                   struct ares_options *options,
Packit 514978
                                   int *optmask);
Packit 514978
Packit 514978
CARES_EXTERN void ares_destroy_options(struct ares_options *options);
Packit 514978
Packit 514978
CARES_EXTERN int ares_dup(ares_channel *dest,
Packit 514978
                          ares_channel src);
Packit 514978
Packit 514978
CARES_EXTERN void ares_destroy(ares_channel channel);
Packit 514978
Packit 514978
CARES_EXTERN void ares_cancel(ares_channel channel);
Packit 514978
Packit 514978
/* These next 3 configure local binding for the out-going socket
Packit 514978
 * connection.  Use these to specify source IP and/or network device
Packit 514978
 * on multi-homed systems.
Packit 514978
 */
Packit 514978
CARES_EXTERN void ares_set_local_ip4(ares_channel channel, unsigned int local_ip);
Packit 514978
Packit 514978
/* local_ip6 should be 16 bytes in length */
Packit 514978
CARES_EXTERN void ares_set_local_ip6(ares_channel channel,
Packit 514978
                                     const unsigned char* local_ip6);
Packit 514978
Packit 514978
/* local_dev_name should be null terminated. */
Packit 514978
CARES_EXTERN void ares_set_local_dev(ares_channel channel,
Packit 514978
                                     const char* local_dev_name);
Packit 514978
Packit 514978
CARES_EXTERN void ares_set_socket_callback(ares_channel channel,
Packit 514978
                                           ares_sock_create_callback callback,
Packit 514978
                                           void *user_data);
Packit 514978
Packit 514978
CARES_EXTERN void ares_set_socket_configure_callback(ares_channel channel,
Packit 514978
                                                     ares_sock_config_callback callback,
Packit 514978
                                                     void *user_data);
Packit 514978
Packit 514978
CARES_EXTERN int ares_set_sortlist(ares_channel channel,
Packit 514978
                                   const char *sortstr);
Packit 514978
Packit 514978
/*
Packit 514978
 * Virtual function set to have user-managed socket IO.
Packit 514978
 * Note that all functions need to be defined, and when
Packit 514978
 * set, the library will not do any bind nor set any
Packit 514978
 * socket options, assuming the client handles these
Packit 514978
 * through either socket creation or the
Packit 514978
 * ares_sock_config_callback call.
Packit 514978
 */
Packit 514978
struct iovec;
Packit 514978
struct ares_socket_functions {
Packit 514978
   ares_socket_t(*asocket)(int, int, int, void *);
Packit 514978
   int(*aclose)(ares_socket_t, void *);
Packit 514978
   int(*aconnect)(ares_socket_t, const struct sockaddr *, ares_socklen_t, void *);
Packit 514978
   ares_ssize_t(*arecvfrom)(ares_socket_t, void *, size_t, int, struct sockaddr *, ares_socklen_t *, void *);
Packit 514978
   ares_ssize_t(*asendv)(ares_socket_t, const struct iovec *, int, void *);
Packit 514978
};
Packit 514978
Packit 514978
CARES_EXTERN void ares_set_socket_functions(ares_channel channel,
Packit 514978
					    const struct ares_socket_functions * funcs,
Packit 514978
					    void *user_data);
Packit 514978
Packit 514978
CARES_EXTERN void ares_send(ares_channel channel,
Packit 514978
                            const unsigned char *qbuf,
Packit 514978
                            int qlen,
Packit 514978
                            ares_callback callback,
Packit 514978
                            void *arg);
Packit 514978
Packit 514978
CARES_EXTERN void ares_query(ares_channel channel,
Packit 514978
                             const char *name,
Packit 514978
                             int dnsclass,
Packit 514978
                             int type,
Packit 514978
                             ares_callback callback,
Packit 514978
                             void *arg);
Packit 514978
Packit 514978
CARES_EXTERN void ares_search(ares_channel channel,
Packit 514978
                              const char *name,
Packit 514978
                              int dnsclass,
Packit 514978
                              int type,
Packit 514978
                              ares_callback callback,
Packit 514978
                              void *arg);
Packit 514978
Packit 514978
CARES_EXTERN void ares_gethostbyname(ares_channel channel,
Packit 514978
                                     const char *name,
Packit 514978
                                     int family,
Packit 514978
                                     ares_host_callback callback,
Packit 514978
                                     void *arg);
Packit 514978
Packit 514978
CARES_EXTERN int ares_gethostbyname_file(ares_channel channel,
Packit 514978
                                         const char *name,
Packit 514978
                                         int family,
Packit 514978
                                         struct hostent **host);
Packit 514978
Packit 514978
CARES_EXTERN void ares_gethostbyaddr(ares_channel channel,
Packit 514978
                                     const void *addr,
Packit 514978
                                     int addrlen,
Packit 514978
                                     int family,
Packit 514978
                                     ares_host_callback callback,
Packit 514978
                                     void *arg);
Packit 514978
Packit 514978
CARES_EXTERN void ares_getnameinfo(ares_channel channel,
Packit 514978
                                   const struct sockaddr *sa,
Packit 514978
                                   ares_socklen_t salen,
Packit 514978
                                   int flags,
Packit 514978
                                   ares_nameinfo_callback callback,
Packit 514978
                                   void *arg);
Packit 514978
Packit 514978
CARES_EXTERN int ares_fds(ares_channel channel,
Packit 514978
                          fd_set *read_fds,
Packit 514978
                          fd_set *write_fds);
Packit 514978
Packit 514978
CARES_EXTERN int ares_getsock(ares_channel channel,
Packit 514978
                              ares_socket_t *socks,
Packit 514978
                              int numsocks);
Packit 514978
Packit 514978
CARES_EXTERN struct timeval *ares_timeout(ares_channel channel,
Packit 514978
                                          struct timeval *maxtv,
Packit 514978
                                          struct timeval *tv);
Packit 514978
Packit 514978
CARES_EXTERN void ares_process(ares_channel channel,
Packit 514978
                               fd_set *read_fds,
Packit 514978
                               fd_set *write_fds);
Packit 514978
Packit 514978
CARES_EXTERN void ares_process_fd(ares_channel channel,
Packit 514978
                                  ares_socket_t read_fd,
Packit 514978
                                  ares_socket_t write_fd);
Packit 514978
Packit 514978
CARES_EXTERN int ares_create_query(const char *name,
Packit 514978
                                   int dnsclass,
Packit 514978
                                   int type,
Packit 514978
                                   unsigned short id,
Packit 514978
                                   int rd,
Packit 514978
                                   unsigned char **buf,
Packit 514978
                                   int *buflen,
Packit 514978
                                   int max_udp_size);
Packit 514978
Packit 514978
CARES_EXTERN int ares_mkquery(const char *name,
Packit 514978
                              int dnsclass,
Packit 514978
                              int type,
Packit 514978
                              unsigned short id,
Packit 514978
                              int rd,
Packit 514978
                              unsigned char **buf,
Packit 514978
                              int *buflen);
Packit 514978
Packit 514978
CARES_EXTERN int ares_expand_name(const unsigned char *encoded,
Packit 514978
                                  const unsigned char *abuf,
Packit 514978
                                  int alen,
Packit 514978
                                  char **s,
Packit 514978
                                  long *enclen);
Packit 514978
Packit 514978
CARES_EXTERN int ares_expand_string(const unsigned char *encoded,
Packit 514978
                                    const unsigned char *abuf,
Packit 514978
                                    int alen,
Packit 514978
                                    unsigned char **s,
Packit 514978
                                    long *enclen);
Packit 514978
Packit 514978
/*
Packit 514978
 * NOTE: before c-ares 1.7.0 we would most often use the system in6_addr
Packit 514978
 * struct below when ares itself was built, but many apps would use this
Packit 514978
 * private version since the header checked a HAVE_* define for it. Starting
Packit 514978
 * with 1.7.0 we always declare and use our own to stop relying on the
Packit 514978
 * system's one.
Packit 514978
 */
Packit 514978
struct ares_in6_addr {
Packit 514978
  union {
Packit 514978
    unsigned char _S6_u8[16];
Packit 514978
  } _S6_un;
Packit 514978
};
Packit 514978
Packit 514978
struct ares_addrttl {
Packit 514978
  struct in_addr ipaddr;
Packit 514978
  int            ttl;
Packit 514978
};
Packit 514978
Packit 514978
struct ares_addr6ttl {
Packit 514978
  struct ares_in6_addr ip6addr;
Packit 514978
  int             ttl;
Packit 514978
};
Packit 514978
Packit 514978
struct ares_srv_reply {
Packit 514978
  struct ares_srv_reply  *next;
Packit 514978
  char                   *host;
Packit 514978
  unsigned short          priority;
Packit 514978
  unsigned short          weight;
Packit 514978
  unsigned short          port;
Packit 514978
};
Packit 514978
Packit 514978
struct ares_mx_reply {
Packit 514978
  struct ares_mx_reply   *next;
Packit 514978
  char                   *host;
Packit 514978
  unsigned short          priority;
Packit 514978
};
Packit 514978
Packit 514978
struct ares_txt_reply {
Packit 514978
  struct ares_txt_reply  *next;
Packit 514978
  unsigned char          *txt;
Packit 514978
  size_t                  length;  /* length excludes null termination */
Packit 514978
};
Packit 514978
Packit 514978
/* NOTE: This structure is a superset of ares_txt_reply
Packit 514978
 */
Packit 514978
struct ares_txt_ext {
Packit 514978
  struct ares_txt_ext      *next;
Packit 514978
  unsigned char            *txt;
Packit 514978
  size_t                   length;
Packit 514978
  /* 1 - if start of new record
Packit 514978
   * 0 - if a chunk in the same record */
Packit 514978
  unsigned char            record_start;
Packit 514978
};
Packit 514978
Packit 514978
struct ares_naptr_reply {
Packit 514978
  struct ares_naptr_reply *next;
Packit 514978
  unsigned char           *flags;
Packit 514978
  unsigned char           *service;
Packit 514978
  unsigned char           *regexp;
Packit 514978
  char                    *replacement;
Packit 514978
  unsigned short           order;
Packit 514978
  unsigned short           preference;
Packit 514978
};
Packit 514978
Packit 514978
struct ares_soa_reply {
Packit 514978
  char        *nsname;
Packit 514978
  char        *hostmaster;
Packit 514978
  unsigned int serial;
Packit 514978
  unsigned int refresh;
Packit 514978
  unsigned int retry;
Packit 514978
  unsigned int expire;
Packit 514978
  unsigned int minttl;
Packit 514978
};
Packit 514978
Packit 514978
/*
Packit 514978
** Parse the buffer, starting at *abuf and of length alen bytes, previously
Packit 514978
** obtained from an ares_search call.  Put the results in *host, if nonnull.
Packit 514978
** Also, if addrttls is nonnull, put up to *naddrttls IPv4 addresses along with
Packit 514978
** their TTLs in that array, and set *naddrttls to the number of addresses
Packit 514978
** so written.
Packit 514978
*/
Packit 514978
Packit 514978
CARES_EXTERN int ares_parse_a_reply(const unsigned char *abuf,
Packit 514978
                                    int alen,
Packit 514978
                                    struct hostent **host,
Packit 514978
                                    struct ares_addrttl *addrttls,
Packit 514978
                                    int *naddrttls);
Packit 514978
Packit 514978
CARES_EXTERN int ares_parse_aaaa_reply(const unsigned char *abuf,
Packit 514978
                                       int alen,
Packit 514978
                                       struct hostent **host,
Packit 514978
                                       struct ares_addr6ttl *addrttls,
Packit 514978
                                       int *naddrttls);
Packit 514978
Packit 514978
CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf,
Packit 514978
                                      int alen,
Packit 514978
                                      const void *addr,
Packit 514978
                                      int addrlen,
Packit 514978
                                      int family,
Packit 514978
                                      struct hostent **host);
Packit 514978
Packit 514978
CARES_EXTERN int ares_parse_ns_reply(const unsigned char *abuf,
Packit 514978
                                     int alen,
Packit 514978
                                     struct hostent **host);
Packit 514978
Packit 514978
CARES_EXTERN int ares_parse_srv_reply(const unsigned char* abuf,
Packit 514978
                                      int alen,
Packit 514978
                                      struct ares_srv_reply** srv_out);
Packit 514978
Packit 514978
CARES_EXTERN int ares_parse_mx_reply(const unsigned char* abuf,
Packit 514978
                                      int alen,
Packit 514978
                                      struct ares_mx_reply** mx_out);
Packit 514978
Packit 514978
CARES_EXTERN int ares_parse_txt_reply(const unsigned char* abuf,
Packit 514978
                                      int alen,
Packit 514978
                                      struct ares_txt_reply** txt_out);
Packit 514978
Packit 514978
CARES_EXTERN int ares_parse_txt_reply_ext(const unsigned char* abuf,
Packit 514978
                                          int alen,
Packit 514978
                                          struct ares_txt_ext** txt_out);
Packit 514978
Packit 514978
CARES_EXTERN int ares_parse_naptr_reply(const unsigned char* abuf,
Packit 514978
                                        int alen,
Packit 514978
                                        struct ares_naptr_reply** naptr_out);
Packit 514978
Packit 514978
CARES_EXTERN int ares_parse_soa_reply(const unsigned char* abuf,
Packit 514978
				      int alen,
Packit 514978
				      struct ares_soa_reply** soa_out);
Packit 514978
Packit 514978
CARES_EXTERN void ares_free_string(void *str);
Packit 514978
Packit 514978
CARES_EXTERN void ares_free_hostent(struct hostent *host);
Packit 514978
Packit 514978
CARES_EXTERN void ares_free_data(void *dataptr);
Packit 514978
Packit 514978
CARES_EXTERN const char *ares_strerror(int code);
Packit 514978
Packit 514978
struct ares_addr_node {
Packit 514978
  struct ares_addr_node *next;
Packit 514978
  int family;
Packit 514978
  union {
Packit 514978
    struct in_addr       addr4;
Packit 514978
    struct ares_in6_addr addr6;
Packit 514978
  } addr;
Packit 514978
};
Packit 514978
Packit 514978
struct ares_addr_port_node {
Packit 514978
  struct ares_addr_port_node *next;
Packit 514978
  int family;
Packit 514978
  union {
Packit 514978
    struct in_addr       addr4;
Packit 514978
    struct ares_in6_addr addr6;
Packit 514978
  } addr;
Packit 514978
  int udp_port;
Packit 514978
  int tcp_port;
Packit 514978
};
Packit 514978
Packit 514978
CARES_EXTERN int ares_set_servers(ares_channel channel,
Packit 514978
                                  struct ares_addr_node *servers);
Packit 514978
CARES_EXTERN int ares_set_servers_ports(ares_channel channel,
Packit 514978
                                        struct ares_addr_port_node *servers);
Packit 514978
Packit 514978
/* Incomming string format: host[:port][,host[:port]]... */
Packit 514978
CARES_EXTERN int ares_set_servers_csv(ares_channel channel,
Packit 514978
                                      const char* servers);
Packit 514978
CARES_EXTERN int ares_set_servers_ports_csv(ares_channel channel,
Packit 514978
                                            const char* servers);
Packit 514978
Packit 514978
CARES_EXTERN int ares_get_servers(ares_channel channel,
Packit 514978
                                  struct ares_addr_node **servers);
Packit 514978
CARES_EXTERN int ares_get_servers_ports(ares_channel channel,
Packit 514978
                                        struct ares_addr_port_node **servers);
Packit 514978
Packit 514978
CARES_EXTERN const char *ares_inet_ntop(int af, const void *src, char *dst,
Packit 514978
                                        ares_socklen_t size);
Packit 514978
Packit 514978
CARES_EXTERN int ares_inet_pton(int af, const char *src, void *dst);
Packit 514978
Packit 514978
Packit 514978
#ifdef  __cplusplus
Packit 514978
}
Packit 514978
#endif
Packit 514978
Packit 514978
#endif /* ARES__H */