1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
diff -ru trafd-3.0.1~/lib/interfaces.c trafd-3.0.1/lib/interfaces.c
--- trafd-3.0.1~/lib/interfaces.c 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/lib/interfaces.c 2006-11-16 21:22:18.000000000 +0100
@@ -43,6 +43,7 @@
#include <stdio.h>
#include <pcap.h>
+#include <string.h>
#include "ethertype.h"
#include "interface.h"
diff -ru trafd-3.0.1~/lib/savestr.c trafd-3.0.1/lib/savestr.c
--- trafd-3.0.1~/lib/savestr.c 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/lib/savestr.c 2006-11-16 21:22:18.000000000 +0100
@@ -29,6 +29,7 @@
#endif
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "gnuc.h"
diff -ru trafd-3.0.1~/Makefile trafd-3.0.1/Makefile
--- trafd-3.0.1~/Makefile 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/Makefile 2006-11-16 21:34:14.000000000 +0100
@@ -12,22 +12,27 @@
#
# Target directory for install execution files.
-PATH_BINDIR=/usr/local/bin
+PATH_BINDIR=/usr/bin
+
+# Installation path
+PATH_BINDIR_INSTALL=${DESTDIR}usr/bin
+PATH_CONF_INSTALL=${DESTDIR}etc
# Target directory for install man pages.
-PATH_MANDIR=/usr/local/man/man1
+PATH_MANDIR=/usr/share/man/man1
+PATH_INSTALL_DOC=${DESTDIR}usr/share/doc/trafd-3.0.1
# Trailing slash directory, summary traffic log files will be put there.
PATH_TOSAVE=/var/trafd/
# Full pathname where locate tarfstat program.
-PATH_TRAFSTAT=/usr/local/bin/trafstat
+PATH_TRAFSTAT=/usr/bin/trafstat
# Where locate trafstatd log file, if you want log then file must exist.
PATH_TRAFSTAT_LOG=/var/log/trafstat.log
# File with user defined descriptions of the traflog output format.
-PATH_TRAFLOG_FMT=/usr/local/etc/traflog.format
+PATH_TRAFLOG_FMT=/etc/traflog.format
# Only group wheel can execute binary files.
SHELL = /bin/sh
@@ -42,9 +47,9 @@
#DEFINE += -DHAVE_MEMORY_H=1
#DEFINE += -DHAVE_MALLOC_H=1
-LDFLAGS = -L../lib -lbpft -lpcap -lcurses -ltermcap -ll
+LDFLAGS+=-L../lib -lbpft -lpcap -lcurses -ltermcap -lfl
-INCLUDE = -I../include
+INCLUDE = -I../include -I../../tcpdump-richard-1.7/linux-include -I../../tcpdump-richard-1.7/libpcap-0.0/bpf/
CFLAGS = ${FLAGS} ${INCLUDE} ${DEFINE} \
-DPATH_TOSAVE=\"${PATH_TOSAVE}\"\
-DPATH_TRAFSTAT=\"${PATH_TRAFSTAT}\"\
@@ -64,15 +69,17 @@
@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 -o root -g ${GROUP} -m ${MODE} trafd/trafd ${PATH_BINDIR_INSTALL}
+ install -c -o root -g ${GROUP} -m ${MODE} trafd/trafstart ${PATH_BINDIR_INSTALL}
+ install -c -o root -g ${GROUP} -m ${MODE} trafd/trafstop ${PATH_BINDIR_INSTALL}
+ install -c -o root -g ${GROUP} -m ${MODE} trafd/trafsave ${PATH_BINDIR_INSTALL}
+ install -c -o root -g ${GROUP} -m ${MODE} trafd/trafdump ${PATH_BINDIR_INSTALL}
+ install -c -o root -g ${GROUP} -m ${MODE} traflog/traflog ${PATH_BINDIR_INSTALL}
+ install -o root -g ${GROUP} -m ${MODE} trafstat/trafstat ${PATH_BINDIR_INSTALL}
+ install -o root -g ${GROUP} -m ${MODE} trafstatd/trafstatd ${PATH_BINDIR_INSTALL}
+ install -o root -g ${GROUP} -m ${MODE} traflog/traflog ${PATH_BINDIR_INSTALL}
+ install -c -o root -g ${GROUP} -m ${MODE} traflog/traflog.format ${PATH_CONF_INSTALL}
+ install -c -o root -g ${GROUP} -m 644 README ${PATH_INSTALL_DOC}
@echo Done.
clean:
diff -ru trafd-3.0.1~/trafd/main.c trafd-3.0.1/trafd/main.c
--- trafd-3.0.1~/trafd/main.c 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/trafd/main.c 2006-11-16 21:22:18.000000000 +0100
@@ -86,7 +86,7 @@
static pcap_t *pd;
-void
+int
main(argc, argv)
int argc;
char **argv;
diff -ru trafd-3.0.1~/trafd/Makefile trafd-3.0.1/trafd/Makefile
--- trafd-3.0.1~/trafd/Makefile 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/trafd/Makefile 2006-11-16 21:31:43.000000000 +0100
@@ -5,7 +5,7 @@
PROG = trafd
SRC = main.c traffic.c
OBJ = $(SRC:.c=.o)
-LIB = -lpcap -ll
+LIB = -lpcap -lfl
CC = gcc
FLAGS = -g
DEFINE =
diff -ru trafd-3.0.1~/trafd/trafdump trafd-3.0.1/trafd/trafdump
--- trafd-3.0.1~/trafd/trafdump 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/trafd/trafdump 2006-11-16 21:22:18.000000000 +0100
@@ -1,3 +1,4 @@
+#!/bin/sh
#
# trafdump Copyright (c)1993 CAD lab
#
@@ -18,6 +19,7 @@
for iface in $*; do
PID_FILE=$WHERE_PID$iface
if [ -f $PID_FILE ]; then
+ echo dumping $iface ...
kill -HUP `cat $PID_FILE`
if [ $? = 0 ]; then
echo `date +"%b %e %H:%M:%S"` `hostname -s` trafdump: \
diff -ru trafd-3.0.1~/trafd/traffic.c trafd-3.0.1/trafd/traffic.c
--- trafd-3.0.1~/trafd/traffic.c 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/trafd/traffic.c 2006-11-16 21:22:18.000000000 +0100
@@ -56,10 +56,10 @@
#include <netinet/tcpip.h>
#include <netdb.h>
#include <pcap.h>
+#include <stdlib.h>
#include "interface.h"
#include "traffic.h"
-#include "trafd.h"
#ifdef USE_PIPE
static jmp_buf after_pipe;
@@ -72,6 +72,8 @@
static struct timeval begin_time;
static u_char s_port_big[IPPORT_RESERVED];
+#include "trafd.h"
+
/*
* Initialize traffic collector.
*/
@@ -214,7 +216,7 @@
t.p_port = tp->th_sport, t.who_srv = 1;
else if (tp->th_sport > tp->th_dport)
t.p_port = tp->th_dport, t.who_srv = 2;
- else if (tp->th_sport = tp->th_dport)
+ else if (tp->th_sport == tp->th_dport)
t.p_port = tp->th_sport, t.who_srv = 3;
if (t.p_port > IPPORT_RESERVED) {
if (s_port_big[tp->th_sport & (IPPORT_RESERVED-1)] & IPPROTO_TCP) {
@@ -224,7 +226,7 @@
t.p_port = tp->th_dport;
t.who_srv = 2;
}
- if (tp->th_sport = tp->th_dport) t.who_srv = 3;
+ if (tp->th_sport == tp->th_dport) t.who_srv = 3;
}
traf_add(insertentry(&t), t.n_bytes, t.n_psize);
@@ -261,7 +263,7 @@
t.p_port = up->uh_sport, t.who_srv = 1;
else if (up->uh_sport > up->uh_dport)
t.p_port = up->uh_dport, t.who_srv = 2;
- else if (up->uh_sport = up->uh_dport)
+ else if (up->uh_sport == up->uh_dport)
t.p_port = up->uh_sport, t.who_srv = 3;
if (t.p_port > IPPORT_RESERVED) {
if (s_port_big[up->uh_sport & (IPPORT_RESERVED-1)] & IPPROTO_UDP) {
@@ -271,7 +273,7 @@
t.p_port = up->uh_dport;
t.who_srv = 2;
}
- if (up->uh_sport = up->uh_dport) t.who_srv = 3;
+ if (up->uh_sport == up->uh_dport) t.who_srv = 3;
}
traf_add(insertentry(&t), t.n_bytes, t.n_psize);
diff -ru trafd-3.0.1~/trafd/trafsave trafd-3.0.1/trafd/trafsave
--- trafd-3.0.1~/trafd/trafsave 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/trafd/trafsave 2006-11-16 21:22:18.000000000 +0100
@@ -1,3 +1,4 @@
+#!/bin/sh
#
# trafsave Copyright (c)1993 CAD lab
#
@@ -19,6 +20,7 @@
for iface in $*; do
PID_FILE=$WHERE_PID$iface
if [ -f $PID_FILE ]; then
+ echo saving $iface ...
kill -INT `cat $PID_FILE`
if [ $? = 0 ]; then
echo `date +"%b %e %H:%M:%S"` `hostname -s` trafsave: \
diff -ru trafd-3.0.1~/trafd/trafstart trafd-3.0.1/trafd/trafstart
--- trafd-3.0.1~/trafd/trafstart 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/trafd/trafstart 2006-11-16 21:22:18.000000000 +0100
@@ -1,3 +1,4 @@
+#!/bin/sh
#
# trafstart Copyright (c)1993 CAD lab
#
@@ -18,7 +19,8 @@
#trafd -r -i sl0
# count all ftp traffic passthrough ne0 interface -
#trafd -i ne0 port ftp or ftp-data
-./trafd -p -r -i xl0
+echo starting trafd eth0 ...
+/usr/bin/trafd -p -r -i eth0
#
#echo I am storage, before use invoke editor and edit as your need.
#trafd -?
diff -ru trafd-3.0.1~/trafd/trafstop trafd-3.0.1/trafd/trafstop
--- trafd-3.0.1~/trafd/trafstop 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/trafd/trafstop 2006-11-16 21:22:18.000000000 +0100
@@ -1,3 +1,4 @@
+#!/bin/sh
#
# trafstop Copyright (c)1993 CAD lab
#
@@ -19,6 +20,7 @@
for iface in $*; do
PID_FILE=$WHERE_PID$iface
if [ -f $PID_FILE ]; then
+ echo stopping $iface ...
kill -TERM `cat $PID_FILE`
if [ $? = 0 ]; then
echo `date +"%b %e %H:%M:%S"` `hostname -s` trafstop: \
diff -ru trafd-3.0.1~/traflog/main.c trafd-3.0.1/traflog/main.c
--- trafd-3.0.1~/traflog/main.c 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/traflog/main.c 2006-11-16 21:22:18.000000000 +0100
@@ -42,6 +42,7 @@
#include <sys/stat.h>
#include <sys/param.h>
#include <pcap.h>
+#include <time.h>
#include "../include/interface.h"
#include "../include/addrtoname.h"
diff -ru trafd-3.0.1~/traflog/Makefile trafd-3.0.1/traflog/Makefile
--- trafd-3.0.1~/traflog/Makefile 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/traflog/Makefile 2006-11-16 21:22:18.000000000 +0100
@@ -5,7 +5,7 @@
PROG = traflog
SRC = main.c traflog.c
OBJ = $(SRC:.c=.o)
-LIB = -L../lib -lbpft -ll -lpcap
+LIB = -L../lib -lbpft -lfl -lpcap
CC = gcc
FLAGS = -g
DEFINE =
diff -ru trafd-3.0.1~/traflog/traflog.c trafd-3.0.1/traflog/traflog.c
--- trafd-3.0.1~/traflog/traflog.c 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/traflog/traflog.c 2006-11-16 21:22:18.000000000 +0100
@@ -48,6 +48,7 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <pcap.h>
+#include <time.h>
#include "interface.h"
#include "addrtoname.h"
diff -ru trafd-3.0.1~/trafstat/main.c trafd-3.0.1/trafstat/main.c
--- trafd-3.0.1~/trafstat/main.c 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/trafstat/main.c 2006-11-16 21:22:18.000000000 +0100
@@ -72,7 +72,7 @@
static jmp_buf after_alarm;
-void
+int
main(argc, argv)
int argc;
char **argv;
diff -ru trafd-3.0.1~/trafstatd/trafstatd.c trafd-3.0.1/trafstatd/trafstatd.c
--- trafd-3.0.1~/trafstatd/trafstatd.c 2006-11-16 21:21:56.000000000 +0100
+++ trafd-3.0.1/trafstatd/trafstatd.c 2006-11-16 21:22:18.000000000 +0100
@@ -39,7 +39,7 @@
#define LINELEN 1024
#define ENTRIES 50
-void
+int
main()
{
register FILE *fp;
|