winsock and virtual interfaces

Juan Lang juan_lang at
Sat May 3 09:04:08 CDT 2003

I'm planning to patch winsock (both ws2_32 and wsock32
varieties) so that virtual interfaces will be included
in response to IP address/interface list queries.  If
you'd like different behavior, please speak up (though
it's up to Alexandre anyway :) )

More detail:  I'm patching wsock32 and winsock to use
iphlpapi.dll to enumerate interfaces, get the route
table, and that sort of thing.  Less code duplication,
and I'm trying to isolate the plaform-specific network
code to fewer files.  (If any of you saw my earlier
call for help, the stack corruption was due to
socket() mismatching.)

Yet more detail:
In writing iphlpapi.dll, I was curious about the code
in wsock32 and winsock that tries to filter out
virtual interface names (in
WSAIOCTL_GetInterfaceName()).  So, I tested a little
bit with my Linux system, and it seems this code does
not behave as desired:

On my system, virtual interfaces don't show up in
/proc/net/dev, so the filtering for them seems a
little pointless.  But if they did show up, the
filtering seems counterproductive:

Say you had three interfaces, lo, eth0, and eth0:0. 
You'd be told (by WSAIOCTL_GetInterfaceCount()) that
you have three interfaces, but if you got the names of
them, you'd only get two unique names.  Furthermore,
since the filtered name is what's used for getting the
IP address, MAC address, and whatnot, in fact you'd
end up with duplicate entries in responses to queries.

I've attached my little test program; try it with and
without virtual interfaces to see what I mean.

I also tested how Win2K behaves with multiple IP
addresses on an interface.  In IP address tables,
there's one entry per IP address, as expected.  In
GetAdaptersInfo, the IP address list has every
configured address for the adapter, also I suppose as
expected.  So, in Win2K, an interface (uniquely
identified by an index) can have 0..N IP addresses. 
I've attached some output from a test program on Win2K
to illustrate.

I don't emulate this behavior.  Instead, I let an
interface have 0 or 1 IP address, and treat virtual
interfaces as unique interfaces, with their own index.
 This makes the code rather simpler.  If anyone has a
strong opinion otherwise, please speak up.

(Patches coming this week.  iphlpapi.dll is working,
and wsock32 is using it to implement WsControl now.  I
want to change iphlpapi a little bit to make it more
appropriate for netapi32 before I submit.)


Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
-------------- next part --------------
GetIpAddrTable returned 3 entries:
GetIpAddrTable entry for adapter index 16777219:
ip mask broadcast reasm size 65535
GetIpAddrTable entry for adapter index 16777219:
ip mask broadcast reasm size 65535
GetIpAddrTable entry for adapter index 1:
ip mask broadcast reasm size 65535

GetIfEntry returned 2 entries:
GetIfEntry for adapter index 16777219:
name: description: Wireless-G Notebook Adapter
Type: ethernet
physical address: 00:06:25:3d:b5:58
GetIfEntry for adapter index 1:
name: description: MS TCP Loopback interface
Type: loopback
physical address: 

See 1 adapters in IP_INTERFACE_INFO
Adapter 16777219's name is \DEVICE\TCPIP_{66B081D9-F4E3-4FE8-85CC-0934F6134D44}

GetAdaptersInfo output:
Name: {66B081D9-F4E3-4FE8-85CC-0934F6134D44}
Description: Wireless-G Notebook Adapter
MAC addr: 00:06:25:3d:b5:58
Index: 16777219
Type: ethernet
IP addresses:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: enumtest.c.gz
Type: application/x-gzip
Size: 1724 bytes
Desc: enumtest.c.gz
Url :

More information about the wine-devel mailing list