* net.cc (if_nametoindex): Fix typo in call to get_adapters_addresses.
(if_indextoname): Prefer IPv6 loopback device name over IPv4 loopback device name on pre-Vista systems. (if_nameindex): Ditto.
This commit is contained in:
parent
7a2c0a0d6b
commit
bbfcc68ad2
|
@ -1,3 +1,10 @@
|
||||||
|
2008-06-10 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* net.cc (if_nametoindex): Fix typo in call to get_adapters_addresses.
|
||||||
|
(if_indextoname): Prefer IPv6 loopback device name over IPv4 loopback
|
||||||
|
device name on pre-Vista systems.
|
||||||
|
(if_nameindex): Ditto.
|
||||||
|
|
||||||
2008-06-10 Corinna Vinschen <corinna@vinschen.de>
|
2008-06-10 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* fhandler_procnet.cc (format_procnet_ifinet6): Use sprintf rather than
|
* fhandler_procnet.cc (format_procnet_ifinet6): Use sprintf rather than
|
||||||
|
|
|
@ -2037,7 +2037,7 @@ if_nametoindex (const char *name)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (wincap.has_gaa_prefixes ()
|
if (wincap.has_gaa_prefixes ()
|
||||||
&& get_adapters_addresses (&pap, AF_UNSPEC))
|
&& get_adapters_addresses (&pa0, AF_UNSPEC))
|
||||||
{
|
{
|
||||||
char lname[IF_NAMESIZE], *c;
|
char lname[IF_NAMESIZE], *c;
|
||||||
|
|
||||||
|
@ -2072,6 +2072,19 @@ if_indextoname (unsigned ifindex, char *ifname)
|
||||||
for (pap = pa0; pap; pap = pap->Next)
|
for (pap = pa0; pap; pap = pap->Next)
|
||||||
if (ifindex == (pap->Ipv6IfIndex ?: pap->IfIndex))
|
if (ifindex == (pap->Ipv6IfIndex ?: pap->IfIndex))
|
||||||
{
|
{
|
||||||
|
/* Unfortunately the pre-Vista IPv6 stack has a distinct loopback
|
||||||
|
device with the same Ipv6IfIndex as the IfIndex of the IPv4
|
||||||
|
loopback device, but with a different adapter name.
|
||||||
|
For consistency with /proc/net/if_inet6, try to find the
|
||||||
|
IPv6 loopback device and use that adapter name instead.
|
||||||
|
We identify the loopback device by its IfIndex of 1. */
|
||||||
|
if (pap->IfIndex == 1 && pap->Ipv6IfIndex == 0)
|
||||||
|
for (PIP_ADAPTER_ADDRESSES pap2 = pa0; pap2; pap2 = pap2->Next)
|
||||||
|
if (pap2->Ipv6IfIndex == 1)
|
||||||
|
{
|
||||||
|
pap = pap2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
name = strcpy (ifname, pap->AdapterName);
|
name = strcpy (ifname, pap->AdapterName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2114,6 +2127,14 @@ if_nameindex (void)
|
||||||
goto outer_loop;
|
goto outer_loop;
|
||||||
iflist[cnt].if_index = pap->Ipv6IfIndex ?: pap->IfIndex;
|
iflist[cnt].if_index = pap->Ipv6IfIndex ?: pap->IfIndex;
|
||||||
strcpy (iflist[cnt].if_name = ifnamelist[cnt], pap->AdapterName);
|
strcpy (iflist[cnt].if_name = ifnamelist[cnt], pap->AdapterName);
|
||||||
|
/* See comment in if_indextoname. */
|
||||||
|
if (pap->IfIndex == 1 && pap->Ipv6IfIndex == 0)
|
||||||
|
for (PIP_ADAPTER_ADDRESSES pap2 = pa0; pap2; pap2 = pap2->Next)
|
||||||
|
if (pap2->Ipv6IfIndex == 1)
|
||||||
|
{
|
||||||
|
strcpy (ifnamelist[cnt], pap2->AdapterName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
++cnt;
|
++cnt;
|
||||||
outer_loop:
|
outer_loop:
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in New Issue