14#include "ns3/assert.h"
15#include "ns3/fatal-error.h"
36 for (
auto i = begin();
i != end();
i++)
48 "Error: attempting to enable the packet metadata "
49 "subsystem too late in the simulation, which is not allowed.\n"
50 "A common cause for this problem is to enable ASCII tracing "
51 "after sending any packets. One way to fix this problem is "
52 "to call ns3::PacketMetadata::Enable () near the beginning of"
53 " the program, before any packets are sent.");
120 bool ok = pointer == 0xffff || pointer <=
m_used;
131 uint16_t current =
m_head;
132 while (
ok && current != 0xffff)
168 if (
value < 0x200000)
172 if (
value < 0x10000000)
183 const uint8_t* buffer = *
pBuffer;
188 result = (
byte & (~0x80));
195 result |= (
byte & (~0x80)) << 7;
202 result |= (
byte & (~0x80)) << 14;
209 result |= (
byte & (~0x80)) << 21;
216 result |= (
byte & (~0x80)) << 28;
233 buffer[0] =
value & 0xff;
242 buffer[0] =
value & 0xff;
243 buffer[1] = (
value >> 8) & 0xff;
244 buffer[2] = (
value >> 16) & 0xff;
245 buffer[3] = (
value >> 24) & 0xff;
252 if (
value < 0x200000)
254 uint8_t
byte =
value & (~0x80);
255 buffer[0] = 0x80 | byte;
257 byte =
value & (~0x80);
258 buffer[1] = 0x80 | byte;
263 if (
value < 0x10000000)
265 uint8_t
byte =
value & (~0x80);
266 buffer[0] = 0x80 | byte;
268 byte =
value & (~0x80);
269 buffer[1] = 0x80 | byte;
271 byte =
value & (~0x80);
272 buffer[2] = 0x80 | byte;
278 uint8_t
byte =
value & (~0x80);
279 buffer[0] = 0x80 | byte;
281 byte =
value & (~0x80);
282 buffer[1] = 0x80 | byte;
284 byte =
value & (~0x80);
285 buffer[2] = 0x80 | byte;
287 byte =
value & (~0x80);
288 buffer[3] = 0x80 | byte;
305 uint8_t
byte =
value & (~0x80);
306 buffer[0] = 0x80 | byte;
496 uint16_t current =
m_head;
497 while (current != 0xffff && current !=
m_tail)
523 item->next = buffer[0];
524 item->next |= (buffer[1]) << 8;
525 item->prev = buffer[2];
526 item->prev |= (buffer[3]) << 8;
530 item->chunkUid = buffer[0];
531 item->chunkUid |= (buffer[1]) << 8;
568 if (
data->m_size >= size)
612 auto buf =
new uint8_t[size];
616 data->m_dirtyEnd = 0;
624 auto buf = (uint8_t*)
data;
681 if ((
item.typeUid & 0xfffffffe) !=
uid ||
item.size != size)
748 if ((
item.typeUid & 0xfffffffe) !=
uid ||
item.size != size)
797 if (
o.m_head == 0xffff)
826 if (
o.m_head ==
o.m_tail)
842 while (current != 0xffff)
847 if (current ==
o.m_tail)
878 uint16_t current =
m_head;
907 while (current != 0xffff && current !=
m_tail)
940 uint16_t current =
m_tail;
970 while (current != 0xffff && current !=
m_head)
996 uint16_t current =
m_head;
998 while (current != 0xffff)
1004 if (current ==
tail)
1009 current =
item.next;
1033 m_hasReadTail(
false)
1042 if (m_current == 0xffff)
1061 if (m_current == m_metadata->m_tail)
1063 m_hasReadTail =
true;
1081 if (!
item.isFragment)
1083 item.current = m_buffer.Begin();
1084 item.current.Next(m_offset);
1090 if (!
item.isFragment)
1092 item.current = m_buffer.End();
1093 item.current.Prev(m_buffer.GetSize() - (m_offset +
smallItem.size));
1124 while (current != 0xffff)
1144 current =
item.next;
1153 uint8_t* start = buffer;
1156 if (buffer ==
nullptr)
1164 while (current != 0xffff)
1168 <<
", typeUid=" <<
item.typeUid <<
", size=" <<
item.size
1169 <<
", chunkUid=" <<
item.chunkUid
1170 <<
", fragmentStart=" <<
extraItem.fragmentStart
1171 <<
", fragmentEnd=" <<
extraItem.fragmentEnd
1172 <<
", packetUid=" <<
extraItem.packetUid);
1182 if (buffer ==
nullptr)
1191 if (buffer ==
nullptr)
1199 if (buffer ==
nullptr)
1207 if (buffer ==
nullptr)
1213 if (buffer ==
nullptr)
1219 if (buffer ==
nullptr)
1225 if (buffer ==
nullptr)
1231 if (buffer ==
nullptr)
1237 if (buffer ==
nullptr)
1248 current =
item.next;
1259 const uint8_t* start = buffer;
1306 <<
", chunkUid=" <<
item.chunkUid <<
", fragmentStart="
1308 <<
", packetUid=" <<
extraItem.packetUid);
1313 return (
desSize != 0) ? 0 : 1;
1321 if (
static_cast<uint32_t>(current +
sizeof(uint8_t) - start) >
maxSize)
1326 return current +
sizeof(uint8_t);
1337 if (
static_cast<uint32_t>(current +
sizeof(uint16_t) - start) >
maxSize)
1342 return current +
sizeof(uint16_t);
1369 if (
static_cast<uint32_t>(current +
sizeof(uint64_t) - start) >
maxSize)
1374 return current +
sizeof(uint64_t);
1396 const uint8_t* start,
1397 const uint8_t* current,
1402 if (
static_cast<uint32_t>(current +
sizeof(uint8_t) - start) >
maxSize)
1407 return const_cast<uint8_t*
>(current) +
sizeof(uint8_t);
1412 const uint8_t* start,
1413 const uint8_t* current,
1418 if (
static_cast<uint32_t>(current +
sizeof(uint16_t) - start) >
maxSize)
1423 return const_cast<uint8_t*
>(current) +
sizeof(uint16_t);
1428 const uint8_t* start,
1429 const uint8_t* current,
1439 return const_cast<uint8_t*
>(current) +
sizeof(
uint32_t);
1444 const uint8_t* start,
1445 const uint8_t* current,
1455 return const_cast<uint8_t*
>(current) +
sizeof(uint64_t);
automatically resized byte buffer
virtual TypeId GetInstanceTypeId() const =0
Get the most derived TypeId for this Object.
Protocol trailer serialization and deserialization.
static TypeId GetTypeId()
Get the type ID.
a unique identifier for an interface.
bool IsChildOf(TypeId other) const
Check if this TypeId is a child of another.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
void SetUid(uint16_t uid)
Set the internal id of this TypeId.
uint16_t GetUid() const
Get the internal id of this TypeId.
std::string GetName() const
Get the name.
#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_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#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 ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static unsigned int value(char c)