| #!/bin/sh |
| |
| ################################################################################ |
| ## ## |
| ## Copyright (c) International Business Machines Corp., 2005 ## |
| ## ## |
| ## This program is free software; you can redistribute it and#or modify ## |
| ## it under the terms of the GNU General Public License as published by ## |
| ## the Free Software Foundation; either version 2 of the License, or ## |
| ## (at your option) any later version. ## |
| ## ## |
| ## This program is distributed in the hope that it will be useful, but ## |
| ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ## |
| ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## |
| ## for more details. ## |
| ## ## |
| ## You should have received a copy of the GNU General Public License ## |
| ## along with this program; if not, write to the Free Software ## |
| ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## |
| ## ## |
| ## ## |
| ################################################################################ |
| # |
| # File: |
| # check_icmpv6_connectivity |
| # |
| # Description: |
| # Functions for the network stress tests |
| # Check the ICMPv6 connectivity from a interface to a IPv6 address |
| # |
| # Arguments: |
| # $1: source interface name |
| # $2: destination IPv6 address |
| # |
| # Returns: |
| # 0: connectivity is good. |
| # 1: connectivity is something wrong. |
| # |
| # Author: |
| # Mitsuru Chinen <mitch@jp.ibm.com> |
| # |
| # History: |
| # Oct 19 2005 - Created (Mitsuru Chinen) |
| # |
| #----------------------------------------------------------------------- |
| #Uncomment line below for debug output. |
| #trace_logic=${trace_logic:-"set -x"} |
| $trace_logic |
| |
| # The max number of ICMP echo request |
| PING_MAX=10 |
| |
| # Check the arguments |
| if [ $# -ne 2 ]; then |
| echo "Usage: $0 source_interface_name destionation_ipv6_address" >&2 |
| exit 1 |
| fi |
| src_ifname=$1 |
| dst_ipv6addr=$2 |
| |
| cnt=0 |
| while [ $cnt -lt $PING_MAX ]; do |
| cnt=`expr $cnt + 1` |
| ping6 -I $src_ifname -c 1 $dst_ipv6addr -w 1 >/dev/null 2>&1 |
| if [ $? -eq 0 ]; then |
| exit 0 |
| fi |
| sleep 1 |
| done |
| |
| exit 1 |