This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: ioctl(sock, SIOCGIFHWADDR, &ifr) fails with 1.7
> 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?
FrÃdÃric
--
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/