From: Guilherme Maciel Ferreira Date: Thu, 9 Jun 2011 19:41:34 +0000 (-0300) Subject: Added and formatted some error messages X-Git-Tag: v1.0~1 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=d9a7f2f3621f57e28ec671c3802a5d6c11d124a1;p=pingcheck Added and formatted some error messages --- diff --git a/src/icmp/icmppinger.cpp b/src/icmp/icmppinger.cpp index 019c726..bec718d 100644 --- a/src/icmp/icmppinger.cpp +++ b/src/icmp/icmppinger.cpp @@ -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; }