27#define USE_FREE_LIST 1
28#define FREE_LIST_SIZE 1000
29#define OFFSET_MAX (std::numeric_limits<int32_t>::max())
70 for (ByteTagListDataFreeList::iterator i = begin(); i != end(); i++)
72 uint8_t* buffer = (uint8_t*)(*i);
139 NS_LOG_FUNCTION(
this << &start << &end << offsetStart << offsetEnd << adjustment);
147 return m_offsetStart;
161 : m_minStart(o.m_minStart),
162 m_maxEnd(o.m_maxEnd),
163 m_adjustment(o.m_adjustment),
279 return Iterator(
nullptr,
nullptr, offsetStart, offsetEnd, 0);
301 if (item.
start >= appendOffset)
305 if (item.
end > appendOffset)
307 item.
end = appendOffset;
334 if (item.
end <= prependOffset)
338 if (item.
start < prependOffset)
340 item.
start = prependOffset;
363 if (
data->size >= size)
369 uint8_t* buffer = (uint8_t*)
data;
390 if (
data->count == 0)
394 uint8_t* buffer = (uint8_t*)
data;
427 if (
data->count == 0)
429 uint8_t* buffer = (uint8_t*)
data;
475 if (size + 4 <= maxSize)
495 if (size + hashSize <= maxSize)
507 if (size + 4 <= maxSize)
517 if (size + 4 <= maxSize)
527 if (size + 4 <= maxSize)
540 if (size + tagWordSize <= maxSize)
542 item.
buf.
Read(
reinterpret_cast<uint8_t*
>(p), item.
size);
544 p += tagWordSize / 4;
569 NS_LOG_INFO(
"Deserializing number of tags " << numberTagData);
571 for (
uint32_t i = 0; i < numberTagData; ++i)
578 sizeCheck -= hashSize;
596 buf.
Write(
reinterpret_cast<const uint8_t*
>(p), bufferSize);
599 uint32_t tagSizeBytes = (bufferSize + 3) & (~3);
600 sizeCheck -= tagSizeBytes;
601 p += tagSizeBytes / 4;
608 return (sizeCheck != 0) ? 0 : 1;
An iterator for iterating through a byte tag list.
uint8_t * m_current
Current tag.
int32_t m_adjustment
Adjustment to byte tag offsets.
int32_t m_offsetEnd
Offset to the end of the tag from the virtual byte buffer.
ByteTagList::Iterator::Item Next()
Returns the next Item from the ByteTagList.
void PrepareForNext()
Prepare the iterator for the next tag.
int32_t m_nextEnd
End of the next tag.
uint32_t GetOffsetStart() const
Returns the offset from the start of the virtual byte buffer to the ByteTagList.
int32_t m_nextStart
Start of the next tag.
int32_t m_offsetStart
Offset to the start of the tag from the virtual byte buffer.
uint32_t m_nextSize
Size of the next tag.
Iterator(uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd, int32_t adjustment)
Constructor.
bool HasNext() const
Used to determine if the iterator is at the end of the byteTagList.
uint32_t m_nextTid
TypeId of the next tag.
Container class for struct ByteTagListData.
~ByteTagListDataFreeList()
keep track of the byte tags stored in a packet.
uint32_t Deserialize(const uint32_t *buffer, uint32_t size)
Deserialize tag list from the provided buffer.
void AddAtEnd(int32_t appendOffset)
Make sure that all offsets are smaller than appendOffset which represents the location where new byte...
void Deallocate(ByteTagListData *data)
Deallocates a ByteTagListData.
ByteTagList & operator=(const ByteTagList &o)
Assignment operator, deallocates current data and assigns value of passed in ByteTagList.
ByteTagList::Iterator Begin(int32_t offsetStart, int32_t offsetEnd) const
int32_t m_minStart
minimal start offset
uint32_t m_used
the number of used bytes in the buffer
ByteTagListData * Allocate(uint32_t size)
Allocate the memory for the ByteTagListData.
ByteTagList::Iterator BeginAll() const
Returns an iterator pointing to the very first tag in this list.
void RemoveAll()
Removes all of the tags from the ByteTagList.
int32_t m_adjustment
adjustment to byte tag offsets
TagBuffer Add(TypeId tid, uint32_t bufferSize, int32_t start, int32_t end)
uint32_t Serialize(uint32_t *buffer, uint32_t maxSize) const
Serialize the tag list into a byte buffer.
void AddAtStart(int32_t prependOffset)
Make sure that all offsets are bigger than prependOffset which represents the location where new byte...
int32_t m_maxEnd
maximal end offset
ByteTagListData * m_data
the ByteTagListData structure
uint32_t GetSerializedSize() const
Returns number of bytes required for packet serialization.
TAG_BUFFER_INLINE uint32_t ReadU32()
void TrimAtEnd(uint32_t trim)
Trim some space from the end.
void Read(uint8_t *buffer, uint32_t size)
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
void Write(const uint8_t *buffer, uint32_t size)
void CopyFrom(TagBuffer o)
Copy the nternal structure of another TagBuffer.
a unique identifier for an interface.
hash_t GetHash() const
Get the hash.
void SetUid(uint16_t uid)
Set the internal id of this TypeId.
static TypeId LookupByHash(hash_t hash)
Get a TypeId by hash.
uint32_t hash_t
Type of hash values.
uint16_t GetUid() const
Get the internal id of this TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#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.
ns3::ByteTagListDataFreeList g_freeList
Container for struct ByteTagListData.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static uint32_t g_maxSize
maximum data size (used for allocation)
An item specifies an individual tag within a byte buffer.
TypeId tid
type of the tag
TagBuffer buf
the data for the tag as generated by Tag::Serialize
uint32_t size
size of tag data
int32_t end
offset to the end of the tag from the virtual byte buffer
Item(TagBuffer buf)
Constructs an item with the given TagBuffer.
int32_t start
offset to the start of the tag from the virtual byte buffer
Internal representation of the byte tags stored in a packet.
uint32_t dirty
number of bytes actually in use
uint32_t size
size of the data
uint32_t count
use counter (for smart deallocation)