X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Thu, 2 Dec 2010 14:32:51 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Difference in behaviour between getifaddrs() and ioctl(SIOCGIFCONF) Message-ID: <20101202133251.GL30913@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <20101202114036 DOT GG30913 AT calimero DOT vinschen DOT de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20101202114036.GG30913@calimero.vinschen.de> User-Agent: Mutt/1.5.20 (2009-06-14) 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 Dec 2 12:40, Corinna Vinschen wrote: > 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". > [...] > 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. I think there's a potential solution to this problem. It just depends on how important it is. The maximum name length for the interface is 43 chars + trailing \0. The length of the current GUID name is 38 chars, for instance: {371D57D9-0FF3-402C-AB69-E88FF9D85BC3} So, subtracting the required colon there are only 4 chars left for a unique alias name. The only unique value we could use for the alias name is the IPv4 address itself. However, it doesn't fit into 4 bytes in a readable manner. So here's the idea. If we remove the braces from the GUID name, we drop 2 chars, so we have 6 chars left. 6 chars are enough to convert the IPv4 address into a radix-64 like string, using the l64a function. For instance, in my case the aforementioned interface has the IPv4 address 192.168.129.107. That's 0xc0a8816b as long, which translates into "f36e.1" as radix-64 value per the l64a function. So, for the above interface we get 371D57D9-0FF3-402C-AB69-E88FF9D85BC3:f36e.1 as the unique alias name for the given IPv4 address. Of course, if we do that, then all configured IPv4 address will always get an alias name like this. Just skipping the alias extension for the first IPv4 address of an interface would not be an option. Only the IPv6 addresses would use the interface name without alias. I don't think that's actually a problem, though, but I'm not sure. Any thoughts on this? Is it worth it? 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