iterator in a Buffer instance More...
#include <buffer.h>
Public Member Functions | |
Iterator () | |
void | Next (void) |
void | Prev (void) |
void | Next (uint32_t delta) |
void | Prev (uint32_t delta) |
uint32_t | GetDistanceFrom (Iterator const &o) const |
bool | IsEnd (void) const |
bool | IsStart (void) const |
BUFFER_INLINE void | WriteU8 (uint8_t data) |
BUFFER_INLINE void | WriteU8 (uint8_t data, uint32_t len) |
void | WriteU16 (uint16_t data) |
void | WriteU32 (uint32_t data) |
void | WriteU64 (uint64_t data) |
void | WriteHtolsbU16 (uint16_t data) |
void | WriteHtolsbU32 (uint32_t data) |
void | WriteHtolsbU64 (uint64_t data) |
void | WriteHtonU16 (uint16_t data) |
void | WriteHtonU32 (uint32_t data) |
void | WriteHtonU64 (uint64_t data) |
void | Write (uint8_t const *buffer, uint32_t size) |
void | Write (Iterator start, Iterator end) |
BUFFER_INLINE uint8_t | ReadU8 (void) |
uint16_t | ReadU16 (void) |
uint32_t | ReadU32 (void) |
uint64_t | ReadU64 (void) |
uint16_t | ReadNtohU16 (void) |
uint32_t | ReadNtohU32 (void) |
uint64_t | ReadNtohU64 (void) |
uint16_t | ReadLsbtohU16 (void) |
uint32_t | ReadLsbtohU32 (void) |
uint64_t | ReadLsbtohU64 (void) |
void | Read (uint8_t *buffer, uint32_t size) |
uint16_t | CalculateIpChecksum (uint16_t size) |
Calculate the checksum. | |
uint16_t | CalculateIpChecksum (uint16_t size, uint32_t initialChecksum) |
Calculate the checksum. | |
uint32_t | GetSize (void) const |
Private Member Functions | |
Iterator (Buffer const *buffer) | |
Iterator (Buffer const *buffer, bool) | |
void | Construct (const Buffer *buffer) |
bool | CheckNoZero (uint32_t start, uint32_t end) const |
bool | Check (uint32_t i) const |
Private Attributes | |
uint32_t | m_zeroStart |
uint32_t | m_zeroEnd |
uint32_t | m_dataStart |
uint32_t | m_dataEnd |
uint32_t | m_current |
uint8_t * | m_data |
Friends | |
class | Buffer |
iterator in a Buffer instance
Definition at line 102 of file buffer.h.
ns3::Buffer::Iterator::Iterator | ( | Buffer const * | buffer | ) | [private] |
Definition at line 659 of file buffer.cc.
References Construct(), m_current, and m_dataStart.
ns3::Buffer::Iterator::Iterator | ( | Buffer const * | buffer, | |
bool | dummy | |||
) | [private] |
Definition at line 664 of file buffer.cc.
References Construct(), m_current, and m_dataEnd.
uint16_t ns3::Buffer::Iterator::CalculateIpChecksum | ( | uint16_t | size, | |
uint32_t | initialChecksum | |||
) |
uint16_t ns3::Buffer::Iterator::CalculateIpChecksum | ( | uint16_t | size | ) |
Calculate the checksum.
size | size of the buffer. |
Definition at line 1109 of file buffer.cc.
Referenced by ns3::Ipv4Header::Deserialize(), ns3::Ipv4Header::Serialize(), ns3::UdpHeader::Serialize(), and ns3::Icmpv4Header::Serialize().
bool ns3::Buffer::Iterator::Check | ( | uint32_t | i | ) | const [private] |
Definition at line 744 of file buffer.cc.
References m_dataEnd, m_dataStart, m_zeroEnd, and m_zeroStart.
Referenced by CheckNoZero().
bool ns3::Buffer::Iterator::CheckNoZero | ( | uint32_t | start, | |
uint32_t | end | |||
) | const [private] |
void ns3::Buffer::Iterator::Construct | ( | const Buffer * | buffer | ) | [private] |
Definition at line 671 of file buffer.cc.
References ns3::BufferData::m_data, ns3::Buffer::m_data, m_data, m_dataEnd, m_dataStart, ns3::Buffer::m_end, ns3::Buffer::m_start, ns3::Buffer::m_zeroAreaEnd, ns3::Buffer::m_zeroAreaStart, m_zeroEnd, and m_zeroStart.
Referenced by Iterator().
uint32_t ns3::Buffer::Iterator::GetDistanceFrom | ( | Iterator const & | o | ) | const |
o | the second iterator |
This method works only if the two iterators point to the same underlying buffer. Debug builds ensure this with an assert.
Definition at line 705 of file buffer.cc.
References m_current, m_data, and NS_ASSERT.
Referenced by ns3::Icmpv4TimeExceeded::Deserialize(), ns3::Icmpv4DestinationUnreachable::Deserialize(), and ns3::WifiMacHeader::Deserialize().
uint32_t ns3::Buffer::Iterator::GetSize | ( | void | ) | const |
Definition at line 1132 of file buffer.cc.
References m_dataEnd, and m_dataStart.
Referenced by ns3::Icmpv4Echo::Deserialize(), ns3::UdpHeader::Serialize(), and ns3::Icmpv4Header::Serialize().
bool ns3::Buffer::Iterator::IsEnd | ( | void | ) | const |
Definition at line 720 of file buffer.cc.
References m_current, and m_dataEnd.
Referenced by ns3::Packet::CopyData().
bool ns3::Buffer::Iterator::IsStart | ( | void | ) | const |
Definition at line 725 of file buffer.cc.
References m_current, and m_dataStart.
void ns3::Buffer::Iterator::Next | ( | uint32_t | delta | ) |
void ns3::Buffer::Iterator::Next | ( | void | ) |
go forward by one byte
Definition at line 681 of file buffer.cc.
References m_current, m_dataEnd, and NS_ASSERT.
Referenced by ns3::Icmpv4TimeExceeded::Deserialize(), ns3::Icmpv4DestinationUnreachable::Deserialize(), ns3::ArpHeader::Deserialize(), ns3::BufferTest::RunTests(), ns3::Ipv4Header::Serialize(), ns3::UdpHeader::Serialize(), ns3::Icmpv4TimeExceeded::Serialize(), ns3::Icmpv4DestinationUnreachable::Serialize(), and ns3::Icmpv4Header::Serialize().
void ns3::Buffer::Iterator::Prev | ( | uint32_t | delta | ) |
void ns3::Buffer::Iterator::Prev | ( | void | ) |
go backward by one byte
Definition at line 687 of file buffer.cc.
References m_current, and NS_ASSERT.
Referenced by ns3::Buffer::AddAtEnd(), ns3::Buffer::CreateFullCopy(), ns3::Ipv4Header::Deserialize(), ns3::EthernetTrailer::Deserialize(), anonymous_namespace{packet.cc}::ATestTrailer< N >::Deserialize(), anonymous_namespace{packet-metadata-test.cc}::HistoryTrailer< N >::Deserialize(), ns3::BufferTest::RunTests(), ns3::EthernetTrailer::Serialize(), ns3::WifiMacTrailer::Serialize(), anonymous_namespace{packet.cc}::ATestTrailer< N >::Serialize(), and anonymous_namespace{packet-metadata-test.cc}::HistoryTrailer< N >::Serialize().
void ns3::Buffer::Iterator::Read | ( | uint8_t * | buffer, | |
uint32_t | size | |||
) |
buffer | buffer to copy data into | |
size | number of bytes to copy |
Copy size bytes of data from the internal buffer to the input buffer and avance the Iterator by the number of bytes read.
Definition at line 1023 of file buffer.cc.
References ReadU8().
Referenced by ns3::Icmpv4Echo::Deserialize(), ns3::SupportedRates::Deserialize(), and ns3::Ssid::Deserialize().
uint16_t ns3::Buffer::Iterator::ReadLsbtohU16 | ( | void | ) |
Read data and advance the Iterator by the number of bytes read. The data is read in network format and return in host format.
Definition at line 968 of file buffer.cc.
References ReadU8().
Referenced by ns3::WifiMacHeader::Deserialize().
uint32_t ns3::Buffer::Iterator::ReadLsbtohU32 | ( | void | ) |
uint64_t ns3::Buffer::Iterator::ReadLsbtohU64 | ( | void | ) |
uint16_t ns3::Buffer::Iterator::ReadNtohU16 | ( | void | ) |
Read data and advance the Iterator by the number of bytes read. The data is read in network format and return in host format.
Definition at line 925 of file buffer.cc.
References ReadU8().
Referenced by ns3::olsr::MessageHeader::Tc::Deserialize(), ns3::olsr::MessageHeader::Hello::Deserialize(), ns3::olsr::MessageHeader::Deserialize(), ns3::olsr::PacketHeader::Deserialize(), ns3::Ipv6Header::Deserialize(), ns3::Ipv4Header::Deserialize(), ns3::EthernetHeader::Deserialize(), ns3::Icmpv4DestinationUnreachable::Deserialize(), ns3::Icmpv4Echo::Deserialize(), ns3::Icmpv4Header::Deserialize(), ns3::ArpHeader::Deserialize(), ns3::StatusCode::Deserialize(), ns3::CapabilityInformation::Deserialize(), ns3::PppHeader::Deserialize(), and ns3::BufferTest::RunTests().
uint32_t ns3::Buffer::Iterator::ReadNtohU32 | ( | void | ) |
Read data and advance the Iterator by the number of bytes read. The data is read in network format and return in host format.
Definition at line 934 of file buffer.cc.
References ReadU8().
Referenced by ns3::olsr::MessageHeader::Hna::Deserialize(), ns3::olsr::MessageHeader::Tc::Deserialize(), ns3::olsr::MessageHeader::Hello::Deserialize(), ns3::olsr::MessageHeader::Mid::Deserialize(), ns3::olsr::MessageHeader::Deserialize(), ns3::Ipv6Header::Deserialize(), and ns3::Ipv4Header::Deserialize().
uint64_t ns3::Buffer::Iterator::ReadNtohU64 | ( | void | ) |
uint16_t ns3::Buffer::Iterator::ReadU16 | ( | void | ) |
Read data and advance the Iterator by the number of bytes read. The data is read in the format written by writeU16.
Definition at line 869 of file buffer.cc.
References ReadU8().
Referenced by CalculateIpChecksum(), ns3::Ipv4Header::Deserialize(), ns3::PacketMetadata::Deserialize(), and ns3::BufferTest::RunTests().
uint32_t ns3::Buffer::Iterator::ReadU32 | ( | void | ) |
Read data and advance the Iterator by the number of bytes read. The data is read in the format written by writeU32.
Definition at line 880 of file buffer.cc.
References ReadU8().
Referenced by ns3::EthernetTrailer::Deserialize(), ns3::Packet::Deserialize(), and ns3::PacketMetadata::Deserialize().
uint64_t ns3::Buffer::Iterator::ReadU64 | ( | void | ) |
Read data and advance the Iterator by the number of bytes read. The data is read in the format written by writeU64.
Definition at line 896 of file buffer.cc.
References ReadU8().
Referenced by ns3::EthernetHeader::Deserialize().
BUFFER_INLINE uint8_t ns3::Buffer::Iterator::ReadU8 | ( | void | ) |
Read data and advance the Iterator by the number of bytes read.
Referenced by CalculateIpChecksum(), ns3::Packet::CopyData(), ns3::olsr::MessageHeader::Hello::Deserialize(), ns3::olsr::MessageHeader::Deserialize(), ns3::Ipv6Header::Deserialize(), ns3::Ipv4Header::Deserialize(), ns3::Icmpv4TimeExceeded::Deserialize(), ns3::Icmpv4DestinationUnreachable::Deserialize(), ns3::Icmpv4Header::Deserialize(), ns3::ArpHeader::Deserialize(), ns3::SupportedRates::Deserialize(), ns3::Ssid::Deserialize(), anonymous_namespace{packet.cc}::ATestTrailer< N >::Deserialize(), anonymous_namespace{packet.cc}::ATestHeader< N >::Deserialize(), ns3::PacketMetadata::Deserialize(), anonymous_namespace{packet-metadata-test.cc}::HistoryTrailer< N >::Deserialize(), anonymous_namespace{packet-metadata-test.cc}::HistoryHeader< N >::Deserialize(), Read(), ReadLsbtohU16(), ReadLsbtohU32(), ReadLsbtohU64(), ReadNtohU16(), ReadNtohU32(), ReadNtohU64(), ReadU16(), ReadU32(), ReadU64(), and Write().
start | the start of the data to copy | |
end | the end of the data to copy |
Write the data delimited by start and end in internal buffer and avance the iterator position by the number of bytes copied. The input interators _must_ not point to the same Buffer as we do to avoid overlapping copies. This is enforced in debug builds by asserts.
Definition at line 753 of file buffer.cc.
References m_current, m_data, m_zeroEnd, m_zeroStart, NS_ASSERT, ReadU8(), and WriteU8().
void ns3::Buffer::Iterator::Write | ( | uint8_t const * | buffer, | |
uint32_t | size | |||
) |
buffer | a byte buffer to copy in the internal buffer. | |
size | number of bytes to copy. |
Write the data in buffer and avance the iterator position by size bytes.
Definition at line 860 of file buffer.cc.
References WriteU8().
Referenced by ns3::Buffer::AddAtEnd(), ns3::Buffer::CreateFullCopy(), ns3::Packet::Packet(), ns3::BufferTest::RunTests(), ns3::Icmpv4TimeExceeded::Serialize(), ns3::Icmpv4DestinationUnreachable::Serialize(), ns3::Icmpv4Echo::Serialize(), ns3::SupportedRates::Serialize(), ns3::Ssid::Serialize(), and ns3::PacketMetadata::Serialize().
void ns3::Buffer::Iterator::WriteHtolsbU16 | ( | uint16_t | data | ) |
data | data to write in buffer |
Write the data in buffer and avance the iterator position by two bytes. The data is written in network order and the input data is expected to be in host order.
Definition at line 807 of file buffer.cc.
References WriteU8().
Referenced by ns3::WifiMacHeader::Serialize().
void ns3::Buffer::Iterator::WriteHtolsbU32 | ( | uint32_t | data | ) |
void ns3::Buffer::Iterator::WriteHtolsbU64 | ( | uint64_t | data | ) |
void ns3::Buffer::Iterator::WriteHtonU16 | ( | uint16_t | data | ) |
data | data to write in buffer |
Write the data in buffer and avance the iterator position by two bytes. The data is written in least significant byte order and the input data is expected to be in host order.
Definition at line 834 of file buffer.cc.
References WriteU8().
Referenced by ns3::BufferTest::RunTests(), ns3::olsr::MessageHeader::Tc::Serialize(), ns3::olsr::MessageHeader::Hello::Serialize(), ns3::olsr::MessageHeader::Serialize(), ns3::olsr::PacketHeader::Serialize(), ns3::Ipv6Header::Serialize(), ns3::Ipv4Header::Serialize(), ns3::EthernetHeader::Serialize(), ns3::UdpHeader::Serialize(), ns3::Icmpv4DestinationUnreachable::Serialize(), ns3::Icmpv4Echo::Serialize(), ns3::Icmpv4Header::Serialize(), ns3::ArpHeader::Serialize(), ns3::StatusCode::Serialize(), ns3::CapabilityInformation::Serialize(), and ns3::PppHeader::Serialize().
void ns3::Buffer::Iterator::WriteHtonU32 | ( | uint32_t | data | ) |
data | data to write in buffer |
Write the data in buffer and avance the iterator position by four bytes. The data is written in network order and the input data is expected to be in host order.
Definition at line 840 of file buffer.cc.
References WriteU8().
Referenced by ns3::BufferTest::RunTests(), ns3::olsr::MessageHeader::Hna::Serialize(), ns3::olsr::MessageHeader::Tc::Serialize(), ns3::olsr::MessageHeader::Hello::Serialize(), ns3::olsr::MessageHeader::Mid::Serialize(), ns3::olsr::MessageHeader::Serialize(), ns3::Ipv6Header::Serialize(), and ns3::Ipv4Header::Serialize().
void ns3::Buffer::Iterator::WriteHtonU64 | ( | uint64_t | data | ) |
void ns3::Buffer::Iterator::WriteU16 | ( | uint16_t | data | ) |
data | data to write in buffer |
Write the data in buffer and avance the iterator position by two bytes. The format of the data written in the byte buffer is non-portable. We only ensure that readU16 will return exactly what we wrote with writeU16 if the program is run on the same machine.
Definition at line 770 of file buffer.cc.
References WriteU8().
Referenced by ns3::BufferTest::RunTests(), ns3::olsr::MessageHeader::Hello::Serialize(), ns3::Ipv4Header::Serialize(), ns3::UdpHeader::Serialize(), ns3::Icmpv4DestinationUnreachable::Serialize(), ns3::Icmpv4Header::Serialize(), and ns3::PacketMetadata::Serialize().
void ns3::Buffer::Iterator::WriteU32 | ( | uint32_t | data | ) |
data | data to write in buffer |
Write the data in buffer and avance the iterator position by four bytes. The format of the data written in the byte buffer is non-portable. We only ensure that readU32 will return exactly what we wrote with writeU32 if the program is run on the same machine.
Definition at line 777 of file buffer.cc.
References WriteU8().
Referenced by ns3::EthernetTrailer::Serialize(), ns3::Icmpv4TimeExceeded::Serialize(), ns3::WifiMacTrailer::Serialize(), ns3::Packet::Serialize(), and ns3::PacketMetadata::Serialize().
void ns3::Buffer::Iterator::WriteU64 | ( | uint64_t | data | ) |
data | data to write in buffer |
Write the data in buffer and avance the iterator position by eight bytes. The format of the data written in the byte buffer is non-portable. We only ensure that readU64 will return exactly what we wrote with writeU64 if the program is run on the same machine.
Definition at line 788 of file buffer.cc.
References WriteU8().
Referenced by ns3::EthernetHeader::Serialize().
BUFFER_INLINE void ns3::Buffer::Iterator::WriteU8 | ( | uint8_t | data, | |
uint32_t | len | |||
) |
data | data to write in buffer | |
len | number of times data must be written in buffer |
Write the data in buffer len times and avance the iterator position by len byte.
BUFFER_INLINE void ns3::Buffer::Iterator::WriteU8 | ( | uint8_t | data | ) |
data | data to write in buffer |
Write the data in buffer and avance the iterator position by one byte.
Referenced by ns3::Buffer::CreateFullCopy(), ns3::BufferTest::RunTests(), ns3::olsr::MessageHeader::Hello::Serialize(), ns3::olsr::MessageHeader::Serialize(), ns3::Ipv6Header::Serialize(), ns3::Ipv4Header::Serialize(), ns3::Icmpv4Header::Serialize(), ns3::ArpHeader::Serialize(), ns3::SupportedRates::Serialize(), ns3::Ssid::Serialize(), anonymous_namespace{packet.cc}::ATestTrailer< N >::Serialize(), anonymous_namespace{packet.cc}::ATestHeader< N >::Serialize(), ns3::PacketMetadata::Serialize(), anonymous_namespace{packet-metadata-test.cc}::HistoryTrailer< N >::Serialize(), anonymous_namespace{packet-metadata-test.cc}::HistoryHeader< N >::Serialize(), Write(), WriteHtolsbU16(), WriteHtolsbU32(), WriteHtolsbU64(), WriteHtonU16(), WriteHtonU32(), WriteHtonU64(), WriteU16(), WriteU32(), and WriteU64().
uint32_t ns3::Buffer::Iterator::m_current [private] |
Definition at line 393 of file buffer.h.
Referenced by GetDistanceFrom(), IsEnd(), IsStart(), Iterator(), Next(), Prev(), and Write().
uint8_t* ns3::Buffer::Iterator::m_data [private] |
Definition at line 397 of file buffer.h.
Referenced by Construct(), GetDistanceFrom(), and Write().
uint32_t ns3::Buffer::Iterator::m_dataEnd [private] |
Definition at line 389 of file buffer.h.
Referenced by Check(), Construct(), GetSize(), IsEnd(), Iterator(), and Next().
uint32_t ns3::Buffer::Iterator::m_dataStart [private] |
Definition at line 385 of file buffer.h.
Referenced by Check(), Construct(), GetSize(), IsStart(), and Iterator().
uint32_t ns3::Buffer::Iterator::m_zeroEnd [private] |
Definition at line 381 of file buffer.h.
Referenced by Check(), Construct(), and Write().
uint32_t ns3::Buffer::Iterator::m_zeroStart [private] |
Definition at line 377 of file buffer.h.
Referenced by Check(), Construct(), and Write().