delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-0.3 required=5.0 tests=AWL,BAYES_05,J_CHICKENPOX_54,SARE_MSGID_LONG40,SPF_PASS |
X-Spam-Check-By: | sourceware.org |
MIME-Version: | 1.0 |
In-Reply-To: | <20090612142631.GA14587@calimero.vinschen.de> |
References: | <a9a39a210906120530j7892c00eu526489b97feff150 AT mail DOT gmail DOT com> <20090612142631 DOT GA14587 AT calimero DOT vinschen DOT de> |
Date: | Mon, 15 Jun 2009 11:22:12 +0200 |
Message-ID: | <a9a39a210906150222k5aa69cddg22118d889328c004@mail.gmail.com> |
Subject: | Re: ioctl(sock, SIOCGIFHWADDR, &ifr) fails with 1.7 |
From: | =?UTF-8?B?RnLDqWTDqXJpYyBCcm9u?= <frederic DOT bron AT m4x DOT org> |
To: | cygwin <cygwin AT cygwin DOT com> |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
> To fix your application, call either > > =C2=A0struct ifconf ifc; > =C2=A0ifc.ifc_len =3D sizeof (struct ifreq) * 32; > =C2=A0ifc.ifc_buf =3D malloc (ifc.ifc_len); > =C2=A0if (ioctl (fd, SIOCGIFCONF, &ifc)) > =C2=A0 =C2=A0/* Resize ifc_buf and retry */ > =C2=A0else > =C2=A0 =C2=A0{ > =C2=A0 =C2=A0 =C2=A0struct ifreq *ifr =3D ifc.ifc_req; > =C2=A0 =C2=A0 =C2=A0struct ifreq ifr2; > =C2=A0 =C2=A0 =C2=A0for (int i =3D 0; i < ifc.ifc_len; i +=3D sizeof (str= uct ifreq), ++ifr) > =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!ioctl (fd, SIOCGIFADDR, &ifr2)) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* Print result for that interface */ > =C2=A0 =C2=A0} Thanks, this works half! No need of ifr2, ifr is enough. I saw the name change: 1.5 gives eth0, eth1, eth2, lo and 1.7 gives {821C54BE-...}... However, with that code, I get all network adapters with cygwin 1.5 but only active adpaters with 1.7 (with IP adress !=3D 0). For example if I unplug the ethernet wire, the ip of eth0 becomes 0.0.0.0 with 1.5 and I don't see it anymore with 1.7. How can I get all interfaces with 1.7? Fr=C3=A9d=C3=A9ric -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |