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

ares_private.h

Go to the documentation of this file.
00001 /* Copyright 1998 by the Massachusetts Institute of Technology.
00002  *
00003  * Permission to use, copy, modify, and distribute this
00004  * software and its documentation for any purpose and without
00005  * fee is hereby granted, provided that the above copyright
00006  * notice appear in all copies and that both that copyright
00007  * notice and this permission notice appear in supporting
00008  * documentation, and that the name of M.I.T. not be used in
00009  * advertising or publicity pertaining to distribution of the
00010  * software without specific, written prior permission.
00011  * M.I.T. makes no representations about the suitability of
00012  * this software for any purpose.  It is provided "as is"
00013  * without express or implied warranty.
00014  *
00015  * CHANGELOG: this file has been modified by Sergio Perez Alcañiz <serpeal@disca.upv.es> 
00016  *            Departamento de Informática de Sistemas y Computadores          
00017  *            Universidad Politécnica de Valencia                             
00018  *            Valencia (Spain)    
00019  *            Date: April 2003                                          
00020  *
00021  */
00022 
00023 #include "lwip/api.h"
00024 
00025 #ifndef LWIP_COMPAT_SOCKETS
00026 #define LWIP_COMPAT_SOCKETS
00027 #endif
00028 
00029 #include "lwip/sockets.h"
00030 
00031 #define u_char unsigned char
00032 #define u_int unsigned int
00033 #define u_int16_t u16_t
00034 #define u_int32_t u32_t
00035 
00036 #include "arpa/nameser.h"
00037 
00038 #define malloc mem_malloc
00039 #define realloc mem_reallocm
00040 #define free mem_free
00041 
00042 #define strdup ares_strdup
00043 char *ares_strdup(const char *);
00044 
00045 #define strcasecmp ares_strcasecmp
00046 int ares_strcasecmp (const char *s1, const char *s2);
00047 
00048 #define time ares_time
00049 //typedef long time_t;
00050 time_t ares_time(time_t *);
00051 
00052 
00053 //#include <stdlib.h>
00054 #include <string.h>
00055 #include "netdb.h"
00056 #include <ctype.h>
00057 
00058 #include "ares.h"
00059 
00060 #define DEFAULT_TIMEOUT         5
00061 #define DEFAULT_TRIES           4
00062 #ifndef INADDR_NONE
00063 #define INADDR_NONE 0xffffffff
00064 #endif
00065 
00066 #define PATH_RESOLV_CONF        "/etc/resolv.conf"
00067 #ifdef ETC_INET
00068 #define PATH_HOSTS              "/etc/inet/hosts"
00069 #else
00070 #define PATH_HOSTS              "/etc/hosts"
00071 #endif
00072 
00073 struct send_request {
00074   /* Remaining data to send */
00075   const unsigned char *data;
00076   int len;
00077 
00078   /* Next request in queue */
00079   struct send_request *next;
00080 };
00081 
00082 struct server_state {
00083   struct in_addr addr;
00084   int udp_socket;
00085   int tcp_socket;
00086 
00087   /* Mini-buffer for reading the length word */
00088   unsigned char tcp_lenbuf[2];
00089   int tcp_lenbuf_pos;
00090   int tcp_length;
00091 
00092   /* Buffer for reading actual TCP data */
00093   unsigned char *tcp_buffer;
00094   int tcp_buffer_pos;
00095 
00096   /* TCP output queue */
00097   struct send_request *qhead;
00098   struct send_request *qtail;
00099 };
00100 
00101 struct query {
00102   /* Query ID from qbuf, for faster lookup, and current timeout */
00103   unsigned short qid;
00104   time_t timeout;
00105 
00106   /* Query buf with length at beginning, for TCP transmission */
00107   unsigned char *tcpbuf;
00108   int tcplen;
00109 
00110   /* Arguments passed to ares_send() (qbuf points into tcpbuf) */
00111   const unsigned char *qbuf;
00112   int qlen;
00113   ares_callback callback;
00114   void *arg;
00115 
00116   /* Query status */
00117   int try;
00118   int server;
00119   int *skip_server;
00120   int using_tcp;
00121   int error_status;
00122 
00123   /* Next query in chain */
00124   struct query *next;
00125 };
00126 
00127 /* An IP address pattern; matches an IP address X if X & mask == addr */
00128 struct apattern {
00129   struct in_addr addr;
00130   struct in_addr mask;
00131 };
00132 
00133 struct ares_channeldata {
00134   /* Configuration data */
00135   int flags;
00136   int timeout;
00137   int tries;
00138   int ndots;
00139   int udp_port;
00140   int tcp_port;
00141   char **domains;
00142   int ndomains;
00143   struct apattern *sortlist;
00144   int nsort;
00145   char *lookups;
00146 
00147   /* Server addresses and communications state */
00148   struct server_state *servers;
00149   int nservers;
00150 
00151   /* ID to use for next query */
00152   unsigned short next_id;
00153 
00154   /* Active queries */
00155   struct query *queries;
00156 };
00157 
00158 void ares__send_query(ares_channel channel, struct query *query, time_t now);
00159 void ares__close_sockets(struct server_state *server);
00160 //int ares__get_hostent(const char *fp, struct hostent **host);
00161 //int ares__read_line(const char *fp, char **buf, int *bufsize);

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