Added and formatted some error messages
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Thu, 9 Jun 2011 19:41:34 +0000 (16:41 -0300)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Thu, 9 Jun 2011 19:41:34 +0000 (16:41 -0300)
src/icmp/icmppinger.cpp

index 019c726..bec718d 100644 (file)
@@ -160,8 +160,7 @@ void IcmpPinger::send_echo_request( const IcmpPacket &icmp_packet )
         size_t bytes_sent = Socket.send_to( data, DestinationEndpoint );
         if ( bytes_sent != buffer_size( data ) )
         {
-            GlobalLogger.error() << "Error: fail sending ping data."
-                    << endl;
+            GlobalLogger.error() << "Error: fail sending ping data." << endl;
         }
     }
     catch ( const exception &ex )
@@ -206,7 +205,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;
 
@@ -240,7 +239,7 @@ void IcmpPinger::handle_receive_icmp_packet( const size_t &bytes_transferred )
         istream is( &ReplyBuffer );
         if ( !is )
         {
-            GlobalLogger.error() << "can't handle ReplyBuffer" << endl;
+            GlobalLogger.error() << "Error: can't handle ReplyBuffer" << endl;
             return;
         }
 
@@ -258,8 +257,7 @@ void IcmpPinger::handle_receive_icmp_packet( const size_t &bytes_transferred )
         // ICMP packets from the host we had ping).
         if ( icmp_packet.match(
                 IcmpType_EchoReply, Identifier, SequenceNumber,
-                DestinationEndpoint.address())
-        )
+                DestinationEndpoint.address() ) )
         {
             ReceivedReply = true;
             print_echo_reply( icmp_packet, bytes_transferred );
@@ -270,8 +268,7 @@ void IcmpPinger::handle_receive_icmp_packet( const size_t &bytes_transferred )
         }
         else if ( icmp_packet.match(
                 IcmpType_DestinationUnreachable, Identifier, SequenceNumber,
-                DestinationEndpoint.address()
-        ) )
+                DestinationEndpoint.address() ) )
         {
             ReceivedReply = true;
             print_destination_unreachable( icmp_packet );
@@ -279,7 +276,8 @@ void IcmpPinger::handle_receive_icmp_packet( const size_t &bytes_transferred )
             set_ping_status( PingStatus_FailureDestinationUnreachable );
 
             IcmpPacketReceiveTimer.cancel();
-        } else
+        }
+        else
         {
             /*
             GlobalLogger.notice() << "unknown ICMP reply (src IP: " << icmp_packet.get_ip_header().get_source_address() << ")"
@@ -287,9 +285,12 @@ void IcmpPinger::handle_receive_icmp_packet( const size_t &bytes_transferred )
             */
             start_receive();
         }
-    } catch(...)
+    }
+    catch ( ... )
     {
-        GlobalLogger.notice() << "exception during ICMP parse. Starting another recieve till timeout." << endl;
+        GlobalLogger.notice()
+                << "exception during ICMP parse. Starting another receive till timeout."
+                << endl;
         start_receive();
     }
 }
@@ -365,6 +366,8 @@ bool IcmpPinger::select_source_network_interface(
     );
     if ( ret == -1 )
     {
+        GlobalLogger.error() << "Error: could not bind pinger to interface "
+                << source_network_interface << endl;
         return false;
     }