* net.cc (get_2k_ifconf): Change multiple IP address naming scheme
to Linux style. Patch by Alexander Gottwald <ago@informatik.tu-chemnitz.de>: * net.cc (get_2k_ifconf): Added support for multiple IP addresses on one interface.
This commit is contained in:
parent
8b6234ca12
commit
c270dc2555
@ -1,3 +1,13 @@
|
|||||||
|
2001-10-22 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* net.cc (get_2k_ifconf): Change multiple IP address naming scheme
|
||||||
|
to Linux style.
|
||||||
|
|
||||||
|
Sun Oct 21 19:04:37 2001 Alexander Gottwald <ago@informatik.tu-chemnitz.de>
|
||||||
|
|
||||||
|
* net.cc (get_2k_ifconf): Added support for multiple IP addresses on
|
||||||
|
one interface.
|
||||||
|
|
||||||
2001-10-22 Corinna Vinschen <corinna@vinschen.de>
|
2001-10-22 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* miscfuncs.cc (__check_invalid_read_ptr_errno): Return error, if any.
|
* miscfuncs.cc (__check_invalid_read_ptr_errno): Return error, if any.
|
||||||
|
@ -1551,7 +1551,7 @@ static void
|
|||||||
get_2k_ifconf (struct ifconf *ifc, int what)
|
get_2k_ifconf (struct ifconf *ifc, int what)
|
||||||
{
|
{
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
char eth[2] = "/", ppp[2] = "/", slp[2] = "/";
|
char eth[2] = "/", ppp[2] = "/", slp[2] = "/", sub[2] = "0";
|
||||||
|
|
||||||
/* Union maps buffer to correct struct */
|
/* Union maps buffer to correct struct */
|
||||||
struct ifreq *ifr = ifc->ifc_req;
|
struct ifreq *ifr = ifc->ifc_req;
|
||||||
@ -1571,84 +1571,98 @@ get_2k_ifconf (struct ifconf *ifc, int what)
|
|||||||
!GetIfTable(ift, &siz_if_table, TRUE) &&
|
!GetIfTable(ift, &siz_if_table, TRUE) &&
|
||||||
!GetIpAddrTable(ipt, &siz_ip_table, TRUE))
|
!GetIpAddrTable(ipt, &siz_ip_table, TRUE))
|
||||||
{
|
{
|
||||||
|
/* Iterate over all known interfaces */
|
||||||
for (if_cnt = 0; if_cnt < ift->dwNumEntries; ++if_cnt)
|
for (if_cnt = 0; if_cnt < ift->dwNumEntries; ++if_cnt)
|
||||||
{
|
{
|
||||||
switch (ift->table[if_cnt].dwType)
|
*sub = '0';
|
||||||
|
/* Iterate over all configured IP-addresses */
|
||||||
|
for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
|
||||||
{
|
{
|
||||||
case MIB_IF_TYPE_ETHERNET:
|
/* Does the IP address belong to the interface? */
|
||||||
++*eth;
|
if (ipt->table[ip_cnt].dwIndex == ift->table[if_cnt].dwIndex)
|
||||||
strcpy (ifr->ifr_name, "eth");
|
{
|
||||||
strcat (ifr->ifr_name, eth);
|
/* Setup the interface name */
|
||||||
break;
|
switch (ift->table[if_cnt].dwType)
|
||||||
case MIB_IF_TYPE_PPP:
|
{
|
||||||
++*ppp;
|
case MIB_IF_TYPE_ETHERNET:
|
||||||
strcpy (ifr->ifr_name, "ppp");
|
if (*sub == '0')
|
||||||
strcat (ifr->ifr_name, ppp);
|
++*eth;
|
||||||
break;
|
strcpy (ifr->ifr_name, "eth");
|
||||||
case MIB_IF_TYPE_SLIP:
|
strcat (ifr->ifr_name, eth);
|
||||||
++*slp;
|
break;
|
||||||
strcpy (ifr->ifr_name, "slp");
|
case MIB_IF_TYPE_PPP:
|
||||||
strcat (ifr->ifr_name, slp);
|
++*ppp;
|
||||||
break;
|
strcpy (ifr->ifr_name, "ppp");
|
||||||
case MIB_IF_TYPE_LOOPBACK:
|
strcat (ifr->ifr_name, ppp);
|
||||||
strcpy (ifr->ifr_name, "lo");
|
break;
|
||||||
break;
|
case MIB_IF_TYPE_SLIP:
|
||||||
default:
|
++*slp;
|
||||||
continue;
|
strcpy (ifr->ifr_name, "slp");
|
||||||
}
|
strcat (ifr->ifr_name, slp);
|
||||||
for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
|
break;
|
||||||
if (ipt->table[ip_cnt].dwIndex == ift->table[if_cnt].dwIndex)
|
case MIB_IF_TYPE_LOOPBACK:
|
||||||
{
|
strcpy (ifr->ifr_name, "lo");
|
||||||
switch (what)
|
break;
|
||||||
{
|
default:
|
||||||
case SIOCGIFCONF:
|
continue;
|
||||||
case SIOCGIFADDR:
|
}
|
||||||
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
if (*sub > '0')
|
||||||
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwAddr;
|
{
|
||||||
sa->sin_family = AF_INET;
|
strcat (ifr->ifr_name, ":");
|
||||||
sa->sin_port = 0;
|
strcat (ifr->ifr_name, sub);
|
||||||
break;
|
}
|
||||||
case SIOCGIFBRDADDR:
|
++*sub;
|
||||||
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
/* setup sockaddr struct */
|
||||||
|
switch (what)
|
||||||
|
{
|
||||||
|
case SIOCGIFCONF:
|
||||||
|
case SIOCGIFADDR:
|
||||||
|
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
||||||
|
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwAddr;
|
||||||
|
sa->sin_family = AF_INET;
|
||||||
|
sa->sin_port = 0;
|
||||||
|
break;
|
||||||
|
case SIOCGIFBRDADDR:
|
||||||
|
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
||||||
#if 0
|
#if 0
|
||||||
/* Unfortunately, the field returns only crap. */
|
/* Unfortunately, the field returns only crap. */
|
||||||
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwBCastAddr;
|
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwBCastAddr;
|
||||||
#else
|
#else
|
||||||
lip = ipt->table[ip_cnt].dwAddr;
|
lip = ipt->table[ip_cnt].dwAddr;
|
||||||
lnp = ipt->table[ip_cnt].dwMask;
|
lnp = ipt->table[ip_cnt].dwMask;
|
||||||
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
||||||
sa->sin_family = AF_INET;
|
sa->sin_family = AF_INET;
|
||||||
sa->sin_port = 0;
|
sa->sin_port = 0;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case SIOCGIFNETMASK:
|
case SIOCGIFNETMASK:
|
||||||
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
||||||
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwMask;
|
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwMask;
|
||||||
sa->sin_family = AF_INET;
|
sa->sin_family = AF_INET;
|
||||||
sa->sin_port = 0;
|
sa->sin_port = 0;
|
||||||
break;
|
break;
|
||||||
case SIOCGIFHWADDR:
|
case SIOCGIFHWADDR:
|
||||||
so = &ifr->ifr_hwaddr;
|
so = &ifr->ifr_hwaddr;
|
||||||
for (UINT i = 0; i < IFHWADDRLEN; ++i)
|
for (UINT i = 0; i < IFHWADDRLEN; ++i)
|
||||||
if (i >= ift->table[if_cnt].dwPhysAddrLen)
|
if (i >= ift->table[if_cnt].dwPhysAddrLen)
|
||||||
so->sa_data[i] = '\0';
|
so->sa_data[i] = '\0';
|
||||||
else
|
else
|
||||||
so->sa_data[i] = ift->table[if_cnt].bPhysAddr[i];
|
so->sa_data[i] = ift->table[if_cnt].bPhysAddr[i];
|
||||||
so->sa_family = AF_INET;
|
so->sa_family = AF_INET;
|
||||||
break;
|
break;
|
||||||
case SIOCGIFMETRIC:
|
case SIOCGIFMETRIC:
|
||||||
ifr->ifr_metric = 1;
|
ifr->ifr_metric = 1;
|
||||||
break;
|
break;
|
||||||
case SIOCGIFMTU:
|
case SIOCGIFMTU:
|
||||||
ifr->ifr_mtu = ift->table[if_cnt].dwMtu;
|
ifr->ifr_mtu = ift->table[if_cnt].dwMtu;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++cnt;
|
++cnt;
|
||||||
if ((caddr_t) ++ifr >
|
if ((caddr_t) ++ifr >
|
||||||
ifc->ifc_buf + ifc->ifc_len - sizeof (struct ifreq))
|
ifc->ifc_buf + ifc->ifc_len - sizeof (struct ifreq))
|
||||||
goto done;
|
goto done;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user