On Sun, Jun 08, 2003 at 07:10:03PM +0100, Paul Warren wrote:
v0.13pre1 is now available from:
http://www.ex-parrot.com/~pdw/iftop/download/iftop-0.13pre1.tar.gz
This includes extensive work on the Solaris port by Jonathan Abbey.
The only other change is to make failure to find hardware/ethernet addresses non-fatal.
The addrs_dlpi.c file isn't set up to fail non-fatally as it stands.
The following patch takes care of that, assuming I've done the diff'ing in a useful fashion.
*** addrs_dlpi.c.orig Sun Jun 8 13:28:56 2003 --- addrs_dlpi.c Sun Jun 8 13:35:53 2003 *************** *** 102,108 ****
if (cp == NULL) { free(devname2); ! return -1; } else { *cp = '\0'; /* null terminate devname2 right before numeric extension */ } --- 102,108 ----
if (cp == NULL) { free(devname2); ! goto get_ip_address; } else { *cp = '\0'; /* null terminate devname2 right before numeric extension */ } *************** *** 114,125 **** if (errno != ENOENT) { fprintf(stderr, "Couldn't open %s\n", devname2); free(devname2); ! return -1; } else { if ((fd = open(fulldevpath, O_RDWR)) < 0) { fprintf(stderr, "Couldn't open %s\n", fulldevpath); free(devname2); ! return -1; } } } --- 114,125 ---- if (errno != ENOENT) { fprintf(stderr, "Couldn't open %s\n", devname2); free(devname2); ! goto get_ip_address; } else { if ((fd = open(fulldevpath, O_RDWR)) < 0) { fprintf(stderr, "Couldn't open %s\n", fulldevpath); free(devname2); ! goto get_ip_address; } } } *************** *** 167,178 **** fprintf(stderr, "Error, bad length for hardware interface %s -- %d\n", interface, dlp->info_ack.dl_addr_length); - close(fd); - return -1; }
close(fd);
/* Get the IP address of the interface */
#ifdef SIOCGIFADDR --- 167,178 ---- fprintf(stderr, "Error, bad length for hardware interface %s -- %d\n", interface, dlp->info_ack.dl_addr_length); }
close(fd);
+ get_ip_address: + /* Get the IP address of the interface */
#ifdef SIOCGIFADDR *************** *** 186,195 **** if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) { fprintf(stderr, "Error getting IP address for interface: %s\n", "ge0"); perror("ioctl(SIOCGIFADDR)"); ! close(fd); ! return -1; ! } ! else { memcpy(if_ip_addr, &((*(struct sockaddr_in *) &ifr.ifr_addr).sin_addr), sizeof(struct in_addr)); got_ip_addr = 2; } --- 186,192 ---- if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) { fprintf(stderr, "Error getting IP address for interface: %s\n", "ge0"); perror("ioctl(SIOCGIFADDR)"); ! } else { memcpy(if_ip_addr, &((*(struct sockaddr_in *) &ifr.ifr_addr).sin_addr), sizeof(struct in_addr)); got_ip_addr = 2; }