pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/net/tcpflow Include a set of patches from Jukka Salmi ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/710d2047dc3a
branches:  trunk
changeset: 505315:710d2047dc3a
user:      adrianp <adrianp%pkgsrc.org@localhost>
date:      Mon Jan 02 19:23:40 2006 +0000

description:
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:

 net/tcpflow/Makefile         |   3 +-
 net/tcpflow/distinfo         |   6 ++-
 net/tcpflow/patches/patch-ab |  60 ++++++++++++++++++++++++++++
 net/tcpflow/patches/patch-ac |  13 ++++++
 net/tcpflow/patches/patch-ad |  92 ++++++++++++++++++++++++++++++++++++++++++++
 net/tcpflow/patches/patch-ae |  29 +++++++++++++
 6 files changed, 201 insertions(+), 2 deletions(-)

diffs (238 lines):

diff -r 5802b54cf990 -r 710d2047dc3a net/tcpflow/Makefile
--- a/net/tcpflow/Makefile      Mon Jan 02 18:56:20 2006 +0000
+++ b/net/tcpflow/Makefile      Mon Jan 02 19:23:40 2006 +0000
@@ -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 -r 5802b54cf990 -r 710d2047dc3a net/tcpflow/distinfo
--- a/net/tcpflow/distinfo      Mon Jan 02 18:56:20 2006 +0000
+++ b/net/tcpflow/distinfo      Mon Jan 02 19:23:40 2006 +0000
@@ -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 -r 5802b54cf990 -r 710d2047dc3a net/tcpflow/patches/patch-ab
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/tcpflow/patches/patch-ab      Mon Jan 02 19:23:40 2006 +0000
@@ -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@localhost>\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 -r 5802b54cf990 -r 710d2047dc3a net/tcpflow/patches/patch-ac
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/tcpflow/patches/patch-ac      Mon Jan 02 19:23:40 2006 +0000
@@ -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 -r 5802b54cf990 -r 710d2047dc3a net/tcpflow/patches/patch-ad
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/tcpflow/patches/patch-ad      Mon Jan 02 19:23:40 2006 +0000
@@ -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 -r 5802b54cf990 -r 710d2047dc3a net/tcpflow/patches/patch-ae
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/tcpflow/patches/patch-ae      Mon Jan 02 19:23:40 2006 +0000
@@ -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.



Home | Main Index | Thread Index | Old Index