//-----------------------------------------------------------------------------
IcmpPinger::IcmpPinger(
- boost::asio::io_service &io_service,
- string source_network_interface,
+ io_service &io_serv,
+ const string &source_network_interface,
const int echo_reply_timeout_in_sec
) :
- IoService( io_service ),
+ IoService( io_serv ),
DestinationEndpoint(),
Socket( IoService, icmp::v4() ),
IcmpPacketReceiveTimer( IoService ),
}
/**
- * Ping a destination address from an available local source.
+ * @brief Ping a destination address from an available local source.
*
* @param destination_ip The address of the host to ping.
* @param done_handler Done handler will be called on successful ping or timeout
*/
void IcmpPinger::ping(
const string &destination_ip,
- boost::function< void(bool) > ping_done_callback
+ function< void(bool) > ping_done_callback
)
{
BOOST_ASSERT( !destination_ip.empty() );
{
// Check ReceivedReply as the timer handler
// is also called by Timer.cancel();
- if (ReceivedReply == false)
+ if ( ReceivedReply == false )
{
GlobalLogger.info() << "Request timed out" << endl;
IcmpPacketReceiveTimer.cancel();
} else
{
- /*
- GlobalLogger.notice() << "unknown ICMP reply (src IP: " << icmp_packet.get_ip_header().get_source_address() << ")"
- << ". Starting another recieve till timeout." << endl;
- */
+ // Unknown ICMP reply, start another receive till timeout
start_receive();
}
- } catch(...)
+ }
+ catch ( ... )
{
GlobalLogger.notice() << "exception during ICMP parse. Starting another recieve till timeout." << endl;
start_receive();
#ifndef ICMPPINGER_H
#define ICMPPINGER_H
+#include <string>
+
#include <boost/asio.hpp>
#include <boost/function.hpp>
{
public:
IcmpPinger(
- boost::asio::io_service &io_service,
- std::string source_network_interface,
+ boost::asio::io_service &io_serv,
+ const std::string &source_network_interface,
const int echo_reply_timeout_in_sec
);
virtual ~IcmpPinger();