• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2
3################################################################################
4##                                                                            ##
5## Copyright (c) International Business Machines  Corp., 2005                 ##
6##                                                                            ##
7## This program is free software;  you can redistribute it and#or modify      ##
8## it under the terms of the GNU General Public License as published by       ##
9## the Free Software Foundation; either version 2 of the License, or          ##
10## (at your option) any later version.                                        ##
11##                                                                            ##
12## This program is distributed in the hope that it will be useful, but        ##
13## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
14## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
15## for more details.                                                          ##
16##                                                                            ##
17## You should have received a copy of the GNU General Public License          ##
18## along with this program;  if not, write to the Free Software               ##
19## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
20##                                                                            ##
21##                                                                            ##
22################################################################################
23#
24# File:
25#   check_icmpv6_connectivity
26#
27# Description:
28#   Functions for the network stress tests
29#   Check the ICMPv6 connectivity from a interface to a IPv6 address
30#
31# Arguments:
32#   $1: source interface name
33#   $2: destination IPv6 address
34#
35# Returns:
36#   0: connectivity is good.
37#   1: connectivity is something wrong.
38#
39# Author:
40#   Mitsuru Chinen <mitch@jp.ibm.com>
41#
42# History:
43#   Oct 19 2005 - Created (Mitsuru Chinen)
44#
45#-----------------------------------------------------------------------
46#Uncomment line below for debug output.
47#trace_logic=${trace_logic:-"set -x"}
48$trace_logic
49
50# The max number of ICMP echo request
51PING_MAX=10
52
53# Check the arguments
54if [ $# -ne 2 ]; then
55    echo "Usage: $0 source_interface_name destionation_ipv6_address" >&2
56    exit 1
57fi
58src_ifname=$1
59dst_ipv6addr=$2
60
61cnt=0
62while [ $cnt -lt $PING_MAX ]; do
63    cnt=`expr $cnt + 1`
64    ping6 -I $src_ifname -c 1 $dst_ipv6addr -w 1 >/dev/null 2>&1
65    if [ $? -eq 0 ]; then
66	exit 0
67    fi
68    sleep 1
69done
70
71exit 1
72