From: Felix Fietkau Date: Sun, 1 Dec 2013 22:47:47 +0000 (+0100) Subject: wireless: fix reload of active interfaces X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=557c36d169c82e025c633a1f3ef935df40d10784;p=oweals%2Fnetifd.git wireless: fix reload of active interfaces Signed-off-by: Felix Fietkau --- diff --git a/wireless.c b/wireless.c index c19d12c..fb66e7f 100644 --- a/wireless.c +++ b/wireless.c @@ -247,6 +247,32 @@ __wireless_device_set_up(struct wireless_device *wdev) wireless_device_run_handler(wdev, true); } +static void +wireless_device_free(struct wireless_device *wdev) +{ + vlist_flush_all(&wdev->interfaces); + free(wdev->config); + free(wdev); +} + +static void +wdev_handle_config_change(struct wireless_device *wdev) +{ + enum interface_config_state state = wdev->config_state; + + wdev->config_state = IFC_NORMAL; + switch(state) { + case IFC_NORMAL: + case IFC_RELOAD: + if (wdev->autostart) + __wireless_device_set_up(wdev); + break; + case IFC_REMOVE: + wireless_device_free(wdev); + break; + } +} + static void wireless_device_mark_down(struct wireless_device *wdev) { @@ -262,9 +288,7 @@ wireless_device_mark_down(struct wireless_device *wdev) wdev->cancel = false; wdev->state = IFS_DOWN; wireless_device_free_state(wdev); - - if (wdev->autostart) - __wireless_device_set_up(wdev); + wdev_handle_config_change(wdev); } static void @@ -344,33 +368,6 @@ wireless_device_set_down(struct wireless_device *wdev) __wireless_device_set_down(wdev); } -static void -wireless_device_free(struct wireless_device *wdev) -{ - vlist_flush_all(&wdev->interfaces); - free(wdev->config); - free(wdev); -} - -static void -wdev_handle_config_change(struct wireless_device *wdev) -{ - enum interface_config_state state = wdev->config_state; - - wdev->config_state = IFC_NORMAL; - switch(state) { - case IFC_NORMAL: - break; - case IFC_RELOAD: - if (wdev->autostart) - __wireless_device_set_up(wdev); - break; - case IFC_REMOVE: - wireless_device_free(wdev); - break; - } -} - static void wdev_set_config_state(struct wireless_device *wdev, enum interface_config_state s) {