Open trinity-1686a opened 3 years ago
When trying to set the Don't Fragment flag on an Ipv4 packet, using .flags(Flags::DONT_FRAGMENT), the resulting packet is incorrect
.flags(Flags::DONT_FRAGMENT)
| 45 | 00 | 00 28 | 00 00 | 00 02 | 40 | 06 | F7 14 | C0 A8 01 36 | C0 A8 01 33 | ^^^^^
I underlined the flag+fragment offset fields. It should be 0x4000 (0b0100_0000_0000_0000).
It seems when modifying flags, the full 2 bytes are overwritten, without any bitshift https://github.com/meh/rust-packet/blob/7496656c097aa96678745e6628fe4b616209e1af/src/ip/v4/packet.rs#L307-L312
When trying to set the Don't Fragment flag on an Ipv4 packet, using
.flags(Flags::DONT_FRAGMENT)
, the resulting packet is incorrectI underlined the flag+fragment offset fields. It should be 0x4000 (0b0100_0000_0000_0000).
It seems when modifying flags, the full 2 bytes are overwritten, without any bitshift https://github.com/meh/rust-packet/blob/7496656c097aa96678745e6628fe4b616209e1af/src/ip/v4/packet.rs#L307-L312