summaryrefslogtreecommitdiff
path: root/net.Linux/iwconfig.sh
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-11-28 15:45:03 +0000
committerRoy Marples <roy@marples.name>2007-11-28 15:45:03 +0000
commitac9279cc0d5a00bc17908b2914941186020cd3ce (patch)
tree850a4fe19917113e75bfd2e79d00b58208468503 /net.Linux/iwconfig.sh
parent444f23e2d158389b22d40537fc9b027d9f575229 (diff)
downloadopenrc-ac9279cc0d5a00bc17908b2914941186020cd3ce.tar.gz
openrc-ac9279cc0d5a00bc17908b2914941186020cd3ce.tar.bz2
openrc-ac9279cc0d5a00bc17908b2914941186020cd3ce.tar.xz
Massive whitespace cleanup
Diffstat (limited to 'net.Linux/iwconfig.sh')
-rw-r--r--net.Linux/iwconfig.sh216
1 files changed, 108 insertions, 108 deletions
diff --git a/net.Linux/iwconfig.sh b/net.Linux/iwconfig.sh
index 066f258..4f8e12f 100644
--- a/net.Linux/iwconfig.sh
+++ b/net.Linux/iwconfig.sh
@@ -36,7 +36,7 @@ iwconfig_get_wep_status() {
local mode= status="disabled"
# No easy way of doing this grep in bash regex :/
- if LC_ALL=C iwconfig "${IFACE}" | grep -qE "^ +Encryption key:[*0-9,A-F]" ; then
+ if LC_ALL=C iwconfig "${IFACE}" | grep -qE "^ +Encryption key:[*0-9,A-F]"; then
status="enabled"
mode=$(LC_ALL=C iwconfig "${IFACE}" | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p')
[ -n "${mode}" ] && mode=" - ${mode}"
@@ -48,9 +48,9 @@ iwconfig_get_wep_status() {
_get_ssid() {
local i=5 ssid=
- while [ ${i} -gt 0 ] ; do
+ while [ ${i} -gt 0 ]; do
ssid=$(iwgetid --raw "${IFACE}")
- if [ -n "${ssid}" ] ; then
+ if [ -n "${ssid}" ]; then
echo "${ssid}"
return 0
fi
@@ -64,11 +64,11 @@ _get_ssid() {
_get_ap_mac_address() {
local mac="$(iwgetid --raw --ap "${IFACE}")"
case "${mac}" in
- "00:00:00:00:00:00") return 1 ;;
- "44:44:44:44:44:44") return 1 ;;
- "FF:00:00:00:00:00") return 1 ;;
- "FF:FF:FF:FF:FF:FF") return 1 ;;
- *) echo "${mac}" ;;
+ "00:00:00:00:00:00") return 1;;
+ "44:44:44:44:44:44") return 1;;
+ "FF:00:00:00:00:00") return 1;;
+ "FF:FF:FF:FF:FF:FF") return 1;;
+ *) echo "${mac}";;
esac
}
@@ -117,13 +117,13 @@ iwconfig_get_wep_key() {
[ -n "${mac}" ] && mac="$(echo "${mac}" | sed -e 's/://g')"
eval key=\$mac_key_${mac}
[ -z "${key}" ] && eval key=\$key_${SSIDVAR}
- if [ -z "${key}" ] ; then
+ if [ -z "${key}" ]; then
echo "off"
else
set -- ${key}
local x= e=false
- for x in "$@" ; do
- if [ "${x}" = "enc" ] ; then
+ for x in "$@"; do
+ if [ "${x}" = "enc" ]; then
e=true
break
fi
@@ -141,7 +141,7 @@ iwconfig_user_config() {
local IFS="$__IFS"
for conf in ${config}; do
unset IFS
- if ! eval iwconfig "${IFACE}" "${conf}" ; then
+ if ! eval iwconfig "${IFACE}" "${conf}"; then
ewarn "${IFACE} does not support the following configuration commands"
ewarn " ${conf}"
fi
@@ -152,7 +152,7 @@ iwconfig_user_config() {
local IFS="$__IFS"
for conf in ${config}; do
unset IFS
- if ! eval iwpriv "${IFACE}" "${conf}" ; then
+ if ! eval iwpriv "${IFACE}" "${conf}"; then
ewarn "${IFACE} does not support the following private ioctls"
ewarn " ${conf}"
fi
@@ -172,7 +172,7 @@ iwconfig_setup_specific() {
iwconfig_set_mode "${mode}"
# Now set the key
- if ! eval iwconfig "${IFACE}" key "${key}" ; then
+ if ! eval iwconfig "${IFACE}" key "${key}"; then
if [ "${key}" != "off" ]; then
ewarn "${IFACE} does not support setting keys"
ewarn "or the parameter \"mac_key_${SSIDVAR}\" or \"key_${SSIDVAR}\" is incorrect"
@@ -180,7 +180,7 @@ iwconfig_setup_specific() {
fi
# Then set the SSID
- if ! iwconfig "${IFACE}" essid "${SSID}" ; then
+ if ! iwconfig "${IFACE}" essid "${SSID}"; then
eerror "${IFACE} does not support setting SSID to \"${SSID}\""
return 1
fi
@@ -188,7 +188,7 @@ iwconfig_setup_specific() {
eval channel=\$channel_${SSIDVAR}
[ -z "${channel}" ] && eval channel=\$channel_${IFVAR}
# We default the channel to 3
- if ! iwconfig "${IFACE}" channel "${channel:-3}" ; then
+ if ! iwconfig "${IFACE}" channel "${channel:-3}"; then
ewarn "${IFACE} does not support setting the channel to \"${channel:-3}\""
return 1
fi
@@ -210,8 +210,8 @@ iwconfig_wait_for_association() {
while true; do
# Use sysfs if we can
- if [ -e /sys/class/net/"${IFACE}"/carrier ] ; then
- if [ "$(cat /sys/class/net/"${IFACE}"/carrier)" = "1" ] ; then
+ if [ -e /sys/class/net/"${IFACE}"/carrier ]; then
+ if [ "$(cat /sys/class/net/"${IFACE}"/carrier)" = "1" ]; then
# Double check we have an ssid. This is mainly for buggy
# prism54 drivers that always set their carrier on :/
[ -n "$(iwgetid --raw "${IFACE}")" ] && return 0
@@ -220,10 +220,10 @@ iwconfig_wait_for_association() {
local atest=
eval atest=\$associate_test_${IFVAR}
atest=${atest:-mac}
- if [ "${atest}" = "mac" -o "${atest}" = "all" ] ; then
+ if [ "${atest}" = "mac" -o "${atest}" = "all" ]; then
[ -n "$(_get_ap_mac_address)" ] && return 0
fi
- if [ "${atest}" = "quality" -o "${atest}" = "all" ] ; then
+ if [ "${atest}" = "quality" -o "${atest}" = "all" ]; then
[ "$(sed -n -e 's/^.*'"${IFACE}"': *[0-9]* *\([0-9]*\).*/\1/p' \
/proc/net/wireless)" != "0" ] && return 0
fi
@@ -249,17 +249,17 @@ iwconfig_associate() {
else
SSIDVAR=$(_shell_var "${SSID}")
key="$(iwconfig_get_wep_key "${mac}")"
- if [ "${wep_required}" = "on" -a "${key}" = "off" ] ; then
+ if [ "${wep_required}" = "on" -a "${key}" = "off" ]; then
ewarn "WEP key is not set for \"${SSID}\" - not connecting"
return 1
fi
- if [ "${wep_required}" = "off" -a "${key}" != "off" ] ; then
+ if [ "${wep_required}" = "off" -a "${key}" != "off" ]; then
key="off"
ewarn "\"${SSID}\" is not WEP enabled - ignoring setting"
fi
- if ! eval iwconfig "${IFACE}" key "${key}" ; then
- if [ "${key}" != "off" ] ; then
+ if ! eval iwconfig "${IFACE}" key "${key}"; then
+ if [ "${key}" != "off" ]; then
ewarn "${IFACE} does not support setting keys"
ewarn "or the parameter \"mac_key_${SSIDVAR}\" or \"key_${SSIDVAR}\" is incorrect"
return 1
@@ -268,16 +268,16 @@ iwconfig_associate() {
[ "${key}" != "off" ] && w="$(iwconfig_get_wep_status "${iface}")"
fi
- if ! iwconfig "${IFACE}" essid "${SSID}" ; then
- if [ "${SSID}" != "any" ] ; then
+ if ! iwconfig "${IFACE}" essid "${SSID}"; then
+ if [ "${SSID}" != "any" ]; then
ewarn "${IFACE} does not support setting SSID to \"${SSID}\""
fi
fi
# Only use channel or frequency
- if [ -n "${chan}" ] ; then
+ if [ -n "${chan}" ]; then
iwconfig "${IFACE}" channel "${chan}"
- elif [ -n "${freq}" ] ; then
+ elif [ -n "${freq}" ]; then
iwconfig "${IFACE}" freq "${freq}"
fi
[ -n "${mac}" ] && iwconfig "${IFACE}" ap "${mac}"
@@ -287,19 +287,19 @@ iwconfig_associate() {
ebegin "Connecting to \"${SSID}\" in ${mode} mode ${w}"
- if [ "${SSID}" != "any" ] && type preassociate >/dev/null 2>/dev/null ; then
+ if [ "${SSID}" != "any" ] && type preassociate >/dev/null 2>&1; then
veinfo "Running preassociate function"
veindent
( preassociate )
local e=$?
veoutdent
- if [ ${e} -eq 0 ] ; then
+ if [ ${e} -eq 0 ]; then
veend 1 "preassociate \"${SSID}\" on ${IFACE} failed"
return 1
fi
fi
- if ! iwconfig_wait_for_association ; then
+ if ! iwconfig_wait_for_association; then
eend 1
return 1
fi
@@ -313,7 +313,7 @@ iwconfig_associate() {
iwconfig_report
- if type postassociate >/dev/null 2>/dev/null ; then
+ if type postassociate >/dev/null 2>&1; then
veinfo "Running postassociate function"
veindent
( postassociate )
@@ -332,12 +332,12 @@ iwconfig_scan() {
eval x=\$sleep_scan_${IFVAR}
[ -n "${x}" ] && sleep "${x}"
- while [ ${i} -lt 3 ] ; do
+ while [ ${i} -lt 3 ]; do
local scan="${scan}${scan:+ }$(LC_ALL=C iwlist "${IFACE}" scan 2>/dev/null | sed -e "s/'/'\\\\''/g" -e "s/$/'/g" -e "s/^/'/g")"
# If this is the first pass and txpower as off and we have no results
# then we need to wait for at least 2 seconds whilst the interface
# does an initial scan.
- if [ "${i}" = "0" -a "${txpowerwasoff}" = "0" ] ; then
+ if [ "${i}" = "0" -a "${txpowerwasoff}" = "0" ]; then
case "${scan}" in
"'${IFACE} "*"No scan results"*)
sleep 2
@@ -349,12 +349,12 @@ iwconfig_scan() {
i=$((${i} + 1))
done
- if [ -z "${scan}" ] ; then
+ if [ -z "${scan}" ]; then
ewarn "${iface} does not support scanning"
eoutdent
eval x=\$adhoc_ssid_${IFVAR}
[ -n "${x}" ] && return 0
- if [ -n "${preferred_aps}" ] ; then
+ if [ -n "${preferred_aps}" ]; then
[ "${associate_order}" = "forcepreferred" ] || \
[ "${associate_order}" = "forcepreferredonly" ] && return 0
fi
@@ -373,48 +373,48 @@ iwconfig_scan() {
APS=-1
eval set -- ${scan}
- for line in "$@" ; do
- case "${line}" in
- *Address:*)
- APS=$((${APS} + 1))
- eval MAC_${APS}=\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\"
- eval QUALITY_${APS}=0
- ;;
- *ESSID:*)
- x=${line#*\"}
- x=${x%*\"}
- eval SSID_${APS}=\$x
- ;;
- *Mode:*)
- x="$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]')"
- if [ "${x}" = "master" ] ; then
- eval MODE_${APS}=\"managed\"
- else
- eval MODE_${APS}=\$x
- fi
- ;;
- *'Encryption key:'*)
- x=${line#*:}
- eval ENC_${APS}=\$x
- ;;
- #*Frequency:*)
- # freq[i]="${line#*:}"
- # x="${freq[i]#* }"
- # freq[i]="${freq[i]%% *}${x:0:1}"
- # ;;
- *Channel:*)
- x=${line#*:}
- x=${x%% *}
- eval CHAN_${APS}=\$x
- ;;
- *Quality*)
- x=${line#*:}
- x=${x%/*}
- x="$(echo "${x}" | sed -e 's/[^[:digit:]]//g')"
- x=${x:-0}
- eval QUALITY_${APS}=\$x
- ;;
- esac
+ for line in "$@"; do
+ case "${line}" in
+ *Address:*)
+ APS=$((${APS} + 1))
+ eval MAC_${APS}="\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\""
+ eva l QUALITY_${APS}=0
+ ;;
+ *ESSID:*)
+ x=${line#*\"}
+ x=${x%*\"}
+ eval SSID_${APS}=\$x
+ ;;
+ *Mode:*)
+ x="$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]')"
+ if [ "${x}" = "master" ]; then
+ eval MODE_${APS}=managed
+ else
+ eval MODE_${APS}=\$x
+ fi
+ ;;
+ *'Encryption key:'*)
+ x=${line#*:}
+ eval ENC_${APS}=\$x
+ ;;
+ #*Frequency:*)
+ # freq[i]="${line#*:}"
+ # x="${freq[i]#* }"
+ # freq[i]="${freq[i]%% *}${x:0:1}"
+ # ;;
+ *Channel:*)
+ x=${line#*:}
+ x=${x%% *}
+ eval CHAN_${APS}=\$x
+ ;;
+ *Quality*)
+ x=${line#*:}
+ x=${x%/*}
+ x="$(echo "${x}" | sed -e 's/[^[:digit:]]//g')"
+ x=${x:-0}
+ eval QUALITY_${APS}=\$x
+ ;;
+ esac
done
if [ -z "${MAC_0}" ]; then
@@ -425,14 +425,14 @@ iwconfig_scan() {
# Sort based on quality
local i=0 k=1 a= b= x= t=
- while [ ${i} -lt ${APS} ] ; do
+ while [ ${i} -lt ${APS} ]; do
k=$((${i} + 1))
- while [ ${k} -le ${APS} ] ; do
+ while [ ${k} -le ${APS} ]; do
eval a=\$QUALITY_${i}
[ -z "${a}" ] && break
eval b=\$QUALITY_${k}
- if [ -n "${b}" -a "${a}" -lt "${b}" ] ; then
- for x in MAC SSID CHAN QUALITY ENC ; do
+ if [ -n "${b}" -a "${a}" -lt "${b}" ]; then
+ for x in MAC SSID CHAN QUALITY ENC; do
eval t=\$${x}_${i}
eval ${x}_${i}=\$${x}_${k}
eval ${x}_${k}=\$t
@@ -445,12 +445,12 @@ iwconfig_scan() {
# Strip any duplicates
local i=0 k=1 a= b=
- while [ ${i} -lt ${APS} ] ; do
+ while [ ${i} -lt ${APS} ]; do
k=$((${i} + 1))
- while [ ${k} -le ${APS} ] ; do
+ while [ ${k} -le ${APS} ]; do
eval a=\$MAC_${i}
eval b=\$MAC_${k}
- if [ "${a}" = "${b}" ] ; then
+ if [ "${a}" = "${b}" ]; then
eval a=\$QUALITY_${i}
eval b=\$QUALITY_${k}
local u=${k}
@@ -465,9 +465,9 @@ iwconfig_scan() {
local i=0 e= m= s=
- while [ ${i} -le ${APS} ] ; do
+ while [ ${i} -le ${APS} ]; do
eval x=\$MAC_${i}
- if [ -z "${x}" ] ; then
+ if [ -z "${x}" ]; then
i=$((${i} + 1))
continue
fi
@@ -476,12 +476,12 @@ iwconfig_scan() {
eval s=\$SSID_${i}
eval q=\$QUALITY_${i}
eval e=\$ENC_${i}
- if [ -n "${e}" -a "${e}" != "off" ] ; then
+ if [ -n "${e}" -a "${e}" != "off" ]; then
e=", encrypted"
else
e=""
fi
- if [ -z "${s}" ] ; then
+ if [ -z "${s}" ]; then
einfo "Found ${x}, ${m}${e}"
else
einfo "Found \"${s}\" at ${x}, ${m}${e}"
@@ -489,7 +489,7 @@ iwconfig_scan() {
x="$(echo "${x}" | sed -e 's/://g')"
eval x=\$mac_ssid_${x}
- if [ -n "${x}" ] ; then
+ if [ -n "${x}" ]; then
eval SSID_${i}=\$x
s=${x}
eindent
@@ -500,7 +500,7 @@ iwconfig_scan() {
eval set -- $(_flatten_array "blacklist_aps_${IFVAR}")
[ $# = 0 ] && eval set -- $(_flatten_array "blacklist_aps")
for x in "$@"; do
- if [ "${x}" = "${s}" ] ; then
+ if [ "${x}" = "${s}" ]; then
ewarn "${s} has been blacklisted - not connecting"
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} ENC_${i}
fi
@@ -518,15 +518,15 @@ iwconfig_force_preferred() {
ewarn "Trying to force preferred in case they are hidden"
for ssid in "$@"; do
local found_AP=false i=0 e=
- while [ ${i} -le ${APS} ] ; do
+ while [ ${i} -le ${APS} ]; do
eval e=\$SSID_${i}
- if [ "${e}" = "${ssid}" ] ; then
+ if [ "${e}" = "${ssid}" ]; then
found_AP=true
break
fi
i=$((${i} + 1))
done
- if ! ${found_AP} ; then
+ if ! ${found_AP}; then
SSID=${e}
iwconfig_associate && return 0
fi
@@ -544,9 +544,9 @@ iwconfig_connect_preferred() {
for ssid in "$@"; do
unset IFS
i=0
- while [ ${i} -le ${APS} ] ; do
+ while [ ${i} -le ${APS} ]; do
eval e=\$SSID_${i}
- if [ "${e}" = "${ssid}" ] ; then
+ if [ "${e}" = "${ssid}" ]; then
SSID=${e}
eval mode=\$MODE_${i}
eval mac=\$MAC_${i}
@@ -566,19 +566,19 @@ iwconfig_connect_preferred() {
iwconfig_connect_not_preferred() {
local ssid= i=0 mode= mac= enc= freq= chan= pref=false
- while [ ${i} -le ${APS} ] ; do
+ while [ ${i} -le ${APS} ]; do
eval e=\$SSID_${i}
- if [ -n "${e}" ] ; then
+ if [ -n "${e}" ]; then
eval set -- $(_flatten_array "preferred_aps_${IFVAR}")
[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps")
for ssid in "$@"; do
- if [ "${e}" = "${ssid}" ] ; then
+ if [ "${e}" = "${ssid}" ]; then
pref=true
break
fi
done
- if ! ${pref} ; then
+ if ! ${pref}; then
SSID=${e}
eval mode=\$MODE_${i}
eval mac=\$MAC_${i}
@@ -597,7 +597,7 @@ iwconfig_connect_not_preferred() {
iwconfig_defaults() {
local x=
- for x in txpower rate rts frag ; do
+ for x in txpower rate rts frag; do
iwconfig "${IFACE}" "${x}" auto 2>/dev/null
done
@@ -617,12 +617,12 @@ iwconfig_configure() {
# Setup ad-hoc mode?
eval x=\$mode_${IFVAR}
x=${x:-managed}
- if [ "${x}" = "ad-hoc" -o "${x}" = "master" ] ; then
+ if [ "${x}" = "ad-hoc" -o "${x}" = "master" ]; then
iwconfig_setup_specific "${x}"
return $?
fi
- if [ "${x}" != "managed" -a "${x}" != "auto" ] ; then
+ if [ "${x}" != "managed" -a "${x}" != "auto" ]; then
eerror "Only managed, ad-hoc, master and auto modes are supported"
return 1
fi
@@ -690,13 +690,13 @@ iwconfig_pre_start() {
save_options "SSID" ""
_exists || return 0
- if ! _is_wireless ; then
+ if ! _is_wireless; then
veinfo "Wireless extensions not found for ${IFACE}"
return 0
fi
# Warn about old file - we want to punt it really
- if [ -e /etc/conf.d/wireless ] ; then
+ if [ -e /etc/conf.d/wireless ]; then
ewarn "/etc/conf.d/wireless is deprecated"
ewarn "Please put all settings into /etc/conf.d/net"
. /etc/conf.d/wireless
@@ -715,8 +715,8 @@ iwconfig_pre_start() {
# Check for rf_kill - only ipw supports this at present, but other
# cards may in the future.
- if [ -e /sys/class/net/"${IFACE}"/device/rf_kill ] ; then
- if [ $(cat /sys/class/net/"${IFACE}"/device/rf_kill) != "0" ] ; then
+ if [ -e /sys/class/net/"${IFACE}"/device/rf_kill ]; then
+ if [ $(cat /sys/class/net/"${IFACE}"/device/rf_kill) != "0" ]; then
eerror "Wireless radio has been killed for interface ${IFACE}"
return 1
fi
@@ -736,7 +736,7 @@ iwconfig_pre_start() {
return 1
fi
- if iwconfig_configure ; then
+ if iwconfig_configure; then
save_options "SSID" "${SSID}"
return 0
fi