* net.cc (get_xp_ifs): Fix counting of idx to return stable interface

alias names for interfaces with multiple IPv4 addresses.
This commit is contained in:
Corinna Vinschen 2010-12-02 11:39:15 +00:00
parent 910e31f015
commit bdcc0b84ed
2 changed files with 9 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2010-12-02 Corinna Vinschen <corinna@vinschen.de>
* net.cc (get_xp_ifs): Fix counting of idx to return stable interface
alias names for interfaces with multiple IPv4 addresses.
2010-11-29 Corinna Vinschen <corinna@vinschen.de>
* fhandler_tty.cc (fhandler_tty_slave::dup): Free path_conv strings

View File

@ -1907,8 +1907,7 @@ get_xp_ifs (ULONG family)
++ifp;
}
else
for (idx = 0, pua = pap->FirstUnicastAddress; pua;
++idx, pua = pua->Next)
for (idx = 0, pua = pap->FirstUnicastAddress; pua; pua = pua->Next)
{
struct sockaddr *sa = (struct sockaddr *) pua->Address.lpSockaddr;
# define sin ((struct sockaddr_in *) sa)
@ -1918,10 +1917,12 @@ get_xp_ifs (ULONG family)
/* Next in chain */
ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa;
/* Interface name */
if (idx && sa->sa_family == AF_INET)
if (sa->sa_family == AF_INET && idx)
__small_sprintf (ifp->ifa_name, "%s:%u", pap->AdapterName, idx);
else
strcpy (ifp->ifa_name, pap->AdapterName);
if (sa->sa_family == AF_INET)
++idx;
ifp->ifa_ifa.ifa_name = ifp->ifa_name;
/* Flags */
ifp->ifa_ifa.ifa_flags = get_flags (pap);