From: Guilherme Maciel Ferreira Date: Fri, 18 Nov 2011 02:00:21 +0000 (-0200) Subject: It is working, and can be configurated, the ICMP ping over IPv6 X-Git-Tag: v1.2~14 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=5b008ada48fc49c900021a35401024944067b1c3;p=pingcheck It is working, and can be configurated, the ICMP ping over IPv6 --- diff --git a/src/host/pingprotocol.cpp b/src/host/pingprotocol.cpp index 79ff9c5..548e157 100644 --- a/src/host/pingprotocol.cpp +++ b/src/host/pingprotocol.cpp @@ -34,6 +34,7 @@ PingProtocol get_ping_protocol_from_string( string protocol_string ) // 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 ]; diff --git a/src/icmp/icmppinger.cpp b/src/icmp/icmppinger.cpp index f03057f..d2bb4db 100644 --- a/src/icmp/icmppinger.cpp +++ b/src/icmp/icmppinger.cpp @@ -39,6 +39,12 @@ using I2n::Logger::GlobalLogger; /** * @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, @@ -48,7 +54,8 @@ IcmpPinger::IcmpPinger( ) : IoService( io_serv ), DestinationEndpoint(), - Socket( IoService, protocol ), + Protocol( protocol ), + Socket( IoService, Protocol ), NetInterface( source_network_interface, Socket ), IcmpPacketReceiveTimer( IoService ), Identifier( 0 ), @@ -123,7 +130,7 @@ void IcmpPinger::start_send() ++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 ); @@ -232,7 +239,7 @@ void IcmpPinger::handle_receive_icmp_packet( const size_t &bytes_transferred ) } // 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" diff --git a/src/icmp/icmppinger.h b/src/icmp/icmppinger.h index 57b5edb..bb0f17f 100644 --- a/src/icmp/icmppinger.h +++ b/src/icmp/icmppinger.h @@ -60,6 +60,8 @@ private: 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