diff options
author | Yoshinobu Inoue <shin@FreeBSD.org> | 2000-01-06 12:40:54 +0000 |
---|---|---|
committer | Yoshinobu Inoue <shin@FreeBSD.org> | 2000-01-06 12:40:54 +0000 |
commit | 9a4365d0e0833374e893c519639bde71756aa104 (patch) | |
tree | 0fa615bec427848e939cbb6c31fed401f162edbb /sbin/setkey/scriptdump.pl | |
parent | 171eec1876b8c1cf601856138ec2f53771c1e32b (diff) | |
download | src-9a4365d0e0833374e893c519639bde71756aa104.tar.gz src-9a4365d0e0833374e893c519639bde71756aa104.zip |
libipsec and IPsec related apps. (and some KAME related man pages)
Reviewed by: freebsd-arch, cvs-committers
Obtained from: KAME project
Notes
Notes:
svn path=/head/; revision=55505
Diffstat (limited to 'sbin/setkey/scriptdump.pl')
-rw-r--r-- | sbin/setkey/scriptdump.pl | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/sbin/setkey/scriptdump.pl b/sbin/setkey/scriptdump.pl new file mode 100644 index 000000000000..5df9b4f4fd7b --- /dev/null +++ b/sbin/setkey/scriptdump.pl @@ -0,0 +1,54 @@ +#! @LOCALPREFIX@/bin/perl +# $FreeBSD$ + +if ($< != 0) { + print STDERR "must be root to invoke this\n"; + exit 1; +} + +$mode = 'add'; +while ($i = shift @ARGV) { + if ($i eq '-d') { + $mode = 'delete'; + } else { + print STDERR "usage: scriptdump [-d]\n"; + exit 1; + } +} + +open(IN, "setkey -D |") || die; +foreach $_ (<IN>) { + if (/^[^\t]/) { + ($src, $dst) = split(/\s+/, $_); + } elsif (/^\t(esp|ah) mode=(\S+) spi=(\d+).*replay=(\d+)/) { + ($proto, $ipsecmode, $spi, $replay) = ($1, $2, $3, $4); + } elsif (/^\tE: (\S+) (.*)/) { + $ealgo = $1; + $ekey = $2; + $ekey =~ s/\s//g; + $ekey =~ s/^/0x/g; + } elsif (/^\tA: (\S+) (.*)/) { + $aalgo = $1; + $akey = $2; + $akey =~ s/\s//g; + $akey =~ s/^/0x/g; + } elsif (/^\tstate=/) { + print "$mode $src $dst $proto $spi -m $ipsecmode"; + print " -r $replay" if $replay; + if ($mode eq 'add') { + if ($proto eq 'esp') { + print " -E $ealgo $ekey" if $ealgo; + print " -A $aalgo $akey" if $aalgo; + } elsif ($proto eq 'ah') { + print " -A $aalgo $akey" if $aalgo; + } + } + print ";\n"; + + $src = $dst = $upper = $proxy = ''; + $ealgo = $ekey = $aalgo = $akey = ''; + } +} +close(IN); + +exit 0; |