mirror of
https://github.com/threefoldtech/mycelium.git
synced 2026-10-22 21:51:19 +00:00
Add method to get best route entries for IP
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
1 parent
537618c0b2
commit
7ba424a983
1 file changed
+15
@@ -433,6 +433,21 @@ impl RoutingTable {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a list of the routes for the most precises [`Subnet`] known which contains the given
|
||||
/// [`IpAddr`].
|
||||
pub fn best_routes(&self, ip: IpAddr) -> Option<Arc<RouteList>> {
|
||||
let IpAddr::V6(ip) = ip else {
|
||||
panic!("Only IPv6 is supported currently");
|
||||
};
|
||||
self.reader
|
||||
.enter()
|
||||
.expect("Write handle is saved on the router so it is not dropped yet.")
|
||||
.table
|
||||
.longest_match(ip)
|
||||
.map(|(_, _, rl)| rl)
|
||||
.cloned()
|
||||
}
|
||||
|
||||
/// Get a list of all routes for the given subnet. Changes to the RoutingTable after this
|
||||
/// method returns will not be visible and require this method to be called again to be
|
||||
/// observed.
|
||||
|
||||
Reference in new issue
Block a user