network: Fix alignment for TSFT radiotap subfield
This commit is contained in:
committed by
Sébastien Deronne
parent
17708181bb
commit
4da2fbfca2
@@ -72,7 +72,7 @@ RadiotapHeader::Serialize(Buffer::Iterator start) const
|
||||
//
|
||||
if (m_present & RADIOTAP_TSFT) // bit 0
|
||||
{
|
||||
start.WriteU64(m_tsft);
|
||||
SerializeTsft(start);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -307,8 +307,7 @@ RadiotapHeader::Deserialize(Buffer::Iterator start)
|
||||
//
|
||||
if (m_present & RADIOTAP_TSFT) // bit 0
|
||||
{
|
||||
m_tsft = start.ReadU64();
|
||||
bytesRead += 8;
|
||||
bytesRead += DeserializeTsft(start, bytesRead);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -575,14 +574,31 @@ RadiotapHeader::SetTsft(uint64_t value)
|
||||
NS_LOG_FUNCTION(this << value);
|
||||
|
||||
NS_ASSERT_MSG(!(m_present & RADIOTAP_TSFT), "TSFT radiotap field already present");
|
||||
m_tsftPad = ((8 - m_length % 8) % 8);
|
||||
m_present |= RADIOTAP_TSFT;
|
||||
m_length += 8;
|
||||
m_length += 8 + m_tsftPad;
|
||||
m_tsft = value;
|
||||
|
||||
NS_LOG_LOGIC(this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present
|
||||
<< std::dec);
|
||||
}
|
||||
|
||||
void
|
||||
RadiotapHeader::SerializeTsft(Buffer::Iterator& start) const
|
||||
{
|
||||
start.WriteU8(0, m_tsftPad);
|
||||
start.WriteU64(m_tsft);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
RadiotapHeader::DeserializeTsft(Buffer::Iterator start, uint32_t bytesRead)
|
||||
{
|
||||
m_tsftPad = ((8 - bytesRead % 8) % 8);
|
||||
start.Next(m_tsftPad);
|
||||
m_tsft = start.ReadU64();
|
||||
return sizeof(m_tsft) + m_tsftPad;
|
||||
}
|
||||
|
||||
void
|
||||
RadiotapHeader::SetFrameFlags(uint8_t flags)
|
||||
{
|
||||
|
||||
@@ -773,6 +773,23 @@ class RadiotapHeader : public Header
|
||||
void SetEhtFields(const EhtFields& ehtFields);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Serialize the TSFT radiotap header.
|
||||
*
|
||||
* @param start An iterator which points to where the header should be written.
|
||||
*/
|
||||
void SerializeTsft(Buffer::Iterator& start) const;
|
||||
|
||||
/**
|
||||
* Deserialize the TSFT radiotap header.
|
||||
*
|
||||
* @param start An iterator which points to where the header should be read.
|
||||
* @param bytesRead the number of bytes already read.
|
||||
|
||||
* @returns The number of bytes read.
|
||||
*/
|
||||
uint32_t DeserializeTsft(Buffer::Iterator start, uint32_t bytesRead);
|
||||
|
||||
/**
|
||||
* Serialize the Channel radiotap header.
|
||||
*
|
||||
@@ -1035,8 +1052,9 @@ class RadiotapHeader : public Header
|
||||
uint32_t m_present{0}; //!< bits describing which fields follow header
|
||||
std::optional<uint32_t> m_presentExt{}; //!< optional extended present bitmask
|
||||
|
||||
uint64_t m_tsft{0}; //!< Time Synchronization Function Timer (when the first bit of the MPDU
|
||||
//!< arrived at the MAC)
|
||||
uint8_t m_tsftPad{0}; //!< TSFT padding.
|
||||
uint64_t m_tsft{0}; //!< Time Synchronization Function Timer (when the first bit of the MPDU
|
||||
//!< arrived at the MAC)
|
||||
|
||||
uint8_t m_flags{FRAME_FLAG_NONE}; //!< Properties of transmitted and received frames.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user