26 #define USE_FREE_LIST 1 27 #define FREE_LIST_SIZE 1000 28 #define OFFSET_MAX (std::numeric_limits<int32_t>::max ()) 66 for (ByteTagListDataFreeList::iterator i = begin ();
69 uint8_t *buffer = (uint8_t *)(*i);
137 return m_offsetStart;
151 : m_minStart (o.m_minStart),
152 m_maxEnd (o.m_maxEnd),
153 m_adjustment (o.m_adjustment),
195 uint32_t spaceNeeded =
m_used + bufferSize + 4 + 4 + 4 + 4;
269 return Iterator (0, 0, offsetStart, offsetEnd, 0);
291 if (item.
start >= appendOffset)
295 if (item.
end > appendOffset)
297 item.
end = appendOffset;
324 if (item.
end <= prependOffset)
328 if (item.
start < prependOffset)
330 item.
start = prependOffset;
353 if (
data->size >= size)
359 uint8_t *buffer = (uint8_t *)
data;
380 if (
data->count == 0)
385 uint8_t *buffer = (uint8_t *)
data;
401 uint8_t *buffer =
new uint8_t [size +
sizeof (
struct ByteTagListData) - 4];
418 if (
data->count == 0)
420 uint8_t *buffer = (uint8_t *)
data;
449 uint32_t tagWordSize = (item.
size+3) & (~3);
461 uint32_t* p = buffer;
464 uint32_t* numberOfTags = 0;
466 if (size + 4 <= maxSize)
486 if (size + hashSize <= maxSize)
498 if (size + 4 <= maxSize)
508 if (size + 4 <= maxSize)
518 if (size + 4 <= maxSize)
529 uint32_t tagWordSize = (item.
size+3) & (~3);
531 if (size + tagWordSize <= maxSize)
533 item.
buf.
Read (reinterpret_cast<uint8_t *> (p), item.
size);
535 p += tagWordSize / 4;
553 const uint32_t* p = buffer;
554 uint32_t sizeCheck = size - 4;
557 uint32_t numberTagData = *p++;
560 NS_LOG_INFO (
"Deserializing number of tags " << numberTagData);
562 for(uint32_t i = 0; i < numberTagData; ++i)
569 sizeCheck -= hashSize;
574 uint32_t bufferSize = *p++;
578 uint32_t
start = *p++;
587 buf.
Write ( reinterpret_cast<const uint8_t *> (p), bufferSize);
590 uint32_t tagSizeBytes = (bufferSize+3) & (~3);
591 sizeCheck -= tagSizeBytes;
592 p += tagSizeBytes / 4;
599 return (sizeCheck != 0) ? 0 : 1;
uint32_t Deserialize(const uint32_t *buffer, uint32_t size)
Deserialize tag list from the provided buffer.
uint32_t hash_t
Type of hash values.
void Write(const uint8_t *buffer, uint32_t size)
hash_t GetHash(void) const
Get the hash.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint32_t dirty
number of bytes actually in use
ByteTagList & operator=(const ByteTagList &o)
Assignment operator, deallocates current data and assigns value of passed in ByteTagList.
static TypeId LookupByHash(hash_t hash)
Get a TypeId by hash.
struct ByteTagListData * m_data
the ByteTagListData structure
uint32_t count
use counter (for smart deallocation)
uint32_t GetSerializedSize(void) const
Returns number of bytes required for packet serialization.
keep track of the byte tags stored in a packet.
#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.
TagBuffer Add(TypeId tid, uint32_t bufferSize, int32_t start, int32_t end)
void TrimAtEnd(uint32_t trim)
Trim some space from the end.
uint32_t m_nextTid
TypeId of the next tag.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
TAG_BUFFER_INLINE uint32_t ReadU32(void)
ns3::ByteTagListDataFreeList g_freeList
Container for struct ByteTagListData.
void Deallocate(struct ByteTagListData *data)
Deallocates a ByteTagListData.
uint8_t * m_current
Current tag.
int32_t m_offsetEnd
Offset to the end of the tag from the virtual byte buffer.
void AddAtEnd(int32_t appendOffset)
Make sure that all offsets are smaller than appendOffset which represents the location where new byte...
void PrepareForNext(void)
Prepare the iterator for the next tag.
void RemoveAll(void)
Removes all of the tags from the ByteTagList.
ByteTagList::Iterator Begin(int32_t offsetStart, int32_t offsetEnd) const
Internal representation of the byte tags stored in a packet.
uint32_t m_nextSize
Size of the next tag.
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
int32_t start
offset to the start of the tag from the virtual byte buffer
struct ByteTagList::Iterator::Item Next(void)
Returns the next Item from the ByteTagList.
uint16_t GetUid(void) const
Get the internal id of this TypeId.
struct ByteTagListData * Allocate(uint32_t size)
Allocate the memory for the ByteTagListData.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Iterator(uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd, int32_t adjustment)
Constructor.
int32_t m_minStart
minimal start offset
int32_t m_nextStart
Start of the next tag.
int32_t end
offset to the end of the tag from the virtual byte buffer
ByteTagList::Iterator BeginAll(void) const
Returns an iterator pointing to the very first tag in this list.
uint32_t m_used
the number of used bytes in the buffer
int32_t m_offsetStart
Offset to the start of the tag from the virtual byte buffer.
Container class for struct ByteTagListData.
TypeId tid
type of the tag
uint32_t size
size of tag data
uint32_t size
size of the data
void SetUid(uint16_t uid)
Set the internal id of this TypeId.
int32_t m_adjustment
adjustment to byte tag offsets
~ByteTagListDataFreeList()
TagBuffer buf
the data for the tag as generated by Tag::Serialize
An iterator for iterating through a byte tag list.
int32_t m_nextEnd
End of the next tag.
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
void Read(uint8_t *buffer, uint32_t size)
Item(TagBuffer buf)
Constructs an item with the given TagBuffer.
uint32_t GetOffsetStart(void) const
Returns the offset from the start of the virtual byte buffer to the ByteTagList.
uint32_t Serialize(uint32_t *buffer, uint32_t maxSize) const
Serialize the tag list into a byte buffer.
static uint32_t g_maxSize
maximum data size (used for allocation)
a unique identifier for an interface.
int32_t m_adjustment
Adjustment to byte tag offsets.
void CopyFrom(TagBuffer o)
Copy the nternal structure of another TagBuffer.
bool HasNext(void) const
Used to determine if the iterator is at the end of the byteTagList.
An item specifies an individual tag within a byte buffer.