1#!/bin/sh 2# 3# usage: rtpw_test <rtpw_commands> 4# 5# tests the rtpw sender and receiver functions 6# 7# Copyright (c) 2001-2017, Cisco Systems, Inc. 8# All rights reserved. 9# 10# Redistribution and use in source and binary forms, with or without 11# modification, are permitted provided that the following conditions 12# are met: 13# 14# Redistributions of source code must retain the above copyright 15# notice, this list of conditions and the following disclaimer. 16# 17# Redistributions in binary form must reproduce the above 18# copyright notice, this list of conditions and the following 19# disclaimer in the documentation and/or other materials provided 20# with the distribution. 21# 22# Neither the name of the Cisco Systems, Inc. nor the names of its 23# contributors may be used to endorse or promote products derived 24# from this software without specific prior written permission. 25# 26# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 29# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 30# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 31# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 32# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 33# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 35# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 37# OF THE POSSIBILITY OF SUCH DAMAGE. 38# 39 40case $(uname -s) in 41 *CYGWIN*|*MINGW*) 42 EXE=".exe" 43 ;; 44 *Linux*) 45 EXE="" 46 export LD_LIBRARY_PATH=$CRYPTO_LIBDIR 47 ;; 48 *Darwin*) 49 EXE="" 50 export DYLD_LIBRARY_PATH=$CRYPTO_LIBDIR 51 ;; 52esac 53 54RTPW=./rtpw$EXE 55DEST_PORT=9999 56DURATION=3 57 58key=Ky7cUDT2GnI0XKWYbXv9AYmqbcLsqzL9mvdN9t/G 59 60ARGS="-b $key -a -e 128" 61 62# First, we run "killall" to get rid of all existing rtpw processes. 63# This step also enables this script to clean up after itself; if this 64# script is interrupted after the rtpw processes are started but before 65# they are killed, those processes will linger. Re-running the script 66# will get rid of them. 67 68killall rtpw 2>/dev/null 69 70if test -x $RTPW; then 71 72echo $0 ": starting rtpw receiver process... " 73 74$RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT & 75 76receiver_pid=$! 77 78echo $0 ": receiver PID = $receiver_pid" 79 80sleep 1 81 82# verify that the background job is running 83ps -e | grep -q $receiver_pid 84retval=$? 85echo $retval 86if [ $retval != 0 ]; then 87 echo $0 ": error" 88 exit 254 89fi 90 91echo $0 ": starting rtpw sender process..." 92 93$RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT & 94 95sender_pid=$! 96 97echo $0 ": sender PID = $sender_pid" 98 99# verify that the background job is running 100ps -e | grep -q $sender_pid 101retval=$? 102echo $retval 103if [ $retval != 0 ]; then 104 echo $0 ": error" 105 exit 255 106fi 107 108sleep $DURATION 109 110kill $receiver_pid 111kill $sender_pid 112 113wait $receiver_pid 2>/dev/null 114wait $sender_pid 2>/dev/null 115 116 117key=033490ba9e82994fc21013395739038992b2edc5034f61a72345ca598d7bfd0189aa6dc2ecab32fd9af74df6dfc6 118 119ARGS="-k $key -a -e 256" 120 121echo $0 ": starting rtpw receiver process... " 122 123$RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT & 124 125receiver_pid=$! 126 127echo $0 ": receiver PID = $receiver_pid" 128 129sleep 1 130 131# verify that the background job is running 132ps -e | grep -q $receiver_pid 133retval=$? 134echo $retval 135if [ $retval != 0 ]; then 136 echo $0 ": error" 137 exit 254 138fi 139 140echo $0 ": starting rtpw sender process..." 141 142$RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT & 143 144sender_pid=$! 145 146echo $0 ": sender PID = $sender_pid" 147 148# verify that the background job is running 149ps -e | grep -q $sender_pid 150retval=$? 151echo $retval 152if [ $retval != 0 ]; then 153 echo $0 ": error" 154 exit 255 155fi 156 157sleep $DURATION 158 159kill $receiver_pid 160kill $sender_pid 161 162wait $receiver_pid 2>/dev/null 163wait $sender_pid 2>/dev/null 164 165echo $0 ": done (test passed)" 166 167else 168 169echo "error: can't find executable" $RTPW 170exit 1 171 172fi 173 174# EOF 175 176 177