I am trying to use winpcap for an application that is to be used on multiple servers in a production line. One thing that annoys me so far is the Windows 7 device naming convention, which is a long hex string and changes from server to server (i.e. \Device\NPF_{6F2E340D-FD43-4505-81C2-735716D02F15}
(Linux makes this easier with just the eth0, eth1, … convention). Since each server will be using 5 network adapters, I would like to keep from having to keep a configuration file with the device names or keep from changing the source code to accommodate the device name changes. In addition, the cat5 hook up will be going to different devices on separate networks and the port assignments should always stay the same per drawing.
So my question is, is there some easy way to manage these device names under windows, such as being able to easily rename them somehow in the registry? When I looked in the registry, the hex string is shown in many entries and also shows up in folder names, so I was not sure if that would become some hassle to change or not. Or perhaps, is there a way with winpcap to grab the friendly name of a device that one can set via the network connections page and get the hex device name result that way (similar to findalldev_ex()). Any other suggestions are also welcome.
PS: I know I can use bind() to bind to ip and ports or use winsock etc, but the application and hardware interfacing to other devices is complicated due to multiple network adapters needing to have the same IP address and that conflicts in windows, hence the winpcap option in promiscuous mode creating all raw messages.
Best Answer
How do I get a network connection's "Connection Name"?
On Windows
getmac
can be used to retrieve both the "Connection Name" (friendly name) and the "Transport Name" (GUID).Example output:
How do I rename a connection?
netsh
can be used to rename a network connection.How can I automate all of this?
You can use the above commands in a batch file when installing your product to automatically create a custom local configuration file.
Further Reading