--- a/src/common/packet.cc Fri Sep 08 18:51:47 2006 +0200
+++ b/src/common/packet.cc Fri Sep 08 18:57:40 2006 +0200
@@ -38,16 +38,17 @@
{
m_global_uid++;
}
-Packet::Packet (Buffer buffer, Tags tags)
+Packet::Packet (Buffer buffer, Tags tags, uint32_t uid)
: m_buffer (buffer),
- m_tags (tags)
+ m_tags (tags),
+ m_uid (uid)
{}
Packet
Packet::createFragment (uint32_t start, uint32_t length) const
{
Buffer tmp = m_buffer.createFragment (start, length);
- return Packet (tmp, m_tags);
+ return Packet (tmp, m_tags, m_uid);
}
uint32_t
@@ -129,7 +130,7 @@
}
uint32_t
-Packet::getUid (void)
+Packet::getUid (void) const
{
return m_uid;
}
--- a/src/common/packet.h Fri Sep 08 18:51:47 2006 +0200
+++ b/src/common/packet.h Fri Sep 08 18:57:40 2006 +0200
@@ -87,7 +87,8 @@
class Packet {
public:
/**
- * Create an empty packet.
+ * Create an empty packet with a new uid (as returned
+ * by getUid).
*/
Packet ();
/**
@@ -95,14 +96,15 @@
* The memory necessary for the payload is not allocated:
* it will be allocated at any later point if you attempt
* to fragment this packet or to access the zero-filled
- * bytes.
+ * bytes. The packet is allocated with a new uid (as
+ * returned by getUid).
*
* \param size the size of the zero-filled payload
*/
Packet (uint32_t size);
/**
* Create a new packet which contains a fragment of the original
- * packet.
+ * packet. The returned packet shares the same uid as this packet.
*
* \param start offset from start of packet to start of fragment to create
* \param length length of fragment to create
@@ -183,7 +185,7 @@
void removeAllTags (void);
/**
* Concatenate the input packet at the end of the current
- * packet.
+ * packet. This does not alter the uid of either packet.
*
* \param packet packet to concatenate
*/
@@ -191,7 +193,7 @@
/**
* Concatenate the fragment of the input packet identified
* by the offset and size parameters at the end of the current
- * packet.
+ * packet. This does not alter the uid of either packet.
*
* \param packet to concatenate
* \param offset offset of fragment to copy from the start of the input packet
@@ -223,9 +225,16 @@
*/
uint8_t const *peekData (void) const;
+ /**
+ * A packet is allocated a new uid when it is created
+ * empty or with zero-filled payload.
+ *
+ * \returns an integer identifier which uniquely
+ * identifies this packet.
+ */
uint32_t getUid (void) const;
private:
- Packet (Buffer buffer, Tags tags);
+ Packet (Buffer buffer, Tags tags, uint32_t uid);
Buffer m_buffer;
Tags m_tags;
uint32_t m_uid;