dns.h
/*
Copyright (c) 2005-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef DNS_H__
#define DNS_H__
#include "macros.h"
#include "logsink.h"
#ifdef __MINGW32__
# include <windows.h>
# include <windns.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#endif
#ifdef __APPLE__
# include <arpa/nameser_compat.h>
#endif
#ifndef NS_MAXDNAME
# define NS_MAXDNAME 1025
#endif
#ifndef NS_PACKETSZ
# define NS_PACKETSZ 512
#endif
#ifdef HAVE_GETADDRINFO
# include <sys/types.h>
# include <sys/socket.h>
# include <netdb.h>
#endif
#include <string>
#include <map>
namespace gloox
{
class GLOOX_API DNS
{
public:
typedef std::map<std::string, int> HostMap;
static HostMap resolve( const std::string& service, const std::string& proto,
const std::string& domain, const LogSink& logInstance );
static HostMap resolve( const std::string& domain, const LogSink& logInstance )
{ return resolve( "xmpp-client", "tcp", domain, logInstance ); }
static int connect( const std::string& host, const LogSink& logInstance );
static int connect( const std::string& host, int port, const LogSink& logInstance );
static int getSocket( const LogSink& logInstance );
static void closeSocket( int fd, const LogSink& logInstance );
private:
#ifdef HAVE_GETADDRINFO
static void resolve( struct addrinfo** res, const std::string& service, const std::string& proto,
const std::string& domain, const LogSink& logInstance );
static void resolve( struct addrinfo** res, const std::string& domain, const LogSink& logInstance )
{ resolve( res, "xmpp-client", "tcp", domain, logInstance ); }
static int connect( struct addrinfo* res, const LogSink& logInstance );
#endif
static int getSocket( int af, int socktype, int proto, const LogSink& logInstance );
static HostMap defaultHostMap( const std::string& domain, const LogSink& logInstance );
static void cleanup( const LogSink& logInstance );
struct buffer
{
unsigned char buf[NS_PACKETSZ];
int len;
};
};
}
#endif // DNS_H__
gloox::DNS
This class holds a number of static functions used for DNS related stuff.
Definition dns.h:62
gloox::DNS::resolve
static HostMap resolve(const std::string &service, const std::string &proto, const std::string &domain, const LogSink &logInstance)
Definition dns.cpp:83
gloox::DNS::resolve
static HostMap resolve(const std::string &domain, const LogSink &logInstance)
Definition dns.h:90
gloox::DNS::HostMap
std::map< std::string, int > HostMap
Definition dns.h:68
gloox::LogSink
An implementation of log sink and source.
Definition logsink.h:39
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28