Start deprecating various AP mode driver_ops

The preferred way of configuring AP mode will be to use set_ap() instead
of number of separate operations hostapd has collected over the years.
This commit is contained in:
Jouni Malinen 2011-10-17 18:35:25 +03:00 committed by Jouni Malinen
parent 9e85b1ed49
commit 062390efd4
7 changed files with 103 additions and 85 deletions

View file

@ -52,6 +52,7 @@ OBJS += ../src/ap/wpa_auth_ie.o
OBJS += ../src/ap/preauth_auth.o OBJS += ../src/ap/preauth_auth.o
OBJS += ../src/ap/pmksa_cache_auth.o OBJS += ../src/ap/pmksa_cache_auth.o
OBJS += ../src/ap/ieee802_11_shared.o OBJS += ../src/ap/ieee802_11_shared.o
OBJS += ../src/ap/beacon.o
OBJS_c = hostapd_cli.o ../src/common/wpa_ctrl.o ../src/utils/os_$(CONFIG_OS).o OBJS_c = hostapd_cli.o ../src/common/wpa_ctrl.o ../src/utils/os_$(CONFIG_OS).o
@ -729,7 +730,6 @@ OBJS += ../src/utils/base64.o
endif endif
ifdef NEED_AP_MLME ifdef NEED_AP_MLME
OBJS += ../src/ap/beacon.o
OBJS += ../src/ap/wmm.o OBJS += ../src/ap/wmm.o
OBJS += ../src/ap/ap_list.o OBJS += ../src/ap/ap_list.o
OBJS += ../src/ap/ieee802_11.o OBJS += ../src/ap/ieee802_11.o

View file

@ -233,74 +233,6 @@ int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
} }
static int hostapd_set_ap_isolate(struct hostapd_data *hapd, int value)
{
if (hapd->driver == NULL || hapd->driver->set_intra_bss == NULL)
return 0;
return hapd->driver->set_intra_bss(hapd->drv_priv, !value);
}
int hostapd_set_bss_params(struct hostapd_data *hapd, int use_protection)
{
int ret = 0;
int preamble;
#ifdef CONFIG_IEEE80211N
u8 buf[60], *ht_capab, *ht_oper, *pos;
pos = buf;
ht_capab = pos;
pos = hostapd_eid_ht_capabilities(hapd, pos);
ht_oper = pos;
pos = hostapd_eid_ht_operation(hapd, pos);
if (pos > ht_oper && ht_oper > ht_capab &&
hostapd_set_ht_params(hapd, ht_capab + 2, ht_capab[1],
ht_oper + 2, ht_oper[1])) {
wpa_printf(MSG_ERROR, "Could not set HT capabilities "
"for kernel driver");
ret = -1;
}
#endif /* CONFIG_IEEE80211N */
if (hostapd_set_cts_protect(hapd, use_protection)) {
wpa_printf(MSG_ERROR, "Failed to set CTS protect in kernel "
"driver");
ret = -1;
}
if (hapd->iface->current_mode &&
hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
hostapd_set_short_slot_time(hapd,
hapd->iface->num_sta_no_short_slot_time
> 0 ? 0 : 1)) {
wpa_printf(MSG_ERROR, "Failed to set Short Slot Time option "
"in kernel driver");
ret = -1;
}
if (hapd->iface->num_sta_no_short_preamble == 0 &&
hapd->iconf->preamble == SHORT_PREAMBLE)
preamble = SHORT_PREAMBLE;
else
preamble = LONG_PREAMBLE;
if (hostapd_set_preamble(hapd, preamble)) {
wpa_printf(MSG_ERROR, "Could not set preamble for kernel "
"driver");
ret = -1;
}
if (hostapd_set_ap_isolate(hapd, hapd->conf->isolate) &&
hapd->conf->isolate) {
wpa_printf(MSG_ERROR, "Could not enable AP isolation in "
"kernel driver");
ret = -1;
}
return ret;
}
int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname) int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname)
{ {
char force_ifname[IFNAMSIZ]; char force_ifname[IFNAMSIZ];

View file

@ -34,7 +34,6 @@ int hostapd_set_authorized(struct hostapd_data *hapd,
int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta); int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta);
int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname, int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
int enabled); int enabled);
int hostapd_set_bss_params(struct hostapd_data *hapd, int use_protection);
int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname); int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname);
int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname); int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname);
int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, int aid, int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, int aid,

View file

@ -35,6 +35,8 @@
#include "beacon.h" #include "beacon.h"
#ifdef NEED_AP_MLME
static u8 ieee802_11_erp_info(struct hostapd_data *hapd) static u8 ieee802_11_erp_info(struct hostapd_data *hapd)
{ {
u8 erp = 0; u8 erp = 0;
@ -434,14 +436,88 @@ void handle_probe_req(struct hostapd_data *hapd,
} }
static int hostapd_set_ap_isolate(struct hostapd_data *hapd, int value)
{
if (hapd->driver == NULL || hapd->driver->set_intra_bss == NULL)
return 0;
return hapd->driver->set_intra_bss(hapd->drv_priv, !value);
}
static int hostapd_set_bss_params(struct hostapd_data *hapd,
int use_protection)
{
int ret = 0;
int preamble;
#ifdef CONFIG_IEEE80211N
u8 buf[60], *ht_capab, *ht_oper, *pos;
pos = buf;
ht_capab = pos;
pos = hostapd_eid_ht_capabilities(hapd, pos);
ht_oper = pos;
pos = hostapd_eid_ht_operation(hapd, pos);
if (pos > ht_oper && ht_oper > ht_capab &&
hostapd_set_ht_params(hapd, ht_capab + 2, ht_capab[1],
ht_oper + 2, ht_oper[1])) {
wpa_printf(MSG_ERROR, "Could not set HT capabilities "
"for kernel driver");
ret = -1;
}
#endif /* CONFIG_IEEE80211N */
if (hostapd_set_cts_protect(hapd, use_protection)) {
wpa_printf(MSG_ERROR, "Failed to set CTS protect in kernel "
"driver");
ret = -1;
}
if (hapd->iface->current_mode &&
hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
hostapd_set_short_slot_time(hapd,
hapd->iface->num_sta_no_short_slot_time
> 0 ? 0 : 1)) {
wpa_printf(MSG_ERROR, "Failed to set Short Slot Time option "
"in kernel driver");
ret = -1;
}
if (hapd->iface->num_sta_no_short_preamble == 0 &&
hapd->iconf->preamble == SHORT_PREAMBLE)
preamble = SHORT_PREAMBLE;
else
preamble = LONG_PREAMBLE;
if (hostapd_set_preamble(hapd, preamble)) {
wpa_printf(MSG_ERROR, "Could not set preamble for kernel "
"driver");
ret = -1;
}
if (hostapd_set_ap_isolate(hapd, hapd->conf->isolate) &&
hapd->conf->isolate) {
wpa_printf(MSG_ERROR, "Could not enable AP isolation in "
"kernel driver");
ret = -1;
}
return ret;
}
#endif /* NEED_AP_MLME */
void ieee802_11_set_beacon(struct hostapd_data *hapd) void ieee802_11_set_beacon(struct hostapd_data *hapd)
{ {
struct ieee80211_mgmt *head; struct ieee80211_mgmt *head = NULL;
u8 *pos, *tail, *tailpos; u8 *tail = NULL;
u16 capab_info; size_t head_len = 0, tail_len = 0;
size_t head_len, tail_len;
struct wpa_driver_ap_params params; struct wpa_driver_ap_params params;
struct wpabuf *beacon, *proberesp, *assocresp; struct wpabuf *beacon, *proberesp, *assocresp;
#ifdef NEED_AP_MLME
u16 capab_info;
u8 *pos, *tailpos;
#endif /* NEED_AP_MLME */
#ifdef CONFIG_P2P #ifdef CONFIG_P2P
if ((hapd->conf->p2p & (P2P_ENABLED | P2P_GROUP_OWNER)) == P2P_ENABLED) if ((hapd->conf->p2p & (P2P_ENABLED | P2P_GROUP_OWNER)) == P2P_ENABLED)
@ -449,6 +525,8 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
#endif /* CONFIG_P2P */ #endif /* CONFIG_P2P */
hapd->beacon_set_done = 1; hapd->beacon_set_done = 1;
#ifdef NEED_AP_MLME
#define BEACON_HEAD_BUF_SIZE 256 #define BEACON_HEAD_BUF_SIZE 256
#define BEACON_TAIL_BUF_SIZE 512 #define BEACON_TAIL_BUF_SIZE 512
head = os_zalloc(BEACON_HEAD_BUF_SIZE); head = os_zalloc(BEACON_HEAD_BUF_SIZE);
@ -556,6 +634,8 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
tail_len = tailpos > tail ? tailpos - tail : 0; tail_len = tailpos > tail ? tailpos - tail : 0;
#endif /* NEED_AP_MLME */
os_memset(&params, 0, sizeof(params)); os_memset(&params, 0, sizeof(params));
params.head = (u8 *) head; params.head = (u8 *) head;
params.head_len = head_len; params.head_len = head_len;
@ -600,8 +680,10 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
#ifdef CONFIG_P2P #ifdef CONFIG_P2P
no_beacon: no_beacon:
#endif /* CONFIG_P2P */ #endif /* CONFIG_P2P */
#ifdef NEED_AP_MLME
hostapd_set_bss_params(hapd, !!(ieee802_11_erp_info(hapd) & hostapd_set_bss_params(hapd, !!(ieee802_11_erp_info(hapd) &
ERP_INFO_USE_PROTECTION)); ERP_INFO_USE_PROTECTION));
#endif /* NEED_AP_MLME */
} }

View file

@ -20,17 +20,7 @@ struct ieee80211_mgmt;
void handle_probe_req(struct hostapd_data *hapd, void handle_probe_req(struct hostapd_data *hapd,
const struct ieee80211_mgmt *mgmt, size_t len); const struct ieee80211_mgmt *mgmt, size_t len);
#ifdef NEED_AP_MLME
void ieee802_11_set_beacon(struct hostapd_data *hapd); void ieee802_11_set_beacon(struct hostapd_data *hapd);
void ieee802_11_set_beacons(struct hostapd_iface *iface); void ieee802_11_set_beacons(struct hostapd_iface *iface);
#else /* NEED_AP_MLME */
static inline void ieee802_11_set_beacon(struct hostapd_data *hapd)
{
}
static inline void ieee802_11_set_beacons(struct hostapd_iface *iface)
{
}
#endif /* NEED_AP_MLME */
#endif /* BEACON_H */ #endif /* BEACON_H */

View file

@ -614,6 +614,9 @@ struct wpa_driver_ap_params {
/** /**
* assocresp_ies - WPS IE(s) for (Re)Association Response frames * assocresp_ies - WPS IE(s) for (Re)Association Response frames
*
* This is used to add IEs like WPS IE by drivers that reply to
* (Re)Association Request frames internally.
*/ */
const struct wpabuf *assocresp_ies; const struct wpabuf *assocresp_ies;
}; };
@ -1465,6 +1468,8 @@ struct wpa_driver_ops {
* can be left undefined (set to %NULL) if IEEE 802.1X support is * can be left undefined (set to %NULL) if IEEE 802.1X support is
* always enabled and the driver uses set_ap() to set WPA/RSN IE * always enabled and the driver uses set_ap() to set WPA/RSN IE
* for Beacon frames. * for Beacon frames.
*
* DEPRECATED - use set_ap() instead
*/ */
int (*set_ieee8021x)(void *priv, struct wpa_bss_params *params); int (*set_ieee8021x)(void *priv, struct wpa_bss_params *params);
@ -1477,6 +1482,8 @@ struct wpa_driver_ops {
* This is an optional function to configure privacy field in the * This is an optional function to configure privacy field in the
* kernel driver for Beacon frames. This can be left undefined (set to * kernel driver for Beacon frames. This can be left undefined (set to
* %NULL) if the driver uses the Beacon template from set_ap(). * %NULL) if the driver uses the Beacon template from set_ap().
*
* DEPRECATED - use set_ap() instead
*/ */
int (*set_privacy)(void *priv, int enabled); int (*set_privacy)(void *priv, int enabled);
@ -1519,6 +1526,8 @@ struct wpa_driver_ops {
* kernel driver for Beacon and Probe Response frames. This can be left * kernel driver for Beacon and Probe Response frames. This can be left
* undefined (set to %NULL) if the driver uses the Beacon template from * undefined (set to %NULL) if the driver uses the Beacon template from
* set_ap(). * set_ap().
*
* DEPRECATED - use set_ap() instead
*/ */
int (*set_generic_elem)(void *priv, const u8 *elem, size_t elem_len); int (*set_generic_elem)(void *priv, const u8 *elem, size_t elem_len);
@ -1602,6 +1611,8 @@ struct wpa_driver_ops {
* @buf: SSID * @buf: SSID
* @len: Length of the SSID in octets * @len: Length of the SSID in octets
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
*
* DEPRECATED - use set_ap() instead
*/ */
int (*hapd_set_ssid)(void *priv, const u8 *buf, int len); int (*hapd_set_ssid)(void *priv, const u8 *buf, int len);
@ -1870,6 +1881,8 @@ struct wpa_driver_ops {
* also used to provide Probe Response IEs for P2P Listen state * also used to provide Probe Response IEs for P2P Listen state
* operations for drivers that generate the Probe Response frames * operations for drivers that generate the Probe Response frames
* internally. * internally.
*
* DEPRECATED - use set_ap() instead
*/ */
int (*set_ap_wps_ie)(void *priv, const struct wpabuf *beacon, int (*set_ap_wps_ie)(void *priv, const struct wpabuf *beacon,
const struct wpabuf *proberesp, const struct wpabuf *proberesp,
@ -2383,6 +2396,8 @@ struct wpa_driver_ops {
* This function can be used to set authentication algorithms for AP * This function can be used to set authentication algorithms for AP
* mode when static WEP is used. If the driver uses user space MLME/SME * mode when static WEP is used. If the driver uses user space MLME/SME
* implementation, there is no need to implement this function. * implementation, there is no need to implement this function.
*
* DEPRECATED - use set_ap() instead
*/ */
int (*set_authmode)(void *priv, int authmode); int (*set_authmode)(void *priv, int authmode);

View file

@ -681,6 +681,7 @@ OBJS += ../src/ap/ieee802_11_auth.o
OBJS += ../src/ap/ieee802_11_shared.o OBJS += ../src/ap/ieee802_11_shared.o
OBJS += ../src/ap/drv_callbacks.o OBJS += ../src/ap/drv_callbacks.o
OBJS += ../src/ap/ap_drv_ops.o OBJS += ../src/ap/ap_drv_ops.o
OBJS += ../src/ap/beacon.o
ifdef CONFIG_IEEE80211N ifdef CONFIG_IEEE80211N
OBJS += ../src/ap/ieee802_11_ht.o OBJS += ../src/ap/ieee802_11_ht.o
endif endif
@ -698,7 +699,6 @@ CFLAGS += -DCONFIG_IEEE80211N
endif endif
ifdef NEED_AP_MLME ifdef NEED_AP_MLME
OBJS += ../src/ap/beacon.o
OBJS += ../src/ap/wmm.o OBJS += ../src/ap/wmm.o
OBJS += ../src/ap/ap_list.o OBJS += ../src/ap/ap_list.o
OBJS += ../src/ap/ieee802_11.o OBJS += ../src/ap/ieee802_11.o