Debian Codegraph @

wrappers/lft

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/bin/sh
2 #
3 # Copyright (c) 2007 Dmitry K. 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 lft(8) command line interface.
12 #
13 # The original implementation of lft(8) can be obtained
14 # from http://pwhois.org/lft/
15 #
16
17
18 prgname=$0
19 opts=""
20 length=""
21 method="-T"
22
23 dport=""
24 sport=""
25 queries=2
26 ahead=5
27 scatter=20
28 timeout=1000
29
30
31 usage () {
32 echo "Usage: $prgname [-ACEFINRSTUVbehinpruvz] [-d dport] [-s sport]
33 [-m retry min] [-M retry max] [-a ahead] [-c scatter ms] [-t timeout ms]
34 [-l min ttl] [-H max ttl] [-L length] [-q ISN] [-D device] [--help]
35 [gateway ...] target:dport" >&2
36 }
37
38 warning () {
39 echo "$prgname: Option '$1' is not implemented in this wrapper" >&2
40 }
41
42
43 PARSED=`getopt -o 'ACEFINRSTUVbehinpruvzd:s:m:M:a:c:t:l:H:L:q:D:' -l help -- "$@"`
44 [ $? != 0 ] && exit 2
45
46 eval set -- "$PARSED"
47
48 while [ $# -gt 0 ]
49 do
50 case "$1" in
51 -d) dport=$2; shift 2 ;;
52 -s) sport=$2; shift 2 ;;
53 -z) sport=""; shift ;;
54 -m) queries=$2; shift 2 ;;
55 -a) ahead=$2; shift 2 ;;
56 -c) scatter=$2; shift 2 ;;
57 -t) timeout=$2; shift 2 ;;
58 -l) opts="$opts -f $2"; shift 2 ;;
59 -L) length=$2; shift 2 ;;
60 -D) case "$2" in
61 [0-9]*) opts="$opts -s $2" ;;
62 *) opts="$opts -i $2" ;;
63 esac
64 shift 2
65 ;;
66 -H) opts="$opts -m $2"; shift 2 ;;
67 -I) opts="$opts -t 0x10"; shift ;;
68 -n) opts="$opts -n"; shift ;;
69 -h) shift ;;
70 -F) opts="$opts -O fin"; shift ;;
71 -u) method="-U"; shift ;;
72 -N) opts="$opts -A"; shift ;;
73 -p) method="-I"; shift ;;
74 -b) shift ;;
75 -A) opts="$opts -A"; shift ;;
76 -[ieErCTUV]) warning $1; shift ;;
77 -[Mq]) warning $1; shift 2 ;;
78 -[RS]) shift ;;
79 --help) usage; exit 0 ;;
80 -v) echo "\"lft\"-compatible wrapper for new Linux Traceroute" >&2;
81 exit 0 ;;
82 --) shift; break ;;
83 *) echo "$prgname: Internal parsing error" >&2; exit 2 ;;
84 esac
85 done
86
87 while [ $# -gt 1 ]
88 do
89 opts="$opts -g $1"
90 shift
91 done
92
93 [ $# -eq 0 ] && {
94 usage
95 exit 2
96 }
97
98 case "$1" in
99 *:*:*) host=$1 ;;
100 *:*) dport=${1##*:}; host=${1%:*} ;;
101 *) host=$1 ;;
102 esac
103
104 [ -n "$dport" ] && opts="$opts -p $dport"
105 [ -n "$sport" ] && opts="$opts --sport=$sport"
106 opts="$opts -q $queries"
107 opts="$opts -N $(($ahead * $queries))"
108 opts="$opts -z $scatter"
109
110 timeout=`printf "%04d" $timeout`
111 sec=${timeout%???}
112 opts="$opts -w $sec.${timeout#$sec}"
113
114 opts="$method $opts"
115
116 exec traceroute $opts $host $length
117