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

(-)net/pload/Makefile (-2 / +1 lines)
Lines 8-14 Link Here
8
PORTNAME=	pload
8
PORTNAME=	pload
9
PORTVERSION=	0.9.5
9
PORTVERSION=	0.9.5
10
CATEGORIES=	net sysutils
10
CATEGORIES=	net sysutils
11
MASTER_SITES=	http://www.engr.utk.edu/~mdsmith/pload/
11
MASTER_SITES=	http://opal.com/freebsd/ports/net/pload/
12
12
13
MAINTAINER=	fbsd@opal.com
13
MAINTAINER=	fbsd@opal.com
14
COMMENT=	An X11 program to display network traffic graphs
14
COMMENT=	An X11 program to display network traffic graphs
Lines 18-23 Link Here
18
18
19
MAN1=		pload.1
19
MAN1=		pload.1
20
MANCOMPRESSED=	yes
20
MANCOMPRESSED=	yes
21
PLIST_FILES=	bin/pload
22
21
23
.include <bsd.port.mk>
22
.include <bsd.port.mk>
(-)net/pload/files/patch-ioctl_stat.c (+80 lines)
Line 0 Link Here
1
--- ioctl_stat.c.orig	Tue Feb  1 02:11:24 2000
2
+++ ioctl_stat.c	Mon Oct 18 22:32:49 2004
3
@@ -30,6 +30,12 @@
4
 #include <fcntl.h>		/* open */
5
 #include <sys/ioctl.h>		/* ioctl */
6
 #include <errno.h>
7
+#ifdef __FreeBSD__
8
+#include <sys/sysctl.h>
9
+#include <sys/socket.h>
10
+#include <net/if.h>
11
+#include <net/if_mib.h>
12
+#endif
13
 
14
 #ifndef STREAMS				/* Linux, FreeBSD, NetBSD, Ultrix */
15
 #	include <sys/socket.h>		/* socket */
16
@@ -63,6 +69,16 @@
17
 	struct ifreq ifr;
18
 	struct ifpppstatsreq req;
19
 	
20
+#ifdef __FreeBSD__
21
+	static int		if_ix = -1;
22
+	struct ifmibdata	ifmd;
23
+	size_t			ifmd_sz = sizeof(ifmd);
24
+	int			nr_ifs;
25
+	size_t			nr_ifs_sz = sizeof(nr_ifs);
26
+	int			name[6];
27
+	int			i;
28
+#endif
29
+
30
 	if (!ifd->s) getsocket(ifd);
31
 	
32
 	memset(&ifr, 0, sizeof(ifr));
33
@@ -84,18 +100,36 @@
34
 #define ifr_name ifr__name
35
 #endif	
36
 
37
-	strncpy(req.ifr_name, ifd->device, sizeof(req.ifr_name));
38
-	if (ioctl(ifd->s, SIOCGPPPSTATS, &req) != 0)
39
-	{
40
-		/* shouldn't fail if SIOCGIFFLAGS worked... */
41
-		ifd->in_bytes = 0UL;
42
-		ifd->out_bytes = 0UL;
43
-		return;
44
+#ifdef __FreeBSD__
45
+	name[0] = CTL_NET;
46
+	name[1] = PF_LINK;
47
+	name[2] = NETLINK_GENERIC;
48
+	name[3] = IFMIB_IFDATA;
49
+	name[5] = IFDATA_GENERAL;
50
+
51
+	if (if_ix < 0) {
52
+		if (sysctlbyname("net.link.generic.system.ifcount", (void *) &nr_ifs, &nr_ifs_sz, (void *) 0, 0) < 0) {
53
+			return;
54
+		}
55
+		for (i = 1; i <= nr_ifs; i++) {
56
+			name[4] = i; /* row of the ifmib table */
57
+
58
+			if (sysctl(name, 6, (void *) &ifmd, &ifmd_sz, (void *) 0, 0) < 0) {
59
+				continue;
60
+			}
61
+			if (strncmp(ifmd.ifmd_name, ifr.ifr_name, strlen(ifr.ifr_name)) == 0) {
62
+				if_ix = i;
63
+				break;
64
+			}
65
+		}
66
 	}
67
-	
68
-	ifd->in_bytes = (unsigned long)req.stats.p.ppp_ibytes;
69
-	ifd->out_bytes = (unsigned long)req.stats.p.ppp_obytes;
70
-	
71
+	name[4] = if_ix;
72
+	if (sysctl(name, 6, (void *) &ifmd, &ifmd_sz, (void *) 0, 0) >= 0) {
73
+		ifd->in_bytes = ifmd.ifmd_data.ifi_ibytes;
74
+		ifd->out_bytes = ifmd.ifmd_data.ifi_obytes;
75
+	}
76
+#endif
77
+
78
 	return;
79
 }
80
 
(-)net/pload/files/patch-ioctl_stats.c (-80 lines)
Lines 1-80 Link Here
1
--- ioctl_stat.c.orig	Tue Feb  1 08:11:24 2000
2
+++ ioctl_stat.c	Mon Oct 18 22:32:49 2004
3
@@ -30,6 +30,12 @@
4
 #include <fcntl.h>		/* open */
5
 #include <sys/ioctl.h>		/* ioctl */
6
 #include <errno.h>
7
+#ifdef __FreeBSD__
8
+#include <sys/sysctl.h>
9
+#include <sys/socket.h>
10
+#include <net/if.h>
11
+#include <net/if_mib.h>
12
+#endif
13
 
14
 #ifndef STREAMS				/* Linux, FreeBSD, NetBSD, Ultrix */
15
 #	include <sys/socket.h>		/* socket */
16
@@ -63,6 +69,16 @@
17
 	struct ifreq ifr;
18
 	struct ifpppstatsreq req;
19
 	
20
+#ifdef __FreeBSD__
21
+	static int		if_ix = -1;
22
+	struct ifmibdata	ifmd;
23
+	size_t			ifmd_sz = sizeof(ifmd);
24
+	int			nr_ifs;
25
+	size_t			nr_ifs_sz = sizeof(nr_ifs);
26
+	int			name[6];
27
+	int			i;
28
+#endif
29
+
30
 	if (!ifd->s) getsocket(ifd);
31
 	
32
 	memset(&ifr, 0, sizeof(ifr));
33
@@ -84,18 +100,36 @@
34
 #define ifr_name ifr__name
35
 #endif	
36
 
37
-	strncpy(req.ifr_name, ifd->device, sizeof(req.ifr_name));
38
-	if (ioctl(ifd->s, SIOCGPPPSTATS, &req) != 0)
39
-	{
40
-		/* shouldn't fail if SIOCGIFFLAGS worked... */
41
-		ifd->in_bytes = 0UL;
42
-		ifd->out_bytes = 0UL;
43
-		return;
44
+#ifdef __FreeBSD__
45
+	name[0] = CTL_NET;
46
+	name[1] = PF_LINK;
47
+	name[2] = NETLINK_GENERIC;
48
+	name[3] = IFMIB_IFDATA;
49
+	name[5] = IFDATA_GENERAL;
50
+
51
+	if (if_ix < 0) {
52
+		if (sysctlbyname("net.link.generic.system.ifcount", (void *) &nr_ifs, &nr_ifs_sz, (void *) 0, 0) < 0) {
53
+			return;
54
+		}
55
+		for (i = 1; i <= nr_ifs; i++) {
56
+			name[4] = i; /* row of the ifmib table */
57
+
58
+			if (sysctl(name, 6, (void *) &ifmd, &ifmd_sz, (void *) 0, 0) < 0) {
59
+				continue;
60
+			}
61
+			if (strncmp(ifmd.ifmd_name, ifr.ifr_name, strlen(ifr.ifr_name)) == 0) {
62
+				if_ix = i;
63
+				break;
64
+			}
65
+		}
66
 	}
67
-	
68
-	ifd->in_bytes = (unsigned long)req.stats.p.ppp_ibytes;
69
-	ifd->out_bytes = (unsigned long)req.stats.p.ppp_obytes;
70
-	
71
+	name[4] = if_ix;
72
+	if (sysctl(name, 6, (void *) &ifmd, &ifmd_sz, (void *) 0, 0) >= 0) {
73
+		ifd->in_bytes = ifmd.ifmd_data.ifi_ibytes;
74
+		ifd->out_bytes = ifmd.ifmd_data.ifi_obytes;
75
+	}
76
+#endif
77
+
78
 	return;
79
 }
80

Return to bug 83335