]> The Tcpdump Group git mirrors - tcpdump/blob - tests/setkey2esp-secrets.pl
CHANGES: Move change(s) backported to 4.99
[tcpdump] / tests / setkey2esp-secrets.pl
1 #!/usr/local/bin/perl
2 #
3 # usage:
4 # setkey -D | perl thisfile > secrets.txt
5 # tcpdump -n -E "file secrets.txt"
6 #
7 while (<>) {
8 if (/^(\S+)\s+(\S+)/) {
9 $src = $1;
10 $dst = $2;
11 next;
12 }
13 if (/^\s+esp.*spi=(\d+)/) {
14 $spi = $1;
15 next;
16 }
17 if (/^\s+E:\s+(\S+)\s+(.*)$/) {
18 $algo = $1. "-hmac96";
19 ($secret = $2) =~ s/\s+//g;
20
21 printf"0x%x@%s %s:0x%s\n", $spi, $dst, $algo, $secret;
22 next;
23 }
24 }