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 )
{
// Check ReceivedReply as the timer handler
// is also called by Timer.cancel();
- if (ReceivedReply == false)
+ if ( ReceivedReply == false )
{
GlobalLogger.info() << "Request timed out" << endl;
istream is( &ReplyBuffer );
if ( !is )
{
- GlobalLogger.error() << "can't handle ReplyBuffer" << endl;
+ GlobalLogger.error() << "Error: can't handle ReplyBuffer" << endl;
return;
}
// 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 );
}
else if ( icmp_packet.match(
IcmpType_DestinationUnreachable, Identifier, SequenceNumber,
- DestinationEndpoint.address()
- ) )
+ DestinationEndpoint.address() ) )
{
ReceivedReply = true;
print_destination_unreachable( icmp_packet );
set_ping_status( PingStatus_FailureDestinationUnreachable );
IcmpPacketReceiveTimer.cancel();
- } else
+ }
+ else
{
/*
GlobalLogger.notice() << "unknown ICMP reply (src IP: " << icmp_packet.get_ip_header().get_source_address() << ")"
*/
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();
}
}
);
if ( ret == -1 )
{
+ GlobalLogger.error() << "Error: could not bind pinger to interface "
+ << source_network_interface << endl;
return false;
}