From: Michael Tremer Date: Sun, 27 May 2012 12:12:53 +0000 (+0000) Subject: wireless-ap: Add hotplug support. X-Git-Tag: 004~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=47859d95a0b9a41b905169eb7401887391973485;p=network.git wireless-ap: Add hotplug support. This patch will help wireless APs to automatically start up when an USB wireless device is plugged in. --- diff --git a/hooks/ports/wireless-ap b/hooks/ports/wireless-ap index b98e3e70..5897c3df 100755 --- a/hooks/ports/wireless-ap +++ b/hooks/ports/wireless-ap @@ -157,17 +157,17 @@ function _up() { function _down() { local port=${1} - assert isset port config_read $(port_file ${port}) - if ! device_exists ${port}; then - exit ${EXIT_OK} - fi - + # Stop the hostapd daemon. hostapd_stop ${port} - wireless_remove ${port} + + # Remove the device if it is still present. + if device_exists ${port}; then + wireless_remove ${port} + fi exit ${EXIT_OK} } @@ -196,4 +196,27 @@ config_read $(zone_dir ${zone})/${port} exit ${EXIT_OK} } +function _hotplug() { + local port=${1} + local phy=${2} + + assert isset port + assert isset phy + assert port_exists ${port} + + # Read configuration of port. + config_read $(port_file ${port}) + + # Get the address of the phy. + local phy_address=$(phy_get_address ${phy}) + + # 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} + fi + + exit ${EXIT_OK} +} + run $@