mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 18:28:23 -05:00
hostapd: Call global_init/global_deinit driver_ops
Now both wpa_supplicant and hostapd allow the driver wrappers to use the global context similarly.
This commit is contained in:
parent
9fb0407055
commit
4b24282a17
@ -37,6 +37,16 @@ extern int wpa_debug_level;
|
|||||||
extern int wpa_debug_show_keys;
|
extern int wpa_debug_show_keys;
|
||||||
extern int wpa_debug_timestamp;
|
extern int wpa_debug_timestamp;
|
||||||
|
|
||||||
|
extern struct wpa_driver_ops *wpa_drivers[];
|
||||||
|
|
||||||
|
|
||||||
|
struct hapd_global {
|
||||||
|
void **drv_priv;
|
||||||
|
size_t drv_count;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct hapd_global global;
|
||||||
|
|
||||||
|
|
||||||
struct hapd_interfaces {
|
struct hapd_interfaces {
|
||||||
size_t count;
|
size_t count;
|
||||||
@ -246,6 +256,12 @@ static int hostapd_driver_init(struct hostapd_iface *iface)
|
|||||||
b = NULL;
|
b = NULL;
|
||||||
|
|
||||||
os_memset(¶ms, 0, sizeof(params));
|
os_memset(¶ms, 0, sizeof(params));
|
||||||
|
for (i = 0; wpa_drivers[i]; i++) {
|
||||||
|
if (wpa_drivers[i] == hapd->driver) {
|
||||||
|
params.global_priv = global.drv_priv[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
params.bssid = b;
|
params.bssid = b;
|
||||||
params.ifname = hapd->conf->iface;
|
params.ifname = hapd->conf->iface;
|
||||||
params.ssid = (const u8 *) hapd->conf->ssid.ssid;
|
params.ssid = (const u8 *) hapd->conf->ssid.ssid;
|
||||||
@ -372,6 +388,10 @@ static void handle_dump_state(int sig, void *signal_ctx)
|
|||||||
static int hostapd_global_init(struct hapd_interfaces *interfaces,
|
static int hostapd_global_init(struct hapd_interfaces *interfaces,
|
||||||
const char *entropy_file)
|
const char *entropy_file)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
os_memset(&global, 0, sizeof(global));
|
||||||
|
|
||||||
hostapd_logger_register_cb(hostapd_logger_cb);
|
hostapd_logger_register_cb(hostapd_logger_cb);
|
||||||
|
|
||||||
if (eap_server_register_methods()) {
|
if (eap_server_register_methods()) {
|
||||||
@ -396,12 +416,42 @@ static int hostapd_global_init(struct hapd_interfaces *interfaces,
|
|||||||
openlog("hostapd", 0, LOG_DAEMON);
|
openlog("hostapd", 0, LOG_DAEMON);
|
||||||
#endif /* CONFIG_NATIVE_WINDOWS */
|
#endif /* CONFIG_NATIVE_WINDOWS */
|
||||||
|
|
||||||
|
for (i = 0; wpa_drivers[i]; i++)
|
||||||
|
global.drv_count++;
|
||||||
|
if (global.drv_count == 0) {
|
||||||
|
wpa_printf(MSG_ERROR, "No drivers enabled");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
global.drv_priv = os_zalloc(global.drv_count * sizeof(void *));
|
||||||
|
if (global.drv_priv == NULL)
|
||||||
|
return -1;
|
||||||
|
for (i = 0; wpa_drivers[i]; i++) {
|
||||||
|
if (!wpa_drivers[i]->global_init)
|
||||||
|
continue;
|
||||||
|
global.drv_priv[i] = wpa_drivers[i]->global_init();
|
||||||
|
if (global.drv_priv[i] == NULL) {
|
||||||
|
wpa_printf(MSG_ERROR, "Failed to initialize driver "
|
||||||
|
"'%s'", wpa_drivers[i]->name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void hostapd_global_deinit(const char *pid_file)
|
static void hostapd_global_deinit(const char *pid_file)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; wpa_drivers[i] && global.drv_priv; i++) {
|
||||||
|
if (!global.drv_priv[i])
|
||||||
|
continue;
|
||||||
|
wpa_drivers[i]->global_deinit(global.drv_priv[i]);
|
||||||
|
}
|
||||||
|
os_free(global.drv_priv);
|
||||||
|
global.drv_priv = NULL;
|
||||||
|
|
||||||
#ifdef EAP_SERVER_TNC
|
#ifdef EAP_SERVER_TNC
|
||||||
tncs_global_deinit();
|
tncs_global_deinit();
|
||||||
#endif /* EAP_SERVER_TNC */
|
#endif /* EAP_SERVER_TNC */
|
||||||
|
@ -837,6 +837,7 @@ enum wpa_driver_if_type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct wpa_init_params {
|
struct wpa_init_params {
|
||||||
|
void *global_priv;
|
||||||
const u8 *bssid;
|
const u8 *bssid;
|
||||||
const char *ifname;
|
const char *ifname;
|
||||||
const u8 *ssid;
|
const u8 *ssid;
|
||||||
|
@ -6377,7 +6377,8 @@ static void *i802_init(struct hostapd_data *hapd,
|
|||||||
int ifindex, br_ifindex;
|
int ifindex, br_ifindex;
|
||||||
int br_added = 0;
|
int br_added = 0;
|
||||||
|
|
||||||
bss = wpa_driver_nl80211_init(hapd, params->ifname, NULL);
|
bss = wpa_driver_nl80211_init(hapd, params->ifname,
|
||||||
|
params->global_priv);
|
||||||
if (bss == NULL)
|
if (bss == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1232,6 +1232,7 @@ static void * test_driver_init(struct hostapd_data *hapd,
|
|||||||
return NULL;
|
return NULL;
|
||||||
drv->ap = 1;
|
drv->ap = 1;
|
||||||
bss = dl_list_first(&drv->bss, struct test_driver_bss, list);
|
bss = dl_list_first(&drv->bss, struct test_driver_bss, list);
|
||||||
|
drv->global = params->global_priv;
|
||||||
|
|
||||||
bss->bss_ctx = hapd;
|
bss->bss_ctx = hapd;
|
||||||
os_memcpy(bss->bssid, drv->own_addr, ETH_ALEN);
|
os_memcpy(bss->bssid, drv->own_addr, ETH_ALEN);
|
||||||
|
Loading…
Reference in New Issue
Block a user