From c90933d2a3826206cef6822ac6d6293794ef273a Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 24 Dec 2009 20:13:44 +0200 Subject: [PATCH] Use hostapd driver op wrapper for send_mgmt_frame --- hostapd/ap_drv_ops.c | 10 ++++++++++ hostapd/beacon.c | 2 +- hostapd/driver_i.h | 8 -------- hostapd/hostapd.c | 2 +- hostapd/hostapd.h | 2 ++ hostapd/ieee802_11.c | 14 +++++++------- hostapd/sta_info.c | 2 +- hostapd/wme.c | 4 ++-- 8 files changed, 24 insertions(+), 20 deletions(-) diff --git a/hostapd/ap_drv_ops.c b/hostapd/ap_drv_ops.c index 2d31829da..c560f1e4d 100644 --- a/hostapd/ap_drv_ops.c +++ b/hostapd/ap_drv_ops.c @@ -30,7 +30,17 @@ 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); +} + + void hostapd_set_driver_ops(struct hostapd_driver_ops *ops) { ops->set_ap_wps_ie = hostapd_set_ap_wps_ie; + ops->send_mgmt_frame = hostapd_send_mgmt_frame; } diff --git a/hostapd/beacon.c b/hostapd/beacon.c index 6e2afe880..41fa78fd6 100644 --- a/hostapd/beacon.c +++ b/hostapd/beacon.c @@ -315,7 +315,7 @@ void handle_probe_req(struct hostapd_data *hapd, } #endif /* CONFIG_WPS */ - if (hostapd_send_mgmt_frame(hapd, resp, pos - (u8 *) resp) < 0) + if (hapd->drv.send_mgmt_frame(hapd, resp, pos - (u8 *) resp) < 0) perror("handle_probe_req: send"); os_free(resp); diff --git a/hostapd/driver_i.h b/hostapd/driver_i.h index f589efda4..9a1d56dcc 100644 --- a/hostapd/driver_i.h +++ b/hostapd/driver_i.h @@ -184,14 +184,6 @@ hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len) buf, len); } -static inline 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 inline int hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled) { diff --git a/hostapd/hostapd.c b/hostapd/hostapd.c index 57154e07b..824e70ef0 100644 --- a/hostapd/hostapd.c +++ b/hostapd/hostapd.c @@ -710,7 +710,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->u, data, data_len); - res = hostapd_send_mgmt_frame(hapd, (u8 *) m, mlen); + res = hapd->drv.send_mgmt_frame(hapd, (u8 *) m, mlen); os_free(m); return res; } diff --git a/hostapd/hostapd.h b/hostapd/hostapd.h index 3d188e048..bf50dfa73 100644 --- a/hostapd/hostapd.h +++ b/hostapd/hostapd.h @@ -45,6 +45,8 @@ struct hostapd_driver_ops { int (*set_ap_wps_ie)(struct hostapd_data *hapd, const struct wpabuf *beacon, const struct wpabuf *probe); + int (*send_mgmt_frame)(struct hostapd_data *hapd, const void *msg, + size_t len); }; /** diff --git a/hostapd/ieee802_11.c b/hostapd/ieee802_11.c index df18a9341..f3dc81a3a 100644 --- a/hostapd/ieee802_11.c +++ b/hostapd/ieee802_11.c @@ -211,8 +211,8 @@ void ieee802_11_send_deauth(struct hostapd_data *hapd, const u8 *addr, os_memcpy(mgmt.sa, hapd->own_addr, ETH_ALEN); os_memcpy(mgmt.bssid, hapd->own_addr, ETH_ALEN); mgmt.u.deauth.reason_code = host_to_le16(reason); - if (hostapd_send_mgmt_frame(hapd, &mgmt, IEEE80211_HDRLEN + - sizeof(mgmt.u.deauth)) < 0) + if (hapd->drv.send_mgmt_frame(hapd, &mgmt, IEEE80211_HDRLEN + + sizeof(mgmt.u.deauth)) < 0) perror("ieee802_11_send_deauth: send"); } @@ -308,7 +308,7 @@ static void send_auth_reply(struct hostapd_data *hapd, " auth_alg=%d auth_transaction=%d resp=%d (IE len=%lu)", MAC2STR(dst), auth_alg, auth_transaction, resp, (unsigned long) ies_len); - if (hostapd_send_mgmt_frame(hapd, reply, rlen) < 0) + if (hapd->drv.send_mgmt_frame(hapd, reply, rlen) < 0) perror("send_auth_reply: send"); os_free(buf); @@ -816,7 +816,7 @@ static void send_deauth(struct hostapd_data *hapd, const u8 *addr, send_len = IEEE80211_HDRLEN + sizeof(reply.u.deauth); reply.u.deauth.reason_code = host_to_le16(reason_code); - if (hostapd_send_mgmt_frame(hapd, &reply, send_len) < 0) + if (hapd->drv.send_mgmt_frame(hapd, &reply, send_len) < 0) wpa_printf(MSG_INFO, "Failed to send deauth: %s", strerror(errno)); } @@ -877,7 +877,7 @@ static void send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta, send_len += p - reply->u.assoc_resp.variable; - if (hostapd_send_mgmt_frame(hapd, reply, send_len) < 0) + if (hapd->drv.send_mgmt_frame(hapd, reply, send_len) < 0) wpa_printf(MSG_INFO, "Failed to send assoc resp: %s", strerror(errno)); } @@ -1187,7 +1187,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, WLAN_SA_QUERY_TR_ID_LEN); end = mgmt.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN; - if (hostapd_send_mgmt_frame(hapd, &mgmt, end - (u8 *) &mgmt) < 0) + if (hapd->drv.send_mgmt_frame(hapd, &mgmt, end - (u8 *) &mgmt) < 0) perror("ieee802_11_send_sa_query_req: send"); } @@ -1337,7 +1337,7 @@ static void handle_action(struct hostapd_data *hapd, os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN); resp->u.action.category |= 0x80; - hostapd_send_mgmt_frame(hapd, resp, len); + hapd->drv.send_mgmt_frame(hapd, resp, len); os_free(resp); } } diff --git a/hostapd/sta_info.c b/hostapd/sta_info.c index 4d9ba429a..2c82ceccc 100644 --- a/hostapd/sta_info.c +++ b/hostapd/sta_info.c @@ -317,7 +317,7 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx) ETH_ALEN); os_memcpy(hdr.IEEE80211_SA_FROMDS, hapd->own_addr, ETH_ALEN); - if (hostapd_send_mgmt_frame(hapd, &hdr, sizeof(hdr)) < 0) + if (hapd->drv.send_mgmt_frame(hapd, &hdr, sizeof(hdr)) < 0) perror("ap_handle_timer: send"); #endif /* CONFIG_NATIVE_WINDOWS */ } else if (sta->timeout_next != STA_REMOVE) { diff --git a/hostapd/wme.c b/hostapd/wme.c index f539e9896..a575fbc7b 100644 --- a/hostapd/wme.c +++ b/hostapd/wme.c @@ -20,7 +20,7 @@ #include "ieee802_11.h" #include "wme.h" #include "sta_info.h" -#include "driver_i.h" +#include "config.h" /* TODO: maintain separate sequence and fragment numbers for each AC @@ -144,7 +144,7 @@ static void wmm_send_action(struct hostapd_data *hapd, const u8 *addr, os_memcpy(t, tspec, sizeof(struct wmm_tspec_element)); len = ((u8 *) (t + 1)) - buf; - if (hostapd_send_mgmt_frame(hapd, m, len) < 0) + if (hapd->drv.send_mgmt_frame(hapd, m, len) < 0) perror("wmm_send_action: send"); }