function _up() {
local port=${1}
-
assert isset port
config_read $(port_file ${port})
+ # Check if the PHY is present.
+ local phy=$(phy_get ${PHY})
+ if ! isset phy; then
+ log DEBUG "phy '${PHY}' is not present"
+ exit ${EXIT_ERROR}
+ fi
+
+ # Create the wireless device, if it does not exist, yet.
if ! device_exists ${port}; then
- wireless_create ${port} ${PHY} __ap ${ADDRESS}
+ wireless_create ${port} --phy="${phy}" --type="ap" \
+ --address="${ADDRESS}"
fi
- if ! hostapd_is_running ${port}; then
- hostapd_start ${port} \
- --broadcast-ssid="${BROADCAST_SSID}" \
- --channel="${CHANNEL}" \
- --country-code="${COUNTRY_CODE}" \
- --encryption="${ENCRYPTION}" \
- --key="${KEY}" \
- --mode="${MODE}" \
- --ssid="${SSID}"
-
- local ret=$?
-
- if [ ${ret} -eq ${EXIT_ERROR} ]; then
- error_log "Could not start '${port}' because hostapd crashed previously."
- ( _down ${port} )
- exit ${EXIT_ERROR}
- fi
+ # Start the hostapd service.
+ hostapd_start ${port}
+ local ret=$?
+
+ if [ ${ret} -ne ${EXIT_OK} ]; then
+ log ERROR "Could not start hostapd on port '${port}': ${ret}"
+ exit ${EXIT_ERROR}
fi
exit ${EXIT_OK}
local port=${1}
assert isset port
- config_read $(port_file ${port})
-
# Stop the hostapd daemon.
hostapd_stop ${port}
function _hotplug() {
local port=${1}
- local phy=${2}
-
assert isset port
+
+ local phy=${2}
assert isset phy
+
assert port_exists ${port}
# Read configuration of port.
# Check if the phy is the same we have
# read from the configuration file.
if [ "${PHY}" = "${phy_address}" ]; then
- wireless_create ${port} ${PHY} __ap ${ADDRESS}
+ wireless_create ${port} --phy="${phy_address}" --type="ap" \
+ --address="${ADDRESS}"
fi
exit ${EXIT_OK}