View | Details | Raw Unified | Return to bug 184839
Collapse All | Expand All

(-)net/wmnet2/Makefile (-5 / +6 lines)
Lines 5-12 Link Here
5
PORTVERSION=	1.06
5
PORTVERSION=	1.06
6
PORTREVISION=	5
6
PORTREVISION=	5
7
CATEGORIES=	net
7
CATEGORIES=	net
8
MASTER_SITES=	http://www.dockapps.org/files/77/115/ \
8
MASTER_SITES=	http://fossies.org/linux/misc/old/ \
9
		http://www.katharineosborne.com/wmnet/
9
		http://linux-bsd-unix.strefa.pl/
10
DISTNAME=	wmnet-${PORTVERSION}
10
DISTNAME=	wmnet-${PORTVERSION}
11
11
12
MAINTAINER=	ports@FreeBSD.org
12
MAINTAINER=	ports@FreeBSD.org
Lines 15-22 Link Here
15
USES=		imake
15
USES=		imake
16
USE_XORG=	x11 xext
16
USE_XORG=	x11 xext
17
17
18
MAN1=		wmnet2.1
18
PLIST_FILES=	bin/wmnet2 man/man1/wmnet2.1.gz
19
PLIST_FILES=	bin/wmnet2
19
20
post-extract:
21
	@${LN} -sf wmnet.man ${WRKSRC}/wmnet2.man
20
22
21
NO_STAGE=	yes
22
.include <bsd.port.mk>
23
.include <bsd.port.mk>
(-)net/wmnet2/files/patch-Imakefile (+34 lines)
Line 0 Link Here
1
--- Imakefile.orig
2
+++ Imakefile
3
@@ -1,5 +1,4 @@
4
 DEPLIBS = $(DEPXLIB) 
5
-CC = gcc -Wall
6
 
7
 #ifdef LinuxArchitecture
8
 STD_DEFINES = -Dlinux
9
@@ -10,14 +9,17 @@
10
 LOCAL_LIBRARIES = $(XLIB) -lm 
11
 #endif
12
 
13
-#if defined (FreeBSDArchitecture) || defined (OpenBSDArchitecture)
14
+#if defined (OpenBSDArchitecture)
15
 LOCAL_LIBRARIES = $(XLIB) -lm -lkvm
16
 INSTPGMFLAGS = -s -g kmem -m 2755 
17
+#elif defined (FreeBSDArchitecture)
18
+LOCAL_LIBRARIES = $(XLIB) -lm
19
+INSTPGMFLAGS = -m 0755 
20
 #endif
21
 
22
 LINTLIBS = $(LINTXLIB)
23
 
24
-#if defined (FreeBSDArchitecture) || defined (OpenBSDArchitecture)
25
+#if defined (OpenBSDArchitecture)
26
 SRCS = wmnet.c drivers.c getopt.c getopt1.c
27
 OBJS = wmnet.o drivers.o getopt.o getopt1.o
28
 #else
29
@@ -26,4 +28,4 @@
30
 #endif
31
 
32
 
33
-ComplexProgramTarget(wmnet)
34
+ComplexProgramTarget(wmnet2)
(-)net/wmnet2/files/patch-aa (-198 lines)
Lines 1-198 Link Here
1
--- Imakefile	Fri May  5 02:34:29 2000
2
+++ Imakefile	Tue Nov 11 10:54:42 2003
3
@@ -10,9 +10,12 @@
4
 LOCAL_LIBRARIES = $(XLIB) -lm 
5
 #endif
6
 
7
-#if defined (FreeBSDArchitecture) || defined (OpenBSDArchitecture)
8
+#if defined (OpenBSDArchitecture)
9
 LOCAL_LIBRARIES = $(XLIB) -lm -lkvm
10
 INSTPGMFLAGS = -s -g kmem -m 2755 
11
+#elif defined (FreeBSDArchitecture)
12
+LOCAL_LIBRARIES = $(XLIB) -lm
13
+INSTPGMFLAGS = -s -m 0755 
14
 #endif
15
 
16
 LINTLIBS = $(LINTXLIB)
17
--- config.h	Fri May  5 02:34:29 2000
18
+++ config.h	Tue Nov 11 10:59:05 2003
19
@@ -1,6 +1,6 @@
20
-#if defined (__FreeBSD__) || defined (__OpenBSD__)
21
+#if defined (__OpenBSD__)
22
 
23
-/* Our only FreeBSD driver, this goes straight into kernel memory 
24
+/* Our only OpenBSD driver(old FreeBSD-4.x driver), this goes straight into kernel memory 
25
  * and reads the raw structures from right underneath the kernel using the
26
  * kvm library.  This made the code a require a little more thought, but 
27
  * the end result is a statistics driver thats faster than the linux ones 
28
@@ -12,7 +12,11 @@
29
 
30
 #endif
31
 
32
+#if defined (__FreeBSD__)
33
 
34
+#define USE_SYSCTL
35
+
36
+#endif
37
 
38
 #ifdef linux
39
 
40
--- drivers.c	Fri May  5 02:34:29 2000
41
+++ drivers.c	Wed Nov 12 11:42:40 2003
42
@@ -21,7 +21,7 @@
43
 #include"config.h"
44
 
45
 
46
-/* For FreeBSD */
47
+/* For OpenBSD */
48
 #ifdef USE_KVM
49
 #include<net/if.h>
50
 #include<kvm.h>
51
@@ -37,6 +37,22 @@
52
 int kvm_updateStats(void);
53
 #endif /* USE_KVM */
54
 
55
+#ifdef USE_SYSCTL
56
+/* system headers */
57
+#include <sys/types.h>
58
+#include <sys/sysctl.h>
59
+#include <sys/socket.h>
60
+#include <net/if.h>
61
+#include <net/if_mib.h>
62
+#include <sys/errno.h>
63
+
64
+int id = 0; /* interface id */
65
+int len = 0; /* sizeof libmibdata */
66
+struct ifmibdata *data = NULL;
67
+
68
+int sysctl_test(void);
69
+int sysctl_updateStats(void);
70
+#endif
71
 
72
 #ifdef USE_LINUX_PPP
73
 #include<net/ppp_defs.h>
74
@@ -104,6 +120,9 @@
75
 #ifdef USE_KVM
76
  {"kmem",kvm_updateStats, kvm_test},
77
 #endif
78
+#ifdef USE_SYSCTL
79
+ {"sysctl",sysctl_updateStats, sysctl_test},
80
+#endif
81
  {NULL, NULL}
82
 };
83
 
84
@@ -439,6 +458,114 @@
85
 
86
 
87
 #endif /* linux */
88
+
89
+/* new FreeBSD driver */
90
+#ifdef USE_SYSCTL
91
+
92
+int sysctl_test(void) {
93
+  struct ifmibdata tempndata;
94
+  int numifaces, len2;
95
+  int mib[5], datamib[6];
96
+  int i;
97
+
98
+  if(device == NULL) device = "lo0";
99
+  
100
+  mib[0] = CTL_NET;
101
+  mib[1] = PF_LINK;
102
+  mib[2] = NETLINK_GENERIC;
103
+  mib[3] = IFMIB_SYSTEM;
104
+  mib[4] = IFMIB_IFCOUNT;
105
+         
106
+  datamib[0] = CTL_NET;
107
+  datamib[1] = PF_LINK;
108
+  datamib[2] = NETLINK_GENERIC;
109
+  datamib[3] = IFMIB_IFDATA;
110
+  datamib[4] = 1; 
111
+  datamib[5] = IFDATA_GENERAL;
112
+
113
+  len = sizeof(struct ifmibdata); 
114
+  len2 = sizeof(numifaces);
115
+
116
+  if(sysctl(mib, 5, &numifaces, &len2, NULL, 0) < 0)
117
+  {
118
+    fprintf( stderr, "wmnet: failed to perform sysctl" );
119
+    return 0;
120
+  }
121
+
122
+  for(i = 1; i <= numifaces; i++)
123
+  {
124
+    datamib[4] = i;
125
+    if(sysctl(datamib, 6, &tempndata, &len, NULL, 0) < 0)
126
+    {
127
+      fprintf( stderr, "wmnet: failed to get device(%d) data", i );
128
+      break;
129
+    }
130
+
131
+    if( strcmp( device, tempndata.ifmd_name ) == 0 )
132
+    {
133
+      id = i;
134
+      break;
135
+    }
136
+  }
137
+  
138
+  if ( id == 0 ) {
139
+    fprintf( stderr, "%s doesn't seem to exist!\n", device );
140
+    exit( -1 );
141
+  }
142
+
143
+  /* calculate and allocate mem for ifmibdata containing the if stats */ 
144
+  data = malloc(len);
145
+
146
+  fprintf(stderr, "wmnet: using sysctl driver to monitor %s\n", device);
147
+  return True;
148
+}
149
+
150
+int sysctl_updateStats(void) {
151
+  int datamib[6];
152
+
153
+  datamib[0] = CTL_NET;
154
+  datamib[1] = PF_LINK;
155
+  datamib[2] = NETLINK_GENERIC;
156
+  datamib[3] = IFMIB_IFDATA;
157
+  datamib[4] = id;
158
+  datamib[5] = IFDATA_GENERAL;
159
+
160
+  if(sysctl( datamib, 6, data, &len, NULL, 0) < 0 ) {
161
+    fprintf( stderr, "wmnet: can't monitor %s device\n", device );
162
+    exit( -1 );  
163
+  }
164
+
165
+  //  printf( "if name: %s\n", data->ifmd_name );  
166
+
167
+  /* get the stats from the if */
168
+  totalpackets_in = data->ifmd_data.ifi_ipackets;
169
+  totalpackets_out = data->ifmd_data.ifi_opackets;
170
+
171
+  if (totalpackets_in != lastpackets_in) {
172
+    totalbytes_in = data->ifmd_data.ifi_ibytes;
173
+    diffpackets_in += totalpackets_in - lastpackets_in;
174
+    diffbytes_in += totalbytes_in - lastbytes_in;
175
+    lastpackets_in = totalpackets_in;
176
+    lastbytes_in = totalbytes_in;
177
+    rx = True;
178
+  } else rx = False;
179
+  
180
+  if (totalpackets_out != lastpackets_out) {
181
+    totalbytes_out = data->ifmd_data.ifi_obytes;
182
+    diffpackets_out += totalpackets_out - lastpackets_out;
183
+    diffbytes_out += totalbytes_out - lastbytes_out;
184
+    lastpackets_out = totalpackets_out;
185
+    lastbytes_out = totalbytes_out;
186
+    tx = True;
187
+  } else tx = False;
188
+  
189
+  /* return True if no change to tx/rx
190
+   * return False if display will need to be updated
191
+   */	 
192
+  return((rx == current_rx) && (tx == current_tx));
193
+}
194
+
195
+#endif
196
 
197
 #ifdef USE_KVM
198
 int kvm_test(void) {
(-)net/wmnet2/files/patch-ab (-11 lines)
Lines 1-11 Link Here
1
--- Imakefile	2001/09/08 12:01:26	1.1
2
+++ Imakefile	2001/09/08 12:02:34
3
@@ -26,4 +26,7 @@
4
 #endif
5
 
6
 
7
-ComplexProgramTarget(wmnet)
8
+ComplexProgramTarget(wmnet2)
9
+
10
+wmnet2.man: wmnet.man
11
+	ln -sf wmnet.man wmnet2.man
(-)net/wmnet2/files/patch-config.h (+23 lines)
Line 0 Link Here
1
--- config.h.orig
2
+++ config.h
3
@@ -1,6 +1,6 @@
4
-#if defined (__FreeBSD__) || defined (__OpenBSD__)
5
+#if defined (__OpenBSD__)
6
 
7
-/* Our only FreeBSD driver, this goes straight into kernel memory 
8
+/* Our only OpenBSD driver(old FreeBSD-4.x driver), this goes straight into kernel memory 
9
  * and reads the raw structures from right underneath the kernel using the
10
  * kvm library.  This made the code a require a little more thought, but 
11
  * the end result is a statistics driver thats faster than the linux ones 
12
@@ -12,7 +12,11 @@
13
 
14
 #endif
15
 
16
+#if defined (__FreeBSD__)
17
 
18
+#define USE_SYSCTL
19
+
20
+#endif
21
 
22
 #ifdef linux
23
 
(-)net/wmnet2/files/patch-drivers.c (-14 / +151 lines)
Lines 1-15 Link Here
1
--- drivers.c.orig	Tue Apr 27 09:22:02 2004
1
--- drivers.c.orig	Tue Apr 27 09:22:02 2004
2
+++ drivers.c	Tue Apr 27 09:32:19 2004
2
+++ drivers.c	Tue Apr 27 09:32:19 2004
3
@@ -47,7 +47,7 @@
3
@@ -21,7 +21,7 @@
4
 #include <sys/errno.h>
4
 #include"config.h"
5
 
5
 
6
 int id = 0; /* interface id */
6
 
7
-int len = 0; /* sizeof libmibdata */
7
-/* For FreeBSD */
8
+/* For OpenBSD */
9
 #ifdef USE_KVM
10
 #include<net/if.h>
11
 #include<kvm.h>
12
@@ -37,6 +37,22 @@
13
 int kvm_updateStats(void);
14
 #endif /* USE_KVM */
15
 
16
+#ifdef USE_SYSCTL
17
+/* system headers */
18
+#include <sys/types.h>
19
+#include <sys/sysctl.h>
20
+#include <sys/socket.h>
21
+#include <net/if.h>
22
+#include <net/if_mib.h>
23
+#include <sys/errno.h>
24
+
25
+int id = 0; /* interface id */
8
+size_t len = 0; /* sizeof libmibdata */
26
+size_t len = 0; /* sizeof libmibdata */
9
 struct ifmibdata *data = NULL;
27
+struct ifmibdata *data = NULL;
28
+
29
+int sysctl_test(void);
30
+int sysctl_updateStats(void);
31
+#endif
10
 
32
 
11
 int sysctl_test(void);
33
 #ifdef USE_LINUX_PPP
12
@@ -128,7 +128,7 @@
34
 #include<net/ppp_defs.h>
35
@@ -104,12 +120,15 @@
36
 #ifdef USE_KVM
37
  {"kmem",kvm_updateStats, kvm_test},
38
 #endif
39
+#ifdef USE_SYSCTL
40
+ {"sysctl",sysctl_updateStats, sysctl_test},
41
+#endif
42
  {NULL, NULL}
43
 };
13
 
44
 
14
 char* available_drivers(void) {
45
 char* available_drivers(void) {
15
  int ind = 0;
46
  int ind = 0;
Lines 18-30 Link Here
18
  char *string, *ptr;
49
  char *string, *ptr;
19
  while(drivers[ind].name != NULL) {
50
  while(drivers[ind].name != NULL) {
20
   len += strlen(drivers[ind].name) + 1;
51
   len += strlen(drivers[ind].name) + 1;
21
@@ -464,7 +464,8 @@
52
@@ -440,6 +459,115 @@
22
 
53
 
23
 int sysctl_test(void) {
54
 #endif /* linux */
24
   struct ifmibdata tempndata;
55
 
25
-  int numifaces, len2;
56
+/* new FreeBSD driver */
57
+#ifdef USE_SYSCTL
58
+
59
+int sysctl_test(void) {
60
+  struct ifmibdata tempndata;
26
+  int numifaces;
61
+  int numifaces;
27
+  size_t len2;
62
+  size_t len2;
28
   int mib[5], datamib[6];
63
+  int mib[5], datamib[6];
29
   int i;
64
+  int i;
30
 
65
+
66
+  if(device == NULL) device = "lo0";
67
+  
68
+  mib[0] = CTL_NET;
69
+  mib[1] = PF_LINK;
70
+  mib[2] = NETLINK_GENERIC;
71
+  mib[3] = IFMIB_SYSTEM;
72
+  mib[4] = IFMIB_IFCOUNT;
73
+         
74
+  datamib[0] = CTL_NET;
75
+  datamib[1] = PF_LINK;
76
+  datamib[2] = NETLINK_GENERIC;
77
+  datamib[3] = IFMIB_IFDATA;
78
+  datamib[4] = 1; 
79
+  datamib[5] = IFDATA_GENERAL;
80
+
81
+  len = sizeof(struct ifmibdata); 
82
+  len2 = sizeof(numifaces);
83
+
84
+  if(sysctl(mib, 5, &numifaces, &len2, NULL, 0) < 0)
85
+  {
86
+    fprintf( stderr, "wmnet: failed to perform sysctl" );
87
+    return 0;
88
+  }
89
+
90
+  for(i = 1; i <= numifaces; i++)
91
+  {
92
+    datamib[4] = i;
93
+    if(sysctl(datamib, 6, &tempndata, &len, NULL, 0) < 0)
94
+    {
95
+      fprintf( stderr, "wmnet: failed to get device(%d) data", i );
96
+      break;
97
+    }
98
+
99
+    if( strcmp( device, tempndata.ifmd_name ) == 0 )
100
+    {
101
+      id = i;
102
+      break;
103
+    }
104
+  }
105
+  
106
+  if ( id == 0 ) {
107
+    fprintf( stderr, "%s doesn't seem to exist!\n", device );
108
+    exit( -1 );
109
+  }
110
+
111
+  /* calculate and allocate mem for ifmibdata containing the if stats */ 
112
+  data = malloc(len);
113
+
114
+  fprintf(stderr, "wmnet: using sysctl driver to monitor %s\n", device);
115
+  return True;
116
+}
117
+
118
+int sysctl_updateStats(void) {
119
+  int datamib[6];
120
+
121
+  datamib[0] = CTL_NET;
122
+  datamib[1] = PF_LINK;
123
+  datamib[2] = NETLINK_GENERIC;
124
+  datamib[3] = IFMIB_IFDATA;
125
+  datamib[4] = id;
126
+  datamib[5] = IFDATA_GENERAL;
127
+
128
+  if(sysctl( datamib, 6, data, &len, NULL, 0) < 0 ) {
129
+    fprintf( stderr, "wmnet: can't monitor %s device\n", device );
130
+    exit( -1 );  
131
+  }
132
+
133
+  //  printf( "if name: %s\n", data->ifmd_name );  
134
+
135
+  /* get the stats from the if */
136
+  totalpackets_in = data->ifmd_data.ifi_ipackets;
137
+  totalpackets_out = data->ifmd_data.ifi_opackets;
138
+
139
+  if (totalpackets_in != lastpackets_in) {
140
+    totalbytes_in = data->ifmd_data.ifi_ibytes;
141
+    diffpackets_in += totalpackets_in - lastpackets_in;
142
+    diffbytes_in += totalbytes_in - lastbytes_in;
143
+    lastpackets_in = totalpackets_in;
144
+    lastbytes_in = totalbytes_in;
145
+    rx = True;
146
+  } else rx = False;
147
+  
148
+  if (totalpackets_out != lastpackets_out) {
149
+    totalbytes_out = data->ifmd_data.ifi_obytes;
150
+    diffpackets_out += totalpackets_out - lastpackets_out;
151
+    diffbytes_out += totalbytes_out - lastbytes_out;
152
+    lastpackets_out = totalpackets_out;
153
+    lastbytes_out = totalbytes_out;
154
+    tx = True;
155
+  } else tx = False;
156
+  
157
+  /* return True if no change to tx/rx
158
+   * return False if display will need to be updated
159
+   */	 
160
+  return((rx == current_rx) && (tx == current_tx));
161
+}
162
+
163
+#endif
164
+
165
 #ifdef USE_KVM
166
 int kvm_test(void) {
167
   if (((kvmfd = kvm_open(NULL, NULL, NULL, O_RDONLY, buffer)) == NULL) ||
(-)net/wmnet2/files/patch-getopt.c (-11 lines)
Lines 1-11 Link Here
1
--- getopt.c.orig	Fri Oct  9 10:59:00 1998
2
+++ getopt.c	Tue Apr 27 09:57:46 2004
3
@@ -209,6 +209,8 @@
4
 
5
 char *getenv ();
6
 extern int strncmp(const char *s1, const char *s2, size_t len);
7
+extern int strcmp(const char *, const char *);
8
+extern size_t   strlen(const char *);
9
 
10
 static char *
11
 my_index (str, chr)
(-)net/wmnet2/pkg-descr (-10 / +10 lines)
Lines 1-11 Link Here
1
This little program polls network statistics and does a few things with the
1
This little program polls network statistics and does a few things with
2
data it gets.  It has small blinking lights for the rx and tx of IP packets,
2
the data it gets. It has small blinking lights for the rx and tx of IP
3
a digital speedometer of your polled stat's currentspeed and a bar graph like
3
packets, a digital speedometer of your polled stat's currentspeed and a
4
xload et. al which has a tx speed graph from bottom-up and rx speed graph
4
bar graph like xload et. al which has a tx speed graph from bottom-up
5
from the top-down. The speedometer keeps track of the current speed per
5
and rx speed graph from the top-down. The speedometer keeps track of the
6
second and shows it in a color corresponding to which of rx or tx that has
6
current speed per second and shows it in a color corresponding to which
7
the highest speed at the moment.  Also, the graph is drawn in a way that the
7
of rx or tx that has the highest speed at the moment. Also, the graph is
8
highest speed is drawn on top of the other while the other is in the
8
drawn in a way that the highest speed is drawn on top of the other while
9
background.
9
the other is in the background.
10
10
11
WWW: http://www.dockapps.org/file.php/id/77
11
WWW: http://linux-bsd-unix.strefa.pl/

Return to bug 184839