Package: guessnet
Version: 0.41-1
Severity: wishlist
Tags: patch
I'm including the scripts test-wireless, test-wireless-ap,
test-wirelsess-scan with an --help interface implemented in bare
sh. Other than this addition, the beahaviour of the scripts is the
same.
Thanks for guessnet.
Cheers.
-- System Information:
Debian Release: 3.1
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17.11.061003.eramil
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Versions of packages guessnet depends on:
ii libc6 2.3.6-7 GNU C Library: Shared libraries
ii libgcc1 1:4.1.1-13 GCC support library
ii libnet1 1.1.2.1-2 library for the construction and h
ii libpcap0.7 0.7.2-7 System interface for user-level pa
ii libstdc++6 4.1.1-13 The GNU Standard C++ Library v3
guessnet recommends no packages.
-- no debconf information
#!/bin/sh
#
# test-wireless
# History
# Oct 2004: Written by Thomas Hood
set -o errexit # -e
set -o noglob # -f
MYNAME="$(basename $0)"
PATH=/sbin:/bin
usage() {
cat <<EOT
Usage:
$MYNAME <IFACE> [mac <MACADDRESS>] [essid <ESSID>]
$MYNAME --help|-h
Tests whether the current interface has the appropriate MAC address
and/or the appropriate ESSID.
MACADDRESS letters must be in upper case
Licensed under the GNU GPL. See /usr/share/common-licenses/GPL.
Options:
-h|--help Print this help
EOT
}
report_err() { echo "${MYNAME}: Error: $*" >&2 ; }
do_sleep() { LANG=C sleep "$@" ; }
if [ "$1" = "--help" ] || [ "$1" == "-h" ]; then
usage
exit 0
fi
IFACE="$1"
[ "$IFACE" ] || { report_err "Interface not specified. Exiting." ; exit 1 ; }
shift
while [ "$1" ] ; do
case "$1" in
mac)
MAC_ADDRESS="$2"
shift
;;
essid)
ESSID="$2"
shift
;;
esac
shift
done
[ "$MAC_ADDRESS" ] || [ "$ESSID" ] || { report_err "Neither AP MAC address nor
ESSID specified. Exiting." ; exit 1 ; }
FAILED=0
do_sleep 0.5
if [ "$MAC_ADDRESS" ] ; then
ACTUAL_MAC_ADDRESS="$(iwgetid "$IFACE" --ap)"
ACTUAL_MAC_ADDRESS="${ACTUAL_MAC_ADDRESS#*Cell:}"
ACTUAL_MAC_ADDRESS="${ACTUAL_MAC_ADDRESS# }"
ACTUAL_MAC_ADDRESS="${ACTUAL_MAC_ADDRESS% }"
[ "$ACTUAL_MAC_ADDRESS" = "$MAC_ADDRESS" ] || FAILED=1
fi
if [ "$FAILED" = 0 ] && [ "$ESSID" ] ; then
ACTUAL_ESSID="$(iwgetid "$IFACE")"
ACTUAL_ESSID="${ACTUAL_ESSID#*ESSID:\"}"
ACTUAL_ESSID="${ACTUAL_ESSID%\"*}"
[ "$ACTUAL_ESSID" = "$ESSID" ] || FAILED=1
fi
exit "$FAILED"
#!/bin/bash
# Need bash because we use ${.../...}
#
# test-wireless-ap
# Licensed under the GNU GPL. See /usr/share/common-licenses/GPL.
#
# History
# May 2005: Bugs fixed by Christoph Biedl and Thomas Hood
# Nov 2003: Modified by Thomas Hood and Klaus Wacker
# July 2003: Modified by Thomas Hood to support Aironet cards
# June 2003: Modified by John Fettig <[EMAIL PROTECTED]>
# Jan 2003: Derived from testssid by Andrew McMillan <[EMAIL PROTECTED]>
# Written by Thomas Hood <[EMAIL PROTECTED]>
set -o errexit # -e
set -o noglob # -f
MYNAME="$(basename $0)"
PATH=/sbin:/bin
ESSID=""
MAC_ADDRESS=""
usage() {
cat <<EOT
Usage:
$MYNAME [--timeout=TIMEOUT] <IFACE> [<AP_MAC_ADDRESS>] [<IWCONFIG_ARG>]...
$MYNAME --help|-h
Tests whether the wireless card can associate to an access
point using the given iwconfig argument pairs essid ESSID
key 123456 and so on.
Options:
--help|-h Print this help.
EOT
}
report_err() { echo "${MYNAME}: Error: $*" >&2 ; }
do_sleep() { LANG=C sleep "$@" ; }
is_ethernet_mac()
{
[ "$1" ] && [ !
"${1/[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]/}"
]
}
# Set ESSID to string following 'essid' in the array of function arguments
extract_ESSID()
{
while [ "$1" ] ; do
[ "$1" = "essid" ] && { ESSID="$2" ; return 0 ; }
shift
done
}
if [ "$1" = "--help" ] || [ "$1" == "-h" ]; then
usage
exit 0
fi
TIMEOUT=3
case "$1" in
--timeout) TIMEOUT="$2" ; shift 2 ;;
--timeout=*) TIMEOUT="${1#--timeout=}" ; shift ;;
esac
IFACE="$1"
shift
[ "$IFACE" ] || { report_err "Interface not specified. Exiting." ; exit 1 ; }
if is_ethernet_mac "$1" ; then
MAC_ADDRESS="$1"
shift
fi
extract_ESSID "$@"
[ "$1" ] && iwconfig "$IFACE" "$@"
ifconfig "$IFACE" up
for (( TIMELEFT="$TIMEOUT" ; TIMELEFT > 0 ; TIMELEFT-- )) ; do
FAILED=0
if [ "$ESSID" ] ; then
# Check that interface ESSID is what we are looking for
ACTUAL_ESSID="$(iwgetid $IFACE)"
ACTUAL_ESSID="${ACTUAL_ESSID#*ESSID:}"
ACTUAL_ESSID="${ACTUAL_ESSID# }"
ACTUAL_ESSID="${ACTUAL_ESSID#\"}"
ACTUAL_ESSID="${ACTUAL_ESSID%\"}"
[ "$ACTUAL_ESSID" = "$ESSID" ] || FAILED=1
fi
if [ "$FAILED" = 0 ] && [ "$MAC_ADDRESS" ] ; then
# Check that access point MAC address is what we are looking for
ACTUAL_MAC_ADDRESS="$(iwgetid $IFACE --ap --scheme)"
case "$ACTUAL_MAC_ADDRESS" in
"FF:FF:FF:FF:FF:FF"|"ff:ff:ff:ff:ff:ff"|"44:44:44:44:44:44"|"00:00:00:00:00:00")
ACTUAL_MAC_ADDRESS=""
;;
esac
[ "$ACTUAL_MAC_ADDRESS" = "$MAC_ADDRESS" ] || FAILED=1
fi
if [ "$FAILED" = 0 ] ; then
ifconfig "$IFACE" down
exit 0
fi
do_sleep 1
done
# Out of time
ifconfig "$IFACE" down
exit 1
#!/bin/bash
#
# test-wireless-scan
#
# History
# Oct 2004: Written by Thomas Hood
set -o errexit # -e
set -o noglob # -f
MYNAME="$(basename $0)"
PATH=/sbin:/bin
usage() {
cat <<EOT
Usage: $MYNAME <IFACE> [mac <MACADDRESS>] [essid <ESSID>]
$MYNAME --help|-h
Tests whether an access point is in range [with the appropriate
MAC address] [and appropriate ESSID] by looking at the output of
"iwlist IFACE scan".
MACADDRESS letters must be in upper case
Licensed under the GNU GPL. See /usr/share/common-licenses/GPL.
Options:
--help|-h Print this help
EOT
}
report_err() { echo "${MYNAME}: Error: $*" >&2 ; }
do_sleep() { LANG=C sleep "$@" ; }
is_ethernet_mac()
{
[ "$1" ] && [ !
"${1/[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]/}"
]
}
if [ "$1" = "--help" ] || [ "$1" == "-h" ]; then
usage
exit 0
fi
IFACE="$1"
[ "$IFACE" ] || { report_err "Interface not specified. Exiting." ; exit 1 ; }
shift
while [ "$2" ] ; do
case "$1" in
mac)
is_ethernet_mac "$2" || { report_err "Argument of 'mac'
is not a MAC address" ; exit 1 ; }
MAC_ADDRESS="$2"
;;
essid)
ESSID="$2"
;;
esac
shift 2
done
[ "$MAC_ADDRESS" ] || [ "$ESSID" ] || { report_err "Neither AP MAC address nor
ESSID specified. Exiting." ; exit 1 ; }
ifconfig "$IFACE" up
do_sleep 0.5
SCAN="$(iwlist "$IFACE" scan 2>&1)"
ifconfig "$IFACE" down
shopt -s extglob # We need this to allow the ?( ) syntax in patterns
[ "$SCAN" = "${SCAN/Interface doesn?t support scanning/}" ] || exit 1
[ "$SCAN" = "${SCAN/Operation not supported/}" ] || exit 1
if [ "$MAC_ADDRESS" ] ; then
[ "$SCAN" != "${SCAN/Address:*( )$MAC_ADDRESS/}" ] || exit 1
fi
if [ "$ESSID" ] ; then
[ "$SCAN" != "${SCAN/ESSID:*( )?${ESSID}?/}" ] || exit 1
fi
exit 0