From: Guilherme Maciel Ferreira Date: Mon, 4 Apr 2011 10:14:30 +0000 (+0200) Subject: Removed the address resolution from the pinger. X-Git-Tag: v1.0~99 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=2035d00eb6e55c1b05692646f2d518d673ce6800;p=pingcheck Removed the address resolution from the pinger. - There is a special class to translate DNS to IP, thus makes no sense to keep this feature here, which simplify this class. --- diff --git a/src/ping/boostpinger.cpp b/src/ping/boostpinger.cpp index f48f49c..ca1c921 100644 --- a/src/ping/boostpinger.cpp +++ b/src/ping/boostpinger.cpp @@ -26,7 +26,6 @@ BoostPinger::BoostPinger( const int echo_reply_timeout_in_sec ) : IoService( io_serv ), - Resolver( io_serv ), DestinationEndpoint(), Socket( io_serv, icmp::v4() ), Timer( io_serv ), @@ -44,22 +43,24 @@ BoostPinger::~BoostPinger() } /** - * Pings a given destination address. + * Ping a destination address from an available local source. * - * @param destination The address of the host where to ping. + * @param destination_ip The address of the host to ping. * * @return true if the ping was successfully performed, or false if the ping - * was not replied due timeout. + * was not replied due a timeout. * * @note This method is synchronous, i.e. this method blocks and returns only * after the ping requested has finished or timed-out. */ -bool BoostPinger::ping( const string &destination ) +bool BoostPinger::ping( const string &destination_ip ) { - BOOST_ASSERT( !destination.empty() ); + BOOST_ASSERT( !destination_ip.empty() ); - icmp::resolver::query query( icmp::v4(), destination, "" ); - DestinationEndpoint = *Resolver.resolve( query ); + int port = 0; + address destination_address = ip::address::from_string( destination_ip ); + icmp::endpoint destination_endpoint( destination_address, port ); + DestinationEndpoint = destination_endpoint; start_pinger(); diff --git a/src/ping/boostpinger.h b/src/ping/boostpinger.h index 9b383b0..1ce974f 100644 --- a/src/ping/boostpinger.h +++ b/src/ping/boostpinger.h @@ -22,7 +22,7 @@ public: ); virtual ~BoostPinger(); - bool ping( const std::string &destination ); + bool ping( const std::string &destination_ip ); private: enum PingStatus @@ -56,7 +56,6 @@ private: private: boost::asio::io_service &IoService; - boost::asio::ip::icmp::resolver Resolver; boost::asio::ip::icmp::endpoint DestinationEndpoint; boost::asio::ip::icmp::socket Socket; boost::asio::deadline_timer Timer;