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

(-)wmnet2/Makefile (-4 / +4 lines)
Lines 7-22 Link Here
7
7
8
PORTNAME=	wmnet2
8
PORTNAME=	wmnet2
9
PORTVERSION=	1.06
9
PORTVERSION=	1.06
10
PORTREVISION=	2
10
PORTREVISION=	3
11
CATEGORIES=	net
11
CATEGORIES=	net
12
MASTER_SITES=	http://www.digitalkaos.net/linux/wmnet/download/
12
MASTER_SITES=	http://www.digitalkaos.net/linux/wmnet/download/
13
DISTNAME=	wmnet-${PORTVERSION}
13
DISTNAME=	wmnet-${PORTVERSION}
14
14
15
MAINTAINER=	flag@libero.it
15
MAINTAINER=	flag@gufi.org
16
COMMENT=	A cool network monitor for WindowMaker
16
COMMENT=	A nice network monitor for WindowMaker
17
17
18
USE_IMAKE=	yes
18
USE_IMAKE=	yes
19
19
20
MAN1=		wmnet2.1
20
MAN1=		wmnet.1
21
21
22
.include <bsd.port.mk>
22
.include <bsd.port.mk>
(-)wmnet2/files/patch-aa (-32 / +193 lines)
Lines 1-37 Link Here
1
--- drivers.c.orig	Thu May  4 20:34:29 2000
1
--- Imakefile	Fri May  5 02:34:29 2000
2
+++ drivers.c	Mon Feb 18 12:54:45 2002
2
+++ Imakefile	Tue Nov 11 10:54:42 2003
3
@@ -15,6 +15,7 @@
3
@@ -10,9 +10,12 @@
4
 #include<X11/Xlib.h>
4
 LOCAL_LIBRARIES = $(XLIB) -lm 
5
 #include<fcntl.h>
5
 #endif
6
 #include<sys/types.h>
6
 
7
+#include <sys/time.h>
7
-#if defined (FreeBSDArchitecture) || defined (OpenBSDArchitecture)
8
 #include<sys/stat.h>
8
+#if defined (OpenBSDArchitecture)
9
 #include<sys/socket.h>
9
 LOCAL_LIBRARIES = $(XLIB) -lm -lkvm
10
 #include<unistd.h>
10
 INSTPGMFLAGS = -s -g kmem -m 2755 
11
@@ -24,6 +25,8 @@
11
+#elif defined (FreeBSDArchitecture)
12
 /* For FreeBSD */
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 */
13
 #ifdef USE_KVM
48
 #ifdef USE_KVM
14
 #include<net/if.h>
49
 #include<net/if.h>
15
+#include <net/if_var.h>
16
+#include <net/if_types.h>
17
 #include<kvm.h>
50
 #include<kvm.h>
18
 #include<nlist.h>
51
@@ -37,6 +37,22 @@
52
 int kvm_updateStats(void);
53
 #endif /* USE_KVM */
19
 
54
 
20
@@ -455,6 +458,8 @@
55
+#ifdef USE_SYSCTL
21
  unsigned long ifnet_addr = ifnet_savedaddr;
56
+/* system headers */
22
  char devname[16];
57
+#include <sys/types.h>
23
  int flag = 0;
58
+#include <sys/sysctl.h>
24
+ rx = False;
59
+#include <sys/socket.h>
25
+ tx = False;
60
+#include <net/if.h>
26
  while (ifnet_addr && flag != (ACCOUNT_IN_FOUND|ACCOUNT_OUT_FOUND)) {
61
+#include <net/if_mib.h>
27
   kvm_read(kvmfd, ifnet_addr, buffer, sizeof(struct ifnet));
62
+#include <sys/errno.h>
28
 #ifdef __OpenBSD__
63
+
29
@@ -490,7 +495,7 @@
64
+int id = 0; /* interface id */
30
 #ifdef __OpenBSD__
65
+int len = 0; /* sizeof libmibdata */
31
         ifnet_addr = (unsigned long)ifnet->if_list.tqe_next;
66
+struct ifmibdata *data = NULL;
32
 #else
67
+
33
-        ifnet_addr = (unsigned long)ifnet->if_next;
68
+int sysctl_test(void);
34
+	ifnet_addr = (unsigned long) TAILQ_NEXT(ifnet,if_link);
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},
35
 #endif
77
 #endif
36
   }
78
+#ifdef USE_SYSCTL
37
  }
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) {
(-)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
(-)wmnet2/files/patch-ac (-10 lines)
Lines 1-10 Link Here
1
--- wmnet.c.orig	Thu May  4 21:01:14 2000
2
+++ wmnet.c	Wed Dec 19 17:43:40 2001
3
@@ -732,6 +732,7 @@
4
 			case ButtonPress:
5
 				if(event.xbutton.button == Button1 && click_command != NULL) {
6
 					if (fork() == 0) {
7
+						setgid(getgid());
8
 						execl("/bin/sh", "sh", "-c", click_command, NULL);
9
 						perror("wmnet: execl()");
10
 						exit(15);
(-)wmnet2/pkg-descr (-1 / +1 lines)
Lines 11-14 Link Here
11
WWW: http://www.digitalkaos.net/linux/wmnet/
11
WWW: http://www.digitalkaos.net/linux/wmnet/
12
12
13
- Paolo
13
- Paolo
14
flag@libero.it
14
flag@gufi.org
(-)wmnet2/pkg-plist (-1 / +1 lines)
Line 1 Link Here
1
bin/wmnet2
1
bin/wmnet

Return to bug 60095