X-Recipient: archive-cygwin@delorie.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@mail.gmail.com> 	 <20090612142631.GA14587@calimero.vinschen.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.bron@m4x.org>
To: cygwin <cygwin@cygwin.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.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/

