Skip to content

Commit

Permalink
Merge branch 'main' into chore-more-lints
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert authored Jan 16, 2025
2 parents 6d90eeb + bb286ef commit 0d2be45
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 0 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ fn bindgen() {
"Windows.Win32.Foundation.NO_ERROR",
"Windows.Win32.Networking.WinSock.AF_INET",
"Windows.Win32.Networking.WinSock.AF_INET6",
"Windows.Win32.Networking.WinSock.AF_UNSPEC",
"Windows.Win32.Networking.WinSock.SOCKADDR_INET",
"Windows.Win32.NetworkManagement.IpHelper.FreeMibTable",
"Windows.Win32.NetworkManagement.IpHelper.GetBestInterfaceEx",
Expand Down
5 changes: 3 additions & 2 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod bindings {

use bindings::{
if_indextoname, FreeMibTable, GetBestInterfaceEx, GetIpInterfaceTable, AF_INET, AF_INET6,
AF_UNSPEC, IF_MAX_STRING_SIZE, IN6_ADDR, IN6_ADDR_0, IN_ADDR, IN_ADDR_0, MIB_IPINTERFACE_ROW,
IF_MAX_STRING_SIZE, IN6_ADDR, IN6_ADDR_0, IN_ADDR, IN_ADDR_0, MIB_IPINTERFACE_ROW,
MIB_IPINTERFACE_TABLE, NO_ERROR, SOCKADDR, SOCKADDR_IN, SOCKADDR_IN6, SOCKADDR_INET,
};

Expand Down Expand Up @@ -109,7 +109,8 @@ pub fn interface_and_mtu_impl(remote: IpAddr) -> Result<(String, usize)> {
// Get a list of all interfaces with associated metadata.
let mut if_table = MibTablePtr::default();
// GetIpInterfaceTable allocates memory, which MibTablePtr::drop will free.
if unsafe { GetIpInterfaceTable(AF_UNSPEC, if_table.mut_ptr_ptr()) } != NO_ERROR {
let family = if remote.is_ipv4() { AF_INET } else { AF_INET6 };
if unsafe { GetIpInterfaceTable(family, if_table.mut_ptr_ptr()) } != NO_ERROR {
return Err(Error::last_os_error());
}
// Make a slice
Expand Down

0 comments on commit 0d2be45

Please sign in to comment.