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: <20090612142631 DOT GA14587 AT calimero DOT vinschen DOT de> Date: Mon, 15 Jun 2009 11:22:12 +0200 Message-ID: Subject: Re: ioctl(sock, SIOCGIFHWADDR, &ifr) fails with 1.7 From: =?UTF-8?B?RnLDqWTDqXJpYyBCcm9u?= To: cygwin Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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/