Code formatting
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 19 Jul 2011 01:19:28 +0000 (22:19 -0300)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 19 Jul 2011 01:19:28 +0000 (22:19 -0300)
src/icmp/icmppinger.cpp
src/icmp/icmppinger.h

index 3722a48..aeff606 100644 (file)
@@ -43,11 +43,11 @@ using I2n::Logger::GlobalLogger;
 //-----------------------------------------------------------------------------
 
 IcmpPinger::IcmpPinger(
-        boost::asio::io_service &io_service,
-        string source_network_interface,
+        io_service &io_serv,
+        const string &source_network_interface,
         const int echo_reply_timeout_in_sec
 ) :
-    IoService( io_service ),
+    IoService( io_serv ),
     DestinationEndpoint(),
     Socket( IoService, icmp::v4() ),
     IcmpPacketReceiveTimer( IoService ),
@@ -80,14 +80,14 @@ IcmpPinger::~IcmpPinger()
 }
 
 /**
- * Ping a destination address from an available local source.
+ * @brief Ping a destination address from an available local source.
  *
  * @param destination_ip The address of the host to ping.
  * @param done_handler Done handler will be called on successful ping or timeout
  */
 void IcmpPinger::ping(
         const string &destination_ip,
-        boost::function< void(bool) > ping_done_callback
+        function< void(bool) > ping_done_callback
 )
 {
     BOOST_ASSERT( !destination_ip.empty() );
@@ -206,7 +206,7 @@ void IcmpPinger::handle_ping_done()
 {
     // Check ReceivedReply as the timer handler
     // is also called by Timer.cancel();
-    if (ReceivedReply == false)
+    if ( ReceivedReply == false )
     {
         GlobalLogger.info() << "Request timed out" << endl;
 
@@ -281,13 +281,11 @@ void IcmpPinger::handle_receive_icmp_packet( const size_t &bytes_transferred )
             IcmpPacketReceiveTimer.cancel();
         } else
         {
-            /*
-            GlobalLogger.notice() << "unknown ICMP reply (src IP: " << icmp_packet.get_ip_header().get_source_address() << ")"
-                                            << ". Starting another recieve till timeout." << endl;
-            */
+            // Unknown ICMP reply, start another receive till timeout
             start_receive();
         }
-    } catch(...)
+    }
+    catch ( ... )
     {
         GlobalLogger.notice() << "exception during ICMP parse. Starting another recieve till timeout." << endl;
         start_receive();
index a64fd39..54564e7 100644 (file)
@@ -7,6 +7,8 @@
 #ifndef ICMPPINGER_H
 #define ICMPPINGER_H
 
+#include <string>
+
 #include <boost/asio.hpp>
 #include <boost/function.hpp>
 
@@ -26,8 +28,8 @@ class IcmpPinger : public Pinger
 {
 public:
     IcmpPinger(
-            boost::asio::io_service &io_service,
-            std::string source_network_interface,
+            boost::asio::io_service &io_serv,
+            const std::string &source_network_interface,
             const int echo_reply_timeout_in_sec
     );
     virtual ~IcmpPinger();