SequenceNumber( 0 ),
TimeSent( microsec_clock::universal_time() ),
ReplyBuffer(),
- RepliesCount( 0 ),
+ ReceivedReply( false ),
EchoReplyTimeoutInSec( echo_reply_timeout_in_sec ),
PingerStatus( PingStatus_NotSent ),
PingDoneCallback()
void BoostPinger::schedule_timeout_echo_reply()
{
// Wait up to N seconds for a reply.
- RepliesCount = 0;
+ ReceivedReply = false;
(void) IcmpPacketReceiveTimer.expires_at(
TimeSent + seconds( EchoReplyTimeoutInSec )
);
**/
void BoostPinger::handle_ping_done()
{
- // Check reply count as the timer handler
+ // Check ReceivedReply as the timer handler
// is also called by Timer.cancel();
- if (RepliesCount == 0)
+ if (ReceivedReply == false)
{
GlobalLogger.info() << "Request timed out" << endl;
DestinationEndpoint.address())
)
{
- ++RepliesCount;
+ ReceivedReply = true;
print_echo_reply( icmp_packet, bytes_transferred );
DestinationEndpoint.address()
) )
{
- ++RepliesCount;
+ ReceivedReply = true;
print_destination_unreachable( icmp_packet );
set_ping_status( PingStatus_FailureDestinationUnreachable );
boost::posix_time::ptime TimeSent;
/// the buffer where the data received will be placed
boost::asio::streambuf ReplyBuffer;
+ /// Flag to indicate if we got a reply or not
/// number of replies to the ICMP echo request
- int RepliesCount;
+ bool ReceivedReply;
/// the amount of time to wait for the reply
int EchoReplyTimeoutInSec;
/// the status of the pinger
BoostPinger::PingStatus PingerStatus;
-
+ /// Callback to notify when the ping is done (got reply/timeout)
boost::function< void(bool) > PingDoneCallback;
};