X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Mon, 15 Jun 2009 22:13:59 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: ioctl(sock, SIOCGIFHWADDR, &ifr) fails with 1.7 Message-ID: <20090615201359.GX5039@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <20090612142631 DOT GA14587 AT calimero DOT vinschen DOT de> <20090615114256 DOT GR5039 AT calimero DOT vinschen DOT de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20090615114256.GR5039@calimero.vinschen.de> User-Agent: Mutt/1.5.19 (2009-02-20) 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 On Jun 15 13:42, Corinna Vinschen wrote: > On Jun 15 11:22, Fr?d?ric Bron wrote: > > > To fix your application, call either > > > > > >  struct ifconf ifc; > > >  ifc.ifc_len = sizeof (struct ifreq) * 32; > > >  ifc.ifc_buf = malloc (ifc.ifc_len); > > >  if (ioctl (fd, SIOCGIFCONF, &ifc)) > > >    /* Resize ifc_buf and retry */ > > >  else > > >    { > > >      struct ifreq *ifr = ifc.ifc_req; > > >      struct ifreq ifr2; > > >      for (int i = 0; i < ifc.ifc_len; i += sizeof (struct ifreq), ++ifr) > > >        if (!ioctl (fd, SIOCGIFADDR, &ifr2)) > > >          /* Print result for that interface */ > > >    } > > > > 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 != 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? > > I just debugged this and the answer is, right now you can't. I'm > going to fix that at one point, but I have other stuff to do first. I applied a patch to Cygwin which also reports the IPv4 addresses of disconnected interfaces, fetching the info from the registry. It's a pity that Windows doesn't correctly report these addresses in the official API. This won't work for IPv6 and IPv6-only interfaces. I didn't find a generic way to list IPv6 addresses except for using the official API. Since Windows Vista the IPv6 address information isn't stored in the registry at all, at least not in a publically available, easy to read place. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- 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/