aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2020-06-02 14:44:26 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2020-06-02 14:44:57 -0700
commit1c846d9d8e23d94046df471c7ccbb88228537188 (patch)
treeab7923f483d5a4736583484ede66e3b0c9b6d6eb
parentdoc/net.example.Linux: document !wireless better (diff)
downloadnetifrc-1c846d9d8e23d94046df471c7ccbb88228537188.tar.gz
netifrc-1c846d9d8e23d94046df471c7ccbb88228537188.tar.bz2
netifrc-1c846d9d8e23d94046df471c7ccbb88228537188.zip
net/iw: refactor iw mode setup
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r--net/iw.sh37
1 files changed, 20 insertions, 17 deletions
diff --git a/net/iw.sh b/net/iw.sh
index 82b9ba9..dcdbb79 100644
--- a/net/iw.sh
+++ b/net/iw.sh
@@ -585,27 +585,30 @@ iw_configure()
[ -z "${SSID}" ] && eval SSID=\$essid_${IFVAR}
# Setup ad-hoc mode?
- eval x=\$mode_${IFVAR}
- x=${x:-managed}
+ eval _mode=\$mode_${IFVAR}
+ _mode=${_mode:-managed}
- if [ "${x}" = "master" ]; then
- eerror "Please use hostapd to make this interface an access point"
- return 1
- fi
-
- if [ "${x}" = "ad-hoc" ]; then
- iw_setup_adhoc
- return $?
- fi
-
- if [ "${x}" != "managed" ]; then
- eerror "Only managed and ad-hoc are supported"
- return 1
- fi
+ case "${_mode}" in
+ master)
+ eerror "Please use hostapd to make this interface an access point"
+ return 1
+ ;;
+ ad-hoc|adhoc)
+ iw_setup_adhoc
+ return $?
+ ;;
+ managed)
+ # Fall through
+ ;;
+ *)
+ eerror "Only managed and ad-hoc are supported"
+ return 1
+ ;;
+ esac
# Has an SSID been forced?
if [ -n "${SSID}" ]; then
- iw_set_mode "${x}"
+ iw_set_mode "${_mode}"
iw_associate && return 0
[ "${SSID}" = "any" ] && iw_force_preferred && return 0