// expected sequence number, and destination host address (receive just
// the ICMP packets from the host we had ping).
- if ( icmp_packet->match_echo_reply(
- Identifier, SequenceNumber,
- DestinationEndpoint.address() ) )
+ try
{
- GlobalLogger.info()
- << DestinationEndpoint.address().to_string()
- << ": Received reply" << endl;
+ if ( icmp_packet->match_echo_reply(
+ Identifier, SequenceNumber,
+ DestinationEndpoint.address() ) )
+ {
+ GlobalLogger.info()
+ << DestinationEndpoint.address().to_string()
+ << ": Received reply" << endl;
- ReplyReceived = true;
- does_match = true;
+ ReplyReceived = true;
+ does_match = true;
- icmp_packet->print( bytes_transferred, TimeSent );
+ icmp_packet->print( bytes_transferred, TimeSent );
- set_ping_status( PingStatus_SuccessReply );
+ set_ping_status( PingStatus_SuccessReply );
- IcmpPacketReceiveTimer.cancel(); //lint !e534
- }
- else if ( icmp_packet->match_destination_unreachable(
- Identifier, SequenceNumber,
- DestinationEndpoint.address() ) )
- {
- GlobalLogger.info()
- << DestinationEndpoint.address().to_string()
- << ": Received destination unreachable" << endl;
+ IcmpPacketReceiveTimer.cancel(); //lint !e534
+ }
+ else if ( icmp_packet->match_destination_unreachable(
+ Identifier, SequenceNumber,
+ DestinationEndpoint.address() ) )
+ {
+ GlobalLogger.info()
+ << DestinationEndpoint.address().to_string()
+ << ": Received destination unreachable" << endl;
- ReplyReceived = true;
- does_match = true;
+ ReplyReceived = true;
+ does_match = true;
- icmp_packet->print( bytes_transferred, TimeSent );
+ icmp_packet->print( bytes_transferred, TimeSent );
- set_ping_status( PingStatus_FailureDestinationUnreachable );
+ set_ping_status( PingStatus_FailureDestinationUnreachable );
- IcmpPacketReceiveTimer.cancel(); //lint !e534
- }
- else if ( icmp_packet->match_time_exceeded(
- Identifier, SequenceNumber,
- DestinationEndpoint.address() ) )
- {
- GlobalLogger.info()
- << DestinationEndpoint.address().to_string()
- << ": Received time exceeded" << endl;
+ IcmpPacketReceiveTimer.cancel(); //lint !e534
+ }
+ else if ( icmp_packet->match_time_exceeded(
+ Identifier, SequenceNumber,
+ DestinationEndpoint.address() ) )
+ {
+ GlobalLogger.info()
+ << DestinationEndpoint.address().to_string()
+ << ": Received time exceeded" << endl;
- ReplyReceived = true;
- does_match = true;
+ ReplyReceived = true;
+ does_match = true;
- icmp_packet->print( bytes_transferred, TimeSent );
+ icmp_packet->print( bytes_transferred, TimeSent );
- set_ping_status( PingStatus_FailureDestinationUnreachable );
+ set_ping_status( PingStatus_FailureDestinationUnreachable );
- IcmpPacketReceiveTimer.cancel(); //lint !e534
+ IcmpPacketReceiveTimer.cancel(); //lint !e534
+ }
+ else
+ {
+ GlobalLogger.debug()
+ << DestinationEndpoint.address().to_string()
+ << ": Received packet that does not match or has wrong seq.nr"
+ << endl;
+ }
}
- else
+ catch ( std::exception &exc)
{
- GlobalLogger.debug()
- << DestinationEndpoint.address().to_string()
- << ": Received packet that does not match or has wrong seq.nr"
- << endl;
+ GlobalLogger.warning()
+ << DestinationEndpoint.address().to_string()
+ << ": Caught exception in packet interpretation: " << exc.what()
+ << std::endl;
+ if ( IcmpPacketFactory::PacketDumpMode == DUMP_ALWAYS ||
+ IcmpPacketFactory::PacketDumpMode == DUMP_IF_ERROR )
+ IcmpPacketFactory::dump_packet(*icmp_packet);
+ does_match = true; // avoid the same procedure in all other pingers
+ }
+ catch ( ... )
+ {
+ GlobalLogger.warning()
+ << DestinationEndpoint.address().to_string()
+ << ": Caught unspecified exception in packet interpretation!"
+ << std::endl;
+ if ( IcmpPacketFactory::PacketDumpMode == DUMP_ALWAYS ||
+ IcmpPacketFactory::PacketDumpMode == DUMP_IF_ERROR )
+ IcmpPacketFactory::dump_packet(*icmp_packet);
+ does_match = true; // avoid the same procedure in all other pingers
}
return does_match;
}
if (!packet_matches)
GlobalLogger.info() << "Packet did not match any pinger"
- << std::endl;
+ << std::endl;
}
// re-register receive handler