Using the list of protocols in the scheduler.
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sat, 25 Feb 2012 17:20:16 +0000 (15:20 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sat, 25 Feb 2012 17:20:16 +0000 (15:20 -0200)
src/host/pingscheduler.cpp
src/host/pingscheduler.h
src/main.cpp

index 85ca13b..67fa690 100644 (file)
@@ -27,6 +27,7 @@ on this file might be covered by the GNU General Public License.
 #include <logfunc.hpp>
 
 #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()
 {
 }
index 161866e..877d6e4 100644 (file)
@@ -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,
index 24496fc..17f685f 100644 (file)
@@ -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,