hostapd: Start removing struct hostapd_driver_ops abstraction
Commit bf65bc638f
started the path to
add this new abstraction for driver operations in AP mode to allow
wpa_supplicant to control AP mode operations. At that point, the
extra abstraction was needed, but it is not needed anymore since
hostapd and wpa_supplicant share the same struct wpa_driver_ops.
Start removing the unneeded abstraction by converting
send_mgmt_frame() to an inline function, hostapd_drv_send_mlme().
This is similar to the design that is used in wpa_supplicant and
that was used in hostapd in the past (hostapd_send_mgmt_frame()
inline function).
This commit is contained in:
parent
719007f5c0
commit
cee7d66b1d
8 changed files with 25 additions and 22 deletions
|
@ -157,15 +157,6 @@ static int hostapd_set_ap_wps_ie(struct hostapd_data *hapd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg,
|
|
||||||
size_t len)
|
|
||||||
{
|
|
||||||
if (hapd->driver == NULL || hapd->driver->send_mlme == NULL)
|
|
||||||
return 0;
|
|
||||||
return hapd->driver->send_mlme(hapd->drv_priv, msg, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr,
|
static int hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr,
|
||||||
const u8 *data, size_t data_len, int encrypt)
|
const u8 *data, size_t data_len, int encrypt)
|
||||||
{
|
{
|
||||||
|
@ -476,7 +467,6 @@ static int hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
|
||||||
void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
|
void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
|
||||||
{
|
{
|
||||||
ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
|
ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
|
||||||
ops->send_mgmt_frame = hostapd_send_mgmt_frame;
|
|
||||||
ops->send_eapol = hostapd_send_eapol;
|
ops->send_eapol = hostapd_send_eapol;
|
||||||
ops->set_authorized = hostapd_set_authorized;
|
ops->set_authorized = hostapd_set_authorized;
|
||||||
ops->set_key = hostapd_set_key;
|
ops->set_key = hostapd_set_key;
|
||||||
|
|
|
@ -66,4 +66,15 @@ struct wpa_scan_results * hostapd_driver_get_scan_results(
|
||||||
int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
|
int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
|
||||||
int duration);
|
int duration);
|
||||||
|
|
||||||
|
|
||||||
|
#include "drivers/driver.h"
|
||||||
|
|
||||||
|
static inline int hostapd_drv_send_mlme(struct hostapd_data *hapd,
|
||||||
|
const void *msg, size_t len)
|
||||||
|
{
|
||||||
|
if (hapd->driver == NULL || hapd->driver->send_mlme == NULL)
|
||||||
|
return 0;
|
||||||
|
return hapd->driver->send_mlme(hapd->drv_priv, msg, len);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* AP_DRV_OPS */
|
#endif /* AP_DRV_OPS */
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "ap_config.h"
|
#include "ap_config.h"
|
||||||
#include "sta_info.h"
|
#include "sta_info.h"
|
||||||
#include "p2p_hostapd.h"
|
#include "p2p_hostapd.h"
|
||||||
|
#include "ap_drv_ops.h"
|
||||||
#include "beacon.h"
|
#include "beacon.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,7 +376,7 @@ void handle_probe_req(struct hostapd_data *hapd,
|
||||||
pos = hostapd_eid_p2p_manage(hapd, pos);
|
pos = hostapd_eid_p2p_manage(hapd, pos);
|
||||||
#endif /* CONFIG_P2P_MANAGER */
|
#endif /* CONFIG_P2P_MANAGER */
|
||||||
|
|
||||||
if (hapd->drv.send_mgmt_frame(hapd, resp, pos - (u8 *) resp) < 0)
|
if (hostapd_drv_send_mlme(hapd, resp, pos - (u8 *) resp) < 0)
|
||||||
perror("handle_probe_req: send");
|
perror("handle_probe_req: send");
|
||||||
|
|
||||||
os_free(resp);
|
os_free(resp);
|
||||||
|
|
|
@ -51,8 +51,6 @@ struct hostapd_frame_info {
|
||||||
|
|
||||||
struct hostapd_driver_ops {
|
struct hostapd_driver_ops {
|
||||||
int (*set_ap_wps_ie)(struct hostapd_data *hapd);
|
int (*set_ap_wps_ie)(struct hostapd_data *hapd);
|
||||||
int (*send_mgmt_frame)(struct hostapd_data *hapd, const void *msg,
|
|
||||||
size_t len);
|
|
||||||
int (*send_eapol)(struct hostapd_data *hapd, const u8 *addr,
|
int (*send_eapol)(struct hostapd_data *hapd, const u8 *addr,
|
||||||
const u8 *data, size_t data_len, int encrypt);
|
const u8 *data, size_t data_len, int encrypt);
|
||||||
int (*set_authorized)(struct hostapd_data *hapd, struct sta_info *sta,
|
int (*set_authorized)(struct hostapd_data *hapd, struct sta_info *sta,
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "ap_config.h"
|
#include "ap_config.h"
|
||||||
#include "ap_mlme.h"
|
#include "ap_mlme.h"
|
||||||
#include "p2p_hostapd.h"
|
#include "p2p_hostapd.h"
|
||||||
|
#include "ap_drv_ops.h"
|
||||||
#include "ieee802_11.h"
|
#include "ieee802_11.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,7 +285,7 @@ static void send_auth_reply(struct hostapd_data *hapd,
|
||||||
" auth_alg=%d auth_transaction=%d resp=%d (IE len=%lu)",
|
" auth_alg=%d auth_transaction=%d resp=%d (IE len=%lu)",
|
||||||
MAC2STR(dst), auth_alg, auth_transaction,
|
MAC2STR(dst), auth_alg, auth_transaction,
|
||||||
resp, (unsigned long) ies_len);
|
resp, (unsigned long) ies_len);
|
||||||
if (hapd->drv.send_mgmt_frame(hapd, reply, rlen) < 0)
|
if (hostapd_drv_send_mlme(hapd, reply, rlen) < 0)
|
||||||
perror("send_auth_reply: send");
|
perror("send_auth_reply: send");
|
||||||
|
|
||||||
os_free(buf);
|
os_free(buf);
|
||||||
|
@ -809,7 +810,7 @@ static void send_deauth(struct hostapd_data *hapd, const u8 *addr,
|
||||||
send_len = IEEE80211_HDRLEN + sizeof(reply.u.deauth);
|
send_len = IEEE80211_HDRLEN + sizeof(reply.u.deauth);
|
||||||
reply.u.deauth.reason_code = host_to_le16(reason_code);
|
reply.u.deauth.reason_code = host_to_le16(reason_code);
|
||||||
|
|
||||||
if (hapd->drv.send_mgmt_frame(hapd, &reply, send_len) < 0)
|
if (hostapd_drv_send_mlme(hapd, &reply, send_len) < 0)
|
||||||
wpa_printf(MSG_INFO, "Failed to send deauth: %s",
|
wpa_printf(MSG_INFO, "Failed to send deauth: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
@ -912,7 +913,7 @@ static void send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta,
|
||||||
|
|
||||||
send_len += p - reply->u.assoc_resp.variable;
|
send_len += p - reply->u.assoc_resp.variable;
|
||||||
|
|
||||||
if (hapd->drv.send_mgmt_frame(hapd, reply, send_len) < 0)
|
if (hostapd_drv_send_mlme(hapd, reply, send_len) < 0)
|
||||||
wpa_printf(MSG_INFO, "Failed to send assoc resp: %s",
|
wpa_printf(MSG_INFO, "Failed to send assoc resp: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
@ -1222,7 +1223,7 @@ void ieee802_11_send_sa_query_req(struct hostapd_data *hapd,
|
||||||
os_memcpy(mgmt.u.action.u.sa_query_req.trans_id, trans_id,
|
os_memcpy(mgmt.u.action.u.sa_query_req.trans_id, trans_id,
|
||||||
WLAN_SA_QUERY_TR_ID_LEN);
|
WLAN_SA_QUERY_TR_ID_LEN);
|
||||||
end = mgmt.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN;
|
end = mgmt.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN;
|
||||||
if (hapd->drv.send_mgmt_frame(hapd, &mgmt, end - (u8 *) &mgmt) < 0)
|
if (hostapd_drv_send_mlme(hapd, &mgmt, end - (u8 *) &mgmt) < 0)
|
||||||
perror("ieee802_11_send_sa_query_req: send");
|
perror("ieee802_11_send_sa_query_req: send");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,7 +1263,7 @@ static void hostapd_sa_query_request(struct hostapd_data *hapd,
|
||||||
mgmt->u.action.u.sa_query_req.trans_id,
|
mgmt->u.action.u.sa_query_req.trans_id,
|
||||||
WLAN_SA_QUERY_TR_ID_LEN);
|
WLAN_SA_QUERY_TR_ID_LEN);
|
||||||
end = resp.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN;
|
end = resp.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN;
|
||||||
if (hapd->drv.send_mgmt_frame(hapd, &resp, end - (u8 *) &resp) < 0)
|
if (hostapd_drv_send_mlme(hapd, &resp, end - (u8 *) &resp) < 0)
|
||||||
perror("hostapd_sa_query_request: send");
|
perror("hostapd_sa_query_request: send");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1433,7 +1434,7 @@ static void handle_action(struct hostapd_data *hapd,
|
||||||
os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
|
os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
|
||||||
resp->u.action.category |= 0x80;
|
resp->u.action.category |= 0x80;
|
||||||
|
|
||||||
hapd->drv.send_mgmt_frame(hapd, resp, len);
|
hostapd_drv_send_mlme(hapd, resp, len);
|
||||||
os_free(resp);
|
os_free(resp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "ap_mlme.h"
|
#include "ap_mlme.h"
|
||||||
#include "vlan_init.h"
|
#include "vlan_init.h"
|
||||||
#include "p2p_hostapd.h"
|
#include "p2p_hostapd.h"
|
||||||
|
#include "ap_drv_ops.h"
|
||||||
#include "sta_info.h"
|
#include "sta_info.h"
|
||||||
|
|
||||||
static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
|
static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
|
||||||
|
@ -335,7 +336,7 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
|
||||||
ETH_ALEN);
|
ETH_ALEN);
|
||||||
os_memcpy(hdr.IEEE80211_SA_FROMDS, hapd->own_addr, ETH_ALEN);
|
os_memcpy(hdr.IEEE80211_SA_FROMDS, hapd->own_addr, ETH_ALEN);
|
||||||
|
|
||||||
if (hapd->drv.send_mgmt_frame(hapd, &hdr, sizeof(hdr)) < 0)
|
if (hostapd_drv_send_mlme(hapd, &hdr, sizeof(hdr)) < 0)
|
||||||
perror("ap_handle_timer: send");
|
perror("ap_handle_timer: send");
|
||||||
#endif /* CONFIG_NATIVE_WINDOWS */
|
#endif /* CONFIG_NATIVE_WINDOWS */
|
||||||
} else if (sta->timeout_next != STA_REMOVE) {
|
} else if (sta->timeout_next != STA_REMOVE) {
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "ieee802_11.h"
|
#include "ieee802_11.h"
|
||||||
#include "sta_info.h"
|
#include "sta_info.h"
|
||||||
#include "ap_config.h"
|
#include "ap_config.h"
|
||||||
|
#include "ap_drv_ops.h"
|
||||||
#include "wmm.h"
|
#include "wmm.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,7 +151,7 @@ static void wmm_send_action(struct hostapd_data *hapd, const u8 *addr,
|
||||||
os_memcpy(t, tspec, sizeof(struct wmm_tspec_element));
|
os_memcpy(t, tspec, sizeof(struct wmm_tspec_element));
|
||||||
len = ((u8 *) (t + 1)) - buf;
|
len = ((u8 *) (t + 1)) - buf;
|
||||||
|
|
||||||
if (hapd->drv.send_mgmt_frame(hapd, m, len) < 0)
|
if (hostapd_drv_send_mlme(hapd, m, len) < 0)
|
||||||
perror("wmm_send_action: send");
|
perror("wmm_send_action: send");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -396,7 +396,7 @@ static int hostapd_wpa_auth_send_ft_action(void *ctx, const u8 *dst,
|
||||||
os_memcpy(m->bssid, hapd->own_addr, ETH_ALEN);
|
os_memcpy(m->bssid, hapd->own_addr, ETH_ALEN);
|
||||||
os_memcpy(&m->u, data, data_len);
|
os_memcpy(&m->u, data, data_len);
|
||||||
|
|
||||||
res = hapd->drv.send_mgmt_frame(hapd, (u8 *) m, mlen);
|
res = hostapd_drv_send_mlme(hapd, (u8 *) m, mlen);
|
||||||
os_free(m);
|
os_free(m);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue