Skip to content

Commit

Permalink
Merge pull request #871 from thvdveld/neighbor-cache-with-expiration
Browse files Browse the repository at this point in the history
neigh: add fill_with_expiration method
  • Loading branch information
thvdveld committed Dec 11, 2023
2 parents cec04d9 + ece00ac commit 48cb672
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/iface/neighbor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,21 @@ impl Cache {
debug_assert!(protocol_addr.is_unicast());
debug_assert!(hardware_addr.is_unicast());

let expires_at = timestamp + Self::ENTRY_LIFETIME;
self.fill_with_expiration(protocol_addr, hardware_addr, expires_at);
}

pub fn fill_with_expiration(
&mut self,
protocol_addr: IpAddress,
hardware_addr: HardwareAddress,
expires_at: Instant,
) {
debug_assert!(protocol_addr.is_unicast());
debug_assert!(hardware_addr.is_unicast());

let neighbor = Neighbor {
expires_at: timestamp + Self::ENTRY_LIFETIME,
expires_at,
hardware_addr,
};
match self.storage.insert(protocol_addr, neighbor) {
Expand Down

0 comments on commit 48cb672

Please sign in to comment.