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
00054 class GLOOX_API DNS
00055 {
00056 public:
00057
00061 enum DNSError
00062 {
00063 DNS_COULD_NOT_CONNECT = 1,
00064 DNS_NO_HOSTS_FOUND,
00065 DNS_COULD_NOT_RESOLVE
00066 };
00067
00071 typedef std::map<std::string, int> HostMap;
00072
00081 static HostMap resolve( const std::string& service, const std::string& proto,
00082 const std::string& domain );
00083
00091 static HostMap resolve( const std::string& domain );
00092
00100 static int connect( const std::string& domain, const LogSink& logInstance );
00101
00110 static int connect( const std::string& domain, int port, const LogSink& logInstance );
00111
00112 private:
00113 static HostMap defaultHostMap( const std::string& service, const std::string& proto,
00114 const std::string& domain );
00115 static void cleanup();
00116
00117 typedef struct buffer
00118 {
00119 unsigned char buf[NS_PACKETSZ];
00120 int len;
00121 };
00122 typedef unsigned char name[NS_MAXDNAME];
00123 };
00124
00125 }
00126
00127 #endif // DNS_H__