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
4 changes: 2 additions & 2 deletions src/interface/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ pub fn interfaces() -> Vec<Interface> {
ipv6: ipv6_vec,
ipv6_scope_ids: ipv6_scope_id_vec,
flags,
transmit_speed: Some(cur.TransmitLinkSpeed),
receive_speed: Some(cur.ReceiveLinkSpeed),
transmit_speed: sys::sanitize_u64(cur.TransmitLinkSpeed),
receive_speed: sys::sanitize_u64(cur.ReceiveLinkSpeed),
#[cfg(feature = "gateway")]
gateway: if default_gateway.mac_addr == MacAddr::zero() {
None
Expand Down
10 changes: 10 additions & 0 deletions src/sys/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ pub const IFF_BROADCAST: u32 = ws::IFF_BROADCAST;
pub const IFF_LOOPBACK: u32 = ws::IFF_LOOPBACK;
pub const IFF_POINTOPOINT: u32 = ws::IFF_POINTTOPOINT;
pub const IFF_MULTICAST: u32 = ws::IFF_MULTICAST;

/// Convert u64::MAX to None.
/// Used for Windows APIs that return invalid max values.
pub(crate) fn sanitize_u64(val: u64) -> Option<u64> {
if val == u64::MAX {
None
} else {
Some(val)
}
}