On 29/11/16 at 06:05pm, NanerLee wrote:
> Thanks for your reply, But the order I said is not the order in which they
> are declared. I means the positions *left-shifted*.
>
> In the source code, DONT_FRAGMENT left-shifted by 0 = 001; MORE_FRAGMENTS
> left-shifted by 1 = 010.
>
> As we know, DONT_FRAGMENT should set 1 at the second position(010), and
> MORE_FRAGMENTS should set 1 at the third position(001). So I think the
> positions is wrong.
Hi,
I'm absolutely not an expert of the Ipv4 code, but I suggest you to not
focus on the declaration only, take also a look on the Serialize ()
method and the various Set*Fragments () methods.
Print the values, and then look what is written in the Serialize ()
and various Set*Fragments() methods. Just for reference, this is what goes on
the network:
uint32_t fragmentOffset = m_fragmentOffset / 8;
uint8_t flagsFrag = (fragmentOffset >> 8) & 0x1f;
if (m_flags & DONT_FRAGMENT)
{
flagsFrag |= (1<<6);
}
if (m_flags & MORE_FRAGMENTS)
{
flagsFrag |= (1<<5);
}
i.WriteU8 (flagsFrag);
In which the values DONT_FRAGMENT and MORE_FRAGMENTS are not written directly
into the buffer.
Nat