From: Guilherme Maciel Ferreira Date: Sat, 20 Aug 2011 15:26:23 +0000 (-0300) Subject: Removed select_source_network_interface() function, replace by simple call to Network... X-Git-Tag: v1.1^2~10 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=ac5071274b71046e266486859546e371ce1a6f05;p=pingcheck Removed select_source_network_interface() function, replace by simple call to NetworkInterface::bind() --- diff --git a/src/icmp/icmppinger.cpp b/src/icmp/icmppinger.cpp index c96416a..fcfc161 100644 --- a/src/icmp/icmppinger.cpp +++ b/src/icmp/icmppinger.cpp @@ -63,8 +63,7 @@ IcmpPinger::IcmpPinger( PingerStatus( PingStatus_NotSent ), PingDoneCallback() { - if ( !source_network_interface.empty() && - !select_source_network_interface( source_network_interface ) ) + if ( !NetInterface.bind() ) { GlobalLogger.error() << "Error: could not bind the socket " << "with the local interface. " << ::strerror( errno ) << endl; @@ -358,21 +357,3 @@ void IcmpPinger::set_ping_status( PingStatus ping_status ) { PingerStatus = ping_status; } - -/** - * Avoid the socket to drop to another network interface if the destination - * is unreachable through the binded interface. Packets are sent only from - * this interface. - * - * @param source_network_interface The network interface to bind the pinger. - * - * @return false if the bind failed. - */ -bool IcmpPinger::select_source_network_interface( - const string &source_network_interface -) -{ - BOOST_ASSERT( !source_network_interface.empty() ); - - return NetInterface.bind(); -} diff --git a/src/icmp/icmppinger.h b/src/icmp/icmppinger.h index 1cbc339..69a92e4 100644 --- a/src/icmp/icmppinger.h +++ b/src/icmp/icmppinger.h @@ -63,10 +63,6 @@ private: void set_ping_status( PingStatus ping_status ); - bool select_source_network_interface( - const std::string &source_network_interface - ); - private: /// The IO service object, which has the loop event boost::asio::io_service &IoService; diff --git a/src/tcp/tcppinger.cpp b/src/tcp/tcppinger.cpp index 3b91cdd..fe4eee5 100644 --- a/src/tcp/tcppinger.cpp +++ b/src/tcp/tcppinger.cpp @@ -71,8 +71,7 @@ TcpPinger::TcpPinger( PingerStatus( PingStatus_NotSent ), PingDoneCallback() { - if ( !source_network_interface_name.empty() && - !select_source_network_interface( source_network_interface_name ) ) + if ( !NetInterface.bind() ) { GlobalLogger.error() << "Error: could not bind the socket " "with the local interface. " << ::strerror( errno ) << endl; @@ -331,21 +330,3 @@ void TcpPinger::set_ping_status( PingStatus ping_status ) { PingerStatus = ping_status; } - -/** - * Avoid the socket to drop to another network interface if the destination - * is unreachable through the binded interface. Packets are sent only from - * this interface. - * - * @param source_network_interface_name The network interface to bind the pinger. - * - * @return false if the bind failed. - */ -bool TcpPinger::select_source_network_interface( - const string &source_network_interface_name -) -{ - BOOST_ASSERT( !source_network_interface_name.empty() ); - - return NetInterface.bind(); -} diff --git a/src/tcp/tcppinger.h b/src/tcp/tcppinger.h index 68d64ac..51382ba 100644 --- a/src/tcp/tcppinger.h +++ b/src/tcp/tcppinger.h @@ -80,10 +80,6 @@ private: void set_ping_status( PingStatus ping_status ); - bool select_source_network_interface( - const std::string &source_network_interface_name - ); - private: /// io service object, which has the loop event boost::asio::io_service &IoService;