The IcmpPacket's write() method returns a boolean, mirroring the read() method.
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sun, 6 Nov 2011 21:35:25 +0000 (19:35 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sun, 6 Nov 2011 21:35:25 +0000 (19:35 -0200)
src/icmp/icmppacket.h
src/icmp/icmpv4packet.cpp
src/icmp/icmpv4packet.h
src/icmp/icmpv6packet.cpp
src/icmp/icmpv6packet.h

index 3760ede..352e105 100644 (file)
@@ -24,7 +24,6 @@
 #include <stdint.h>
 
 #include <iostream>
-#include <string>
 
 #include <boost/asio.hpp>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
@@ -58,7 +57,7 @@ public:
     virtual void print_destination_unreachable() const = 0;
 
     virtual bool read( std::istream &is ) = 0;
-    virtual void write( std::ostream &os ) const = 0;
+    virtual bool write( std::ostream &os ) const = 0;
 
 protected:
     IcmpPacket();
index 180d464..3bd148b 100644 (file)
@@ -86,13 +86,13 @@ IcmpData Icmpv4Packet::get_icmp_data() const
 
 /**
  * @brief Convenience method to check if this packet, matching the arguments,
- * is a echo reply.
+ * is an echo reply.
  *
  * @param identifier The identifier.
  * @param sequence_number The sequence number.
  * @param source_address The source address.
  *
- * @return @c true if this packet is a echo reply, or @c false otherwise.
+ * @return @c true if this packet is an echo reply, or @c false otherwise.
  */
 bool Icmpv4Packet::match_echo_reply(
         const uint16_t identifier,
@@ -211,9 +211,13 @@ bool Icmpv4Packet::read( istream &is )
     return is.fail();
 }
 
-void Icmpv4Packet::write( ostream &os ) const
+bool Icmpv4Packet::write( ostream &os ) const
 {
+    os.clear();
+
     os << *this;
+
+    return os.fail();
 }
 
 istream& operator>>(
index 459ea58..ac1c7f0 100644 (file)
@@ -98,7 +98,7 @@ public:
     virtual void print_destination_unreachable() const;
 
     virtual bool read( std::istream &is );
-    virtual void write( std::ostream &os ) const;
+    virtual bool write( std::ostream &os ) const;
 
     friend std::istream& operator>>(
             std::istream &is,
index 1823d31..02a08f2 100644 (file)
@@ -211,9 +211,13 @@ bool Icmpv6Packet::read( istream &is )
     return is.fail();
 }
 
-void Icmpv6Packet::write( ostream &os ) const
+bool Icmpv6Packet::write( ostream &os ) const
 {
+    os.clear();
+
     os << *this;
+
+    return os.fail();
 }
 
 istream& operator>>(
index 5ad9db1..2816b0b 100644 (file)
@@ -112,7 +112,7 @@ public:
     virtual void print_destination_unreachable() const;
 
     virtual bool read( std::istream &is );
-    virtual void write( std::ostream &os ) const;
+    virtual bool write( std::ostream &os ) const;
 
     friend std::istream& operator>>(
             std::istream &is,