Imported Upstream version 0.3.4
[anytun.git] / src / resolver.h
index b5553bc..4a82733 100644 (file)
  *  tunneling and relaying of packets of any protocol.
  *
  *
- *  Copyright (C) 2007-2008 Othmar Gsenger, Erwin Nindl, 
+ *  Copyright (C) 2007-2009 Othmar Gsenger, Erwin Nindl,
  *                          Christian Pointner <satp@wirdorange.org>
  *
  *  This file is part of Anytun.
  *
  *  Anytun is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3 as
- *  published by the Free Software Foundation.
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  any later version.
  *
  *  Anytun is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -29,8 +30,8 @@
  *  along with anytun.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef _RESOLVER_H_
-#define _RESOLVER_H_
+#ifndef ANYTUN_resolver_h_INCLUDED
+#define ANYTUN_resolver_h_INCLUDED
 
 #include <queue>
 #include <boost/asio.hpp>
 #include "datatypes.h"
 #include "threadUtils.hpp"
 
-typedef boost::function<void (boost::asio::ip::udp::endpoint)> UdpResolveCallback;
-typedef boost::function<void (boost::asio::ip::tcp::endpoint)> TcpResolveCallback;
+typedef boost::function<void (boost::asio::ip::udp::resolver::iterator)> UdpResolveCallback;
+typedef boost::function<void (boost::asio::ip::tcp::resolver::iterator)> TcpResolveCallback;
 typedef boost::function<void (std::runtime_error const&)> ErrorCallback;
 
 template<class Proto>
 class ResolveHandler
 {
 public:
-  ResolveHandler(const std::string& addr, const std::string& port, boost::function<void (boost::asio::ip::basic_endpoint<Proto>)> const& onResolve, ErrorCallback const& onError, ResolvAddrType r = ANY);
-  void operator()(const boost::system::error_code& e, const boost::asio::ip::basic_resolver_iterator<Proto>);
+  ResolveHandler(const std::string& addr, const std::string& port, boost::function<void (boost::asio::ip::basic_resolver_iterator<Proto>)> const& onResolve, ErrorCallback const& onError, ResolvAddrType r = ANY);
+  void operator()(const boost::system::error_code& e, boost::asio::ip::basic_resolver_iterator<Proto>);
 
 private:
   std::string addr_;
   std::string port_;
-  boost::function<void (boost::asio::ip::basic_endpoint<Proto>)> onResolve_;
+  boost::function<void (const boost::asio::ip::basic_resolver_iterator<Proto>)> onResolve_;
   ErrorCallback onError_;
   ResolvAddrType resolv_addr_type_;
 };
@@ -61,7 +62,7 @@ private:
 typedef ResolveHandler<boost::asio::ip::udp> UdpResolveHandler;
 typedef ResolveHandler<boost::asio::ip::tcp> TcpResolveHandler;
 
-class Resolver 
+class Resolver
 {
 public:
   static Resolver& instance();
@@ -75,15 +76,18 @@ public:
 private:
   Resolver();
   ~Resolver();
-  Resolver(const Resolver &r);
-  void operator=(const Resolver &r);
+  Resolver(const Resolverr);
+  void operator=(const Resolverr);
 
   static Resolver* inst;
   static ::Mutex instMutex;
-  class instanceCleaner {
-    public: ~instanceCleaner() {
-      if(Resolver::inst != 0)
+  class instanceCleaner
+  {
+  public:
+    ~instanceCleaner() {
+      if(Resolver::inst != 0) {
         delete Resolver::inst;
+      }
     }
   };
   friend class instanceCleaner;