--- /dev/null
+/*
+ The software in this package is distributed under the GNU General
+ Public License version 2 (with a special exception described below).
+
+ A copy of GNU General Public License (GPL) is included in this distribution,
+ in the file COPYING.GPL.
+
+ As a special exception, if other files instantiate templates or use macros
+ or inline functions from this file, or you compile this file and link it
+ with other works to produce a work based on this file, this file
+ does not by itself cause the resulting work to be covered
+ by the GNU General Public License.
+
+ However the source code for this file must still be made available
+ in accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work based
+ on this file might be covered by the GNU General Public License.
+ */
+
+#include "dns/dnsresolverfactory.h"
+
+#include <boost/net/dns.hpp>
+
+using namespace std;
+using boost::net::dns::type_t;
+
+//-----------------------------------------------------------------------------
+// DnsResolverFactory
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief Default constructor.
+ */
+DnsResolverFactory::DnsResolverFactory()
+{
+}
+
+/**
+ * @brief Destructor.
+ */
+DnsResolverFactory::~DnsResolverFactory()
+{
+}
+
+/**
+ * @brief Creates a DNS resolver suitable to the given protocol.
+ *
+ * @param destination_address The remote address to ping.
+ * @param nameserver Server to resolve the addresses.
+ * @param ping_protocol The protocol used to ping, in order to find the DNS resolver more
+ * appropriated to resolve the addresses for this protocol.
+ */
+DnsResolverItem DnsResolverFactory::createResolver(
+ const string &destination_address,
+ const string &nameserver,
+ const PingProtocol ping_protocol
+)
+{
+ switch ( ping_protocol )
+ {
+ case PingProtocol_ICMP:
+ case PingProtocol_TCP:
+ return DnsResolverItem(
+ new DnsResolver( destination_address, nameserver, boost::net::dns::type_a )
+ );
+ case PingProtocol_ICMPv6:
+ case PingProtocol_TCP_IPv6:
+ return DnsResolverItem(
+ new DnsResolver( destination_address, nameserver, boost::net::dns::type_a6 )
+ );
+ default:
+ BOOST_ASSERT( !"Try to create a DNS from an invalid address resource record" ); //lint !e506
+ return DnsResolverItem(); //lint !e527
+ }
+}
--- /dev/null
+/*
+ The software in this package is distributed under the GNU General
+ Public License version 2 (with a special exception described below).
+
+ A copy of GNU General Public License (GPL) is included in this distribution,
+ in the file COPYING.GPL.
+
+ As a special exception, if other files instantiate templates or use macros
+ or inline functions from this file, or you compile this file and link it
+ with other works to produce a work based on this file, this file
+ does not by itself cause the resulting work to be covered
+ by the GNU General Public License.
+
+ However the source code for this file must still be made available
+ in accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work based
+ on this file might be covered by the GNU General Public License.
+ */
+
+#ifndef DNS_RESOLVER_FACTORY_H
+#define DNS_RESOLVER_FACTORY_H
+
+#include <string>
+
+#include "dns/dnsresolver.h"
+#include "host/pingprotocol.h"
+
+//-----------------------------------------------------------------------------
+// DnsResolverFactory
+//-----------------------------------------------------------------------------
+
+class DnsResolverFactory
+{
+public:
+ static DnsResolverItem createResolver(
+ const std::string &destination_address,
+ const std::string &nameserver,
+ const PingProtocol ping_protocol
+ );
+
+private:
+ DnsResolverFactory();
+ ~DnsResolverFactory();
+
+};
+
+#endif // DNS_RESOLVER_FACTORY_H