00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef DNS_H__
00015 #define DNS_H__
00016
00017 #include "macros.h"
00018 #include "logsink.h"
00019
00020 #ifdef __MINGW32__
00021 # include <windows.h>
00022 # include <windns.h>
00023 #endif
00024
00025 #ifdef HAVE_ARPA_NAMESER_H
00026 # include <arpa/nameser.h>
00027 #endif
00028
00029 #ifdef __APPLE__
00030 # include <arpa/nameser_compat.h>
00031 #endif
00032
00033 #ifndef NS_MAXDNAME
00034 # define NS_MAXDNAME 1025
00035 #endif
00036
00037 #ifndef NS_PACKETSZ
00038 # define NS_PACKETSZ 512
00039 #endif
00040
00041 #include <string>
00042 #include <map>
00043
00044 namespace gloox
00045 {
00046
00055 class GLOOX_API DNS
00056 {
00057 public:
00058
00062 typedef std::map<std::string, int> HostMap;
00063
00073 static HostMap resolve( const std::string& service, const std::string& proto,
00074 const std::string& domain, const LogSink& logInstance );
00075
00084 static HostMap resolve( const std::string& domain, const LogSink& logInstance )
00085 { return resolve( "xmpp-client", "tcp", domain, logInstance ); }
00086
00094 static int connect( const std::string& domain, const LogSink& logInstance );
00095
00104 static int connect( const std::string& domain, unsigned short port, const LogSink& logInstance );
00105
00110 static int getSocket();
00111
00116 static void closeSocket( int fd );
00117
00118 private:
00119 static HostMap defaultHostMap( const std::string& domain, const LogSink& logInstance );
00120 static void cleanup();
00121
00122 typedef struct buffer
00123 {
00124 unsigned char buf[NS_PACKETSZ];
00125 int len;
00126 };
00127 typedef unsigned char name[NS_MAXDNAME];
00128 };
00129
00130 }
00131
00132 #endif // DNS_H__