commit: 1c846d9d8e23d94046df471c7ccbb88228537188
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 2 21:44:26 2020 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Jun 2 21:44:57 2020 +0000
URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1c846d9d
net/iw: refactor iw mode setup
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
net/iw.sh | 37 ++++++++++++++++++++-----------------
1 file 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