aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2009-04-09 10:40:12 (GMT)
committerJouni Malinen <j@w1.fi>2009-04-09 10:40:12 (GMT)
commitc51218372f6ee40c3830b4cb06fa58752e546d06 (patch)
tree42936f385bc11c7fe257cd8ab62e1561c84379b7 /wpa_supplicant
parentc2220ec0b7f47841fbec71d9f4626e2705a03a89 (diff)
downloadhostap-c51218372f6ee40c3830b4cb06fa58752e546d06.zip
hostap-c51218372f6ee40c3830b4cb06fa58752e546d06.tar.gz
hostap-c51218372f6ee40c3830b4cb06fa58752e546d06.tar.bz2
Merge wpa_supplicant and hostapd driver wrapper implementations
This commit merges the driver_ops structures and implementations from hostapd/driver*.[ch] into src/drivers. This is only an initial step and there is room for number of cleanups to share code between the hostapd and wpa_supplicant parts of the wrappers to avoid unnecessary source code duplication.
Diffstat (limited to 'wpa_supplicant')
-rw-r--r--wpa_supplicant/ap.c33
-rw-r--r--wpa_supplicant/ctrl_iface.c6
-rw-r--r--wpa_supplicant/eapol_test.c2
-rw-r--r--wpa_supplicant/main.c11
-rw-r--r--wpa_supplicant/preauth_test.c3
-rw-r--r--wpa_supplicant/wpa_priv.c8
-rw-r--r--wpa_supplicant/wpa_supplicant.c28
7 files changed, 49 insertions, 42 deletions
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index d257172..03455ec 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -18,7 +18,6 @@
#include "common.h"
#include "../hostapd/hostapd.h"
#include "../hostapd/config.h"
-#include "../hostapd/driver.h"
#ifdef NEED_MLME
#include "../hostapd/ieee802_11.h"
#endif /* NEED_MLME */
@@ -245,13 +244,13 @@ static struct hostapd_hw_modes *ap_driver_get_hw_feature_data(void *priv,
}
-static struct hapd_driver_ops ap_driver_ops =
+struct wpa_driver_ops ap_driver_ops =
{
.name = "wpa_supplicant",
- .init = ap_driver_init,
- .deinit = ap_driver_deinit,
+ .hapd_init = ap_driver_init,
+ .hapd_deinit = ap_driver_deinit,
.send_ether = ap_driver_send_ether,
- .set_key = ap_driver_set_key,
+ .hapd_set_key = ap_driver_set_key,
.get_seqnum = ap_driver_get_seqnum,
.flush = ap_driver_flush,
.read_sta_data = ap_driver_read_sta_data,
@@ -263,27 +262,35 @@ static struct hapd_driver_ops ap_driver_ops =
.sta_add = ap_driver_sta_add,
.get_inact_sec = ap_driver_get_inact_sec,
.set_freq = ap_driver_set_freq,
- .set_beacon = ap_driver_set_beacon,
- .set_beacon_int = ap_driver_set_beacon_int,
+ .hapd_set_beacon = ap_driver_set_beacon,
+ .hapd_set_beacon_int = ap_driver_set_beacon_int,
.set_cts_protect = ap_driver_set_cts_protect,
.set_preamble = ap_driver_set_preamble,
.set_short_slot_time = ap_driver_set_short_slot_time,
.set_tx_queue_params = ap_driver_set_tx_queue_params,
- .get_hw_feature_data = ap_driver_get_hw_feature_data,
+ .hapd_get_hw_feature_data = ap_driver_get_hw_feature_data,
};
-struct hapd_driver_ops *hostapd_drivers[] =
-{
- &ap_driver_ops,
- NULL
-};
+extern struct wpa_driver_ops *wpa_drivers[];
static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid,
struct hostapd_config *conf)
{
struct hostapd_bss_config *bss = &conf->bss[0];
+ int j;
+
+ for (j = 0; wpa_drivers[j]; j++) {
+ if (os_strcmp("wpa_supplicant", wpa_drivers[j]->name) == 0) {
+ conf->driver = wpa_drivers[j];
+ break;
+ }
+ }
+ if (conf->driver == NULL) {
+ wpa_printf(MSG_ERROR, "No AP driver ops found");
+ return -1;
+ }
os_strlcpy(bss->iface, wpa_s->ifname, sizeof(bss->iface));
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 81c52b3..a7536d3 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -32,7 +32,7 @@
#include "wps/wps.h"
#include "ibss_rsn.h"
-extern struct wpa_driver_ops *wpa_supplicant_drivers[];
+extern struct wpa_driver_ops *wpa_drivers[];
static int wpa_supplicant_global_iface_list(struct wpa_global *global,
char *buf, int len);
@@ -1825,8 +1825,8 @@ static int wpa_supplicant_global_iface_list(struct wpa_global *global,
struct wpa_interface_info *iface = NULL, *last = NULL, *tmp;
char *pos, *end;
- for (i = 0; wpa_supplicant_drivers[i]; i++) {
- struct wpa_driver_ops *drv = wpa_supplicant_drivers[i];
+ for (i = 0; wpa_drivers[i]; i++) {
+ struct wpa_driver_ops *drv = wpa_drivers[i];
if (drv->get_interfaces == NULL)
continue;
tmp = drv->get_interfaces(global->drv_priv);
diff --git a/wpa_supplicant/eapol_test.c b/wpa_supplicant/eapol_test.c
index b188549..1b5ae68 100644
--- a/wpa_supplicant/eapol_test.c
+++ b/wpa_supplicant/eapol_test.c
@@ -35,7 +35,7 @@
extern int wpa_debug_level;
extern int wpa_debug_show_keys;
-struct wpa_driver_ops *wpa_supplicant_drivers[] = { NULL };
+struct wpa_driver_ops *wpa_drivers[] = { NULL };
struct extra_radius_attr {
diff --git a/wpa_supplicant/main.c b/wpa_supplicant/main.c
index 2ae8ae4..7e77e3f 100644
--- a/wpa_supplicant/main.c
+++ b/wpa_supplicant/main.c
@@ -21,7 +21,7 @@
#include "wpa_supplicant_i.h"
#include "driver_i.h"
-extern struct wpa_driver_ops *wpa_supplicant_drivers[];
+extern struct wpa_driver_ops *wpa_drivers[];
static void usage(void)
@@ -41,10 +41,10 @@ static void usage(void)
"drivers:\n",
wpa_supplicant_version, wpa_supplicant_license);
- for (i = 0; wpa_supplicant_drivers[i]; i++) {
+ for (i = 0; wpa_drivers[i]; i++) {
printf(" %s = %s\n",
- wpa_supplicant_drivers[i]->name,
- wpa_supplicant_drivers[i]->desc);
+ wpa_drivers[i]->name,
+ wpa_drivers[i]->desc);
}
#ifndef CONFIG_NO_STDOUT_DEBUG
@@ -79,8 +79,7 @@ static void usage(void)
printf("example:\n"
" wpa_supplicant -D%s -iwlan0 -c/etc/wpa_supplicant.conf\n",
- wpa_supplicant_drivers[i] ?
- wpa_supplicant_drivers[i]->name : "wext");
+ wpa_drivers[i] ? wpa_drivers[i]->name : "wext");
#endif /* CONFIG_NO_STDOUT_DEBUG */
}
diff --git a/wpa_supplicant/preauth_test.c b/wpa_supplicant/preauth_test.c
index db43071..3082191 100644
--- a/wpa_supplicant/preauth_test.c
+++ b/wpa_supplicant/preauth_test.c
@@ -30,12 +30,13 @@
#include "pcsc_funcs.h"
#include "preauth.h"
#include "pmksa_cache.h"
+#include "drivers/driver.h"
extern int wpa_debug_level;
extern int wpa_debug_show_keys;
-struct wpa_driver_ops *wpa_supplicant_drivers[] = { NULL };
+struct wpa_driver_ops *wpa_drivers[] = { NULL };
struct preauth_test_data {
diff --git a/wpa_supplicant/wpa_priv.c b/wpa_supplicant/wpa_priv.c
index 592e47c..0cc9fd5 100644
--- a/wpa_supplicant/wpa_priv.c
+++ b/wpa_supplicant/wpa_priv.c
@@ -692,7 +692,7 @@ static void wpa_priv_interface_deinit(struct wpa_priv_interface *iface)
}
-extern struct wpa_driver_ops *wpa_supplicant_drivers[];
+extern struct wpa_driver_ops *wpa_drivers[];
static struct wpa_priv_interface *
wpa_priv_interface_init(const char *dir, const char *params)
@@ -721,10 +721,10 @@ wpa_priv_interface_init(const char *dir, const char *params)
os_memcpy(iface->driver_name, params, len);
iface->driver_name[len] = '\0';
- for (i = 0; wpa_supplicant_drivers[i]; i++) {
+ for (i = 0; wpa_drivers[i]; i++) {
if (os_strcmp(iface->driver_name,
- wpa_supplicant_drivers[i]->name) == 0) {
- iface->driver = wpa_supplicant_drivers[i];
+ wpa_drivers[i]->name) == 0) {
+ iface->driver = wpa_drivers[i];
break;
}
}
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 716635f..ddfe706 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -114,7 +114,7 @@ const char *wpa_supplicant_full_license5 =
extern int wpa_debug_level;
extern int wpa_debug_show_keys;
extern int wpa_debug_timestamp;
-extern struct wpa_driver_ops *wpa_supplicant_drivers[];
+extern struct wpa_driver_ops *wpa_drivers[];
/* Configure default/group WEP keys for static WEP */
static int wpa_set_wep_keys(struct wpa_supplicant *wpa_s,
@@ -1533,7 +1533,7 @@ static int wpa_supplicant_set_driver(struct wpa_supplicant *wpa_s,
if (wpa_s == NULL)
return -1;
- if (wpa_supplicant_drivers[0] == NULL) {
+ if (wpa_drivers[0] == NULL) {
wpa_printf(MSG_ERROR, "No driver interfaces build into "
"wpa_supplicant.");
return -1;
@@ -1541,7 +1541,7 @@ static int wpa_supplicant_set_driver(struct wpa_supplicant *wpa_s,
if (name == NULL) {
/* default to first driver in the list */
- wpa_s->driver = wpa_supplicant_drivers[0];
+ wpa_s->driver = wpa_drivers[0];
return 0;
}
@@ -1550,11 +1550,11 @@ static int wpa_supplicant_set_driver(struct wpa_supplicant *wpa_s,
len = pos - name;
else
len = os_strlen(name);
- for (i = 0; wpa_supplicant_drivers[i]; i++) {
- if (os_strlen(wpa_supplicant_drivers[i]->name) == len &&
- os_strncmp(name, wpa_supplicant_drivers[i]->name, len) ==
+ for (i = 0; wpa_drivers[i]; i++) {
+ if (os_strlen(wpa_drivers[i]->name) == len &&
+ os_strncmp(name, wpa_drivers[i]->name, len) ==
0) {
- wpa_s->driver = wpa_supplicant_drivers[i];
+ wpa_s->driver = wpa_drivers[i];
return 0;
}
}
@@ -2159,7 +2159,7 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params)
}
}
- for (i = 0; wpa_supplicant_drivers[i]; i++)
+ for (i = 0; wpa_drivers[i]; i++)
global->drv_count++;
if (global->drv_count == 0) {
wpa_printf(MSG_ERROR, "No drivers enabled");
@@ -2171,13 +2171,13 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params)
wpa_supplicant_deinit(global);
return NULL;
}
- for (i = 0; wpa_supplicant_drivers[i]; i++) {
- if (!wpa_supplicant_drivers[i]->global_init)
+ for (i = 0; wpa_drivers[i]; i++) {
+ if (!wpa_drivers[i]->global_init)
continue;
- global->drv_priv[i] = wpa_supplicant_drivers[i]->global_init();
+ 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_supplicant_drivers[i]->name);
+ "'%s'", wpa_drivers[i]->name);
wpa_supplicant_deinit(global);
return NULL;
}
@@ -2244,10 +2244,10 @@ void wpa_supplicant_deinit(struct wpa_global *global)
eap_peer_unregister_methods();
- for (i = 0; wpa_supplicant_drivers[i] && global->drv_priv; i++) {
+ for (i = 0; wpa_drivers[i] && global->drv_priv; i++) {
if (!global->drv_priv[i])
continue;
- wpa_supplicant_drivers[i]->global_deinit(global->drv_priv[i]);
+ wpa_drivers[i]->global_deinit(global->drv_priv[i]);
}
os_free(global->drv_priv);