pub struct Route {
pub destination: IpAddr,
pub prefix: u8,
pub gateway: Option<IpAddr>,
pub ifindex: Option<u32>,
pub table: u8,
pub source: Option<IpAddr>,
pub source_prefix: u8,
pub source_hint: Option<IpAddr>,
pub metric: Option<u32>,
}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.
source: Option<IpAddr>Network address of the source.
source_prefix: u8Prefix length of the source address.
source_hint: Option<IpAddr>Source address hint. Does not influence routing.
metric: Option<u32>The route metric offset value for this route.
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.
Sourcepub fn with_source(self, source: IpAddr, prefix: u8) -> Self
pub fn with_source(self, source: IpAddr, prefix: u8) -> Self
Set source.
Sourcepub fn with_source_hint(self, hint: IpAddr) -> Self
pub fn with_source_hint(self, hint: IpAddr) -> Self
Set source hint.
Sourcepub fn with_metric(self, metric: u32) -> Self
pub fn with_metric(self, metric: u32) -> Self
Set route metric.