Move struct hostapd_frame_info definition away from driver API

This is internal data structure for hostapd/AP functionality and does
not need to be defined in driver.h.
This commit is contained in:
Jouni Malinen 2010-01-03 12:37:02 +02:00
parent 3af1f9cb14
commit 2a8b74163e
7 changed files with 37 additions and 34 deletions

View file

@ -270,15 +270,15 @@ static void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd,
} }
static void hostapd_mgmt_rx(struct hostapd_data *hapd, const u8 *buf, static void hostapd_mgmt_rx(struct hostapd_data *hapd, struct rx_mgmt *rx_mgmt)
size_t len, struct hostapd_frame_info *fi)
{ {
struct hostapd_iface *iface = hapd->iface; struct hostapd_iface *iface = hapd->iface;
const struct ieee80211_hdr *hdr; const struct ieee80211_hdr *hdr;
const u8 *bssid; const u8 *bssid;
struct hostapd_frame_info fi;
hdr = (const struct ieee80211_hdr *) buf; hdr = (const struct ieee80211_hdr *) rx_mgmt->frame;
bssid = get_hdr_bssid(hdr, len); bssid = get_hdr_bssid(hdr, rx_mgmt->frame_len);
if (bssid == NULL) if (bssid == NULL)
return; return;
@ -298,12 +298,17 @@ static void hostapd_mgmt_rx(struct hostapd_data *hapd, const u8 *buf,
return; return;
} }
os_memset(&fi, 0, sizeof(fi));
fi.datarate = rx_mgmt->datarate;
fi.ssi_signal = rx_mgmt->ssi_signal;
if (hapd == HAPD_BROADCAST) { if (hapd == HAPD_BROADCAST) {
size_t i; size_t i;
for (i = 0; i < iface->num_bss; i++) for (i = 0; i < iface->num_bss; i++)
ieee802_11_mgmt(iface->bss[i], buf, len, fi); ieee802_11_mgmt(iface->bss[i], rx_mgmt->frame,
rx_mgmt->frame_len, &fi);
} else } else
ieee802_11_mgmt(hapd, buf, len, fi); ieee802_11_mgmt(hapd, rx_mgmt->frame, rx_mgmt->frame_len, &fi);
} }
@ -382,8 +387,7 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
data->rx_from_unknown.len); data->rx_from_unknown.len);
break; break;
case EVENT_RX_MGMT: case EVENT_RX_MGMT:
hostapd_mgmt_rx(hapd, data->rx_mgmt.frame, hostapd_mgmt_rx(hapd, &data->rx_mgmt);
data->rx_mgmt.frame_len, data->rx_mgmt.fi);
break; break;
#endif /* NEED_AP_MLME */ #endif /* NEED_AP_MLME */
case EVENT_RX_PROBE_REQ: case EVENT_RX_PROBE_REQ:

View file

@ -40,6 +40,12 @@ struct hostapd_rate_data {
int flags; /* HOSTAPD_RATE_ flags */ int flags; /* HOSTAPD_RATE_ flags */
}; };
struct hostapd_frame_info {
u32 channel;
u32 datarate;
u32 ssi_signal;
};
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,

View file

@ -1957,7 +1957,8 @@ union wpa_event_data {
struct rx_mgmt { struct rx_mgmt {
const u8 *frame; const u8 *frame;
size_t frame_len; size_t frame_len;
struct hostapd_frame_info *fi; u32 datarate;
u32 ssi_signal;
} rx_mgmt; } rx_mgmt;
/** /**
@ -2057,12 +2058,6 @@ void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
void hostapd_eapol_receive(struct hostapd_data *hapd, const u8 *sa, void hostapd_eapol_receive(struct hostapd_data *hapd, const u8 *sa,
const u8 *buf, size_t len); const u8 *buf, size_t len);
struct hostapd_frame_info {
u32 channel;
u32 datarate;
u32 ssi_signal;
};
struct hostapd_data * hostapd_sta_get_bss(struct hostapd_data *hapd, struct hostapd_data * hostapd_sta_get_bss(struct hostapd_data *hapd,
const u8 *addr); const u8 *addr);

View file

@ -2726,8 +2726,7 @@ static void from_unknown_sta(struct wpa_driver_nl80211_data *drv,
static void handle_frame(struct wpa_driver_nl80211_data *drv, static void handle_frame(struct wpa_driver_nl80211_data *drv,
u8 *buf, size_t len, u8 *buf, size_t len, int datarate, int ssi_signal)
struct hostapd_frame_info *hfi)
{ {
struct ieee80211_hdr *hdr; struct ieee80211_hdr *hdr;
u16 fc; u16 fc;
@ -2741,7 +2740,8 @@ static void handle_frame(struct wpa_driver_nl80211_data *drv,
os_memset(&event, 0, sizeof(event)); os_memset(&event, 0, sizeof(event));
event.rx_mgmt.frame = buf; event.rx_mgmt.frame = buf;
event.rx_mgmt.frame_len = len; event.rx_mgmt.frame_len = len;
event.rx_mgmt.fi = hfi; event.rx_mgmt.datarate = datarate;
event.rx_mgmt.ssi_signal = ssi_signal;
wpa_supplicant_event(drv->ctx, EVENT_RX_MGMT, &event); wpa_supplicant_event(drv->ctx, EVENT_RX_MGMT, &event);
break; break;
case WLAN_FC_TYPE_CTRL: case WLAN_FC_TYPE_CTRL:
@ -2763,7 +2763,7 @@ static void handle_monitor_read(int sock, void *eloop_ctx, void *sock_ctx)
unsigned char buf[3000]; unsigned char buf[3000];
struct ieee80211_radiotap_iterator iter; struct ieee80211_radiotap_iterator iter;
int ret; int ret;
struct hostapd_frame_info hfi; int datarate = 0, ssi_signal = 0;
int injected = 0, failed = 0, rxflags = 0; int injected = 0, failed = 0, rxflags = 0;
len = recv(sock, buf, sizeof(buf), 0); len = recv(sock, buf, sizeof(buf), 0);
@ -2777,8 +2777,6 @@ static void handle_monitor_read(int sock, void *eloop_ctx, void *sock_ctx)
return; return;
} }
memset(&hfi, 0, sizeof(hfi));
while (1) { while (1) {
ret = ieee80211_radiotap_iterator_next(&iter); ret = ieee80211_radiotap_iterator_next(&iter);
if (ret == -ENOENT) if (ret == -ENOENT)
@ -2803,15 +2801,13 @@ static void handle_monitor_read(int sock, void *eloop_ctx, void *sock_ctx)
case IEEE80211_RADIOTAP_DATA_RETRIES: case IEEE80211_RADIOTAP_DATA_RETRIES:
break; break;
case IEEE80211_RADIOTAP_CHANNEL: case IEEE80211_RADIOTAP_CHANNEL:
/* TODO convert from freq/flags to channel number /* TODO: convert from freq/flags to channel number */
hfi.channel = XXX;
*/
break; break;
case IEEE80211_RADIOTAP_RATE: case IEEE80211_RADIOTAP_RATE:
hfi.datarate = *iter.this_arg * 5; datarate = *iter.this_arg * 5;
break; break;
case IEEE80211_RADIOTAP_DB_ANTSIGNAL: case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
hfi.ssi_signal = *iter.this_arg; ssi_signal = *iter.this_arg;
break; break;
} }
} }
@ -2821,7 +2817,7 @@ static void handle_monitor_read(int sock, void *eloop_ctx, void *sock_ctx)
if (!injected) if (!injected)
handle_frame(drv, buf + iter.max_length, handle_frame(drv, buf + iter.max_length,
len - iter.max_length, &hfi); len - iter.max_length, datarate, ssi_signal);
else else
handle_tx_callback(drv->ctx, buf + iter.max_length, handle_tx_callback(drv->ctx, buf + iter.max_length,
len - iter.max_length, !failed); len - iter.max_length, !failed);

View file

@ -262,12 +262,16 @@ void ap_rx_from_unknown_sta(void *ctx, const struct ieee80211_hdr *hdr,
} }
void ap_mgmt_rx(void *ctx, const u8 *buf, size_t len, void ap_mgmt_rx(void *ctx, struct rx_mgmt *rx_mgmt)
struct hostapd_frame_info *fi)
{ {
#ifdef NEED_AP_MLME #ifdef NEED_AP_MLME
struct wpa_supplicant *wpa_s = ctx; struct wpa_supplicant *wpa_s = ctx;
ieee802_11_mgmt(wpa_s->ap_iface->bss[0], buf, len, fi); struct hostapd_frame_info fi;
os_memset(&fi, 0, sizeof(fi));
fi.datarate = rx_mgmt->datarate;
fi.ssi_signal = rx_mgmt->ssi_signal;
ieee802_11_mgmt(wpa_s->ap_iface->bss[0], rx_mgmt->frame,
rx_mgmt->frame_len, &fi);
#endif /* NEED_AP_MLME */ #endif /* NEED_AP_MLME */
} }

View file

@ -36,8 +36,7 @@ void ap_tx_status(void *ctx, const u8 *addr,
const u8 *buf, size_t len, int ack); const u8 *buf, size_t len, int ack);
void ap_rx_from_unknown_sta(void *ctx, const struct ieee80211_hdr *hdr, void ap_rx_from_unknown_sta(void *ctx, const struct ieee80211_hdr *hdr,
size_t len); size_t len);
void ap_mgmt_rx(void *ctx, const u8 *buf, size_t len, void ap_mgmt_rx(void *ctx, struct rx_mgmt *rx_mgmt);
struct hostapd_frame_info *fi);
void ap_mgmt_tx_cb(void *ctx, const u8 *buf, size_t len, u16 stype, int ok); void ap_mgmt_tx_cb(void *ctx, const u8 *buf, size_t len, u16 stype, int ok);
#endif /* AP_H */ #endif /* AP_H */

View file

@ -1500,8 +1500,7 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
case EVENT_RX_MGMT: case EVENT_RX_MGMT:
if (wpa_s->ap_iface == NULL) if (wpa_s->ap_iface == NULL)
break; break;
ap_mgmt_rx(wpa_s, data->rx_mgmt.frame, ap_mgmt_rx(wpa_s, &data->rx_mgmt);
data->rx_mgmt.frame_len, data->rx_mgmt.fi);
break; break;
#endif /* CONFIG_AP */ #endif /* CONFIG_AP */
#ifdef CONFIG_CLIENT_MLME #ifdef CONFIG_CLIENT_MLME