pub struct Route {
pub destination: IpAddr,
pub prefix: u8,
pub gateway: Option<IpAddr>,
pub ifindex: Option<u32>,
pub table: u8,
}Expand description
Contains information that describes a route in the local computer’s Ipv4 or Ipv6 routing table.
Fields§
§destination: IpAddrNetwork address of the destination. 0.0.0.0 with a prefix of 0 is considered a default route.
prefix: u8Length 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
table: u8The routing table this route belongs to.
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.
sourcepub fn with_table(self, table: u8) -> Self
pub fn with_table(self, table: u8) -> Self
Set table the route will be installed in.