From 3710027463e2549afba24e5dab8df083e122aff3 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 3 Jan 2020 13:34:37 +0200 Subject: [PATCH] Make hostapd_drv_send_mlme() more generic Merge hostapd_drv_send_mlme_csa() functionality into hostapd_drv_send_mlme() to get a single driver ops handler function for hostapd. In addition, add a new no_encrypt parameter in preparation for functionality that is needed to get rid of the separate send_frame() driver op. Signed-off-by: Jouni Malinen --- hostapd/ctrl_iface.c | 2 +- src/ap/ap_drv_ops.c | 15 +++------------ src/ap/ap_drv_ops.h | 7 +++---- src/ap/beacon.c | 6 +++--- src/ap/ctrl_iface_ap.c | 3 ++- src/ap/ieee802_11.c | 8 ++++---- src/ap/ieee802_11_shared.c | 6 ++++-- src/ap/wmm.c | 2 +- src/ap/wnm_ap.c | 8 ++++---- src/ap/wpa_auth_glue.c | 2 +- 10 files changed, 26 insertions(+), 33 deletions(-) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index bc8aaf276..cb4d8fac2 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -1662,7 +1662,7 @@ static int hostapd_ctrl_iface_mgmt_tx(struct hostapd_data *hapd, char *cmd) return -1; } - res = hostapd_drv_send_mlme(hapd, buf, len, 0); + res = hostapd_drv_send_mlme(hapd, buf, len, 0, NULL, 0, 0); os_free(buf); return res; } diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c index 758586689..ec1d970ea 100644 --- a/src/ap/ap_drv_ops.c +++ b/src/ap/ap_drv_ops.c @@ -693,21 +693,12 @@ int hostapd_drv_set_key(const char *ifname, struct hostapd_data *hapd, int hostapd_drv_send_mlme(struct hostapd_data *hapd, - const void *msg, size_t len, int noack) + const void *msg, size_t len, int noack, + const u16 *csa_offs, size_t csa_offs_len, + int no_encrypt) { if (!hapd->driver || !hapd->driver->send_mlme || !hapd->drv_priv) return 0; - return hapd->driver->send_mlme(hapd->drv_priv, msg, len, noack, 0, - NULL, 0); -} - - -int hostapd_drv_send_mlme_csa(struct hostapd_data *hapd, - const void *msg, size_t len, int noack, - const u16 *csa_offs, size_t csa_offs_len) -{ - if (hapd->driver == NULL || hapd->driver->send_mlme == NULL) - return 0; return hapd->driver->send_mlme(hapd->drv_priv, msg, len, noack, 0, csa_offs, csa_offs_len); } diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h index fa413df08..b0170df58 100644 --- a/src/ap/ap_drv_ops.h +++ b/src/ap/ap_drv_ops.h @@ -93,10 +93,9 @@ int hostapd_drv_set_key(const char *ifname, const u8 *seq, size_t seq_len, const u8 *key, size_t key_len); int hostapd_drv_send_mlme(struct hostapd_data *hapd, - const void *msg, size_t len, int noack); -int hostapd_drv_send_mlme_csa(struct hostapd_data *hapd, - const void *msg, size_t len, int noack, - const u16 *csa_offs, size_t csa_offs_len); + const void *msg, size_t len, int noack, + const u16 *csa_offs, size_t csa_offs_len, + int no_encrypt); int hostapd_drv_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason); int hostapd_drv_sta_disassoc(struct hostapd_data *hapd, diff --git a/src/ap/beacon.c b/src/ap/beacon.c index f3f496ba9..29c7e383d 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -1000,9 +1000,9 @@ void handle_probe_req(struct hostapd_data *hapd, hapd->cs_c_off_ecsa_proberesp; } - ret = hostapd_drv_send_mlme_csa(hapd, resp, resp_len, noack, - csa_offs_len ? csa_offs : NULL, - csa_offs_len); + ret = hostapd_drv_send_mlme(hapd, resp, resp_len, noack, + csa_offs_len ? csa_offs : NULL, + csa_offs_len, 0); if (ret < 0) wpa_printf(MSG_INFO, "handle_probe_req: send failed"); diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c index 73238f2c5..335d5a7b1 100644 --- a/src/ap/ctrl_iface_ap.c +++ b/src/ap/ctrl_iface_ap.c @@ -495,7 +495,8 @@ static int p2p_manager_disconnect(struct hostapd_data *hapd, u16 stype, pos += 2; *pos++ = minor_reason_code; - ret = hostapd_drv_send_mlme(hapd, mgmt, pos - (u8 *) mgmt, 0); + ret = hostapd_drv_send_mlme(hapd, mgmt, pos - (u8 *) mgmt, 0, NULL, 0, + 0); os_free(mgmt); return ret < 0 ? -1 : 0; diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 0fb2ec116..84dea20ca 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -349,7 +349,7 @@ static int send_auth_reply(struct hostapd_data *hapd, " auth_alg=%d auth_transaction=%d resp=%d (IE len=%lu) (dbg=%s)", MAC2STR(dst), auth_alg, auth_transaction, resp, (unsigned long) ies_len, dbg); - if (hostapd_drv_send_mlme(hapd, reply, rlen, 0) < 0) + if (hostapd_drv_send_mlme(hapd, reply, rlen, 0, NULL, 0, 0) < 0) wpa_printf(MSG_INFO, "send_auth_reply: send failed"); else reply_res = WLAN_STATUS_SUCCESS; @@ -3462,7 +3462,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_drv_send_mlme(hapd, &reply, send_len, 0) < 0) + if (hostapd_drv_send_mlme(hapd, &reply, send_len, 0, NULL, 0, 0) < 0) wpa_printf(MSG_INFO, "Failed to send deauth: %s", strerror(errno)); } @@ -3848,7 +3848,7 @@ static u16 send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta, } #endif /* CONFIG_FILS */ - if (hostapd_drv_send_mlme(hapd, reply, send_len, 0) < 0) { + if (hostapd_drv_send_mlme(hapd, reply, send_len, 0, NULL, 0, 0) < 0) { wpa_printf(MSG_INFO, "Failed to send assoc resp: %s", strerror(errno)); res = WLAN_STATUS_UNSPECIFIED_FAILURE; @@ -4678,7 +4678,7 @@ static int handle_action(struct hostapd_data *hapd, os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN); resp->u.action.category |= 0x80; - if (hostapd_drv_send_mlme(hapd, resp, len, 0) < 0) { + if (hostapd_drv_send_mlme(hapd, resp, len, 0, NULL, 0, 0) < 0) { wpa_printf(MSG_ERROR, "IEEE 802.11: Failed to send " "Action frame"); } diff --git a/src/ap/ieee802_11_shared.c b/src/ap/ieee802_11_shared.c index 1e1cc3825..ab81d083e 100644 --- a/src/ap/ieee802_11_shared.c +++ b/src/ap/ieee802_11_shared.c @@ -112,7 +112,8 @@ void ieee802_11_send_sa_query_req(struct hostapd_data *hapd, end += oci_ie_len; } #endif /* CONFIG_OCV */ - if (hostapd_drv_send_mlme(hapd, mgmt, end - (u8 *) mgmt, 0) < 0) + if (hostapd_drv_send_mlme(hapd, mgmt, end - (u8 *) mgmt, 0, NULL, 0, 0) + < 0) wpa_printf(MSG_INFO, "ieee802_11_send_sa_query_req: send failed"); os_free(mgmt); @@ -193,7 +194,8 @@ static void ieee802_11_send_sa_query_resp(struct hostapd_data *hapd, end += oci_ie_len; } #endif /* CONFIG_OCV */ - if (hostapd_drv_send_mlme(hapd, resp, end - (u8 *) resp, 0) < 0) + if (hostapd_drv_send_mlme(hapd, resp, end - (u8 *) resp, 0, NULL, 0, 0) + < 0) wpa_printf(MSG_INFO, "ieee80211_mgmt_sa_query_request: send failed"); os_free(resp); diff --git a/src/ap/wmm.c b/src/ap/wmm.c index 9f52dee32..881fd9f23 100644 --- a/src/ap/wmm.c +++ b/src/ap/wmm.c @@ -209,7 +209,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_drv_send_mlme(hapd, m, len, 0) < 0) + if (hostapd_drv_send_mlme(hapd, m, len, 0, NULL, 0, 0) < 0) wpa_printf(MSG_INFO, "wmm_send_action: send failed"); } diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c index e4dcfe9e0..29ca95092 100644 --- a/src/ap/wnm_ap.c +++ b/src/ap/wnm_ap.c @@ -641,7 +641,7 @@ int wnm_send_disassoc_imminent(struct hostapd_data *hapd, wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Request frame to indicate imminent disassociation (disassoc_timer=%d) to " MACSTR, disassoc_timer, MAC2STR(sta->addr)); - if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0) < 0) { + if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0, NULL, 0, 0) < 0) { wpa_printf(MSG_DEBUG, "Failed to send BSS Transition " "Management Request frame"); return -1; @@ -714,7 +714,7 @@ int wnm_send_ess_disassoc_imminent(struct hostapd_data *hapd, os_memcpy(pos, url, url_len); pos += url_len; - if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0) < 0) { + if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0, NULL, 0, 0) < 0) { wpa_printf(MSG_DEBUG, "Failed to send BSS Transition " "Management Request frame"); return -1; @@ -790,7 +790,7 @@ int wnm_send_bss_tm_req(struct hostapd_data *hapd, struct sta_info *sta, mbo_len); } - if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0) < 0) { + if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0, NULL, 0, 0) < 0) { wpa_printf(MSG_DEBUG, "Failed to send BSS Transition Management Request frame"); os_free(buf); @@ -834,7 +834,7 @@ int wnm_send_coloc_intf_req(struct hostapd_data *hapd, struct sta_info *sta, wpa_printf(MSG_DEBUG, "WNM: Sending Collocated Interference Request to " MACSTR " (dialog_token=%u auto_report=%u timeout=%u)", MAC2STR(sta->addr), dialog_token, auto_report, timeout); - if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0) < 0) { + if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0, NULL, 0, 0) < 0) { wpa_printf(MSG_DEBUG, "WNM: Failed to send Collocated Interference Request frame"); return -1; diff --git a/src/ap/wpa_auth_glue.c b/src/ap/wpa_auth_glue.c index 8ac70faa7..b655ae57b 100644 --- a/src/ap/wpa_auth_glue.c +++ b/src/ap/wpa_auth_glue.c @@ -918,7 +918,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_drv_send_mlme(hapd, (u8 *) m, mlen, 0); + res = hostapd_drv_send_mlme(hapd, (u8 *) m, mlen, 0, NULL, 0, 0); os_free(m); return res; }