Populate ARP cache from incoming IP packets.

v0.7.x
whitequark 2016-12-23 07:31:02 +00:00
parent 1ad8f9c9bd
commit 2f24fb263b
1 changed files with 4 additions and 0 deletions

View File

@ -171,6 +171,10 @@ impl<'a, 'b: 'a,
EthernetProtocol::Ipv4 => {
let ip_packet = try!(Ipv4Packet::new(eth_frame.payload()));
let ip_repr = try!(Ipv4Repr::parse(&ip_packet));
// Fill the ARP cache from IP header.
self.arp_cache.fill(IpAddress::Ipv4(ip_repr.src_addr), eth_frame.src_addr());
match ip_repr {
// Ignore IP packets not directed at us.
Ipv4Repr { dst_addr, .. } if !self.has_protocol_addr(dst_addr) => (),