wire/dhcp: BROADCAST flag is MSB (0x8000), not LSB (0x0001).

This fixes DHCP on Linksys WRT1900AC. With 0x0001, it would not reply to
DISCOVERs at all, probably because seeing an unknown reserved flag being set.
With 0x8000, it works fine.
master
Dario Nieuwenhuis 2021-10-14 13:59:16 +02:00
parent c0a46e2d14
commit fc5559069c
1 changed files with 2 additions and 2 deletions

View File

@ -455,7 +455,7 @@ impl<T: AsRef<[u8]>> Packet<T> {
/// Returns true if the broadcast flag is set.
pub fn broadcast_flag(&self) -> bool {
let field = &self.buffer.as_ref()[field::FLAGS];
NetworkEndian::read_u16(field) & 0b1 == 0b1
NetworkEndian::read_u16(field) & 0x8000 == 0x8000
}
}
@ -578,7 +578,7 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
/// Sets the broadcast flag to the specified value.
pub fn set_broadcast_flag(&mut self, value: bool) {
let field = &mut self.buffer.as_mut()[field::FLAGS];
NetworkEndian::write_u16(field, if value { 1 } else { 0 });
NetworkEndian::write_u16(field, if value { 0x8000 } else { 0 });
}
}