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 "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
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_flush_old_stations(hapd);
hostapd_cleanup(hapd);
if (j == iface->num_bss - 1 && hapd->driver)
hostapd_driver_deinit(hapd);
}
for (j = 0; j < iface->num_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) ||
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);
if (driver && driver->hapd_deinit)
driver->hapd_deinit(drv_priv);
return NULL;
}
@ -532,8 +538,16 @@ int main(int argc, char *argv[])
out:
/* Deinitialize all interfaces */
for (i = 0; i < interfaces.count; i++)
hostapd_interface_deinit(interfaces.iface[i]);
for (i = 0; i < interfaces.count; 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);
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)
{
const struct wpa_driver_ops *driver;
void *drv_priv;
if (wpa_s->ap_iface == NULL)
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);
wpa_s->ap_iface = NULL;
if (driver && driver->hapd_deinit)
driver->hapd_deinit(drv_priv);
}