From 1dec89e3a3d4e735ae926722c448d67fe657234e Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 24 May 2019 09:08:59 +0200 Subject: winipcfg: switch to windows.GetAdaptersAddresses Signed-off-by: Simon Rozman --- tunnel/winipcfg/winipcfg.go | 3 +-- tunnel/winipcfg/zwinipcfg_windows.go | 9 --------- 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'tunnel/winipcfg') diff --git a/tunnel/winipcfg/winipcfg.go b/tunnel/winipcfg/winipcfg.go index bc878606..5af9f1aa 100644 --- a/tunnel/winipcfg/winipcfg.go +++ b/tunnel/winipcfg/winipcfg.go @@ -21,7 +21,6 @@ import ( // Interface-related functions // -//sys getAdaptersAddresses(family uint32, flags GAAFlags, reserved uintptr, adapterAddresses *IPAdapterAddresses, sizePointer *uint32) (ret error) = iphlpapi.GetAdaptersAddresses //sys initializeIPInterfaceEntry(row *MibIPInterfaceRow) = iphlpapi.InitializeIpInterfaceEntry //sys getIPInterfaceTable(family AddressFamily, table **mibIPInterfaceTable) (ret error) = iphlpapi.GetIpInterfaceTable //sys getIPInterfaceEntry(row *MibIPInterfaceRow) (ret error) = iphlpapi.GetIpInterfaceEntry @@ -39,7 +38,7 @@ func GetAdaptersAddresses(family uint32, flags GAAFlags) ([]*IPAdapterAddresses, for { b = make([]byte, size) - err := getAdaptersAddresses(family, flags, 0, (*IPAdapterAddresses)(unsafe.Pointer(&b[0])), &size) + err := windows.GetAdaptersAddresses(family, uint32(flags), 0, (*windows.IpAdapterAddresses)(unsafe.Pointer(&b[0])), &size) if err == nil { break } diff --git a/tunnel/winipcfg/zwinipcfg_windows.go b/tunnel/winipcfg/zwinipcfg_windows.go index b08f887f..8f37ac26 100644 --- a/tunnel/winipcfg/zwinipcfg_windows.go +++ b/tunnel/winipcfg/zwinipcfg_windows.go @@ -40,7 +40,6 @@ var ( modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll") procFreeMibTable = modiphlpapi.NewProc("FreeMibTable") - procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") procInitializeIpInterfaceEntry = modiphlpapi.NewProc("InitializeIpInterfaceEntry") procGetIpInterfaceTable = modiphlpapi.NewProc("GetIpInterfaceTable") procGetIpInterfaceEntry = modiphlpapi.NewProc("GetIpInterfaceEntry") @@ -76,14 +75,6 @@ func freeMibTable(memory unsafe.Pointer) { return } -func getAdaptersAddresses(family uint32, flags GAAFlags, reserved uintptr, adapterAddresses *IPAdapterAddresses, sizePointer *uint32) (ret error) { - r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0) - if r0 != 0 { - ret = syscall.Errno(r0) - } - return -} - func initializeIPInterfaceEntry(row *MibIPInterfaceRow) { syscall.Syscall(procInitializeIpInterfaceEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0) return -- cgit v1.2.3-59-g8ed1b