[Iftop-users] v0.13pre1

Jonathan Abbey jonabbey at arlut.utexas.edu
Sun, 8 Jun 2003 13:39:51 -0500


--jI8keyz6grp/JLjh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Jun 08, 2003 at 07:10:03PM +0100, Paul Warren wrote:
> v0.13pre1 is now available from:
>=20
> http://www.ex-parrot.com/~pdw/iftop/download/iftop-0.13pre1.tar.gz
>=20
> This includes extensive work on the Solaris port by Jonathan Abbey.
>=20
> 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 ****
 =20
    if (cp =3D=3D NULL) {
      free(devname2);
!     return -1;
    } else {
      *cp =3D '\0';			/* null terminate devname2 right before numeric exten=
sion */
    }
--- 102,108 ----
 =20
    if (cp =3D=3D NULL) {
      free(devname2);
!     goto get_ip_address;
    } else {
      *cp =3D '\0';			/* null terminate devname2 right before numeric exten=
sion */
    }
***************
*** 114,125 ****
      if (errno !=3D ENOENT) {
        fprintf(stderr, "Couldn't open %s\n", devname2);
        free(devname2);
!       return -1;
      } else {
        if ((fd =3D open(fulldevpath, O_RDWR)) < 0) {
  	fprintf(stderr, "Couldn't open %s\n", fulldevpath);
  	free(devname2);
! 	return -1;
        }
      }
    }
--- 114,125 ----
      if (errno !=3D ENOENT) {
        fprintf(stderr, "Couldn't open %s\n", devname2);
        free(devname2);
!       goto get_ip_address;
      } else {
        if ((fd =3D 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"=
,=20
  	    interface,
  	    dlp->info_ack.dl_addr_length);
-     close(fd);
-     return -1;
    }
 =20
    close(fd);
 =20
    /* Get the IP address of the interface */
 =20
  #ifdef SIOCGIFADDR
--- 167,178 ----
      fprintf(stderr, "Error, bad length for hardware interface %s -- %d\n"=
,=20
  	    interface,
  	    dlp->info_ack.dl_addr_length);
    }
 =20
    close(fd);
 =20
+  get_ip_address:
+=20
    /* Get the IP address of the interface */
 =20
  #ifdef SIOCGIFADDR
***************
*** 186,195 ****
    if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) {
      fprintf(stderr, "Error getting IP address for interface: %s\n", "ge0"=
);=20
      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 =3D 2;
    }
--- 186,192 ----
    if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) {
      fprintf(stderr, "Error getting IP address for interface: %s\n", "ge0"=
);=20
      perror("ioctl(SIOCGIFADDR)");
!   } else {
      memcpy(if_ip_addr, &((*(struct sockaddr_in *) &ifr.ifr_addr).sin_addr=
), sizeof(struct in_addr));
      got_ip_addr =3D 2;
    }


--=20
---------------------------------------------------------------------------=
----
Jonathan Abbey 				              jonabbey@arlut.utexas.edu
Applied Research Laboratories                 The University of Texas at Au=
stin
GPG Key: 71767586 at keyserver pgp.mit.edu, http://www.ganymeta.org/workkey=
.gpg

--jI8keyz6grp/JLjh
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (SunOS)

iD8DBQE+44L2GI9EwHF2dYYRAoT3AKC1U/MZ6y2fi5l3f8McJEL9ILwOcwCg1ril
GWDRgyQDI0e/U45Ugqc5Yxw=
=kX7q
-----END PGP SIGNATURE-----

--jI8keyz6grp/JLjh--