#include <stdint.h>
#include <iostream>
-#include <string>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
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();
/**
* @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,
return is.fail();
}
-void Icmpv4Packet::write( ostream &os ) const
+bool Icmpv4Packet::write( ostream &os ) const
{
+ os.clear();
+
os << *this;
+
+ return os.fail();
}
istream& operator>>(
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,
return is.fail();
}
-void Icmpv6Packet::write( ostream &os ) const
+bool Icmpv6Packet::write( ostream &os ) const
{
+ os.clear();
+
os << *this;
+
+ return os.fail();
}
istream& operator>>(
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,