Skip to content

Commit

Permalink
Follow-up to b9e79d1; always process broadcast frames.
Browse files Browse the repository at this point in the history
whitequark committed Mar 6, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent b9e79d1 commit 3dfcb11
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/iface/ethernet.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions src/wire/ethernet.rs
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3dfcb11

Please sign in to comment.