route: add remove_default_ipvX_route

master
Dario Nieuwenhuis 2021-04-07 00:47:41 +02:00
parent ab47db24e0
commit ef58fc67a4
1 changed files with 18 additions and 0 deletions

View File

@ -106,6 +106,24 @@ impl<'a> Routes<'a> {
}
}
/// Remove the default ipv4 gateway
///
/// On success, returns the previous default route, if any.
#[cfg(feature = "proto-ipv4")]
pub fn remove_default_ipv4_route(&mut self) -> Option<Route> {
let cidr = IpCidr::new(IpAddress::v4(0, 0, 0, 0), 0);
self.storage.remove(&cidr)
}
/// Remove the default ipv6 gateway
///
/// On success, returns the previous default route, if any.
#[cfg(feature = "proto-ipv6")]
pub fn remove_default_ipv6_route(&mut self) -> Option<Route> {
let cidr = IpCidr::new(IpAddress::v6(0, 0, 0, 0, 0, 0, 0, 0), 0);
self.storage.remove(&cidr)
}
pub(crate) fn lookup(&self, addr: &IpAddress, timestamp: Instant) ->
Option<IpAddress> {
assert!(addr.is_unicast());