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
while [ $# -gt 0 ]; do
case "${1}" in
--address=*)
- address=$(cli_get_val ${1})
+ address=$(cli_get_val "${1}")
;;
--channel=*)
channel=$(cli_get_val "${1}")
;;
--phy=*)
- phy=$(cli_get_val ${1})
+ phy=$(cli_get_val "${1}")
phy=$(phy_get ${phy})
;;
--type=*)
- type=$(cli_get_val ${1})
+ type=$(cli_get_val "${1}")
# ap --> __ap
[ "${type}" = "ap" ] && type="__ap"
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
while [ $# -gt 0 ]; do
case "${1}" in
--bssid=*)
- bssid="$(cli_get_val ${1})"
+ bssid="$(cli_get_val "${1}")"
;;
--essid=*)
- essid="$(cli_get_val ${1})"
+ essid="$(cli_get_val "${1}")"
;;
--channel=*)
- local channel="$(cli_get_val ${1})"
+ local channel="$(cli_get_val "${1}")"
# Save the frequency of the channel instead
# of the channel itself.