From fc5559069c3ffe150bf0df304b59c880a481b674 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 14 Oct 2021 13:59:16 +0200 Subject: [PATCH] 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. --- src/wire/dhcpv4.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wire/dhcpv4.rs b/src/wire/dhcpv4.rs index 8ac8e59..de281b3 100644 --- a/src/wire/dhcpv4.rs +++ b/src/wire/dhcpv4.rs @@ -455,7 +455,7 @@ impl> Packet { /// 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 + AsMut<[u8]>> Packet { /// 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 }); } }