From ac5071274b71046e266486859546e371ce1a6f05 Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Sat, 20 Aug 2011 12:26:23 -0300 Subject: [PATCH] Removed select_source_network_interface() function, replace by simple call to NetworkInterface::bind() --- src/icmp/icmppinger.cpp | 21 +-------------------- src/icmp/icmppinger.h | 4 ---- src/tcp/tcppinger.cpp | 21 +-------------------- src/tcp/tcppinger.h | 4 ---- 4 files changed, 2 insertions(+), 48 deletions(-) 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; -- 1.7.1