diff --git a/src/network/model/packet.cc b/src/network/model/packet.cc index 9815dabc3..80ede2837 100644 --- a/src/network/model/packet.cc +++ b/src/network/model/packet.cc @@ -412,6 +412,14 @@ Packet::PrintByteTags (std::ostream &os) const } } +std::string +Packet::ToString() const +{ + std::ostringstream oss; + Print (oss); + return oss.str(); +} + void Packet::Print (std::ostream &os) const { diff --git a/src/network/model/packet.h b/src/network/model/packet.h index 050e36c6f..a6f3bd444 100644 --- a/src/network/model/packet.h +++ b/src/network/model/packet.h @@ -453,6 +453,15 @@ public: */ void Print (std::ostream &os) const; + /** + * \brief Return a string representation of the packet + * + * An empty string is returned if you haven't called EnablePrinting () + * + * \return String representation + */ + std::string ToString (void) const; + /** * \brief Returns an iterator which points to the first 'item' * stored in this buffer.