本文整理匯總了Golang中syscall.GetAdaptersInfo函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetAdaptersInfo函數的具體用法?Golang GetAdaptersInfo怎麽用?Golang GetAdaptersInfo使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetAdaptersInfo函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getAdapterList
func (cInfo *connectionInfo) getAdapterList() (*syscall.IpAdapterInfo, error) {
bTmp := make([]byte, 1000)
length := uint32(len(bTmp))
adtr := (*syscall.IpAdapterInfo)(unsafe.Pointer(&bTmp[0]))
if err := syscall.GetAdaptersInfo(adtr, &length); err == syscall.ERROR_BUFFER_OVERFLOW {
bTmp = make([]byte, length)
adtr = (*syscall.IpAdapterInfo)(unsafe.Pointer(&bTmp[0]))
if err = syscall.GetAdaptersInfo(adtr, &length); err != nil {
return nil, os.NewSyscallError("GetAdaptersInfo", err)
}
}
return adtr, nil
}
示例2: getAdapterList
// borrowed from src/pkg/net/interface_windows.go
func getAdapterList() (*syscall.IpAdapterInfo, error) {
b := make([]byte, 1000)
l := uint32(len(b))
a := (*syscall.IpAdapterInfo)(unsafe.Pointer(&b[0]))
err := syscall.GetAdaptersInfo(a, &l)
if err == syscall.ERROR_BUFFER_OVERFLOW {
b = make([]byte, l)
a = (*syscall.IpAdapterInfo)(unsafe.Pointer(&b[0]))
err = syscall.GetAdaptersInfo(a, &l)
}
if err != nil {
return nil, os.NewSyscallError("GetAdaptersInfo", err)
}
return a, nil
}
示例3: getAdapterList
func getAdapterList() (*syscall.IpAdapterInfo, error) {
b := make([]byte, 1000)
l := uint32(len(b))
a := (*syscall.IpAdapterInfo)(unsafe.Pointer(&b[0]))
// TODO(mikio): GetAdaptersInfo returns IP_ADAPTER_INFO that
// contains IPv4 address list only. We should use another API
// for fetching IPv6 stuff from the kernel.
err := syscall.GetAdaptersInfo(a, &l)
if err == syscall.ERROR_BUFFER_OVERFLOW {
b = make([]byte, l)
a = (*syscall.IpAdapterInfo)(unsafe.Pointer(&b[0]))
err = syscall.GetAdaptersInfo(a, &l)
}
if err != nil {
return nil, os.NewSyscallError("GetAdaptersInfo", err)
}
return a, nil
}