1 #! @LOCALPREFIX@/bin/perl
2 # $FreeBSD: src/usr.sbin/setkey/scriptdump.pl,v 1.1.2.3 2001/10/24 19:49:16 ume Exp $
3 # $DragonFly: src/usr.sbin/setkey/scriptdump.pl,v 1.2 2003/06/17 04:30:03 dillon Exp $
6 print STDERR
"must be root to invoke this\n";
11 while ($i = shift @ARGV) {
15 print STDERR
"usage: scriptdump [-d]\n";
20 open(IN
, "setkey -D |") || die;
23 ($src, $dst) = split(/\s+/, $_);
24 } elsif (/^\t(esp|ah) mode=(\S+) spi=(\d+).*reqid=(\d+)/) {
25 ($proto, $ipsecmode, $spi, $reqid) = ($1, $2, $3, $4);
26 } elsif (/^\tE: (\S+) (.*)/) {
31 } elsif (/^\tA: (\S+) (.*)/) {
36 } elsif (/^\tseq=(0x\d+) replay=(\d+) flags=(0x\d+) state=/) {
37 print "$mode $src $dst $proto $spi";
39 print " -u $reqid" if $reqid;
41 print " -m $ipsecmode -r $replay" if $replay;
42 if ($proto eq 'esp') {
43 print " -E $ealgo $ekey" if $ealgo;
44 print " -A $aalgo $akey" if $aalgo;
45 } elsif ($proto eq 'ah') {
46 print " -A $aalgo $akey" if $aalgo;
51 $src = $dst = $upper = $proxy = '';
52 $ealgo = $ekey = $aalgo = $akey = '';