Add port net/wmnd a network monitor dockapp.

PR:		31690
Submitted by:	Paolo Flag <flag@gufi.org>
Reviewed by:	petef
This commit is contained in:
Patrick Li 2001-12-03 06:32:27 +00:00
parent 93afc658ba
commit 64a85d3e38
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=50945
11 changed files with 309 additions and 0 deletions

View file

@ -462,6 +462,7 @@
SUBDIR += walker
SUBDIR += whatmask
SUBDIR += wide-dhcp
SUBDIR += wmnd
SUBDIR += wmnet
SUBDIR += wmnet2
SUBDIR += wmnetmon

37
net/wmnd/Makefile Normal file
View file

@ -0,0 +1,37 @@
# New ports collection makefile for: wmnd
# Date created: 29 October 2001
# Whom: Paolo Pisati <flag@gufi.org>
#
# $FreeBSD$
#
PORTNAME= wmnd
PORTVERSION= 0.3.3
CATEGORIES= net
MASTER_SITES= http://www.wingeer.org/wmnd/pkg/
DISTNAME= wmnd_${PORTVERSION}
MAINTAINER= flag@gufi.org
WRKSRC= ${WRKDIR}/wmnd
USE_X_PREFIX= yes
USE_GMAKE= yes
MAN1= wmnd.1
do-install:
@${MKDIR} ${PREFIX}/share/examples/${PORTNAME}
@${INSTALL_PROGRAM} ${WRKSRC}/wmnd ${PREFIX}/bin
@${INSTALL_MAN} ${WRKSRC}/man/wmnd.1 ${PREFIX}/man/man1
@${INSTALL_DATA} ${WRKSRC}/wmndrc \
${PREFIX}/share/examples/${PORTNAME}
post-install:
.if !defined(NOPORTDOCS)
.for docs in CHANGELOGS DISPLAY HINTS README
@${MKDIR} ${DOCSDIR}
@${INSTALL_DATA} ${WRKSRC}/${docs} ${DOCSDIR}
.endfor
.endif
.include <bsd.port.mk>

1
net/wmnd/distinfo Normal file
View file

@ -0,0 +1 @@
MD5 (wmnd_0.3.3.tar.gz) = eadd01d602e8d9ef4c5aec8125e10a49

View file

@ -0,0 +1,36 @@
--- Makefile.orig Tue May 22 07:30:58 2001
+++ Makefile Thu Nov 29 16:11:31 2001
@@ -6,7 +6,6 @@
VERSION = `sed -n "s/\#define WMND_VERSION \"\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)\"/\1\\.\2\\.\\3/p" src/wmnd.h`
PRE =
-prefix = /usr/local/
bindir = $(prefix)/bin/
mandir = $(prefix)/man/
datadir = $(prefix)/share/
@@ -14,13 +13,13 @@
# X11 headers location may vary on some systems
# XFree (linux etc):
-X11CFLAGS = -I/usr/X11R6/include
-X11LDFLAGS = -L/usr/X11R6/lib -lXpm -lXext -lX11
+X11CFLAGS = -I${X11BASE}/include
+X11LDFLAGS = -L${X11BASE}/lib -lXpm -lXext -lX11
# OpenWindows (solaris, sco unixware etc):
# X11CFLAGS = -I/usr/openwin/include
# X11LDFLAGS = -L/usr/openwin/lib -lXpm -lXext -lX11 -lsocket -lnsl
# Solaris specific (for use with kstat)
-LDFLAGS = -lkstat -lsocket -lnsl
+# LDFLAGS = -lkstat -lsocket -lnsl
##################
# compiler flags #
@@ -32,7 +31,7 @@
VPATH = $(SRC):$(MAN)
# Optimizing
-CFLAGS = -Wall -O3 -fomit-frame-pointer -fstrict-aliasing -pipe
+# CFLAGS = -Wall -O -fomit-frame-pointer -fstrict-aliasing -pipe
# Profiling
# CFLAGS = -Wall -ansi -pg -g -O3 -pipe -D_GNU_SOURCE -DPRO

View file

@ -0,0 +1,25 @@
--- src/config.h.orig Fri May 18 14:06:47 2001
+++ src/config.h Thu Nov 29 16:26:26 2001
@@ -11,16 +11,19 @@
/* define below if you're on a big endian architecture */
/* #define WORDS_BIGENDIAN */
+/*FreeBSD dev driver*/
+#define USE_FREEBSD_SYSCTL
+
/* linux /proc/net/dev driver */
/* #define USE_LINUX_PROC */
/* free pppd for Solaris 2.x and compatible streams ppp devices */
-#define USE_SOLARIS_FPPPD
+//#define USE_SOLARIS_FPPPD
/* solaris kstat driver, also works on kstat compatible OSs */
-#define USE_SOLARIS_KSTAT
+//#define USE_SOLARIS_KSTAT
/* dummy driver for testing purposes, it's safe to leave it defined */
-#define USE_TESTING_DUMMY
+//#define USE_TESTING_DUMMY
#endif

View file

@ -0,0 +1,120 @@
--- src/drivers.c.orig Tue May 22 11:11:25 2001
+++ src/drivers.c Thu Nov 29 16:29:44 2001
@@ -17,6 +17,117 @@
* *_term: deallocate name, eventually drvdata and close fds
*/
+#ifdef USE_FREEBSD_SYSCTL
+
+/* functions prototypes */
+int freebsd_dev_list(const char *devname, struct Devices *list) {
+ char *devn;
+ struct Devices *ndev;
+ int mib[5], len;
+ int i;
+ struct ifmibdata ifmd;
+
+ mib[0]=CTL_NET;
+ mib[1]=PF_LINK;
+ mib[2]=NETLINK_GENERIC;
+ mib[3]=IFMIB_SYSTEM;
+ mib[4]=IFMIB_IFCOUNT;
+
+ len=sizeof(int);
+
+ if (sysctl(mib, 5, &freebsd_interface_count, &len ,NULL, 0)==-1) {perror("systcl failed");exit(-1);}
+ printf("freebsd_interface_count: %d\n",freebsd_interface_count);
+
+ printf("devname: %s\n", devname);
+ if (devname != NULL) {
+ // fill in the Devices structure
+ ndev=malloc(sizeof(struct Devices));
+ list->next=ndev;
+ // name of device
+ devn=strdup(devname);
+ ndev->name=devn;
+ // next Devices field used to create the chain
+ ndev->next=NULL;
+ // internale driver data
+ ndev->drvdata=NULL;
+ // driver number
+ ndev->drvnum=0;
+ // status indicator (0 online, 1 offline)
+ ndev->online=0;
+ // device activity start
+ ndev->devstart=time(NULL);
+ // end of initialization
+ printf("freebsd_dev_list finished ok!!!\n");
+ return 1;
+ }
+ else { // we don't have a specific interface to monitor, so we must first retrieve the name of all available interfaces
+printf("any interface defined!\n");
+
+ len=sizeof(ifmd);
+
+ for(i=1;i<=freebsd_interface_count;i++) {
+
+
+ if (get_ifmib_general(i, &ifmd)==-1) {perror("sysctl2");exit(-1);}
+
+ // fill in the Devices structure
+ ndev=malloc(sizeof(struct Devices));
+ list->next=ndev;
+ // name of device
+ devn=strdup(ifmd.ifmd_name);
+ ndev->name=devn;
+ // next Devices field used to create the chain
+ ndev->next=NULL;
+ // internale driver data
+ ndev->drvdata=NULL;
+ // driver number
+ ndev->drvnum=0;
+ // status indicator (0 online, 1 offline)
+ ndev->online=0;
+ // device activity start
+ ndev->devstart=time(NULL);
+ //update the list pointer
+ list=ndev;
+ // end of initialization
+
+}
+
+ return 1;
+ }
+}
+
+int freebsd_dev_init(struct Devices *dev) {
+ printf("nothing to do here!\n");
+ return 0;
+}
+
+int freebsd_dev_get(struct Devices *dev, unsigned long *ip, unsigned long *op, unsigned long *ib, unsigned long *ob) {
+ struct ifmibdata ifmd;
+ int i;
+for(i=1;i<=freebsd_interface_count;i++) {
+ if(get_ifmib_general(i, &ifmd)==-1) {perror("systcl3");exit(-1);}
+ //printf("comparing devname: %s with ifmdname: %s\n",dev->name, ifmd.ifmd_name);
+ if(strcmp(dev->name,ifmd.ifmd_name)==0) {
+ //printf("interface name: %s\n",ifmd.ifmd_name);
+ //printf("ipacktes: %ld opackets: %ld\n",ifmd.ifmd_data.ifi_ipackets,ifmd.ifmd_data.ifi_opackets);
+ //printf("ibytes: %ld obytes: %ld\n",ifmd.ifmd_data.ifi_ibytes,ifmd.ifmd_data.ifi_obytes);
+ //printf("\n");
+ *ip=ifmd.ifmd_data.ifi_ipackets; *op=ifmd.ifmd_data.ifi_opackets;
+ *ib=ifmd.ifmd_data.ifi_ibytes; *ob=ifmd.ifmd_data.ifi_obytes;
+ return 0;
+ }
+} printf("interface %s not found!\n",dev->name); exit(-1);
+
+ return 0;
+}
+
+void freebsd_dev_term(struct Devices *dev) {
+ printf("freebsd_dev_term: %s\n",dev->name);
+ //free(dev);
+}
+
+#endif /*USE_FREESD_SYSCTL*/
+
#ifdef USE_SOLARIS_FPPPD
/* strioclt is a support function, not previously declared */

View file

@ -0,0 +1,31 @@
--- src/drivers.h.orig Sun May 20 10:19:01 2001
+++ src/drivers.h Thu Nov 29 16:33:19 2001
@@ -32,6 +32,18 @@
typedef void (*p_term_drv) (struct Devices * dev);
/* driver vars */
+#ifdef USE_FREEBSD_SYSCTL
+
+
+/* functions prototypes */
+int freebsd_dev_list(const char *devname, struct Devices *list);
+int freebsd_dev_init(struct Devices *dev);
+int freebsd_dev_get(struct Devices *dev, unsigned long *ip, unsigned long *op,
+ unsigned long *ib, unsigned long *ob);
+void freebsd_dev_term(struct Devices *dev);
+
+#endif /*USE_FREESD_SYSCTL*/
+
#ifdef USE_SOLARIS_FPPPD
#include <sys/stropts.h>
@@ -133,6 +145,9 @@
#endif
#ifdef USE_TESTING_DUMMY
{"testing_dummy", testing_dummy_list, testing_dummy_init, testing_dummy_get, testing_dummy_term},
+#endif
+#ifdef USE_FREEBSD_SYSCTL
+ {"FreeBSD_sysctl", freebsd_dev_list, freebsd_dev_init, freebsd_dev_get, freebsd_dev_term},
#endif
{NULL, NULL, NULL, NULL, NULL}
};

View file

@ -0,0 +1,40 @@
--- src/wmnd.h.orig Tue May 22 05:06:36 2001
+++ src/wmnd.h Thu Nov 29 16:08:01 2001
@@ -24,6 +24,37 @@
#include <X11/xpm.h>
#include <X11/extensions/shape.h>
+#ifdef USE_FREEBSD_SYSCTL
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/sysctl.h>
+#include <sys/time.h>
+#include <net/if.h>
+#include <net/if_mib.h>
+
+/* internal structure used for freebsd-systcl */
+
+int freebsd_interface_count=0;
+
+int get_ifmib_general(int row, struct ifmibdata *ifmd) {
+
+ int name[6], len;
+
+ len=sizeof(struct ifmibdata);
+
+ name[0] = CTL_NET;
+ name[1] = PF_LINK;
+ name[2] = NETLINK_GENERIC;
+ name[3] = IFMIB_IFDATA;
+ name[4] = row;
+ name[5] = IFDATA_GENERAL;
+
+ return sysctl(name, 6, ifmd, &len, NULL, 0);
+}
+
+#endif
+
/*
* Wmnd version number, do not modify line layout or sed will not find
* the main version number

1
net/wmnd/pkg-comment Normal file
View file

@ -0,0 +1 @@
Improved network monitoring dock app (with tons of features)

9
net/wmnd/pkg-descr Normal file
View file

@ -0,0 +1,9 @@
WMND (WindowMaker Network Devices) is a network monitoring
dock app improved and based on WMiFS 1.3b. The version 0.2 of
wmnd is almost totally written by Timecop, given the optimization
and flexibility. Enjoy!
WWW: http://www.wingeer.org/wmnd/
- Paolo
flag@gufi.org

8
net/wmnd/pkg-plist Normal file
View file

@ -0,0 +1,8 @@
bin/wmnd
%%PORTDOCS%%share/doc/wmnd/CHANGELOGS
%%PORTDOCS%%share/doc/wmnd/DISPLAY
%%PORTDOCS%%share/doc/wmnd/HINTS
%%PORTDOCS%%share/doc/wmnd/README
share/examples/wmnd/wmndrc
@dirrm share/examples/wmnd
%%PORTDOCS%%@dirrm share/doc/wmnd