home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / bin / traceproto.db < prev    next >
Encoding:
Text File  |  2010-07-18  |  2.8 KB  |  128 lines

  1. #!/bin/sh
  2. #
  3. #   Copyright (c)  2007             Dmitry K. Butskoy
  4. #                                   <buc@citadel.stu.neva.ru>
  5. #   License:  GPL v2 or any later
  6. #
  7. #   See COPYING for the status of this software.
  8. #
  9.  
  10. #
  11. #  Shell wrapper providing traceproto(8) command line interface.
  12. #
  13. #  The original implementation of traceproto(8) can be obtained
  14. #  from http://traceproto.sourceforge.net/
  15. #
  16.  
  17.  
  18. prgname=$0
  19. opts=""
  20. length=""
  21. method="tcp"
  22. sendwait=100
  23. cont=""
  24. iface=$TP_DEFAULT_IF
  25.  
  26.  
  27. usage () {
  28.     echo "Usage: $prgname [-cCTfAhvR] [-p protocol] [-d dst_port] [-D max_dst_port]
  29.     [-s src_port] [-S max_src_port] [-m min_ttl] [-M max_ttl] [-w response_timeout]
  30.     [-W send_delay] [-a account_level] [-P payload_size]
  31.     [-F interface] [-k skips] [-I consecutive_trace_count]
  32.     [-H packets_per_hop] [-i incr_pattern] [-o output_style] [-t tcp_flags]
  33.     target" >&2
  34. }
  35.  
  36. warning () {
  37.     echo "$prgname: Option '$1' is not implemented in this wrapper" >&2
  38. }
  39.  
  40.  
  41. PARSED=`getopt 'cCTfAhvRp:d:D:s:S:m:M:w:W:a:P:F:k:I:H:i:o:t:' "$@"`
  42. [ $? != 0 ] && exit 2
  43.  
  44. eval set -- "$PARSED"
  45.  
  46. while [ $# -gt 0 ]
  47. do
  48.     case "$1" in
  49.     -p)  method=$2; shift 2 ;;
  50.     -d)  opts="$opts -p $2"; shift 2 ;;
  51.     -s)  opts="$opts --sport=$2"; shift 2 ;;
  52.     -m)  opts="$opts -f $2"; shift 2 ;;
  53.     -M)  opts="$opts -m $2"; shift 2 ;;
  54.     -w)  opts="$opts -w $2"; shift 2 ;;
  55.     -W)  sendwait=$2; shift 2 ;;
  56.     -P)  length=$2; shift 2 ;;
  57.     -c)  cont=100000; shift ;;
  58.     -I)  cont=$2; shift 2 ;;
  59.     -H)  opts="$opts -q $2"; shift 2 ;;
  60.     -f)  opts="$opts -F"; shift ;;
  61.     -F)  iface=$2; shift 2 ;;
  62.     -A)  opts="$opts -A"; shift ;;
  63.     -o)  [ $2 != "c" ] && warning $1; shift 2 ;;
  64.     -t)  case $2 in
  65.         *S*)  opts="$opts -O syn" ;;
  66.          esac
  67.          case $2 in
  68.         *A*)  opts="$opts -O ack" ;;
  69.          esac
  70.          case $2 in
  71.         *R*)  opts="$opts -O rst" ;;
  72.          esac
  73.          case $2 in
  74.         *U*)  opts="$opts -O urg" ;;
  75.          esac
  76.          case $2 in
  77.         *P*)  opts="$opts -O psh" ;;
  78.          esac
  79.          case $2 in
  80.         *F*)  opts="$opts -O fin" ;;
  81.          esac
  82.          case $2 in
  83.         *E*)  opts="$opts -O ece" ;;
  84.          esac
  85.          case $2 in
  86.         *C*)  opts="$opts -O cwr" ;;
  87.          esac
  88.          shift 2 ;;
  89.     -[DSaki])  warning $1; shift 2 ;;
  90.     -[TCR])  warning $1; shift ;;
  91.     -h)  usage; exit 0 ;;
  92.     -v)  echo "\"traceproto\"-compatible wrapper for new Linux Traceroute" >&2;
  93.          exit 0 ;;
  94.     --)  shift; break ;;
  95.     *)  echo "$prgname: Internal parsing error" >&2; exit 2 ;;
  96.     esac
  97. done
  98.  
  99.  
  100.  
  101. [ $# -eq 0 ] && {
  102.     usage
  103.     exit 2
  104. }
  105.  
  106. host=$1
  107.  
  108.  
  109. opts="-M $method $opts"
  110. opts="$opts -z $sendwait"
  111. [ -n "$iface" ] && opts="$opts -i $iface"
  112.  
  113. [ -n "$TP_OUTPUT_STYLE" -a "$TP_OUTPUT_STYLE" != "classic" ] && {
  114.     echo "$prgname: warning: only classic output style supported" >&2
  115. }
  116.  
  117. [ -n "$TP_RA_SERVER" -a -z "$RA_SERVER" ] && RA_SERVER=$TP_RA_SERVER
  118.  
  119.  
  120. [ -z "$cont" ] && exec traceroute $opts $host $length
  121.  
  122. while [ "$cont" -gt 0 ]
  123. do
  124.     cont=$(($cont - 1))
  125.     /usr/bin/traceroute.db $opts $host $length
  126. done
  127.  
  128.