dns.h

00001 /*
00002   Copyright (c) 2005-2007 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
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__

Generated on Sat Nov 10 08:50:27 2007 for gloox by  doxygen 1.5.3-20071008