hostlookup.h

Go to the documentation of this file.
00001 
00025 #ifndef _hostlookup_h_
00026 #define _hostlookup_h_
00027 
00028 #include "bool.h"
00029 
00074 #ifdef WIN32
00075 #include <winsock2.h>
00076 #include <ws2tcpip.h>
00077 #ifdef _MSC_VER
00078 // This isn't defined in Microsoft's ws2tcpip.h, but is defined in the mingw32
00079 // equivalent.
00080 #define IN6_ARE_ADDR_EQUAL  IN6_ADDR_EQUAL
00081 #endif
00082 #else
00083 #include <netinet/in.h>
00084 #endif
00085 
00089 #define MAX_HOST_LEN  64
00090 
00094 struct INetAddr_t {
00095     union {
00099         struct in_addr  ipv4;
00103         struct in6_addr ipv6;
00104     };
00108     int family;
00109 };
00110 
00111 typedef struct INetAddr_t INetAddr;
00112 
00117 struct SocketAddr_t {
00118     union {
00122         struct sockaddr_in  ipv4;
00126         struct sockaddr_in6 ipv6;
00130         struct sockaddr addr;
00131     };
00135     socklen_t length;
00136 };
00137 
00138 typedef struct SocketAddr_t SocketAddr;
00139 
00145 extern SocketAddr outgoingAddr;
00146 
00154 #define EqualAddresses(sa1, sa2) \
00155     (((sa1)->addr.sa_family == (sa2)->addr.sa_family) &&               \
00156     ((((sa2)->addr.sa_family == AF_INET)                               \
00157     && ((sa2)->ipv4.sin_addr.s_addr == (sa1)->ipv4.sin_addr.s_addr))   \
00158     || (((sa2)->addr.sa_family == AF_INET6) &&                         \
00159     IN6_ARE_ADDR_EQUAL(&((sa2)->ipv6.sin6_addr),                       \
00160     &((sa1)->ipv6.sin6_addr)))))
00161 
00165 extern char localhostName[MAX_HOST_LEN];
00166 
00170 extern char localhostAddrStr[INET6_ADDRSTRLEN];
00171 
00180 void StartAddrLookup(char *name);
00181 
00194 Bool StartStrNameLookup(char *addrstr, char *name);
00195 
00207 void StartNameLookup(SocketAddr *addr, char *name);
00208 
00225 int LookupResult(char *name, INetAddr *addr);
00226 
00246 void DoHostnameLookup(void *);
00247 
00248 #ifdef WIN32
00249 
00262 int inet_pton(int fam, char *straddr, void *addr);
00263 #endif
00264 
00267 #endif
00268 

Generated on Mon May 28 04:41:39 2007 for Retro Tank Super Attack by  doxygen 1.5.2