LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Network interface identification for Windows | 5 // Network interface identification for Windows |
6 | 6 |
7 package net | 7 package net |
8 | 8 |
9 import ( | 9 import ( |
10 "os" | 10 "os" |
(...skipping 21 matching lines...) Expand all Loading... |
32 e = syscall.GetAdaptersInfo(a, &l) | 32 e = syscall.GetAdaptersInfo(a, &l) |
33 } | 33 } |
34 if e != 0 { | 34 if e != 0 { |
35 return nil, os.NewSyscallError("GetAdaptersInfo", e) | 35 return nil, os.NewSyscallError("GetAdaptersInfo", e) |
36 } | 36 } |
37 return a, nil | 37 return a, nil |
38 } | 38 } |
39 | 39 |
40 func getInterfaceList() ([]syscall.InterfaceInfo, error) { | 40 func getInterfaceList() ([]syscall.InterfaceInfo, error) { |
41 s, e := syscall.Socket(syscall.AF_INET, syscall.SOCK_DGRAM, syscall.IPPR
OTO_UDP) | 41 s, e := syscall.Socket(syscall.AF_INET, syscall.SOCK_DGRAM, syscall.IPPR
OTO_UDP) |
42 » if e != 0 { | 42 » if e != nil { |
43 return nil, os.NewSyscallError("Socket", e) | 43 return nil, os.NewSyscallError("Socket", e) |
44 } | 44 } |
45 defer syscall.Closesocket(s) | 45 defer syscall.Closesocket(s) |
46 | 46 |
47 ii := [20]syscall.InterfaceInfo{} | 47 ii := [20]syscall.InterfaceInfo{} |
48 ret := uint32(0) | 48 ret := uint32(0) |
49 size := uint32(unsafe.Sizeof(ii)) | 49 size := uint32(unsafe.Sizeof(ii)) |
50 e = syscall.WSAIoctl(s, syscall.SIO_GET_INTERFACE_LIST, nil, 0, (*byte)(
unsafe.Pointer(&ii[0])), size, &ret, nil, 0) | 50 e = syscall.WSAIoctl(s, syscall.SIO_GET_INTERFACE_LIST, nil, 0, (*byte)(
unsafe.Pointer(&ii[0])), size, &ret, nil, 0) |
51 » if e != 0 { | 51 » if e != nil { |
52 return nil, os.NewSyscallError("WSAIoctl", e) | 52 return nil, os.NewSyscallError("WSAIoctl", e) |
53 } | 53 } |
54 c := ret / uint32(unsafe.Sizeof(ii[0])) | 54 c := ret / uint32(unsafe.Sizeof(ii[0])) |
55 return ii[:c-1], nil | 55 return ii[:c-1], nil |
56 } | 56 } |
57 | 57 |
58 // If the ifindex is zero, interfaceTable returns mappings of all | 58 // If the ifindex is zero, interfaceTable returns mappings of all |
59 // network interfaces. Otheriwse it returns a mapping of a specific | 59 // network interfaces. Otheriwse it returns a mapping of a specific |
60 // interface. | 60 // interface. |
61 func interfaceTable(ifindex int) ([]Interface, error) { | 61 func interfaceTable(ifindex int) ([]Interface, error) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 149 } |
150 return ifat, nil | 150 return ifat, nil |
151 } | 151 } |
152 | 152 |
153 // If the ifindex is zero, interfaceMulticastAddrTable returns | 153 // If the ifindex is zero, interfaceMulticastAddrTable returns |
154 // addresses for all network interfaces. Otherwise it returns | 154 // addresses for all network interfaces. Otherwise it returns |
155 // addresses for a specific interface. | 155 // addresses for a specific interface. |
156 func interfaceMulticastAddrTable(ifindex int) ([]Addr, error) { | 156 func interfaceMulticastAddrTable(ifindex int) ([]Addr, error) { |
157 return nil, nil | 157 return nil, nil |
158 } | 158 } |
LEFT | RIGHT |