Move driver deinitialization away from hostapd.c

This matches with the earlier change of moving driver initialization
and allows more control on how the driver context is managed.
This commit is contained in:
Jouni Malinen 2009-12-25 18:32:44 +02:00
parent a4f2110934
commit 8c5fe31fe8
4 changed files with 23 additions and 12 deletions

View file

@ -18,14 +18,6 @@
#include "drivers/driver.h" #include "drivers/driver.h"
#include "ap/config.h" #include "ap/config.h"
static inline void
hostapd_driver_deinit(struct hostapd_data *hapd)
{
if (hapd->driver == NULL || hapd->driver->hapd_deinit == NULL)
return;
hapd->driver->hapd_deinit(hapd->drv_priv);
}
static inline int static inline int
hostapd_set_ieee8021x(struct hostapd_data *hapd, struct wpa_bss_params *params) hostapd_set_ieee8021x(struct hostapd_data *hapd, struct wpa_bss_params *params)
{ {

View file

@ -819,8 +819,6 @@ void hostapd_interface_deinit(struct hostapd_iface *iface)
hostapd_free_stas(hapd); hostapd_free_stas(hapd);
hostapd_flush_old_stations(hapd); hostapd_flush_old_stations(hapd);
hostapd_cleanup(hapd); hostapd_cleanup(hapd);
if (j == iface->num_bss - 1 && hapd->driver)
hostapd_driver_deinit(hapd);
} }
for (j = 0; j < iface->num_bss; j++) for (j = 0; j < iface->num_bss; j++)
os_free(iface->bss[j]); os_free(iface->bss[j]);

View file

@ -291,7 +291,13 @@ hostapd_interface_init(struct hapd_interfaces *interfaces,
if (hostapd_driver_init(iface) || if (hostapd_driver_init(iface) ||
hostapd_setup_interface(iface)) { hostapd_setup_interface(iface)) {
const struct wpa_driver_ops *driver;
void *drv_priv;
driver = iface->bss[0]->driver;
drv_priv = iface->bss[0]->drv_priv;
hostapd_interface_deinit(iface); hostapd_interface_deinit(iface);
if (driver && driver->hapd_deinit)
driver->hapd_deinit(drv_priv);
return NULL; return NULL;
} }
@ -532,8 +538,16 @@ int main(int argc, char *argv[])
out: out:
/* Deinitialize all interfaces */ /* Deinitialize all interfaces */
for (i = 0; i < interfaces.count; i++) for (i = 0; i < interfaces.count; i++) {
hostapd_interface_deinit(interfaces.iface[i]); struct hostapd_iface *iface = interfaces.iface[i];
const struct wpa_driver_ops *driver;
void *drv_priv;
driver = iface->bss[0]->driver;
drv_priv = iface->bss[0]->drv_priv;
hostapd_interface_deinit(iface);
if (driver && driver->hapd_deinit)
driver->hapd_deinit(drv_priv);
}
os_free(interfaces.iface); os_free(interfaces.iface);
hostapd_global_deinit(pid_file); hostapd_global_deinit(pid_file);

View file

@ -519,11 +519,18 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
void wpa_supplicant_ap_deinit(struct wpa_supplicant *wpa_s) void wpa_supplicant_ap_deinit(struct wpa_supplicant *wpa_s)
{ {
const struct wpa_driver_ops *driver;
void *drv_priv;
if (wpa_s->ap_iface == NULL) if (wpa_s->ap_iface == NULL)
return; return;
driver = wpa_s->ap_iface->bss[0]->driver;
drv_priv = wpa_s->ap_iface->bss[0]->drv_priv;
hostapd_interface_deinit(wpa_s->ap_iface); hostapd_interface_deinit(wpa_s->ap_iface);
wpa_s->ap_iface = NULL; wpa_s->ap_iface = NULL;
if (driver && driver->hapd_deinit)
driver->hapd_deinit(drv_priv);
} }