From: Guilherme Maciel Ferreira Date: Tue, 18 Oct 2011 23:50:05 +0000 (-0200) Subject: Renamed IcmpHeader class to Icmpv4Header, in order to distinguish from ICMP v6 X-Git-Tag: v1.2~57 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=e2a7289787934776028e394ed8e68eaf9c13e601;p=pingcheck Renamed IcmpHeader class to Icmpv4Header, in order to distinguish from ICMP v6 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 10fb523..536a5da 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,11 +48,12 @@ set(SOURCES icmp/icmpechoreplymessage.cpp icmp/icmpechorequestmessage.cpp icmp/icmpgenericmessage.cpp - icmp/icmpheader.cpp + icmp/icmpv4header.cpp icmp/icmpmessage.cpp icmp/icmppacket.cpp icmp/icmppinger.cpp ip/ipv4header.cpp + ip/ipv6header.cpp link/linkstatusanalyzer.cpp link/statusnotifiercommand.cpp tcp/tcpheader.cpp diff --git a/src/icmp/icmppacket.cpp b/src/icmp/icmppacket.cpp index 4268dab..bbebfcb 100644 --- a/src/icmp/icmppacket.cpp +++ b/src/icmp/icmppacket.cpp @@ -5,6 +5,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include "icmp/icmppacket.h" + #include using namespace std; @@ -31,7 +32,7 @@ IcmpPacket::IcmpPacket() : * @param icmp_data The ICMP payload data. */ IcmpPacket::IcmpPacket( - const IcmpHeader &icmp_header, + const Icmpv4Header &icmp_header, const IcmpData &icmp_data ) : IpHeader(), @@ -62,7 +63,7 @@ Ipv4Header IcmpPacket::get_ip_header() const * * @return The ICMP header object. */ -IcmpHeader IcmpPacket::get_icmp_header() const +Icmpv4Header IcmpPacket::get_icmp_header() const { return IcmpPayloadHeader; } diff --git a/src/icmp/icmppacket.h b/src/icmp/icmppacket.h index dfe9445..1106bc0 100644 --- a/src/icmp/icmppacket.h +++ b/src/icmp/icmppacket.h @@ -14,7 +14,7 @@ #include -#include "icmp/icmpheader.h" +#include "icmp/icmpv4header.h" #include "icmp/icmpdata.h" #include "icmp/icmptype.h" #include "ip/ipv4header.h" @@ -70,13 +70,13 @@ class IcmpPacket public: IcmpPacket(); IcmpPacket( - const IcmpHeader &icmp_header, + const Icmpv4Header &icmp_header, const IcmpData &icmp_data ); virtual ~IcmpPacket(); Ipv4Header get_ip_header() const; - IcmpHeader get_icmp_header() const; + Icmpv4Header get_icmp_header() const; IcmpData get_icmp_data() const; bool match( @@ -99,7 +99,7 @@ private: /// The IP header. Ipv4Header IpHeader; /// The ICMP packet header. - IcmpHeader IcmpPayloadHeader; + Icmpv4Header IcmpPayloadHeader; /// The ICMP packet payload (data). IcmpData IcmpPayloadData; }; diff --git a/src/icmp/icmppinger.cpp b/src/icmp/icmppinger.cpp index 4e45e58..56e9e1b 100644 --- a/src/icmp/icmppinger.cpp +++ b/src/icmp/icmppinger.cpp @@ -23,7 +23,7 @@ #include "icmp/icmpchecksum.h" #include "icmp/icmpdata.h" -#include "icmp/icmpheader.h" +#include "icmp/icmpv4header.h" #include "icmp/icmppacket.h" #include "icmp/icmptype.h" #include "ip/ipv4header.h" @@ -140,7 +140,7 @@ IcmpPacket IcmpPinger::create_echo_request( uint16_t checksum = calculator.compute( type, code, Identifier, sequence_number ); - IcmpHeader icmp_header( + Icmpv4Header icmp_header( type, code, checksum, Identifier, sequence_number ); @@ -316,7 +316,7 @@ void IcmpPinger::print_echo_reply( BOOST_ASSERT( icmp_packet.get_icmp_header().get_type() == IcmpType_EchoReply ); Ipv4Header ipv4_header = icmp_packet.get_ip_header(); - IcmpHeader icmp_header = icmp_packet.get_icmp_header(); + Icmpv4Header icmp_header = icmp_packet.get_icmp_header(); size_t bytes_received = bytes_transferred - ipv4_header.get_header_length(); string remote_address = ipv4_header.get_source_address().to_string(); @@ -347,7 +347,7 @@ void IcmpPinger::print_destination_unreachable( BOOST_ASSERT( icmp_packet.get_icmp_header().get_type() == IcmpType_DestinationUnreachable ); Ipv4Header ipv4_hdr = icmp_packet.get_ip_header(); - IcmpHeader icmp_hdr = icmp_packet.get_icmp_header(); + Icmpv4Header icmp_hdr = icmp_packet.get_icmp_header(); string local_address = ipv4_hdr.get_destination_address().to_string(); uint16_t sequence_number = icmp_hdr.get_sequence_number(); diff --git a/src/icmp/icmpheader.cpp b/src/icmp/icmpv4header.cpp similarity index 82% rename from src/icmp/icmpheader.cpp rename to src/icmp/icmpv4header.cpp index 54f4523..2f45211 100644 --- a/src/icmp/icmpheader.cpp +++ b/src/icmp/icmpv4header.cpp @@ -4,7 +4,7 @@ // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include "icmp/icmpheader.h" +#include "icmp/icmpv4header.h" #include "icmp/icmpdestinationunreachablemessage.h" #include "icmp/icmpechoreplymessage.h" @@ -15,15 +15,15 @@ using namespace std; using boost::shared_ptr; //----------------------------------------------------------------------------- -// IcmpHeader +// Icmpv4Header //----------------------------------------------------------------------------- -IcmpHeader::IcmpHeader() : +Icmpv4Header::Icmpv4Header() : MessageFormat() { } -IcmpHeader::IcmpHeader( +Icmpv4Header::Icmpv4Header( IcmpType type, uint8_t code, uint16_t checksum, @@ -41,64 +41,64 @@ IcmpHeader::IcmpHeader( set_sequence_number( sequence_number ); } -IcmpType IcmpHeader::get_type() const +IcmpType Icmpv4Header::get_type() const { return get_icmp_message_format()->get_type(); } -void IcmpHeader::set_type( IcmpType type ) +void Icmpv4Header::set_type( IcmpType type ) { get_icmp_message_format()->set_type( type ); } -uint8_t IcmpHeader::get_code() const +uint8_t Icmpv4Header::get_code() const { return get_icmp_message_format()->get_code(); } -void IcmpHeader::set_code( uint8_t code ) +void Icmpv4Header::set_code( uint8_t code ) { get_icmp_message_format()->set_code( code ); } -uint16_t IcmpHeader::get_checksum() const +uint16_t Icmpv4Header::get_checksum() const { return get_icmp_message_format()->get_checksum(); } -void IcmpHeader::set_checksum( uint16_t checksum ) +void Icmpv4Header::set_checksum( uint16_t checksum ) { get_icmp_message_format()->set_checksum( checksum ); } -uint16_t IcmpHeader::get_identifier() const +uint16_t Icmpv4Header::get_identifier() const { return get_icmp_message_format()->get_identifier(); } -void IcmpHeader::set_identifier( uint16_t identifier ) +void Icmpv4Header::set_identifier( uint16_t identifier ) { get_icmp_message_format()->set_identifier( identifier ); } -uint16_t IcmpHeader::get_sequence_number() const +uint16_t Icmpv4Header::get_sequence_number() const { return get_icmp_message_format()->get_sequence_number(); } -void IcmpHeader::set_sequence_number( uint16_t sequence_number ) +void Icmpv4Header::set_sequence_number( uint16_t sequence_number ) { get_icmp_message_format()->set_sequence_number( sequence_number ); } -shared_ptr IcmpHeader::get_icmp_message_format() const +shared_ptr Icmpv4Header::get_icmp_message_format() const { BOOST_ASSERT( MessageFormat.get() != NULL ); return MessageFormat; } -void IcmpHeader::set_icmp_message_format( IcmpType type ) +void Icmpv4Header::set_icmp_message_format( IcmpType type ) { BOOST_ASSERT( MessageFormat.get() == NULL ); @@ -143,7 +143,7 @@ void IcmpHeader::set_icmp_message_format( IcmpType type ) BOOST_ASSERT( MessageFormat->get_type() != IcmpType_InvalidLast ); } -void IcmpHeader::set_icmp_message_format( std::istream &is ) +void Icmpv4Header::set_icmp_message_format( std::istream &is ) { // read the first byte, which contains the type of the ICMP message char first_byte; @@ -159,7 +159,7 @@ void IcmpHeader::set_icmp_message_format( std::istream &is ) std::istream& operator>>( std::istream &is, - IcmpHeader &header + Icmpv4Header &header ) { // select the message format which will parse the fields @@ -171,7 +171,7 @@ std::istream& operator>>( std::ostream& operator<<( std::ostream &os, - const IcmpHeader &header + const Icmpv4Header &header ) { // delegate the writing of the fields to a specialized encoder diff --git a/src/icmp/icmpheader.h b/src/icmp/icmpv4header.h similarity index 89% rename from src/icmp/icmpheader.h rename to src/icmp/icmpv4header.h index d4dd221..5e07ce4 100644 --- a/src/icmp/icmpheader.h +++ b/src/icmp/icmpv4header.h @@ -4,8 +4,8 @@ // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef ICMP_HEADER_H -#define ICMP_HEADER_H +#ifndef ICMPV4_HEADER_H +#define ICMPV4_HEADER_H #include @@ -18,11 +18,11 @@ #include "icmp/icmptype.h" //----------------------------------------------------------------------------- -// IcmpHeader +// Icmpv4Header //----------------------------------------------------------------------------- /** - * @brief This class represents the ICMP Packet Header. + * @brief This class represents the ICMP version 4 Packet Header. * * The ICMP Generic Header Format is: * @@ -39,11 +39,11 @@ * +-------------------------------+------------------------------+ * @endcode */ -class IcmpHeader +class Icmpv4Header { public: - IcmpHeader(); - IcmpHeader( + Icmpv4Header(); + Icmpv4Header( IcmpType type, uint8_t code, uint16_t checksum, @@ -72,11 +72,11 @@ public: friend std::istream& operator>>( std::istream &is, - IcmpHeader &header + Icmpv4Header &header ); friend std::ostream& operator<<( std::ostream &os, - const IcmpHeader &header + const Icmpv4Header &header ); private: @@ -85,4 +85,4 @@ private: }; -#endif // ICMP_HEADER_H +#endif // ICMPV4_HEADER_H