1#!/bin/sh 2# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 3# Copyright (c) International Business Machines Corp., 2000 4# 5# This program is free software; you can redistribute it and/or 6# modify it under the terms of the GNU General Public License as 7# published by the Free Software Foundation; either version 2 of 8# the License, or (at your option) any later version. 9# 10# This program is distributed in the hope that it would be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write the Free Software Foundation, 17# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18# 19# TEST DESCRIPTION: 20# To verify that IP Multicast can be used to send UDP datagrams 21# between two or more nodes on the same subnetwork using 22# a specific IP Multicast group and a specific port address. 23# 24# Authors: 25# Robbie Williamson (robbiew@us.ibm.com) 26# Michael Reed mreedltp@vnet.ibm.com 27 28TTL=10 29OUTFILE=mc_commo_out 30 31TCID=mc_commo 32TST_TOTAL=2 33 34TST_USE_LEGACY_API=1 35. tst_net.sh 36 37do_setup() 38{ 39 tst_require_cmds netstat pgrep 40 41 OCTET=$(ps -ewf | grep [m]c_commo | wc -l | awk '{print $1}') 42 GROUP_ADDR=224.0.0.$OCTET 43 PORT=$(tst_get_unused_port ipv4 dgram) 44 tst_tmpdir 45} 46 47do_test() 48{ 49 # Run setsockopt/getsockopt test 50 # Start up the recv on local host 51 tst_resm TINFO "Start mc_recv $GROUP_ADDR $(tst_ipaddr) $PORT" 52 mc_recv $GROUP_ADDR $(tst_ipaddr) $PORT >> $OUTFILE & 53 SERVER_PID=$! 54 sleep 5 55 pgrep -x mc_recv > /dev/null || \ 56 tst_brkm TFAIL "Could NOT start mc_recv on $(tst_ipaddr)" 57 58 grep -q "cannot join group" $OUTFILE && \ 59 tst_brkm TFAIL "Membership NOT set" 60 61 netstat -ng | grep -q $GROUP_ADDR || \ 62 tst_brkm TFAIL "membership not set for $GROUP_ADDR" 63 64 tst_resm TINFO "Start on $RHOST mc_send $GROUP_ADDR" \ 65 "$(tst_ipaddr rhost) $PORT $TTL" 66 67 tst_rhost_run -b -c "mc_send $GROUP_ADDR $(tst_ipaddr rhost) $PORT $TTL" 68 sleep 10 69 tst_rhost_run -s -c "pgrep -x mc_send > /dev/null" 70 71 tst_resm TINFO "Waiting for 100 sec.! Do not interrupt." 72 sleep 100 #wait until datagrams are received in $STATUS 73 74 #test if datagrams has been sent 75 grep -q "$(tst_ipaddr rhost) [0-9] [0-9]" $OUTFILE || \ 76 tst_brkm TFAIL "NO Datagrams received from $RHOST" 77 78 tst_resm TPASS "Test Successful" 79} 80 81do_cleanup() 82{ 83 ps -p $SERVER_PID > /dev/null 2>&1 84 if [ $? -eq 0 ]; then 85 kill -9 $SERVER_PID 86 fi 87 88 tst_rmdir 89} 90 91do_setup 92TST_CLEANUP=do_cleanup 93 94for i in $(seq 1 $TST_TOTAL); do 95 do_test 96done 97 98tst_exit 99