22 #include "ns3/assert.h" 
   23 #include "ns3/fatal-error.h" 
   44   for (iterator i = begin (); i != end (); i++)
 
   56                  "Error: attempting to enable the packet metadata " 
   57                  "subsystem too late in the simulation, which is not allowed.\n" 
   58                  "A common cause for this problem is to enable ASCII tracing " 
   59                  "after sending any packets.  One way to fix this problem is " 
   60                  "to call ns3::PacketMetadata::Enable () near the beginning of" 
   61                  " the program, before any packets are sent.");
 
  121   bool ok = pointer == 0xffff || pointer <= 
m_data->
m_size;
 
  128   bool ok = pointer == 0xffff || pointer <= 
m_used;
 
  139   uint16_t current = 
m_head;
 
  140   while (ok && current != 0xffff)
 
  176   if (value < 0x200000)
 
  180   if (value < 0x10000000)
 
  190   const uint8_t *buffer = *pBuffer;
 
  195   result = (byte & (~0x80));
 
  198       *pBuffer = buffer + 1;
 
  202   result |= (byte & (~0x80)) << 7;
 
  205       *pBuffer = buffer + 2;
 
  209   result |= (byte & (~0x80)) << 14;
 
  212       *pBuffer = buffer + 3;
 
  216   result |= (byte & (~0x80)) << 21;
 
  219       *pBuffer = buffer + 4;
 
  223   result |= (byte & (~0x80)) << 28;
 
  226       *pBuffer = buffer + 5;
 
  240   buffer[0] = value & 0xff;
 
  248   buffer[0] = value & 0xff;
 
  249   buffer[1] = (value >> 8) & 0xff;
 
  250   buffer[2] = (value >> 16) & 0xff;
 
  251   buffer[3] = (value >> 24) & 0xff;
 
  258   if (value < 0x200000)
 
  260       uint8_t byte = value & (~0x80);
 
  261       buffer[0] = 0x80 | byte;
 
  263       byte = value & (~0x80);
 
  264       buffer[1] = 0x80 | byte;
 
  266       byte = value & (~0x80);
 
  270   if (value < 0x10000000)
 
  272       uint8_t byte = value & (~0x80);
 
  273       buffer[0] = 0x80 | byte;
 
  275       byte = value & (~0x80);
 
  276       buffer[1] = 0x80 | byte;
 
  278       byte = value & (~0x80);
 
  279       buffer[2] = 0x80 | byte;
 
  285     uint8_t byte = value & (~0x80);
 
  286     buffer[0] = 0x80 | byte;
 
  288     byte = value & (~0x80);
 
  289     buffer[1] = 0x80 | byte;
 
  291     byte = value & (~0x80);
 
  292     buffer[2] = 0x80 | byte;
 
  294     byte = value & (~0x80);
 
  295     buffer[3] = 0x80 | byte;
 
  312       uint8_t byte = value & (~0x80);
 
  313       buffer[0] = 0x80 | byte;
 
  382   uint32_t n =  2 + 2 + typeUidSize + sizeSize + 2;
 
  396   buffer += typeUidSize;
 
  419   uint32_t n = 2 + 2 + typeUidSize + sizeSize + 2 + fragStartSize + fragEndSize + 4;
 
  436   buffer += typeUidSize;
 
  442   buffer += fragStartSize;
 
  444   buffer += fragEndSize;
 
  477   uint32_t n = 2 + 2 + typeUidSize + sizeSize + 2 + fragStartSize + fragEndSize + 4;
 
  479   if (available >= n &&
 
  488       buffer += typeUidSize;
 
  494       buffer += fragStartSize;
 
  496       buffer += fragEndSize;
 
  509   uint16_t current = 
m_head;
 
  510   while (current != 0xffff && current != 
m_tail)
 
  514       ReadItems (current, &tmpItem, &tmpExtraItem);
 
  516                                    &tmpItem, &tmpExtraItem);
 
  518       current = tmpItem.
next;
 
  521   uint16_t written = h.
AddBig (0xffff, h.
m_tail, item, extraItem);
 
  538   item->
next = buffer[0];
 
  539   item->
next |= (buffer[1]) << 8;
 
  540   item->
prev = buffer[2];
 
  541   item->
prev |= (buffer[3]) << 8;
 
  549   bool isExtra = (item->
typeUid & 0x1) == 0x1;
 
  567   return buffer - &m_data->m_data[current];
 
  622   uint32_t size = 
sizeof (
struct Data);
 
  628   uint8_t *buf = 
new uint8_t [size];
 
  639   uint8_t *buf = (uint8_t *)data;
 
  680   uint16_t written = 
AddSmall (&item);
 
  697   if ((item.
typeUid & 0xfffffffe) != uid ||
 
  706   else if (item.
typeUid != uid &&
 
  749   uint16_t written = 
AddSmall (&item);
 
  767   if ((item.
typeUid & 0xfffffffe) != uid ||
 
  776   else if (item.
typeUid != uid &&
 
  837   if (extraItem.packetUid == tailExtraItem.packetUid &&
 
  841       extraItem.fragmentStart == tailExtraItem.fragmentEnd)
 
  848       tailExtraItem.fragmentEnd = extraItem.fragmentEnd;
 
  866   while (current != 0xffff)
 
  868       o.
ReadItems (current, &item, &extraItem);
 
  869       uint16_t written = 
AddBig (0xffff, 
m_tail, &item, &extraItem);
 
  900   uint32_t leftToRemove = 
start;
 
  901   uint16_t current = 
m_head;
 
  902   while (current != 0xffff && leftToRemove > 0)
 
  907       uint32_t itemRealSize = extraItem.fragmentEnd - extraItem.fragmentStart;
 
  908       if (itemRealSize <= leftToRemove)
 
  920           leftToRemove -= itemRealSize;
 
  926           extraItem.fragmentStart += leftToRemove;
 
  928           uint16_t written = fragment.
AddBig (0xffff, fragment.
m_tail,
 
  931           while (current != 0xffff && current != 
m_tail)
 
  941       NS_ASSERT (item.
size >= extraItem.fragmentEnd - extraItem.fragmentStart &&
 
  942                  extraItem.fragmentStart <= extraItem.fragmentEnd);
 
  964   uint32_t leftToRemove = end;
 
  965   uint16_t current = 
m_tail;
 
  966   while (current != 0xffff && leftToRemove > 0)
 
  971       uint32_t itemRealSize = extraItem.fragmentEnd - extraItem.fragmentStart;
 
  972       if (itemRealSize <= leftToRemove)
 
  984           leftToRemove -= itemRealSize;
 
  990           NS_ASSERT (extraItem.fragmentEnd > leftToRemove);
 
  991           extraItem.fragmentEnd -= leftToRemove;
 
  993           uint16_t written = fragment.
AddBig (fragment.
m_head, 0xffff,
 
  996           while (current != 0xffff && current != 
m_head)
 
 1006       NS_ASSERT (item.
size >= extraItem.fragmentEnd - extraItem.fragmentStart &&
 
 1007                  extraItem.fragmentStart <= extraItem.fragmentEnd);
 
 1012       current = item.
prev;
 
 1021   uint32_t totalSize = 0;
 
 1022   uint16_t current = 
m_head;
 
 1024   while (current != 0xffff)
 
 1029       totalSize += extraItem.fragmentEnd - extraItem.fragmentStart;
 
 1030       if (current == tail)
 
 1035       current = item.
next;
 
 1053   : m_metadata (metadata),
 
 1055     m_current (metadata->
m_head),
 
 1057     m_hasReadTail (false)
 
 1065   if (m_current == 0xffff)
 
 1082   m_metadata->ReadItems (m_current, &smallItem, &extraItem);
 
 1083   if (m_current == m_metadata->m_tail)
 
 1085       m_hasReadTail = 
true;
 
 1087   m_current = smallItem.
next;
 
 1088   uint32_t uid = (smallItem.
typeUid & 0xfffffffe) >> 1;
 
 1141   uint32_t totalSize = 0;
 
 1156   uint32_t current = 
m_head;
 
 1157   while (current != 0xffff)
 
 1160       uint32_t uid = (item.
typeUid & 0xfffffffe) >> 1;
 
 1169           totalSize += 4 + tid.
GetName ().size ();
 
 1171       totalSize += 1 + 4 + 2 + 4 + 4 + 8;
 
 1177       current = item.
next;
 
 1186   uint8_t* 
start = buffer;
 
 1196   uint32_t current = 
m_head;
 
 1197   while (current != 0xffff)
 
 1200       NS_LOG_LOGIC (
"bytesWritten=" << static_cast<uint32_t> (buffer - start) << 
", typeUid="<<
 
 1202                     ", fragmentStart="<<extraItem.
fragmentStart<<
", fragmentEnd="<<
 
 1205       uint32_t uid = (item.
typeUid & 0xfffffffe) >> 1;
 
 1210           std::string uidString = tid.
GetName ();
 
 1211           uint32_t uidStringSize = uidString.size ();
 
 1212           buffer = 
AddToRawU32 (uidStringSize, start, buffer, maxSize);
 
 1217           buffer = 
AddToRaw (reinterpret_cast<const uint8_t *> (uidString.c_str ()), 
 
 1218                              uidStringSize, start, buffer, maxSize);
 
 1233       uint8_t isBig = item.
typeUid & 0x1;
 
 1234       buffer = 
AddToRawU8 (isBig, start, buffer, maxSize);
 
 1276       current = item.
next;
 
 1279   NS_ASSERT (static_cast<uint32_t> (buffer - start) == maxSize);
 
 1287   const uint8_t* 
start = buffer;
 
 1288   uint32_t desSize = size - 4;
 
 1297       uint32_t uidStringSize = 0;
 
 1301       if (uidStringSize == 0)
 
 1308           std::string uidString;
 
 1309           for (uint32_t j = 0; j < uidStringSize; j++)
 
 1313               uidString.push_back (ch);
 
 1322       item.
typeUid = (uid << 1) | isBig;
 
 1335                     ", fragmentStart="<<extraItem.
fragmentStart<<
", fragmentEnd="<<
 
 1337       uint32_t tmp = 
AddBig (0xffff, 
m_tail, &item, &extraItem);
 
 1341   return (desSize !=0) ? 0 : 1;
 
 1350   NS_LOG_FUNCTION (static_cast<uint32_t> (data) << &start << ¤t << maxSize);
 
 1352   if (static_cast<uint32_t> ((current + 
sizeof (uint8_t) - start)) > maxSize) 
 
 1356   memcpy (current, &data, 
sizeof (uint8_t));
 
 1357   return current + 
sizeof (uint8_t);
 
 1368   if (static_cast<uint32_t> ((current + 
sizeof (uint16_t) - start)) > maxSize) 
 
 1372   memcpy (current, &data, 
sizeof (uint16_t));
 
 1373   return current + 
sizeof (uint16_t);
 
 1384   if (static_cast<uint32_t> ((current + 
sizeof (uint32_t) - start)) > maxSize) 
 
 1388   memcpy (current, &data, 
sizeof (uint32_t));
 
 1389   return current + 
sizeof (uint32_t);
 
 1400   if (static_cast<uint32_t> ((current + 
sizeof (uint64_t) - start)) > maxSize) 
 
 1404   memcpy (current, &data, 
sizeof (uint64_t));
 
 1405   return current + 
sizeof (uint64_t);
 
 1417   if (static_cast<uint32_t> ((current + dataSize - start)) > maxSize) 
 
 1421   memcpy (current, data, dataSize);
 
 1422   return current + dataSize;
 
 1427                                const uint8_t* 
start,
 
 1428                                const uint8_t* current,
 
 1431   NS_LOG_FUNCTION (static_cast<uint32_t> (data) << &start << ¤t << maxSize);
 
 1433   if (static_cast<uint32_t> ((current + 
sizeof (uint8_t) - start)) > maxSize) 
 
 1437   memcpy (&data, current, 
sizeof (uint8_t));
 
 1438   return const_cast<uint8_t *
> (current) + 
sizeof (uint8_t);
 
 1443                                 const uint8_t* 
start,
 
 1444                                 const uint8_t* current,
 
 1449   if (static_cast<uint32_t> ((current + 
sizeof (uint16_t) - start)) > maxSize) 
 
 1453   memcpy (&data, current, 
sizeof (uint16_t));
 
 1454   return const_cast<uint8_t *
> (current) + 
sizeof (uint16_t);
 
 1459                                 const uint8_t* 
start,
 
 1460                                 const uint8_t* current,
 
 1465   if (static_cast<uint32_t> ((current + 
sizeof (uint32_t) - start)) > maxSize) 
 
 1469   memcpy (&data, current, 
sizeof (uint32_t));
 
 1470   return const_cast<uint8_t *
> (current) + 
sizeof (uint32_t);
 
 1475                                 const uint8_t* 
start,
 
 1476                                 const uint8_t* current,
 
 1481   if ((uint32_t)((current + 
sizeof (uint64_t) - start)) > maxSize) 
 
 1485   memcpy (&data, current, 
sizeof (uint64_t));
 
 1486   return const_cast<uint8_t *
> (current) + 
sizeof (uint64_t);
 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
 
void RemoveAtEnd(uint32_t end)
 
void RemoveAtStart(uint32_t start)
 
automatically resized byte buffer 
 
#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_FATAL_ERROR(msg)
fatal error handling 
 
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function. 
 
static TypeId GetTypeId(void)
Get the type ID. 
 
Buffer::Iterator End(void) const 
 
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC. 
 
Buffer::Iterator Begin(void) const 
 
Protocol trailer serialization and deserialization. 
 
void SetUid(uint16_t tid)
 
std::string GetName(void) const 
 
uint16_t GetUid(void) const 
 
uint32_t GetSize(void) const 
 
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
 
virtual TypeId GetInstanceTypeId(void) const =0
 
bool IsChildOf(TypeId other) const 
 
a unique identifier for an interface. 
 
static TypeId LookupByName(std::string name)