]> git.ipfire.org Git - people/stevee/network.git/blobdiff - src/functions/functions.wireless
wireless: Fix crash of status if not connected
[people/stevee/network.git] / src / functions / functions.wireless
index 57377e1a4f21c692274c8ea340a5f5aff89631cb..298cb19e0d958210b3e31e10c8889a8a9c5eff1a 100644 (file)
@@ -25,6 +25,25 @@ NETWORK_SETTINGS_FILE_PARAMS="${NETWORK_SETTINGS_FILE_PARAMS} WIRELESS_REGULATOR
 
 WIRELESS_REGULATORY_DOMAIN_DATABASE="/usr/lib/crda/regulatory.bin"
 
+WIRELESS_DEFAULT_ENCRYPTION_MODE="NONE"
+WIRELESS_VALID_ENCRYPTION_MODES="WPA2-PSK-SHA256 WPA2-PSK \
+       WPA-PSK-SHA256 WPA-PSK NONE"
+
+cli_wireless() {
+       local action=${1}
+       shift 1
+
+       case "${action}" in
+               network)
+                       cli_wireless_network "$@"
+                       ;;
+               *)
+                       error "Unrecognized argument: ${action}"
+                       exit ${EXIT_ERROR}
+                       ;;
+       esac
+}
+
 wireless_create() {
        local device=${1}
        assert isset device
@@ -310,6 +329,38 @@ wireless_set_channel() {
        cmd iw dev "${device}" set channel "${channel}"
 }
 
+wireless_pre_shared_key_is_valid() {
+       local encryption_mode="${1}"
+       local psk="${2}"
+
+       # Length of the PSK
+       local l="${#psk}"
+
+       case "${encryption_mode}" in
+               # For WPA*, the key must be between 8 and 63 chars
+               WPA2-PSK|WPA2-PSK-SHA256|WPA-PSK|WPA-PSK-SHA256)
+                       if [ ${l} -ge 8 ] && [ ${l} -le 63 ]; then
+                               return ${EXIT_TRUE}
+                       fi
+
+                       return ${EXIT_FALSE}
+                       ;;
+
+               WEP)
+                       # XXX need to check if the key is entered in
+                       # hex or ascii and then count the bytes
+                       ;;
+       esac
+
+       return ${EXIT_ERROR}
+}
+
+wireless_client_is_connected() {
+       local device="${1}"
+
+       device_has_carrier "${device}"
+}
+
 wireless_ibss_join() {
        local device=${1}
        assert isset device