diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2020-06-02 14:44:26 -0700 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2020-06-02 14:44:57 -0700 |
commit | 1c846d9d8e23d94046df471c7ccbb88228537188 (patch) | |
tree | ab7923f483d5a4736583484ede66e3b0c9b6d6eb | |
parent | doc/net.example.Linux: document !wireless better (diff) | |
download | netifrc-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.sh | 37 |
1 files changed, 20 insertions, 17 deletions
@@ -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 |