El lun, 17-11-2003 a las 23:59, William Jon McCann escribió: > For some reason connect() always returns zero for IPV6 on my RedHat 9 > system configured to use IPV4. This breaks the port scan function in > gnome-netinfo. > > Here is a patch that works around that and at the same time reduces the > number of system calls. Yes, I agree to reduce the number of system calls :-) > Can someone please test this on a IPV6 system? It doesn't work for IPv6. I don't know the reason but using a "size" variable instead of sizeof in the connect system call, it works perfectly for IPv4 and IPv6 (in my system). I have attached the patch > Let me know if this is ok to commit. > > Thanks, > Jon > -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Carlos Garcia Campos a.k.a. KaL elkalmail yahoo es carlosgc gnome org Grupo Linups Usuarios de SL/Linux de la UPSAM http://www.linups.org =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= PGP key: http://pgp.rediris.es:11371/pks/lookup?op=get&search=0x523E6462
Index: ChangeLog =================================================================== RCS file: /cvs/gnome/gnome-network/gnome-netinfo/ChangeLog,v retrieving revision 1.93 diff -u -r1.93 ChangeLog --- ChangeLog 2 Oct 2003 21:26:16 -0000 1.93 +++ ChangeLog 17 Nov 2003 22:53:27 -0000 @@ -1,3 +1,9 @@ +2003-11-17 William Jon McCann <mccann jhu edu> + + * scan.c (scan_do): Work around bug in RH9 where connect always + returns zero for IPV6. Also reduces the number of system calls + performed. + 2003-10-02 Carlos García Campos <carlosgc gnome org> * netinfo.c (get_ip_version): added a function to get the Index: scan.c =================================================================== RCS file: /cvs/gnome/gnome-network/gnome-netinfo/scan.c,v retrieving revision 1.6 diff -u -u -r1.6 scan.c --- scan.c 2 Oct 2003 21:26:16 -0000 1.6 +++ scan.c 18 Nov 2003 13:33:25 -0000 @@ -64,9 +64,16 @@ gchar buf[SIZE]; gchar *service_name = NULL; gint ip_version, pf; + struct sockaddr *addr_ptr; + gint size; g_return_if_fail (netinfo != NULL); + if (netinfo_validate_host (netinfo) == FALSE) { + netinfo_stop_process_command (netinfo); + return; + } + host = netinfo_get_host (netinfo); /* Clear the current output */ @@ -123,17 +130,20 @@ addr.sin_family = PF_INET; bcopy (hp->h_addr, &addr.sin_addr, hp->h_length); addr.sin_port = htons (i); + addr_ptr = (struct sockaddr *) &addr; + size = sizeof (addr); } else { addr6.sin6_family = PF_INET6; addr6.sin6_flowinfo = 0; bcopy (hp->h_addr, &addr6.sin6_addr, hp->h_length); - addr6.sin6_port = htons(i); + addr6.sin6_port = htons (i); + addr_ptr = (struct sockaddr *) &addr6; + size = sizeof (addr6); } - - if ((connect (sock, (struct sockaddr *) &addr, sizeof (addr)) == 0) || - (connect (sock, (struct sockaddr *) &addr6, sizeof (addr6)) == 0)) { - service = getservbyport (htons(i), "tcp"); + + if (connect (sock, addr_ptr, size) == 0) { + service = getservbyport (htons (i), "tcp"); if (service != NULL) { service_name = g_strdup (service->s_name);
Attachment:
signature.asc
Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada digitalmente