Renamed IcmpPacket class to Icmpv4Packet, in order to distinguish from the ICMPv6...
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Wed, 19 Oct 2011 23:55:58 +0000 (21:55 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Wed, 19 Oct 2011 23:55:58 +0000 (21:55 -0200)
src/CMakeLists.txt
src/icmp/icmppinger.cpp
src/icmp/icmppinger.h
src/icmp/icmpv4packet.cpp [moved from src/icmp/icmppacket.cpp with 87% similarity]
src/icmp/icmpv4packet.h [moved from src/icmp/icmppacket.h with 94% similarity]

index 536a5da..a5a93ac 100644 (file)
@@ -50,7 +50,7 @@ set(SOURCES
     icmp/icmpgenericmessage.cpp
     icmp/icmpv4header.cpp
     icmp/icmpmessage.cpp
-    icmp/icmppacket.cpp
+    icmp/icmpv4packet.cpp
     icmp/icmppinger.cpp
     ip/ipv4header.cpp
     ip/ipv6header.cpp
index 56e9e1b..a7cf8b8 100644 (file)
@@ -24,7 +24,7 @@
 #include "icmp/icmpchecksum.h"
 #include "icmp/icmpdata.h"
 #include "icmp/icmpv4header.h"
-#include "icmp/icmppacket.h"
+#include "icmp/icmpv4packet.h"
 #include "icmp/icmptype.h"
 #include "ip/ipv4header.h"
 
@@ -122,13 +122,13 @@ void IcmpPinger::start_send()
 {
     ++SequenceNumber;
 
-    IcmpPacket icmp_echo_request_packet = create_echo_request( SequenceNumber );
+    Icmpv4Packet icmp_echo_request_packet = create_echo_request( SequenceNumber );
 
     BOOST_ASSERT( PingerStatus == PingStatus_NotSent );
     send_echo_request( icmp_echo_request_packet );
 }
 
-IcmpPacket IcmpPinger::create_echo_request(
+Icmpv4Packet IcmpPinger::create_echo_request(
         const uint16_t sequence_number
 ) const
 {
@@ -144,10 +144,10 @@ IcmpPacket IcmpPinger::create_echo_request(
             type, code, checksum, Identifier, sequence_number
     );
 
-    return IcmpPacket( icmp_header, icmp_data );
+    return Icmpv4Packet( icmp_header, icmp_data );
 }
 
-void IcmpPinger::send_echo_request( const IcmpPacket &icmp_packet )
+void IcmpPinger::send_echo_request( const Icmpv4Packet &icmp_packet )
 {
     boost::asio::streambuf request_buffer;
     ostream os( &request_buffer );
@@ -250,7 +250,7 @@ void IcmpPinger::handle_receive_icmp_packet( const size_t &bytes_transferred )
         }
 
         // Decode the reply packet.
-        IcmpPacket icmp_packet;
+        Icmpv4Packet icmp_packet;
         if (! (is >> icmp_packet) )
         {
             GlobalLogger.notice() << "Warning: ignoring broken ICMP packet"
@@ -304,12 +304,12 @@ void IcmpPinger::handle_receive_icmp_packet( const size_t &bytes_transferred )
 /**
  * @brief Prints the ICMP echo reply messages.
  *
- * @param icmp_packet The IcmpPacket object containing the received echo reply data.
+ * @param icmp_packet The Icmpv4Packet object containing the received echo reply data.
  * @param bytes_transferred Number of bytes transferred.
  * @return void
  */
 void IcmpPinger::print_echo_reply(
-        const IcmpPacket &icmp_packet,
+        const Icmpv4Packet &icmp_packet,
         const size_t &bytes_transferred
 ) const
 {
@@ -336,12 +336,12 @@ void IcmpPinger::print_echo_reply(
 /**
  * @brief Prints the destination unreachable messages.
  *
- * @param icmp_packet The IcmpPacket object containing the received destination
+ * @param icmp_packet The Icmpv4Packet object containing the received destination
  * unreachable data.
  * @return void
  */
 void IcmpPinger::print_destination_unreachable(
-        const IcmpPacket &icmp_packet
+        const Icmpv4Packet &icmp_packet
 ) const
 {
     BOOST_ASSERT( icmp_packet.get_icmp_header().get_type() == IcmpType_DestinationUnreachable );
index d0a09c6..da294d7 100644 (file)
@@ -16,7 +16,7 @@
 #include "host/pinger.h"
 #include "host/pingstatus.h"
 
-class IcmpPacket;
+class Icmpv4Packet;
 
 //-----------------------------------------------------------------------------
 // IcmpPinger
@@ -46,8 +46,8 @@ private:
     void set_destination_endpoint( const std::string &destination_ip );
 
     void start_send();
-    IcmpPacket create_echo_request( const uint16_t sequence_number ) const;
-    void send_echo_request( const IcmpPacket &icmp_packet );
+    Icmpv4Packet create_echo_request( const uint16_t sequence_number ) const;
+    void send_echo_request( const Icmpv4Packet &icmp_packet );
     void schedule_timeout_echo_reply();
     void handle_ping_done();
 
@@ -55,11 +55,11 @@ private:
     void handle_receive_icmp_packet( const std::size_t &bytes_transferred );
 
     void print_echo_reply(
-            const IcmpPacket &icmp_packet,
+            const Icmpv4Packet &icmp_packet,
             const std::size_t &bytes_transferred
     ) const;
     void print_destination_unreachable(
-            const IcmpPacket &icmp_packet
+            const Icmpv4Packet &icmp_packet
     ) const;
 
     void set_ping_status( PingStatus ping_status );
similarity index 87%
rename from src/icmp/icmppacket.cpp
rename to src/icmp/icmpv4packet.cpp
index bbebfcb..fea6701 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/icmppacket.h"
+#include "icmp/icmpv4packet.h"
 
 #include <iostream>
 
@@ -12,13 +12,13 @@ using namespace std;
 using boost::asio::ip::address;
 
 //-----------------------------------------------------------------------------
-// IcmpPacket
+// Icmpv4Packet
 //-----------------------------------------------------------------------------
 
 /**
  * @brief Default constructor.
  */
-IcmpPacket::IcmpPacket() :
+Icmpv4Packet::Icmpv4Packet() :
     IpHeader(),
     IcmpPayloadHeader(),
     IcmpPayloadData()
@@ -31,7 +31,7 @@ IcmpPacket::IcmpPacket() :
  * @param icmp_header The ICMP header.
  * @param icmp_data The ICMP payload data.
  */
-IcmpPacket::IcmpPacket(
+Icmpv4Packet::Icmpv4Packet(
         const Icmpv4Header &icmp_header,
         const IcmpData &icmp_data
 ) :
@@ -44,7 +44,7 @@ IcmpPacket::IcmpPacket(
 /**
  * @brief Destructor.
  */
-IcmpPacket::~IcmpPacket()
+Icmpv4Packet::~Icmpv4Packet()
 {
 }
 
@@ -53,7 +53,7 @@ IcmpPacket::~IcmpPacket()
  *
  * @return The IP header object.
  */
-Ipv4Header IcmpPacket::get_ip_header() const
+Ipv4Header Icmpv4Packet::get_ip_header() const
 {
     return IpHeader;
 }
@@ -63,7 +63,7 @@ Ipv4Header IcmpPacket::get_ip_header() const
  *
  * @return The ICMP header object.
  */
-Icmpv4Header IcmpPacket::get_icmp_header() const
+Icmpv4Header Icmpv4Packet::get_icmp_header() const
 {
     return IcmpPayloadHeader;
 }
@@ -73,7 +73,7 @@ Icmpv4Header IcmpPacket::get_icmp_header() const
  *
  * @return The ICMP data.
  */
-IcmpData IcmpPacket::get_icmp_data() const
+IcmpData Icmpv4Packet::get_icmp_data() const
 {
     return IcmpPayloadData;
 }
@@ -89,7 +89,7 @@ IcmpData IcmpPacket::get_icmp_data() const
  * @return @c true if this matches all the parameters, or @c false if at least
  * one does not match.
  */
-bool IcmpPacket::match(
+bool Icmpv4Packet::match(
         const IcmpType type,
         const uint16_t identifier,
         const uint16_t sequence_number,
@@ -106,7 +106,7 @@ bool IcmpPacket::match(
 
 istream& operator>>(
         istream &is,
-        IcmpPacket &packet
+        Icmpv4Packet &packet
 )
 {
     is >> packet.IpHeader >> packet.IcmpPayloadHeader >> packet.IcmpPayloadData;
@@ -116,7 +116,7 @@ istream& operator>>(
 
 ostream& operator<<(
         ostream& os,
-        const IcmpPacket& packet
+        const Icmpv4Packet& packet
 )
 {
     os << packet.IcmpPayloadHeader << packet.IcmpPayloadData;
similarity index 94%
rename from src/icmp/icmppacket.h
rename to src/icmp/icmpv4packet.h
index 1106bc0..26fa9be 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 ICMPPACKET_H
-#define ICMPPACKET_H
+#ifndef ICMPV4PACKET_H
+#define ICMPV4PACKET_H
 
 #include <stdint.h>
 
@@ -20,7 +20,7 @@
 #include "ip/ipv4header.h"
 
 //-----------------------------------------------------------------------------
-// IcmpPacket
+// Icmpv4Packet
 //-----------------------------------------------------------------------------
 
 /**
  * +-------------------------------+------------------------------+      ---
  * @endcode
  */
-class IcmpPacket
+class Icmpv4Packet
 {
 public:
-    IcmpPacket();
-    IcmpPacket(
+    Icmpv4Packet();
+    Icmpv4Packet(
             const Icmpv4Header &icmp_header,
             const IcmpData &icmp_data
     );
-    virtual ~IcmpPacket();
+    virtual ~Icmpv4Packet();
 
     Ipv4Header get_ip_header() const;
     Icmpv4Header get_icmp_header() const;
@@ -88,11 +88,11 @@ public:
 
     friend std::istream& operator>>(
             std::istream &is,
-            IcmpPacket &packet
+            Icmpv4Packet &packet
     );
     friend std::ostream& operator<<(
             std::ostream &os,
-            const IcmpPacket &packet
+            const Icmpv4Packet &packet
     );
 
 private:
@@ -104,4 +104,4 @@ private:
     IcmpData IcmpPayloadData;
 };
 
-#endif /* ICMPPACKET_H */
+#endif // ICMPV4PACKET_H