Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

ares.h

Go to the documentation of this file.
00001 /* $Id: ares.h,v 1.3 2000/09/21 19:15:48 ghudson Exp $ */
00002 
00003 /* Copyright 1998 by the Massachusetts Institute of Technology.
00004  *
00005  * Permission to use, copy, modify, and distribute this
00006  * software and its documentation for any purpose and without
00007  * fee is hereby granted, provided that the above copyright
00008  * notice appear in all copies and that both that copyright
00009  * notice and this permission notice appear in supporting
00010  * documentation, and that the name of M.I.T. not be used in
00011  * advertising or publicity pertaining to distribution of the
00012  * software without specific, written prior permission.
00013  * M.I.T. makes no representations about the suitability of
00014  * this software for any purpose.  It is provided "as is"
00015  * without express or implied warranty.
00016  *
00017  * CHANGELOG: this file has been modified by Sergio Perez Alcañiz <serpeal@disca.upv.es> 
00018  *            Departamento de Informática de Sistemas y Computadores          
00019  *            Universidad Politécnica de Valencia                             
00020  *            Valencia (Spain)    
00021  *            Date: April 2003                                          
00022  *
00023  */
00024 
00025 #ifndef ARES__H
00026 #define ARES__H
00027 
00028 #define ARES_SUCCESS            0
00029 
00030 /* Server error codes (ARES_ENODATA indicates no relevant answer) */
00031 #define ARES_ENODATA            1
00032 #define ARES_EFORMERR           2
00033 #define ARES_ESERVFAIL          3
00034 #define ARES_ENOTFOUND          4
00035 #define ARES_ENOTIMP            5
00036 #define ARES_EREFUSED           6
00037 
00038 /* Locally generated error codes */
00039 #define ARES_EBADQUERY          7
00040 #define ARES_EBADNAME           8
00041 #define ARES_EBADFAMILY         9
00042 #define ARES_EBADRESP           10
00043 #define ARES_ECONNREFUSED       11
00044 #define ARES_ETIMEOUT           12
00045 #define ARES_EOF                13
00046 #define ARES_EFILE              14
00047 #define ARES_ENOMEM             15
00048 #define ARES_EDESTRUCTION       16
00049 
00050 /* Flag values */
00051 #define ARES_FLAG_USEVC         (1 << 0)
00052 #define ARES_FLAG_PRIMARY       (1 << 1)
00053 #define ARES_FLAG_IGNTC         (1 << 2)
00054 #define ARES_FLAG_NORECURSE     (1 << 3)
00055 #define ARES_FLAG_STAYOPEN      (1 << 4)
00056 #define ARES_FLAG_NOSEARCH      (1 << 5)
00057 #define ARES_FLAG_NOALIASES     (1 << 6)
00058 #define ARES_FLAG_NOCHECKRESP   (1 << 7)
00059 
00060 /* Option mask values */
00061 #define ARES_OPT_FLAGS          (1 << 0)
00062 #define ARES_OPT_TIMEOUT        (1 << 1)
00063 #define ARES_OPT_TRIES          (1 << 2)
00064 #define ARES_OPT_NDOTS          (1 << 3)
00065 #define ARES_OPT_UDP_PORT       (1 << 4)
00066 #define ARES_OPT_TCP_PORT       (1 << 5)
00067 #define ARES_OPT_SERVERS        (1 << 6)
00068 #define ARES_OPT_DOMAINS        (1 << 7)
00069 #define ARES_OPT_LOOKUPS        (1 << 8)
00070 
00071 struct ares_options {
00072   int flags;
00073   int timeout;
00074   int tries;
00075   int ndots;
00076   unsigned short udp_port;
00077   unsigned short tcp_port;
00078   struct in_addr *servers;
00079   int nservers;
00080   char **domains;
00081   int ndomains;
00082   char *lookups;
00083 };
00084 
00085 struct ares_channeldata;
00086 typedef struct ares_channeldata *ares_channel;
00087 typedef void (*ares_callback)(void *arg, int status, unsigned char *abuf,
00088                               int alen);
00089 typedef void (*ares_host_callback)(void *arg, int status,
00090                                    struct hostent *hostent);
00091 
00092 int ares_init(ares_channel *channelptr);
00093 int ares_init_options(ares_channel *channelptr, struct ares_options *options,
00094                       int optmask);
00095 void ares_destroy(ares_channel channel);
00096 
00097 void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
00098                ares_callback callback, void *arg);
00099 void ares_query(ares_channel channel, const char *name, int dnsclass,
00100                 int type, ares_callback callback, void *arg);
00101 void ares_search(ares_channel channel, const char *name, int dnsclass,
00102                  int type, ares_callback callback, void *arg);
00103 void ares_gethostbyname(ares_channel channel, const char *name, int family,
00104                         ares_host_callback callback, void *arg);
00105 void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
00106                         int family, ares_host_callback callback, void *arg);
00107 
00108 int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
00109 struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv,
00110                              struct timeval *tv);
00111 void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
00112 
00113 int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
00114                  int rd, unsigned char **buf, int *buflen);
00115 int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
00116                      int alen, char **s, int *enclen);
00117 int ares_parse_a_reply(const unsigned char *abuf, int alen,
00118                        struct hostent **host);
00119 int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
00120                          int addrlen, int family, struct hostent **host);
00121 void ares_free_string(unsigned char *str);
00122 void ares_free_hostent(struct hostent *host);
00123 const char *ares_strerror(int code, char **memptr);
00124 void ares_free_errmem(char *mem);
00125 
00126 #endif /* ARES__H */

Generated on Wed Jan 14 12:58:55 2004 for RTL-lwIP-0.4 by doxygen 1.3.4