Follow-up to b9e79d19; always process broadcast frames.

This commit is contained in:
whitequark 2017-03-06 04:00:13 +00:00
parent d25eebc0ef
commit 5137608aed
2 changed files with 9 additions and 1 deletions

View File

@ -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() {

View File

@ -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