소스 검색

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.
Dario Nieuwenhuis 3 년 전
부모
커밋
22e7233bec
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      src/wire/dhcpv4.rs

+ 2 - 2
src/wire/dhcpv4.rs

@@ -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 });
     }
 }