2 # $FreeBSD: src/usr.sbin/setkey/scriptdump.pl,v 1.1.2.3 2001/10/24 19:49:16 ume Exp $
5 print STDERR
"must be root to invoke this\n";
10 while ($i = shift @ARGV) {
14 print STDERR
"usage: scriptdump [-d]\n";
19 open(IN
, "setkey -D |") || die;
22 ($src, $dst) = split(/\s+/, $_);
23 } elsif (/^\t(esp|ah) mode=(\S+) spi=(\d+).*reqid=(\d+)/) {
24 ($proto, $ipsecmode, $spi, $reqid) = ($1, $2, $3, $4);
25 } elsif (/^\tE: (\S+) (.*)/) {
30 } elsif (/^\tA: (\S+) (.*)/) {
35 } elsif (/^\tseq=(0x\d+) replay=(\d+) flags=(0x\d+) state=/) {
36 print "$mode $src $dst $proto $spi";
38 print " -u $reqid" if $reqid;
40 print " -m $ipsecmode -r $replay" if $replay;
41 if ($proto eq 'esp') {
42 print " -E $ealgo $ekey" if $ealgo;
43 print " -A $aalgo $akey" if $aalgo;
44 } elsif ($proto eq 'ah') {
45 print " -A $aalgo $akey" if $aalgo;
50 $src = $dst = $upper = $proxy = '';
51 $ealgo = $ekey = $aalgo = $akey = '';