check_icmpv6_connectivity 2.6 KB

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