Renamed IcmpHeader class to Icmpv4Header, in order to distinguish from ICMP v6
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 18 Oct 2011 23:50:05 +0000 (21:50 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 18 Oct 2011 23:50:05 +0000 (21:50 -0200)
src/CMakeLists.txt
src/icmp/icmppacket.cpp
src/icmp/icmppacket.h
src/icmp/icmppinger.cpp
src/icmp/icmpv4header.cpp [moved from src/icmp/icmpheader.cpp with 82% similarity]
src/icmp/icmpv4header.h [moved from src/icmp/icmpheader.h with 89% similarity]

index 10fb523..536a5da 100644 (file)
@@ -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
index 4268dab..bbebfcb 100644 (file)
@@ -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 <iostream>
 
 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;
 }
index dfe9445..1106bc0 100644 (file)
@@ -14,7 +14,7 @@
 
 #include <boost/asio.hpp>
 
-#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;
 };
index 4e45e58..56e9e1b 100644 (file)
@@ -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();
similarity index 82%
rename from src/icmp/icmpheader.cpp
rename to src/icmp/icmpv4header.cpp
index 54f4523..2f45211 100644 (file)
@@ -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<IcmpMessage> IcmpHeader::get_icmp_message_format() const
+shared_ptr<IcmpMessage> 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
similarity index 89%
rename from src/icmp/icmpheader.h
rename to src/icmp/icmpv4header.h
index d4dd221..5e07ce4 100644 (file)
@@ -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 <stdint.h>
 
 #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:
  *
  * +-------------------------------+------------------------------+
  * @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