From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 2AFF03850213; Wed, 3 Aug 2022 14:06:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2AFF03850213 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 57c3ca8d51cdf1e9fcf10588c9519fb7b9dcf7e1 X-Git-Newrev: fee7b24bebd9474bda7730101d85e59cd11302b2 Message-Id: <20220803140610.2AFF03850213@sourceware.org> Date: Wed, 3 Aug 2022 14:06:10 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Aug 2022 14:06:10 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dfee7b24bebd= 9474bda7730101d85e59cd11302b2 commit fee7b24bebd9474bda7730101d85e59cd11302b2 Author: Corinna Vinschen Date: Wed Aug 3 15:57:30 2022 +0200 Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ =20 Signed-off-by: Corinna Vinschen 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_sock= et.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 =3D ifcp->ifc_len / sizeof (struct __old_ifreq) - * sizeof (struct ifreq); - ifc.ifc_buf =3D (caddr_t) alloca (ifc.ifc_len); - } - else - { - ifc.ifc_len =3D ifcp->ifc_len; - ifc.ifc_buf =3D ifcp->ifc_buf; - } + ifc.ifc_len =3D ifcp->ifc_len; + ifc.ifc_buf =3D ifcp->ifc_buf; res =3D get_ifconf (&ifc, cmd); if (res) debug_printf ("error in get_ifconf"); - if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ) - { - struct __old_ifreq *ifr =3D (struct __old_ifreq *) ifcp->ifc_buf; - for (ifrp =3D 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] =3D '\0'; - memcpy (&ifr->ifr_ifru, &ifrp->ifr_ifru, sizeof ifr->ifr_ifru); - } - ifcp->ifc_len =3D ifc.ifc_len / sizeof (struct ifreq) - * sizeof (struct __old_ifreq); - } - else - ifcp->ifc_len =3D ifc.ifc_len; + ifcp->ifc_len =3D ifc.ifc_len; break; case OLD_SIOCGIFFLAGS: case OLD_SIOCGIFADDR: @@ -159,12 +135,6 @@ fhandler_socket::ioctl (unsigned int cmd, void *p) return -1; } =20 - 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 =3D 64 * sizeof (struct ifreq); ifc.ifc_buf =3D (caddr_t) alloca (ifc.ifc_len); if (cmd =3D=3D SIOCGIFFRNDLYNAM) @@ -182,45 +152,26 @@ fhandler_socket::ioctl (unsigned int cmd, void *p) break; } =20 - if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ) + struct ifreq *ifr =3D (struct ifreq *) p; + debug_printf (" name: %s", ifr->ifr_name); + for (ifrp =3D ifc.ifc_req; + (caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len; + ++ifrp) { - struct __old_ifreq *ifr =3D (struct __old_ifreq *) p; - debug_printf (" name: %s", ifr->ifr_name); - for (ifrp =3D 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 =3D (struct ifreq *) p; - debug_printf (" name: %s", ifr->ifr_name); - for (ifrp =3D 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 =3D=3D 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 =3D=3D 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 >=3D 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) =20 -#define CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ \ - (CYGWIN_VERSION_USER_API_VERSION_COMBINED <=3D 161) - #define CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE \ (CYGWIN_VERSION_USER_API_VERSION_COMBINED <=3D 209) =20 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] =3D pap->PhysicalAddress[i]; } =20 -/* - * 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 =3D "tok"; - break; - case IF_TYPE_PPP: - prefix =3D "ppp"; - break; - case IF_TYPE_SOFTWARE_LOOPBACK: - prefix =3D "lo"; - break; - case IF_TYPE_ATM: - prefix =3D "atm"; - break; - case IF_TYPE_IEEE80211: - prefix =3D "wlan"; - break; - case IF_TYPE_SLIP: - case IF_TYPE_RS232: - case IF_TYPE_MODEM: - prefix =3D "slp"; - break; - case IF_TYPE_TUNNEL: - prefix =3D "tun"; - break; - default: - prefix =3D "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 =3D (struct ifaddrs *) &ifp[1].ifa_ifa; /* Interface name */ =20 - 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 =3D (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 =3D=3D AF_INET && idx) + if (sa->sa_family =3D=3D AF_INET && idx) __small_sprintf (ifp->ifa_name, "%s:%u", pap->AdapterName, idx); else strcpy (ifp->ifa_name, pap->AdapterName);