#include "hostapd.h"
#include "driver.h"
-#include "ieee802_1x.h"
#include "eloop.h"
-#include "ieee802_11.h"
-#include "sta_info.h"
#include "hw_features.h"
#include "mlme.h"
#include "radiotap.h"
#include "radiotap_iter.h"
+#include "ieee802_11_defs.h"
#ifdef CONFIG_LIBNL20
/* libnl 2.0 compatibility code */
#define nl_handle_destroy nl_socket_free
#endif /* CONFIG_LIBNL20 */
+static const u8 rfc1042_header[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
+
enum ieee80211_msg_type {
ieee80211_msg_normal = 0,
ieee80211_msg_tx_callback_ack = 1,
};
+static int i802_sta_deauth(void *priv, const u8 *addr, int reason);
+static int i802_sta_disassoc(void *priv, const u8 *addr, int reason);
+
+
static void add_ifidx(struct i802_driver_data *drv, int ifidx)
{
int i;
struct iwreq iwr;
memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
+ os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
iwr.u.rts.value = rts;
iwr.u.rts.fixed = 1;
struct iwreq iwr;
memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
+ os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
if (ioctl(drv->ioctl_sock, SIOCGIWRTS, &iwr) < 0) {
perror("ioctl[SIOCGIWRTS]");
struct iwreq iwr;
memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
+ os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
iwr.u.frag.value = frag;
iwr.u.frag.fixed = 1;
struct iwreq iwr;
memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
+ os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
if (ioctl(drv->ioctl_sock, SIOCGIWFRAG, &iwr) < 0) {
perror("ioctl[SIOCGIWFRAG]");
struct iwreq iwr;
memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
+ os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
iwr.u.retry.value = short_retry;
iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
- if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
+ if (ioctl(drv->ioctl_sock, SIOCSIWRETRY, &iwr) < 0) {
perror("ioctl[SIOCSIWRETRY(short)]");
return -1;
}
iwr.u.retry.value = long_retry;
iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
- if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
+ if (ioctl(drv->ioctl_sock, SIOCSIWRETRY, &iwr) < 0) {
perror("ioctl[SIOCSIWRETRY(long)]");
return -1;
}
struct iwreq iwr;
memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
+ os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
if (ioctl(drv->ioctl_sock, SIOCGIWRETRY, &iwr) < 0) {
}
-static int i802_set_regulatory_domain(void *priv, unsigned int rd)
-{
- return -1;
-}
-
-
static int i802_set_tx_queue_params(void *priv, int queue, int aifs,
int cw_min, int cw_max, int burst_time)
{
genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
0, NL80211_CMD_NEW_INTERFACE, 0);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
- if_nametoindex(drv->hapd->conf->iface));
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, ifname);
NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, iftype);
}
-static void handle_unknown_sta(struct hostapd_data *hapd, u8 *ta)
-{
- struct sta_info *sta;
-
- sta = ap_get_sta(hapd, ta);
- if (!sta || !(sta->flags & WLAN_STA_ASSOC)) {
- printf("Data/PS-poll frame from not associated STA "
- MACSTR "\n", MAC2STR(ta));
- if (sta && (sta->flags & WLAN_STA_AUTH))
- hostapd_sta_disassoc(
- hapd, ta,
- WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
- else
- hostapd_sta_deauth(
- hapd, ta,
- WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
- }
-}
-
-
static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
int ok)
{
struct ieee80211_hdr *hdr;
u16 fc, type, stype;
- struct sta_info *sta;
hdr = (struct ieee80211_hdr *) buf;
fc = le_to_host16(hdr->frame_control);
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",
case WLAN_FC_TYPE_DATA:
wpa_printf(MSG_DEBUG, "DATA (TX callback) %s",
ok ? "ACK" : "fail");
- sta = ap_get_sta(hapd, hdr->addr1);
- if (sta && sta->flags & WLAN_STA_PENDING_POLL) {
- wpa_printf(MSG_DEBUG, "STA " MACSTR " %s pending "
- "activity poll", MAC2STR(sta->addr),
- ok ? "ACKed" : "did not ACK");
- if (ok)
- sta->flags &= ~WLAN_STA_PENDING_POLL;
- }
- if (sta)
- ieee802_1x_tx_status(hapd, sta, buf, len, ok);
+ hostapd_tx_status(hapd, hdr->addr1, buf, len, ok);
break;
default:
printf("unknown TX callback frame type %d\n", type);
}
-static void handle_frame(struct hostapd_iface *iface, u8 *buf, size_t len,
+static void handle_frame(struct i802_driver_data *drv,
+ struct hostapd_iface *iface, u8 *buf, size_t len,
struct hostapd_frame_info *hfi,
enum ieee80211_msg_type msg_type)
{
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 */
wpa_printf(MSG_DEBUG, "CTRL");
- handle_unknown_sta(hapd, hdr->addr2);
+ hostapd_rx_from_unknown_sta(drv->hapd, hdr->addr2);
break;
case WLAN_FC_TYPE_DATA:
- handle_unknown_sta(hapd, hdr->addr2);
+ hostapd_rx_from_unknown_sta(drv->hapd, hdr->addr2);
break;
}
}
}
if (have_ifidx(drv, lladdr.sll_ifindex))
- ieee802_1x_receive(hapd, lladdr.sll_addr, buf, len);
+ hostapd_eapol_receive(hapd, lladdr.sll_addr, buf, len);
}
else
msg_type = ieee80211_msg_tx_callback_ack;
- handle_frame(hapd->iface, buf + iter.max_length,
+ handle_frame(drv, hapd->iface, buf + iter.max_length,
len - iter.max_length, &hfi, msg_type);
}
struct ifreq ifr;
struct sockaddr_ll addr;
- drv->ioctl_sock = -1;
-
drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
if (drv->ioctl_sock < 0) {
perror("socket[PF_INET,SOCK_DGRAM]");
}
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 "
.set_retry = i802_set_retry,
.get_retry = i802_get_retry,
.set_rate_sets = i802_set_rate_sets,
- .set_regulatory_domain = i802_set_regulatory_domain,
.set_beacon = i802_set_beacon,
.set_internal_bridge = i802_set_internal_bridge,
.set_beacon_int = i802_set_beacon_int,