and added files
[bcm963xx.git] / userapps / opensource / ipsec-tools / src / racoon / contrib / sp.pl
diff --git a/userapps/opensource/ipsec-tools/src/racoon/contrib/sp.pl b/userapps/opensource/ipsec-tools/src/racoon/contrib/sp.pl
new file mode 100755 (executable)
index 0000000..d1f9caf
--- /dev/null
@@ -0,0 +1,21 @@
+#! /usr/pkg/bin/perl
+
+die "insufficient arguments" if (scalar(@ARGV) < 2);
+$src = $ARGV[0];
+$dst = $ARGV[1];
+$mode = 'transport';
+if (scalar(@ARGV) > 2) {
+       $mode = $ARGV[2];
+}
+
+open(OUT, "|setkey -c");
+if ($mode eq 'transport') {
+       print STDERR "install esp transport mode: $src -> $dst\n";
+       print OUT "spdadd $src $dst any -P out ipsec esp/transport//require;\n";
+       print OUT "spdadd $dst $src any -P in ipsec esp/transport//require;\n";
+} elsif ($mode eq 'delete') {
+       print STDERR "delete policy: $src -> $dst\n";
+       print OUT "spddelete $src $dst any -P out;\n";
+       print OUT "spddelete $dst $src any -P in;\n";
+}
+close(OUT);