This is the mail archive of the cygwin-xfree mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question for Corinna (was Re: Novice Question)


On Jul  1 19:46, Jon TURNEY wrote:
> On 01/07/2009 16:42, Corinna Vinschen wrote:
>>> On Mon, Jun 29, 2009 at 12:09:12PM +0100, Jon TURNEY wrote:
>>>> It seems that the (new for Cygwin 1.7) getifaddr() function can return
>>>> interfaces with IFF_BROADCAST&  IFF_UP set, but no broadcast address, which
>>>> the X server assumes never happens
>> [...]
>> As for the broadcast address, you *have* to expect that an interface
>> is broadcast capable and the ifa_broadaddr pointer is NULL.  This
>> is at least true for all IPv6 entries.  For IPv4 that shouldn't occur
>> under Cygwin.
>
> The code in question (before I patched it) looks like this:
>
> #if defined(IPv6) && defined(AF_INET6)
> 	    if (family == FamilyInternet6)
> 		/* IPv6 doesn't support broadcasting, so we drop out here */
> 		continue;
> #endif
> 	    if ((ifr->ifa_flags & IFF_BROADCAST) &&
> 		(ifr->ifa_flags & IFF_UP))
> 		broad_addr = *ifr->ifa_broadaddr;
> 	    else
> 		continue;
> 	    XdmcpRegisterBroadcastAddress((struct sockaddr_in *)
> 					  &broad_addr);
>
> Staring at the code a bit, I think this means we have either an IPv4  
> interface, or an IPv6 interface with a mapped IPv4 address when the 
> broadcast address is looked at.

A v4inv6 address would also not have a broadcast info since it's still a
v6 address.  For real v4 addresses the broadcast address is not provided
by Windows, but computed from address and netmask by Cygwin, so it's
always available.

However, without the actual interface data I can't tell.  Maybe an
`ipconfig /all' sheds some light on this.  

Oh, wait.  Andy, please build and run the below test app under 1.7 with

  $ gcc -o getifaddrs getifaddrs.c
  $ ./getifaddrs

and paste the output into your reply, together with the `ipconfig /all'
output.


Thanks,
Corinna

=== START getifaddrs.c ===
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <net/if.h>
#include <ifaddrs.h>

#define mk_addr(a) ((a) ? inet_ntop (AF_INET,  &((struct sockaddr_in *) (a))->sin_addr, buf, 256) : "<NULL>")
#define mk_addr6(a) ((a) ? inet_ntop (AF_INET6,  &((struct sockaddr_in6 *) (a))->sin6_addr, buf, 256) : "<NULL>")

int
main ()
{
  struct ifaddrs *ifs, *ifp;
  char buf[256];

  if (getifaddrs (&ifs))
    {
      perror ("getifaddrs: ");
      return 1;
    }
  for (ifp = ifs; ifp; ifp = ifp->ifa_next)
    {
      if (ifp->ifa_addr->sa_family != AF_INET
	  && ifp->ifa_addr->sa_family != AF_INET6)
	continue;
      printf ("Name : %s\n", ifp->ifa_name);
      printf ("Flags: %x\n", ifp->ifa_flags);
      switch (ifp->ifa_addr->sa_family)
        {
	case AF_INET:
	  printf ("Addr : %s\n", mk_addr (ifp->ifa_addr));
	  printf ("Mask : %s\n", mk_addr (ifp->ifa_netmask));
	  if (ifp->ifa_flags & IFF_POINTOPOINT)
	    printf ("Dest : %s\n", mk_addr (ifp->ifa_dstaddr));
	  else
	    printf ("Bcast: %s\n", mk_addr (ifp->ifa_broadaddr));
	  break;
	case AF_INET6:
	  printf ("Addr : %s\n", mk_addr6 (ifp->ifa_addr));
	  printf ("Mask : %s\n", mk_addr6 (ifp->ifa_netmask));
	  if (ifp->ifa_flags & IFF_POINTOPOINT)
	    printf ("Dest : %s\n", mk_addr6 (ifp->ifa_dstaddr));
	  else
	    printf ("Bcast: %s\n", mk_addr6 (ifp->ifa_broadaddr));
	  break;
	}
      putchar ('\n');
    }
  freeifaddrs (ifs);
}
=== END getifaddrs.c ===

-- 
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://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]