local broadcast_ssid
local channel
local country_code
+ local encryption
+ local key
local mode
local ssid
--ssid=*)
ssid=${1#--ssid=}
;;
+ --encryption=*)
+ encryption=$(cli_get_val ${1})
+ ;;
+ --key=*)
+ key=$(cli_get_val ${1})
+ ;;
*)
warning_log "Ignoring unknown argument '${1}'."
;;
assert isset mode
assert isset ssid
+ # Check if key is set when encryption is used.
+ if isset encryption; then
+ assert isoneof encryption WPA WPA2 WPA/WPA2
+ assert isset key
+ fi
+
local ignore_broadcast_ssid
if enabled broadcast_ssid; then
ignore_broadcast_ssid="0"
ignore_broadcast_ssid=${ignore_broadcast_ssid}
ssid=${ssid}
-# Logging options
-logger_syslog=-1
-logger_syslog_level=2
-logger_stdout=-1
-logger_stdout_level=2
-
# Dump file
-dump_file=$(hostapd_config_dir ${device}/dump
+dump_file=$(hostapd_config_dir ${device}/dump)
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
+
EOF
+ if isset encryption; then
+ local encryption_mode=0
+ case "${encryption}" in
+ WPA)
+ encryption_mode=1
+ ;;
+ WPA2)
+ encryption_mode=2
+ ;;
+ WPA/WPA2)
+ encryption_mode=3
+ ;;
+ esac
+
+ print "# Encryption settings."
+ print "wpa=${encryption_mode}"
+ print "wpa_passphrase=${key}"
+ print "wpa_key_mgmt=WPA-PSK"
+ print "wpa_pairwise=TKIP"
+ print "rsn_pairwise=CCMP"
+ print
+ fi
+
return ${EXIT_OK}
}
. /usr/lib/network/header-port
HOOK_SETTINGS="HOOK ADDRESS BROADCAST_SSID CHANNEL COUNTRY_CODE MODE PHY SSID"
+HOOK_SETTINGS="${HOOK_SETTINGS} ENCRYPTION KEY"
ADDRESS=$(mac_generate)
BROADCAST_SSID=on
CHANNEL=1
COUNTRY_CODE="US"
+ENCRYPTION=""
+KEY=""
MODE="g"
SSID=
assert isset PHY
assert ismac PHY
assert isset SSID
+
+ if isset ENCRYPTION; then
+ assert isoneof ENCRYPTION WPA WPA2 WPA/WPA2
+
+ assert isset KEY
+ assert [ ${#KEY} -ge 8 ]
+ assert [ ${#KEY} -le 63 ]
+ fi
}
function _create() {
--country-code=*)
COUNTRY_CODE=$(cli_get_val ${1})
;;
+ --encryption=*)
+ ENCRYPTION=$(cli_get_val ${1})
+ ;;
+ --key=*)
+ KEY=$(cli_get_val ${1})
+ ;;
--mac=*)
ADDRESS=$(cli_get_val ${1})
;;
--country-code=*)
COUNTRY_CODE=$(cli_get_val ${1})
;;
+ --encryption=*)
+ ENCRYPTION=$(cli_get_val ${1})
+ ;;
+ --key=*)
+ KEY=$(cli_get_val ${1})
+ ;;
--ssid=*)
SSID=$(cli_get_val ${1})
;;
--broadcast-ssid="${BROADCAST_SSID}" \
--channel="${CHANNEL}" \
--country-code="${COUNTRY_CODE}" \
+ --encryption="${ENCRYPTION}" \
+ --key="${KEY}" \
--mode="${MODE}" \
--ssid="${SSID}"