Remove obsoleted get_scan_results() driver_ops
This has now been replaced with get_scan_results2() in every in-tree driver.
This commit is contained in:
parent
c2e8d0a092
commit
ec8d20187d
6 changed files with 61 additions and 265 deletions
|
@ -68,57 +68,6 @@ struct hostapd_hw_modes {
|
|||
#define IEEE80211_CAP_IBSS 0x0002
|
||||
#define IEEE80211_CAP_PRIVACY 0x0010
|
||||
|
||||
#define SSID_MAX_WPA_IE_LEN 40
|
||||
/**
|
||||
* struct wpa_scan_result - Scan results (old structure)
|
||||
* @bssid: BSSID
|
||||
* @ssid: SSID
|
||||
* @ssid_len: length of the ssid
|
||||
* @wpa_ie: WPA IE
|
||||
* @wpa_ie_len: length of the wpa_ie
|
||||
* @rsn_ie: RSN IE
|
||||
* @rsn_ie_len: length of the RSN IE
|
||||
* @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
|
||||
* @caps: capability information field in host byte order
|
||||
* @qual: signal quality
|
||||
* @noise: noise level
|
||||
* @level: signal level
|
||||
* @maxrate: maximum supported rate
|
||||
* @mdie_present: Whether MDIE was included in Beacon/ProbeRsp frame
|
||||
* @mdie: Mobility domain identifier IE (IEEE 802.11r MDIE) (starting from
|
||||
* IE type field)
|
||||
* @tsf: Timestamp
|
||||
*
|
||||
* This structure is used as a generic format for scan results from the
|
||||
* driver. Each driver interface implementation is responsible for converting
|
||||
* the driver or OS specific scan results into this format.
|
||||
*
|
||||
* This structure is the old data structure used for scan results. It is
|
||||
* obsoleted by the new struct wpa_scan_res structure and the old version is
|
||||
* only included for backwards compatibility with existing driver wrapper
|
||||
* implementations. New implementations are encouraged to implement for struct
|
||||
* wpa_scan_res. The old structure will be removed at some point.
|
||||
*/
|
||||
struct wpa_scan_result {
|
||||
u8 bssid[ETH_ALEN];
|
||||
u8 ssid[32];
|
||||
size_t ssid_len;
|
||||
u8 wpa_ie[SSID_MAX_WPA_IE_LEN];
|
||||
size_t wpa_ie_len;
|
||||
u8 rsn_ie[SSID_MAX_WPA_IE_LEN];
|
||||
size_t rsn_ie_len;
|
||||
int freq;
|
||||
u16 caps;
|
||||
int qual;
|
||||
int noise;
|
||||
int level;
|
||||
int maxrate;
|
||||
int mdie_present;
|
||||
u8 mdie[5];
|
||||
u64 tsf;
|
||||
};
|
||||
|
||||
|
||||
#define WPA_SCAN_QUAL_INVALID BIT(0)
|
||||
#define WPA_SCAN_NOISE_INVALID BIT(1)
|
||||
#define WPA_SCAN_LEVEL_INVALID BIT(2)
|
||||
|
@ -674,26 +623,6 @@ struct wpa_driver_ops {
|
|||
*/
|
||||
int (*set_countermeasures)(void *priv, int enabled);
|
||||
|
||||
/**
|
||||
* get_scan_results - Fetch the latest scan results (old version)
|
||||
* @priv: private driver interface data
|
||||
* @results: pointer to buffer for scan results
|
||||
* @max_size: maximum number of entries (buffer size)
|
||||
*
|
||||
* Returns: Number of scan result entries used on success, -1 on
|
||||
* failure
|
||||
*
|
||||
* If scan results include more than max_size BSSes, max_size will be
|
||||
* returned and the remaining entries will not be included in the
|
||||
* buffer.
|
||||
*
|
||||
* This function is deprecated. New driver wrapper implementations
|
||||
* should implement support for get_scan_results2().
|
||||
*/
|
||||
int (*get_scan_results)(void *priv,
|
||||
struct wpa_scan_result *results,
|
||||
size_t max_size);
|
||||
|
||||
/**
|
||||
* deauthenticate - Request driver to deauthenticate
|
||||
* @priv: private driver interface data
|
||||
|
|
|
@ -436,20 +436,19 @@ struct bss_ie_hdr {
|
|||
/* u16 version; */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
static int
|
||||
wpa_driver_broadcom_get_scan_results(void *priv,
|
||||
struct wpa_scan_result *results,
|
||||
size_t max_size)
|
||||
static struct wpa_scan_results *
|
||||
wpa_driver_broadcom_get_scan_results(void *priv)
|
||||
{
|
||||
struct wpa_driver_broadcom_data *drv = priv;
|
||||
char *buf;
|
||||
wl_scan_results_t *wsr;
|
||||
wl_bss_info_t *wbi;
|
||||
size_t ap_num;
|
||||
struct wpa_scan_results *res;
|
||||
|
||||
buf = os_malloc(WLC_IOCTL_MAXLEN);
|
||||
if (buf == NULL)
|
||||
return -1;
|
||||
return NULL;
|
||||
|
||||
wsr = (wl_scan_results_t *) buf;
|
||||
|
||||
|
@ -459,40 +458,34 @@ wpa_driver_broadcom_get_scan_results(void *priv,
|
|||
|
||||
if (broadcom_ioctl(drv, WLC_SCAN_RESULTS, buf, WLC_IOCTL_MAXLEN) < 0) {
|
||||
os_free(buf);
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
os_memset(results, 0, max_size * sizeof(struct wpa_scan_result));
|
||||
res = os_zalloc(sizeof(*res));
|
||||
if (res == NULL) {
|
||||
os_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res->res = os_zalloc(wsr->count * sizeof(struct wpa_scan_res *));
|
||||
if (res->res == NULL) {
|
||||
os_free(res);
|
||||
os_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (ap_num = 0, wbi = wsr->bss_info; ap_num < wsr->count; ++ap_num) {
|
||||
int left;
|
||||
struct bss_ie_hdr *ie;
|
||||
|
||||
os_memcpy(results[ap_num].bssid, &wbi->BSSID, ETH_ALEN);
|
||||
os_memcpy(results[ap_num].ssid, wbi->SSID, wbi->SSID_len);
|
||||
results[ap_num].ssid_len = wbi->SSID_len;
|
||||
results[ap_num].freq = frequency_list[wbi->channel - 1];
|
||||
/* get ie's */
|
||||
wpa_hexdump(MSG_MSGDUMP, "BROADCOM: AP IEs",
|
||||
(u8 *) wbi + sizeof(*wbi), wbi->ie_length);
|
||||
ie = (struct bss_ie_hdr *) ((u8 *) wbi + sizeof(*wbi));
|
||||
for (left = wbi->ie_length; left > 0;
|
||||
left -= (ie->len + 2), ie = (struct bss_ie_hdr *)
|
||||
((u8 *) ie + 2 + ie->len)) {
|
||||
wpa_printf(MSG_MSGDUMP, "BROADCOM: IE: id:%x, len:%d",
|
||||
ie->elem_id, ie->len);
|
||||
if (ie->len >= 3)
|
||||
wpa_printf(MSG_MSGDUMP,
|
||||
"BROADCOM: oui:%02x%02x%02x",
|
||||
ie->oui[0], ie->oui[1], ie->oui[2]);
|
||||
if (ie->elem_id != 0xdd ||
|
||||
ie->len < 6 ||
|
||||
os_memcmp(ie->oui, WPA_OUI, 3) != 0)
|
||||
continue;
|
||||
os_memcpy(results[ap_num].wpa_ie, ie, ie->len + 2);
|
||||
results[ap_num].wpa_ie_len = ie->len + 2;
|
||||
struct wpa_scan_res *r;
|
||||
r = os_malloc(sizeof(*r) + wbi->ie_length);
|
||||
if (r == NULL)
|
||||
break;
|
||||
}
|
||||
res->res[res->num++] = r;
|
||||
|
||||
os_memcpy(r->bssid, &wbi->BSSID, ETH_ALEN);
|
||||
r->freq = frequency_list[wbi->channel - 1];
|
||||
/* get ie's */
|
||||
os_memcpy(r + 1, wbi + 1, wbi->ie_length);
|
||||
r->ie_len = wbi->ie_length;
|
||||
|
||||
wbi = (wl_bss_info_t *) ((u8 *) wbi + wbi->length);
|
||||
}
|
||||
|
@ -502,7 +495,7 @@ wpa_driver_broadcom_get_scan_results(void *priv,
|
|||
wsr->buflen, (unsigned long) ap_num);
|
||||
|
||||
os_free(buf);
|
||||
return ap_num;
|
||||
return res;
|
||||
}
|
||||
|
||||
static int wpa_driver_broadcom_deauthenticate(void *priv, const u8 *addr,
|
||||
|
@ -604,7 +597,7 @@ const struct wpa_driver_ops wpa_driver_broadcom_ops = {
|
|||
.deinit = wpa_driver_broadcom_deinit,
|
||||
.set_countermeasures = wpa_driver_broadcom_set_countermeasures,
|
||||
.scan2 = wpa_driver_broadcom_scan,
|
||||
.get_scan_results = wpa_driver_broadcom_get_scan_results,
|
||||
.get_scan_results2 = wpa_driver_broadcom_get_scan_results,
|
||||
.deauthenticate = wpa_driver_broadcom_deauthenticate,
|
||||
.disassociate = wpa_driver_broadcom_disassociate,
|
||||
.associate = wpa_driver_broadcom_associate,
|
||||
|
|
|
@ -3175,7 +3175,6 @@ const struct wpa_driver_ops wpa_driver_ndis_ops = {
|
|||
wpa_driver_ndis_deinit,
|
||||
NULL /* set_param */,
|
||||
NULL /* set_countermeasures */,
|
||||
NULL /* get_scan_results */,
|
||||
wpa_driver_ndis_deauthenticate,
|
||||
wpa_driver_ndis_disassociate,
|
||||
wpa_driver_ndis_associate,
|
||||
|
|
|
@ -1067,10 +1067,8 @@ static int wpa_driver_ralink_scan(void *priv,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
wpa_driver_ralink_get_scan_results(void *priv,
|
||||
struct wpa_scan_result *results,
|
||||
size_t max_size)
|
||||
static struct wpa_scan_results *
|
||||
wpa_driver_ralink_get_scan_results(void *priv)
|
||||
{
|
||||
struct wpa_driver_ralink_data *drv = priv;
|
||||
UCHAR *buf = NULL;
|
||||
|
@ -1080,9 +1078,10 @@ wpa_driver_ralink_get_scan_results(void *priv,
|
|||
int rv = 0;
|
||||
size_t ap_num;
|
||||
u8 *pos, *end;
|
||||
struct wpa_scan_results *res;
|
||||
|
||||
if (drv->g_driver_down == 1)
|
||||
return -1;
|
||||
return NULL;
|
||||
wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
|
||||
|
||||
if (drv->we_version_compiled >= 17) {
|
||||
|
@ -1093,7 +1092,7 @@ wpa_driver_ralink_get_scan_results(void *priv,
|
|||
iwr.u.data.length = 4096;
|
||||
}
|
||||
if (buf == NULL)
|
||||
return -1;
|
||||
return NULL;
|
||||
|
||||
wsr = (NDIS_802_11_BSSID_LIST_EX *) buf;
|
||||
|
||||
|
@ -1105,22 +1104,33 @@ wpa_driver_ralink_get_scan_results(void *priv,
|
|||
if ((rv = ioctl(drv->ioctl_sock, RT_PRIV_IOCTL, &iwr)) < 0) {
|
||||
wpa_printf(MSG_DEBUG, "ioctl fail: rv = %d", rv);
|
||||
os_free(buf);
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
os_memset(results, 0, max_size * sizeof(struct wpa_scan_result));
|
||||
res = os_zalloc(sizeof(*res));
|
||||
if (res == NULL) {
|
||||
os_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res->res = os_zalloc(wsr->NumberOfItems *
|
||||
sizeof(struct wpa_scan_res *));
|
||||
if (res->res == NULL) {
|
||||
os_free(res);
|
||||
os_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (ap_num = 0, wbi = wsr->Bssid; ap_num < wsr->NumberOfItems;
|
||||
++ap_num) {
|
||||
os_memcpy(results[ap_num].bssid, &wbi->MacAddress, ETH_ALEN);
|
||||
os_memcpy(results[ap_num].ssid, wbi->Ssid.Ssid,
|
||||
wbi->Ssid.SsidLength);
|
||||
results[ap_num].ssid_len = wbi->Ssid.SsidLength;
|
||||
results[ap_num].freq = (wbi->Configuration.DSConfig / 1000);
|
||||
struct wpa_scan_res *r;
|
||||
r = os_malloc(sizeof(*r) + wbi->IELength);
|
||||
if (r == NULL)
|
||||
break;
|
||||
res->res[res->num++] = r;
|
||||
|
||||
/* get ie's */
|
||||
wpa_hexdump(MSG_DEBUG, "RALINK: AP IEs",
|
||||
(u8 *) wbi + sizeof(*wbi) - 1, wbi->IELength);
|
||||
os_memcpy(r->bssid, &wbi->MacAddress, ETH_ALEN);
|
||||
r->freq = (wbi->Configuration.DSConfig / 1000);
|
||||
|
||||
pos = (u8 *) wbi + sizeof(*wbi) - 1;
|
||||
end = (u8 *) wbi + sizeof(*wbi) + wbi->IELength;
|
||||
|
@ -1129,34 +1139,17 @@ wpa_driver_ralink_get_scan_results(void *priv,
|
|||
break;
|
||||
|
||||
pos += sizeof(NDIS_802_11_FIXED_IEs) - 2;
|
||||
os_memcpy(&results[ap_num].caps, pos, 2);
|
||||
r->caps = WPA_GET_LE16(pos);
|
||||
pos += 2;
|
||||
|
||||
while (pos + 1 < end && pos + 2 + pos[1] <= end) {
|
||||
u8 ielen = 2 + pos[1];
|
||||
|
||||
if (ielen > SSID_MAX_WPA_IE_LEN) {
|
||||
pos += ielen;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pos[0] == WLAN_EID_VENDOR_SPECIFIC &&
|
||||
pos[1] >= 4 &&
|
||||
os_memcmp(pos + 2, "\x00\x50\xf2\x01", 4) == 0) {
|
||||
os_memcpy(results[ap_num].wpa_ie, pos, ielen);
|
||||
results[ap_num].wpa_ie_len = ielen;
|
||||
} else if (pos[0] == WLAN_EID_RSN) {
|
||||
os_memcpy(results[ap_num].rsn_ie, pos, ielen);
|
||||
results[ap_num].rsn_ie_len = ielen;
|
||||
}
|
||||
pos += ielen;
|
||||
}
|
||||
os_memcpy(r + 1, pos, end - pos);
|
||||
r->ie_len = end - pos;
|
||||
|
||||
wbi = (NDIS_WLAN_BSSID_EX *) ((u8 *) wbi + wbi->Length);
|
||||
}
|
||||
|
||||
os_free(buf);
|
||||
return ap_num;
|
||||
return res;
|
||||
}
|
||||
|
||||
static int ralink_set_auth_mode(struct wpa_driver_ralink_data *drv,
|
||||
|
@ -1499,7 +1492,7 @@ const struct wpa_driver_ops wpa_driver_ralink_ops = {
|
|||
.deinit = wpa_driver_ralink_deinit,
|
||||
.set_countermeasures = wpa_driver_ralink_set_countermeasures,
|
||||
.scan2 = wpa_driver_ralink_scan,
|
||||
.get_scan_results = wpa_driver_ralink_get_scan_results,
|
||||
.get_scan_results2 = wpa_driver_ralink_get_scan_results,
|
||||
.deauthenticate = wpa_driver_ralink_deauthenticate,
|
||||
.disassociate = wpa_driver_ralink_disassociate,
|
||||
.associate = wpa_driver_ralink_associate,
|
||||
|
|
|
@ -78,17 +78,6 @@ static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s,
|
|||
return -1;
|
||||
}
|
||||
|
||||
static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_scan_result *results,
|
||||
size_t max_size)
|
||||
{
|
||||
if (wpa_s->driver->get_scan_results) {
|
||||
return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
|
||||
results, max_size);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline struct wpa_scan_results * wpa_drv_get_scan_results2(
|
||||
struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
|
|
|
@ -1574,111 +1574,6 @@ static void notify_bss_changes(struct wpa_supplicant *wpa_s,
|
|||
}
|
||||
|
||||
|
||||
static struct wpa_scan_results * wpa_supplicant_get_scan_results_old(
|
||||
struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
#define SCAN_AP_LIMIT 128
|
||||
struct wpa_scan_result *results;
|
||||
int num, i;
|
||||
struct wpa_scan_results *res;
|
||||
|
||||
results = os_malloc(SCAN_AP_LIMIT * sizeof(struct wpa_scan_result));
|
||||
if (results == NULL) {
|
||||
wpa_printf(MSG_WARNING, "Failed to allocate memory for scan "
|
||||
"results");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
num = wpa_drv_get_scan_results(wpa_s, results, SCAN_AP_LIMIT);
|
||||
wpa_printf(MSG_DEBUG, "Scan results: %d", num);
|
||||
if (num < 0) {
|
||||
wpa_printf(MSG_DEBUG, "Failed to get scan results");
|
||||
os_free(results);
|
||||
return NULL;
|
||||
}
|
||||
if (num > SCAN_AP_LIMIT) {
|
||||
wpa_printf(MSG_INFO, "Not enough room for all APs (%d < %d)",
|
||||
num, SCAN_AP_LIMIT);
|
||||
num = SCAN_AP_LIMIT;
|
||||
}
|
||||
|
||||
/* Convert old scan result data structure to the new one */
|
||||
res = os_zalloc(sizeof(*res));
|
||||
if (res == NULL) {
|
||||
os_free(results);
|
||||
return NULL;
|
||||
}
|
||||
res->res = os_zalloc(num * sizeof(struct wpa_scan_res *));
|
||||
if (res->res == NULL) {
|
||||
os_free(results);
|
||||
os_free(res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
struct wpa_scan_result *bss = &results[i];
|
||||
struct wpa_scan_res *r;
|
||||
size_t ie_len;
|
||||
u8 *pos;
|
||||
|
||||
ie_len = 2 + bss->ssid_len + bss->rsn_ie_len + bss->wpa_ie_len;
|
||||
if (bss->maxrate)
|
||||
ie_len += 3;
|
||||
if (bss->mdie_present)
|
||||
ie_len += 5;
|
||||
|
||||
r = os_zalloc(sizeof(*r) + ie_len);
|
||||
if (r == NULL)
|
||||
break;
|
||||
|
||||
os_memcpy(r->bssid, bss->bssid, ETH_ALEN);
|
||||
r->freq = bss->freq;
|
||||
r->caps = bss->caps;
|
||||
r->qual = bss->qual;
|
||||
r->noise = bss->noise;
|
||||
r->level = bss->level;
|
||||
r->tsf = bss->tsf;
|
||||
r->ie_len = ie_len;
|
||||
|
||||
pos = (u8 *) (r + 1);
|
||||
|
||||
/* SSID IE */
|
||||
*pos++ = WLAN_EID_SSID;
|
||||
*pos++ = bss->ssid_len;
|
||||
os_memcpy(pos, bss->ssid, bss->ssid_len);
|
||||
pos += bss->ssid_len;
|
||||
|
||||
if (bss->maxrate) {
|
||||
/* Fake Supported Rate IE to include max rate */
|
||||
*pos++ = WLAN_EID_SUPP_RATES;
|
||||
*pos++ = 1;
|
||||
*pos++ = bss->maxrate;
|
||||
}
|
||||
|
||||
if (bss->rsn_ie_len) {
|
||||
os_memcpy(pos, bss->rsn_ie, bss->rsn_ie_len);
|
||||
pos += bss->rsn_ie_len;
|
||||
}
|
||||
|
||||
if (bss->mdie_present) {
|
||||
os_memcpy(pos, bss->mdie, 5);
|
||||
pos += 5;
|
||||
}
|
||||
|
||||
if (bss->wpa_ie_len) {
|
||||
os_memcpy(pos, bss->wpa_ie, bss->wpa_ie_len);
|
||||
pos += bss->wpa_ie_len;
|
||||
}
|
||||
|
||||
res->res[res->num++] = r;
|
||||
}
|
||||
|
||||
os_free(results);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* wpa_supplicant_get_scan_results - Get scan results
|
||||
* @wpa_s: Pointer to wpa_supplicant data
|
||||
|
@ -1709,8 +1604,6 @@ int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s)
|
|||
wpa_scan_results_free(wpa_s->scan_res);
|
||||
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
|
||||
wpa_s->scan_res = ieee80211_sta_get_scan_results(wpa_s);
|
||||
else if (wpa_s->driver->get_scan_results2 == NULL)
|
||||
wpa_s->scan_res = wpa_supplicant_get_scan_results_old(wpa_s);
|
||||
else
|
||||
wpa_s->scan_res = wpa_drv_get_scan_results2(wpa_s);
|
||||
if (wpa_s->scan_res == NULL) {
|
||||
|
|
Loading…
Reference in a new issue