Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
57c3ca8d51
commit
fee7b24beb
|
@ -100,35 +100,11 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
|
|
||||||
{
|
|
||||||
ifc.ifc_len = ifcp->ifc_len / sizeof (struct __old_ifreq)
|
|
||||||
* sizeof (struct ifreq);
|
|
||||||
ifc.ifc_buf = (caddr_t) alloca (ifc.ifc_len);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ifc.ifc_len = ifcp->ifc_len;
|
ifc.ifc_len = ifcp->ifc_len;
|
||||||
ifc.ifc_buf = ifcp->ifc_buf;
|
ifc.ifc_buf = ifcp->ifc_buf;
|
||||||
}
|
|
||||||
res = get_ifconf (&ifc, cmd);
|
res = get_ifconf (&ifc, cmd);
|
||||||
if (res)
|
if (res)
|
||||||
debug_printf ("error in get_ifconf");
|
debug_printf ("error in get_ifconf");
|
||||||
if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
|
|
||||||
{
|
|
||||||
struct __old_ifreq *ifr = (struct __old_ifreq *) ifcp->ifc_buf;
|
|
||||||
for (ifrp = ifc.ifc_req;
|
|
||||||
(caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len;
|
|
||||||
++ifrp, ++ifr)
|
|
||||||
{
|
|
||||||
memcpy (&ifr->ifr_ifrn, &ifrp->ifr_ifrn, sizeof ifr->ifr_ifrn);
|
|
||||||
ifr->ifr_name[__OLD_IFNAMSIZ - 1] = '\0';
|
|
||||||
memcpy (&ifr->ifr_ifru, &ifrp->ifr_ifru, sizeof ifr->ifr_ifru);
|
|
||||||
}
|
|
||||||
ifcp->ifc_len = ifc.ifc_len / sizeof (struct ifreq)
|
|
||||||
* sizeof (struct __old_ifreq);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ifcp->ifc_len = ifc.ifc_len;
|
ifcp->ifc_len = ifc.ifc_len;
|
||||||
break;
|
break;
|
||||||
case OLD_SIOCGIFFLAGS:
|
case OLD_SIOCGIFFLAGS:
|
||||||
|
@ -159,12 +135,6 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd > SIOCGIFINDEX && CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
|
|
||||||
{
|
|
||||||
debug_printf ("cmd not supported on this platform");
|
|
||||||
set_errno (EINVAL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ifc.ifc_len = 64 * sizeof (struct ifreq);
|
ifc.ifc_len = 64 * sizeof (struct ifreq);
|
||||||
ifc.ifc_buf = (caddr_t) alloca (ifc.ifc_len);
|
ifc.ifc_buf = (caddr_t) alloca (ifc.ifc_len);
|
||||||
if (cmd == SIOCGIFFRNDLYNAM)
|
if (cmd == SIOCGIFFRNDLYNAM)
|
||||||
|
@ -182,25 +152,6 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
|
|
||||||
{
|
|
||||||
struct __old_ifreq *ifr = (struct __old_ifreq *) p;
|
|
||||||
debug_printf (" name: %s", ifr->ifr_name);
|
|
||||||
for (ifrp = ifc.ifc_req;
|
|
||||||
(caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len;
|
|
||||||
++ifrp)
|
|
||||||
{
|
|
||||||
debug_printf ("testname: %s", ifrp->ifr_name);
|
|
||||||
if (! strcmp (ifrp->ifr_name, ifr->ifr_name))
|
|
||||||
{
|
|
||||||
memcpy (&ifr->ifr_ifru, &ifrp->ifr_ifru,
|
|
||||||
sizeof ifr->ifr_ifru);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct ifreq *ifr = (struct ifreq *) p;
|
struct ifreq *ifr = (struct ifreq *) p;
|
||||||
debug_printf (" name: %s", ifr->ifr_name);
|
debug_printf (" name: %s", ifr->ifr_name);
|
||||||
for (ifrp = ifc.ifc_req;
|
for (ifrp = ifc.ifc_req;
|
||||||
|
@ -220,7 +171,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ((caddr_t) ifrp >= ifc.ifc_buf + ifc.ifc_len)
|
if ((caddr_t) ifrp >= ifc.ifc_buf + ifc.ifc_len)
|
||||||
{
|
{
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
|
|
|
@ -34,9 +34,6 @@ details. */
|
||||||
#define CYGWIN_VERSION_USER_API_VERSION_COMBINED \
|
#define CYGWIN_VERSION_USER_API_VERSION_COMBINED \
|
||||||
CYGWIN_VERSION_PER_PROCESS_API_VERSION_COMBINED (user_data)
|
CYGWIN_VERSION_PER_PROCESS_API_VERSION_COMBINED (user_data)
|
||||||
|
|
||||||
#define CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ \
|
|
||||||
(CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 161)
|
|
||||||
|
|
||||||
#define CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE \
|
#define CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE \
|
||||||
(CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 209)
|
(CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 209)
|
||||||
|
|
||||||
|
|
|
@ -1673,51 +1673,6 @@ get_hwaddr (struct ifall *ifp, PIP_ADAPTER_ADDRESSES pap)
|
||||||
ifp->ifa_hwdata.ifa_hwaddr.sa_data[i] = pap->PhysicalAddress[i];
|
ifp->ifa_hwdata.ifa_hwaddr.sa_data[i] = pap->PhysicalAddress[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Generate short, unique interface name for usage with aged
|
|
||||||
* applications still using the old pre-1.7 ifreq structure.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
gen_old_if_name (char *name, PIP_ADAPTER_ADDRESSES pap, DWORD idx)
|
|
||||||
{
|
|
||||||
/* Note: The returned name must be < 16 chars. */
|
|
||||||
const char *prefix;
|
|
||||||
|
|
||||||
switch (pap->IfType)
|
|
||||||
{
|
|
||||||
case IF_TYPE_ISO88025_TOKENRING:
|
|
||||||
prefix = "tok";
|
|
||||||
break;
|
|
||||||
case IF_TYPE_PPP:
|
|
||||||
prefix = "ppp";
|
|
||||||
break;
|
|
||||||
case IF_TYPE_SOFTWARE_LOOPBACK:
|
|
||||||
prefix = "lo";
|
|
||||||
break;
|
|
||||||
case IF_TYPE_ATM:
|
|
||||||
prefix = "atm";
|
|
||||||
break;
|
|
||||||
case IF_TYPE_IEEE80211:
|
|
||||||
prefix = "wlan";
|
|
||||||
break;
|
|
||||||
case IF_TYPE_SLIP:
|
|
||||||
case IF_TYPE_RS232:
|
|
||||||
case IF_TYPE_MODEM:
|
|
||||||
prefix = "slp";
|
|
||||||
break;
|
|
||||||
case IF_TYPE_TUNNEL:
|
|
||||||
prefix = "tun";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
prefix = "eth";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (idx)
|
|
||||||
__small_sprintf (name, "%s%u:%u", prefix, pap->IfIndex, idx);
|
|
||||||
else
|
|
||||||
__small_sprintf (name, "%s%u", prefix, pap->IfIndex, idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get network interfaces. Use IP Helper function GetAdaptersAddresses.
|
* Get network interfaces. Use IP Helper function GetAdaptersAddresses.
|
||||||
*/
|
*/
|
||||||
|
@ -1760,9 +1715,7 @@ get_ifs (ULONG family)
|
||||||
ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa;
|
ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa;
|
||||||
/* Interface name */
|
/* Interface name */
|
||||||
|
|
||||||
if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
|
if (idx)
|
||||||
gen_old_if_name (ifp->ifa_name, pap, idx);
|
|
||||||
else if (idx)
|
|
||||||
__small_sprintf (ifp->ifa_name, "%s:%u", pap->AdapterName, idx);
|
__small_sprintf (ifp->ifa_name, "%s:%u", pap->AdapterName, idx);
|
||||||
else
|
else
|
||||||
strcpy (ifp->ifa_name, pap->AdapterName);
|
strcpy (ifp->ifa_name, pap->AdapterName);
|
||||||
|
@ -1808,9 +1761,7 @@ get_ifs (ULONG family)
|
||||||
/* Next in chain */
|
/* Next in chain */
|
||||||
ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa;
|
ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa;
|
||||||
/* Interface name */
|
/* Interface name */
|
||||||
if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
|
if (sa->sa_family == AF_INET && idx)
|
||||||
gen_old_if_name (ifp->ifa_name, pap, idx);
|
|
||||||
else if (sa->sa_family == AF_INET && idx)
|
|
||||||
__small_sprintf (ifp->ifa_name, "%s:%u", pap->AdapterName, idx);
|
__small_sprintf (ifp->ifa_name, "%s:%u", pap->AdapterName, idx);
|
||||||
else
|
else
|
||||||
strcpy (ifp->ifa_name, pap->AdapterName);
|
strcpy (ifp->ifa_name, pap->AdapterName);
|
||||||
|
|
Loading…
Reference in New Issue