void IcmpPacketDistributor::register_receive_handler()
{
- // Waiting for a reply, We prepare the buffer to receive up to SOCKET_BUFFER_SIZE bytes
+ // wait for reply, prepare buffer to receive up to SOCKET_BUFFER_SIZE bytes
Socket->async_receive(
ReplyBuffer.prepare( SOCKET_BUFFER_SIZE ),
boost::bind( &IcmpPacketDistributor::handle_receive, this,
);
}
-void IcmpPacketDistributor::handle_receive( const boost::system::error_code &error,
- const size_t &bytes_transferred )
+void IcmpPacketDistributor::handle_receive(
+ const boost::system::error_code &error,
+ const size_t &bytes_transferred )
{
if ( error )
{
}
// Decode the reply packet.
- IcmpPacketItem icmp_packet = IcmpPacketFactory::create_icmp_packet( Protocol, is );
+ IcmpPacketItem icmp_packet = IcmpPacketFactory::create_icmp_packet(
+ Protocol, is );
if ( !icmp_packet )
{
- GlobalLogger.warning() << "Ignoring broken ICMP packet" << std::endl;
+ GlobalLogger.warning() << "Ignoring broken ICMP packet"
+ << std::endl;
}
// check which pinger wants this packet
bool packet_matches = false;
BOOST_FOREACH( IcmpPingerItem pinger, PingerList )
{
- packet_matches |= pinger->handle_receive_icmp_packet(icmp_packet, bytes_received);
+ packet_matches |= pinger->handle_receive_icmp_packet(icmp_packet,
+ bytes_received);
if (packet_matches)
break;
}
if (!packet_matches)
- GlobalLogger.warning() << "Packet did not match any pinger" << std::endl;
+ GlobalLogger.warning() << "Packet did not match any pinger"
+ << std::endl;
catch ( ... )
{
std::pair<PingerListIterator, bool> result = PingerList.insert(new_pinger);
bool was_new = result.second;
if (was_new)
- GlobalLogger.info() << "Register new pinger with IcmpPacketDistributor" << std::endl;
+ GlobalLogger.info() << "Register new pinger with IcmpPacketDistributor"
+ << std::endl;
else
- GlobalLogger.warning() << "Pinger to register was already known in IcmpPacketDistributor"
- << std::endl;
+ GlobalLogger.warning()
+ << "Pinger to register was already known in IcmpPacketDistributor"
+ << std::endl;
return was_new;
}
int n_erased = PingerList.erase(old_pinger);
bool was_erased = n_erased > 0;
if (was_erased)
- GlobalLogger.info() << "Removed pinger from IcmpPacketDistributor" << std::endl;
+ GlobalLogger.info() << "Removed pinger from IcmpPacketDistributor"
+ << std::endl;
else
- GlobalLogger.warning() << "Could not find pinger to remove from IcmpPacketDistributor"
- << std::endl;
+ GlobalLogger.warning()
+ << "Could not find pinger to remove from IcmpPacketDistributor"
+ << std::endl;
return was_erased;
}
PingerList.clear();
boost::system::error_code error;
- //Socket->shutdown(icmp::socket::shutdown_both, error); // both=send and receive
+ //Socket->shutdown(icmp::socket::shutdown_both, error); //both=send&receive
//if ( error )
- // GlobalLogger.warning() << "Received error " << error << " when shutting down ICMP socket";
+ // GlobalLogger.warning() << "Received error " << error
+ // << " when shutting down ICMP socket";
// always gave an error system:9 (probably EBADF: Bad file descriptor)
Socket->close(error);
if ( error )
- GlobalLogger.warning() << "Received error " << error << " when closing ICMP socket";
+ GlobalLogger.warning() << "Received error " << error
+ << " when closing ICMP socket";
}
IcmpPacketDistributor::~IcmpPacketDistributor()