2 * hostapd / Kernel driver communication via nl80211
3 * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
4 * Copyright (c) 2003-2004, Instant802 Networks, Inc.
5 * Copyright (c) 2005-2006, Devicescape Software, Inc.
6 * Copyright (c) 2007, Johannes Berg <johannes@sipsolutions.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * Alternatively, this software may be distributed under the terms of BSD
15 * See README and COPYING for more details.
20 #include <sys/ioctl.h>
21 #include <netlink/genl/genl.h>
22 #include <netlink/genl/family.h>
23 #include <netlink/genl/ctrl.h>
24 #include <netlink/msg.h>
25 #include <netlink/attr.h>
26 #include "nl80211_copy.h"
28 #include <netpacket/packet.h>
29 #include "wireless_copy.h"
30 #include <net/if_arp.h>
34 #include "ieee802_1x.h"
36 #include "ieee802_11.h"
38 #include "hw_features.h"
41 #include "radiotap_iter.h"
44 /* libnl 2.0 compatibility code */
45 #define nl_handle_alloc_cb nl_socket_alloc_cb
46 #define nl_handle_destroy nl_socket_free
47 #endif /* CONFIG_LIBNL20 */
49 enum ieee80211_msg_type {
50 ieee80211_msg_normal = 0,
51 ieee80211_msg_tx_callback_ack = 1,
52 ieee80211_msg_tx_callback_fail = 2,
55 struct i802_driver_data {
56 struct hostapd_data *hapd;
58 char iface[IFNAMSIZ + 1];
60 int ioctl_sock; /* socket for ioctl() use */
61 int wext_sock; /* socket for wireless events */
62 int eapol_sock; /* socket for EAPOL frames */
63 int monitor_sock; /* socket for monitor */
66 int default_if_indices[16];
71 struct nl_handle *nl_handle;
72 struct nl_cache *nl_cache;
74 struct genl_family *nl80211;
75 int dtim_period, beacon_int;
76 unsigned int beacon_set:1;
77 unsigned int ieee802_1x_active:1;
84 static void add_ifidx(struct i802_driver_data *drv, int ifidx)
89 for (i = 0; i < drv->num_if_indices; i++) {
90 if (drv->if_indices[i] == 0) {
91 drv->if_indices[i] = ifidx;
96 if (drv->if_indices != drv->default_if_indices)
97 old = drv->if_indices;
101 drv->if_indices = realloc(old,
102 sizeof(int) * (drv->num_if_indices + 1));
103 if (!drv->if_indices) {
105 drv->if_indices = drv->default_if_indices;
107 drv->if_indices = old;
108 wpa_printf(MSG_ERROR, "Failed to reallocate memory for "
110 wpa_printf(MSG_ERROR, "Ignoring EAPOL on interface %d", ifidx);
113 drv->if_indices[drv->num_if_indices] = ifidx;
114 drv->num_if_indices++;
118 static void del_ifidx(struct i802_driver_data *drv, int ifidx)
122 for (i = 0; i < drv->num_if_indices; i++) {
123 if (drv->if_indices[i] == ifidx) {
124 drv->if_indices[i] = 0;
131 static int have_ifidx(struct i802_driver_data *drv, int ifidx)
135 if (ifidx == drv->bridge)
138 for (i = 0; i < drv->num_if_indices; i++)
139 if (drv->if_indices[i] == ifidx)
147 static int ack_handler(struct nl_msg *msg, void *arg)
154 static int finish_handler(struct nl_msg *msg, void *arg)
161 static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
169 static int send_and_recv_msgs(struct i802_driver_data *drv,
171 int (*valid_handler)(struct nl_msg *, void *),
177 cb = nl_cb_clone(drv->nl_cb);
181 err = nl_send_auto_complete(drv->nl_handle, msg);
187 nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err);
188 nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
189 nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
192 nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
193 valid_handler, valid_data);
196 nl_recvmsgs(drv->nl_handle, cb);
203 static int hostapd_set_iface_flags(struct i802_driver_data *drv,
204 const char *ifname, int dev_up)
208 if (drv->ioctl_sock < 0)
211 memset(&ifr, 0, sizeof(ifr));
212 os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
214 if (ioctl(drv->ioctl_sock, SIOCGIFFLAGS, &ifr) != 0) {
215 perror("ioctl[SIOCGIFFLAGS]");
216 wpa_printf(MSG_DEBUG, "Could not read interface flags (%s)",
222 ifr.ifr_flags |= IFF_UP;
224 ifr.ifr_flags &= ~IFF_UP;
226 if (ioctl(drv->ioctl_sock, SIOCSIFFLAGS, &ifr) != 0) {
227 perror("ioctl[SIOCSIFFLAGS]");
235 static int nl_set_encr(int ifindex, struct i802_driver_data *drv,
236 const char *alg, const u8 *addr, int idx, const u8 *key,
237 size_t key_len, int txkey)
246 if (strcmp(alg, "none") == 0) {
247 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
248 0, NL80211_CMD_DEL_KEY, 0);
250 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
251 0, NL80211_CMD_NEW_KEY, 0);
252 NLA_PUT(msg, NL80211_ATTR_KEY_DATA, key_len, key);
253 if (strcmp(alg, "WEP") == 0) {
255 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
258 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
260 } else if (strcmp(alg, "TKIP") == 0)
261 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC02);
262 else if (strcmp(alg, "CCMP") == 0)
263 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC04);
264 else if (strcmp(alg, "IGTK") == 0)
265 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC06);
267 wpa_printf(MSG_ERROR, "%s: Unsupported encryption "
268 "algorithm '%s'", __func__, alg);
275 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
276 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
277 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
279 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
284 * If we failed or don't need to set the default TX key (below),
287 if (ret || !txkey || addr)
294 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
295 0, NL80211_CMD_SET_KEY, 0);
296 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
297 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
298 if (strcmp(alg, "IGTK") == 0)
299 NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT_MGMT);
301 NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT);
303 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
312 static int i802_set_encryption(const char *iface, void *priv, const char *alg,
313 const u8 *addr, int idx, const u8 *key,
314 size_t key_len, int txkey)
316 struct i802_driver_data *drv = priv;
319 ret = nl_set_encr(if_nametoindex(iface), drv, alg, addr, idx, key,
328 static inline int min_int(int a, int b)
336 static int get_key_handler(struct nl_msg *msg, void *arg)
338 struct nlattr *tb[NL80211_ATTR_MAX + 1];
339 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
341 nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
342 genlmsg_attrlen(gnlh, 0), NULL);
345 * TODO: validate the key index and mac address!
346 * Otherwise, there's a race condition as soon as
347 * the kernel starts sending key notifications.
350 if (tb[NL80211_ATTR_KEY_SEQ])
351 memcpy(arg, nla_data(tb[NL80211_ATTR_KEY_SEQ]),
352 min_int(nla_len(tb[NL80211_ATTR_KEY_SEQ]), 6));
357 static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr,
360 struct i802_driver_data *drv = priv;
367 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
368 0, NL80211_CMD_GET_KEY, 0);
371 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
372 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
373 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
377 return send_and_recv_msgs(drv, msg, get_key_handler, seq);
383 static int i802_set_rate_sets(void *priv, int *supp_rates, int *basic_rates,
386 struct i802_driver_data *drv = priv;
388 u8 rates[NL80211_MAX_SUPP_RATES];
396 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
397 NL80211_CMD_SET_BSS, 0);
399 for (i = 0; i < NL80211_MAX_SUPP_RATES && basic_rates[i] >= 0; i++)
400 rates[rates_len++] = basic_rates[i] / 5;
402 NLA_PUT(msg, NL80211_ATTR_BSS_BASIC_RATES, rates_len, rates);
404 /* TODO: multi-BSS support */
405 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
407 return send_and_recv_msgs(drv, msg, NULL, NULL);
413 static int i802_send_frame(void *priv, const void *data, size_t len,
414 int encrypt, int flags)
417 0x00, 0x00, /* radiotap version */
418 0x0e, 0x00, /* radiotap length */
419 0x02, 0xc0, 0x00, 0x00, /* bmap: flags, tx and rx flags */
420 IEEE80211_RADIOTAP_F_FRAG, /* F_FRAG (fragment if required) */
422 0x00, 0x00, /* RX and TX flags to indicate that */
423 0x00, 0x00, /* this is the injected frame directly */
425 struct i802_driver_data *drv = priv;
426 struct iovec iov[2] = {
428 .iov_base = &rtap_hdr,
429 .iov_len = sizeof(rtap_hdr),
432 .iov_base = (void*)data,
436 struct msghdr msg = {
447 rtap_hdr[8] |= IEEE80211_RADIOTAP_F_WEP;
449 return sendmsg(drv->monitor_sock, &msg, flags);
452 static int i802_send_mgmt_frame(void *priv, const void *data, size_t len,
455 struct ieee80211_mgmt *mgmt;
456 int do_not_encrypt = 0;
459 mgmt = (struct ieee80211_mgmt *) data;
460 fc = le_to_host16(mgmt->frame_control);
462 if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
463 WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_AUTH) {
465 * Only one of the authentication frame types is encrypted.
466 * In order for static WEP encryption to work properly (i.e.,
467 * to not encrypt the frame), we need to tell mac80211 about
468 * the frames that must not be encrypted.
470 u16 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
471 u16 auth_trans = le_to_host16(mgmt->u.auth.auth_transaction);
472 if (auth_alg == WLAN_AUTH_OPEN ||
473 (auth_alg == WLAN_AUTH_SHARED_KEY && auth_trans != 3))
477 return i802_send_frame(priv, data, len, !do_not_encrypt, flags);
480 /* Set kernel driver on given frequency (MHz) */
481 static int i802_set_freq2(void *priv, struct hostapd_freq_params *freq)
483 struct i802_driver_data *drv = priv;
490 drv->last_freq = freq->freq;
491 drv->last_freq_ht = freq->ht_enabled;
493 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
494 NL80211_CMD_SET_WIPHY, 0);
496 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
497 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq->freq);
498 if (freq->ht_enabled) {
499 switch (freq->sec_channel_offset) {
501 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
502 NL80211_CHAN_HT40MINUS);
505 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
506 NL80211_CHAN_HT40PLUS);
509 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
515 if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
522 static int i802_set_rts(void *priv, int rts)
524 struct i802_driver_data *drv = priv;
527 memset(&iwr, 0, sizeof(iwr));
528 os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
529 iwr.u.rts.value = rts;
532 if (ioctl(drv->ioctl_sock, SIOCSIWRTS, &iwr) < 0) {
533 perror("ioctl[SIOCSIWRTS]");
541 static int i802_get_rts(void *priv, int *rts)
543 struct i802_driver_data *drv = priv;
546 memset(&iwr, 0, sizeof(iwr));
547 os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
549 if (ioctl(drv->ioctl_sock, SIOCGIWRTS, &iwr) < 0) {
550 perror("ioctl[SIOCGIWRTS]");
554 *rts = iwr.u.rts.value;
560 static int i802_set_frag(void *priv, int frag)
562 struct i802_driver_data *drv = priv;
565 memset(&iwr, 0, sizeof(iwr));
566 os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
567 iwr.u.frag.value = frag;
568 iwr.u.frag.fixed = 1;
570 if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
571 perror("ioctl[SIOCSIWFRAG]");
579 static int i802_get_frag(void *priv, int *frag)
581 struct i802_driver_data *drv = priv;
584 memset(&iwr, 0, sizeof(iwr));
585 os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
587 if (ioctl(drv->ioctl_sock, SIOCGIWFRAG, &iwr) < 0) {
588 perror("ioctl[SIOCGIWFRAG]");
592 *frag = iwr.u.frag.value;
598 static int i802_set_retry(void *priv, int short_retry, int long_retry)
600 struct i802_driver_data *drv = priv;
603 memset(&iwr, 0, sizeof(iwr));
604 os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
606 iwr.u.retry.value = short_retry;
607 iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
608 if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
609 perror("ioctl[SIOCSIWRETRY(short)]");
613 iwr.u.retry.value = long_retry;
614 iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
615 if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
616 perror("ioctl[SIOCSIWRETRY(long)]");
624 static int i802_get_retry(void *priv, int *short_retry, int *long_retry)
626 struct i802_driver_data *drv = priv;
629 memset(&iwr, 0, sizeof(iwr));
630 os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
632 iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
633 if (ioctl(drv->ioctl_sock, SIOCGIWRETRY, &iwr) < 0) {
634 perror("ioctl[SIOCGIWFRAG(short)]");
637 *short_retry = iwr.u.retry.value;
639 iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
640 if (ioctl(drv->ioctl_sock, SIOCGIWRETRY, &iwr) < 0) {
641 perror("ioctl[SIOCGIWFRAG(long)]");
644 *long_retry = iwr.u.retry.value;
650 static int i802_flush(void *priv)
652 struct i802_driver_data *drv = priv;
659 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
660 0, NL80211_CMD_DEL_STATION, 0);
663 * XXX: FIX! this needs to flush all VLANs too
665 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
666 if_nametoindex(drv->iface));
668 return send_and_recv_msgs(drv, msg, NULL, NULL);
674 static int get_sta_handler(struct nl_msg *msg, void *arg)
676 struct nlattr *tb[NL80211_ATTR_MAX + 1];
677 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
678 struct hostap_sta_driver_data *data = arg;
679 struct nlattr *stats[NL80211_STA_INFO_MAX + 1];
680 static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
681 [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
682 [NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 },
683 [NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 },
686 nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
687 genlmsg_attrlen(gnlh, 0), NULL);
690 * TODO: validate the interface and mac address!
691 * Otherwise, there's a race condition as soon as
692 * the kernel starts sending station notifications.
695 if (!tb[NL80211_ATTR_STA_INFO]) {
696 wpa_printf(MSG_DEBUG, "sta stats missing!");
699 if (nla_parse_nested(stats, NL80211_STA_INFO_MAX,
700 tb[NL80211_ATTR_STA_INFO],
702 wpa_printf(MSG_DEBUG, "failed to parse nested attributes!");
706 if (stats[NL80211_STA_INFO_INACTIVE_TIME])
707 data->inactive_msec =
708 nla_get_u32(stats[NL80211_STA_INFO_INACTIVE_TIME]);
709 if (stats[NL80211_STA_INFO_RX_BYTES])
710 data->rx_bytes = nla_get_u32(stats[NL80211_STA_INFO_RX_BYTES]);
711 if (stats[NL80211_STA_INFO_TX_BYTES])
712 data->rx_bytes = nla_get_u32(stats[NL80211_STA_INFO_TX_BYTES]);
717 static int i802_read_sta_data(void *priv, struct hostap_sta_driver_data *data,
720 struct i802_driver_data *drv = priv;
727 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
728 0, NL80211_CMD_GET_STATION, 0);
730 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
731 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
733 return send_and_recv_msgs(drv, msg, get_sta_handler, data);
739 static int i802_send_eapol(void *priv, const u8 *addr, const u8 *data,
740 size_t data_len, int encrypt, const u8 *own_addr)
742 struct i802_driver_data *drv = priv;
743 struct ieee80211_hdr *hdr;
748 int qos = sta->flags & WLAN_STA_WME;
753 len = sizeof(*hdr) + (qos ? 2 : 0) + sizeof(rfc1042_header) + 2 +
755 hdr = os_zalloc(len);
757 printf("malloc() failed for i802_send_data(len=%lu)\n",
758 (unsigned long) len);
763 IEEE80211_FC(WLAN_FC_TYPE_DATA, WLAN_FC_STYPE_DATA);
764 hdr->frame_control |= host_to_le16(WLAN_FC_FROMDS);
766 hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
767 #if 0 /* To be enabled if qos determination is added above */
769 hdr->frame_control |=
770 host_to_le16(WLAN_FC_STYPE_QOS_DATA << 4);
774 memcpy(hdr->IEEE80211_DA_FROMDS, addr, ETH_ALEN);
775 memcpy(hdr->IEEE80211_BSSID_FROMDS, own_addr, ETH_ALEN);
776 memcpy(hdr->IEEE80211_SA_FROMDS, own_addr, ETH_ALEN);
777 pos = (u8 *) (hdr + 1);
779 #if 0 /* To be enabled if qos determination is added above */
781 /* add an empty QoS header if needed */
788 memcpy(pos, rfc1042_header, sizeof(rfc1042_header));
789 pos += sizeof(rfc1042_header);
790 WPA_PUT_BE16(pos, ETH_P_PAE);
792 memcpy(pos, data, data_len);
794 res = i802_send_frame(drv, (u8 *) hdr, len, encrypt, 0);
798 perror("i802_send_eapol: send");
799 printf("i802_send_eapol - packet len: %lu - failed\n",
800 (unsigned long) len);
807 static int i802_sta_add2(const char *ifname, void *priv,
808 struct hostapd_sta_add_params *params)
810 struct i802_driver_data *drv = priv;
818 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
819 0, NL80211_CMD_NEW_STATION, 0);
821 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
822 if_nametoindex(drv->iface));
823 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, params->addr);
824 NLA_PUT_U16(msg, NL80211_ATTR_STA_AID, params->aid);
825 NLA_PUT(msg, NL80211_ATTR_STA_SUPPORTED_RATES, params->supp_rates_len,
827 NLA_PUT_U16(msg, NL80211_ATTR_STA_LISTEN_INTERVAL,
828 params->listen_interval);
830 #ifdef CONFIG_IEEE80211N
831 if (params->ht_capabilities) {
832 NLA_PUT(msg, NL80211_ATTR_HT_CAPABILITY,
833 params->ht_capabilities->length,
834 ¶ms->ht_capabilities->data);
836 #endif /* CONFIG_IEEE80211N */
838 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
846 static int i802_sta_remove(void *priv, const u8 *addr)
848 struct i802_driver_data *drv = priv;
856 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
857 0, NL80211_CMD_DEL_STATION, 0);
859 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
860 if_nametoindex(drv->iface));
861 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
863 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
872 static int i802_sta_set_flags(void *priv, const u8 *addr,
873 int total_flags, int flags_or, int flags_and)
875 struct i802_driver_data *drv = priv;
876 struct nl_msg *msg, *flags = NULL;
882 flags = nlmsg_alloc();
888 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
889 0, NL80211_CMD_SET_STATION, 0);
891 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
892 if_nametoindex(drv->iface));
893 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
895 if (total_flags & WLAN_STA_AUTHORIZED || !drv->ieee802_1x_active)
896 NLA_PUT_FLAG(flags, NL80211_STA_FLAG_AUTHORIZED);
898 if (total_flags & WLAN_STA_WME)
899 NLA_PUT_FLAG(flags, NL80211_STA_FLAG_WME);
901 if (total_flags & WLAN_STA_SHORT_PREAMBLE)
902 NLA_PUT_FLAG(flags, NL80211_STA_FLAG_SHORT_PREAMBLE);
904 if (total_flags & WLAN_STA_MFP)
905 NLA_PUT_FLAG(flags, NL80211_STA_FLAG_MFP);
907 if (nla_put_nested(msg, NL80211_ATTR_STA_FLAGS, flags))
908 goto nla_put_failure;
912 return send_and_recv_msgs(drv, msg, NULL, NULL);
919 static int i802_set_regulatory_domain(void *priv, unsigned int rd)
925 static int i802_set_tx_queue_params(void *priv, int queue, int aifs,
926 int cw_min, int cw_max, int burst_time)
928 struct i802_driver_data *drv = priv;
930 struct nlattr *txq, *params;
936 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
937 0, NL80211_CMD_SET_WIPHY, 0);
939 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
941 txq = nla_nest_start(msg, NL80211_ATTR_WIPHY_TXQ_PARAMS);
943 goto nla_put_failure;
945 /* We are only sending parameters for a single TXQ at a time */
946 params = nla_nest_start(msg, 1);
948 goto nla_put_failure;
950 NLA_PUT_U8(msg, NL80211_TXQ_ATTR_QUEUE, queue);
951 /* Burst time is configured in units of 0.1 msec and TXOP parameter in
952 * 32 usec, so need to convert the value here. */
953 NLA_PUT_U16(msg, NL80211_TXQ_ATTR_TXOP, (burst_time * 100 + 16) / 32);
954 NLA_PUT_U16(msg, NL80211_TXQ_ATTR_CWMIN, cw_min);
955 NLA_PUT_U16(msg, NL80211_TXQ_ATTR_CWMAX, cw_max);
956 NLA_PUT_U8(msg, NL80211_TXQ_ATTR_AIFS, aifs);
958 nla_nest_end(msg, params);
960 nla_nest_end(msg, txq);
962 if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
969 static void nl80211_remove_iface(struct i802_driver_data *drv, int ifidx)
973 /* stop listening for EAPOL on this interface */
974 del_ifidx(drv, ifidx);
978 goto nla_put_failure;
980 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
981 0, NL80211_CMD_DEL_INTERFACE, 0);
982 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifidx);
984 if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
987 printf("Failed to remove interface.\n");
991 static int nl80211_create_iface(struct i802_driver_data *drv,
993 enum nl80211_iftype iftype,
996 struct nl_msg *msg, *flags = NULL;
1002 msg = nlmsg_alloc();
1006 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1007 0, NL80211_CMD_NEW_INTERFACE, 0);
1008 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
1009 if_nametoindex(drv->hapd->conf->iface));
1010 NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, ifname);
1011 NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, iftype);
1013 if (iftype == NL80211_IFTYPE_MONITOR) {
1016 flags = nlmsg_alloc();
1018 goto nla_put_failure;
1020 NLA_PUT_FLAG(flags, NL80211_MNTR_FLAG_COOK_FRAMES);
1022 err = nla_put_nested(msg, NL80211_ATTR_MNTR_FLAGS, flags);
1027 goto nla_put_failure;
1030 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
1033 printf("Failed to create interface %s.\n", ifname);
1037 ifidx = if_nametoindex(ifname);
1042 /* start listening for EAPOL on this interface */
1043 add_ifidx(drv, ifidx);
1047 case NL80211_IFTYPE_AP:
1048 os_strlcpy(ifreq.ifr_name, ifname, IFNAMSIZ);
1049 memcpy(ifreq.ifr_hwaddr.sa_data, addr, ETH_ALEN);
1050 ifreq.ifr_hwaddr.sa_family = ARPHRD_ETHER;
1052 if (ioctl(drv->ioctl_sock, SIOCSIFHWADDR, &ifreq)) {
1053 nl80211_remove_iface(drv, ifidx);
1057 case NL80211_IFTYPE_WDS:
1058 memset(&iwr, 0, sizeof(iwr));
1059 os_strlcpy(iwr.ifr_name, ifname, IFNAMSIZ);
1060 iwr.u.addr.sa_family = ARPHRD_ETHER;
1061 memcpy(iwr.u.addr.sa_data, addr, ETH_ALEN);
1062 if (ioctl(drv->ioctl_sock, SIOCSIWAP, &iwr))
1075 static int i802_bss_add(void *priv, const char *ifname, const u8 *bssid)
1080 * The kernel supports that when the low-level driver does,
1081 * but we currently don't because we need per-BSS data that
1082 * currently we can't handle easily.
1086 ifidx = nl80211_create_iface(priv, ifname, NL80211_IFTYPE_AP, bssid);
1089 if (hostapd_set_iface_flags(priv, ifname, 1)) {
1090 nl80211_remove_iface(priv, ifidx);
1097 static int i802_bss_remove(void *priv, const char *ifname)
1099 nl80211_remove_iface(priv, if_nametoindex(ifname));
1104 static int i802_set_beacon(const char *iface, void *priv,
1105 u8 *head, size_t head_len,
1106 u8 *tail, size_t tail_len)
1108 struct i802_driver_data *drv = priv;
1110 u8 cmd = NL80211_CMD_NEW_BEACON;
1113 msg = nlmsg_alloc();
1117 if (drv->beacon_set)
1118 cmd = NL80211_CMD_SET_BEACON;
1120 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1122 NLA_PUT(msg, NL80211_ATTR_BEACON_HEAD, head_len, head);
1123 NLA_PUT(msg, NL80211_ATTR_BEACON_TAIL, tail_len, tail);
1124 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
1125 NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, drv->beacon_int);
1127 if (!drv->dtim_period)
1128 drv->dtim_period = 2;
1129 NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
1131 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
1133 drv->beacon_set = 1;
1140 static int i802_del_beacon(struct i802_driver_data *drv)
1144 msg = nlmsg_alloc();
1148 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1149 0, NL80211_CMD_DEL_BEACON, 0);
1150 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1152 return send_and_recv_msgs(drv, msg, NULL, NULL);
1158 static int i802_set_ieee8021x(const char *ifname, void *priv, int enabled)
1160 struct i802_driver_data *drv = priv;
1163 * FIXME: This needs to be per interface (BSS)
1165 drv->ieee802_1x_active = enabled;
1170 static int i802_set_privacy(const char *ifname, void *priv, int enabled)
1172 struct i802_driver_data *drv = priv;
1175 memset(&iwr, 0, sizeof(iwr));
1177 os_strlcpy(iwr.ifr_name, ifname, IFNAMSIZ);
1178 iwr.u.param.flags = IW_AUTH_PRIVACY_INVOKED;
1179 iwr.u.param.value = enabled;
1181 ioctl(drv->ioctl_sock, SIOCSIWAUTH, &iwr);
1183 /* ignore errors, the kernel/driver might not care */
1188 static int i802_set_internal_bridge(void *priv, int value)
1194 static int i802_set_beacon_int(void *priv, int value)
1196 struct i802_driver_data *drv = priv;
1199 drv->beacon_int = value;
1201 if (!drv->beacon_set)
1204 msg = nlmsg_alloc();
1208 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1209 0, NL80211_CMD_SET_BEACON, 0);
1210 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1212 NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, value);
1214 return send_and_recv_msgs(drv, msg, NULL, NULL);
1220 static int i802_set_dtim_period(const char *iface, void *priv, int value)
1222 struct i802_driver_data *drv = priv;
1225 msg = nlmsg_alloc();
1229 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1230 0, NL80211_CMD_SET_BEACON, 0);
1231 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
1233 drv->dtim_period = value;
1234 NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
1236 return send_and_recv_msgs(drv, msg, NULL, NULL);
1242 static int i802_set_bss(void *priv, int cts, int preamble, int slot)
1244 struct i802_driver_data *drv = priv;
1247 msg = nlmsg_alloc();
1251 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
1252 NL80211_CMD_SET_BSS, 0);
1255 NLA_PUT_U8(msg, NL80211_ATTR_BSS_CTS_PROT, cts);
1257 NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_PREAMBLE, preamble);
1259 NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_SLOT_TIME, slot);
1261 /* TODO: multi-BSS support */
1262 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1264 return send_and_recv_msgs(drv, msg, NULL, NULL);
1270 static int i802_set_cts_protect(void *priv, int value)
1272 return i802_set_bss(priv, value, -1, -1);
1276 static int i802_set_preamble(void *priv, int value)
1278 return i802_set_bss(priv, -1, value, -1);
1282 static int i802_set_short_slot_time(void *priv, int value)
1284 return i802_set_bss(priv, -1, -1, value);
1288 static enum nl80211_iftype i802_if_type(enum hostapd_driver_if_type type)
1291 case HOSTAPD_IF_VLAN:
1292 return NL80211_IFTYPE_AP_VLAN;
1293 case HOSTAPD_IF_WDS:
1294 return NL80211_IFTYPE_WDS;
1300 static int i802_if_add(const char *iface, void *priv,
1301 enum hostapd_driver_if_type type, char *ifname,
1304 if (nl80211_create_iface(priv, ifname, i802_if_type(type), addr) < 0)
1310 static int i802_if_update(void *priv, enum hostapd_driver_if_type type,
1311 char *ifname, const u8 *addr)
1313 /* unused at the moment */
1318 static int i802_if_remove(void *priv, enum hostapd_driver_if_type type,
1319 const char *ifname, const u8 *addr)
1321 nl80211_remove_iface(priv, if_nametoindex(ifname));
1326 struct phy_info_arg {
1328 struct hostapd_hw_modes *modes;
1331 static int phy_info_handler(struct nl_msg *msg, void *arg)
1333 struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
1334 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
1335 struct phy_info_arg *phy_info = arg;
1337 struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1];
1339 struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1];
1340 static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
1341 [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
1342 [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
1343 [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
1344 [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
1345 [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
1346 [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
1349 struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1];
1350 static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = {
1351 [NL80211_BITRATE_ATTR_RATE] = { .type = NLA_U32 },
1352 [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE] = { .type = NLA_FLAG },
1355 struct nlattr *nl_band;
1356 struct nlattr *nl_freq;
1357 struct nlattr *nl_rate;
1358 int rem_band, rem_freq, rem_rate;
1359 struct hostapd_hw_modes *mode;
1360 int idx, mode_is_set;
1362 nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
1363 genlmsg_attrlen(gnlh, 0), NULL);
1365 if (!tb_msg[NL80211_ATTR_WIPHY_BANDS])
1368 nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) {
1369 mode = realloc(phy_info->modes, (*phy_info->num_modes + 1) * sizeof(*mode));
1372 phy_info->modes = mode;
1376 mode = &phy_info->modes[*(phy_info->num_modes)];
1377 memset(mode, 0, sizeof(*mode));
1378 *(phy_info->num_modes) += 1;
1380 nla_parse(tb_band, NL80211_BAND_ATTR_MAX, nla_data(nl_band),
1381 nla_len(nl_band), NULL);
1383 nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) {
1384 nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq),
1385 nla_len(nl_freq), freq_policy);
1386 if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
1388 mode->num_channels++;
1391 mode->channels = calloc(mode->num_channels, sizeof(struct hostapd_channel_data));
1392 if (!mode->channels)
1397 nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) {
1398 nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq),
1399 nla_len(nl_freq), freq_policy);
1400 if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
1403 mode->channels[idx].freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]);
1404 mode->channels[idx].flag = 0;
1407 /* crude heuristic */
1408 if (mode->channels[idx].freq < 4000)
1409 mode->mode = HOSTAPD_MODE_IEEE80211B;
1411 mode->mode = HOSTAPD_MODE_IEEE80211A;
1415 /* crude heuristic */
1416 if (mode->channels[idx].freq < 4000)
1417 if (mode->channels[idx].freq == 2848)
1418 mode->channels[idx].chan = 14;
1420 mode->channels[idx].chan = (mode->channels[idx].freq - 2407) / 5;
1422 mode->channels[idx].chan = mode->channels[idx].freq/5 - 1000;
1424 if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
1425 mode->channels[idx].flag |=
1426 HOSTAPD_CHAN_DISABLED;
1427 if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN])
1428 mode->channels[idx].flag |=
1429 HOSTAPD_CHAN_PASSIVE_SCAN;
1430 if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IBSS])
1431 mode->channels[idx].flag |=
1432 HOSTAPD_CHAN_NO_IBSS;
1433 if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR])
1434 mode->channels[idx].flag |=
1437 if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] &&
1438 !tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
1439 mode->channels[idx].max_tx_power =
1440 nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]) / 100;
1445 nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
1446 nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate),
1447 nla_len(nl_rate), rate_policy);
1448 if (!tb_rate[NL80211_BITRATE_ATTR_RATE])
1453 mode->rates = calloc(mode->num_rates, sizeof(struct hostapd_rate_data));
1459 nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
1460 nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate),
1461 nla_len(nl_rate), rate_policy);
1462 if (!tb_rate[NL80211_BITRATE_ATTR_RATE])
1464 mode->rates[idx].rate = nla_get_u32(tb_rate[NL80211_BITRATE_ATTR_RATE]);
1466 /* crude heuristic */
1467 if (mode->mode == HOSTAPD_MODE_IEEE80211B &&
1468 mode->rates[idx].rate > 200)
1469 mode->mode = HOSTAPD_MODE_IEEE80211G;
1471 if (tb_rate[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE])
1472 mode->rates[idx].flags |= HOSTAPD_RATE_PREAMBLE2;
1481 static struct hostapd_hw_modes *i802_add_11b(struct hostapd_hw_modes *modes,
1485 struct hostapd_hw_modes *mode11g = NULL, *nmodes, *mode;
1486 int i, mode11g_idx = -1;
1488 /* If only 802.11g mode is included, use it to construct matching
1489 * 802.11b mode data. */
1491 for (m = 0; m < *num_modes; m++) {
1492 if (modes[m].mode == HOSTAPD_MODE_IEEE80211B)
1493 return modes; /* 802.11b already included */
1494 if (modes[m].mode == HOSTAPD_MODE_IEEE80211G)
1498 if (mode11g_idx < 0)
1499 return modes; /* 2.4 GHz band not supported at all */
1501 nmodes = os_realloc(modes, (*num_modes + 1) * sizeof(*nmodes));
1503 return modes; /* Could not add 802.11b mode */
1505 mode = &nmodes[*num_modes];
1506 os_memset(mode, 0, sizeof(*mode));
1510 mode->mode = HOSTAPD_MODE_IEEE80211B;
1512 mode11g = &modes[mode11g_idx];
1513 mode->num_channels = mode11g->num_channels;
1514 mode->channels = os_malloc(mode11g->num_channels *
1515 sizeof(struct hostapd_channel_data));
1516 if (mode->channels == NULL) {
1518 return modes; /* Could not add 802.11b mode */
1520 os_memcpy(mode->channels, mode11g->channels,
1521 mode11g->num_channels * sizeof(struct hostapd_channel_data));
1523 mode->num_rates = 0;
1524 mode->rates = os_malloc(4 * sizeof(struct hostapd_rate_data));
1525 if (mode->rates == NULL) {
1526 os_free(mode->channels);
1528 return modes; /* Could not add 802.11b mode */
1531 for (i = 0; i < mode11g->num_rates; i++) {
1532 if (mode11g->rates[i].rate > 110 ||
1533 mode11g->rates[i].flags &
1534 (HOSTAPD_RATE_ERP | HOSTAPD_RATE_OFDM))
1536 mode->rates[mode->num_rates] = mode11g->rates[i];
1538 if (mode->num_rates == 4)
1542 if (mode->num_rates == 0) {
1543 os_free(mode->channels);
1544 os_free(mode->rates);
1546 return modes; /* No 802.11b rates */
1549 wpa_printf(MSG_DEBUG, "nl80211: Added 802.11b mode based on 802.11g "
1555 static struct hostapd_hw_modes *i802_get_hw_feature_data(void *priv,
1559 struct i802_driver_data *drv = priv;
1561 struct phy_info_arg result = {
1562 .num_modes = num_modes,
1569 msg = nlmsg_alloc();
1573 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1574 0, NL80211_CMD_GET_WIPHY, 0);
1576 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1578 if (send_and_recv_msgs(drv, msg, phy_info_handler, &result) == 0)
1579 return i802_add_11b(result.modes, num_modes);
1585 static int i802_set_sta_vlan(void *priv, const u8 *addr,
1586 const char *ifname, int vlan_id)
1588 struct i802_driver_data *drv = priv;
1591 msg = nlmsg_alloc();
1595 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1596 0, NL80211_CMD_SET_STATION, 0);
1598 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
1599 if_nametoindex(drv->iface));
1600 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
1601 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
1602 if_nametoindex(ifname));
1604 return send_and_recv_msgs(drv, msg, NULL, NULL);
1610 static int i802_set_country(void *priv, const char *country)
1612 struct i802_driver_data *drv = priv;
1616 msg = nlmsg_alloc();
1620 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1621 0, NL80211_CMD_REQ_SET_REG, 0);
1623 alpha2[0] = country[0];
1624 alpha2[1] = country[1];
1626 NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2, alpha2);
1628 return send_and_recv_msgs(drv, msg, NULL, NULL);
1634 static void handle_unknown_sta(struct hostapd_data *hapd, u8 *ta)
1636 struct sta_info *sta;
1638 sta = ap_get_sta(hapd, ta);
1639 if (!sta || !(sta->flags & WLAN_STA_ASSOC)) {
1640 printf("Data/PS-poll frame from not associated STA "
1641 MACSTR "\n", MAC2STR(ta));
1642 if (sta && (sta->flags & WLAN_STA_AUTH))
1643 hostapd_sta_disassoc(
1645 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
1649 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
1654 static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
1657 struct ieee80211_hdr *hdr;
1658 u16 fc, type, stype;
1659 struct sta_info *sta;
1661 hdr = (struct ieee80211_hdr *) buf;
1662 fc = le_to_host16(hdr->frame_control);
1664 type = WLAN_FC_GET_TYPE(fc);
1665 stype = WLAN_FC_GET_STYPE(fc);
1668 case WLAN_FC_TYPE_MGMT:
1669 wpa_printf(MSG_DEBUG, "MGMT (TX callback) %s",
1670 ok ? "ACK" : "fail");
1671 ieee802_11_mgmt_cb(hapd, buf, len, stype, ok);
1673 case WLAN_FC_TYPE_CTRL:
1674 wpa_printf(MSG_DEBUG, "CTRL (TX callback) %s",
1675 ok ? "ACK" : "fail");
1677 case WLAN_FC_TYPE_DATA:
1678 wpa_printf(MSG_DEBUG, "DATA (TX callback) %s",
1679 ok ? "ACK" : "fail");
1680 sta = ap_get_sta(hapd, hdr->addr1);
1681 if (sta && sta->flags & WLAN_STA_PENDING_POLL) {
1682 wpa_printf(MSG_DEBUG, "STA " MACSTR " %s pending "
1683 "activity poll", MAC2STR(sta->addr),
1684 ok ? "ACKed" : "did not ACK");
1686 sta->flags &= ~WLAN_STA_PENDING_POLL;
1689 ieee802_1x_tx_status(hapd, sta, buf, len, ok);
1692 printf("unknown TX callback frame type %d\n", type);
1698 static void handle_frame(struct hostapd_iface *iface, u8 *buf, size_t len,
1699 struct hostapd_frame_info *hfi,
1700 enum ieee80211_msg_type msg_type)
1702 struct ieee80211_hdr *hdr;
1703 u16 fc, type, stype;
1704 size_t data_len = len;
1705 struct hostapd_data *hapd = NULL;
1706 int broadcast_bssid = 0;
1711 * PS-Poll frames are 16 bytes. All other frames are
1712 * 24 bytes or longer.
1717 hdr = (struct ieee80211_hdr *) buf;
1718 fc = le_to_host16(hdr->frame_control);
1720 type = WLAN_FC_GET_TYPE(fc);
1721 stype = WLAN_FC_GET_STYPE(fc);
1724 case WLAN_FC_TYPE_DATA:
1727 switch (fc & (WLAN_FC_FROMDS | WLAN_FC_TODS)) {
1736 case WLAN_FC_TYPE_CTRL:
1737 /* discard non-ps-poll frames */
1738 if (stype != WLAN_FC_STYPE_PSPOLL)
1742 case WLAN_FC_TYPE_MGMT:
1750 /* find interface frame belongs to */
1751 for (i = 0; i < iface->num_bss; i++) {
1752 if (memcmp(bssid, iface->bss[i]->own_addr, ETH_ALEN) == 0) {
1753 hapd = iface->bss[i];
1759 hapd = iface->bss[0];
1761 if (bssid[0] != 0xff || bssid[1] != 0xff ||
1762 bssid[2] != 0xff || bssid[3] != 0xff ||
1763 bssid[4] != 0xff || bssid[5] != 0xff) {
1765 * Unknown BSSID - drop frame if this is not from
1766 * passive scanning or a beacon (at least ProbeReq
1767 * frames to other APs may be allowed through RX
1768 * filtering in the wlan hw/driver)
1770 if ((type != WLAN_FC_TYPE_MGMT ||
1771 stype != WLAN_FC_STYPE_BEACON))
1774 broadcast_bssid = 1;
1778 case ieee80211_msg_normal:
1779 /* continue processing */
1781 case ieee80211_msg_tx_callback_ack:
1782 handle_tx_callback(hapd, buf, data_len, 1);
1784 case ieee80211_msg_tx_callback_fail:
1785 handle_tx_callback(hapd, buf, data_len, 0);
1790 case WLAN_FC_TYPE_MGMT:
1791 if (stype != WLAN_FC_STYPE_BEACON &&
1792 stype != WLAN_FC_STYPE_PROBE_REQ)
1793 wpa_printf(MSG_MSGDUMP, "MGMT");
1794 if (broadcast_bssid) {
1795 for (i = 0; i < iface->num_bss; i++)
1796 ieee802_11_mgmt(iface->bss[i], buf, data_len,
1799 ieee802_11_mgmt(hapd, buf, data_len, stype, hfi);
1801 case WLAN_FC_TYPE_CTRL:
1802 /* can only get here with PS-Poll frames */
1803 wpa_printf(MSG_DEBUG, "CTRL");
1804 handle_unknown_sta(hapd, hdr->addr2);
1806 case WLAN_FC_TYPE_DATA:
1807 handle_unknown_sta(hapd, hdr->addr2);
1813 static void handle_eapol(int sock, void *eloop_ctx, void *sock_ctx)
1815 struct i802_driver_data *drv = eloop_ctx;
1816 struct hostapd_data *hapd = drv->hapd;
1817 struct sockaddr_ll lladdr;
1818 unsigned char buf[3000];
1820 socklen_t fromlen = sizeof(lladdr);
1822 len = recvfrom(sock, buf, sizeof(buf), 0,
1823 (struct sockaddr *)&lladdr, &fromlen);
1829 if (have_ifidx(drv, lladdr.sll_ifindex))
1830 ieee802_1x_receive(hapd, lladdr.sll_addr, buf, len);
1834 static void handle_monitor_read(int sock, void *eloop_ctx, void *sock_ctx)
1836 struct i802_driver_data *drv = eloop_ctx;
1838 unsigned char buf[3000];
1839 struct hostapd_data *hapd = drv->hapd;
1840 struct ieee80211_radiotap_iterator iter;
1842 struct hostapd_frame_info hfi;
1843 int injected = 0, failed = 0, msg_type, rxflags = 0;
1845 len = recv(sock, buf, sizeof(buf), 0);
1851 if (ieee80211_radiotap_iterator_init(&iter, (void*)buf, len)) {
1852 printf("received invalid radiotap frame\n");
1856 memset(&hfi, 0, sizeof(hfi));
1859 ret = ieee80211_radiotap_iterator_next(&iter);
1863 printf("received invalid radiotap frame (%d)\n", ret);
1866 switch (iter.this_arg_index) {
1867 case IEEE80211_RADIOTAP_FLAGS:
1868 if (*iter.this_arg & IEEE80211_RADIOTAP_F_FCS)
1871 case IEEE80211_RADIOTAP_RX_FLAGS:
1874 case IEEE80211_RADIOTAP_TX_FLAGS:
1876 failed = le_to_host16((*(uint16_t *) iter.this_arg)) &
1877 IEEE80211_RADIOTAP_F_TX_FAIL;
1879 case IEEE80211_RADIOTAP_DATA_RETRIES:
1881 case IEEE80211_RADIOTAP_CHANNEL:
1882 /* TODO convert from freq/flags to channel number
1887 case IEEE80211_RADIOTAP_RATE:
1888 hfi.datarate = *iter.this_arg * 5;
1890 case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
1891 hfi.ssi_signal = *iter.this_arg;
1896 if (rxflags && injected)
1900 msg_type = ieee80211_msg_normal;
1902 msg_type = ieee80211_msg_tx_callback_fail;
1904 msg_type = ieee80211_msg_tx_callback_ack;
1906 handle_frame(hapd->iface, buf + iter.max_length,
1907 len - iter.max_length, &hfi, msg_type);
1911 static int nl80211_create_monitor_interface(struct i802_driver_data *drv)
1914 struct sockaddr_ll ll;
1918 snprintf(buf, IFNAMSIZ, "mon.%s", drv->iface);
1919 buf[IFNAMSIZ - 1] = '\0';
1921 drv->monitor_ifidx =
1922 nl80211_create_iface(drv, buf, NL80211_IFTYPE_MONITOR, NULL);
1924 if (drv->monitor_ifidx < 0)
1927 if (hostapd_set_iface_flags(drv, buf, 1))
1930 memset(&ll, 0, sizeof(ll));
1931 ll.sll_family = AF_PACKET;
1932 ll.sll_ifindex = drv->monitor_ifidx;
1933 drv->monitor_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
1934 if (drv->monitor_sock < 0) {
1935 perror("socket[PF_PACKET,SOCK_RAW]");
1939 if (bind(drv->monitor_sock, (struct sockaddr *) &ll,
1941 perror("monitor socket bind");
1945 optlen = sizeof(optval);
1948 (drv->monitor_sock, SOL_SOCKET, SO_PRIORITY, &optval, optlen)) {
1949 perror("Failed to set socket priority");
1953 if (eloop_register_read_sock(drv->monitor_sock, handle_monitor_read,
1955 printf("Could not register monitor read socket\n");
1961 nl80211_remove_iface(drv, drv->monitor_ifidx);
1966 static int nl80211_set_master_mode(struct i802_driver_data *drv,
1972 msg = nlmsg_alloc();
1976 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1977 0, NL80211_CMD_SET_INTERFACE, 0);
1978 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
1979 if_nametoindex(ifname));
1980 NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_AP);
1982 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
1986 wpa_printf(MSG_ERROR, "Failed to set interface %s to master "
1992 static int i802_init_sockets(struct i802_driver_data *drv, const u8 *bssid)
1995 struct sockaddr_ll addr;
1997 drv->ioctl_sock = -1;
1999 drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
2000 if (drv->ioctl_sock < 0) {
2001 perror("socket[PF_INET,SOCK_DGRAM]");
2005 /* start listening for EAPOL on the default AP interface */
2006 add_ifidx(drv, if_nametoindex(drv->iface));
2008 if (hostapd_set_iface_flags(drv, drv->iface, 0))
2012 os_strlcpy(ifr.ifr_name, drv->iface, IFNAMSIZ);
2013 memcpy(ifr.ifr_hwaddr.sa_data, bssid, ETH_ALEN);
2014 ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
2016 if (ioctl(drv->ioctl_sock, SIOCSIFHWADDR, &ifr)) {
2017 perror("ioctl(SIOCSIFHWADDR)");
2023 * initialise generic netlink and nl80211
2025 drv->nl_cb = nl_cb_alloc(NL_CB_DEFAULT);
2027 printf("Failed to allocate netlink callbacks.\n");
2031 drv->nl_handle = nl_handle_alloc_cb(drv->nl_cb);
2032 if (!drv->nl_handle) {
2033 printf("Failed to allocate netlink handle.\n");
2037 if (genl_connect(drv->nl_handle)) {
2038 printf("Failed to connect to generic netlink.\n");
2042 #ifdef CONFIG_LIBNL20
2043 if (genl_ctrl_alloc_cache(drv->nl_handle, &drv->nl_cache) < 0) {
2044 printf("Failed to allocate generic netlink cache.\n");
2047 #else /* CONFIG_LIBNL20 */
2048 drv->nl_cache = genl_ctrl_alloc_cache(drv->nl_handle);
2049 if (!drv->nl_cache) {
2050 printf("Failed to allocate generic netlink cache.\n");
2053 #endif /* CONFIG_LIBNL20 */
2055 drv->nl80211 = genl_ctrl_search_by_name(drv->nl_cache, "nl80211");
2056 if (!drv->nl80211) {
2057 printf("nl80211 not found.\n");
2061 /* Initialise a monitor interface */
2062 if (nl80211_create_monitor_interface(drv))
2065 if (nl80211_set_master_mode(drv, drv->iface))
2068 if (hostapd_set_iface_flags(drv, drv->iface, 1))
2071 memset(&addr, 0, sizeof(addr));
2072 addr.sll_family = AF_PACKET;
2073 addr.sll_ifindex = ifr.ifr_ifindex;
2074 wpa_printf(MSG_DEBUG, "Opening raw packet socket for ifindex %d",
2077 drv->eapol_sock = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_PAE));
2078 if (drv->eapol_sock < 0) {
2079 perror("socket(PF_PACKET, SOCK_DGRAM, ETH_P_PAE)");
2083 if (eloop_register_read_sock(drv->eapol_sock, handle_eapol, drv, NULL))
2085 printf("Could not register read socket for eapol\n");
2089 memset(&ifr, 0, sizeof(ifr));
2090 os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
2091 if (ioctl(drv->ioctl_sock, SIOCGIFHWADDR, &ifr) != 0) {
2092 perror("ioctl(SIOCGIFHWADDR)");
2096 if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
2097 printf("Invalid HW-addr family 0x%04x\n",
2098 ifr.ifr_hwaddr.sa_family);
2101 memcpy(drv->hapd->own_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
2106 nl80211_remove_iface(drv, drv->monitor_ifidx);
2111 static int i802_get_inact_sec(void *priv, const u8 *addr)
2113 struct hostap_sta_driver_data data;
2116 data.inactive_msec = (unsigned long) -1;
2117 ret = i802_read_sta_data(priv, &data, addr);
2118 if (ret || data.inactive_msec == (unsigned long) -1)
2120 return data.inactive_msec / 1000;
2124 static int i802_sta_clear_stats(void *priv, const u8 *addr)
2134 hostapd_wireless_event_wireless_custom(struct i802_driver_data *drv,
2137 wpa_printf(MSG_DEBUG, "Custom wireless event: '%s'", custom);
2139 if (strncmp(custom, "MLME-MICHAELMICFAILURE.indication", 33) == 0) {
2142 pos = strstr(custom, "addr=");
2144 wpa_printf(MSG_DEBUG,
2145 "MLME-MICHAELMICFAILURE.indication "
2146 "without sender address ignored");
2150 if (hwaddr_aton(pos, addr) == 0) {
2151 ieee80211_michael_mic_failure(drv->hapd, addr, 1);
2153 wpa_printf(MSG_DEBUG,
2154 "MLME-MICHAELMICFAILURE.indication "
2155 "with invalid MAC address");
2161 static void hostapd_wireless_event_wireless(struct i802_driver_data *drv,
2162 char *data, int len)
2164 struct iw_event iwe_buf, *iwe = &iwe_buf;
2165 char *pos, *end, *custom, *buf;
2170 while (pos + IW_EV_LCP_LEN <= end) {
2171 /* Event data may be unaligned, so make a local, aligned copy
2172 * before processing. */
2173 memcpy(&iwe_buf, pos, IW_EV_LCP_LEN);
2174 wpa_printf(MSG_DEBUG, "Wireless event: cmd=0x%x len=%d",
2175 iwe->cmd, iwe->len);
2176 if (iwe->len <= IW_EV_LCP_LEN)
2179 custom = pos + IW_EV_POINT_LEN;
2180 if (drv->we_version > 18 &&
2181 (iwe->cmd == IWEVMICHAELMICFAILURE ||
2182 iwe->cmd == IWEVCUSTOM)) {
2183 /* WE-19 removed the pointer from struct iw_point */
2184 char *dpos = (char *) &iwe_buf.u.data.length;
2185 int dlen = dpos - (char *) &iwe_buf;
2186 memcpy(dpos, pos + IW_EV_LCP_LEN,
2187 sizeof(struct iw_event) - dlen);
2189 memcpy(&iwe_buf, pos, sizeof(struct iw_event));
2190 custom += IW_EV_POINT_OFF;
2195 if (custom + iwe->u.data.length > end)
2197 buf = malloc(iwe->u.data.length + 1);
2200 memcpy(buf, custom, iwe->u.data.length);
2201 buf[iwe->u.data.length] = '\0';
2202 hostapd_wireless_event_wireless_custom(drv, buf);
2212 static void hostapd_wireless_event_rtm_newlink(struct i802_driver_data *drv,
2213 struct nlmsghdr *h, int len)
2215 struct ifinfomsg *ifi;
2216 int attrlen, nlmsg_len, rta_len;
2217 struct rtattr *attr;
2219 if (len < (int) sizeof(*ifi))
2222 ifi = NLMSG_DATA(h);
2224 /* TODO: use ifi->ifi_index to filter out wireless events from other
2227 nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
2229 attrlen = h->nlmsg_len - nlmsg_len;
2233 attr = (struct rtattr *) (((char *) ifi) + nlmsg_len);
2235 rta_len = RTA_ALIGN(sizeof(struct rtattr));
2236 while (RTA_OK(attr, attrlen)) {
2237 if (attr->rta_type == IFLA_WIRELESS) {
2238 hostapd_wireless_event_wireless(
2239 drv, ((char *) attr) + rta_len,
2240 attr->rta_len - rta_len);
2242 attr = RTA_NEXT(attr, attrlen);
2247 static void hostapd_wireless_event_receive(int sock, void *eloop_ctx,
2252 struct sockaddr_nl from;
2255 struct i802_driver_data *drv = eloop_ctx;
2257 fromlen = sizeof(from);
2258 left = recvfrom(sock, buf, sizeof(buf), MSG_DONTWAIT,
2259 (struct sockaddr *) &from, &fromlen);
2261 if (errno != EINTR && errno != EAGAIN)
2262 perror("recvfrom(netlink)");
2266 h = (struct nlmsghdr *) buf;
2267 while (left >= (int) sizeof(*h)) {
2271 plen = len - sizeof(*h);
2272 if (len > left || plen < 0) {
2273 printf("Malformed netlink message: "
2274 "len=%d left=%d plen=%d\n",
2279 switch (h->nlmsg_type) {
2281 hostapd_wireless_event_rtm_newlink(drv, h, plen);
2285 len = NLMSG_ALIGN(len);
2287 h = (struct nlmsghdr *) ((char *) h + len);
2291 printf("%d extra bytes in the end of netlink message\n", left);
2296 static int hostap_get_we_version(struct i802_driver_data *drv)
2298 struct iw_range *range;
2303 drv->we_version = 0;
2306 * Use larger buffer than struct iw_range in order to allow the
2307 * structure to grow in the future.
2309 buflen = sizeof(struct iw_range) + 500;
2310 range = os_zalloc(buflen);
2314 memset(&iwr, 0, sizeof(iwr));
2315 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
2316 iwr.u.data.pointer = (caddr_t) range;
2317 iwr.u.data.length = buflen;
2319 minlen = ((char *) &range->enc_capa) - (char *) range +
2320 sizeof(range->enc_capa);
2322 if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) {
2323 perror("ioctl[SIOCGIWRANGE]");
2326 } else if (iwr.u.data.length >= minlen &&
2327 range->we_version_compiled >= 18) {
2328 wpa_printf(MSG_DEBUG, "SIOCGIWRANGE: WE(compiled)=%d "
2329 "WE(source)=%d enc_capa=0x%x",
2330 range->we_version_compiled,
2331 range->we_version_source,
2333 drv->we_version = range->we_version_compiled;
2341 static int i802_wireless_event_init(void *priv)
2343 struct i802_driver_data *drv = priv;
2345 struct sockaddr_nl local;
2347 hostap_get_we_version(drv);
2349 drv->wext_sock = -1;
2351 s = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
2353 perror("socket(PF_NETLINK,SOCK_RAW,NETLINK_ROUTE)");
2357 memset(&local, 0, sizeof(local));
2358 local.nl_family = AF_NETLINK;
2359 local.nl_groups = RTMGRP_LINK;
2360 if (bind(s, (struct sockaddr *) &local, sizeof(local)) < 0) {
2361 perror("bind(netlink)");
2366 eloop_register_read_sock(s, hostapd_wireless_event_receive, drv,
2374 static void i802_wireless_event_deinit(void *priv)
2376 struct i802_driver_data *drv = priv;
2377 if (drv->wext_sock < 0)
2379 eloop_unregister_read_sock(drv->wext_sock);
2380 close(drv->wext_sock);
2384 static int i802_sta_deauth(void *priv, const u8 *addr, int reason)
2386 struct i802_driver_data *drv = priv;
2387 struct ieee80211_mgmt mgmt;
2389 memset(&mgmt, 0, sizeof(mgmt));
2390 mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
2391 WLAN_FC_STYPE_DEAUTH);
2392 memcpy(mgmt.da, addr, ETH_ALEN);
2393 memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN);
2394 memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN);
2395 mgmt.u.deauth.reason_code = host_to_le16(reason);
2396 return i802_send_mgmt_frame(drv, &mgmt, IEEE80211_HDRLEN +
2397 sizeof(mgmt.u.deauth), 0);
2401 static int i802_sta_disassoc(void *priv, const u8 *addr, int reason)
2403 struct i802_driver_data *drv = priv;
2404 struct ieee80211_mgmt mgmt;
2406 memset(&mgmt, 0, sizeof(mgmt));
2407 mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
2408 WLAN_FC_STYPE_DISASSOC);
2409 memcpy(mgmt.da, addr, ETH_ALEN);
2410 memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN);
2411 memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN);
2412 mgmt.u.disassoc.reason_code = host_to_le16(reason);
2413 return i802_send_mgmt_frame(drv, &mgmt, IEEE80211_HDRLEN +
2414 sizeof(mgmt.u.disassoc), 0);
2418 static void *i802_init_bssid(struct hostapd_data *hapd, const u8 *bssid)
2420 struct i802_driver_data *drv;
2422 drv = os_zalloc(sizeof(struct i802_driver_data));
2424 printf("Could not allocate memory for i802 driver data\n");
2429 memcpy(drv->iface, hapd->conf->iface, sizeof(drv->iface));
2431 drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
2432 drv->if_indices = drv->default_if_indices;
2433 drv->bridge = if_nametoindex(hapd->conf->bridge);
2435 if (i802_init_sockets(drv, bssid))
2446 static void *i802_init(struct hostapd_data *hapd)
2448 return i802_init_bssid(hapd, NULL);
2452 static void i802_deinit(void *priv)
2454 struct i802_driver_data *drv = priv;
2456 if (drv->last_freq_ht) {
2457 /* Clear HT flags from the driver */
2458 struct hostapd_freq_params freq;
2459 os_memset(&freq, 0, sizeof(freq));
2460 freq.freq = drv->last_freq;
2461 i802_set_freq2(priv, &freq);
2464 i802_del_beacon(drv);
2466 /* remove monitor interface */
2467 nl80211_remove_iface(drv, drv->monitor_ifidx);
2469 (void) hostapd_set_iface_flags(drv, drv->iface, 0);
2471 if (drv->monitor_sock >= 0) {
2472 eloop_unregister_read_sock(drv->monitor_sock);
2473 close(drv->monitor_sock);
2475 if (drv->ioctl_sock >= 0)
2476 close(drv->ioctl_sock);
2477 if (drv->eapol_sock >= 0) {
2478 eloop_unregister_read_sock(drv->eapol_sock);
2479 close(drv->eapol_sock);
2482 genl_family_put(drv->nl80211);
2483 nl_cache_free(drv->nl_cache);
2484 nl_handle_destroy(drv->nl_handle);
2485 nl_cb_put(drv->nl_cb);
2487 if (drv->if_indices != drv->default_if_indices)
2488 free(drv->if_indices);
2494 const struct wpa_driver_ops wpa_driver_nl80211_ops = {
2497 .init_bssid = i802_init_bssid,
2498 .deinit = i802_deinit,
2499 .wireless_event_init = i802_wireless_event_init,
2500 .wireless_event_deinit = i802_wireless_event_deinit,
2501 .set_ieee8021x = i802_set_ieee8021x,
2502 .set_privacy = i802_set_privacy,
2503 .set_encryption = i802_set_encryption,
2504 .get_seqnum = i802_get_seqnum,
2505 .flush = i802_flush,
2506 .read_sta_data = i802_read_sta_data,
2507 .send_eapol = i802_send_eapol,
2508 .sta_set_flags = i802_sta_set_flags,
2509 .sta_deauth = i802_sta_deauth,
2510 .sta_disassoc = i802_sta_disassoc,
2511 .sta_remove = i802_sta_remove,
2512 .send_mgmt_frame = i802_send_mgmt_frame,
2513 .sta_add2 = i802_sta_add2,
2514 .get_inact_sec = i802_get_inact_sec,
2515 .sta_clear_stats = i802_sta_clear_stats,
2516 .set_freq2 = i802_set_freq2,
2517 .set_rts = i802_set_rts,
2518 .get_rts = i802_get_rts,
2519 .set_frag = i802_set_frag,
2520 .get_frag = i802_get_frag,
2521 .set_retry = i802_set_retry,
2522 .get_retry = i802_get_retry,
2523 .set_rate_sets = i802_set_rate_sets,
2524 .set_regulatory_domain = i802_set_regulatory_domain,
2525 .set_beacon = i802_set_beacon,
2526 .set_internal_bridge = i802_set_internal_bridge,
2527 .set_beacon_int = i802_set_beacon_int,
2528 .set_dtim_period = i802_set_dtim_period,
2529 .set_cts_protect = i802_set_cts_protect,
2530 .set_preamble = i802_set_preamble,
2531 .set_short_slot_time = i802_set_short_slot_time,
2532 .set_tx_queue_params = i802_set_tx_queue_params,
2533 .bss_add = i802_bss_add,
2534 .bss_remove = i802_bss_remove,
2535 .if_add = i802_if_add,
2536 .if_update = i802_if_update,
2537 .if_remove = i802_if_remove,
2538 .get_hw_feature_data = i802_get_hw_feature_data,
2539 .set_sta_vlan = i802_set_sta_vlan,
2540 .set_country = i802_set_country,