Browse Source

Follow-up to b9e79d19; always process broadcast frames.

whitequark 8 years ago
parent
commit
3dfcb11d33
2 changed files with 9 additions and 1 deletions
  1. 4 1
      src/iface/ethernet.rs
  2. 5 0
      src/wire/ethernet.rs

+ 4 - 1
src/iface/ethernet.rs

@@ -119,7 +119,10 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> {
         let rx_buffer = try!(self.device.receive());
         let eth_frame = try!(EthernetFrame::new(&rx_buffer));
 
-        if eth_frame.dst_addr() != self.hardware_addr { return Ok(()) }
+        if !eth_frame.dst_addr().is_broadcast() &&
+                eth_frame.dst_addr() != self.hardware_addr {
+            return Ok(())
+        }
 
         let mut response = Response::Nop;
         match eth_frame.ethertype() {

+ 5 - 0
src/wire/ethernet.rs

@@ -45,6 +45,11 @@ impl Address {
         &self.0
     }
 
+    /// Query whether this address is the broadcast address.
+    pub fn is_broadcast(&self) -> bool {
+        self.0 == [0xff; 6]
+    }
+
     /// Query whether the "multicast" bit in the OUI is set.
     pub fn is_multicast(&self) -> bool {
         self.0[0] & 0x01 != 0