ioctl(sock, SIOCGIFHWADDR, &ifr) fails with 1.7

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Jun 15 14:35:00 GMT 2009


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.


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/



More information about the Cygwin mailing list