add intercept-capture script
authorBrendan O'Dea <bod@optus.net>
Wed, 12 Oct 2005 07:16:13 +0000 (07:16 +0000)
committerBrendan O'Dea <bod@optus.net>
Wed, 12 Oct 2005 07:16:13 +0000 (07:16 +0000)
Changes
l2tpns.h
l2tpns.spec
scripts/l2tpns-capture [new file with mode: 0644]

diff --git a/Changes b/Changes
index aee33c3..f769dba 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+* Wed Oct 12 2005 Brendan O'Dea <bod@optus.net> 2.1.10
+- Add scripts/l2tpns-capture.
+
 * Tue Oct 11 2005 Brendan O'Dea <bod@optus.net> 2.1.9
 - Fix Calling-Station-Id in RADIUS accounting records (Slobodan Tomic).
 - Fix RADIUS authentication on DAE responses.
index 46ca4e6..e901d04 100644 (file)
--- a/l2tpns.h
+++ b/l2tpns.h
@@ -1,5 +1,5 @@
 // L2TPNS Global Stuff
-// $Id: l2tpns.h,v 1.94 2005-10-11 07:06:56 bodea Exp $
+// $Id: l2tpns.h,v 1.95 2005-10-12 07:16:13 bodea Exp $
 
 #ifndef __L2TPNS_H__
 #define __L2TPNS_H__
@@ -15,7 +15,7 @@
 #include <sys/types.h>
 #include <libcli.h>
 
-#define VERSION        "2.1.9"
+#define VERSION        "2.1.10"
 
 // Limits
 #define MAXTUNNEL      500             // could be up to 65535
index e1cf5a5..3721f92 100644 (file)
@@ -1,6 +1,6 @@
 Summary: A high-speed clustered L2TP LNS
 Name: l2tpns
-Version: 2.1.9
+Version: 2.1.10
 Release: 1
 Copyright: GPL
 Group: System Environment/Daemons
@@ -43,5 +43,5 @@ rm -rf %{buildroot}
 %attr(644,root,root) /usr/share/man/man[58]/*
 
 %changelog
-* Tue Oct 11 2005 Brendan O'Dea <bod@optus.net> 2.1.9-1
-- 2.1.9 release, see /usr/share/doc/l2tpns-2.1.9/Changes
+* Wed Oct 12 2005 Brendan O'Dea <bod@optus.net> 2.1.10-1
+- 2.1.10 release, see /usr/share/doc/l2tpns-2.1.10/Changes
diff --git a/scripts/l2tpns-capture b/scripts/l2tpns-capture
new file mode 100644 (file)
index 0000000..d675518
--- /dev/null
@@ -0,0 +1,68 @@
+#! /usr/bin/perl -w
+
+#
+# Accept intercept data from l2tpns, write to a file in pcap format
+# (http://wiki.ethereal.com/Development/LibpcapFileFormat) suffixed
+# with timestamp.  Killing the process with SIGHUP causes a new file
+# to be opened.
+#
+
+use strict;
+use IO::File;
+use IO::Socket;
+use Time::HiRes 'gettimeofday';
+
+(my $cmd = $0) =~ s!.*//!!;
+
+die "Usage: $cmd PREFIX PORT\n" unless @ARGV == 2 and $ARGV[1] =~ /^\d+$/;
+
+my ($prefix, $port) = @ARGV;
+my $sock = IO::Socket::INET->new(
+    LocalPort  => $port,
+    Proto      => 'udp',
+    Type       => SOCK_DGRAM,
+) or die "$cmd: can't bind to port $port ($!)\n";
+
+my $restart = 0;
+$SIG{HUP} = sub { $restart++ };
+
+my $header = pack LSSlLLL =>
+    0xa1b2c3d4,        # magic no
+    2,         # version maj
+    4,         # version min
+    0,         # timezone offset (GMT)
+    0,         # timestamp accuracy
+    65536,     # snaplen
+    12;                # link type (RAW_IP)
+
+my $cap;
+my $buf;
+my $file;
+for (;;)
+{
+    unless ($cap)
+    {
+       $file = $prefix . time;
+       $cap = IO::File->new("> $file")
+           or die "$0: can't create capture file $file ($!)\n";
+
+       $cap->print($header)
+           or die "$0: error writing to $file ($!)\n";
+    }
+
+    while ($sock->recv($buf, 1600))
+    {
+       $cap->print(
+           # packet header: sec, usec, included size, original size
+           (pack LLLL => (gettimeofday), (length $buf) x 2),
+           $buf
+       ) or die "$0: error writing to $file ($!)\n";
+    }
+
+    if ($restart)
+    {
+       $restart = 0;
+       $cap->close;
+       undef $cap;
+    }
+}