Remove bpft. It has been superseded by ports/net/trafd.

PR:		31185
Submitted by:	maintainer
This commit is contained in:
Anders Nordby
2001-12-09 03:25:27 +00:00
parent c54d38b7cb
commit 37a48ed3ee
24 changed files with 0 additions and 922 deletions
-24
View File
@@ -1,24 +0,0 @@
# New ports collection makefile for: bpft
# Date created: 17 March 1999
# Whom: oddbjorn@tricknology.org
#
# $FreeBSD$
#
PORTNAME= bpft
PORTVERSION= 2.0
CATEGORIES= net
MASTER_SITES= ftp://ftp.nsk.su/pub/unix/
EXTRACT_SUFX= .tgz
MAINTAINER= oddbjorn@tricknology.org
MAN1= trafshow2.1
post-install:
.if !defined(NOPORTDOCS)
${MKDIR} ${PREFIX}/share/doc/bpft
${INSTALL_MAN} ${WRKSRC}/README ${PREFIX}/share/doc/bpft/README
.endif
.include <bsd.port.mk>
-1
View File
@@ -1 +0,0 @@
MD5 (bpft-2.0.tgz) = b7a13bc81e5893931ff4662311ee744f
-80
View File
@@ -1,80 +0,0 @@
*** Makefile.orig Wed Oct 30 13:38:00 1996
--- Makefile Wed Jan 5 15:41:25 2000
***************
*** 11,16 ****
--- 11,17 ----
# Target directory for install execution files.
PATH_BINDIR=/usr/local/bin
+ PATH_SBINDIR=/usr/local/sbin
# Target directory for install man pages.
PATH_MANDIR=/usr/local/man/man1
***************
*** 18,24 ****
# Trailing slash directory, summary traffic log files will be put there.
PATH_TOSAVE=/var/log/
! # Full pathname where locate tarfstat program.
PATH_TRAFSTAT=/usr/local/bin/trafstat
# Where locate trafstatd log file, if you want log then file must exist.
--- 19,25 ----
# Trailing slash directory, summary traffic log files will be put there.
PATH_TOSAVE=/var/log/
! # Full pathname where locate trafstat program.
PATH_TRAFSTAT=/usr/local/bin/trafstat
# Where locate trafstatd log file, if you want log then file must exist.
***************
*** 56,79 ****
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
@(cd trafstatd; echo "Build trafstatd in `pwd`"; \
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
! @(cd traflog; echo "Build tarflog in `pwd`"; \
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
@(cd trafshow; echo "Build trafshow in `pwd`"; \
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
@echo Done.
install: all
! install -s -o root -g $(GROUP) -m $(MODE) trafd/trafd $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafstart $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafstop $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafsave $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafdump $(PATH_BINDIR)
install -s -o root -g $(GROUP) -m $(MODE) trafstat/trafstat $(PATH_BINDIR)
! install -s -o root -g $(GROUP) -m $(MODE) trafstatd/trafstatd $(PATH_BINDIR)
! install -s -o root -g $(GROUP) -m $(MODE) traflog/traflog $(PATH_BINDIR)
install -c -o root -g $(GROUP) -m $(MODE) traflog/traflog.format $(PATH_TRAFLOG_FMT)
! install -s -o root -g $(GROUP) -m $(MODE) trafshow/trafshow $(PATH_BINDIR)
! install -c -m 644 trafshow/trafshow.1 $(PATH_MANDIR)
@echo Done.
clean:
--- 57,80 ----
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
@(cd trafstatd; echo "Build trafstatd in `pwd`"; \
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
! @(cd traflog; echo "Build traflog in `pwd`"; \
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
@(cd trafshow; echo "Build trafshow in `pwd`"; \
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
@echo Done.
install: all
! install -s -o root -g $(GROUP) -m $(MODE) trafd/trafd $(PATH_SBINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafstart $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafstop $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafsave $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafdump $(PATH_BINDIR)
install -s -o root -g $(GROUP) -m $(MODE) trafstat/trafstat $(PATH_BINDIR)
! install -s -o root -g $(GROUP) -m $(MODE) trafstatd/trafstatd $(PATH_SBINDIR)
! install -s -o root -g $(GROUP) -m $(MODE) traflog/traflog $(PATH_BINDIR)
install -c -o root -g $(GROUP) -m $(MODE) traflog/traflog.format $(PATH_TRAFLOG_FMT)
! install -s -o root -g $(GROUP) -m $(MODE) trafshow/trafshow $(PATH_BINDIR)/trafshow2
! install -c -m 644 trafshow/trafshow.1 $(PATH_MANDIR)/trafshow2.1
@echo Done.
clean:
-19
View File
@@ -1,19 +0,0 @@
*** trafd/trafstop.orig Fri Mar 19 21:03:06 1999
--- trafd/trafstop Fri Mar 19 21:04:13 1999
***************
*** 6,12 ****
#
# usage: trafstop interfaces...
#
! PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
WHERE_PID=/var/run/trafd.
LOG_FILE=/var/log/traffic.log
--- 6,12 ----
#
# usage: trafstop interfaces...
#
! PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
WHERE_PID=/var/run/trafd.
LOG_FILE=/var/log/traffic.log
-45
View File
@@ -1,45 +0,0 @@
--- lib/addrtoname.c Fri Jan 12 17:42:37 1996
+++ lib/addrtoname.c Thu Jul 25 07:37:56 1996
@@ -294,8 +294,8 @@
#ifdef ETHER_SERVICE
if (!nflag) {
- cp = ETHER_ntohost(ep);
- if (cp) {
- tp->e_name = cp;
- return cp;
+ char buf[128];
+ if (ether_ntohost(buf, ep) == 0) {
+ tp->e_name =strdup(buf);
+ return tp->e_name;
}
}
--- lib/gencode.c Wed Jan 10 12:27:13 1996
+++ lib/gencode.c Thu Jul 25 07:43:16 1996
@@ -841,4 +841,5 @@
struct block *b, *tmp;
int port, real_proto;
+ static char wrk[6];
switch (q.addr) {
@@ -854,6 +855,9 @@
case Q_HOST:
if (proto == Q_LINK) {
/* XXX Should lookup hw addr based on link layer */
- eaddr = ETHER_hostton(name);
+ if (ether_hostton(name, wrk) == 0)
+ eaddr = wrk;
+ else
+ eaddr = 0;
if (eaddr == 0)
error("unknown ether host '%s'", name);
@@ -896,5 +901,9 @@
case Q_GATEWAY:
- eaddr = ETHER_hostton(name);
+ /* XXX Should lookup hw addr based on link layer */
+ if (ether_hostton(name, wrk) == 0)
+ eaddr = wrk;
+ else
+ eaddr = 0;
if (eaddr == 0)
error("unknown ether host: %s", name);
-10
View File
@@ -1,10 +0,0 @@
--- trafshow/show.c.orig Sun Sep 19 18:27:49 1999
+++ trafshow/show.c Sun Sep 19 18:28:03 1999
@@ -15,6 +15,7 @@
static char copyright[] = "* Copyright (c) 1993-1996 CAD lab, Institute of Telecommunication, Novosibirsk *";
+#include <sys/types.h>
#include <curses.h>
#include <stdlib.h>
#include <string.h>
-13
View File
@@ -1,13 +0,0 @@
--- trafd/trafstart.orig Wed Oct 27 09:04:52 1993
+++ trafd/trafstart Mon Oct 25 11:26:55 1999
@@ -1,3 +1,4 @@
+#!/bin/sh
#
# trafstart Copyright (c)1993 CAD lab
#
@@ -20,4 +21,4 @@
#trafd -i ne0 port ftp or ftp-data
#
echo I am storage, before use invoke editor and edit as your need.
-trafd -?
+/usr/local/sbin/trafd -?
-7
View File
@@ -1,7 +0,0 @@
--- trafd/trafstop.orig Mon Oct 25 11:27:48 1999
+++ trafd/trafstop Mon Oct 25 11:28:29 1999
@@ -1,3 +1,4 @@
+#!/bin/sh
#
# trafstop Copyright (c)1993 CAD lab
#
-228
View File
@@ -1,228 +0,0 @@
--- trafd.orig/main.c Sun Jun 6 08:54:09 1999
+++ trafd/main.c Sun Jun 6 08:53:33 1999
@@ -53,6 +53,17 @@
int pflag; /* don't put the interface into promiscuous mode */
int rflag; /* attempt to resume data from safe file if exist */
+int Iflag = 0; /* don't destinguish packets by port/protocol -> only by IP */
+int Dflag = 1; /* do daemonize */
+
+#define MAX_ACC_ADDRESSES 256
+
+struct AccRecord AccAddr[MAX_ACC_ADDRESSES];
+int AccRecNum = 0;
+
+struct AccRecord AggAddr[MAX_ACC_ADDRESSES];
+int AggRecNum = 0;
+
/* Global interrupts flags */
int flag_hup; /* SIGHUP - drop collected data to tempfile */
int flag_int; /* SIGINT - append collected data to savefile */
@@ -80,7 +91,52 @@
static int if_fd = -1;
-void
+int getnet(char *s, struct AccRecord *ar)
+{
+ int rc;
+ char *r;
+ r = strchr(s, '/');
+ if (r) *r++ = '\0';
+ rc = inet_aton(s, (struct in_addr *)&ar->network);
+ if (rc != 1 || !r || !atoi(r)) {
+ fprintf(stderr, "Incorrect parametr '%s' must be in XXX.XXX.XXX.XXX/MASKLEN form\n", s);
+ exit(1);
+ }
+ ar->netmask = htonl(~(0xFFFFFFFF >> atoi(r)));
+ ar->network &= ar->netmask;
+ return(0);
+}
+
+void AccAdd(char *s, struct AccRecord *ar, int *ap) {
+ if (isdigit(*s)) { /* network */
+ if (*ap + 1 >= MAX_ACC_ADDRESSES) {
+ fprintf( stderr, "too many '-S/-A' flags, only %d allowed for each\n", MAX_ACC_ADDRESSES );
+ exit(1);
+ }
+ getnet(optarg, &ar[(*ap)++]);
+ } else { /* file */
+ char buf[256];
+ FILE *f = fopen(s, "r");
+ if (!f) {
+ perror("can't open file");
+ exit(1);
+ }
+ while(fgets(buf, sizeof(buf)-1, f)) {
+ char *ent;
+ if (*ap + 1 >= MAX_ACC_ADDRESSES) {
+ fprintf( stderr, "too many entries in %s, only %d allowed for each\n", s, MAX_ACC_ADDRESSES );
+ exit(1);
+ }
+ ent = buf;
+ while(*ent && isspace(*ent)) ent++;
+ if (!*ent || *ent == '#') continue;
+ getnet(buf, &ar[(*ap)++]);
+ }
+ fclose(f);
+ }
+}
+
+int
main(argc, argv)
int argc;
char **argv;
@@ -100,7 +156,7 @@
program_name = stripdir(argv[0]);
opterr = 0;
- while ((op = getopt(argc, argv, "c:df:F:i:Opr")) != EOF)
+ while ((op = getopt(argc, argv, "c:df:F:i:OprIS:A:D")) != EOF)
switch (op) {
case 'c':
cnt = atoi(optarg);
@@ -126,6 +182,18 @@
case 'r':
++rflag;
break;
+ case 'I':
+ Iflag = 1;
+ break;
+ case 'D':
+ Dflag = 0;
+ break;
+ case 'S':
+ AccAdd(optarg, AccAddr, &AccRecNum);
+ break;
+ case 'A':
+ AccAdd(optarg, AggAddr, &AggRecNum);
+ break;
default:
usage();
}
@@ -185,7 +253,9 @@
device_name);
/* Jump to background */
- daemon(1, 0);
+ if (Dflag)
+ daemon(1, 0);
+
if ((fd = fopen(file_pid, "w")) == NULL)
exit(1);
@@ -207,6 +277,7 @@
(void)syslog(LOG_ERR, "(%s) traffic collector aborted: %m",
device_name);
exit(1);
+ return(1);
}
/* make a clean exit on interrupts */
@@ -284,6 +355,22 @@
fprintf(stderr, "trafd v%s - tcp/udp data traffic collector daemon\n",
version);
fprintf(stderr,
-"Usage: %s [-dOpr] [-c count] [-i iface] [-f ext] [-F file | expr]\n", program_name);
+ "Usage: %s [<flags>] [-F file | expr]\n"
+ "flags:\n"
+ "\t-d\t\tdump packet-matching code\n"
+ "\t-O\t\tdon't run the packet-matching code optimizer\n"
+ "\t-p\t\tdon't put the interface into promiscuous mode\n"
+ "\t-r\t\tattempt to resume data from safe file if exist\n"
+ "\t-I\t\tdon't destinguish ports and protocols\n"
+ "\t-D\t\trun in foreground\n"
+ "\t-c <N>\t\taccount only <N> packets\n"
+ "\t-i <iface>\tlisten interface <iface>\n"
+ "\t-S <net/mlen>\tdo accounting only for this address range\n"
+ "\t-S <filename>\t--\"\"--, read address ranges from file\n"
+ "\t-A <net/mlen>\taggregate addreses from this range to one\n"
+ "\t-A <filename>\t--\"\"--, read address range from file\n"
+ "\t-f <ext>\tuse <ext> as interface name for data files\n"
+ "\n",
+ program_name);
exit(-1);
}
diff -u -N -r trafd.orig/trafd.h trafd/trafd.h
--- trafd.orig/trafd.h Sun Jun 6 08:54:09 1999
+++ trafd/trafd.h Sun Jun 6 08:16:50 1999
@@ -32,3 +32,15 @@
extern void traf_save();
extern void traf_pipe();
extern void traf_clear();
+
+struct AccRecord {
+ unsigned int network;
+ unsigned int netmask;
+};
+
+extern struct AccRecord AccAddr[];
+extern int AccRecNum;
+
+extern struct AccRecord AggAddr[];
+extern int AggRecNum;
+
\ No newline at end of file
diff -u -N -r trafd.orig/traffic.c trafd/traffic.c
--- trafd.orig/traffic.c Sun Jun 6 08:54:09 1999
+++ trafd/traffic.c Sun Jun 6 08:53:33 1999
@@ -138,6 +138,9 @@
return -2;
}
+
+extern int Iflag;
+extern struct bpf_program *Scode;
/*
* Insert entry.
*/
@@ -146,8 +149,48 @@
register p_entry e;
/* return -1 if success digit if already in table or -2 if table full */
{
- register int ec = findentry(e);
+ register int ec;
register unsigned inx;
+
+ if (Iflag) { /* don't match/store protocol&ports */
+ e->ip_protocol = 0;
+ e->who_srv = 0;
+ e->p_port = 0;
+ }
+
+ if (AccRecNum) {
+ int i;
+ int src = 0, dst = 0;
+ for(i = 0; i < AccRecNum; i++) {
+ if ((e->in_ip.s_addr & AccAddr[i].netmask) ==
+ AccAddr[i].network) src = 1;
+ if ((e->out_ip.s_addr & AccAddr[i].netmask) ==
+ AccAddr[i].network) dst = 1;
+ }
+ if (!src) e->in_ip.s_addr = 0xFFFFFFFF;
+ if (!dst) e->out_ip.s_addr = 0xFFFFFFFF;
+ }
+
+ if (AggRecNum) {
+ int i;
+ int src = 0, dst = 0;
+ for(i = 0; i < AggRecNum; i++) {
+ if (!src &&
+ (e->in_ip.s_addr & AggAddr[i].netmask) ==
+ AggAddr[i].network) {
+ src = 1;
+ e->in_ip.s_addr = (e->in_ip.s_addr & AggAddr[i].netmask);
+ }
+ if (!dst &&
+ (e->out_ip.s_addr & AggAddr[i].netmask) ==
+ AggAddr[i].network) {
+ dst = 1;
+ e->out_ip.s_addr = (e->out_ip.s_addr & AggAddr[i].netmask);
+ }
+ }
+ }
+
+ ec = findentry(e);
if (ec != -1)
return ec;
inx = hash(e);
-1
View File
@@ -1 +0,0 @@
The BPF Traffic Collector
-21
View File
@@ -1,21 +0,0 @@
bpft is a superset of trafshow, and extends it by adding a daemon
which collects data about network connections (src, dst, protocol
and length). The resulting data can be dumped to a file for later
processing.
Read /usr/local/share/doc/bpft/README after installation for more
information.
To use bpft, your kernel must be rebuilt with the following line
added to your kernel config file (/sys/i386/conf/<YourMachine>):
pseudo-device bpfilter 4 # Berkeley packet filter
The number after bpfilter is the number of interfaces that can be
examined simultaneously. See section 6.1 of the Handbook for details.
On FreeBSD 4 or later, use the following line instead:
device bpf # Berkeley packet filter
- oddbjorn <oddbjorn@tricknology.org>
-12
View File
@@ -1,12 +0,0 @@
bin/trafdump
bin/traflog
bin/trafsave
bin/trafshow2
bin/trafstart
bin/trafstat
bin/trafstop
etc/traflog.format
sbin/trafd
sbin/trafstatd
share/doc/bpft/README
@dirrm share/doc/bpft
-24
View File
@@ -1,24 +0,0 @@
# New ports collection makefile for: bpft
# Date created: 17 March 1999
# Whom: oddbjorn@tricknology.org
#
# $FreeBSD$
#
PORTNAME= bpft
PORTVERSION= 2.0
CATEGORIES= net
MASTER_SITES= ftp://ftp.nsk.su/pub/unix/
EXTRACT_SUFX= .tgz
MAINTAINER= oddbjorn@tricknology.org
MAN1= trafshow2.1
post-install:
.if !defined(NOPORTDOCS)
${MKDIR} ${PREFIX}/share/doc/bpft
${INSTALL_MAN} ${WRKSRC}/README ${PREFIX}/share/doc/bpft/README
.endif
.include <bsd.port.mk>
-1
View File
@@ -1 +0,0 @@
MD5 (bpft-2.0.tgz) = b7a13bc81e5893931ff4662311ee744f
-80
View File
@@ -1,80 +0,0 @@
*** Makefile.orig Wed Oct 30 13:38:00 1996
--- Makefile Wed Jan 5 15:41:25 2000
***************
*** 11,16 ****
--- 11,17 ----
# Target directory for install execution files.
PATH_BINDIR=/usr/local/bin
+ PATH_SBINDIR=/usr/local/sbin
# Target directory for install man pages.
PATH_MANDIR=/usr/local/man/man1
***************
*** 18,24 ****
# Trailing slash directory, summary traffic log files will be put there.
PATH_TOSAVE=/var/log/
! # Full pathname where locate tarfstat program.
PATH_TRAFSTAT=/usr/local/bin/trafstat
# Where locate trafstatd log file, if you want log then file must exist.
--- 19,25 ----
# Trailing slash directory, summary traffic log files will be put there.
PATH_TOSAVE=/var/log/
! # Full pathname where locate trafstat program.
PATH_TRAFSTAT=/usr/local/bin/trafstat
# Where locate trafstatd log file, if you want log then file must exist.
***************
*** 56,79 ****
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
@(cd trafstatd; echo "Build trafstatd in `pwd`"; \
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
! @(cd traflog; echo "Build tarflog in `pwd`"; \
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
@(cd trafshow; echo "Build trafshow in `pwd`"; \
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
@echo Done.
install: all
! install -s -o root -g $(GROUP) -m $(MODE) trafd/trafd $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafstart $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafstop $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafsave $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafdump $(PATH_BINDIR)
install -s -o root -g $(GROUP) -m $(MODE) trafstat/trafstat $(PATH_BINDIR)
! install -s -o root -g $(GROUP) -m $(MODE) trafstatd/trafstatd $(PATH_BINDIR)
! install -s -o root -g $(GROUP) -m $(MODE) traflog/traflog $(PATH_BINDIR)
install -c -o root -g $(GROUP) -m $(MODE) traflog/traflog.format $(PATH_TRAFLOG_FMT)
! install -s -o root -g $(GROUP) -m $(MODE) trafshow/trafshow $(PATH_BINDIR)
! install -c -m 644 trafshow/trafshow.1 $(PATH_MANDIR)
@echo Done.
clean:
--- 57,80 ----
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
@(cd trafstatd; echo "Build trafstatd in `pwd`"; \
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
! @(cd traflog; echo "Build traflog in `pwd`"; \
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
@(cd trafshow; echo "Build trafshow in `pwd`"; \
$(MAKE) CC=$(CC) CFLAGS='$(CFLAGS)' LIB='$(LIB)')
@echo Done.
install: all
! install -s -o root -g $(GROUP) -m $(MODE) trafd/trafd $(PATH_SBINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafstart $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafstop $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafsave $(PATH_BINDIR)
! install -c -o root -g $(GROUP) -m $(MODE) trafd/trafdump $(PATH_BINDIR)
install -s -o root -g $(GROUP) -m $(MODE) trafstat/trafstat $(PATH_BINDIR)
! install -s -o root -g $(GROUP) -m $(MODE) trafstatd/trafstatd $(PATH_SBINDIR)
! install -s -o root -g $(GROUP) -m $(MODE) traflog/traflog $(PATH_BINDIR)
install -c -o root -g $(GROUP) -m $(MODE) traflog/traflog.format $(PATH_TRAFLOG_FMT)
! install -s -o root -g $(GROUP) -m $(MODE) trafshow/trafshow $(PATH_BINDIR)/trafshow2
! install -c -m 644 trafshow/trafshow.1 $(PATH_MANDIR)/trafshow2.1
@echo Done.
clean:
-19
View File
@@ -1,19 +0,0 @@
*** trafd/trafstop.orig Fri Mar 19 21:03:06 1999
--- trafd/trafstop Fri Mar 19 21:04:13 1999
***************
*** 6,12 ****
#
# usage: trafstop interfaces...
#
! PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
WHERE_PID=/var/run/trafd.
LOG_FILE=/var/log/traffic.log
--- 6,12 ----
#
# usage: trafstop interfaces...
#
! PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
WHERE_PID=/var/run/trafd.
LOG_FILE=/var/log/traffic.log
-45
View File
@@ -1,45 +0,0 @@
--- lib/addrtoname.c Fri Jan 12 17:42:37 1996
+++ lib/addrtoname.c Thu Jul 25 07:37:56 1996
@@ -294,8 +294,8 @@
#ifdef ETHER_SERVICE
if (!nflag) {
- cp = ETHER_ntohost(ep);
- if (cp) {
- tp->e_name = cp;
- return cp;
+ char buf[128];
+ if (ether_ntohost(buf, ep) == 0) {
+ tp->e_name =strdup(buf);
+ return tp->e_name;
}
}
--- lib/gencode.c Wed Jan 10 12:27:13 1996
+++ lib/gencode.c Thu Jul 25 07:43:16 1996
@@ -841,4 +841,5 @@
struct block *b, *tmp;
int port, real_proto;
+ static char wrk[6];
switch (q.addr) {
@@ -854,6 +855,9 @@
case Q_HOST:
if (proto == Q_LINK) {
/* XXX Should lookup hw addr based on link layer */
- eaddr = ETHER_hostton(name);
+ if (ether_hostton(name, wrk) == 0)
+ eaddr = wrk;
+ else
+ eaddr = 0;
if (eaddr == 0)
error("unknown ether host '%s'", name);
@@ -896,5 +901,9 @@
case Q_GATEWAY:
- eaddr = ETHER_hostton(name);
+ /* XXX Should lookup hw addr based on link layer */
+ if (ether_hostton(name, wrk) == 0)
+ eaddr = wrk;
+ else
+ eaddr = 0;
if (eaddr == 0)
error("unknown ether host: %s", name);
-10
View File
@@ -1,10 +0,0 @@
--- trafshow/show.c.orig Sun Sep 19 18:27:49 1999
+++ trafshow/show.c Sun Sep 19 18:28:03 1999
@@ -15,6 +15,7 @@
static char copyright[] = "* Copyright (c) 1993-1996 CAD lab, Institute of Telecommunication, Novosibirsk *";
+#include <sys/types.h>
#include <curses.h>
#include <stdlib.h>
#include <string.h>
-13
View File
@@ -1,13 +0,0 @@
--- trafd/trafstart.orig Wed Oct 27 09:04:52 1993
+++ trafd/trafstart Mon Oct 25 11:26:55 1999
@@ -1,3 +1,4 @@
+#!/bin/sh
#
# trafstart Copyright (c)1993 CAD lab
#
@@ -20,4 +21,4 @@
#trafd -i ne0 port ftp or ftp-data
#
echo I am storage, before use invoke editor and edit as your need.
-trafd -?
+/usr/local/sbin/trafd -?
-7
View File
@@ -1,7 +0,0 @@
--- trafd/trafstop.orig Mon Oct 25 11:27:48 1999
+++ trafd/trafstop Mon Oct 25 11:28:29 1999
@@ -1,3 +1,4 @@
+#!/bin/sh
#
# trafstop Copyright (c)1993 CAD lab
#
-228
View File
@@ -1,228 +0,0 @@
--- trafd.orig/main.c Sun Jun 6 08:54:09 1999
+++ trafd/main.c Sun Jun 6 08:53:33 1999
@@ -53,6 +53,17 @@
int pflag; /* don't put the interface into promiscuous mode */
int rflag; /* attempt to resume data from safe file if exist */
+int Iflag = 0; /* don't destinguish packets by port/protocol -> only by IP */
+int Dflag = 1; /* do daemonize */
+
+#define MAX_ACC_ADDRESSES 256
+
+struct AccRecord AccAddr[MAX_ACC_ADDRESSES];
+int AccRecNum = 0;
+
+struct AccRecord AggAddr[MAX_ACC_ADDRESSES];
+int AggRecNum = 0;
+
/* Global interrupts flags */
int flag_hup; /* SIGHUP - drop collected data to tempfile */
int flag_int; /* SIGINT - append collected data to savefile */
@@ -80,7 +91,52 @@
static int if_fd = -1;
-void
+int getnet(char *s, struct AccRecord *ar)
+{
+ int rc;
+ char *r;
+ r = strchr(s, '/');
+ if (r) *r++ = '\0';
+ rc = inet_aton(s, (struct in_addr *)&ar->network);
+ if (rc != 1 || !r || !atoi(r)) {
+ fprintf(stderr, "Incorrect parametr '%s' must be in XXX.XXX.XXX.XXX/MASKLEN form\n", s);
+ exit(1);
+ }
+ ar->netmask = htonl(~(0xFFFFFFFF >> atoi(r)));
+ ar->network &= ar->netmask;
+ return(0);
+}
+
+void AccAdd(char *s, struct AccRecord *ar, int *ap) {
+ if (isdigit(*s)) { /* network */
+ if (*ap + 1 >= MAX_ACC_ADDRESSES) {
+ fprintf( stderr, "too many '-S/-A' flags, only %d allowed for each\n", MAX_ACC_ADDRESSES );
+ exit(1);
+ }
+ getnet(optarg, &ar[(*ap)++]);
+ } else { /* file */
+ char buf[256];
+ FILE *f = fopen(s, "r");
+ if (!f) {
+ perror("can't open file");
+ exit(1);
+ }
+ while(fgets(buf, sizeof(buf)-1, f)) {
+ char *ent;
+ if (*ap + 1 >= MAX_ACC_ADDRESSES) {
+ fprintf( stderr, "too many entries in %s, only %d allowed for each\n", s, MAX_ACC_ADDRESSES );
+ exit(1);
+ }
+ ent = buf;
+ while(*ent && isspace(*ent)) ent++;
+ if (!*ent || *ent == '#') continue;
+ getnet(buf, &ar[(*ap)++]);
+ }
+ fclose(f);
+ }
+}
+
+int
main(argc, argv)
int argc;
char **argv;
@@ -100,7 +156,7 @@
program_name = stripdir(argv[0]);
opterr = 0;
- while ((op = getopt(argc, argv, "c:df:F:i:Opr")) != EOF)
+ while ((op = getopt(argc, argv, "c:df:F:i:OprIS:A:D")) != EOF)
switch (op) {
case 'c':
cnt = atoi(optarg);
@@ -126,6 +182,18 @@
case 'r':
++rflag;
break;
+ case 'I':
+ Iflag = 1;
+ break;
+ case 'D':
+ Dflag = 0;
+ break;
+ case 'S':
+ AccAdd(optarg, AccAddr, &AccRecNum);
+ break;
+ case 'A':
+ AccAdd(optarg, AggAddr, &AggRecNum);
+ break;
default:
usage();
}
@@ -185,7 +253,9 @@
device_name);
/* Jump to background */
- daemon(1, 0);
+ if (Dflag)
+ daemon(1, 0);
+
if ((fd = fopen(file_pid, "w")) == NULL)
exit(1);
@@ -207,6 +277,7 @@
(void)syslog(LOG_ERR, "(%s) traffic collector aborted: %m",
device_name);
exit(1);
+ return(1);
}
/* make a clean exit on interrupts */
@@ -284,6 +355,22 @@
fprintf(stderr, "trafd v%s - tcp/udp data traffic collector daemon\n",
version);
fprintf(stderr,
-"Usage: %s [-dOpr] [-c count] [-i iface] [-f ext] [-F file | expr]\n", program_name);
+ "Usage: %s [<flags>] [-F file | expr]\n"
+ "flags:\n"
+ "\t-d\t\tdump packet-matching code\n"
+ "\t-O\t\tdon't run the packet-matching code optimizer\n"
+ "\t-p\t\tdon't put the interface into promiscuous mode\n"
+ "\t-r\t\tattempt to resume data from safe file if exist\n"
+ "\t-I\t\tdon't destinguish ports and protocols\n"
+ "\t-D\t\trun in foreground\n"
+ "\t-c <N>\t\taccount only <N> packets\n"
+ "\t-i <iface>\tlisten interface <iface>\n"
+ "\t-S <net/mlen>\tdo accounting only for this address range\n"
+ "\t-S <filename>\t--\"\"--, read address ranges from file\n"
+ "\t-A <net/mlen>\taggregate addreses from this range to one\n"
+ "\t-A <filename>\t--\"\"--, read address range from file\n"
+ "\t-f <ext>\tuse <ext> as interface name for data files\n"
+ "\n",
+ program_name);
exit(-1);
}
diff -u -N -r trafd.orig/trafd.h trafd/trafd.h
--- trafd.orig/trafd.h Sun Jun 6 08:54:09 1999
+++ trafd/trafd.h Sun Jun 6 08:16:50 1999
@@ -32,3 +32,15 @@
extern void traf_save();
extern void traf_pipe();
extern void traf_clear();
+
+struct AccRecord {
+ unsigned int network;
+ unsigned int netmask;
+};
+
+extern struct AccRecord AccAddr[];
+extern int AccRecNum;
+
+extern struct AccRecord AggAddr[];
+extern int AggRecNum;
+
\ No newline at end of file
diff -u -N -r trafd.orig/traffic.c trafd/traffic.c
--- trafd.orig/traffic.c Sun Jun 6 08:54:09 1999
+++ trafd/traffic.c Sun Jun 6 08:53:33 1999
@@ -138,6 +138,9 @@
return -2;
}
+
+extern int Iflag;
+extern struct bpf_program *Scode;
/*
* Insert entry.
*/
@@ -146,8 +149,48 @@
register p_entry e;
/* return -1 if success digit if already in table or -2 if table full */
{
- register int ec = findentry(e);
+ register int ec;
register unsigned inx;
+
+ if (Iflag) { /* don't match/store protocol&ports */
+ e->ip_protocol = 0;
+ e->who_srv = 0;
+ e->p_port = 0;
+ }
+
+ if (AccRecNum) {
+ int i;
+ int src = 0, dst = 0;
+ for(i = 0; i < AccRecNum; i++) {
+ if ((e->in_ip.s_addr & AccAddr[i].netmask) ==
+ AccAddr[i].network) src = 1;
+ if ((e->out_ip.s_addr & AccAddr[i].netmask) ==
+ AccAddr[i].network) dst = 1;
+ }
+ if (!src) e->in_ip.s_addr = 0xFFFFFFFF;
+ if (!dst) e->out_ip.s_addr = 0xFFFFFFFF;
+ }
+
+ if (AggRecNum) {
+ int i;
+ int src = 0, dst = 0;
+ for(i = 0; i < AggRecNum; i++) {
+ if (!src &&
+ (e->in_ip.s_addr & AggAddr[i].netmask) ==
+ AggAddr[i].network) {
+ src = 1;
+ e->in_ip.s_addr = (e->in_ip.s_addr & AggAddr[i].netmask);
+ }
+ if (!dst &&
+ (e->out_ip.s_addr & AggAddr[i].netmask) ==
+ AggAddr[i].network) {
+ dst = 1;
+ e->out_ip.s_addr = (e->out_ip.s_addr & AggAddr[i].netmask);
+ }
+ }
+ }
+
+ ec = findentry(e);
if (ec != -1)
return ec;
inx = hash(e);
-1
View File
@@ -1 +0,0 @@
The BPF Traffic Collector
-21
View File
@@ -1,21 +0,0 @@
bpft is a superset of trafshow, and extends it by adding a daemon
which collects data about network connections (src, dst, protocol
and length). The resulting data can be dumped to a file for later
processing.
Read /usr/local/share/doc/bpft/README after installation for more
information.
To use bpft, your kernel must be rebuilt with the following line
added to your kernel config file (/sys/i386/conf/<YourMachine>):
pseudo-device bpfilter 4 # Berkeley packet filter
The number after bpfilter is the number of interfaces that can be
examined simultaneously. See section 6.1 of the Handbook for details.
On FreeBSD 4 or later, use the following line instead:
device bpf # Berkeley packet filter
- oddbjorn <oddbjorn@tricknology.org>
-12
View File
@@ -1,12 +0,0 @@
bin/trafdump
bin/traflog
bin/trafsave
bin/trafshow2
bin/trafstart
bin/trafstat
bin/trafstop
etc/traflog.format
sbin/trafd
sbin/trafstatd
share/doc/bpft/README
@dirrm share/doc/bpft