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
00019 #ifdef __MINGW32__
00020 #include <windows.h>
00021 #include <windns.h>
00022 #endif
00023
00024 #ifdef HAVE_ARPA_NAMESER_H
00025 #include <arpa/nameser.h>
00026 #endif
00027
00028 #ifdef __APPLE__
00029 #include <arpa/nameser_compat.h>
00030 #endif
00031
00032 #ifndef NS_MAXDNAME
00033 #define NS_MAXDNAME 1025
00034 #endif
00035
00036 #ifndef NS_PACKETSZ
00037 #define NS_PACKETSZ 512
00038 #endif
00039
00040 #include <string>
00041 #include <map>
00042
00043 namespace gloox
00044 {
00045
00053 class GLOOX_EXPORT DNS
00054 {
00055 public:
00056
00060 enum DNSError
00061 {
00062 DNS_COULD_NOT_CONNECT = 1,
00063 DNS_NO_HOSTS_FOUND,
00064 DNS_COULD_NOT_RESOLVE
00065 };
00066
00070 typedef std::map<std::string, int> HostMap;
00071
00080 static HostMap resolve( const std::string& service, const std::string& proto,
00081 const std::string& domain );
00082
00090 static HostMap resolve( const std::string& domain );
00091
00098 static int connect( const std::string& domain );
00099
00107 static int connect( const std::string& domain, int port );
00108
00109 private:
00110 static HostMap defaultHostMap( const std::string& service, const std::string& proto,
00111 const std::string& domain );
00112 static void cleanup();
00113
00114 typedef struct buffer
00115 {
00116 unsigned char buf[NS_PACKETSZ];
00117 int len;
00118 };
00119 typedef unsigned char name [NS_MAXDNAME];
00120 };
00121
00122 }
00123
00124 #endif // DNS_H__