From sheepkiller@cultdeadsheep.org  Sun Nov  2 03:54:13 2003
Return-Path: <sheepkiller@cultdeadsheep.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id B727C16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  2 Nov 2003 03:54:13 -0800 (PST)
Received: from cultdeadsheep.org (charon.cultdeadsheep.org [80.65.226.72])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6FBD343FA3
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  2 Nov 2003 03:54:11 -0800 (PST)
	(envelope-from sheepkiller@cultdeadsheep.org)
Received: (qmail 75806 invoked by uid 85); 2 Nov 2003 12:54:10 +0100
Received: from sheepkiller@cultdeadsheep.org by goofy.cultdeadsheep.org by uid 82 with qmail-scanner-1.20rc2 
 ( Clear:RC:1:. 
 Processed in 0.046532 secs); 02 Nov 2003 11:54:10 -0000
Received: from lucifer.cultdeadsheep.org (192.168.0.2)
  by goofy.cultdeadsheep.org with SMTP; 2 Nov 2003 12:54:09 +0100
Received: by lucifer.cultdeadsheep.org (sSMTP sendmail emulation); Sun,  2 Nov 2003 12:53:31 +0100
Message-Id: <20031102115411.6FBD343FA3@mx1.FreeBSD.org>
Date: Sun,  2 Nov 2003 12:53:31 +0100
From: Clement Laforet <sheepkiller@cultdeadsheep.org>
Reply-To: Clement Laforet <sheepkiller@cultdeadsheep.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Clement Laforet <sheepkiller@cultdeadsheep.org>
Subject: [new port] net/bandwidthd: a simple bandwidth utilization grapher.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         58830
>Category:       ports
>Synopsis:       [new port] net/bandwidthd: a simple bandwidth utilization grapher.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 02 04:00:38 PST 2003
>Closed-Date:    Thu Nov 06 01:16:16 PST 2003
>Last-Modified:  Thu Nov 06 01:16:16 PST 2003
>Originator:     Clement Laforet
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
cotds.org
>Environment:
System: FreeBSD lucifer.cultdeadsheep.org 5.1-CURRENT FreeBSD 5.1-CURRENT #0: Mon Sep 22 08:20:10 CEST 2003 clement@lucifer.cultdeadsheep.org:/usr/obj/usr/src/sys/LUCIFER i386


	
>Description:
	bandwidthd tracks usage of TCP/IP network subnets and builds HTML files with graphs to display network utilization. 
	Charts are built by individual IP. It color codes HTTP, TCP,UDP, ICMP, VPN, and P2P traffic. Unlike MRTG, it tracks each 
	individual IP address, not the status of any particular link.

>How-To-Repeat:
	N/A.
>Fix:

	

--- bandwidthd.shar begins here ---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	bandwidthd
#	bandwidthd/files
#	bandwidthd/files/bandwidthd.sh
#	bandwidthd/files/patch-bandwidthd.c
#	bandwidthd/files/patch-Makefile
#	bandwidthd/files/patch-conf.tab.c
#	bandwidthd/files/patch-conf.y
#	bandwidthd/files/patch-graph.c
#	bandwidthd/pkg-descr
#	bandwidthd/pkg-plist
#	bandwidthd/Makefile
#	bandwidthd/distinfo
#
echo c - bandwidthd
mkdir -p bandwidthd > /dev/null 2>&1
echo c - bandwidthd/files
mkdir -p bandwidthd/files > /dev/null 2>&1
echo x - bandwidthd/files/bandwidthd.sh
sed 's/^X//' >bandwidthd/files/bandwidthd.sh << 'END-of-bandwidthd/files/bandwidthd.sh'
X#!/bin/sh
X
Xif ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then
X    echo "$0: Cannot determine the PREFIX" >&2
X    exit 1
Xfi
X
Xcase "$1" in
X        start)
X	        [ -x ${PREFIX}/bandwidthd ] && \
X        	[ -r ${PREFIX}/bandwidthd/etc/bandwidthd.conf ] && \
X        	cd ${PREFIX}/bandwidthd && ./bandwidthd &&\
X                        echo -n ' bandwidthd'
X
X	;;
X	stop)
X	killall bandwidthd && echo -n ' bandwidthd'
X	;;
X	*)
X	echo "Usage: `basename $0` {start|stop}" >&2
X	;;
Xesac
END-of-bandwidthd/files/bandwidthd.sh
echo x - bandwidthd/files/patch-bandwidthd.c
sed 's/^X//' >bandwidthd/files/patch-bandwidthd.c << 'END-of-bandwidthd/files/patch-bandwidthd.c'
X--- bandwidthd.c.orig	Fri Oct 10 20:22:39 2003
X+++ bandwidthd.c	Sun Nov  2 12:21:17 2003
X@@ -114,7 +114,11 @@
X 			}
X 		else
X 			{
X+#ifndef FREEBSD
X 			printf("My shared memory segment %d is already in use (%ld locks), perhaps bandwidthd is already running in this directory?\n", shmid, shmstatus.shm_nattch);
X+#else
X+			printf("My shared memory segment %d is already in use (%hd locks), perhaps bandwidthd is already running in this directory?\n", shmid, shmstatus.shm_nattch);
X+#endif
X 			exit(1);
X 			}
X 		}
X@@ -244,7 +248,7 @@
X             tcp = (struct tcphdr *)(ip+1);
X 			tcp = (struct tcphdr *) ( ((char *)tcp) + ((ip->ip_hl-5)*4) ); // Compensate for IP Options
X             Stats->tcp += size;
X-#ifdef SOLARIS
X+#if defined(SOLARIS) || defined(FREEBSD)
X             sport = ntohs(tcp->th_sport);
X             dport = ntohs(tcp->th_dport);			
X #else
END-of-bandwidthd/files/patch-bandwidthd.c
echo x - bandwidthd/files/patch-Makefile
sed 's/^X//' >bandwidthd/files/patch-Makefile << 'END-of-bandwidthd/files/patch-Makefile'
X--- Makefile.orig	Mon Sep 22 20:48:07 2003
X+++ Makefile	Sun Nov  2 12:28:29 2003
X@@ -1,7 +1,7 @@
X #Possible optimizations -fomit-frame-pointer -ffast-math
X OBS= bandwidthd.o graph.o conf.tab.o conf.l.o
X-LIBS= -lgd -lpng -lpcap 
X-CFLAGS= -O3 -Wall
X+LIBS+= -lgd -lpng -lpcap ${LDFLAGS} 
X+CFLAGS+= 
X NONWALLCFLAGS= -O3 #-g -DDEBUG
X 
X # Debugging stuff
X@@ -20,7 +20,7 @@
X 	$(CC) $(CFLAGS) $(OBS) -o bandwidthd $(LIBS) 
X 
X conf.tab.c: conf.y
X-	bison -d conf.y
X+	yacc -d conf.y
X 
X conf.l.c: conf.l
X 	lex -s -i -t -I conf.l > conf.l.c
X@@ -34,12 +34,12 @@
X 	rm -f *.o bandwidthd *~ conf.tab.c conf.tab.h conf.l.c DEADJOE
X 
X install: all
X-	mkdir -p /usr/local/bandwidthd/etc
X-	mkdir -p /usr/local/bandwidthd/htdocs
X-	cp bandwidthd /usr/local/bandwidthd	
X-	cp etc/bandwidthd.conf /usr/local/bandwidthd/etc/
X-	cp htdocs/legend.gif /usr/local/bandwidthd/htdocs/
X-	cp htdocs/logo.gif /usr/local/bandwidthd/htdocs/
X+	mkdir -p ${PREFIX}/bandwidthd/etc
X+	mkdir -p ${PREFIX}/bandwidthd/htdocs
X+	cp bandwidthd ${PREFIX}/bandwidthd
X+	cp etc/bandwidthd.conf ${PREFIX}/bandwidthd/etc/bandwidthd.conf-dist
X+	cp htdocs/legend.gif ${PREFIX}/bandwidthd/htdocs/
X+	cp htdocs/logo.gif ${PREFIX}/bandwidthd/htdocs/
X 
X #**** Stuff where -WALL is turned off to reduce the noise in a compile so I can see my own errors *******************
X conf.l.o: conf.l.c
END-of-bandwidthd/files/patch-Makefile
echo x - bandwidthd/files/patch-conf.tab.c
sed 's/^X//' >bandwidthd/files/patch-conf.tab.c << 'END-of-bandwidthd/files/patch-conf.tab.c'
X--- conf.tab.c.orig	Sun Sep 14 10:34:01 2003
X+++ conf.tab.c	Sun Nov  2 12:21:17 2003
X@@ -23,11 +23,15 @@
X #include <stdio.h>
X #include <string.h>
X #include <unistd.h>
X+#ifdef FREEBSD
X+#include <stdlib.h>
X+#else
X #include <malloc.h>
X+#endif
X #include <unistd.h>
X #include <sys/types.h>
X #include <signal.h>
X-#include <wait.h>
X+#include <sys/wait.h>
X #include <sys/socket.h>
X #include <netinet/in.h>
X #include <arpa/inet.h>
END-of-bandwidthd/files/patch-conf.tab.c
echo x - bandwidthd/files/patch-conf.y
sed 's/^X//' >bandwidthd/files/patch-conf.y << 'END-of-bandwidthd/files/patch-conf.y'
X--- conf.y.orig	Sun Sep 14 10:33:53 2003
X+++ conf.y	Sun Nov  2 12:21:18 2003
X@@ -2,7 +2,11 @@
X #include <stdio.h>
X #include <string.h>
X #include <unistd.h>
X+#ifdef FREEBSD
X+#include <stdlib.h>
X+#else
X #include <malloc.h>
X+#endif
X #include <unistd.h>
X #include <sys/types.h>
X #include <signal.h>
END-of-bandwidthd/files/patch-conf.y
echo x - bandwidthd/files/patch-graph.c
sed 's/^X//' >bandwidthd/files/patch-graph.c << 'END-of-bandwidthd/files/patch-graph.c'
X--- graph.c.orig	Fri Oct 10 21:01:31 2003
X+++ graph.c	Sun Nov  2 12:21:18 2003
X@@ -3,6 +3,11 @@
X #include <signal.h>
X #include <string.h>
X #include <netdb.h>
X+#ifdef FREEBSD
X+#include <netinet/in.h>
X+#include <arpa/nameser.h>
X+#include <sys/types.h>
X+#endif
X #include <sys/socket.h>
X #include <resolv.h>
X #include <time.h>
X@@ -753,7 +758,7 @@
X     // ****  Write the red day seperator bars
X     // ********************************************************************
X 
X-    timestruct = localtime(&sample_begin);
X+    timestruct = localtime((time_t *)(time_t *)&sample_begin);
X     timestruct->tm_sec = 0;
X     timestruct->tm_min = 0;
X     timestruct->tm_hour = 0;
X@@ -772,7 +777,7 @@
X         gdImageLine(im, x, 0, x, YHEIGHT-YOFFSET, red);
X         gdImageLine(im, x+1, 0, x+1, YHEIGHT-YOFFSET, red);
X 
X-        timestruct = localtime(&MarkTime);
X+        timestruct = localtime((time_t *)(time_t *)&MarkTime);
X         strftime(buffer, 100, "%a, %b %d", timestruct);
X         gdImageString(im, gdFontSmall, x-30,  YHEIGHT-YOFFSET+10, buffer, black);        
X 
X@@ -786,7 +791,7 @@
X     // ****  Write the tic marks
X     // ********************************************************************
X 
X-    timestruct = localtime(&sample_begin);
X+    timestruct = localtime((time_t *)(time_t *)&sample_begin);
X     timestruct->tm_sec = 0;
X     timestruct->tm_min = 0;
X     timestruct->tm_hour = 0;
X@@ -803,7 +808,7 @@
X         x = (MarkTime-sample_begin)*((XWIDTH-XOFFSET)/RANGE1) + XOFFSET;
X         }
X 
X-    timestruct = localtime(&sample_begin);
X+    timestruct = localtime((time_t *)(time_t *)&sample_begin);
X     timestruct->tm_sec = 0;
X     timestruct->tm_min = 0;
X     timestruct->tm_hour = 0;
END-of-bandwidthd/files/patch-graph.c
echo x - bandwidthd/pkg-descr
sed 's/^X//' >bandwidthd/pkg-descr << 'END-of-bandwidthd/pkg-descr'
Xbandwidthd tracks usage of TCP/IP network subnets and builds HTML files with 
Xgraphs to display network utilization. Charts are built by individual IP. It 
Xcolor codes HTTP, TCP,UDP, ICMP, VPN, and P2P traffic. Unlike MRTG, it tracks 
Xeach individual IP address, not the status of any particular link. 
X
XWWW: http://bandwidthd.sourceforge.net/
END-of-bandwidthd/pkg-descr
echo x - bandwidthd/pkg-plist
sed 's/^X//' >bandwidthd/pkg-plist << 'END-of-bandwidthd/pkg-plist'
X@comment $FreeBSD$
Xbandwidthd/etc/bandwidthd.conf-dist
Xbandwidthd/bandwidthd
Xbandwidthd/htdocs/legend.gif
Xbandwidthd/htdocs/logo.gif
Xetc/rc.d/bandwidthd.sh.sample
X@unexec rmdir %D/bandwidthd/etc 2> /dev/null || true
X@unexec rmdir %D/bandwidthd/htdocs 2> /dev/null || true
X@unexec rmdir %D/bandwidthd 2> /dev/null || echo "If you do not plan on reinstalling bandwidthd, you can safely remove %D/bandwidthd"
END-of-bandwidthd/pkg-plist
echo x - bandwidthd/Makefile
sed 's/^X//' >bandwidthd/Makefile << 'END-of-bandwidthd/Makefile'
X# New ports collection makefile for:	bandwidthd
X# Date created:				Sun Nov  2
X# Whom:					Clement Laforet <sheepkiller@cultdeadsheep.org>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	bandwidthd
XPORTVERSION=	1.1.5
XCATEGORIES=	net
XMASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
XMASTER_SITE_SUBDIR=	${PORTNAME}
XEXTRACT_SUFX=	.tgz
X
XMAINTAINER=	sheepkiller@cultdeadsheep.org
XCOMMENT=	Tracks bandwidth usage by IP address
X
XLIB_DEPENDS+=	gd.4:${PORTSDIR}/graphics/gd
X
XUSE_GMAKE=	YES
XUSE_REINPLACE=	YES
XCFLAGS+=	-DFREEBSD -I${LOCALBASE}/include
XLDFLAGS+=	-L${LOCALBASE}/lib
XMAKE_ENV+=	LDFLAGS="${LDFLAGS}"
X
Xpost-patch:
X	@${REINPLACE_CMD} -e 's!localtime(!localtime((time_t *)!' ${WRKSRC}/graph.c
X
Xpost-install:
X	@${INSTALL_SCRIPT} ${FILESDIR}/bandwidthd.sh \
X				${PREFIX}/etc/rc.d/bandwidthd.sh.sample
X
X.include <bsd.port.mk>
END-of-bandwidthd/Makefile
echo x - bandwidthd/distinfo
sed 's/^X//' >bandwidthd/distinfo << 'END-of-bandwidthd/distinfo'
XMD5 (bandwidthd-1.1.5.tgz) = a1376f78f7f3414bb95ce76f1a9deac7
END-of-bandwidthd/distinfo
exit
--- bandwidthd.shar ends here ---


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: krion 
State-Changed-When: Thu Nov 6 01:16:09 PST 2003 
State-Changed-Why:  
New port added, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=58830 
>Unformatted:
