Skip to content

Commit

Permalink
Merge pull request #2 from libp2p/windows-non-syscall
Browse files Browse the repository at this point in the history
remove syscall dep from windows
  • Loading branch information
Stebalien authored Mar 10, 2020
2 parents ada0e6f + 1afb09c commit 5e42067
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions netroute_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"encoding/binary"
"fmt"
"net"
"syscall"
"unsafe"

"github.com/google/gopacket/routing"
Expand All @@ -21,7 +20,7 @@ import (
)

var (
modiphlpapi = syscall.NewLazyDLL("iphlpapi.dll")
modiphlpapi = windows.NewLazyDLL("iphlpapi.dll")
procGetBestRoute2 = modiphlpapi.NewProc("GetBestRoute2")
)

Expand Down Expand Up @@ -174,17 +173,16 @@ func readSockAddr(buffer []byte, idx int) (*windows.RawSockaddrAny, int, error)
}

func getBestRoute2(interfaceLuid *NetLUID, interfaceIndex uint32, sourceAddress, destinationAddress *windows.RawSockaddrAny, addressSortOptions uint32, bestRoute []byte, bestSourceAddress []byte) (errcode error) {
r0, _, _ := syscall.Syscall9(procGetBestRoute2.Addr(), 7,
r0, _, _ := procGetBestRoute2.Call(
uintptr(unsafe.Pointer(interfaceLuid)),
uintptr(interfaceIndex),
uintptr(unsafe.Pointer(sourceAddress)),
uintptr(unsafe.Pointer(destinationAddress)),
uintptr(addressSortOptions),
uintptr(unsafe.Pointer(&bestRoute[0])),
uintptr(unsafe.Pointer(&bestSourceAddress[0])),
0, 0)
uintptr(unsafe.Pointer(&bestSourceAddress[0])))
if r0 != 0 {
errcode = syscall.Errno(r0)
errcode = windows.Errno(r0)
}
return
}
Expand Down

0 comments on commit 5e42067

Please sign in to comment.