This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


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

Re: your mail


Please do not send us personal email.  Most of us specifically redirect
our email communication to the cygwin mailing list.  We do this for a very
good reason.  We want cygwin-specific discussions to be carried out in the
mailing list.

Anyway, I'm not familiar with this code so I'll leave it to Corinna, DJ,
or anyone else who is reading this to comment.

cgf

On Tue, May 15, 2001 at 02:24:59PM +0900, tateyama@sanpo.t.u-tokyo.ac.jp wrote:
>Dear cygwin MAINTENERS,
>
>Please fix check routine that makes socket IFF_LOOPBACK flag wrong.
>
>				Yoshisuke TATEYAMA
>== patch ================================================
>*** cygwin/fhandler_socket.cc.orig	Sat May  5 12:55:00 2001
>--- cygwin/fhandler_socket.cc	Tue May 15 13:45:58 2001
>***************
>*** 291,297 ****
>  	  return -1;
>  	}
>        ifr->ifr_flags = IFF_NOTRAILERS | IFF_UP | IFF_RUNNING;
>!       if (((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr
>            == INADDR_LOOPBACK)
>          ifr->ifr_flags |= IFF_LOOPBACK;
>        else
>--- 291,297 ----
>  	  return -1;
>  	}
>        ifr->ifr_flags = IFF_NOTRAILERS | IFF_UP | IFF_RUNNING;
>!       if (htonl(((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr)
>            == INADDR_LOOPBACK)
>          ifr->ifr_flags |= IFF_LOOPBACK;
>        else
>
>== test program execution example  ================================================
>
>bash-2.04$ uname -r
>1.3.1(0.38/3/2)
>bash-2.04$ gcc lbtest.c
>bash-2.04$ ./a.exe
>INADDR_LOOPBACK: 7f000001
>lo: 127.0.0.1 <UP BROADCAST RUNNING >
>addr (host byte order): 100007f
>new_check: loopback !!
>bash-2.04$ 
>
>== test program: lbtest.c ================================================
>#include <stdio.h>
>#include <sys/types.h>
>#include <net/if.h>
>#include <netinet/in.h>
>#include <sys/socket.h>
>
>void
>print_addr(struct sockaddr *ptr)
>{
>    int addr = htonl(((struct sockaddr_in *)ptr)->sin_addr.s_addr);
>
>    printf("%d.%d.%d.%d ",
>	   (addr & 0xff000000) >> 24,
>	   (addr & 0xff0000) >> 16,
>	   (addr & 0xff00) >> 8,
>	   addr & 0xff);
>}
>
>void
>print_flags(int flags)
>{
>    printf("<");
>    if (flags & IFF_UP) {
>    	printf("UP ");
>    }
>    if (flags & IFF_BROADCAST) {
>    	printf("BROADCAST ");
>    }
>    if (flags & IFF_LOOPBACK) {
>    	printf("LOOPBACK ");
>    }
>
>    if (flags & IFF_RUNNING) {
>    	printf("RUNNING ");
>    }
>    if (flags & IFF_MULTICAST) {
>    	printf("MULTICAST ");
>    }
>    printf("> ");
>}
>
>int
>main(int ac, char *av[])
>{
>    char buf[BUFSIZ];
>    int i, fd, num;
>    struct ifconf conf;
>    struct ifreq *ifr;
>
>    printf("INADDR_LOOPBACK: %x\n", INADDR_LOOPBACK);
>
>    if (-1 == (fd = socket(PF_INET, SOCK_DGRAM, 0))) {
>	perror("socket()");
>	return 1;
>    }
>
>    conf.ifc_len = BUFSIZ;
>    conf.ifc_buf = buf;
>
>    if (-1 == ioctl(fd, SIOCGIFCONF, &conf)) {
>	perror("ioctl(SIOCIFCONF)");
>	return 1;
>    }
>
>    num = conf.ifc_len / sizeof(struct ifreq);
>
>    for (i = 0, ifr = conf.ifc_req; i < num; i++, ifr += 1) {
>	printf("%s: ", ifr->ifr_name);
>	
>	print_addr(&ifr->ifr_addr);
>	
>	if (-1 == ioctl(fd, SIOCGIFFLAGS, ifr)) {
>	    fprintf(stderr, ": ", ifr->ifr_name);
>	    perror("ioctl(SIOCGIFFLAGS)");
>	    continue;
>	}
>	
>	print_flags(ifr->ifr_flags);
>	
>	printf("\naddr (host byte order): %x\n",
>	       ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr);
>	if (((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr
>	    == INADDR_LOOPBACK) {
>	    printf("original_check: loopback !!\n");
>	}
>	
>	if (htonl(((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr)
>	    == INADDR_LOOPBACK) {
>	    printf("new_check: loopback !!\n");
>	}
>    }
>
>    return 0;
>}

-- 
cgf@cygnus.com                        Red Hat, Inc.
http://sources.redhat.com/            http://www.redhat.com/

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


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