Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions ts_netmon/src/bsd/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ impl<'a> Message<'a> {

let (MessageHeader::Interface(net_table::Interface {
index,
data: net_table::InterfaceData { mtu, .. },
data: net_table::InterfaceData { mtu, metric, .. },
..
})
| MessageHeader::Interface2(net_table::Interface2 {
index,
data: net_table::InterfaceData64 { mtu, .. },
data: net_table::InterfaceData64 { mtu, metric, .. },
..
})) = &self.header
else {
Expand All @@ -271,6 +271,8 @@ impl<'a> Message<'a> {
},
name: la.name.clone(),
up: self.header.flags().contains(Flags::UP),
metric_v4: metric.get() as _,
metric_v6: metric.get() as _,
})
}

Expand Down
18 changes: 18 additions & 0 deletions ts_netmon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ pub struct Interface {

/// The interface's hardware address (if set).
pub hardware_addr: Option<smallvec::SmallVec<[u8; 6]>>,

/// The routing metric for IPv4 addresses on this interface.
///
/// Only some platforms have this field on an interface basis; others should set it to
/// zero. The metric for a route is the sum of the interface metric and the route's
/// intrinsic metric.
pub metric_v4: usize,

/// The routing metric for IPv6 addresses on this interface.
///
/// Only some platforms have this field on an interface basis; others should set it to
/// zero. The metric for a route is the sum of the interface metric and the route's
/// intrinsic metric.
pub metric_v6: usize,
}

/// The unique/identifying part of a [`Route`] (excludes the metric field).
Expand All @@ -77,6 +91,10 @@ pub struct Route {
/// gateways for a given route.
pub gateway: smallvec::SmallVec<[IpAddr; 1]>,
/// The metric for this route. Lower is higher-preference.
///
/// Not all platforms (notably BSD, including macOS) have a per-route metric and instead
/// use the interface metric instead. The metric for a route is the sum of its interface
/// metric and this intrinsic metric.
pub metric: usize,
}

Expand Down
2 changes: 2 additions & 0 deletions ts_netmon/src/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ fn load_interface(link: LinkMessage) -> Option<Interface> {
name: name?,
mtu,
hardware_addr,
metric_v4: 0,
metric_v6: 0,
})
}

Expand Down
Loading
Loading