Merge pull request #32 from shellrow/24-update-windows-dependency

Update windows dependency
main
shellrow 2 years ago committed by GitHub
commit 3b4c18f550
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .github/workflows/ci.yml
  2. 4
      Cargo.toml
  3. 19
      src/interface/windows.rs

@ -45,6 +45,7 @@ jobs:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- i686-unknown-linux-gnu
- armv7-linux-androideabi
- aarch64-linux-android
@ -53,9 +54,7 @@ jobs:
- uses: actions/checkout@master
- name: Install Rust Toolchain
# See https://github.com/cross-rs/cross/issues/1222 for when
# stable can be used instead of 1.67 again.
run: rustup toolchain install 1.67 --profile minimal --no-self-update
run: rustup toolchain install stable --profile minimal --no-self-update
- uses: swatinem/rust-cache@v2

@ -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"

@ -6,10 +6,11 @@ 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,
IP_ADAPTER_ADDRESSES_LH,
GetAdaptersAddresses, SendARP, GAA_FLAG_INCLUDE_GATEWAYS, IP_ADAPTER_ADDRESSES_LH,
};
use windows::Win32::Networking::WinSock::{
AF_INET, AF_INET6, AF_UNSPEC, SOCKADDR_IN, SOCKADDR_IN6,
};
use windows::Win32::Networking::WinSock::{SOCKADDR_IN, SOCKADDR_IN6};
use crate::gateway::Gateway;
use crate::interface::{Interface, InterfaceType, MacAddr};
@ -61,10 +62,10 @@ pub fn interfaces() -> Vec<Interface> {
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::<std::ffi::c_void>(),
mem,
Some(std::ptr::null_mut::<std::ffi::c_void>()),
Some(mem),
&mut dwsize,
)
};
@ -126,7 +127,7 @@ pub fn interfaces() -> Vec<Interface> {
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 +137,7 @@ pub fn interfaces() -> Vec<Interface> {
};
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 +153,7 @@ pub fn interfaces() -> Vec<Interface> {
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") {

Loading…
Cancel
Save