summaryrefslogtreecommitdiff
path: root/net/tcpflow
diff options
context:
space:
mode:
authoradrianp <adrianp@pkgsrc.org>2006-01-02 19:23:40 +0000
committeradrianp <adrianp@pkgsrc.org>2006-01-02 19:23:40 +0000
commit13de95056ad7217e465747847a18980e5929f525 (patch)
tree34dfdc0c5c0b621239f893590a9f4dee7271ea0f /net/tcpflow
parentbeeaf65738d5b8724fbee3b4c85d9e0b0939ffea (diff)
downloadpkgsrc-13de95056ad7217e465747847a18980e5929f525.tar.gz
Include a set of patches from Jukka Salmi in PR# 30805
The patches are a modified version of some enhancements to tcpflow from Debian Adds the following options: -e When outputting to the console each flow will be output in alternating colours. -C Console print without the packet source and destination details being printed. Print the contents of packets to stdout as they are received, without storing any captured data to files (implies -s).
Diffstat (limited to 'net/tcpflow')
-rw-r--r--net/tcpflow/Makefile3
-rw-r--r--net/tcpflow/distinfo6
-rw-r--r--net/tcpflow/patches/patch-ab60
-rw-r--r--net/tcpflow/patches/patch-ac13
-rw-r--r--net/tcpflow/patches/patch-ad92
-rw-r--r--net/tcpflow/patches/patch-ae29
6 files changed, 201 insertions, 2 deletions
diff --git a/net/tcpflow/Makefile b/net/tcpflow/Makefile
index 63ebcc221ef..c569250e050 100644
--- a/net/tcpflow/Makefile
+++ b/net/tcpflow/Makefile
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.5 2005/04/11 21:47:00 tv Exp $
+# $NetBSD: Makefile,v 1.6 2006/01/02 19:23:40 adrianp Exp $
#
DISTNAME= tcpflow-0.21
+PKGREVISION= 1
CATEGORIES= net security
MASTER_SITES= http://www.circlemud.org/pub/jelson/tcpflow/
diff --git a/net/tcpflow/distinfo b/net/tcpflow/distinfo
index 0dcbf7c2e5d..8592bae927b 100644
--- a/net/tcpflow/distinfo
+++ b/net/tcpflow/distinfo
@@ -1,6 +1,10 @@
-$NetBSD: distinfo,v 1.5 2005/02/24 12:14:05 agc Exp $
+$NetBSD: distinfo,v 1.6 2006/01/02 19:23:40 adrianp Exp $
SHA1 (tcpflow-0.21.tar.gz) = 08eeb8532e1f713db2587580d759ebad813a0b49
RMD160 (tcpflow-0.21.tar.gz) = 250ed27f1a49f4eda4b274857c11762be8261209
Size (tcpflow-0.21.tar.gz) = 79369 bytes
SHA1 (patch-aa) = afea3a5b0fb01ac9af87f63881fdf502dc082899
+SHA1 (patch-ab) = f506c51be721f5dcd484028edc3cd0fa56b795fa
+SHA1 (patch-ac) = 78a92e7e6407810e77799c00d2b3b42ba2522a32
+SHA1 (patch-ad) = d0162fab2dcc226c3bf8a5e0d1daec58faa378f7
+SHA1 (patch-ae) = d858f06b73cbe04001fd9a4a65742df45a157a37
diff --git a/net/tcpflow/patches/patch-ab b/net/tcpflow/patches/patch-ab
new file mode 100644
index 00000000000..db1cc8d152f
--- /dev/null
+++ b/net/tcpflow/patches/patch-ab
@@ -0,0 +1,60 @@
+$NetBSD: patch-ab,v 1.1 2006/01/02 19:23:40 adrianp Exp $
+
+--- src/main.c.orig 2003-08-07 08:35:24.000000000 +0100
++++ src/main.c
+@@ -70,7 +70,9 @@ int bytes_per_flow = 0;
+ int max_flows = 0;
+ int max_desired_fds = 0;
+ int console_only = 0;
++int supress_header = 0;
+ int strip_nonprint = 0;
++int use_colour = 0;
+
+ char error[PCAP_ERRBUF_SIZE];
+
+@@ -79,11 +81,13 @@ void print_usage(char *progname)
+ {
+ fprintf(stderr, "%s version %s by Jeremy Elson <jelson@circlemud.org>\n\n",
+ PACKAGE, VERSION);
+- fprintf(stderr, "usage: %s [-chpsv] [-b max_bytes] [-d debug_level] [-f max_fds]\n", progname);
++ fprintf(stderr, "usage: %s [-cCehpsv] [-b max_bytes] [-d debug_level] [-f max_fds]\n", progname);
+ fprintf(stderr, " [-i iface] [-w file] [expression]\n\n");
+ fprintf(stderr, " -b: max number of bytes per flow to save\n");
+ fprintf(stderr, " -c: console print only (don't create files)\n");
++ fprintf(stderr, " -C: console print only, but without the display of source/dest header\n");
+ fprintf(stderr, " -d: debug level; default is %d\n", DEFAULT_DEBUG_LEVEL);
++ fprintf(stderr, " -e: use colours when printing to console\n");
+ fprintf(stderr, " -f: maximum number of file descriptors to use\n");
+ fprintf(stderr, " -h: print this help message\n");
+ fprintf(stderr, " -i: network interface on which to listen\n");
+@@ -124,7 +128,7 @@ int main(int argc, char *argv[])
+
+ opterr = 0;
+
+- while ((arg = getopt(argc, argv, "b:cd:f:hi:pr:sv")) != EOF) {
++ while ((arg = getopt(argc, argv, "b:cCd:ef:hi:pr:sv")) != EOF) {
+ switch (arg) {
+ case 'b':
+ if ((bytes_per_flow = atoi(optarg)) < 0) {
+@@ -134,6 +138,10 @@ int main(int argc, char *argv[])
+ DEBUG(10) ("capturing max of %d bytes per flow", bytes_per_flow);
+ }
+ break;
++ case 'C':
++ supress_header = 1;
++ DEBUG(10) ("packet header dump suppressed");
++ /* fall through */
+ case 'c':
+ console_only = 1;
+ DEBUG(10) ("printing packets to console only");
+@@ -148,6 +156,10 @@ int main(int argc, char *argv[])
+ DEBUG(1) ("warning: -d flag with 0 debug level '%s'", optarg);
+ }
+ break;
++ case 'e':
++ use_colour = 1;
++ DEBUG(10) ("Using colours");
++ break;
+ case 'f':
+ if ((max_desired_fds = atoi(optarg)) < (NUM_RESERVED_FDS + 2)) {
+ DEBUG(1) ("warning: -f flag must be used with argument >= %d",
diff --git a/net/tcpflow/patches/patch-ac b/net/tcpflow/patches/patch-ac
new file mode 100644
index 00000000000..00382e67526
--- /dev/null
+++ b/net/tcpflow/patches/patch-ac
@@ -0,0 +1,13 @@
+$NetBSD: patch-ac,v 1.1 2006/01/02 19:23:40 adrianp Exp $
+
+--- src/tcpflow.h.orig 2001-08-08 20:39:40.000000000 +0100
++++ src/tcpflow.h
+@@ -133,7 +133,7 @@ void process_tcp(const u_char *data, u_i
+ u_int32_t dst);
+ void print_packet(flow_t flow, const u_char *data, u_int32_t length);
+ void store_packet(flow_t flow, const u_char *data, u_int32_t length,
+- u_int32_t seq);
++ u_int32_t seq, int syn_set);
+ u_char *do_strip_nonprint(const u_char *data, u_int32_t length);
+
+ /* flow.c */
diff --git a/net/tcpflow/patches/patch-ad b/net/tcpflow/patches/patch-ad
new file mode 100644
index 00000000000..5ed6968bf4f
--- /dev/null
+++ b/net/tcpflow/patches/patch-ad
@@ -0,0 +1,92 @@
+$NetBSD: patch-ad,v 1.1 2006/01/02 19:23:40 adrianp Exp $
+
+--- src/tcpip.c.orig 2001-08-24 06:36:14.000000000 +0100
++++ src/tcpip.c
+@@ -55,8 +55,11 @@ static char *cvsid = "$Id: tcpip.c,v 1.1
+ #include "tcpflow.h"
+
+ extern int console_only;
++extern int supress_header;
+ extern int bytes_per_flow;
+ extern int strip_nonprint;
++extern int use_colour;
++
+
+ /*************************************************************************/
+
+@@ -133,7 +136,7 @@ void process_tcp(const u_char *data, u_i
+ tcp_header_len = tcp_header->th_off * 4;
+
+ /* return if this packet doesn't have any data (e.g., just an ACK) */
+- if (length <= tcp_header_len) {
++ if (length <= tcp_header_len && tcp_header->th_flags != TH_SYN ) {
+ DEBUG(50) ("got TCP segment with no data");
+ return;
+ }
+@@ -158,7 +161,7 @@ void process_tcp(const u_char *data, u_i
+ if (console_only) {
+ print_packet(this_flow, data, length);
+ } else {
+- store_packet(this_flow, data, length, seq);
++ store_packet(this_flow, data, length, seq, IS_SET(tcp_header->th_flags, TH_SYN));
+ }
+ }
+
+@@ -188,8 +191,34 @@ u_char *do_strip_nonprint(const u_char *
+ /* print the contents of this packet to the console */
+ void print_packet(flow_t flow, const u_char *data, u_int32_t length)
+ {
+- printf("%s: ", flow_filename(flow));
++ static int current_colour = 0;
++ char *colour[2] = { "\033[0;34m", // blue
++ "\033[0;31m" }; // red
++
++ if ( use_colour )
++ {
++ printf( "%s", colour[ current_colour ] );
++ if ( current_colour == 1 )
++ {
++ current_colour = 0;
++ }
++ else
++ {
++ current_colour = 1;
++ }
++ }
++
++ if ( supress_header == 0 )
++ {
++ printf("%s: ", flow_filename(flow));
++ }
++
+ fwrite(data, length, 1, stdout);
++
++ if ( use_colour )
++ {
++ printf("\033[0m");
++ }
+ putchar('\n');
+ fflush(stdout);
+ }
+@@ -197,7 +226,7 @@ void print_packet(flow_t flow, const u_c
+
+ /* store the contents of this packet to its place in its file */
+ void store_packet(flow_t flow, const u_char *data, u_int32_t length,
+- u_int32_t seq)
++ u_int32_t seq, int syn_set)
+ {
+ flow_state_t *state;
+ tcp_seq offset;
+@@ -208,6 +237,12 @@ void store_packet(flow_t flow, const u_c
+ state = create_flow_state(flow, seq);
+ }
+
++ /* If we got a SYN reset the sequence number */
++ if (syn_set)
++ {
++ state->isn = seq - state->pos +1;
++ }
++
+ /* if we're done collecting for this flow, return now */
+ if (IS_SET(state->flags, FLOW_FINISHED))
+ return;
diff --git a/net/tcpflow/patches/patch-ae b/net/tcpflow/patches/patch-ae
new file mode 100644
index 00000000000..f50272d7074
--- /dev/null
+++ b/net/tcpflow/patches/patch-ae
@@ -0,0 +1,29 @@
+$NetBSD: patch-ae,v 1.1 2006/01/02 19:23:40 adrianp Exp $
+
+--- doc/tcpflow.1.in.orig 2001-02-26 23:01:30.000000000 +0000
++++ doc/tcpflow.1.in
+@@ -6,7 +6,7 @@ tcpflow \- TCP flow recorder
+ .na
+ .B tcpflow
+ [\c
+-.BI \-chpsv\fR\c
++.BI \-cCehpsv\fR\c
+ ]
+ [\c
+ .BI \-b \ max_bytes\fR\c
+@@ -62,6 +62,15 @@ are received, without storing any captur
+ .B -s
+ ).
+ .TP
++.B \-C
++Console print without the packet source and destination details being printed. Print the contents of packets to stdout as they
++are received, without storing any captured data to files (implies
++.B -s
++).
++.TP
++.B \-e
++When outputting to the console each flow will be output in alternating colours.
++.TP
+ .B \-d
+ Debug level. Set the level of debugging messages printed to stderr to
+ \fIdebug_level\fP. Higher numbers produce more messages.