New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: get npcap usable windows network device names #35095
Comments
Current implementation of net package have some differences for Name field. Linux, BSD, AIX: interface name like "eth0" On Windows, the path prefiexed with To get device volume, you need to call SetupDiGetDeviceInterfaceDetail. I suggest to add new field Device to be set identity of the interface. |
FWIW, I'll probably upstream WireGuard's Windows networking wrappers to x/sys or x/net somewhat soon. It does all the things: https://godoc.org/golang.zx2c4.com/wireguard/windows/tunnel/winipcfg |
I like this idea. If .Name was meant to be a friendly/display name, a separate .Device value that would give us what we tend to need to "act on" a device would be great. It would be good to not have to start writing "am I running in Windows" code, and there is no doubt code in production that is using this to display device names. This is a good common ground approach. |
Libpcap's On most UN*Xes, the description is usually non-existent. On Windows, it's either a hardware description or something extraordinarily useful and precisely descriptive such as "Microsoft". That needs to be redone. Wireshark works around this by using, for its description, a string intended for human consumption, fetched by various platform-dependent mechanisms. On Windows, it fetches the "friendly name", which might be "Local Area Connection 17" or might be "Ethernet0" or whatever. See capture/capture_win_ifnames.c in the Wireshark for an example of how to fetch the "friendly name" for an interface, given its GUID (which is the ugly blob in the It would probably be wisest to name (For extra credit, get friendly names on macOS using the code in |
net.Interfaces(), net.InterfaceByName(), and net.InterfaceByIndex() return an Interface struct with a Name variable. On Linux, this will tend to be the name (eth0, wlan0, en0, etc) that can be passed to pcap functions/methods (eg. "github.com/google/gopacket/pcap".OpenLive() )
However, that isn't the case on Windows 10.
On my box net.InterfaceByIndex(5), for example returns a Interface.Name "Ethernet" and what I need for pcap.OpenLive() is "\Device\NPF_{13044533-0543-4AF5-9E3C-85EBBC7C04BB}"
gopacket and gopacket/pcap are really promising. ~as simple as scappy, and ~as fast as c, and I can write it once and run it on Windows and Linux. Except, not quite yet.
The text was updated successfully, but these errors were encountered: