From 649d8890b17a75a789fa123fcfb11c8510f96926 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 9 Jan 2009 16:55:59 +0200 Subject: [PATCH] Add wrapper functions for IEEE 802.11 driver calls into driver.h These functions allow the driver_*.c wrappers not to include ieee802_11.h. --- hostapd/ap_list.c | 1 + hostapd/driver.h | 15 +++++++++++++++ hostapd/driver_bsd.c | 3 +-- hostapd/driver_hostap.c | 7 +++---- hostapd/driver_madwifi.c | 3 +-- hostapd/driver_nl80211.c | 9 ++++----- hostapd/driver_test.c | 5 ++--- hostapd/hostapd.c | 20 ++++++++++++++++++++ hostapd/ieee802_11.h | 10 +--------- 9 files changed, 48 insertions(+), 25 deletions(-) diff --git a/hostapd/ap_list.c b/hostapd/ap_list.c index 4f217dc54..e5546092d 100644 --- a/hostapd/ap_list.c +++ b/hostapd/ap_list.c @@ -23,6 +23,7 @@ #include "ap_list.h" #include "hw_features.h" #include "beacon.h" +#include "driver.h" struct ieee80211_frame_info { diff --git a/hostapd/driver.h b/hostapd/driver.h index 55dace5e0..28d4f80ee 100644 --- a/hostapd/driver.h +++ b/hostapd/driver.h @@ -222,4 +222,19 @@ void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr); void hostapd_eapol_receive(struct hostapd_data *hapd, const u8 *sa, const u8 *buf, size_t len); +struct hostapd_frame_info { + u32 phytype; + u32 channel; + u32 datarate; + u32 ssi_signal; + + unsigned int passive_scan:1; +}; + +void hostapd_mgmt_rx(struct hostapd_data *hapd, u8 *buf, size_t len, + u16 stype, struct hostapd_frame_info *fi); +void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, u8 *buf, size_t len, + u16 stype, int ok); +void hostapd_michael_mic_failure(struct hostapd_data *hapd, const u8 *addr); + #endif /* DRIVER_H */ diff --git a/hostapd/driver_bsd.c b/hostapd/driver_bsd.c index 3cca9345b..920dea045 100644 --- a/hostapd/driver_bsd.c +++ b/hostapd/driver_bsd.c @@ -36,7 +36,6 @@ #include "l2_packet/l2_packet.h" #include "eapol_sm.h" -#include "ieee802_11.h" #include "common.h" struct bsd_driver_data { @@ -585,7 +584,7 @@ bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx) "Michael MIC failure wireless event: " "keyix=%u src_addr=" MACSTR, mic->iev_keyix, MAC2STR(mic->iev_src)); - ieee80211_michael_mic_failure(hapd, mic->iev_src, 1); + hostapd_michael_mic_failure(hapd, mic->iev_src); break; } break; diff --git a/hostapd/driver_hostap.c b/hostapd/driver_hostap.c index cf8b9ba26..18ee729b9 100644 --- a/hostapd/driver_hostap.c +++ b/hostapd/driver_hostap.c @@ -36,7 +36,6 @@ #include "driver.h" #include "eloop.h" #include "priv_netlink.h" -#include "ieee802_11.h" #include "hostap_common.h" #include "hw_features.h" @@ -138,7 +137,7 @@ static void handle_tx_callback(struct hostap_driver_data *drv, u8 *buf, case WLAN_FC_TYPE_MGMT: wpa_printf(MSG_DEBUG, "MGMT (TX callback) %s", ok ? "ACK" : "fail"); - ieee802_11_mgmt_cb(drv->hapd, buf, len, stype, ok); + hostapd_mgmt_tx_cb(drv->hapd, buf, len, stype, ok); break; case WLAN_FC_TYPE_CTRL: wpa_printf(MSG_DEBUG, "CTRL (TX callback) %s", @@ -209,7 +208,7 @@ static void handle_frame(struct hostap_driver_data *drv, u8 *buf, size_t len) case WLAN_FC_TYPE_MGMT: if (stype != WLAN_FC_STYPE_BEACON) wpa_printf(MSG_MSGDUMP, "MGMT"); - ieee802_11_mgmt(drv->hapd, buf, data_len, stype, NULL); + hostapd_mgmt_rx(drv->hapd, buf, data_len, stype, NULL); break; case WLAN_FC_TYPE_CTRL: wpa_printf(MSG_DEBUG, "CTRL"); @@ -844,7 +843,7 @@ hostapd_wireless_event_wireless_custom(struct hostap_driver_data *drv, } pos += 5; if (hwaddr_aton(pos, addr) == 0) { - ieee80211_michael_mic_failure(drv->hapd, addr, 1); + hostapd_michael_mic_failure(drv->hapd, addr); } else { wpa_printf(MSG_DEBUG, "MLME-MICHAELMICFAILURE.indication " diff --git a/hostapd/driver_madwifi.c b/hostapd/driver_madwifi.c index ab143f5ae..b0afc87fa 100644 --- a/hostapd/driver_madwifi.c +++ b/hostapd/driver_madwifi.c @@ -61,7 +61,6 @@ #include "priv_netlink.h" #include "l2_packet/l2_packet.h" -#include "ieee802_11.h" #include "common.h" #include "wps_hostapd.h" @@ -902,7 +901,7 @@ madwifi_wireless_event_wireless_custom(struct madwifi_driver_data *drv, } pos += 5; if (hwaddr_aton(pos, addr) == 0) { - ieee80211_michael_mic_failure(drv->hapd, addr, 1); + hostapd_michael_mic_failure(drv->hapd, addr); } else { wpa_printf(MSG_DEBUG, "MLME-MICHAELMICFAILURE.indication " diff --git a/hostapd/driver_nl80211.c b/hostapd/driver_nl80211.c index c697337d9..a7300bcf9 100644 --- a/hostapd/driver_nl80211.c +++ b/hostapd/driver_nl80211.c @@ -32,7 +32,6 @@ #include "hostapd.h" #include "driver.h" #include "eloop.h" -#include "ieee802_11.h" #include "hw_features.h" #include "mlme.h" #include "radiotap.h" @@ -1650,7 +1649,7 @@ static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len, case WLAN_FC_TYPE_MGMT: wpa_printf(MSG_DEBUG, "MGMT (TX callback) %s", ok ? "ACK" : "fail"); - ieee802_11_mgmt_cb(hapd, buf, len, stype, ok); + hostapd_mgmt_tx_cb(hapd, buf, len, stype, ok); break; case WLAN_FC_TYPE_CTRL: wpa_printf(MSG_DEBUG, "CTRL (TX callback) %s", @@ -1767,10 +1766,10 @@ static void handle_frame(struct i802_driver_data *drv, wpa_printf(MSG_MSGDUMP, "MGMT"); if (broadcast_bssid) { for (i = 0; i < iface->num_bss; i++) - ieee802_11_mgmt(iface->bss[i], buf, data_len, + hostapd_mgmt_rx(iface->bss[i], buf, data_len, stype, hfi); } else - ieee802_11_mgmt(hapd, buf, data_len, stype, hfi); + hostapd_mgmt_rx(hapd, buf, data_len, stype, hfi); break; case WLAN_FC_TYPE_CTRL: /* can only get here with PS-Poll frames */ @@ -2122,7 +2121,7 @@ hostapd_wireless_event_wireless_custom(struct i802_driver_data *drv, } pos += 5; if (hwaddr_aton(pos, addr) == 0) { - ieee80211_michael_mic_failure(drv->hapd, addr, 1); + hostapd_michael_mic_failure(drv->hapd, addr); } else { wpa_printf(MSG_DEBUG, "MLME-MICHAELMICFAILURE.indication " diff --git a/hostapd/driver_test.c b/hostapd/driver_test.c index 248d5d27b..afd7a013c 100644 --- a/hostapd/driver_test.c +++ b/hostapd/driver_test.c @@ -22,7 +22,6 @@ #include "eloop.h" #include "wpa.h" #include "l2_packet/l2_packet.h" -#include "ieee802_11.h" #include "hw_features.h" #include "wps_hostapd.h" @@ -317,7 +316,7 @@ static int test_driver_send_mgmt_frame(void *priv, const void *buf, hdr = (struct ieee80211_hdr *) buf; fc = le_to_host16(hdr->frame_control); - ieee802_11_mgmt_cb(drv->hapd, (u8 *) buf, len, WLAN_FC_GET_STYPE(fc), + hostapd_mgmt_tx_cb(drv->hapd, (u8 *) buf, len, WLAN_FC_GET_STYPE(fc), ret >= 0); return ret; @@ -611,7 +610,7 @@ static void test_driver_mlme(struct test_driver_data *drv, __func__); return; } - ieee802_11_mgmt(drv->hapd, data, datalen, WLAN_FC_GET_STYPE(fc), NULL); + hostapd_mgmt_rx(drv->hapd, data, datalen, WLAN_FC_GET_STYPE(fc), NULL); } diff --git a/hostapd/hostapd.c b/hostapd/hostapd.c index 581a415a0..ee7df2f7f 100644 --- a/hostapd/hostapd.c +++ b/hostapd/hostapd.c @@ -397,6 +397,26 @@ void hostapd_eapol_receive(struct hostapd_data *hapd, const u8 *sa, } +void hostapd_mgmt_rx(struct hostapd_data *hapd, u8 *buf, size_t len, + u16 stype, struct hostapd_frame_info *fi) +{ + ieee802_11_mgmt(hapd, buf, len, stype, fi); +} + + +void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, u8 *buf, size_t len, + u16 stype, int ok) +{ + ieee802_11_mgmt_cb(hapd, buf, len, stype, ok); +} + + +void hostapd_michael_mic_failure(struct hostapd_data *hapd, const u8 *addr) +{ + ieee80211_michael_mic_failure(hapd, addr, 1); +} + + #ifdef EAP_SERVER static int hostapd_sim_db_cb_sta(struct hostapd_data *hapd, struct sta_info *sta, void *ctx) diff --git a/hostapd/ieee802_11.h b/hostapd/ieee802_11.h index 91f57285b..ff678618a 100644 --- a/hostapd/ieee802_11.h +++ b/hostapd/ieee802_11.h @@ -19,18 +19,10 @@ #include "ieee802_11_defs.h" #include "ieee802_11_common.h" -struct hostapd_frame_info { - u32 phytype; - u32 channel; - u32 datarate; - u32 ssi_signal; - - unsigned int passive_scan:1; -}; - struct hostapd_iface; struct hostapd_data; struct sta_info; +struct hostapd_frame_info; void ieee802_11_send_deauth(struct hostapd_data *hapd, u8 *addr, u16 reason); void ieee802_11_mgmt(struct hostapd_data *hapd, u8 *buf, size_t len,