summaryrefslogtreecommitdiff
path: root/keyexchange/isakmpd-20041012/regress/exchange
diff options
context:
space:
mode:
Diffstat (limited to 'keyexchange/isakmpd-20041012/regress/exchange')
-rw-r--r--keyexchange/isakmpd-20041012/regress/exchange/.cvsignore1
-rw-r--r--keyexchange/isakmpd-20041012/regress/exchange/Makefile58
-rw-r--r--keyexchange/isakmpd-20041012/regress/exchange/README78
-rw-r--r--keyexchange/isakmpd-20041012/regress/exchange/def-i.1bin0 -> 72 bytes
-rw-r--r--keyexchange/isakmpd-20041012/regress/exchange/def-r.1bin0 -> 72 bytes
-rw-r--r--keyexchange/isakmpd-20041012/regress/exchange/mm-1-setup.sh12
-rw-r--r--keyexchange/isakmpd-20041012/regress/exchange/mm-i-1.t43
-rw-r--r--keyexchange/isakmpd-20041012/regress/exchange/mm-r-1.t42
-rw-r--r--keyexchange/isakmpd-20041012/regress/exchange/run.pl105
-rw-r--r--keyexchange/isakmpd-20041012/regress/exchange/run.sh137
10 files changed, 476 insertions, 0 deletions
diff --git a/keyexchange/isakmpd-20041012/regress/exchange/.cvsignore b/keyexchange/isakmpd-20041012/regress/exchange/.cvsignore
new file mode 100644
index 0000000..b672fde
--- /dev/null
+++ b/keyexchange/isakmpd-20041012/regress/exchange/.cvsignore
@@ -0,0 +1 @@
+obj
diff --git a/keyexchange/isakmpd-20041012/regress/exchange/Makefile b/keyexchange/isakmpd-20041012/regress/exchange/Makefile
new file mode 100644
index 0000000..ac22db8
--- /dev/null
+++ b/keyexchange/isakmpd-20041012/regress/exchange/Makefile
@@ -0,0 +1,58 @@
+# $OpenBSD: Makefile,v 1.7 2003/06/03 14:39:50 ho Exp $
+# $EOM: Makefile,v 1.8 2000/03/28 21:22:07 ho Exp $
+
+#
+# Copyright (c) 1998, 1999 Niklas Hallqvist. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+#
+# This code was written under funding by Ericsson Radio Systems.
+#
+
+TOPSRC= ${.CURDIR}/../..
+TOPOBJ!= cd ${TOPSRC}; printf "all:\n\t@pwd\n" |${MAKE} -f-
+OS!= awk '/^OS=/ { print $$2 }' ${.CURDIR}/../../Makefile
+.PATH: ${TOPSRC} ${TOPSRC}/sysdep/${OS} ${TOPOBJ}
+CFLAGS+= -I${TOPSRC} -I${TOPSRC}/sysdep/${OS} -I${TOPOBJ} -Wall
+RUN= ISAKMPD=${TOPOBJ}/isakmpd ${.CURDIR}/run.sh
+
+TESTS= def
+
+all:
+
+test: ${TESTS:S/^/test-/}
+
+.for TEST in ${TESTS}
+test-${TEST}:
+.ifdef ONLY_INIT
+ @echo Testing "${TEST}" test as initiator
+ @${RUN} ${RUNFLAGS} ${.CURDIR}/${TEST}
+.endif
+.ifdef ONLY_RESP
+ @echo Testing "${TEST}" test as responder
+ @${RUN} -r ${RUNFLAGS} ${.CURDIR}/${TEST}
+.endif
+.endfor
+
+.include <bsd.obj.mk>
+.include <bsd.subdir.mk>
diff --git a/keyexchange/isakmpd-20041012/regress/exchange/README b/keyexchange/isakmpd-20041012/regress/exchange/README
new file mode 100644
index 0000000..cd1555b
--- /dev/null
+++ b/keyexchange/isakmpd-20041012/regress/exchange/README
@@ -0,0 +1,78 @@
+$OpenBSD: README,v 1.1 1999/08/05 22:41:39 niklas Exp $
+$EOM: README,v 1.1 1999/08/05 15:07:37 niklas Exp $
+
+XXX The old run.sh test-framework is obsoleted, it will go away anyday.
+
+We wanted to do a regression test environment which was flexible
+enough to be able to easily reproduce anomalies in isakmpd. It
+turns out this is not easy to do, as many problems are timing related.
+
+Currently ticks are milliseconds. An idea is to try to measure
+isakmpd's response time somehow, and use that time as some kind of
+basis for a tick.
+
+Our test environment should be able to parse scripts like this:
+
+#Tick Action Format Data
+0 send H* ffffffff
+0 recv H* 00000000
+1000 send H* deadbeef
+
+Ticks are not absolute but relative to the last event. the format is
+Perl's pack/unpack template formats. Data is in the given format with
+one exception, spaces are ignored, newlines are end-of-data unless
+preceeded by a backslash.
+
+Comments are lines with a numbersign as the first non-whitespace
+character. Empty lines are ignored, unless inside a multi-line data
+in which it will be part of the data buffer.
+
+Here is a real world example:
+
+# $RCSId$
+
+# Initiate a MM
+0 send H* ad9de636 f12460bb 00000000 00000000 01100200 00000000 \
+ 00000050 00000034 00000001 00000001 00000028 01010001 \
+ 00000020 00010000 80010005 80020002 80030001 80040002 \
+ 800b0001 800c0258
+
+400 recv H* ad9de636 f12460bb 2aa5a583 ab2f3980 01100200 00000000 \
+ 00000050 00000034 00000001 00000001 00000028 01010001 \
+ 00000020 00010000 80010005 80020002 80030001 80040002 \
+ 800b0001 800c0258
+
+110 send H* ad9de636 f12460bb 2aa5a583 ab2f3980 04100200 00000000 \
+ 000000b4 0a000084 60a8c102 ce97687e 45e3fdd9 6fd586b4 \
+ f3a91167 559dd214 a78d678e 2772b7b2 83267487 15ec02a9 \
+ 419b77ee 0f2add09 e9e09b7d ad40c883 ef2039c9 c59b67ff \
+ 56e4d6f8 c99d47cb d4a565bc 8d192f76 f695d243 09121df5 \
+ 524884a7 3f702630 7f4fad44 e222c4b1 242fd1cd ca3a161d \
+ bcdf6706 025cc90d c4b00ef9 bee5ada2 00000014 ff7c493c \
+ 88e68a10 4ab19a6a 7e75c771
+
+800 recv H* ad9de636 f12460bb 2aa5a583 ab2f3980 04100200 00000000 \
+ 000000b4 0a000084 681b9859 7680a3ff 894bb982 ef924bc8 \
+ 4d9c7ebf 3a92db7b bcfe68f7 6e1de327 a975293f f5c550b1 \
+ 9c69d6ed 64f201ec 514f4f44 0e6242b9 df4917e6 4418212d \
+ 66a66eb1 f3b70c2d 4e14e382 d42ebe04 1027957c 5dadcaf1 \
+ a531c085 6cee739f 433c185c 12a8a946 88622f66 f211783c \
+ 277e134d 22d8e809 f1d38bab 6ca2a35f 00000014 6a917048 \
+ a406fd47 b3d16554 cd6f0967
+
+140 send H* ad9de636 f12460bb 2aa5a583 ab2f3980 05100201 00000000 \
+ 0000005c d6571dec a8b55acb 1069210c 7d195417 1c2738e9 \
+ 42f1d9a3 8561d0ec 0697cd06 ac1beb19 1dc8acf5 904ec1d5 \
+ 5b2b154e 38b0de90 4f2e1f71 083047ca 10cab3d5
+
+900 recv H* ad9de636 f12460bb 2aa5a583 ab2f3980 05100201 00000000 \
+ 00000044 b46b1db4 9ecfbfa6 a5e9baa2 8eb3cb68 be3a857c \
+ b039fa72 d595e69f 03669dbd 350781e2 56c36dce
+
+run with:
+
+perl run.pl filename
+
+You need to have an isakmpd listening on the address which is given in
+run.pl. Of course you need to run it in deterministic mode (-r).
+There will be a better explanation soon.
diff --git a/keyexchange/isakmpd-20041012/regress/exchange/def-i.1 b/keyexchange/isakmpd-20041012/regress/exchange/def-i.1
new file mode 100644
index 0000000..1712249
--- /dev/null
+++ b/keyexchange/isakmpd-20041012/regress/exchange/def-i.1
Binary files differ
diff --git a/keyexchange/isakmpd-20041012/regress/exchange/def-r.1 b/keyexchange/isakmpd-20041012/regress/exchange/def-r.1
new file mode 100644
index 0000000..56f5e62
--- /dev/null
+++ b/keyexchange/isakmpd-20041012/regress/exchange/def-r.1
Binary files differ
diff --git a/keyexchange/isakmpd-20041012/regress/exchange/mm-1-setup.sh b/keyexchange/isakmpd-20041012/regress/exchange/mm-1-setup.sh
new file mode 100644
index 0000000..0efd7c9
--- /dev/null
+++ b/keyexchange/isakmpd-20041012/regress/exchange/mm-1-setup.sh
@@ -0,0 +1,12 @@
+# $OpenBSD: mm-1-setup.sh,v 1.2 2000/01/26 15:23:52 niklas Exp $
+# $EOM: mm-1-setup.sh,v 1.2 1999/10/05 12:54:27 niklas Exp $
+
+# XXX Need to start isakmpd here in a nice way.
+
+echo "C set [Phase 1]:127.0.0.1=localhost 1">/tmp/fifo
+echo "C set [localhost]:phase=1 1">/tmp/fifo
+echo "C set [localhost]:transport=udp 1">/tmp/fifo
+echo "C set [localhost]:address=127.0.0.1 1">/tmp/fifo
+echo "C set [localhost]:port=1501 1">/tmp/fifo
+echo "C set [localhost]:configuration=default-main-mode 1">/tmp/fifo
+echo "C set [localhost]:authentication=mekmitasdigoat 1">/tmp/fifo
diff --git a/keyexchange/isakmpd-20041012/regress/exchange/mm-i-1.t b/keyexchange/isakmpd-20041012/regress/exchange/mm-i-1.t
new file mode 100644
index 0000000..9f9b1be
--- /dev/null
+++ b/keyexchange/isakmpd-20041012/regress/exchange/mm-i-1.t
@@ -0,0 +1,43 @@
+# $OpenBSD: mm-i-1.t,v 1.1 1999/08/05 22:41:39 niklas Exp $
+# $EOM: mm-i-1.t,v 1.1 1999/08/05 15:07:38 niklas Exp $
+
+# The seed to isakmpd was 19990805
+
+# Initiate a MM
+0 send H* ad9de636 f12460bb 00000000 00000000 01100200 00000000 \
+ 00000050 00000034 00000001 00000001 00000028 01010001 \
+ 00000020 00010000 80010005 80020002 80030001 80040002 \
+ 800b0001 800c0258
+
+400 recv H* ad9de636 f12460bb 2aa5a583 ab2f3980 01100200 00000000 \
+ 00000050 00000034 00000001 00000001 00000028 01010001 \
+ 00000020 00010000 80010005 80020002 80030001 80040002 \
+ 800b0001 800c0258
+
+110 send H* ad9de636 f12460bb 2aa5a583 ab2f3980 04100200 00000000 \
+ 000000b4 0a000084 60a8c102 ce97687e 45e3fdd9 6fd586b4 \
+ f3a91167 559dd214 a78d678e 2772b7b2 83267487 15ec02a9 \
+ 419b77ee 0f2add09 e9e09b7d ad40c883 ef2039c9 c59b67ff \
+ 56e4d6f8 c99d47cb d4a565bc 8d192f76 f695d243 09121df5 \
+ 524884a7 3f702630 7f4fad44 e222c4b1 242fd1cd ca3a161d \
+ bcdf6706 025cc90d c4b00ef9 bee5ada2 00000014 ff7c493c \
+ 88e68a10 4ab19a6a 7e75c771
+
+800 recv H* ad9de636 f12460bb 2aa5a583 ab2f3980 04100200 00000000 \
+ 000000b4 0a000084 681b9859 7680a3ff 894bb982 ef924bc8 \
+ 4d9c7ebf 3a92db7b bcfe68f7 6e1de327 a975293f f5c550b1 \
+ 9c69d6ed 64f201ec 514f4f44 0e6242b9 df4917e6 4418212d \
+ 66a66eb1 f3b70c2d 4e14e382 d42ebe04 1027957c 5dadcaf1 \
+ a531c085 6cee739f 433c185c 12a8a946 88622f66 f211783c \
+ 277e134d 22d8e809 f1d38bab 6ca2a35f 00000014 6a917048 \
+ a406fd47 b3d16554 cd6f0967
+
+140 send H* ad9de636 f12460bb 2aa5a583 ab2f3980 05100201 00000000 \
+ 0000005c d6571dec a8b55acb 1069210c 7d195417 1c2738e9 \
+ 42f1d9a3 8561d0ec 0697cd06 ac1beb19 1dc8acf5 904ec1d5 \
+ 5b2b154e 38b0de90 4f2e1f71 083047ca 10cab3d5
+
+900 recv H* ad9de636 f12460bb 2aa5a583 ab2f3980 05100201 00000000 \
+ 00000044 b46b1db4 9ecfbfa6 a5e9baa2 8eb3cb68 be3a857c \
+ b039fa72 d595e69f 03669dbd 350781e2 56c36dce
+
diff --git a/keyexchange/isakmpd-20041012/regress/exchange/mm-r-1.t b/keyexchange/isakmpd-20041012/regress/exchange/mm-r-1.t
new file mode 100644
index 0000000..0c48224
--- /dev/null
+++ b/keyexchange/isakmpd-20041012/regress/exchange/mm-r-1.t
@@ -0,0 +1,42 @@
+# $OpenBSD: mm-r-1.t,v 1.1 1999/08/05 22:41:39 niklas Exp $
+# $EOM: mm-r-1.t,v 1.1 1999/08/05 15:07:38 niklas Exp $
+
+# The seed to isakmpd was 19990805
+
+# Respond to this MM
+999999 recv H* ad9de636 f12460bb 00000000 00000000 01100200 00000000 \
+ 00000050 00000034 00000001 00000001 00000028 01010001 \
+ 00000020 00010000 80010005 80020002 80030001 80040002 \
+ 800b0001 800c0258
+
+40 send H* ad9de636 f12460bb 2aa5a583 ab2f3980 01100200 00000000 \
+ 00000050 00000034 00000001 00000001 00000028 01010001 \
+ 00000020 00010000 80010005 80020002 80030001 80040002 \
+ 800b0001 800c0258
+
+1100 recv H* ad9de636 f12460bb 2aa5a583 ab2f3980 04100200 00000000 \
+ 000000b4 0a000084 60a8c102 ce97687e 45e3fdd9 6fd586b4 \
+ f3a91167 559dd214 a78d678e 2772b7b2 83267487 15ec02a9 \
+ 419b77ee 0f2add09 e9e09b7d ad40c883 ef2039c9 c59b67ff \
+ 56e4d6f8 c99d47cb d4a565bc 8d192f76 f695d243 09121df5 \
+ 524884a7 3f702630 7f4fad44 e222c4b1 242fd1cd ca3a161d \
+ bcdf6706 025cc90d c4b00ef9 bee5ada2 00000014 ff7c493c \
+ 88e68a10 4ab19a6a 7e75c771
+
+80 send H* ad9de636 f12460bb 2aa5a583 ab2f3980 04100200 00000000 \
+ 000000b4 0a000084 681b9859 7680a3ff 894bb982 ef924bc8 \
+ 4d9c7ebf 3a92db7b bcfe68f7 6e1de327 a975293f f5c550b1 \
+ 9c69d6ed 64f201ec 514f4f44 0e6242b9 df4917e6 4418212d \
+ 66a66eb1 f3b70c2d 4e14e382 d42ebe04 1027957c 5dadcaf1 \
+ a531c085 6cee739f 433c185c 12a8a946 88622f66 f211783c \
+ 277e134d 22d8e809 f1d38bab 6ca2a35f 00000014 6a917048 \
+ a406fd47 b3d16554 cd6f0967
+
+1400 recv H* ad9de636 f12460bb 2aa5a583 ab2f3980 05100201 00000000 \
+ 0000005c d6571dec a8b55acb 1069210c 7d195417 1c2738e9 \
+ 42f1d9a3 8561d0ec 0697cd06 ac1beb19 1dc8acf5 904ec1d5 \
+ 5b2b154e 38b0de90 4f2e1f71 083047ca 10cab3d5
+
+90 send H* ad9de636 f12460bb 2aa5a583 ab2f3980 05100201 00000000 \
+ 00000044 b46b1db4 9ecfbfa6 a5e9baa2 8eb3cb68 be3a857c \
+ b039fa72 d595e69f 03669dbd 350781e2 56c36dce
diff --git a/keyexchange/isakmpd-20041012/regress/exchange/run.pl b/keyexchange/isakmpd-20041012/regress/exchange/run.pl
new file mode 100644
index 0000000..d9fce2d
--- /dev/null
+++ b/keyexchange/isakmpd-20041012/regress/exchange/run.pl
@@ -0,0 +1,105 @@
+#!/usr/bin/perl
+# $OpenBSD: run.pl,v 1.2 2004/01/26 14:56:03 niklas Exp $
+# $EOM: run.pl,v 1.2 1999/08/05 22:42:42 niklas Exp $
+
+#
+# Copyright (c) 2004 Niklas Hallqvist. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+use strict;
+require 5.002;
+require 'sys/syscall.ph';
+use Socket;
+use Sys::Hostname;
+
+my ($rfd, $tickfac, $myaddr, $myport, $hisaddr, $hisport, $proto, $bindaddr,
+ $conaddr, $sec, $tick, $action, $template, $data, $next,
+ $nfd, $pkt, $verbose);
+
+$| = 1;
+
+$verbose = 1;
+$tickfac = 0.001;
+$myaddr = gethostbyname ('127.0.0.1');
+$myport = 1501;
+ $hisaddr = inet_aton ('127.0.0.1');
+$hisport = 1500;
+
+$proto = getprotobyname ('udp');
+$bindaddr = sockaddr_in ($myport, $myaddr);
+socket (SOCKET, PF_INET, SOCK_DGRAM, $proto) || die "socket: $!";
+bind (SOCKET, $bindaddr);
+vec ($rfd, fileno SOCKET, 1) = 1;
+
+$conaddr = sockaddr_in ($hisport, $hisaddr);
+
+sub getsec
+{
+ my ($tv) = pack ("ll", 0, 0);
+ my ($tz) = pack ("ii", 0, 0);
+ syscall (&SYS_gettimeofday, $tv, $tz) && return undef;
+ my ($sec, $usec) = unpack ("ll", $tv);
+ $sec % 86400 + $usec / 1000000;
+}
+
+$sec = &getsec;
+while (<>) {
+ next if /^\s*#/o || /^\s*$/o;
+ chop;
+ ($tick, $action, $template, $data) = split ' ', $_, 4;
+ while ($data =~ /\\$/o) {
+ chop $data;
+ $_ = <>;
+ next if /^\s*#/o;
+ chop;
+ $data .= $_;
+ }
+ $data =~ s/\s//go;
+ $data = pack $template, $data;
+ $next = $sec + $tick * $tickfac;
+ if ($action eq "send") {
+ # Wait for the moment to come.
+ print STDERR "waiting ", $next - $sec, " secs\n";
+ select undef, undef, undef, $next - $sec
+ while ($sec = &getsec) < $next;
+# print $data;
+ send SOCKET, $data, 0, $conaddr;
+ print STDERR "sent ", unpack ("H*", $data), "\n" if $verbose;
+ } elsif ($action eq "recv") {
+ $sec = &getsec;
+ printf (STDERR "waiting for data or the %.3f sec timeout\n",
+ $next - $sec);
+ $nfd = select $rfd, undef, undef, $next - $sec;
+ if ($nfd) {
+ printf STDERR "got back after %.3f secs\n", &getsec - $sec
+ if $verbose;
+# sysread (STDIN, $pkt, 65536) if $nfd;
+ sysread (SOCKET, $pkt, 65536) if $nfd;
+ print STDERR "read ", unpack ("H*", $pkt), "\n" if $verbose;
+ print STDERR "cmp ", unpack ("H*", $data), "\n" if $verbose;
+ } else {
+ print STDERR "timed out\n" if $verbose;
+ }
+ die "mismatch\n" if $pkt ne $data;
+ }
+}
diff --git a/keyexchange/isakmpd-20041012/regress/exchange/run.sh b/keyexchange/isakmpd-20041012/regress/exchange/run.sh
new file mode 100644
index 0000000..587c2c1
--- /dev/null
+++ b/keyexchange/isakmpd-20041012/regress/exchange/run.sh
@@ -0,0 +1,137 @@
+#!/bin/sh
+# $OpenBSD: run.sh,v 1.8 2004/01/09 10:03:04 hshoexer Exp $
+# $EOM: run.sh,v 1.6 1999/08/05 15:02:33 niklas Exp $
+
+#
+# Copyright (c) 1998, 1999 Niklas Hallqvist. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+#
+# This code was written under funding by Ericsson Radio Systems.
+#
+
+# Defaults
+SRCPORT=1500
+DSTPORT=1501
+FIFO=test.fifo
+TIMEOUT=2
+
+NC=${NC:-/usr/bin/nc}
+ISAKMPD=${ISAKMPD:-/sbin/isakmpd}
+
+progname=`basename $0`
+indent=`echo -n $progname |sed 's/./ /g'`
+seed=980801
+initiator=yes
+retval=0
+verbose=no
+clean=yes
+
+usage ()
+{
+ echo "usage: $progname [-nrv] [-d dst-port] [-f fifo] [-s src-port]" >&2
+ echo " $indent [-t timeout] testsuite" >&2
+ exit 2
+}
+
+set -- `getopt d:f:nrs:t:v $*`
+if [ $? != 0 ]; then
+ usage
+fi
+for i; do
+ case "$i" in
+ -d)
+ DSTPORT=$2; shift; shift;;
+ -f)
+ FIFO=$2; shift; shift;;
+ -n)
+ clean=no; shift;;
+ -r)
+ initiator=no; shift;;
+ -s)
+ SRCPORT=$2; shift; shift;;
+ -t)
+ TIMEOUT=$2; shift; shift;;
+ -v)
+ verbose=yes; shift;;
+ --)
+ shift; break;;
+ esac
+done
+
+if [ $# -eq 1 ]; then
+ suite=$1
+else
+ usage
+fi
+
+[ ${verbose} = yes ] && set -x
+
+# Start isakmpd and wait for the fifo to get created
+rm -f ${FIFO}
+${ISAKMPD} -d -p${SRCPORT} -f${FIFO} -r${seed} &
+isakmpd_pid=$!
+trap 'kill $isakmpd_pid; rm -f${FIFO}; [ $clean = yes ] && rm -f packet' 1 2 15
+while [ ! -p ${FIFO} ]; do
+ sleep 1
+done
+
+# Start the exchange
+if [ $initiator = yes ]; then
+ ${NC} -nul -w${TIMEOUT} 127.0.0.1 ${DSTPORT} </dev/null >packet &
+# ${NC} -nu -w${TIMEOUT} -p${SRCPORT} 127.0.0.1 ${DSTPORT} </dev/null >packet
+ sleep 1
+ echo "c udp 127.0.0.1:${DSTPORT} 2 1" >${FIFO}
+ in_packets=`ls ${suite}-i.* 2>/dev/null`
+ out_packets=`ls ${suite}-r.* 2>/dev/null`
+else
+ in_packets=`ls ${suite}-r.* 2>/dev/null`
+ out_packets=`ls ${suite}-i.* 2>/dev/null`
+fi
+his_turn=$initiator
+while [ \( $his_turn = yes -a X"$in_packets" != X \) \
+ -o \( $his_turn = no -a X"$out_packets" != X \) ]; do
+ if [ $his_turn = no ]; then
+ set $out_packets
+ packet=$1
+ shift
+ out_packets=$*
+ cat $packet |${NC} -nu -w${TIMEOUT} -p${SRCPORT} 127.0.0.1 ${DSTPORT} \
+ >packet
+ my_turn=no
+ else
+ set $in_packets
+ packet=$1
+ shift
+ in_packets=$*
+ if ! cmp $packet packet 2>/dev/null; then
+ retval=1
+ break
+ fi
+ my_turn=yes
+ fi
+done
+kill $isakmpd_pid
+rm -f ${FIFO}
+[ $clean = yes ] && rm -f packet
+exit $retval