mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-21 00:25:50 +00:00
- Fix build on -current
- Update MASTER_SITES PR: ports/184839 Submitted by: KATO Tsuguru <tkato432@yahoo.com>
This commit is contained in:
parent
e695352d91
commit
86f3097928
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=336964
@ -5,8 +5,8 @@ PORTNAME= wmnet2
|
||||
PORTVERSION= 1.06
|
||||
PORTREVISION= 5
|
||||
CATEGORIES= net
|
||||
MASTER_SITES= http://www.dockapps.org/files/77/115/ \
|
||||
http://www.katharineosborne.com/wmnet/
|
||||
MASTER_SITES= http://fossies.org/linux/misc/old/ \
|
||||
http://linux-bsd-unix.strefa.pl/
|
||||
DISTNAME= wmnet-${PORTVERSION}
|
||||
|
||||
MAINTAINER= ports@FreeBSD.org
|
||||
@ -15,8 +15,12 @@ COMMENT= Nice network monitor for WindowMaker
|
||||
USES= imake
|
||||
USE_XORG= x11 xext
|
||||
|
||||
MAN1= wmnet2.1
|
||||
PLIST_FILES= bin/wmnet2
|
||||
PLIST_FILES= bin/wmnet2 man/man1/wmnet2.1.gz
|
||||
|
||||
post-extract:
|
||||
@${LN} -sf wmnet.man ${WRKSRC}/wmnet2.man
|
||||
|
||||
post-install:
|
||||
@${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/wmnet2
|
||||
|
||||
NO_STAGE= yes
|
||||
.include <bsd.port.mk>
|
||||
|
34
net/wmnet2/files/patch-Imakefile
Normal file
34
net/wmnet2/files/patch-Imakefile
Normal file
@ -0,0 +1,34 @@
|
||||
--- Imakefile.orig
|
||||
+++ Imakefile
|
||||
@@ -1,5 +1,4 @@
|
||||
DEPLIBS = $(DEPXLIB)
|
||||
-CC = gcc -Wall
|
||||
|
||||
#ifdef LinuxArchitecture
|
||||
STD_DEFINES = -Dlinux
|
||||
@@ -10,14 +9,17 @@
|
||||
LOCAL_LIBRARIES = $(XLIB) -lm
|
||||
#endif
|
||||
|
||||
-#if defined (FreeBSDArchitecture) || defined (OpenBSDArchitecture)
|
||||
+#if defined (OpenBSDArchitecture)
|
||||
LOCAL_LIBRARIES = $(XLIB) -lm -lkvm
|
||||
INSTPGMFLAGS = -s -g kmem -m 2755
|
||||
+#elif defined (FreeBSDArchitecture)
|
||||
+LOCAL_LIBRARIES = $(XLIB) -lm
|
||||
+INSTPGMFLAGS = -m 0755
|
||||
#endif
|
||||
|
||||
LINTLIBS = $(LINTXLIB)
|
||||
|
||||
-#if defined (FreeBSDArchitecture) || defined (OpenBSDArchitecture)
|
||||
+#if defined (OpenBSDArchitecture)
|
||||
SRCS = wmnet.c drivers.c getopt.c getopt1.c
|
||||
OBJS = wmnet.o drivers.o getopt.o getopt1.o
|
||||
#else
|
||||
@@ -26,4 +28,4 @@
|
||||
#endif
|
||||
|
||||
|
||||
-ComplexProgramTarget(wmnet)
|
||||
+ComplexProgramTarget(wmnet2)
|
@ -1,198 +0,0 @@
|
||||
--- Imakefile Fri May 5 02:34:29 2000
|
||||
+++ Imakefile Tue Nov 11 10:54:42 2003
|
||||
@@ -10,9 +10,12 @@
|
||||
LOCAL_LIBRARIES = $(XLIB) -lm
|
||||
#endif
|
||||
|
||||
-#if defined (FreeBSDArchitecture) || defined (OpenBSDArchitecture)
|
||||
+#if defined (OpenBSDArchitecture)
|
||||
LOCAL_LIBRARIES = $(XLIB) -lm -lkvm
|
||||
INSTPGMFLAGS = -s -g kmem -m 2755
|
||||
+#elif defined (FreeBSDArchitecture)
|
||||
+LOCAL_LIBRARIES = $(XLIB) -lm
|
||||
+INSTPGMFLAGS = -s -m 0755
|
||||
#endif
|
||||
|
||||
LINTLIBS = $(LINTXLIB)
|
||||
--- config.h Fri May 5 02:34:29 2000
|
||||
+++ config.h Tue Nov 11 10:59:05 2003
|
||||
@@ -1,6 +1,6 @@
|
||||
-#if defined (__FreeBSD__) || defined (__OpenBSD__)
|
||||
+#if defined (__OpenBSD__)
|
||||
|
||||
-/* Our only FreeBSD driver, this goes straight into kernel memory
|
||||
+/* Our only OpenBSD driver(old FreeBSD-4.x driver), this goes straight into kernel memory
|
||||
* and reads the raw structures from right underneath the kernel using the
|
||||
* kvm library. This made the code a require a little more thought, but
|
||||
* the end result is a statistics driver thats faster than the linux ones
|
||||
@@ -12,7 +12,11 @@
|
||||
|
||||
#endif
|
||||
|
||||
+#if defined (__FreeBSD__)
|
||||
|
||||
+#define USE_SYSCTL
|
||||
+
|
||||
+#endif
|
||||
|
||||
#ifdef linux
|
||||
|
||||
--- drivers.c Fri May 5 02:34:29 2000
|
||||
+++ drivers.c Wed Nov 12 11:42:40 2003
|
||||
@@ -21,7 +21,7 @@
|
||||
#include"config.h"
|
||||
|
||||
|
||||
-/* For FreeBSD */
|
||||
+/* For OpenBSD */
|
||||
#ifdef USE_KVM
|
||||
#include<net/if.h>
|
||||
#include<kvm.h>
|
||||
@@ -37,6 +37,22 @@
|
||||
int kvm_updateStats(void);
|
||||
#endif /* USE_KVM */
|
||||
|
||||
+#ifdef USE_SYSCTL
|
||||
+/* system headers */
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/sysctl.h>
|
||||
+#include <sys/socket.h>
|
||||
+#include <net/if.h>
|
||||
+#include <net/if_mib.h>
|
||||
+#include <sys/errno.h>
|
||||
+
|
||||
+int id = 0; /* interface id */
|
||||
+int len = 0; /* sizeof libmibdata */
|
||||
+struct ifmibdata *data = NULL;
|
||||
+
|
||||
+int sysctl_test(void);
|
||||
+int sysctl_updateStats(void);
|
||||
+#endif
|
||||
|
||||
#ifdef USE_LINUX_PPP
|
||||
#include<net/ppp_defs.h>
|
||||
@@ -104,6 +120,9 @@
|
||||
#ifdef USE_KVM
|
||||
{"kmem",kvm_updateStats, kvm_test},
|
||||
#endif
|
||||
+#ifdef USE_SYSCTL
|
||||
+ {"sysctl",sysctl_updateStats, sysctl_test},
|
||||
+#endif
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -439,6 +458,114 @@
|
||||
|
||||
|
||||
#endif /* linux */
|
||||
+
|
||||
+/* new FreeBSD driver */
|
||||
+#ifdef USE_SYSCTL
|
||||
+
|
||||
+int sysctl_test(void) {
|
||||
+ struct ifmibdata tempndata;
|
||||
+ int numifaces, len2;
|
||||
+ int mib[5], datamib[6];
|
||||
+ int i;
|
||||
+
|
||||
+ if(device == NULL) device = "lo0";
|
||||
+
|
||||
+ mib[0] = CTL_NET;
|
||||
+ mib[1] = PF_LINK;
|
||||
+ mib[2] = NETLINK_GENERIC;
|
||||
+ mib[3] = IFMIB_SYSTEM;
|
||||
+ mib[4] = IFMIB_IFCOUNT;
|
||||
+
|
||||
+ datamib[0] = CTL_NET;
|
||||
+ datamib[1] = PF_LINK;
|
||||
+ datamib[2] = NETLINK_GENERIC;
|
||||
+ datamib[3] = IFMIB_IFDATA;
|
||||
+ datamib[4] = 1;
|
||||
+ datamib[5] = IFDATA_GENERAL;
|
||||
+
|
||||
+ len = sizeof(struct ifmibdata);
|
||||
+ len2 = sizeof(numifaces);
|
||||
+
|
||||
+ if(sysctl(mib, 5, &numifaces, &len2, NULL, 0) < 0)
|
||||
+ {
|
||||
+ fprintf( stderr, "wmnet: failed to perform sysctl" );
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ for(i = 1; i <= numifaces; i++)
|
||||
+ {
|
||||
+ datamib[4] = i;
|
||||
+ if(sysctl(datamib, 6, &tempndata, &len, NULL, 0) < 0)
|
||||
+ {
|
||||
+ fprintf( stderr, "wmnet: failed to get device(%d) data", i );
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if( strcmp( device, tempndata.ifmd_name ) == 0 )
|
||||
+ {
|
||||
+ id = i;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if ( id == 0 ) {
|
||||
+ fprintf( stderr, "%s doesn't seem to exist!\n", device );
|
||||
+ exit( -1 );
|
||||
+ }
|
||||
+
|
||||
+ /* calculate and allocate mem for ifmibdata containing the if stats */
|
||||
+ data = malloc(len);
|
||||
+
|
||||
+ fprintf(stderr, "wmnet: using sysctl driver to monitor %s\n", device);
|
||||
+ return True;
|
||||
+}
|
||||
+
|
||||
+int sysctl_updateStats(void) {
|
||||
+ int datamib[6];
|
||||
+
|
||||
+ datamib[0] = CTL_NET;
|
||||
+ datamib[1] = PF_LINK;
|
||||
+ datamib[2] = NETLINK_GENERIC;
|
||||
+ datamib[3] = IFMIB_IFDATA;
|
||||
+ datamib[4] = id;
|
||||
+ datamib[5] = IFDATA_GENERAL;
|
||||
+
|
||||
+ if(sysctl( datamib, 6, data, &len, NULL, 0) < 0 ) {
|
||||
+ fprintf( stderr, "wmnet: can't monitor %s device\n", device );
|
||||
+ exit( -1 );
|
||||
+ }
|
||||
+
|
||||
+ // printf( "if name: %s\n", data->ifmd_name );
|
||||
+
|
||||
+ /* get the stats from the if */
|
||||
+ totalpackets_in = data->ifmd_data.ifi_ipackets;
|
||||
+ totalpackets_out = data->ifmd_data.ifi_opackets;
|
||||
+
|
||||
+ if (totalpackets_in != lastpackets_in) {
|
||||
+ totalbytes_in = data->ifmd_data.ifi_ibytes;
|
||||
+ diffpackets_in += totalpackets_in - lastpackets_in;
|
||||
+ diffbytes_in += totalbytes_in - lastbytes_in;
|
||||
+ lastpackets_in = totalpackets_in;
|
||||
+ lastbytes_in = totalbytes_in;
|
||||
+ rx = True;
|
||||
+ } else rx = False;
|
||||
+
|
||||
+ if (totalpackets_out != lastpackets_out) {
|
||||
+ totalbytes_out = data->ifmd_data.ifi_obytes;
|
||||
+ diffpackets_out += totalpackets_out - lastpackets_out;
|
||||
+ diffbytes_out += totalbytes_out - lastbytes_out;
|
||||
+ lastpackets_out = totalpackets_out;
|
||||
+ lastbytes_out = totalbytes_out;
|
||||
+ tx = True;
|
||||
+ } else tx = False;
|
||||
+
|
||||
+ /* return True if no change to tx/rx
|
||||
+ * return False if display will need to be updated
|
||||
+ */
|
||||
+ return((rx == current_rx) && (tx == current_tx));
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
|
||||
#ifdef USE_KVM
|
||||
int kvm_test(void) {
|
@ -1,11 +0,0 @@
|
||||
--- Imakefile 2001/09/08 12:01:26 1.1
|
||||
+++ Imakefile 2001/09/08 12:02:34
|
||||
@@ -26,4 +26,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
-ComplexProgramTarget(wmnet)
|
||||
+ComplexProgramTarget(wmnet2)
|
||||
+
|
||||
+wmnet2.man: wmnet.man
|
||||
+ ln -sf wmnet.man wmnet2.man
|
23
net/wmnet2/files/patch-config.h
Normal file
23
net/wmnet2/files/patch-config.h
Normal file
@ -0,0 +1,23 @@
|
||||
--- config.h.orig
|
||||
+++ config.h
|
||||
@@ -1,6 +1,6 @@
|
||||
-#if defined (__FreeBSD__) || defined (__OpenBSD__)
|
||||
+#if defined (__OpenBSD__)
|
||||
|
||||
-/* Our only FreeBSD driver, this goes straight into kernel memory
|
||||
+/* Our only OpenBSD driver(old FreeBSD-4.x driver), this goes straight into kernel memory
|
||||
* and reads the raw structures from right underneath the kernel using the
|
||||
* kvm library. This made the code a require a little more thought, but
|
||||
* the end result is a statistics driver thats faster than the linux ones
|
||||
@@ -12,7 +12,11 @@
|
||||
|
||||
#endif
|
||||
|
||||
+#if defined (__FreeBSD__)
|
||||
|
||||
+#define USE_SYSCTL
|
||||
+
|
||||
+#endif
|
||||
|
||||
#ifdef linux
|
||||
|
@ -1,15 +1,46 @@
|
||||
--- drivers.c.orig Tue Apr 27 09:22:02 2004
|
||||
+++ drivers.c Tue Apr 27 09:32:19 2004
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <sys/errno.h>
|
||||
@@ -21,7 +21,7 @@
|
||||
#include"config.h"
|
||||
|
||||
int id = 0; /* interface id */
|
||||
-int len = 0; /* sizeof libmibdata */
|
||||
|
||||
-/* For FreeBSD */
|
||||
+/* For OpenBSD */
|
||||
#ifdef USE_KVM
|
||||
#include<net/if.h>
|
||||
#include<kvm.h>
|
||||
@@ -37,6 +37,22 @@
|
||||
int kvm_updateStats(void);
|
||||
#endif /* USE_KVM */
|
||||
|
||||
+#ifdef USE_SYSCTL
|
||||
+/* system headers */
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/sysctl.h>
|
||||
+#include <sys/socket.h>
|
||||
+#include <net/if.h>
|
||||
+#include <net/if_mib.h>
|
||||
+#include <sys/errno.h>
|
||||
+
|
||||
+int id = 0; /* interface id */
|
||||
+size_t len = 0; /* sizeof libmibdata */
|
||||
struct ifmibdata *data = NULL;
|
||||
+struct ifmibdata *data = NULL;
|
||||
+
|
||||
+int sysctl_test(void);
|
||||
+int sysctl_updateStats(void);
|
||||
+#endif
|
||||
|
||||
int sysctl_test(void);
|
||||
@@ -128,7 +128,7 @@
|
||||
#ifdef USE_LINUX_PPP
|
||||
#include<net/ppp_defs.h>
|
||||
@@ -104,12 +120,15 @@
|
||||
#ifdef USE_KVM
|
||||
{"kmem",kvm_updateStats, kvm_test},
|
||||
#endif
|
||||
+#ifdef USE_SYSCTL
|
||||
+ {"sysctl",sysctl_updateStats, sysctl_test},
|
||||
+#endif
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
char* available_drivers(void) {
|
||||
int ind = 0;
|
||||
@ -18,13 +49,119 @@
|
||||
char *string, *ptr;
|
||||
while(drivers[ind].name != NULL) {
|
||||
len += strlen(drivers[ind].name) + 1;
|
||||
@@ -464,7 +464,8 @@
|
||||
@@ -440,6 +459,115 @@
|
||||
|
||||
int sysctl_test(void) {
|
||||
struct ifmibdata tempndata;
|
||||
- int numifaces, len2;
|
||||
#endif /* linux */
|
||||
|
||||
+/* new FreeBSD driver */
|
||||
+#ifdef USE_SYSCTL
|
||||
+
|
||||
+int sysctl_test(void) {
|
||||
+ struct ifmibdata tempndata;
|
||||
+ int numifaces;
|
||||
+ size_t len2;
|
||||
int mib[5], datamib[6];
|
||||
int i;
|
||||
|
||||
+ int mib[5], datamib[6];
|
||||
+ int i;
|
||||
+
|
||||
+ if(device == NULL) device = "lo0";
|
||||
+
|
||||
+ mib[0] = CTL_NET;
|
||||
+ mib[1] = PF_LINK;
|
||||
+ mib[2] = NETLINK_GENERIC;
|
||||
+ mib[3] = IFMIB_SYSTEM;
|
||||
+ mib[4] = IFMIB_IFCOUNT;
|
||||
+
|
||||
+ datamib[0] = CTL_NET;
|
||||
+ datamib[1] = PF_LINK;
|
||||
+ datamib[2] = NETLINK_GENERIC;
|
||||
+ datamib[3] = IFMIB_IFDATA;
|
||||
+ datamib[4] = 1;
|
||||
+ datamib[5] = IFDATA_GENERAL;
|
||||
+
|
||||
+ len = sizeof(struct ifmibdata);
|
||||
+ len2 = sizeof(numifaces);
|
||||
+
|
||||
+ if(sysctl(mib, 5, &numifaces, &len2, NULL, 0) < 0)
|
||||
+ {
|
||||
+ fprintf( stderr, "wmnet: failed to perform sysctl" );
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ for(i = 1; i <= numifaces; i++)
|
||||
+ {
|
||||
+ datamib[4] = i;
|
||||
+ if(sysctl(datamib, 6, &tempndata, &len, NULL, 0) < 0)
|
||||
+ {
|
||||
+ fprintf( stderr, "wmnet: failed to get device(%d) data", i );
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if( strcmp( device, tempndata.ifmd_name ) == 0 )
|
||||
+ {
|
||||
+ id = i;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if ( id == 0 ) {
|
||||
+ fprintf( stderr, "%s doesn't seem to exist!\n", device );
|
||||
+ exit( -1 );
|
||||
+ }
|
||||
+
|
||||
+ /* calculate and allocate mem for ifmibdata containing the if stats */
|
||||
+ data = malloc(len);
|
||||
+
|
||||
+ fprintf(stderr, "wmnet: using sysctl driver to monitor %s\n", device);
|
||||
+ return True;
|
||||
+}
|
||||
+
|
||||
+int sysctl_updateStats(void) {
|
||||
+ int datamib[6];
|
||||
+
|
||||
+ datamib[0] = CTL_NET;
|
||||
+ datamib[1] = PF_LINK;
|
||||
+ datamib[2] = NETLINK_GENERIC;
|
||||
+ datamib[3] = IFMIB_IFDATA;
|
||||
+ datamib[4] = id;
|
||||
+ datamib[5] = IFDATA_GENERAL;
|
||||
+
|
||||
+ if(sysctl( datamib, 6, data, &len, NULL, 0) < 0 ) {
|
||||
+ fprintf( stderr, "wmnet: can't monitor %s device\n", device );
|
||||
+ exit( -1 );
|
||||
+ }
|
||||
+
|
||||
+ // printf( "if name: %s\n", data->ifmd_name );
|
||||
+
|
||||
+ /* get the stats from the if */
|
||||
+ totalpackets_in = data->ifmd_data.ifi_ipackets;
|
||||
+ totalpackets_out = data->ifmd_data.ifi_opackets;
|
||||
+
|
||||
+ if (totalpackets_in != lastpackets_in) {
|
||||
+ totalbytes_in = data->ifmd_data.ifi_ibytes;
|
||||
+ diffpackets_in += totalpackets_in - lastpackets_in;
|
||||
+ diffbytes_in += totalbytes_in - lastbytes_in;
|
||||
+ lastpackets_in = totalpackets_in;
|
||||
+ lastbytes_in = totalbytes_in;
|
||||
+ rx = True;
|
||||
+ } else rx = False;
|
||||
+
|
||||
+ if (totalpackets_out != lastpackets_out) {
|
||||
+ totalbytes_out = data->ifmd_data.ifi_obytes;
|
||||
+ diffpackets_out += totalpackets_out - lastpackets_out;
|
||||
+ diffbytes_out += totalbytes_out - lastbytes_out;
|
||||
+ lastpackets_out = totalpackets_out;
|
||||
+ lastbytes_out = totalbytes_out;
|
||||
+ tx = True;
|
||||
+ } else tx = False;
|
||||
+
|
||||
+ /* return True if no change to tx/rx
|
||||
+ * return False if display will need to be updated
|
||||
+ */
|
||||
+ return((rx == current_rx) && (tx == current_tx));
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
#ifdef USE_KVM
|
||||
int kvm_test(void) {
|
||||
if (((kvmfd = kvm_open(NULL, NULL, NULL, O_RDONLY, buffer)) == NULL) ||
|
||||
|
@ -1,11 +0,0 @@
|
||||
--- getopt.c.orig Fri Oct 9 10:59:00 1998
|
||||
+++ getopt.c Tue Apr 27 09:57:46 2004
|
||||
@@ -209,6 +209,8 @@
|
||||
|
||||
char *getenv ();
|
||||
extern int strncmp(const char *s1, const char *s2, size_t len);
|
||||
+extern int strcmp(const char *, const char *);
|
||||
+extern size_t strlen(const char *);
|
||||
|
||||
static char *
|
||||
my_index (str, chr)
|
@ -1,11 +1,11 @@
|
||||
This little program polls network statistics and does a few things with the
|
||||
data it gets. It has small blinking lights for the rx and tx of IP packets,
|
||||
a digital speedometer of your polled stat's currentspeed and a bar graph like
|
||||
xload et. al which has a tx speed graph from bottom-up and rx speed graph
|
||||
from the top-down. The speedometer keeps track of the current speed per
|
||||
second and shows it in a color corresponding to which of rx or tx that has
|
||||
the highest speed at the moment. Also, the graph is drawn in a way that the
|
||||
highest speed is drawn on top of the other while the other is in the
|
||||
background.
|
||||
This little program polls network statistics and does a few things with
|
||||
the data it gets. It has small blinking lights for the rx and tx of IP
|
||||
packets, a digital speedometer of your polled stat's current speed and a
|
||||
bar graph like xload et. al which has a tx speed graph from bottom-up
|
||||
and rx speed graph from the top-down. The speedometer keeps track of the
|
||||
current speed per second and shows it in a color corresponding to which
|
||||
of rx or tx that has the highest speed at the moment. Also, the graph is
|
||||
drawn in a way that the highest speed is drawn on top of the other while
|
||||
the other is in the background.
|
||||
|
||||
WWW: http://www.dockapps.org/file.php/id/77
|
||||
WWW: http://linux-bsd-unix.strefa.pl/
|
||||
|
Loading…
Reference in New Issue
Block a user