Differential D20086 Diff 56792 head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh
Changeset View
Changeset View
Standalone View
Standalone View
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localsctpstate.ksh
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
fi | fi | ||||
dtrace=$1 | dtrace=$1 | ||||
local=127.0.0.1 | local=127.0.0.1 | ||||
DIR=/var/tmp/dtest.$$ | DIR=/var/tmp/dtest.$$ | ||||
sctpport=1024 | sctpport=1024 | ||||
bound=5000 | bound=5000 | ||||
while [ $sctpport -lt $bound ]; do | |||||
ncat --sctp -z $local $sctpport > /dev/null || break | |||||
sctpport=$(($sctpport + 1)) | |||||
done | |||||
if [ $sctpport -eq $bound ]; then | |||||
echo "couldn't find an available SCTP port" | |||||
exit 1 | |||||
fi | |||||
mkdir $DIR | mkdir $DIR | ||||
cd $DIR | cd $DIR | ||||
# ncat will exit when the association is closed. | cat > client.pl <<-EOPERL | ||||
ncat --sctp --listen $local $sctpport & | |||||
cat > test.pl <<-EOPERL | |||||
use IO::Socket; | use IO::Socket; | ||||
my \$s = IO::Socket::INET->new( | my \$s = IO::Socket::INET->new( | ||||
Type => SOCK_STREAM, | Type => SOCK_STREAM, | ||||
Proto => "sctp", | Proto => "sctp", | ||||
LocalAddr => "$local", | LocalAddr => "$local", | ||||
PeerAddr => "$local", | PeerAddr => "$local", | ||||
PeerPort => $sctpport, | PeerPort => \$ARGV[0], | ||||
Timeout => 3); | Timeout => 3); | ||||
die "Could not connect to host $local port $sctpport \$@" unless \$s; | die "Could not connect to host $local port \$ARGV[0] \$@" unless \$s; | ||||
close \$s; | close \$s; | ||||
sleep(2); | sleep(\$ARGV[1]); | ||||
EOPERL | EOPERL | ||||
$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE | while [ $sctpport -lt $bound ]; do | ||||
perl client.pl $sctpport 0 2>&- || break | |||||
sctpport=$(($sctpport + 1)) | |||||
done | |||||
if [ $sctpport -eq $bound ]; then | |||||
echo "couldn't find an available SCTP port" | |||||
exit 1 | |||||
fi | |||||
cat > server.pl <<-EOPERL | |||||
use IO::Socket; | |||||
my \$l = IO::Socket::INET->new( | |||||
Type => SOCK_STREAM, | |||||
Proto => "sctp", | |||||
LocalAddr => "$local", | |||||
LocalPort => $sctpport, | |||||
Listen => 1, | |||||
Reuse => 1); | |||||
die "Could not listen on $local port $sctpport \$@" unless \$l; | |||||
my \$c = \$l->accept(); | |||||
close \$l; | |||||
while (<\$c>) {}; | |||||
close \$c; | |||||
EOPERL | |||||
perl server.pl & | |||||
$dtrace -c "perl client.pl $sctpport 2" -qs /dev/stdin <<EODTRACE | |||||
BEGIN | BEGIN | ||||
{ | { | ||||
ipsend = sctpsend = ipreceive = sctpreceive = 0; | ipsend = sctpsend = ipreceive = sctpreceive = 0; | ||||
} | } | ||||
ip:::send | ip:::send | ||||
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && | /args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && | ||||
args[4]->ipv4_protocol == IPPROTO_SCTP/ | args[4]->ipv4_protocol == IPPROTO_SCTP/ | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |