X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fnetwork.git;a=blobdiff_plain;f=src%2Fhooks%2Fports%2Fwireless-ap;h=8de0aba398e818d74e9c673e0c0a4943271faf05;hp=4983f9c268b4122c0b5daa60addd0bb5cdbdeca7;hb=1ba6a2bb3a8d7038e3e282bb82f44357de229643;hpb=5bc016ba313173f66edeeb269fe550d7d6b873a1 diff --git a/src/hooks/ports/wireless-ap b/src/hooks/ports/wireless-ap index 4983f9c2..8de0aba3 100644 --- a/src/hooks/ports/wireless-ap +++ b/src/hooks/ports/wireless-ap @@ -53,7 +53,7 @@ function hook_check() { fi } -function hook_create() { +function hook_new() { while [ $# -gt 0 ]; do case "${1}" in --broadcast-ssid=*) @@ -139,10 +139,12 @@ function hook_edit() { exit ${EXIT_OK} } -function hook_up() { - local port=${1} +function hook_create() { + local port="${1}" assert isset port + device_exists "${port}" && exit ${EXIT_OK} + port_settings_read "${port}" ${HOOK_SETTINGS} # Check if the PHY is present. @@ -152,26 +154,17 @@ function hook_up() { exit ${EXIT_ERROR} fi - # Create the wireless device, if it does not exist, yet. - if ! device_exists ${port}; then - wireless_create ${port} --phy="${phy}" --type="ap" \ - --address="${ADDRESS}" - 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 + # Create the wireless device + wireless_create "${port}" \ + --phy="${phy}" \ + --type="ap" \ + --address="${ADDRESS}" exit ${EXIT_OK} } -function hook_down() { - local port=${1} +function hook_remove() { + local port="${1}" assert isset port # Remove the device if present @@ -182,19 +175,34 @@ function hook_down() { exit ${EXIT_OK} } +function hook_up() { + local port="${1}" + assert isset port + + # The port must already exist before + # hostapd is started. Otherwise it will + # fail horribly over and over again. + assert device_exists "${port}" + + hostapd_start "${port}" +} + +function hook_down() { + local port="${1}" + assert isset port + + hostapd_stop "${port}" +} + function hook_hotplug() { local port="${1}" assert isset port case "$(hotplug_action)" in add) - # Start hostapd after the port has been brought up - if hotplug_event_port_is_interface "${port}"; then - hostapd_start "${port}" - - # Bring up the port when the phy is plugged in - elif hotplug_event_port_uses_phy "${port}"; then - hook_up "${port}" + # Create the port when the phy is plugged in + if hotplug_event_port_uses_phy "${port}"; then + hook_create "${port}" fi ;; @@ -202,13 +210,11 @@ function hook_hotplug() { # Stop hostapd if hotplug_event_port_is_interface "${port}"; then hostapd_stop "${port}" - fi - ;; - *) - exit ${EXIT_NOT_HANDLED} + exit ${EXIT_OK} + fi ;; esac - exit ${EXIT_OK} + exit ${EXIT_NOT_HANDLED} }