Imported Upstream version 2.1.21

This commit is contained in:
Benjamin Cama 2011-07-07 12:45:05 +02:00
commit f2a3180cc0
57 changed files with 24656 additions and 0 deletions

68
scripts/l2tpns-capture Normal file
View file

@ -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;
}
}

28
scripts/l2tpns-monitor Normal file
View file

@ -0,0 +1,28 @@
#!/bin/sh
stopfile=/tmp/l2tpns.stop
first=`date +%s`
min_first_time=3
restart_delay=5
prog=${0##*/}
while :
do
echo "`date`: Starting l2tpns $@"
start=`date +%s`
/usr/sbin/l2tpns ${1+"$@"}
RETVAL=$?
stop=`date +%s`
t=$(($stop - $start));
first=$(($stop - $first));
echo "`date`: l2tpns exited after $t seconds, status $RETVAL"
if [ $first -lt $min_first_time ]; then
echo "`date`: l2tpns exited immediately, $prog exiting"
exit $RETVAL
fi
if [ -f $stopfile ]; then
ls -l $stopfile
echo "`date`: stop file found, $prog exiting"
exit
fi
sleep $restart_delay
done >>/var/log/$prog 2>&1 & # execute in background

93
scripts/l2tpns.script Normal file
View file

@ -0,0 +1,93 @@
#!/bin/bash
#
# Startup script for l2tpns
#
# chkconfig: 2345 83 25
# description: l2tpns.
# processname: l2tpns
# pidfile: /var/run/l2tpns.pid
# config: /etc/l2tpns
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/lt2pns ]; then
. /etc/sysconfig/lt2pns
fi
# Path to the l2tpns-monitor script, server binary, and short-form for messages.
l2tpns_monitor=/usr/sbin/l2tpns-monitor
l2tpns=/usr/sbin/l2tpns
prog=${l2tpns##*/}
RETVAL=0
start() {
echo -n $"Starting $prog: "
rm -f /tmp/l2tpns.stop
daemon --check=$prog $l2tpns_monitor $OPTIONS
RETVAL=$?
echo
sleep 5
pid=`pidofproc $l2tpns_monitor`
if [ -z "$pid" ] || [ "$pid" -eq 0 ]; then
echo -n "Error starting $prog"
echo_failure
echo
return 99
fi
[ $RETVAL = 0 ] && touch /var/lock/subsys/l2tpns
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
echo >/tmp/l2tpns.stop
killproc $l2tpns
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/l2tpns /var/run/l2tpns.pid
}
reload() {
echo -n $"Reloading $prog: "
killproc $l2tpns -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $l2tpns
RETVAL=$?
;;
restart)
stop
sleep 5
start
;;
condrestart)
if [ -f /var/run/l2tpns.pid ] ; then
stop
start
fi
;;
reload)
reload
;;
coldrestart)
stop
sleep 10
rm -f /tmp/l2tpns.dump
start
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|coldrestart}"
exit 1
esac
exit $RETVAL