public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ
@ 2022-08-03 14:06 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2022-08-03 14:06 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=fee7b24bebd9474bda7730101d85e59cd11302b2
commit fee7b24bebd9474bda7730101d85e59cd11302b2
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Wed Aug 3 15:57:30 2022 +0200
Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/fhandler_socket.cc | 87 ++++++++--------------------------
winsup/cygwin/include/cygwin/version.h | 3 --
winsup/cygwin/net.cc | 53 +--------------------
3 files changed, 21 insertions(+), 122 deletions(-)
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 49ad5b3e0..f7c5ff629 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -100,36 +100,12 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
set_errno (EINVAL);
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_buf = ifcp->ifc_buf;
- }
+ ifc.ifc_len = ifcp->ifc_len;
+ ifc.ifc_buf = ifcp->ifc_buf;
res = get_ifconf (&ifc, cmd);
if (res)
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;
case OLD_SIOCGIFFLAGS:
case OLD_SIOCGIFADDR:
@@ -159,12 +135,6 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
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_buf = (caddr_t) alloca (ifc.ifc_len);
if (cmd == SIOCGIFFRNDLYNAM)
@@ -182,45 +152,26 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
break;
}
- if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
+ struct ifreq *ifr = (struct ifreq *) p;
+ debug_printf (" name: %s", ifr->ifr_name);
+ for (ifrp = ifc.ifc_req;
+ (caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len;
+ ++ifrp)
{
- 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))
{
- 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;
- 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))
- {
- if (cmd == SIOCGIFFRNDLYNAM)
- /* The application has to care for the space. */
- memcpy (ifr->ifr_frndlyname, ifrp->ifr_frndlyname,
- sizeof (struct ifreq_frndlyname));
- else
- memcpy (&ifr->ifr_ifru, &ifrp->ifr_ifru,
- sizeof ifr->ifr_ifru);
- break;
- }
+ if (cmd == SIOCGIFFRNDLYNAM)
+ /* The application has to care for the space. */
+ memcpy (ifr->ifr_frndlyname, ifrp->ifr_frndlyname,
+ sizeof (struct ifreq_frndlyname));
+ else
+ memcpy (&ifr->ifr_ifru, &ifrp->ifr_ifru,
+ sizeof ifr->ifr_ifru);
+ break;
}
}
+
if ((caddr_t) ifrp >= ifc.ifc_buf + ifc.ifc_len)
{
set_errno (EINVAL);
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 83f8c34f6..4aea37a79 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -34,9 +34,6 @@ details. */
#define CYGWIN_VERSION_USER_API_VERSION_COMBINED \
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 \
(CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 209)
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index e6c5eadf2..62c7cf807 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -1673,51 +1673,6 @@ get_hwaddr (struct ifall *ifp, PIP_ADAPTER_ADDRESSES pap)
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.
*/
@@ -1760,9 +1715,7 @@ get_ifs (ULONG family)
ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa;
/* Interface name */
- if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
- gen_old_if_name (ifp->ifa_name, pap, idx);
- else if (idx)
+ if (idx)
__small_sprintf (ifp->ifa_name, "%s:%u", pap->AdapterName, idx);
else
strcpy (ifp->ifa_name, pap->AdapterName);
@@ -1808,9 +1761,7 @@ get_ifs (ULONG family)
/* Next in chain */
ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa;
/* Interface name */
- if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
- gen_old_if_name (ifp->ifa_name, pap, idx);
- else if (sa->sa_family == AF_INET && idx)
+ if (sa->sa_family == AF_INET && idx)
__small_sprintf (ifp->ifa_name, "%s:%u", pap->AdapterName, idx);
else
strcpy (ifp->ifa_name, pap->AdapterName);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-03 14:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-03 14:06 [newlib-cygwin] Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).