pub struct Route {
pub destination: IpAddr,
pub prefix: u8,
pub gateway: Option<IpAddr>,
pub ifindex: Option<u32>,
}
Expand description
Contains information that describes a route in the local computer’s Ipv4 or Ipv6 routing table.
Fields§
§destination: IpAddr
Network address of the destination. 0.0.0.0
with a prefix of 0
is considered a default route.
prefix: u8
Length of network prefix in the destination address.
gateway: Option<IpAddr>
The address of the next hop of this route.
On macOS, this must be Some
if ifindex is None
ifindex: Option<u32>
The index of the local interface through which the next hop of this route may be reached.
On macOS, this must be Some
if gateway is None
Implementations§
Source§impl Route
impl Route
Sourcepub fn new(destination: IpAddr, prefix: u8) -> Self
pub fn new(destination: IpAddr, prefix: u8) -> Self
Create a route that matches a given destination network.
Either the gateway or interface should be set before attempting to add to a routing table.
Sourcepub fn with_gateway(self, gateway: IpAddr) -> Self
pub fn with_gateway(self, gateway: IpAddr) -> Self
Set the next next hop gateway for this route.
Sourcepub fn with_ifindex(self, ifindex: u32) -> Self
pub fn with_ifindex(self, ifindex: u32) -> Self
Set the index of the local interface through which the next hop of this route should be reached.