mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
Use BSS table entry instead of raw scan result for connection
This commit is contained in:
parent
e48f0fb6a7
commit
6fa81a3b3f
@ -36,6 +36,7 @@
|
||||
#include "sme.h"
|
||||
#include "bgscan.h"
|
||||
#include "ap.h"
|
||||
#include "bss.h"
|
||||
|
||||
|
||||
static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
|
||||
@ -389,7 +390,7 @@ static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
|
||||
}
|
||||
|
||||
|
||||
static struct wpa_scan_res *
|
||||
static struct wpa_bss *
|
||||
wpa_supplicant_select_bss_wpa(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_ssid *group,
|
||||
struct wpa_ssid **selected_ssid)
|
||||
@ -476,7 +477,7 @@ wpa_supplicant_select_bss_wpa(struct wpa_supplicant *wpa_s,
|
||||
MAC2STR(bss->bssid),
|
||||
wpa_ssid_txt(ssid_, ssid_len));
|
||||
*selected_ssid = ssid;
|
||||
return bss;
|
||||
return wpa_bss_get(wpa_s, bss->bssid, ssid_, ssid_len);
|
||||
}
|
||||
}
|
||||
|
||||
@ -484,7 +485,7 @@ wpa_supplicant_select_bss_wpa(struct wpa_supplicant *wpa_s,
|
||||
}
|
||||
|
||||
|
||||
static struct wpa_scan_res *
|
||||
static struct wpa_bss *
|
||||
wpa_supplicant_select_bss_non_wpa(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_ssid *group,
|
||||
struct wpa_ssid **selected_ssid)
|
||||
@ -602,7 +603,7 @@ wpa_supplicant_select_bss_non_wpa(struct wpa_supplicant *wpa_s,
|
||||
MAC2STR(bss->bssid),
|
||||
wpa_ssid_txt(ssid_, ssid_len));
|
||||
*selected_ssid = ssid;
|
||||
return bss;
|
||||
return wpa_bss_get(wpa_s, bss->bssid, ssid_, ssid_len);
|
||||
}
|
||||
}
|
||||
|
||||
@ -610,11 +611,11 @@ wpa_supplicant_select_bss_non_wpa(struct wpa_supplicant *wpa_s,
|
||||
}
|
||||
|
||||
|
||||
static struct wpa_scan_res *
|
||||
static struct wpa_bss *
|
||||
wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s, struct wpa_ssid *group,
|
||||
struct wpa_ssid **selected_ssid)
|
||||
{
|
||||
struct wpa_scan_res *selected;
|
||||
struct wpa_bss *selected;
|
||||
|
||||
wpa_printf(MSG_DEBUG, "Selecting BSS from priority group %d",
|
||||
group->priority);
|
||||
@ -630,11 +631,11 @@ wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s, struct wpa_ssid *group,
|
||||
}
|
||||
|
||||
|
||||
static struct wpa_scan_res *
|
||||
static struct wpa_bss *
|
||||
wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_ssid **selected_ssid)
|
||||
{
|
||||
struct wpa_scan_res *selected = NULL;
|
||||
struct wpa_bss *selected = NULL;
|
||||
int prio;
|
||||
|
||||
while (selected == NULL) {
|
||||
@ -683,7 +684,7 @@ static void wpa_supplicant_req_new_scan(struct wpa_supplicant *wpa_s,
|
||||
|
||||
|
||||
static void wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_scan_res *selected,
|
||||
struct wpa_bss *selected,
|
||||
struct wpa_ssid *ssid)
|
||||
{
|
||||
if (wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) {
|
||||
@ -766,7 +767,7 @@ static void wpa_supplicant_rsn_preauth_scan_results(
|
||||
static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
|
||||
union wpa_event_data *data)
|
||||
{
|
||||
struct wpa_scan_res *selected;
|
||||
struct wpa_bss *selected;
|
||||
struct wpa_ssid *ssid = NULL;
|
||||
|
||||
wpa_supplicant_notify_scanning(wpa_s, 0);
|
||||
|
@ -27,10 +27,11 @@
|
||||
#include "wps_supplicant.h"
|
||||
#include "notify.h"
|
||||
#include "blacklist.h"
|
||||
#include "bss.h"
|
||||
#include "sme.h"
|
||||
|
||||
void sme_authenticate(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_scan_res *bss, struct wpa_ssid *ssid)
|
||||
struct wpa_bss *bss, struct wpa_ssid *ssid)
|
||||
{
|
||||
struct wpa_driver_auth_params params;
|
||||
struct wpa_ssid *old_ssid;
|
||||
@ -51,13 +52,8 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
|
||||
|
||||
params.freq = bss->freq;
|
||||
params.bssid = bss->bssid;
|
||||
ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
|
||||
if (ie == NULL) {
|
||||
wpa_printf(MSG_ERROR, "SME: SSID not available for the BSS");
|
||||
return;
|
||||
}
|
||||
params.ssid = ie + 2;
|
||||
params.ssid_len = ie[1];
|
||||
params.ssid = bss->ssid;
|
||||
params.ssid_len = bss->ssid_len;
|
||||
|
||||
if (wpa_s->sme.ssid_len != params.ssid_len ||
|
||||
os_memcmp(wpa_s->sme.ssid, params.ssid, params.ssid_len) != 0)
|
||||
@ -105,8 +101,8 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
|
||||
if (bssid_changed)
|
||||
wpas_notify_bssid_changed(wpa_s);
|
||||
|
||||
if (bss && (wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE) ||
|
||||
wpa_scan_get_ie(bss, WLAN_EID_RSN)) &&
|
||||
if (bss && (wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE) ||
|
||||
wpa_bss_get_ie(bss, WLAN_EID_RSN)) &&
|
||||
(ssid->key_mgmt & (WPA_KEY_MGMT_IEEE8021X | WPA_KEY_MGMT_PSK |
|
||||
WPA_KEY_MGMT_FT_IEEE8021X |
|
||||
WPA_KEY_MGMT_FT_PSK |
|
||||
@ -161,7 +157,7 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
ie = wpa_scan_get_ie(bss, WLAN_EID_MOBILITY_DOMAIN);
|
||||
ie = wpa_bss_get_ie(bss, WLAN_EID_MOBILITY_DOMAIN);
|
||||
if (ie && ie[1] >= MOBILITY_DOMAIN_ID_LEN)
|
||||
md = ie + 2;
|
||||
wpa_sm_set_ft_params(wpa_s->wpa, md, NULL, 0, NULL);
|
||||
@ -210,7 +206,7 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
|
||||
break;
|
||||
}
|
||||
if (ssid->ieee80211w != NO_IEEE80211W && bss) {
|
||||
const u8 *rsn = wpa_scan_get_ie(bss, WLAN_EID_RSN);
|
||||
const u8 *rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
|
||||
struct wpa_ie_data _ie;
|
||||
if (rsn && wpa_parse_wpa_ie(rsn, 2 + rsn[1], &_ie) == 0 &&
|
||||
_ie.capabilities &
|
||||
|
@ -18,7 +18,7 @@
|
||||
#ifdef CONFIG_SME
|
||||
|
||||
void sme_authenticate(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_scan_res *bss, struct wpa_ssid *ssid);
|
||||
struct wpa_bss *bss, struct wpa_ssid *ssid);
|
||||
void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data);
|
||||
int sme_update_ft_ies(struct wpa_supplicant *wpa_s, const u8 *md,
|
||||
const u8 *ies, size_t ies_len);
|
||||
@ -34,7 +34,7 @@ void sme_event_disassoc(struct wpa_supplicant *wpa_s,
|
||||
#else /* CONFIG_SME */
|
||||
|
||||
static inline void sme_authenticate(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_scan_res *bss,
|
||||
struct wpa_bss *bss,
|
||||
struct wpa_ssid *ssid)
|
||||
{
|
||||
}
|
||||
|
@ -791,8 +791,7 @@ static int wpa_supplicant_suites_from_ai(struct wpa_supplicant *wpa_s,
|
||||
* available).
|
||||
*/
|
||||
int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_scan_res *bss,
|
||||
struct wpa_ssid *ssid,
|
||||
struct wpa_bss *bss, struct wpa_ssid *ssid,
|
||||
u8 *wpa_ie, size_t *wpa_ie_len)
|
||||
{
|
||||
struct wpa_ie_data ie;
|
||||
@ -800,8 +799,8 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
|
||||
const u8 *bss_wpa, *bss_rsn;
|
||||
|
||||
if (bss) {
|
||||
bss_wpa = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
|
||||
bss_rsn = wpa_scan_get_ie(bss, WLAN_EID_RSN);
|
||||
bss_wpa = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
|
||||
bss_rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
|
||||
} else
|
||||
bss_wpa = bss_rsn = NULL;
|
||||
|
||||
@ -980,7 +979,7 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
|
||||
* This function is used to request %wpa_supplicant to associate with a BSS.
|
||||
*/
|
||||
void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_scan_res *bss, struct wpa_ssid *ssid)
|
||||
struct wpa_bss *bss, struct wpa_ssid *ssid)
|
||||
{
|
||||
u8 wpa_ie[80];
|
||||
size_t wpa_ie_len;
|
||||
@ -1017,19 +1016,18 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
|
||||
wpa_s->reassociate = 0;
|
||||
if (bss) {
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
const u8 *md = NULL;
|
||||
const u8 *ie, *md = NULL;
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
const u8 *ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
|
||||
wpa_msg(wpa_s, MSG_INFO, "Trying to associate with " MACSTR
|
||||
" (SSID='%s' freq=%d MHz)", MAC2STR(bss->bssid),
|
||||
ie ? wpa_ssid_txt(ie + 2, ie[1]) : "", bss->freq);
|
||||
wpa_ssid_txt(bss->ssid, bss->ssid_len), bss->freq);
|
||||
bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
|
||||
os_memset(wpa_s->bssid, 0, ETH_ALEN);
|
||||
os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN);
|
||||
if (bssid_changed)
|
||||
wpas_notify_bssid_changed(wpa_s);
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
ie = wpa_scan_get_ie(bss, WLAN_EID_MOBILITY_DOMAIN);
|
||||
ie = wpa_bss_get_ie(bss, WLAN_EID_MOBILITY_DOMAIN);
|
||||
if (ie && ie[1] >= MOBILITY_DOMAIN_ID_LEN)
|
||||
md = ie + 2;
|
||||
wpa_sm_set_ft_params(wpa_s->wpa, md, NULL, 0, NULL);
|
||||
@ -1083,8 +1081,8 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
|
||||
algs);
|
||||
}
|
||||
|
||||
if (bss && (wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE) ||
|
||||
wpa_scan_get_ie(bss, WLAN_EID_RSN)) &&
|
||||
if (bss && (wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE) ||
|
||||
wpa_bss_get_ie(bss, WLAN_EID_RSN)) &&
|
||||
(ssid->key_mgmt & (WPA_KEY_MGMT_IEEE8021X | WPA_KEY_MGMT_PSK |
|
||||
WPA_KEY_MGMT_FT_IEEE8021X |
|
||||
WPA_KEY_MGMT_FT_PSK |
|
||||
@ -1174,10 +1172,9 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
|
||||
wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATING);
|
||||
os_memset(¶ms, 0, sizeof(params));
|
||||
if (bss) {
|
||||
const u8 *ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
|
||||
params.bssid = bss->bssid;
|
||||
params.ssid = ie ? ie + 2 : (u8 *) "";
|
||||
params.ssid_len = ie ? ie[1] : 0;
|
||||
params.ssid = bss->ssid;
|
||||
params.ssid_len = bss->ssid_len;
|
||||
params.freq = bss->freq;
|
||||
} else {
|
||||
params.ssid = ssid->ssid;
|
||||
@ -1223,7 +1220,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
|
||||
break;
|
||||
}
|
||||
if (ssid->ieee80211w != NO_IEEE80211W && bss) {
|
||||
const u8 *rsn = wpa_scan_get_ie(bss, WLAN_EID_RSN);
|
||||
const u8 *rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
|
||||
struct wpa_ie_data ie;
|
||||
if (rsn && wpa_parse_wpa_ie(rsn, 2 + rsn[1], &ie) == 0 &&
|
||||
ie.capabilities &
|
||||
|
@ -34,6 +34,7 @@ struct wpa_sm;
|
||||
struct wpa_supplicant;
|
||||
struct ibss_rsn;
|
||||
struct scan_info;
|
||||
struct wpa_bss;
|
||||
|
||||
/*
|
||||
* Forward declarations of private structures used within the ctrl_iface
|
||||
@ -437,11 +438,10 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
|
||||
const char * wpa_supplicant_state_txt(enum wpa_states state);
|
||||
int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
|
||||
int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_scan_res *bss,
|
||||
struct wpa_ssid *ssid,
|
||||
struct wpa_bss *bss, struct wpa_ssid *ssid,
|
||||
u8 *wpa_ie, size_t *wpa_ie_len);
|
||||
void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_scan_res *bss,
|
||||
struct wpa_bss *bss,
|
||||
struct wpa_ssid *ssid);
|
||||
void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_ssid *ssid);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* wpa_supplicant / WPS integration
|
||||
* Copyright (c) 2008, Jouni Malinen <j@w1.fi>
|
||||
* Copyright (c) 2008-2010, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@ -993,30 +993,28 @@ int wpas_wps_ssid_wildcard_ok(struct wpa_supplicant *wpa_s,
|
||||
|
||||
|
||||
int wpas_wps_scan_pbc_overlap(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_scan_res *selected,
|
||||
struct wpa_ssid *ssid)
|
||||
struct wpa_bss *selected, struct wpa_ssid *ssid)
|
||||
{
|
||||
const u8 *sel_uuid, *uuid;
|
||||
size_t i;
|
||||
struct wpabuf *wps_ie;
|
||||
int ret = 0;
|
||||
struct wpa_bss *bss;
|
||||
|
||||
if (!eap_is_wps_pbc_enrollee(&ssid->eap))
|
||||
return 0;
|
||||
|
||||
/* Make sure that only one AP is in active PBC mode */
|
||||
wps_ie = wpa_scan_get_vendor_ie_multi(selected, WPS_IE_VENDOR_TYPE);
|
||||
wps_ie = wpa_bss_get_vendor_ie_multi(selected, WPS_IE_VENDOR_TYPE);
|
||||
if (wps_ie)
|
||||
sel_uuid = wps_get_uuid_e(wps_ie);
|
||||
else
|
||||
sel_uuid = NULL;
|
||||
|
||||
for (i = 0; i < wpa_s->scan_res->num; i++) {
|
||||
struct wpa_scan_res *bss = wpa_s->scan_res->res[i];
|
||||
dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
|
||||
struct wpabuf *ie;
|
||||
if (bss == selected)
|
||||
continue;
|
||||
ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
|
||||
ie = wpa_bss_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
|
||||
if (!ie)
|
||||
continue;
|
||||
if (!wps_is_selected_pbc_registrar(ie)) {
|
||||
@ -1044,15 +1042,14 @@ int wpas_wps_scan_pbc_overlap(struct wpa_supplicant *wpa_s,
|
||||
|
||||
void wpas_wps_notify_scan_results(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
size_t i;
|
||||
struct wpa_bss *bss;
|
||||
|
||||
if (wpa_s->disconnected || wpa_s->wpa_state >= WPA_ASSOCIATED)
|
||||
return;
|
||||
|
||||
for (i = 0; i < wpa_s->scan_res->num; i++) {
|
||||
struct wpa_scan_res *bss = wpa_s->scan_res->res[i];
|
||||
dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
|
||||
struct wpabuf *ie;
|
||||
ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
|
||||
ie = wpa_bss_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
|
||||
if (!ie)
|
||||
continue;
|
||||
if (wps_is_selected_pbc_registrar(ie))
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "wps/wps.h"
|
||||
#include "wps/wps_defs.h"
|
||||
|
||||
struct wpa_bss;
|
||||
|
||||
struct wps_new_ap_settings {
|
||||
const char *ssid_hex;
|
||||
const char *auth;
|
||||
@ -43,8 +45,7 @@ int wpas_wps_ssid_bss_match(struct wpa_supplicant *wpa_s,
|
||||
int wpas_wps_ssid_wildcard_ok(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_ssid *ssid, struct wpa_scan_res *bss);
|
||||
int wpas_wps_scan_pbc_overlap(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_scan_res *selected,
|
||||
struct wpa_ssid *ssid);
|
||||
struct wpa_bss *selected, struct wpa_ssid *ssid);
|
||||
void wpas_wps_notify_scan_results(struct wpa_supplicant *wpa_s);
|
||||
int wpas_wps_searching(struct wpa_supplicant *wpa_s);
|
||||
int wpas_wps_scan_result_text(const u8 *ies, size_t ies_len, char *pos,
|
||||
|
Loading…
Reference in New Issue
Block a user