From 086e2cc0ec84d43df351a0c86db1cf31d4774cec Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Sat, 25 Feb 2012 15:20:16 -0200 Subject: [PATCH] Using the list of protocols in the scheduler. --- src/host/pingscheduler.cpp | 21 ++++++++++++++++++--- src/host/pingscheduler.h | 4 +--- src/main.cpp | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/host/pingscheduler.cpp b/src/host/pingscheduler.cpp index 85ca13b..67fa690 100644 --- a/src/host/pingscheduler.cpp +++ b/src/host/pingscheduler.cpp @@ -27,6 +27,7 @@ on this file might be covered by the GNU General Public License. #include #include "dns/dnsresolver.h" +#include "host/pingerfactory.h" #include "icmp/icmppinger.h" #include "link/linkstatus.h" @@ -44,11 +45,23 @@ using I2n::Logger::GlobalLogger; // PingScheduler //----------------------------------------------------------------------------- +/** + * @brief Parameterized constructor. + * + * @param network_interface The name of the network interface originating the pings. + * @param destination_address The remote address to ping. + * @param destination_port The remote port to ping. + * @param ping_protocol_list A list of protocols to use. + * @param ping_interval_in_sec Amount of time between each ping. + * @param ping_fail_percentage_limit Maximum amount of pings that can fail. + * @param nameserver Server to resolve the addresses. + * @param link_analyzer The object to monitor the link status. + */ PingScheduler::PingScheduler( const string &network_interface, const string &destination_address, const uint16_t destination_port, - const PingProtocol ping_protocol, + const PingProtocolList ping_protocol_list, const long ping_interval_in_sec, const int ping_fail_percentage_limit, const string &nameserver, @@ -69,14 +82,16 @@ PingScheduler::PingScheduler( BOOST_ASSERT( !network_interface.empty() ); BOOST_ASSERT( !destination_address.empty() ); BOOST_ASSERT( 0 < destination_port ); - BOOST_ASSERT( /*(PingProtocol_First <= ping_protocol) && */(ping_protocol <= PingProtocol_Last) ); BOOST_ASSERT( 0 < ping_interval_in_sec ); BOOST_ASSERT( (0 <= ping_fail_percentage_limit) && (ping_fail_percentage_limit <= 100) ); BOOST_ASSERT( !nameserver.empty() ); - Ping = PingerFactory::createPinger( ping_protocol, IoService, network_interface ); + Ping = PingerFactory::createPinger( ping_protocol_list, IoService, network_interface ); } +/** + * @brief Destructor. + */ PingScheduler::~PingScheduler() { } diff --git a/src/host/pingscheduler.h b/src/host/pingscheduler.h index 161866e..877d6e4 100644 --- a/src/host/pingscheduler.h +++ b/src/host/pingscheduler.h @@ -33,10 +33,8 @@ on this file might be covered by the GNU General Public License. #include "link/linkstatus.h" #include "host/hoststatus.h" #include "host/pinger.h" -#include "host/pingerfactory.h" #include "host/pinginterval.h" #include "host/pingprotocol.h" -#include "icmp/icmppinger.h" //----------------------------------------------------------------------------- // PingScheduler @@ -54,7 +52,7 @@ public: const std::string &network_interface, const std::string &destination_address, const uint16_t destination_port, - const PingProtocol ping_protocol, + const PingProtocolList ping_protocol_list, const long ping_interval_in_sec, const int ping_fail_percentage_limit, const std::string &nameserver, diff --git a/src/main.cpp b/src/main.cpp index 24496fc..17f685f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -122,14 +122,14 @@ void init_pingers( { string destination_address = host->get_address(); uint16_t destination_port = host->get_port(); - PingProtocol protocol = host->get_ping_protocol(); + PingProtocolList protocol_list = host->get_ping_protocol_list(); int ping_interval_in_sec = host->get_interval_in_sec(); PingSchedulerItem scheduler( new PingScheduler( local_interface, destination_address, destination_port, - protocol, + protocol_list, ping_interval_in_sec, ping_fail_limit, nameserver, -- 1.7.1