// can extract it using a std::istream object.
ReplyBuffer.commit( bytes_transferred );
- istream is( &ReplyBuffer );
- if ( !is )
+ try
{
- GlobalLogger.error() << "Error: can't handle ReplyBuffer" << endl;
- return;
- }
+ istream is( &ReplyBuffer );
+ if ( !is )
+ {
+ GlobalLogger.error() << "Error: can't handle ReplyBuffer" << endl;
+ return;
+ }
- Ipv4Header ipv4_header;
- TcpHeader tcp_header;
- is >> ipv4_header >> tcp_header;
+ Ipv4Header ipv4_header;
+ TcpHeader tcp_header;
+ is >> ipv4_header >> tcp_header;
- // filter out only the TCP reset (RST) replies. Note that the sequence
- // number from RST does not match the sent ACK's sequence number.
- if ( is &&
- tcp_header.reset() &&
- ipv4_header.get_source_address() == DestinationEndpoint.address() )
- {
- ReceivedReply = true;
+ // filter out only the TCP reset (RST) replies. Note that the sequence
+ // number from RST does not match the sent ACK's sequence number.
+ if ( is &&
+ tcp_header.reset() &&
+ ipv4_header.get_source_address() == DestinationEndpoint.address() )
+ {
+ ReceivedReply = true;
- print_rst_reply( ipv4_header, tcp_header );
+ print_rst_reply( ipv4_header, tcp_header );
- set_ping_status( PingStatus_SuccessReply );
+ set_ping_status( PingStatus_SuccessReply );
- TcpSegmentReceiveTimer.cancel();
+ TcpSegmentReceiveTimer.cancel();
+ }
+ // Unknown TCP reply, start another receive till timeout
+ else
+ {
+ start_receive();
+ }
+ }
+ catch ( ... )
+ {
+ GlobalLogger.notice() << "Warning: exception during ICMP parse. "
+ << "Starting another receive till timeout." << endl;
+ start_receive();
}
-
- // TODO need to be in the catch or else?
- // TODO why does the ping fail? Does the callback receive false?
- start_receive();
}
/**