mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-29 02:38:22 -05:00
Convert hostapd_prepare_rates() to use struct hostapd_iface
Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
e5693c4775
commit
34445d12ee
@ -743,7 +743,7 @@ int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iface->current_mode) {
|
if (iface->current_mode) {
|
||||||
if (hostapd_prepare_rates(hapd, iface->current_mode)) {
|
if (hostapd_prepare_rates(iface, iface->current_mode)) {
|
||||||
wpa_printf(MSG_ERROR, "Failed to prepare rates "
|
wpa_printf(MSG_ERROR, "Failed to prepare rates "
|
||||||
"table.");
|
"table.");
|
||||||
hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
|
hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* hostapd / Hardware feature query and different modes
|
* hostapd / Hardware feature query and different modes
|
||||||
* Copyright 2002-2003, Instant802 Networks, Inc.
|
* Copyright 2002-2003, Instant802 Networks, Inc.
|
||||||
* Copyright 2005-2006, Devicescape Software, Inc.
|
* Copyright 2005-2006, Devicescape Software, Inc.
|
||||||
* Copyright (c) 2008-2009, Jouni Malinen <j@w1.fi>
|
* Copyright (c) 2008-2011, Jouni Malinen <j@w1.fi>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
@ -101,7 +101,7 @@ int hostapd_get_hw_features(struct hostapd_iface *iface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int hostapd_prepare_rates(struct hostapd_data *hapd,
|
int hostapd_prepare_rates(struct hostapd_iface *iface,
|
||||||
struct hostapd_hw_modes *mode)
|
struct hostapd_hw_modes *mode)
|
||||||
{
|
{
|
||||||
int i, num_basic_rates = 0;
|
int i, num_basic_rates = 0;
|
||||||
@ -110,8 +110,8 @@ int hostapd_prepare_rates(struct hostapd_data *hapd,
|
|||||||
int basic_rates_g[] = { 10, 20, 55, 110, -1 };
|
int basic_rates_g[] = { 10, 20, 55, 110, -1 };
|
||||||
int *basic_rates;
|
int *basic_rates;
|
||||||
|
|
||||||
if (hapd->iconf->basic_rates)
|
if (iface->conf->basic_rates)
|
||||||
basic_rates = hapd->iconf->basic_rates;
|
basic_rates = iface->conf->basic_rates;
|
||||||
else switch (mode->mode) {
|
else switch (mode->mode) {
|
||||||
case HOSTAPD_MODE_IEEE80211A:
|
case HOSTAPD_MODE_IEEE80211A:
|
||||||
basic_rates = basic_rates_a;
|
basic_rates = basic_rates_a;
|
||||||
@ -129,18 +129,17 @@ int hostapd_prepare_rates(struct hostapd_data *hapd,
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (basic_rates[i] >= 0)
|
while (basic_rates[i] >= 0)
|
||||||
i++;
|
i++;
|
||||||
os_free(hapd->iface->basic_rates);
|
os_free(iface->basic_rates);
|
||||||
hapd->iface->basic_rates = os_malloc(i * sizeof(int *));
|
iface->basic_rates = os_malloc(i * sizeof(int *));
|
||||||
if (hapd->iface->basic_rates)
|
if (iface->basic_rates)
|
||||||
os_memcpy(hapd->iface->basic_rates, basic_rates,
|
os_memcpy(iface->basic_rates, basic_rates, i * sizeof(int *));
|
||||||
i * sizeof(int *));
|
|
||||||
|
|
||||||
os_free(hapd->iface->current_rates);
|
os_free(iface->current_rates);
|
||||||
hapd->iface->num_rates = 0;
|
iface->num_rates = 0;
|
||||||
|
|
||||||
hapd->iface->current_rates =
|
iface->current_rates =
|
||||||
os_zalloc(mode->num_rates * sizeof(struct hostapd_rate_data));
|
os_zalloc(mode->num_rates * sizeof(struct hostapd_rate_data));
|
||||||
if (!hapd->iface->current_rates) {
|
if (!iface->current_rates) {
|
||||||
wpa_printf(MSG_ERROR, "Failed to allocate memory for rate "
|
wpa_printf(MSG_ERROR, "Failed to allocate memory for rate "
|
||||||
"table.");
|
"table.");
|
||||||
return -1;
|
return -1;
|
||||||
@ -149,27 +148,27 @@ int hostapd_prepare_rates(struct hostapd_data *hapd,
|
|||||||
for (i = 0; i < mode->num_rates; i++) {
|
for (i = 0; i < mode->num_rates; i++) {
|
||||||
struct hostapd_rate_data *rate;
|
struct hostapd_rate_data *rate;
|
||||||
|
|
||||||
if (hapd->iconf->supported_rates &&
|
if (iface->conf->supported_rates &&
|
||||||
!hostapd_rate_found(hapd->iconf->supported_rates,
|
!hostapd_rate_found(iface->conf->supported_rates,
|
||||||
mode->rates[i]))
|
mode->rates[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rate = &hapd->iface->current_rates[hapd->iface->num_rates];
|
rate = &iface->current_rates[iface->num_rates];
|
||||||
rate->rate = mode->rates[i];
|
rate->rate = mode->rates[i];
|
||||||
if (hostapd_rate_found(basic_rates, rate->rate)) {
|
if (hostapd_rate_found(basic_rates, rate->rate)) {
|
||||||
rate->flags |= HOSTAPD_RATE_BASIC;
|
rate->flags |= HOSTAPD_RATE_BASIC;
|
||||||
num_basic_rates++;
|
num_basic_rates++;
|
||||||
}
|
}
|
||||||
wpa_printf(MSG_DEBUG, "RATE[%d] rate=%d flags=0x%x",
|
wpa_printf(MSG_DEBUG, "RATE[%d] rate=%d flags=0x%x",
|
||||||
hapd->iface->num_rates, rate->rate, rate->flags);
|
iface->num_rates, rate->rate, rate->flags);
|
||||||
hapd->iface->num_rates++;
|
iface->num_rates++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hapd->iface->num_rates == 0 || num_basic_rates == 0) &&
|
if ((iface->num_rates == 0 || num_basic_rates == 0) &&
|
||||||
(!hapd->iconf->ieee80211n || !hapd->iconf->require_ht)) {
|
(!iface->conf->ieee80211n || !iface->conf->require_ht)) {
|
||||||
wpa_printf(MSG_ERROR, "No rates remaining in supported/basic "
|
wpa_printf(MSG_ERROR, "No rates remaining in supported/basic "
|
||||||
"rate sets (%d,%d).",
|
"rate sets (%d,%d).",
|
||||||
hapd->iface->num_rates, num_basic_rates);
|
iface->num_rates, num_basic_rates);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
* hostapd / Hardware feature query and different modes
|
* hostapd / Hardware feature query and different modes
|
||||||
* Copyright 2002-2003, Instant802 Networks, Inc.
|
* Copyright 2002-2003, Instant802 Networks, Inc.
|
||||||
* Copyright 2005-2006, Devicescape Software, Inc.
|
* Copyright 2005-2006, Devicescape Software, Inc.
|
||||||
|
* Copyright (c) 2008-2011, Jouni Malinen <j@w1.fi>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
@ -25,7 +26,7 @@ const char * hostapd_hw_mode_txt(int mode);
|
|||||||
int hostapd_hw_get_freq(struct hostapd_data *hapd, int chan);
|
int hostapd_hw_get_freq(struct hostapd_data *hapd, int chan);
|
||||||
int hostapd_hw_get_channel(struct hostapd_data *hapd, int freq);
|
int hostapd_hw_get_channel(struct hostapd_data *hapd, int freq);
|
||||||
int hostapd_check_ht_capab(struct hostapd_iface *iface);
|
int hostapd_check_ht_capab(struct hostapd_iface *iface);
|
||||||
int hostapd_prepare_rates(struct hostapd_data *hapd,
|
int hostapd_prepare_rates(struct hostapd_iface *iface,
|
||||||
struct hostapd_hw_modes *mode);
|
struct hostapd_hw_modes *mode);
|
||||||
#else /* NEED_AP_MLME */
|
#else /* NEED_AP_MLME */
|
||||||
static inline void
|
static inline void
|
||||||
|
Loading…
Reference in New Issue
Block a user