diff --git a/net/pload/Makefile b/net/pload/Makefile index 31de8211bf6f..6aab9b94341c 100644 --- a/net/pload/Makefile +++ b/net/pload/Makefile @@ -1,18 +1,18 @@ PORTNAME= pload PORTVERSION= 0.9.5 -PORTREVISION= 4 +PORTREVISION= 5 CATEGORIES= net sysutils MASTER_SITES= http://opal.com/src/pload/ LOCAL/pav MAINTAINER= fbsd@opal.com COMMENT= X11 program to display network traffic graphs WWW= https://opal.com/src/pload/ USES= imake:env xorg USE_XORG= ice sm x11 xaw xext xmu xpm xt HAS_CONFIGURE= yes LATE_INSTALL_ARGS= install.man PLIST_FILES= bin/pload man/man1/pload.1.gz .include diff --git a/net/pload/files/patch-Imakefile b/net/pload/files/patch-Imakefile index ae8cc75f98c7..09a8cdabf97c 100644 --- a/net/pload/files/patch-Imakefile +++ b/net/pload/files/patch-Imakefile @@ -1,20 +1,11 @@ -diff -c Imakefile.orig Imakefile -*** Imakefile.orig Tue Feb 1 02:11:24 2000 ---- Imakefile Tue Aug 3 10:02:12 2004 -*************** -*** 15,21 **** - - ComplexProgramTarget(pload) - -! distclean: clean - $(RM) Makefile osdefs.mk core \ - pload-$(VER).tar.gz \ - pload-$(VER)-1.i386.rpm \ ---- 15,21 ---- - - ComplexProgramTarget(pload) - -! distclean:: clean - $(RM) Makefile osdefs.mk core \ - pload-$(VER).tar.gz \ - pload-$(VER)-1.i386.rpm \ +--- Imakefile.orig 2000-02-01 07:11:24 UTC ++++ Imakefile +@@ -15,7 +15,7 @@ DEFINES = -DVERSION="\"Pload version $(VER)\"" $(OSDEF + + ComplexProgramTarget(pload) + +-distclean: clean ++distclean:: clean + $(RM) Makefile osdefs.mk core \ + pload-$(VER).tar.gz \ + pload-$(VER)-1.i386.rpm \ diff --git a/net/pload/files/patch-ioctl_stats.c b/net/pload/files/patch-ioctl__stat.c similarity index 91% rename from net/pload/files/patch-ioctl_stats.c rename to net/pload/files/patch-ioctl__stat.c index 83962721b2c9..ad980130e51a 100644 --- a/net/pload/files/patch-ioctl_stats.c +++ b/net/pload/files/patch-ioctl__stat.c @@ -1,106 +1,106 @@ ---- ioctl_stat.c.orig 2000-02-01 02:11:24.000000000 -0500 -+++ ioctl_stat.c 2009-06-15 15:30:03.000000000 -0400 +--- ioctl_stat.c.orig 2000-02-01 07:11:24 UTC ++++ ioctl_stat.c @@ -30,6 +30,12 @@ #include /* open */ #include /* ioctl */ #include +#ifdef __FreeBSD__ +#include +#include +#include +#include +#endif #ifndef STREAMS /* Linux, FreeBSD, NetBSD, Ultrix */ # include /* socket */ @@ -39,8 +45,10 @@ # include # else /* most everything else */ # include -# include -# include +# if !defined(__FreeBSD__) +# include +# include +# endif /* ! __FreeBSD__ */ # endif /* linux && __GLIBC__ < 2 */ #else /* STREAMS */ /* Solaris, SunOS, OSF/1, SVR4 */ # include -@@ -61,8 +69,18 @@ +@@ -61,8 +69,18 @@ void getsocket(if_data *ifd) void ioctl_stat(if_data *ifd) { struct ifreq ifr; +#ifdef __FreeBSD__ + static int if_ix = -1; + struct ifmibdata ifmd; + size_t ifmd_sz = sizeof(ifmd); + int nr_ifs; + size_t nr_ifs_sz = sizeof(nr_ifs); + int name[6]; + int i; +#else struct ifpppstatsreq req; - +#endif + if (!ifd->s) getsocket(ifd); memset(&ifr, 0, sizeof(ifr)); -@@ -76,7 +94,9 @@ +@@ -76,7 +94,9 @@ void ioctl_stat(if_data *ifd) return; } +#ifndef __FreeBSD__ memset(&req, 0, sizeof(req)); +#endif #ifdef linux req.stats_ptr = (caddr_t) &req.stats; -@@ -84,18 +104,36 @@ +@@ -84,18 +104,36 @@ void ioctl_stat(if_data *ifd) #define ifr_name ifr__name #endif - strncpy(req.ifr_name, ifd->device, sizeof(req.ifr_name)); - if (ioctl(ifd->s, SIOCGPPPSTATS, &req) != 0) - { - /* shouldn't fail if SIOCGIFFLAGS worked... */ - ifd->in_bytes = 0UL; - ifd->out_bytes = 0UL; - return; +#ifdef __FreeBSD__ + name[0] = CTL_NET; + name[1] = PF_LINK; + name[2] = NETLINK_GENERIC; + name[3] = IFMIB_IFDATA; + name[5] = IFDATA_GENERAL; + + if (if_ix < 0) { + if (sysctlbyname("net.link.generic.system.ifcount", (void *) &nr_ifs, &nr_ifs_sz, (void *) 0, 0) < 0) { + return; + } + for (i = 1; i <= nr_ifs; i++) { + name[4] = i; /* row of the ifmib table */ + + if (sysctl(name, 6, (void *) &ifmd, &ifmd_sz, (void *) 0, 0) < 0) { + continue; + } + if (strncmp(ifmd.ifmd_name, ifr.ifr_name, strlen(ifr.ifr_name)) == 0) { + if_ix = i; + break; + } + } } - - ifd->in_bytes = (unsigned long)req.stats.p.ppp_ibytes; - ifd->out_bytes = (unsigned long)req.stats.p.ppp_obytes; - + name[4] = if_ix; + if (sysctl(name, 6, (void *) &ifmd, &ifmd_sz, (void *) 0, 0) >= 0) { + ifd->in_bytes = ifmd.ifmd_data.ifi_ibytes; + ifd->out_bytes = ifmd.ifmd_data.ifi_obytes; + } +#endif + return; } diff --git a/net/pload/files/patch-pload.c b/net/pload/files/patch-pload.c index 0fb88df906b1..9c6c17263337 100644 --- a/net/pload/files/patch-pload.c +++ b/net/pload/files/patch-pload.c @@ -1,73 +1,74 @@ -diff -c pload.c.orig pload.c -*** pload.c.orig Tue Feb 1 02:11:24 2000 ---- pload.c Wed Sep 22 13:13:46 2004 -*************** -*** 596,608 **** - void do_total(char *b, double total) - { - if (total < 1024.0) -! sprintf(b, "%s%0.0f b", b, total); - else if (total < (1024.0*1024.0)) -! sprintf(b, "%s%0.2f k", b, total/1024.0); - else if (total < (1024.0*1024.0*1024.0)) -! sprintf(b, "%s%0.2f M", b, total/1024.0/1024.0); - else -! sprintf(b, "%s%0.2f G", b, total/1024.0/1024.0/1024.0); - - return; - } ---- 596,608 ---- - void do_total(char *b, double total) - { - if (total < 1024.0) -! sprintf(b, "%s%0.0f B", b, total); - else if (total < (1024.0*1024.0)) -! sprintf(b, "%s%0.2f kB", b, total/1024.0); - else if (total < (1024.0*1024.0*1024.0)) -! sprintf(b, "%s%0.2f MB", b, total/1024.0/1024.0); - else -! sprintf(b, "%s%0.2f GB", b, total/1024.0/1024.0/1024.0); - - return; - } -*************** -*** 610,622 **** - void do_rate(char *b, double rate) - { - if (rate < 1024.0) -! sprintf(b, "%s%0.0f b/s",b, rate); - else if (rate < (1024.0*1024.0)) -! sprintf(b, "%s%0.2f k/s",b, rate/1024.0); - else if (rate < (1024.0*1024.0*1024.0)) -! sprintf(b, "%s%0.2f M/s",b, rate/1024.0/1024.0); - else -! sprintf(b, "%s%0.2f G/s", b, rate/1024.0/1024.0/1024.0); - return; - } - ---- 610,622 ---- - void do_rate(char *b, double rate) - { - if (rate < 1024.0) -! sprintf(b, "%s%0.0f B/s",b, rate); - else if (rate < (1024.0*1024.0)) -! sprintf(b, "%s%0.2f kB/s",b, rate/1024.0); - else if (rate < (1024.0*1024.0*1024.0)) -! sprintf(b, "%s%0.2f MB/s",b, rate/1024.0/1024.0); - else -! sprintf(b, "%s%0.2f GB/s", b, rate/1024.0/1024.0/1024.0); - return; - } - -*************** -*** 643,648 **** ---- 643,651 ---- - break; - case 'M': - do_rate(buff, max); -+ break; -+ case 'd': -+ sprintf(buff, "%s", resources.device); - break; - case '%': /* literal % */ - i = strlen(buff); +--- pload.c.orig 2000-02-01 07:11:24 UTC ++++ pload.c +@@ -285,6 +285,13 @@ static XtResource pload_resources[] = { + /************* Main () ******************/ + int main (int argc, char *argv[]) + { ++ char *orig_argv[64]; ++ int i; ++ ++ /* save original argv pointers */ ++ for(i = 0; argv[i]; i++) ++ orig_argv[i] = argv[i]; ++ + Progname = argv[0]; + + toplevel = XtAppInitialize ( +@@ -301,6 +308,11 @@ int main (int argc, char *argv[]) + and exit */ + if (argc != 1) Usage(); + ++ /* XtAppInitialize() eats the arguments, so restore original ++ argv so that ps(1) shows the command line */ ++ for(i = 0; orig_argv[i]; i++) ++ argv[i] = orig_argv[i]; ++ + XtGetApplicationResources( + toplevel, /* widget */ + (XtPointer) &resources, /* where to put */ +@@ -596,27 +608,26 @@ void CheckForWMExit( Widget w, + void do_total(char *b, double total) + { + if (total < 1024.0) +- sprintf(b, "%s%0.0f b", b, total); ++ sprintf(b, "%s%0.0f B", b, total); + else if (total < (1024.0*1024.0)) +- sprintf(b, "%s%0.2f k", b, total/1024.0); ++ sprintf(b, "%s%0.2f kiB", b, total/1024.0); + else if (total < (1024.0*1024.0*1024.0)) +- sprintf(b, "%s%0.2f M", b, total/1024.0/1024.0); ++ sprintf(b, "%s%0.2f MiB", b, total/1024.0/1024.0); + else +- sprintf(b, "%s%0.2f G", b, total/1024.0/1024.0/1024.0); +- ++ sprintf(b, "%s%0.2f GiB", b, total/1024.0/1024.0/1024.0); + return; + } + + void do_rate(char *b, double rate) + { + if (rate < 1024.0) +- sprintf(b, "%s%0.0f b/s",b, rate); ++ sprintf(b, "%s%0.0f B/s",b, rate); + else if (rate < (1024.0*1024.0)) +- sprintf(b, "%s%0.2f k/s",b, rate/1024.0); ++ sprintf(b, "%s%0.2f kiB/s",b, rate/1024.0); + else if (rate < (1024.0*1024.0*1024.0)) +- sprintf(b, "%s%0.2f M/s",b, rate/1024.0/1024.0); ++ sprintf(b, "%s%0.2f MiB/s",b, rate/1024.0/1024.0); + else +- sprintf(b, "%s%0.2f G/s", b, rate/1024.0/1024.0/1024.0); ++ sprintf(b, "%s%0.2f GiB/s", b, rate/1024.0/1024.0/1024.0); + return; + } + +@@ -643,6 +654,9 @@ void make_label(char *fmt, unsigned long total, double + break; + case 'M': + do_rate(buff, max); ++ break; ++ case 'd': ++ strcat(buff, resources.device); + break; + case '%': /* literal % */ + i = strlen(buff); diff --git a/net/pload/files/patch-pload.man b/net/pload/files/patch-pload.man index 61c502ef5e87..c943c6ca8bc1 100644 --- a/net/pload/files/patch-pload.man +++ b/net/pload/files/patch-pload.man @@ -1,33 +1,33 @@ ---- pload.man.orig Tue Feb 1 02:11:24 2000 -+++ pload.man Wed Sep 22 16:44:12 2004 +--- pload.man.orig 2000-02-01 07:11:24 UTC ++++ pload.man @@ -18,7 +18,7 @@ .TH PLOAD 1 "" "January 2000" .SH NAME -pload \- display ppp throughput statistics in an X window +pload \- display network interface statistics in an X window .SH SYNOPSIS .ta 6n -@@ -30,9 +30,9 @@ +@@ -30,9 +30,9 @@ pload \- display ppp throughput statistics in an X win [-iformat \fIfmt\fP] [-oformat \fIfmt\fP] .SH DESCRIPTION -The \fBpload\fP program displays information about network interface (ppp) statistics. -Additionally, for Linux 2.2 it can display statistics for any interface that -reports to /proc/net/dev . +The \fBpload\fP program displays network throughput statistics in an X window +Athena stripchart graph. +On FreeBSD, \fBpload\fP can handle any network interface. .SH OPTIONS .PP -@@ -144,7 +144,7 @@ +@@ -144,7 +144,7 @@ Display \fImessage\fP in the labels when offline. The .TP 8 .B \-iformat \fIfmt\fP Use string \fIfmt\fP for the inbound label. The \fIfmt\fP string will be displayed -literally with the special tags %t %r and %M expanding to the interface total, current +literally with the special tags %d %t %r and %M expanding to the interface name, interface total, current rate, and maximum rate respectively. The default is "%t %r in". .TP 8