Share same hw_feature definitions between hostapd and wpa_supplicant
This commit is contained in:
parent
0892aaaf51
commit
6caf9ca68c
11 changed files with 89 additions and 127 deletions
|
@ -312,14 +312,6 @@ struct hostapd_bss_config {
|
|||
};
|
||||
|
||||
|
||||
typedef enum {
|
||||
HOSTAPD_MODE_IEEE80211B,
|
||||
HOSTAPD_MODE_IEEE80211G,
|
||||
HOSTAPD_MODE_IEEE80211A,
|
||||
NUM_HOSTAPD_MODES
|
||||
} hostapd_hw_mode;
|
||||
|
||||
|
||||
/**
|
||||
* struct hostapd_config - Per-radio interface configuration
|
||||
*/
|
||||
|
|
|
@ -513,7 +513,7 @@ int hostapd_select_hw_mode(struct hostapd_iface *iface)
|
|||
iface->current_mode = NULL;
|
||||
for (i = 0; i < iface->num_hw_features; i++) {
|
||||
struct hostapd_hw_modes *mode = &iface->hw_features[i];
|
||||
if (mode->mode == (int) iface->conf->hw_mode) {
|
||||
if (mode->mode == iface->conf->hw_mode) {
|
||||
iface->current_mode = mode;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -16,41 +16,6 @@
|
|||
#ifndef HW_FEATURES_H
|
||||
#define HW_FEATURES_H
|
||||
|
||||
#define HOSTAPD_CHAN_DISABLED 0x00000001
|
||||
#define HOSTAPD_CHAN_PASSIVE_SCAN 0x00000002
|
||||
#define HOSTAPD_CHAN_NO_IBSS 0x00000004
|
||||
#define HOSTAPD_CHAN_RADAR 0x00000008
|
||||
|
||||
struct hostapd_channel_data {
|
||||
short chan; /* channel number (IEEE 802.11) */
|
||||
short freq; /* frequency in MHz */
|
||||
int flag; /* flag for hostapd use (HOSTAPD_CHAN_*) */
|
||||
u8 max_tx_power; /* maximum transmit power in dBm */
|
||||
};
|
||||
|
||||
#define HOSTAPD_RATE_ERP 0x00000001
|
||||
#define HOSTAPD_RATE_BASIC 0x00000002
|
||||
#define HOSTAPD_RATE_PREAMBLE2 0x00000004
|
||||
#define HOSTAPD_RATE_SUPPORTED 0x00000010
|
||||
#define HOSTAPD_RATE_OFDM 0x00000020
|
||||
#define HOSTAPD_RATE_CCK 0x00000040
|
||||
#define HOSTAPD_RATE_MANDATORY 0x00000100
|
||||
|
||||
struct hostapd_rate_data {
|
||||
int rate; /* rate in 100 kbps */
|
||||
int flags; /* HOSTAPD_RATE_ flags */
|
||||
};
|
||||
|
||||
struct hostapd_hw_modes {
|
||||
int mode;
|
||||
int num_channels;
|
||||
struct hostapd_channel_data *channels;
|
||||
int num_rates;
|
||||
struct hostapd_rate_data *rates;
|
||||
u16 ht_capab;
|
||||
};
|
||||
|
||||
|
||||
#ifdef NEED_MLME
|
||||
void hostapd_free_hw_features(struct hostapd_hw_modes *hw_features,
|
||||
size_t num_hw_features);
|
||||
|
|
|
@ -213,4 +213,48 @@ enum mfp_options {
|
|||
IEEE80211W_REQUIRED = 2
|
||||
};
|
||||
|
||||
|
||||
/* Hardware features */
|
||||
|
||||
#define HOSTAPD_CHAN_DISABLED 0x00000001
|
||||
#define HOSTAPD_CHAN_PASSIVE_SCAN 0x00000002
|
||||
#define HOSTAPD_CHAN_NO_IBSS 0x00000004
|
||||
#define HOSTAPD_CHAN_RADAR 0x00000008
|
||||
|
||||
struct hostapd_channel_data {
|
||||
short chan; /* channel number (IEEE 802.11) */
|
||||
short freq; /* frequency in MHz */
|
||||
int flag; /* flag for hostapd use (HOSTAPD_CHAN_*) */
|
||||
u8 max_tx_power; /* maximum transmit power in dBm */
|
||||
};
|
||||
|
||||
#define HOSTAPD_RATE_ERP 0x00000001
|
||||
#define HOSTAPD_RATE_BASIC 0x00000002
|
||||
#define HOSTAPD_RATE_PREAMBLE2 0x00000004
|
||||
#define HOSTAPD_RATE_SUPPORTED 0x00000010
|
||||
#define HOSTAPD_RATE_OFDM 0x00000020
|
||||
#define HOSTAPD_RATE_CCK 0x00000040
|
||||
#define HOSTAPD_RATE_MANDATORY 0x00000100
|
||||
|
||||
struct hostapd_rate_data {
|
||||
int rate; /* rate in 100 kbps */
|
||||
int flags; /* HOSTAPD_RATE_ flags */
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
HOSTAPD_MODE_IEEE80211B,
|
||||
HOSTAPD_MODE_IEEE80211G,
|
||||
HOSTAPD_MODE_IEEE80211A,
|
||||
NUM_HOSTAPD_MODES
|
||||
} hostapd_hw_mode;
|
||||
|
||||
struct hostapd_hw_modes {
|
||||
hostapd_hw_mode mode;
|
||||
int num_channels;
|
||||
struct hostapd_channel_data *channels;
|
||||
int num_rates;
|
||||
struct hostapd_rate_data *rates;
|
||||
u16 ht_capab;
|
||||
};
|
||||
|
||||
#endif /* DEFS_H */
|
||||
|
|
|
@ -411,45 +411,6 @@ struct wpa_driver_capa {
|
|||
};
|
||||
|
||||
|
||||
#define WPA_CHAN_W_SCAN 0x00000001
|
||||
#define WPA_CHAN_W_ACTIVE_SCAN 0x00000002
|
||||
#define WPA_CHAN_W_IBSS 0x00000004
|
||||
|
||||
struct wpa_channel_data {
|
||||
short chan; /* channel number (IEEE 802.11) */
|
||||
short freq; /* frequency in MHz */
|
||||
int flag; /* flag for user space use (WPA_CHAN_*) */
|
||||
};
|
||||
|
||||
#define WPA_RATE_ERP 0x00000001
|
||||
#define WPA_RATE_BASIC 0x00000002
|
||||
#define WPA_RATE_PREAMBLE2 0x00000004
|
||||
#define WPA_RATE_SUPPORTED 0x00000010
|
||||
#define WPA_RATE_OFDM 0x00000020
|
||||
#define WPA_RATE_CCK 0x00000040
|
||||
#define WPA_RATE_MANDATORY 0x00000100
|
||||
|
||||
struct wpa_rate_data {
|
||||
int rate; /* rate in 100 kbps */
|
||||
int flags; /* WPA_RATE_ flags */
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
WPA_MODE_IEEE80211B,
|
||||
WPA_MODE_IEEE80211G,
|
||||
WPA_MODE_IEEE80211A,
|
||||
NUM_WPA_MODES
|
||||
} wpa_hw_mode;
|
||||
|
||||
struct wpa_hw_modes {
|
||||
wpa_hw_mode mode;
|
||||
int num_channels;
|
||||
struct wpa_channel_data *channels;
|
||||
int num_rates;
|
||||
struct wpa_rate_data *rates;
|
||||
};
|
||||
|
||||
|
||||
struct ieee80211_rx_status {
|
||||
int channel;
|
||||
int ssi;
|
||||
|
@ -910,14 +871,14 @@ struct wpa_driver_ops {
|
|||
* This function is only needed for drivers that export MLME
|
||||
* (management frame processing) to wpa_supplicant.
|
||||
*/
|
||||
struct wpa_hw_modes * (*get_hw_feature_data)(void *priv,
|
||||
struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
|
||||
u16 *num_modes,
|
||||
u16 *flags);
|
||||
|
||||
/**
|
||||
* set_channel - Set channel
|
||||
* @priv: Private driver interface data
|
||||
* @phymode: WPA_MODE_IEEE80211B, ..
|
||||
* @phymode: HOSTAPD_MODE_IEEE80211B, ..
|
||||
* @chan: IEEE 802.11 channel number
|
||||
* @freq: Frequency of the channel in MHz
|
||||
* Returns: 0 on success, -1 on failure
|
||||
|
@ -925,7 +886,7 @@ struct wpa_driver_ops {
|
|||
* This function is only needed for drivers that export MLME
|
||||
* (management frame processing) to wpa_supplicant.
|
||||
*/
|
||||
int (*set_channel)(void *priv, wpa_hw_mode phymode, int chan,
|
||||
int (*set_channel)(void *priv, hostapd_hw_mode phymode, int chan,
|
||||
int freq);
|
||||
|
||||
/**
|
||||
|
@ -1524,7 +1485,7 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
|
|||
|
||||
void wpa_supplicant_sta_rx(void *ctx, const u8 *buf, size_t len,
|
||||
struct ieee80211_rx_status *rx_status);
|
||||
void wpa_supplicant_sta_free_hw_features(struct wpa_hw_modes *hw_features,
|
||||
void wpa_supplicant_sta_free_hw_features(struct hostapd_hw_modes *hw_features,
|
||||
size_t num_hw_features);
|
||||
|
||||
const u8 * wpa_scan_get_ie(const struct wpa_scan_res *res, u8 ie);
|
||||
|
|
|
@ -1047,37 +1047,37 @@ static int wpa_driver_test_mlme_setprotection(void *priv, const u8 *addr,
|
|||
|
||||
|
||||
#ifdef CONFIG_CLIENT_MLME
|
||||
static struct wpa_hw_modes *
|
||||
static struct hostapd_hw_modes *
|
||||
wpa_driver_test_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags)
|
||||
{
|
||||
struct wpa_hw_modes *modes;
|
||||
struct hostapd_hw_modes *modes;
|
||||
|
||||
*num_modes = 1;
|
||||
*flags = 0;
|
||||
modes = os_zalloc(*num_modes * sizeof(struct wpa_hw_modes));
|
||||
modes = os_zalloc(*num_modes * sizeof(struct hostapd_hw_modes));
|
||||
if (modes == NULL)
|
||||
return NULL;
|
||||
modes[0].mode = WPA_MODE_IEEE80211G;
|
||||
modes[0].mode = HOSTAPD_MODE_IEEE80211G;
|
||||
modes[0].num_channels = 1;
|
||||
modes[0].num_rates = 1;
|
||||
modes[0].channels = os_zalloc(sizeof(struct wpa_channel_data));
|
||||
modes[0].rates = os_zalloc(sizeof(struct wpa_rate_data));
|
||||
modes[0].channels = os_zalloc(sizeof(struct hostapd_channel_data));
|
||||
modes[0].rates = os_zalloc(sizeof(struct hostapd_rate_data));
|
||||
if (modes[0].channels == NULL || modes[0].rates == NULL) {
|
||||
wpa_supplicant_sta_free_hw_features(modes, *num_modes);
|
||||
return NULL;
|
||||
}
|
||||
modes[0].channels[0].chan = 1;
|
||||
modes[0].channels[0].freq = 2412;
|
||||
modes[0].channels[0].flag = WPA_CHAN_W_SCAN | WPA_CHAN_W_ACTIVE_SCAN;
|
||||
modes[0].channels[0].flag = 0;
|
||||
modes[0].rates[0].rate = 10;
|
||||
modes[0].rates[0].flags = WPA_RATE_BASIC | WPA_RATE_SUPPORTED |
|
||||
WPA_RATE_CCK | WPA_RATE_MANDATORY;
|
||||
modes[0].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED |
|
||||
HOSTAPD_RATE_CCK | HOSTAPD_RATE_MANDATORY;
|
||||
|
||||
return modes;
|
||||
}
|
||||
|
||||
|
||||
static int wpa_driver_test_set_channel(void *priv, wpa_hw_mode phymode,
|
||||
static int wpa_driver_test_set_channel(void *priv, hostapd_hw_mode phymode,
|
||||
int chan, int freq)
|
||||
{
|
||||
wpa_printf(MSG_DEBUG, "%s: phymode=%d chan=%d freq=%d",
|
||||
|
|
|
@ -275,7 +275,7 @@ static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline struct wpa_hw_modes *
|
||||
static inline struct hostapd_hw_modes *
|
||||
wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
|
||||
u16 *flags)
|
||||
{
|
||||
|
@ -286,7 +286,7 @@ wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
|
|||
}
|
||||
|
||||
static inline int wpa_drv_set_channel(struct wpa_supplicant *wpa_s,
|
||||
wpa_hw_mode phymode, int chan,
|
||||
hostapd_hw_mode phymode, int chan,
|
||||
int freq)
|
||||
{
|
||||
if (wpa_s->driver->set_channel)
|
||||
|
|
|
@ -98,11 +98,11 @@ static void ieee80211_build_tspec(struct wpabuf *buf);
|
|||
|
||||
|
||||
static int ieee80211_sta_set_channel(struct wpa_supplicant *wpa_s,
|
||||
wpa_hw_mode phymode, int chan,
|
||||
hostapd_hw_mode phymode, int chan,
|
||||
int freq)
|
||||
{
|
||||
size_t i;
|
||||
struct wpa_hw_modes *mode;
|
||||
struct hostapd_hw_modes *mode;
|
||||
|
||||
for (i = 0; i < wpa_s->mlme.num_modes; i++) {
|
||||
mode = &wpa_s->mlme.modes[i];
|
||||
|
@ -339,7 +339,7 @@ static void ieee80211_send_assoc(struct wpa_supplicant *wpa_s)
|
|||
blen = 0;
|
||||
|
||||
capab = wpa_s->mlme.capab;
|
||||
if (wpa_s->mlme.phymode == WPA_MODE_IEEE80211G) {
|
||||
if (wpa_s->mlme.phymode == HOSTAPD_MODE_IEEE80211G) {
|
||||
capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME |
|
||||
WLAN_CAPABILITY_SHORT_PREAMBLE;
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ static void ieee80211_send_probe_req(struct wpa_supplicant *wpa_s,
|
|||
supp_rates[0] = WLAN_EID_SUPP_RATES;
|
||||
supp_rates[1] = 0;
|
||||
for (i = 0; i < wpa_s->mlme.num_curr_rates; i++) {
|
||||
struct wpa_rate_data *rate = &wpa_s->mlme.curr_rates[i];
|
||||
struct hostapd_rate_data *rate = &wpa_s->mlme.curr_rates[i];
|
||||
if (esupp_rates) {
|
||||
pos = buf + len;
|
||||
len++;
|
||||
|
@ -1600,8 +1600,8 @@ static void ieee80211_bss_info(struct wpa_supplicant *wpa_s,
|
|||
bss->channel = channel;
|
||||
bss->freq = wpa_s->mlme.freq;
|
||||
if (channel != wpa_s->mlme.channel &&
|
||||
(wpa_s->mlme.phymode == WPA_MODE_IEEE80211G ||
|
||||
wpa_s->mlme.phymode == WPA_MODE_IEEE80211B) &&
|
||||
(wpa_s->mlme.phymode == HOSTAPD_MODE_IEEE80211G ||
|
||||
wpa_s->mlme.phymode == HOSTAPD_MODE_IEEE80211B) &&
|
||||
channel >= 1 && channel <= 14) {
|
||||
static const int freq_list[] = {
|
||||
2412, 2417, 2422, 2427, 2432, 2437, 2442,
|
||||
|
@ -2692,14 +2692,14 @@ static int ieee80211_active_scan(struct wpa_supplicant *wpa_s)
|
|||
int c;
|
||||
|
||||
for (m = 0; m < wpa_s->mlme.num_modes; m++) {
|
||||
struct wpa_hw_modes *mode = &wpa_s->mlme.modes[m];
|
||||
struct hostapd_hw_modes *mode = &wpa_s->mlme.modes[m];
|
||||
if ((int) mode->mode != (int) wpa_s->mlme.phymode)
|
||||
continue;
|
||||
for (c = 0; c < mode->num_channels; c++) {
|
||||
struct wpa_channel_data *chan = &mode->channels[c];
|
||||
if (chan->flag & WPA_CHAN_W_SCAN &&
|
||||
struct hostapd_channel_data *chan = &mode->channels[c];
|
||||
if (!(chan->flag & HOSTAPD_CHAN_DISABLED) &&
|
||||
chan->chan == wpa_s->mlme.channel) {
|
||||
if (chan->flag & WPA_CHAN_W_ACTIVE_SCAN)
|
||||
if (!(chan->flag & HOSTAPD_CHAN_PASSIVE_SCAN))
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
@ -2713,8 +2713,8 @@ static int ieee80211_active_scan(struct wpa_supplicant *wpa_s)
|
|||
static void ieee80211_sta_scan_timer(void *eloop_ctx, void *timeout_ctx)
|
||||
{
|
||||
struct wpa_supplicant *wpa_s = eloop_ctx;
|
||||
struct wpa_hw_modes *mode;
|
||||
struct wpa_channel_data *chan;
|
||||
struct hostapd_hw_modes *mode;
|
||||
struct hostapd_channel_data *chan;
|
||||
int skip = 0;
|
||||
int timeout = 0;
|
||||
struct wpa_ssid *ssid = wpa_s->current_ssid;
|
||||
|
@ -2753,10 +2753,10 @@ static void ieee80211_sta_scan_timer(void *eloop_ctx, void *timeout_ctx)
|
|||
}
|
||||
skip = !(wpa_s->mlme.hw_modes & (1 << mode->mode));
|
||||
chan = &mode->channels[wpa_s->mlme.scan_channel_idx];
|
||||
if (!(chan->flag & WPA_CHAN_W_SCAN) ||
|
||||
(adhoc && !(chan->flag & WPA_CHAN_W_IBSS)) ||
|
||||
(wpa_s->mlme.hw_modes & (1 << WPA_MODE_IEEE80211G) &&
|
||||
mode->mode == WPA_MODE_IEEE80211B &&
|
||||
if ((chan->flag & HOSTAPD_CHAN_DISABLED) ||
|
||||
(adhoc && (chan->flag & HOSTAPD_CHAN_NO_IBSS)) ||
|
||||
(wpa_s->mlme.hw_modes & (1 << HOSTAPD_MODE_IEEE80211G) &&
|
||||
mode->mode == HOSTAPD_MODE_IEEE80211B &&
|
||||
wpa_s->mlme.scan_skip_11b))
|
||||
skip = 1;
|
||||
|
||||
|
@ -3019,7 +3019,7 @@ void ieee80211_sta_rx(struct wpa_supplicant *wpa_s, const u8 *buf, size_t len,
|
|||
}
|
||||
|
||||
|
||||
void ieee80211_sta_free_hw_features(struct wpa_hw_modes *hw_features,
|
||||
void ieee80211_sta_free_hw_features(struct hostapd_hw_modes *hw_features,
|
||||
size_t num_hw_features)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -3050,9 +3050,9 @@ int ieee80211_sta_init(struct wpa_supplicant *wpa_s)
|
|||
|
||||
wpa_s->mlme.num_modes = num_modes;
|
||||
|
||||
wpa_s->mlme.hw_modes = 1 << WPA_MODE_IEEE80211A;
|
||||
wpa_s->mlme.hw_modes |= 1 << WPA_MODE_IEEE80211B;
|
||||
wpa_s->mlme.hw_modes |= 1 << WPA_MODE_IEEE80211G;
|
||||
wpa_s->mlme.hw_modes = 1 << HOSTAPD_MODE_IEEE80211A;
|
||||
wpa_s->mlme.hw_modes |= 1 << HOSTAPD_MODE_IEEE80211B;
|
||||
wpa_s->mlme.hw_modes |= 1 << HOSTAPD_MODE_IEEE80211G;
|
||||
|
||||
wpa_s->mlme.wmm_enabled = 1;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ int ieee80211_sta_associate(struct wpa_supplicant *wpa_s,
|
|||
struct wpa_driver_associate_params *params);
|
||||
int ieee80211_sta_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid,
|
||||
size_t *len);
|
||||
void ieee80211_sta_free_hw_features(struct wpa_hw_modes *hw_features,
|
||||
void ieee80211_sta_free_hw_features(struct hostapd_hw_modes *hw_features,
|
||||
size_t num_hw_features);
|
||||
void ieee80211_sta_rx(struct wpa_supplicant *wpa_s, const u8 *buf, size_t len,
|
||||
struct ieee80211_rx_status *rx_status);
|
||||
|
|
|
@ -1631,7 +1631,7 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
|
|||
}
|
||||
|
||||
|
||||
void wpa_supplicant_sta_free_hw_features(struct wpa_hw_modes *hw_features,
|
||||
void wpa_supplicant_sta_free_hw_features(struct hostapd_hw_modes *hw_features,
|
||||
size_t num_hw_features)
|
||||
{
|
||||
ieee80211_sta_free_hw_features(hw_features, num_hw_features);
|
||||
|
|
|
@ -248,13 +248,13 @@ struct wpa_client_mlme {
|
|||
|
||||
int cts_protect_erp_frames;
|
||||
|
||||
int phymode; /* current mode; WPA_MODE_IEEE80211A, .. */
|
||||
struct wpa_hw_modes *modes;
|
||||
hostapd_hw_mode phymode; /* current mode */
|
||||
struct hostapd_hw_modes *modes;
|
||||
size_t num_modes;
|
||||
unsigned int hw_modes; /* bitfield of allowed hardware modes;
|
||||
* (1 << MODE_*) */
|
||||
* (1 << HOSTAPD_MODE_*) */
|
||||
int num_curr_rates;
|
||||
struct wpa_rate_data *curr_rates;
|
||||
struct hostapd_rate_data *curr_rates;
|
||||
int freq; /* The current frequency in MHz */
|
||||
int channel; /* The current IEEE 802.11 channel number */
|
||||
|
||||
|
|
Loading…
Reference in a new issue