Fixed assertion range on times_to_ping
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@intra2net.com>
Mon, 7 Mar 2011 14:30:28 +0000 (15:30 +0100)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@intra2net.com>
Mon, 7 Mar 2011 14:30:28 +0000 (15:30 +0100)
src/ping/boostpinger.cpp

index 8e44269..70c4eee 100644 (file)
@@ -35,7 +35,7 @@ BoostPinger::BoostPinger(
     ReplyBuffer(),
     RepliesCount( 0 ),
     TimesToPingTotal( 0 ),
-    MinTimesToPing( 0 ),
+    MinTimesToPing( 1 ),
     MaxTimesToPing( numeric_limits<uint>::max() )
 {
 }
@@ -50,7 +50,7 @@ void BoostPinger::ping(
 )
 {
     BOOST_ASSERT( !destination.empty() );
-    BOOST_ASSERT( ( MinTimesToPing < times_to_ping ) && ( times_to_ping < MaxTimesToPing ) );
+    BOOST_ASSERT( ( MinTimesToPing <= times_to_ping ) && ( times_to_ping <= MaxTimesToPing ) );
 
     icmp::resolver::query query( icmp::v4(), destination, "" );
     DestinationEndpoint = *Resolver.resolve( query );
@@ -92,7 +92,6 @@ IcmpPacket BoostPinger::create_echo_request_packet()
 {
     IcmpData icmp_data( "ping-message" );
 
-    // Create an ICMP header for an echo request.
     SequenceNumber++;
     IcmpHeader::IcmpType type = IcmpHeader::EchoRequest;
     uint8_t code = 0;
@@ -101,7 +100,6 @@ IcmpPacket BoostPinger::create_echo_request_packet()
     uint16_t checksum = calculator.compute( type, code, identifier, SequenceNumber );
     IcmpHeader icmp_header( type, code, checksum, identifier, SequenceNumber );
 
-    // Encode the ICMP header and data in an ICMP packet.
     return IcmpPacket( icmp_header, icmp_data );
 }