29 #include "ns3/fatal-error.h"
37 PacketTagList::TagData *
42 "Requested TagData size " << dataSize
43 <<
" exceeds maximum "
46 void * p = std::malloc (
sizeof (
TagData) + dataSize - 1);
82 else if (cur->
tid == tid)
84 NS_LOG_INFO (
"found tid before initial merge, calling writer");
85 found = (this->*Writer)(tag,
true, cur, prevNext);
91 prevNext = &cur->
next;
97 if (cur == 0 || found)
99 NS_LOG_INFO (
"returning after header with found: " << found);
107 for (it = cur; it != 0; it = it->
next)
148 while ( cur->
tid != tid)
161 prevNext = ©->
next;
170 found = (this->*Writer)(tag,
false, cur, prevNext);
192 *prevNext = cur->
next;
267 "Error: cannot add the same kind of tag twice.");
321 uint32_t tagWordSize = (cur->size+3) & (~3);
333 uint32_t* p = buffer;
336 uint32_t* numberOfTags = 0;
338 if (size + 4 <= maxSize)
351 if (size + 4 <= maxSize)
365 if (size + hashSize <= maxSize)
378 uint32_t tagWordSize = (cur->size+3) & (~3);
379 if (size + tagWordSize <= maxSize)
381 memcpy (p, cur->data, cur->size);
383 p += tagWordSize / 4;
401 const uint32_t* p = buffer;
402 uint32_t sizeCheck = size - 4;
405 uint32_t numberOfTags = *p++;
408 NS_LOG_INFO(
"Deserializing number of tags " << numberOfTags);
411 for (uint32_t i = 0; i < numberOfTags; ++i)
414 uint32_t tagSize = *p++;
422 sizeCheck -= hashSize;
434 memcpy (newTag->
data, p, tagSize);
437 uint32_t tagWordSize = (tagSize+3) & (~3);
438 p += tagWordSize / 4;
439 sizeCheck -= tagWordSize;
448 prevTag->
next = newTag;
458 return (sizeCheck != 0) ? 0 : 1;
virtual TypeId GetInstanceTypeId(void) 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.
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, struct TagData *cur, struct TagData **prevNext)
Copy-on-write implementing Replace.
struct TagData * m_next
Pointer to first TagData on the list.
bool Replace(Tag &tag)
Replace the value of a tag.
bool Peek(Tag &tag) const
Find a tag and return its value.
bool(PacketTagList::* COWWriter)(Tag &tag, bool preMerge, struct TagData *cur, struct TagData **prevNext)
Typedef of method function pointer for copy-on-write operations.
bool COWTraverse(Tag &tag, PacketTagList::COWWriter Writer)
Traverse the list implementing copy-on-write, using Writer.
static TagData * CreateTagData(size_t dataSize)
Allocate and construct a TagData struct, sizing the data area large enough to serialize dataSize byte...
bool RemoveWriter(Tag &tag, bool preMerge, struct TagData *cur, struct TagData **prevNext)
Copy-on-write implementing Remove.
uint32_t GetSerializedSize(void) const
Returns number of bytes required for packet serialization.
void Add(Tag const &tag) const
Add a tag to the head of this branch.
const struct PacketTagList::TagData * Head(void) const
tag a set of bytes in a packet
virtual uint32_t GetSerializedSize(void) 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.
std::size_t hash(const BasicJsonType &j)
hash a JSON value
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.
TypeId tid
Type of the tag serialized into data.
uint32_t size
Size of the data buffer.
uint32_t count
Number of incoming links.
struct TagData * next
Pointer to next in list.
uint8_t data[1]
Serialization buffer.