Revert "Configuration: added the ping protocol fallback count."
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sun, 11 Mar 2012 20:26:41 +0000 (17:26 -0300)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sun, 11 Mar 2012 20:48:49 +0000 (17:48 -0300)
This reverts commit f1284dcbaa750c1ffb517ed8e2e6a0a051a36057.

src/config/host.cpp
src/config/host.h
src/config/option/hostpingprotocoloption.cpp
src/config/option/hostpingprotocoloption.h

index 15b8179..5bb0bd9 100644 (file)
@@ -38,7 +38,6 @@ Host::Host( string address ) :
     Address( address ),
     Port( 0 ),
     ProtocolList(),
-    ProtocolFallbackCount( 0 ),
     IntervalInSec( 0 )
 {
 }
@@ -107,24 +106,6 @@ void Host::set_ping_protocol_list( const PingProtocolList &ping_protocol_list )
 }
 
 /**
- * @return The amount of pings to perform before change the protocol.
- */
-int Host::get_ping_protocol_fallback_count() const
-{
-    return ProtocolFallbackCount;
-}
-
-/**
- * @param protocol_fallback_count The amount of pings to perform before change the protocol.
- */
-void Host::set_ping_protocol_fallback_count( const int protocol_fallback_count )
-{
-    BOOST_ASSERT( ( 0 <= protocol_fallback_count ) && ( protocol_fallback_count < numeric_limits<int>::max() ) );
-
-    this->ProtocolFallbackCount = protocol_fallback_count;
-}
-
-/**
  * @return The interval between each ping to the host.
  */
 int Host::get_interval_in_sec() const
index 58586b1..8e5969f 100644 (file)
@@ -51,9 +51,6 @@ public:
     PingProtocolList get_ping_protocol_list() const;
     void set_ping_protocol_list( const PingProtocolList &ping_protocol );
 
-    int get_ping_protocol_fallback_count() const;
-    void set_ping_protocol_fallback_count( const int protocol_fallback_count );
-
     int get_interval_in_sec() const;
     void set_interval_in_sec( const int interval_in_sec );
 
@@ -64,8 +61,6 @@ private:
     uint16_t Port;
     /// The list of protocols used to ping
     PingProtocolList ProtocolList;
-    /// The amount of pings to perform before change the protocol.
-    int ProtocolFallbackCount;
     /// The interval between each ping to the host
     int IntervalInSec;
 
index 6f1e08d..aac7025 100644 (file)
@@ -26,7 +26,6 @@
 
 #include <boost/assert.hpp>
 #include <boost/foreach.hpp>
-#include <boost/lexical_cast.hpp>
 
 #include <logfunc.hpp>
 
@@ -43,7 +42,7 @@ HostPingProtocolOption::HostPingProtocolOption() :
     HostConfigurationOption(
         "host.ping-protocol",
         value< vector<string> >(),
-        "Defines which protocols will be used to ping the destination."
+        "Defines which protocol will be used to ping the destination."
     )
 {
 }
@@ -78,11 +77,8 @@ bool HostPingProtocolOption::parse(
             BOOST_ASSERT( !protocols_string.empty() );
 
             HostItem host_item = *hosts_list_iterator;
-            PingProtocolList host_protocols;
-            int protocol_fallback_count = 0;
-            parse_protocol_list( protocols_string, &host_protocols, &protocol_fallback_count );
+            PingProtocolList host_protocols = parse_protocol_list( protocols_string );
             host_item->set_ping_protocol_list( host_protocols );
-            host_item->set_ping_protocol_fallback_count( protocol_fallback_count );
             ++hosts_list_iterator;
 
             GlobalLogger.info() << get_command_string() << "="
@@ -99,16 +95,13 @@ bool HostPingProtocolOption::parse(
     return parsed_success;
 }
 
-void HostPingProtocolOption::parse_protocol_list(
-        const std::string &protocol_list_string,
-        PingProtocolList *protocol_list,
-        int *protocol_fallback_count
-
+PingProtocolList HostPingProtocolOption::parse_protocol_list(
+        const std::string &protocol_list_string
 ) const
 {
     BOOST_ASSERT( !protocol_list_string.empty() );
 
-    size_t protocol_index = 0;
+    PingProtocolList protocol_list;
     string protocol_string;
     istringstream iss( protocol_list_string );
 
@@ -116,31 +109,15 @@ void HostPingProtocolOption::parse_protocol_list(
     {
         BOOST_ASSERT( !protocol_string.empty());
 
-        // The second item in the list is the amount of pings to perform before change from the
-        // first protocol to the second (e.g. ICMP,10,ICMPv6).
-        if ( protocol_index == 1 )
-        {
-            try
-            {
-                *protocol_fallback_count = boost::lexical_cast< int >( protocol_string );
-            }
-            catch ( boost::bad_lexical_cast const &ex )
-            {
-                GlobalLogger.error() << "Error: input string was not valid" << endl;
-            }
-        }
-        else
-        {
-            PingProtocol protocol = get_ping_protocol_from_string( protocol_string );
-            protocol_list->push_back( protocol );
+        PingProtocol protocol = get_ping_protocol_from_string( protocol_string );
+        protocol_list.push_back( protocol );
 
-            GlobalLogger.debug() << "- " << protocol_string;
+        GlobalLogger.debug() << "- " << protocol_string;
 
-            BOOST_ASSERT( ( PingProtocol_First <= protocol ) && ( protocol <= PingProtocol_Last ) );
-        }
-
-        protocol_index++;
+        BOOST_ASSERT( ( PingProtocol_First <= protocol ) && ( protocol <= PingProtocol_Last ) );
     }
 
-    BOOST_ASSERT( 0 < protocol_list->size() );
+    BOOST_ASSERT( 0 < protocol_list.size() );
+
+    return protocol_list;
 }
index 3171992..a920318 100644 (file)
@@ -45,10 +45,8 @@ public:
     );
 
 private:
-    void parse_protocol_list(
-            const std::string &protocol_list_string,
-            PingProtocolList *protocol_list,
-            int *protocol_fallback_count
+    PingProtocolList parse_protocol_list(
+            const std::string &protocol_list_string
     ) const;
 
 };