| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Copyright (c) 2008 Dmitry Butskoy |
| 4 |
# <[email protected]> |
| 5 |
# License: GPL v2 or any later |
| 6 |
# |
| 7 |
# See COPYING for the status of this software. |
| 8 |
# |
| 9 |
|
| 10 |
# |
| 11 |
# Shell wrapper providing tracepath(1) or tracepath6(1) command line interface. |
| 12 |
# |
| 13 |
# The original implementation of tracepath/tracepath6 can be obtained |
| 14 |
# from the iputils package, available at http://www.skbuff.net/iputils/ |
| 15 |
# |
| 16 |
|
| 17 |
opts="-q1 --mtu --back" |
| 18 |
port=44444 |
| 19 |
prgname=$0 |
| 20 |
length="" |
| 21 |
|
| 22 |
|
| 23 |
usage () { |
| 24 |
echo "Usage: $prgname [-nbh] [ -l pktlen ] host[/port]" >&2 |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
PARSED=`getopt -- 'hnbl:' "$@"` |
| 29 |
[ $? != 0 ] && exit 2 |
| 30 |
|
| 31 |
eval set -- "$PARSED" |
| 32 |
|
| 33 |
while [ $# -gt 0 ] |
| 34 |
do |
| 35 |
case "$1" in |
| 36 |
-n) opts="$opts $1"; shift ;; |
| 37 |
-b) shift ;; |
| 38 |
-l) length=$2; shift 2 ;; |
| 39 |
-h) usage ; exit 0 ;; |
| 40 |
--) shift; break ;; |
| 41 |
*) echo "$prgname: Internal parsing error" >&2; exit 2 ;; |
| 42 |
esac |
| 43 |
done |
| 44 |
|
| 45 |
[ $# -eq 0 ] && { |
| 46 |
usage |
| 47 |
exit 2 |
| 48 |
} |
| 49 |
|
| 50 |
host=$1 |
| 51 |
case "$host" in |
| 52 |
*/*) port=${host##*/} |
| 53 |
host=${host%/*} |
| 54 |
;; |
| 55 |
esac |
| 56 |
|
| 57 |
|
| 58 |
case "$prgname" in |
| 59 |
*6) opts="$opts -6" ;; |
| 60 |
esac |
| 61 |
|
| 62 |
exec traceroute $opts -p $port $host $length |
| 63 |
|