restore TCP option padding approach that avoids NOPs
This commit is contained in:
@@ -317,7 +317,9 @@ TcpHeader::Serialize (Buffer::Iterator start) const
|
||||
i.WriteHtonU16 (0);
|
||||
i.WriteHtonU16 (m_urgentPointer);
|
||||
|
||||
// Serialize options if they exists
|
||||
// Serialize options if they exist
|
||||
// This implementation does not presently try to align options on word
|
||||
// boundaries using NOP options
|
||||
uint32_t optionLen = 0;
|
||||
TcpOptionList::const_iterator op;
|
||||
for (op = m_options.begin (); op != m_options.end (); ++op)
|
||||
@@ -327,17 +329,10 @@ TcpHeader::Serialize (Buffer::Iterator start) const
|
||||
i.Next ((*op)->GetSerializedSize ());
|
||||
}
|
||||
|
||||
// padding to word alignment; add NOPs as needed until last byte which is END
|
||||
// padding to word alignment; add ENDs and/or pad values (they are the same)
|
||||
while (optionLen % 4)
|
||||
{
|
||||
if ((optionLen % 4) == 3)
|
||||
{
|
||||
i.WriteU8 (TcpOption::END);
|
||||
}
|
||||
else
|
||||
{
|
||||
i.WriteU8 (TcpOption::NOP);
|
||||
}
|
||||
i.WriteU8 (TcpOption::END);
|
||||
++optionLen;
|
||||
}
|
||||
|
||||
|
||||
@@ -265,18 +265,18 @@ TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime ()
|
||||
buffer.GetSize (), "Header not correctly serialized");
|
||||
|
||||
// Inserted only 1 byte NOP, and so implementation should pad; so
|
||||
// the other 3 bytes should be NOP, NOP, END
|
||||
// the other 3 bytes should be END, PAD, PAD (n.b. PAD is same as END)
|
||||
Buffer::Iterator i = buffer.Begin ();
|
||||
i.Next (20);
|
||||
|
||||
uint8_t value = i.ReadU8 ();
|
||||
NS_TEST_ASSERT_MSG_EQ (value, TcpOption::NOP, "NOP not present at byte 1");
|
||||
value = i.ReadU8 ();
|
||||
NS_TEST_ASSERT_MSG_EQ (value, TcpOption::NOP, "NOP not present at byte 2");
|
||||
NS_TEST_ASSERT_MSG_EQ (value, TcpOption::END, "END not present at byte 2");
|
||||
value = i.ReadU8 ();
|
||||
NS_TEST_ASSERT_MSG_EQ (value, TcpOption::NOP, "NOP not present at byte 3");
|
||||
NS_TEST_ASSERT_MSG_EQ (value, TcpOption::END, "pad not present at byte 3");
|
||||
value = i.ReadU8 ();
|
||||
NS_TEST_ASSERT_MSG_EQ (value, TcpOption::END, "END not present at byte 4");
|
||||
NS_TEST_ASSERT_MSG_EQ (value, TcpOption::END, "pad not present at byte 4");
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user