30#include "ns3/fatal-error.h"
40PacketTagList::TagData*
44 "Requested TagData size " << dataSize <<
" exceeds maximum "
47 void* p = std::malloc(
sizeof(
TagData) + dataSize - 1);
75 while (cur !=
nullptr)
83 else if (cur->
tid == tid)
85 NS_LOG_INFO(
"found tid before initial merge, calling writer");
86 found = (this->*Writer)(tag,
true, cur, prevNext);
92 prevNext = &cur->
next;
98 if (cur ==
nullptr || found)
100 NS_LOG_INFO(
"returning after header with found: " << found);
108 for (it = cur; it !=
nullptr; it = it->
next)
149 while ( cur->
tid != tid)
162 prevNext = ©->
next;
171 found = (this->*Writer)(tag,
false, cur, prevNext);
193 *prevNext = cur->
next;
206 if (cur->
next !=
nullptr)
252 if (copy->
next !=
nullptr)
269 "Error: cannot add the same kind of tag twice.");
273 head->
next =
nullptr;
323 uint32_t tagWordSize = (cur->size + 3) & (~3);
340 if (size + 4 <= maxSize)
353 if (size + 4 <= maxSize)
367 if (size + hashSize <= maxSize)
380 uint32_t tagWordSize = (cur->size + 3) & (~3);
381 if (size + tagWordSize <= maxSize)
383 memcpy(p, cur->data, cur->size);
385 p += tagWordSize / 4;
410 NS_LOG_INFO(
"Deserializing number of tags " << numberOfTags);
413 for (
uint32_t i = 0; i < numberOfTags; ++i)
424 sizeCheck -= hashSize;
432 newTag->
next =
nullptr;
436 memcpy(newTag->
data, p, tagSize);
439 uint32_t tagWordSize = (tagSize + 3) & (~3);
440 p += tagWordSize / 4;
441 sizeCheck -= tagWordSize;
450 prevTag->
next = newTag;
460 return (sizeCheck != 0) ? 0 : 1;
virtual TypeId GetInstanceTypeId() const =0
Get the most derived TypeId for this Object.
List of the packet tags stored in a packet.
bool Remove(Tag &tag)
Remove (the first instance of) tag from the list.
void Add(const Tag &tag) const
Add a tag to the head of this branch.
uint32_t Deserialize(const uint32_t *buffer, uint32_t size)
Deserialize tag list from the provided buffer.
uint32_t Serialize(uint32_t *buffer, uint32_t maxSize) const
Serialize the tag list into a byte buffer.
bool ReplaceWriter(Tag &tag, bool preMerge, TagData *cur, TagData **prevNext)
Copy-on-write implementing Replace.
bool Replace(Tag &tag)
Replace the value of a tag.
bool Peek(Tag &tag) const
Find a tag and return its value.
uint32_t GetSerializedSize() const
Returns number of bytes required for packet serialization.
bool COWTraverse(Tag &tag, PacketTagList::COWWriter Writer)
Traverse the list implementing copy-on-write, using Writer.
bool RemoveWriter(Tag &tag, bool preMerge, TagData *cur, TagData **prevNext)
Copy-on-write implementing Remove.
const PacketTagList::TagData * Head() const
TagData * m_next
Pointer to first TagData on the list.
static TagData * CreateTagData(size_t dataSize)
Allocate and construct a TagData struct, sizing the data area large enough to serialize dataSize byte...
bool(PacketTagList::* COWWriter)(Tag &tag, bool preMerge, TagData *cur, TagData **prevNext)
Typedef of method function pointer for copy-on-write operations.
tag a set of bytes in a packet
virtual uint32_t GetSerializedSize() const =0
virtual void Serialize(TagBuffer i) const =0
virtual void Deserialize(TagBuffer i)=0
a unique identifier for an interface.
static TypeId LookupByHash(hash_t hash)
Get a TypeId by hash.
uint32_t hash_t
Type of hash values.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Defines a linked list of Packet tags, including copy-on-write semantics.
Tree node for sharing serialized tags.
TagData * next
Pointer to next in list.
TypeId tid
Type of the tag serialized into data.
uint32_t size
Size of the data buffer.
uint32_t count
Number of incoming links.
uint8_t data[1]
Serialization buffer.