add packet constructor which accepts payload buffer.
--- a/src/common/packet.cc Fri Feb 09 19:40:19 2007 +0100
+++ b/src/common/packet.cc Sat Feb 10 10:24:36 2007 +0100
@@ -38,6 +38,16 @@
{
m_global_uid++;
}
+Packet::Packet (uint8_t const*buffer, uint32_t size)
+ : m_buffer (),
+ m_uid (m_global_uid)
+{
+ m_global_uid++;
+ m_buffer.AddAtStart (size);
+ Buffer::Iterator i = m_buffer.Begin ();
+ i.Write (buffer, size);
+}
+
Packet::Packet (Buffer buffer, Tags tags, uint32_t uid)
: m_buffer (buffer),
m_tags (tags),
--- a/src/common/packet.h Fri Feb 09 19:40:19 2007 +0100
+++ b/src/common/packet.h Sat Feb 10 10:24:36 2007 +0100
@@ -104,6 +104,15 @@
*/
Packet (uint32_t size);
/**
+ * Create a packet with payload filled with the content
+ * of this buffer. The input data is copied: the input
+ * buffer is untouched.
+ *
+ * \param buffer the data to store in the packet.
+ * \param size the size of the input buffer.
+ */
+ Packet (uint8_t const*buffer, uint32_t size);
+ /**
* Create a new packet which contains a fragment of the original
* packet. The returned packet shares the same uid as this packet.
*