delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/12/02/06:41:01

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Thu, 2 Dec 2010 12:40:36 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Difference in behaviour between getifaddrs() and ioctl(SIOCGIFCONF)
Message-ID: <20101202114036.GG30913@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <id6eq6$un5$1 AT dough DOT gmane DOT org>
MIME-Version: 1.0
In-Reply-To: <id6eq6$un5$1@dough.gmane.org>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 Dec  1 22:30, Jason Curl wrote:
> Hello,
> 
> I've seen an issue when using getifaddrs() using Cygwin 1.7.x
> (snapshot build from 2010-11-24, shortly after the ARP fixes from
> Corinna). Operating System is Windows 7 x64_86 Ultimate.
> 
> When I use getifaddrs() I get a list of interface names, some are
> appended with ":1".

When you use ioctl(SIOCGIFCONF), Cygwin asks the OS only for the AF_INET
addresses of an interface.  When you use getifaddrs(), it asks for
AF_INET and AF_INET6 addresses.  What you get is a list of per-interface
addresses.  If the address is AF_INET, and if it's not the first address
in the list, it gets an additional index value attached, just like the
interface alias name in Linux, if you assign multiple IPv4 addresses to
an interface.

> Getting the list with ioctl(SIOCGIFCONF) provides a different list
> of names, where interface names only differ sometimes by ":1".
> 
> The list from ioctl() is correct, that from getifaddrs() is
> incorrect, in that the name cannot be used to resolve the HWADDR,
> SIOCGIFFRNDLYNAM with ioctl().
> 
> Using getifaddrs():
> device: {4ED54D4E-1024-4BDF-A926-67D2895D2DC4};
> ioctl(SIOCGIFFRNDLYNAM)=0 Local Area Connection 4
> device: {A045DC0F-A979-49B3-954C-D0678365FF26}:1; ioctl(SIOCGIFFRNDLYNAM)=-1
> device: {4EB69B61-C791-434A-8FCE-8F4859EA8DFC};
> ioctl(SIOCGIFFRNDLYNAM)=0 Local Area Connection 3
> device: {85C2CEC7-A2B9-47D4-9A50-D63E9F9ED007};
> ioctl(SIOCGIFFRNDLYNAM)=0 Bluetooth Network Connection
> device: {56D2E68A-4173-4117-A719-65123B973C65}:1; ioctl(SIOCGIFFRNDLYNAM)=-1
> device: {7E5203E8-97DE-4822-9A2E-380BD258D97E}:1; ioctl(SIOCGIFFRNDLYNAM)=-1
> device: {8424F604-4FAE-4541-9D8E-7B0A583A0956}:1; ioctl(SIOCGIFFRNDLYNAM)=-1
> device: {846EE342-7039-11DE-9D20-806E6F6E6963}:1; ioctl(SIOCGIFFRNDLYNAM)=-1

And here's the problem.  Since the requested address families are
different between getifaddrs and ioctl, the indices are different.  This
is a result of how the indices are computed.  The method is just too
simple.  I applied a patch which works better now, AFAICS.  Please test.

However, there's still a problem which I can't fix, due to the nature of
the information returned by Windows.  There's just no unique identifier
for each address of an interface available.  That means, if you ask for
the IPv4 address of an interface, then remove another IPv4 address from
the interface, then the next ioctl/getifaddrs call might return another
interface alias.  The numbering scheme depends on the stability of the
configuration.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019