Update windows dependency

main
shellrow 2 years ago
parent 1bc3d44857
commit dbda68f696
  1. 4
      Cargo.toml
  2. 16
      src/interface/windows.rs

@ -26,8 +26,8 @@ netlink-sys = "0.8"
memalloc = "0.1.0" memalloc = "0.1.0"
[target.'cfg(windows)'.dependencies.windows] [target.'cfg(windows)'.dependencies.windows]
version = "0.32.0" version = "0.48.0"
features = ["Win32_Foundation","Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock"] features = ["Win32_Foundation","Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock", "Win32_NetworkManagement_Ndis"]
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
system-configuration = "0.5.0" system-configuration = "0.5.0"

@ -6,10 +6,10 @@ use std::convert::TryInto;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use windows::Win32::Foundation::{ERROR_BUFFER_OVERFLOW, NO_ERROR}; use windows::Win32::Foundation::{ERROR_BUFFER_OVERFLOW, NO_ERROR};
use windows::Win32::NetworkManagement::IpHelper::{ 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, 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::gateway::Gateway;
use crate::interface::{Interface, InterfaceType, MacAddr}; use crate::interface::{Interface, InterfaceType, MacAddr};
@ -61,10 +61,10 @@ pub fn interfaces() -> Vec<Interface> {
let old_size = dwsize as usize; let old_size = dwsize as usize;
ret_val = unsafe { ret_val = unsafe {
GetAdaptersAddresses( GetAdaptersAddresses(
AF_UNSPEC, AF_UNSPEC.0 as u32,
GAA_FLAG_INCLUDE_GATEWAYS, GAA_FLAG_INCLUDE_GATEWAYS,
std::ptr::null_mut::<std::ffi::c_void>(), Some(std::ptr::null_mut::<std::ffi::c_void>()),
mem, Some(mem),
&mut dwsize, &mut dwsize,
) )
}; };
@ -126,7 +126,7 @@ pub fn interfaces() -> Vec<Interface> {
let addr = unsafe { (*cur_a).Address }; let addr = unsafe { (*cur_a).Address };
let prefix_len = unsafe { (*cur_a).OnLinkPrefixLength }; let prefix_len = unsafe { (*cur_a).OnLinkPrefixLength };
let sockaddr = unsafe { *addr.lpSockaddr }; 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 sockaddr: *mut SOCKADDR_IN = addr.lpSockaddr as *mut SOCKADDR_IN;
let a = unsafe { (*sockaddr).sin_addr.S_un.S_addr }; let a = unsafe { (*sockaddr).sin_addr.S_un.S_addr };
let ipv4 = if cfg!(target_endian = "little") { let ipv4 = if cfg!(target_endian = "little") {
@ -136,7 +136,7 @@ pub fn interfaces() -> Vec<Interface> {
}; };
let ipv4_net: Ipv4Net = Ipv4Net::new(ipv4, prefix_len); let ipv4_net: Ipv4Net = Ipv4Net::new(ipv4, prefix_len);
ipv4_vec.push(ipv4_net); 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 sockaddr: *mut SOCKADDR_IN6 = addr.lpSockaddr as *mut SOCKADDR_IN6;
let a = unsafe { (*sockaddr).sin6_addr.u.Byte }; let a = unsafe { (*sockaddr).sin6_addr.u.Byte };
let ipv6 = Ipv6Addr::from(a); let ipv6 = Ipv6Addr::from(a);
@ -152,7 +152,7 @@ pub fn interfaces() -> Vec<Interface> {
while !cur_g.is_null() { while !cur_g.is_null() {
let addr = unsafe { (*cur_g).Address }; let addr = unsafe { (*cur_g).Address };
let sockaddr = unsafe { *addr.lpSockaddr }; 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 sockaddr: *mut SOCKADDR_IN = addr.lpSockaddr as *mut SOCKADDR_IN;
let a = unsafe { (*sockaddr).sin_addr.S_un.S_addr }; let a = unsafe { (*sockaddr).sin_addr.S_un.S_addr };
let ipv4 = if cfg!(target_endian = "little") { let ipv4 = if cfg!(target_endian = "little") {

Loading…
Cancel
Save