From dbda68f6966ccc0c7a6f23d1a51cd360daa0d07f Mon Sep 17 00:00:00 2001 From: shellrow <81893184+shellrow@users.noreply.github.com> Date: Mon, 22 May 2023 21:20:51 +0900 Subject: [PATCH] Update windows dependency --- Cargo.toml | 4 ++-- src/interface/windows.rs | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c01ce45..e023e32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,8 @@ netlink-sys = "0.8" memalloc = "0.1.0" [target.'cfg(windows)'.dependencies.windows] -version = "0.32.0" -features = ["Win32_Foundation","Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock"] +version = "0.48.0" +features = ["Win32_Foundation","Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock", "Win32_NetworkManagement_Ndis"] [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] system-configuration = "0.5.0" diff --git a/src/interface/windows.rs b/src/interface/windows.rs index 65c5de5..7166712 100644 --- a/src/interface/windows.rs +++ b/src/interface/windows.rs @@ -6,10 +6,10 @@ use std::convert::TryInto; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use windows::Win32::Foundation::{ERROR_BUFFER_OVERFLOW, NO_ERROR}; use windows::Win32::NetworkManagement::IpHelper::{ - GetAdaptersAddresses, SendARP, AF_INET, AF_INET6, AF_UNSPEC, GAA_FLAG_INCLUDE_GATEWAYS, + GetAdaptersAddresses, SendARP, GAA_FLAG_INCLUDE_GATEWAYS, IP_ADAPTER_ADDRESSES_LH, }; -use windows::Win32::Networking::WinSock::{SOCKADDR_IN, SOCKADDR_IN6}; +use windows::Win32::Networking::WinSock::{SOCKADDR_IN, SOCKADDR_IN6, AF_INET, AF_INET6, AF_UNSPEC}; use crate::gateway::Gateway; use crate::interface::{Interface, InterfaceType, MacAddr}; @@ -61,10 +61,10 @@ pub fn interfaces() -> Vec { let old_size = dwsize as usize; ret_val = unsafe { GetAdaptersAddresses( - AF_UNSPEC, + AF_UNSPEC.0 as u32, GAA_FLAG_INCLUDE_GATEWAYS, - std::ptr::null_mut::(), - mem, + Some(std::ptr::null_mut::()), + Some(mem), &mut dwsize, ) }; @@ -126,7 +126,7 @@ pub fn interfaces() -> Vec { let addr = unsafe { (*cur_a).Address }; let prefix_len = unsafe { (*cur_a).OnLinkPrefixLength }; let sockaddr = unsafe { *addr.lpSockaddr }; - if sockaddr.sa_family == AF_INET.0 as u16 { + if sockaddr.sa_family == AF_INET { let sockaddr: *mut SOCKADDR_IN = addr.lpSockaddr as *mut SOCKADDR_IN; let a = unsafe { (*sockaddr).sin_addr.S_un.S_addr }; let ipv4 = if cfg!(target_endian = "little") { @@ -136,7 +136,7 @@ pub fn interfaces() -> Vec { }; let ipv4_net: Ipv4Net = Ipv4Net::new(ipv4, prefix_len); ipv4_vec.push(ipv4_net); - } else if sockaddr.sa_family == AF_INET6.0 as u16 { + } else if sockaddr.sa_family == AF_INET6 { let sockaddr: *mut SOCKADDR_IN6 = addr.lpSockaddr as *mut SOCKADDR_IN6; let a = unsafe { (*sockaddr).sin6_addr.u.Byte }; let ipv6 = Ipv6Addr::from(a); @@ -152,7 +152,7 @@ pub fn interfaces() -> Vec { while !cur_g.is_null() { let addr = unsafe { (*cur_g).Address }; let sockaddr = unsafe { *addr.lpSockaddr }; - if sockaddr.sa_family == AF_INET.0 as u16 { + if sockaddr.sa_family == AF_INET { let sockaddr: *mut SOCKADDR_IN = addr.lpSockaddr as *mut SOCKADDR_IN; let a = unsafe { (*sockaddr).sin_addr.S_un.S_addr }; let ipv4 = if cfg!(target_endian = "little") {