Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Tue, 15 May 2001 01:37:32 -0400 From: Chris Faylor To: tateyama AT sanpo DOT t DOT u-tokyo DOT ac DOT jp Cc: cygwin AT cygwin DOT com Subject: Re: your mail Message-ID: <20010515013732.A25536@redhat.com> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: tateyama AT sanpo DOT t DOT u-tokyo DOT ac DOT jp, cygwin AT cygwin DOT com References: <200105150524 DOT f4F5OxM15912 AT mail DOT sanpo DOT t DOT u-tokyo DOT ac DOT jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.11i In-Reply-To: <200105150524.f4F5OxM15912@mail.sanpo.t.u-tokyo.ac.jp>; from tateyama@sanpo.t.u-tokyo.ac.jp on Tue, May 15, 2001 at 02:24:59PM +0900 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 AT sanpo DOT t DOT u-tokyo DOT ac DOT 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 >addr (host byte order): 100007f >new_check: loopback !! >bash-2.04$ > >== test program: lbtest.c ================================================ >#include >#include >#include >#include >#include > >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 AT cygnus DOT 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