Determiner whether driver is wired at runtime based on capabilities

Do not use just the driver name for this since driver_ndis.c supports
both wired and wireless NDIS drivers and needs to indicate the driver
type after initialization.
This commit is contained in:
Jouni Malinen 2009-03-07 22:05:43 +02:00
parent ed843aaa33
commit 4ef1e644eb
7 changed files with 34 additions and 16 deletions

View file

@ -368,6 +368,7 @@ struct wpa_driver_capa {
/* Driver takes care of RSN 4-way handshake internally; PMK is configured with
* struct wpa_driver_ops::set_key using alg = WPA_ALG_PMK */
#define WPA_DRIVER_FLAGS_4WAY_HANDSHAKE 0x00000008
#define WPA_DRIVER_FLAGS_WIRED 0x00000010
unsigned int flags;
int max_scan_ssids;
@ -1084,13 +1085,6 @@ struct wpa_driver_ops {
int (*scan2)(void *priv, struct wpa_driver_scan_params *params);
};
/* Function to check whether a driver is for wired connections */
static inline int IS_WIRED(const struct wpa_driver_ops *drv)
{
return os_strcmp(drv->name, "wired") == 0 ||
os_strcmp(drv->name, "roboswitch") == 0;
}
/**
* enum wpa_event_type - Event type for wpa_supplicant_event() calls
*/

View file

@ -2794,11 +2794,17 @@ static void * wpa_driver_ndis_init(void *ctx, const char *ifname)
(int) mode);
/* Try to continue anyway */
if (!drv->has_capability && drv->capa.enc == 0) {
if (!drv->has_capability || drv->capa.enc == 0) {
/*
* Note: This will also happen with NDIS 6 drivers with
* Vista.
*/
wpa_printf(MSG_DEBUG, "NDIS: Driver did not provide "
"any wireless capabilities - assume it is "
"a wired interface");
drv->wired = 1;
drv->capa.flags |= WPA_DRIVER_FLAGS_WIRED;
drv->has_capability = 1;
}
}

View file

@ -172,6 +172,15 @@ static int wpa_driver_roboswitch_get_bssid(void *priv, u8 *bssid)
}
static int wpa_driver_roboswitch_get_capa(void *priv,
struct wpa_driver_capa *capa)
{
os_memset(capa, 0, sizeof(*capa));
capa->flags = WPA_DRIVER_FLAGS_WIRED;
return 0;
}
static const char * wpa_driver_roboswitch_get_ifname(void *priv)
{
struct wpa_driver_roboswitch_data *drv = priv;
@ -438,6 +447,7 @@ const struct wpa_driver_ops wpa_driver_roboswitch_ops = {
.desc = "wpa_supplicant roboswitch driver",
.get_ssid = wpa_driver_roboswitch_get_ssid,
.get_bssid = wpa_driver_roboswitch_get_bssid,
.get_capa = wpa_driver_roboswitch_get_capa,
.init = wpa_driver_roboswitch_init,
.deinit = wpa_driver_roboswitch_deinit,
.get_ifname = wpa_driver_roboswitch_get_ifname,

View file

@ -53,6 +53,14 @@ static int wpa_driver_wired_get_bssid(void *priv, u8 *bssid)
}
static int wpa_driver_wired_get_capa(void *priv, struct wpa_driver_capa *capa)
{
os_memset(capa, 0, sizeof(*capa));
capa->flags = WPA_DRIVER_FLAGS_WIRED;
return 0;
}
static int wpa_driver_wired_get_ifflags(const char *ifname, int *flags)
{
struct ifreq ifr;
@ -272,6 +280,7 @@ const struct wpa_driver_ops wpa_driver_wired_ops = {
.desc = "wpa_supplicant wired Ethernet driver",
.get_ssid = wpa_driver_wired_get_ssid,
.get_bssid = wpa_driver_wired_get_bssid,
.get_capa = wpa_driver_wired_get_capa,
.init = wpa_driver_wired_init,
.deinit = wpa_driver_wired_deinit,
};

View file

@ -129,8 +129,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
return;
}
if (wpa_s->conf->ap_scan != 0 &&
wpa_s->driver && IS_WIRED(wpa_s->driver)) {
if (wpa_s->conf->ap_scan != 0 && wpa_s->drv_wired) {
wpa_printf(MSG_DEBUG, "Using wired authentication - "
"overriding ap_scan configuration");
wpa_s->conf->ap_scan = 0;

View file

@ -211,8 +211,7 @@ static void wpa_supplicant_timeout(void *eloop_ctx, void *timeout_ctx)
void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
int sec, int usec)
{
if (wpa_s->conf && wpa_s->conf->ap_scan == 0 &&
wpa_s->driver && IS_WIRED(wpa_s->driver))
if (wpa_s->conf && wpa_s->conf->ap_scan == 0 && wpa_s->drv_wired)
return;
wpa_msg(wpa_s, MSG_DEBUG, "Setting authentication timeout: %d sec "
@ -287,9 +286,8 @@ void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s)
EAPOL_REQUIRE_KEY_BROADCAST;
}
if (wpa_s->conf && wpa_s->driver && IS_WIRED(wpa_s->driver)) {
if (wpa_s->conf && wpa_s->drv_wired)
eapol_conf.required_keys = 0;
}
}
if (wpa_s->conf)
eapol_conf.fast_reauth = wpa_s->conf->fast_reauth;
@ -1461,8 +1459,7 @@ struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s)
return NULL;
}
wired = wpa_s->conf->ap_scan == 0 && wpa_s->driver &&
IS_WIRED(wpa_s->driver);
wired = wpa_s->conf->ap_scan == 0 && wpa_s->drv_wired;
entry = wpa_s->conf->ssid;
while (entry) {
@ -1908,6 +1905,8 @@ next_driver:
if (capa.flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE)
wpa_s->driver_4way_handshake = 1;
wpa_s->max_scan_ssids = capa.max_scan_ssids;
if (capa.flags & WPA_DRIVER_FLAGS_WIRED)
wpa_s->drv_wired = 1;
}
#ifdef CONFIG_IBSS_RSN

View file

@ -311,6 +311,7 @@ struct wpa_supplicant {
int mgmt_group_cipher;
void *drv_priv; /* private data used by driver_ops */
int drv_wired;
struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
* NULL = not yet initialized (start