// TODO move to an init method
protocol_string_map[ "ICMP" ] = PingProtocol_ICMP;
+ protocol_string_map[ "ICMPv6" ] = PingProtocol_ICMPv6;
protocol_string_map[ "TCP" ] = PingProtocol_TCP;
return protocol_string_map[ protocol_string ];
/**
* @brief Parameterized constructor.
+ *
+ * @param io_serv The @c io_service object to control this object.
+ * @param protocol The network layer protocol to use.
+ * @param source_network_interface The network interface name from where to
+ * send the packets.
+ * @param echo_reply_timeout_in_sec The amount of time to wait for a reply.
*/
IcmpPinger::IcmpPinger(
io_service &io_serv,
) :
IoService( io_serv ),
DestinationEndpoint(),
- Socket( IoService, protocol ),
+ Protocol( protocol ),
+ Socket( IoService, Protocol ),
NetInterface( source_network_interface, Socket ),
IcmpPacketReceiveTimer( IoService ),
Identifier( 0 ),
++SequenceNumber;
IcmpPacketItem icmp_packet_echo_request = IcmpPacketFactory::create_icmp_packet_echo_request(
- icmp::v4(), Identifier, SequenceNumber );
+ Protocol, Identifier, SequenceNumber );
BOOST_ASSERT( PingerStatus == PingStatus_NotSent );
send_echo_request( icmp_packet_echo_request );
}
// Decode the reply packet.
- IcmpPacketItem icmp_packet = IcmpPacketFactory::create_icmp_packet( icmp::v4(), is );
+ IcmpPacketItem icmp_packet = IcmpPacketFactory::create_icmp_packet( Protocol, is );
if ( !icmp_packet )
{
GlobalLogger.notice() << "Warning: ignoring broken ICMP packet"
boost::asio::io_service &IoService;
/// The destination host
boost::asio::ip::icmp::endpoint DestinationEndpoint;
+ /// Network layer protocol used to ping, IPv4 or IPv6
+ boost::asio::ip::icmp::socket::protocol_type Protocol;
/// The socket object
boost::asio::ip::icmp::socket Socket;
/// This object represents the network interface