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"
43 enum ieee80211_msg_type {
44 ieee80211_msg_normal = 0,
45 ieee80211_msg_tx_callback_ack = 1,
46 ieee80211_msg_tx_callback_fail = 2,
49 struct i802_driver_data {
50 struct hostapd_data *hapd;
52 char iface[IFNAMSIZ + 1];
54 int ioctl_sock; /* socket for ioctl() use */
55 int wext_sock; /* socket for wireless events */
56 int eapol_sock; /* socket for EAPOL frames */
57 int monitor_sock; /* socket for monitor */
60 int default_if_indices[16];
65 struct nl_handle *nl_handle;
66 struct nl_cache *nl_cache;
68 struct genl_family *nl80211;
69 int dtim_period, beacon_int;
70 unsigned int beacon_set:1;
71 unsigned int ieee802_1x_active:1;
78 static void add_ifidx(struct i802_driver_data *drv, int ifidx)
83 for (i = 0; i < drv->num_if_indices; i++) {
84 if (drv->if_indices[i] == 0) {
85 drv->if_indices[i] = ifidx;
90 if (drv->if_indices != drv->default_if_indices)
91 old = drv->if_indices;
95 drv->if_indices = realloc(old,
96 sizeof(int) * (drv->num_if_indices + 1));
97 if (!drv->if_indices) {
99 drv->if_indices = drv->default_if_indices;
101 drv->if_indices = old;
102 wpa_printf(MSG_ERROR, "Failed to reallocate memory for "
104 wpa_printf(MSG_ERROR, "Ignoring EAPOL on interface %d", ifidx);
107 drv->if_indices[drv->num_if_indices] = ifidx;
108 drv->num_if_indices++;
112 static void del_ifidx(struct i802_driver_data *drv, int ifidx)
116 for (i = 0; i < drv->num_if_indices; i++) {
117 if (drv->if_indices[i] == ifidx) {
118 drv->if_indices[i] = 0;
125 static int have_ifidx(struct i802_driver_data *drv, int ifidx)
129 if (ifidx == drv->bridge)
132 for (i = 0; i < drv->num_if_indices; i++)
133 if (drv->if_indices[i] == ifidx)
141 static int ack_handler(struct nl_msg *msg, void *arg)
148 static int finish_handler(struct nl_msg *msg, void *arg)
155 static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
163 static int send_and_recv_msgs(struct i802_driver_data *drv,
165 int (*valid_handler)(struct nl_msg *, void *),
171 cb = nl_cb_clone(drv->nl_cb);
175 err = nl_send_auto_complete(drv->nl_handle, msg);
181 nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err);
182 nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
183 nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
186 nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
187 valid_handler, valid_data);
190 nl_recvmsgs(drv->nl_handle, cb);
197 static int hostapd_set_iface_flags(struct i802_driver_data *drv,
198 const char *ifname, int dev_up)
202 if (drv->ioctl_sock < 0)
205 memset(&ifr, 0, sizeof(ifr));
206 os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
208 if (ioctl(drv->ioctl_sock, SIOCGIFFLAGS, &ifr) != 0) {
209 perror("ioctl[SIOCGIFFLAGS]");
210 wpa_printf(MSG_DEBUG, "Could not read interface flags (%s)",
216 ifr.ifr_flags |= IFF_UP;
218 ifr.ifr_flags &= ~IFF_UP;
220 if (ioctl(drv->ioctl_sock, SIOCSIFFLAGS, &ifr) != 0) {
221 perror("ioctl[SIOCSIFFLAGS]");
229 static int nl_set_encr(int ifindex, struct i802_driver_data *drv,
230 const char *alg, const u8 *addr, int idx, const u8 *key,
231 size_t key_len, int txkey)
240 if (strcmp(alg, "none") == 0) {
241 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
242 0, NL80211_CMD_DEL_KEY, 0);
244 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
245 0, NL80211_CMD_NEW_KEY, 0);
246 NLA_PUT(msg, NL80211_ATTR_KEY_DATA, key_len, key);
247 if (strcmp(alg, "WEP") == 0) {
249 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
252 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
254 } else if (strcmp(alg, "TKIP") == 0)
255 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC02);
256 else if (strcmp(alg, "CCMP") == 0)
257 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC04);
258 else if (strcmp(alg, "IGTK") == 0)
259 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC06);
261 wpa_printf(MSG_ERROR, "%s: Unsupported encryption "
262 "algorithm '%s'", __func__, alg);
269 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
270 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
271 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
273 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
278 * If we failed or don't need to set the default TX key (below),
281 if (ret || !txkey || addr)
288 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
289 0, NL80211_CMD_SET_KEY, 0);
290 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
291 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
292 #ifdef NL80211_MFP_PENDING
293 if (strcmp(alg, "IGTK") == 0)
294 NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT_MGMT);
296 NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT);
297 #else /* NL80211_MFP_PENDING */
298 NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT);
299 #endif /* NL80211_MFP_PENDING */
301 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
310 static int i802_set_encryption(const char *iface, void *priv, const char *alg,
311 const u8 *addr, int idx, const u8 *key,
312 size_t key_len, int txkey)
314 struct i802_driver_data *drv = priv;
317 ret = nl_set_encr(if_nametoindex(iface), drv, alg, addr, idx, key,
322 if (strcmp(alg, "IGTK") == 0) {
323 ret = nl_set_encr(drv->monitor_ifidx, drv, alg, addr, idx, key,
331 static inline int min_int(int a, int b)
339 static int get_key_handler(struct nl_msg *msg, void *arg)
341 struct nlattr *tb[NL80211_ATTR_MAX + 1];
342 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
344 nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
345 genlmsg_attrlen(gnlh, 0), NULL);
348 * TODO: validate the key index and mac address!
349 * Otherwise, there's a race condition as soon as
350 * the kernel starts sending key notifications.
353 if (tb[NL80211_ATTR_KEY_SEQ])
354 memcpy(arg, nla_data(tb[NL80211_ATTR_KEY_SEQ]),
355 min_int(nla_len(tb[NL80211_ATTR_KEY_SEQ]), 6));
360 static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr,
363 struct i802_driver_data *drv = priv;
370 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
371 0, NL80211_CMD_GET_KEY, 0);
374 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
375 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
376 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
380 return send_and_recv_msgs(drv, msg, get_key_handler, seq);
386 static int i802_set_rate_sets(void *priv, int *supp_rates, int *basic_rates,
389 struct i802_driver_data *drv = priv;
391 u8 rates[NL80211_MAX_SUPP_RATES];
399 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
400 NL80211_CMD_SET_BSS, 0);
402 for (i = 0; i < NL80211_MAX_SUPP_RATES && basic_rates[i] >= 0; i++)
403 rates[rates_len++] = basic_rates[i] / 5;
405 NLA_PUT(msg, NL80211_ATTR_BSS_BASIC_RATES, rates_len, rates);
407 /* TODO: multi-BSS support */
408 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
410 return send_and_recv_msgs(drv, msg, NULL, NULL);
416 static int i802_send_frame(void *priv, const void *data, size_t len,
417 int encrypt, int flags)
420 0x00, 0x00, /* radiotap version */
421 0x0e, 0x00, /* radiotap length */
422 0x02, 0xc0, 0x00, 0x00, /* bmap: flags, tx and rx flags */
423 IEEE80211_RADIOTAP_F_FRAG, /* F_FRAG (fragment if required) */
425 0x00, 0x00, /* RX and TX flags to indicate that */
426 0x00, 0x00, /* this is the injected frame directly */
428 struct i802_driver_data *drv = priv;
429 struct iovec iov[2] = {
431 .iov_base = &rtap_hdr,
432 .iov_len = sizeof(rtap_hdr),
435 .iov_base = (void*)data,
439 struct msghdr msg = {
450 rtap_hdr[8] |= IEEE80211_RADIOTAP_F_WEP;
452 return sendmsg(drv->monitor_sock, &msg, flags);
455 static int i802_send_mgmt_frame(void *priv, const void *data, size_t len,
458 struct ieee80211_mgmt *mgmt;
459 int do_not_encrypt = 0;
462 mgmt = (struct ieee80211_mgmt *) data;
463 fc = le_to_host16(mgmt->frame_control);
465 if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
466 WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_AUTH) {
468 * Only one of the authentication frame types is encrypted.
469 * In order for static WEP encryption to work properly (i.e.,
470 * to not encrypt the frame), we need to tell mac80211 about
471 * the frames that must not be encrypted.
473 u16 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
474 u16 auth_trans = le_to_host16(mgmt->u.auth.auth_transaction);
475 if (auth_alg == WLAN_AUTH_OPEN ||
476 (auth_alg == WLAN_AUTH_SHARED_KEY && auth_trans != 3))
480 return i802_send_frame(priv, data, len, !do_not_encrypt, flags);
483 /* Set kernel driver on given frequency (MHz) */
484 static int i802_set_freq2(void *priv, struct hostapd_freq_params *freq)
486 struct i802_driver_data *drv = priv;
493 drv->last_freq = freq->freq;
494 drv->last_freq_ht = freq->ht_enabled;
496 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
497 NL80211_CMD_SET_WIPHY, 0);
499 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
500 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq->freq);
501 if (freq->ht_enabled) {
502 switch (freq->sec_channel_offset) {
504 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_SEC_CHAN_OFFSET,
505 NL80211_SEC_CHAN_BELOW);
508 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_SEC_CHAN_OFFSET,
509 NL80211_SEC_CHAN_ABOVE);
512 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_SEC_CHAN_OFFSET,
513 NL80211_SEC_CHAN_DISABLED);
518 if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
525 static int i802_set_rts(void *priv, int rts)
527 struct i802_driver_data *drv = priv;
530 memset(&iwr, 0, sizeof(iwr));
531 os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
532 iwr.u.rts.value = rts;
535 if (ioctl(drv->ioctl_sock, SIOCSIWRTS, &iwr) < 0) {
536 perror("ioctl[SIOCSIWRTS]");
544 static int i802_get_rts(void *priv, int *rts)
546 struct i802_driver_data *drv = priv;
549 memset(&iwr, 0, sizeof(iwr));
550 os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
552 if (ioctl(drv->ioctl_sock, SIOCGIWRTS, &iwr) < 0) {
553 perror("ioctl[SIOCGIWRTS]");
557 *rts = iwr.u.rts.value;
563 static int i802_set_frag(void *priv, int frag)
565 struct i802_driver_data *drv = priv;
568 memset(&iwr, 0, sizeof(iwr));
569 os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
570 iwr.u.frag.value = frag;
571 iwr.u.frag.fixed = 1;
573 if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
574 perror("ioctl[SIOCSIWFRAG]");
582 static int i802_get_frag(void *priv, int *frag)
584 struct i802_driver_data *drv = priv;
587 memset(&iwr, 0, sizeof(iwr));
588 os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
590 if (ioctl(drv->ioctl_sock, SIOCGIWFRAG, &iwr) < 0) {
591 perror("ioctl[SIOCGIWFRAG]");
595 *frag = iwr.u.frag.value;
601 static int i802_set_retry(void *priv, int short_retry, int long_retry)
603 struct i802_driver_data *drv = priv;
606 memset(&iwr, 0, sizeof(iwr));
607 os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
609 iwr.u.retry.value = short_retry;
610 iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
611 if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
612 perror("ioctl[SIOCSIWRETRY(short)]");
616 iwr.u.retry.value = long_retry;
617 iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
618 if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
619 perror("ioctl[SIOCSIWRETRY(long)]");
627 static int i802_get_retry(void *priv, int *short_retry, int *long_retry)
629 struct i802_driver_data *drv = priv;
632 memset(&iwr, 0, sizeof(iwr));
633 os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
635 iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
636 if (ioctl(drv->ioctl_sock, SIOCGIWRETRY, &iwr) < 0) {
637 perror("ioctl[SIOCGIWFRAG(short)]");
640 *short_retry = iwr.u.retry.value;
642 iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
643 if (ioctl(drv->ioctl_sock, SIOCGIWRETRY, &iwr) < 0) {
644 perror("ioctl[SIOCGIWFRAG(long)]");
647 *long_retry = iwr.u.retry.value;
653 static int i802_flush(void *priv)
655 struct i802_driver_data *drv = priv;
662 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
663 0, NL80211_CMD_DEL_STATION, 0);
666 * XXX: FIX! this needs to flush all VLANs too
668 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
669 if_nametoindex(drv->iface));
671 return send_and_recv_msgs(drv, msg, NULL, NULL);
677 static int get_sta_handler(struct nl_msg *msg, void *arg)
679 struct nlattr *tb[NL80211_ATTR_MAX + 1];
680 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
681 struct hostap_sta_driver_data *data = arg;
682 struct nlattr *stats[NL80211_STA_INFO_MAX + 1];
683 static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
684 [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
685 [NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 },
686 [NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 },
689 nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
690 genlmsg_attrlen(gnlh, 0), NULL);
693 * TODO: validate the interface and mac address!
694 * Otherwise, there's a race condition as soon as
695 * the kernel starts sending station notifications.
698 if (!tb[NL80211_ATTR_STA_INFO]) {
699 wpa_printf(MSG_DEBUG, "sta stats missing!");
702 if (nla_parse_nested(stats, NL80211_STA_INFO_MAX,
703 tb[NL80211_ATTR_STA_INFO],
705 wpa_printf(MSG_DEBUG, "failed to parse nested attributes!");
709 if (stats[NL80211_STA_INFO_INACTIVE_TIME])
710 data->inactive_msec =
711 nla_get_u32(stats[NL80211_STA_INFO_INACTIVE_TIME]);
712 if (stats[NL80211_STA_INFO_RX_BYTES])
713 data->rx_bytes = nla_get_u32(stats[NL80211_STA_INFO_RX_BYTES]);
714 if (stats[NL80211_STA_INFO_TX_BYTES])
715 data->rx_bytes = nla_get_u32(stats[NL80211_STA_INFO_TX_BYTES]);
720 static int i802_read_sta_data(void *priv, struct hostap_sta_driver_data *data,
723 struct i802_driver_data *drv = priv;
730 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
731 0, NL80211_CMD_GET_STATION, 0);
733 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
734 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
736 return send_and_recv_msgs(drv, msg, get_sta_handler, data);
742 static int i802_send_eapol(void *priv, const u8 *addr, const u8 *data,
743 size_t data_len, int encrypt, const u8 *own_addr)
745 struct i802_driver_data *drv = priv;
746 struct ieee80211_hdr *hdr;
751 int qos = sta->flags & WLAN_STA_WME;
756 len = sizeof(*hdr) + (qos ? 2 : 0) + sizeof(rfc1042_header) + 2 +
758 hdr = os_zalloc(len);
760 printf("malloc() failed for i802_send_data(len=%lu)\n",
761 (unsigned long) len);
766 IEEE80211_FC(WLAN_FC_TYPE_DATA, WLAN_FC_STYPE_DATA);
767 hdr->frame_control |= host_to_le16(WLAN_FC_FROMDS);
769 hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
770 #if 0 /* To be enabled if qos determination is added above */
772 hdr->frame_control |=
773 host_to_le16(WLAN_FC_STYPE_QOS_DATA << 4);
777 memcpy(hdr->IEEE80211_DA_FROMDS, addr, ETH_ALEN);
778 memcpy(hdr->IEEE80211_BSSID_FROMDS, own_addr, ETH_ALEN);
779 memcpy(hdr->IEEE80211_SA_FROMDS, own_addr, ETH_ALEN);
780 pos = (u8 *) (hdr + 1);
782 #if 0 /* To be enabled if qos determination is added above */
784 /* add an empty QoS header if needed */
791 memcpy(pos, rfc1042_header, sizeof(rfc1042_header));
792 pos += sizeof(rfc1042_header);
793 WPA_PUT_BE16(pos, ETH_P_PAE);
795 memcpy(pos, data, data_len);
797 res = i802_send_frame(drv, (u8 *) hdr, len, encrypt, 0);
801 perror("i802_send_eapol: send");
802 printf("i802_send_eapol - packet len: %lu - failed\n",
803 (unsigned long) len);
810 static int i802_sta_add2(const char *ifname, void *priv,
811 struct hostapd_sta_add_params *params)
813 struct i802_driver_data *drv = priv;
821 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
822 0, NL80211_CMD_NEW_STATION, 0);
824 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
825 if_nametoindex(drv->iface));
826 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, params->addr);
827 NLA_PUT_U16(msg, NL80211_ATTR_STA_AID, params->aid);
828 NLA_PUT(msg, NL80211_ATTR_STA_SUPPORTED_RATES, params->supp_rates_len,
830 NLA_PUT_U16(msg, NL80211_ATTR_STA_LISTEN_INTERVAL,
831 params->listen_interval);
833 #ifdef CONFIG_IEEE80211N
834 if (params->ht_capabilities) {
835 NLA_PUT(msg, NL80211_ATTR_HT_CAPABILITY,
836 params->ht_capabilities->length,
837 ¶ms->ht_capabilities->data);
839 #endif /* CONFIG_IEEE80211N */
841 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
849 static int i802_sta_remove(void *priv, const u8 *addr)
851 struct i802_driver_data *drv = priv;
859 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
860 0, NL80211_CMD_DEL_STATION, 0);
862 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
863 if_nametoindex(drv->iface));
864 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
866 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
875 static int i802_sta_set_flags(void *priv, const u8 *addr,
876 int total_flags, int flags_or, int flags_and)
878 struct i802_driver_data *drv = priv;
879 struct nl_msg *msg, *flags = NULL;
885 flags = nlmsg_alloc();
891 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
892 0, NL80211_CMD_SET_STATION, 0);
894 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
895 if_nametoindex(drv->iface));
896 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
898 if (total_flags & WLAN_STA_AUTHORIZED || !drv->ieee802_1x_active)
899 NLA_PUT_FLAG(flags, NL80211_STA_FLAG_AUTHORIZED);
901 if (total_flags & WLAN_STA_WME)
902 NLA_PUT_FLAG(flags, NL80211_STA_FLAG_WME);
904 if (total_flags & WLAN_STA_SHORT_PREAMBLE)
905 NLA_PUT_FLAG(flags, NL80211_STA_FLAG_SHORT_PREAMBLE);
907 #ifdef NL80211_MFP_PENDING
908 if (total_flags & WLAN_STA_MFP)
909 NLA_PUT_FLAG(flags, NL80211_STA_FLAG_MFP);
910 #endif /* NL80211_MFP_PENDING */
912 if (nla_put_nested(msg, NL80211_ATTR_STA_FLAGS, flags))
913 goto nla_put_failure;
917 return send_and_recv_msgs(drv, msg, NULL, NULL);
924 static int i802_set_regulatory_domain(void *priv, unsigned int rd)
930 static int i802_set_tx_queue_params(void *priv, int queue, int aifs,
931 int cw_min, int cw_max, int burst_time)
933 struct i802_driver_data *drv = priv;
935 struct nlattr *txq, *params;
941 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
942 0, NL80211_CMD_SET_WIPHY, 0);
944 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
946 txq = nla_nest_start(msg, NL80211_ATTR_WIPHY_TXQ_PARAMS);
948 goto nla_put_failure;
950 /* We are only sending parameters for a single TXQ at a time */
951 params = nla_nest_start(msg, 1);
953 goto nla_put_failure;
955 NLA_PUT_U8(msg, NL80211_TXQ_ATTR_QUEUE, queue);
956 /* Burst time is configured in units of 0.1 msec and TXOP parameter in
957 * 32 usec, so need to convert the value here. */
958 NLA_PUT_U16(msg, NL80211_TXQ_ATTR_TXOP, (burst_time * 100 + 16) / 32);
959 NLA_PUT_U16(msg, NL80211_TXQ_ATTR_CWMIN, cw_min);
960 NLA_PUT_U16(msg, NL80211_TXQ_ATTR_CWMAX, cw_max);
961 NLA_PUT_U8(msg, NL80211_TXQ_ATTR_AIFS, aifs);
963 nla_nest_end(msg, params);
965 nla_nest_end(msg, txq);
967 if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
974 static void nl80211_remove_iface(struct i802_driver_data *drv, int ifidx)
978 /* stop listening for EAPOL on this interface */
979 del_ifidx(drv, ifidx);
983 goto nla_put_failure;
985 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
986 0, NL80211_CMD_DEL_INTERFACE, 0);
987 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifidx);
989 if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
992 printf("Failed to remove interface.\n");
996 static int nl80211_create_iface(struct i802_driver_data *drv,
998 enum nl80211_iftype iftype,
1001 struct nl_msg *msg, *flags = NULL;
1007 msg = nlmsg_alloc();
1011 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1012 0, NL80211_CMD_NEW_INTERFACE, 0);
1013 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
1014 if_nametoindex(drv->hapd->conf->iface));
1015 NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, ifname);
1016 NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, iftype);
1018 if (iftype == NL80211_IFTYPE_MONITOR) {
1021 flags = nlmsg_alloc();
1023 goto nla_put_failure;
1025 NLA_PUT_FLAG(flags, NL80211_MNTR_FLAG_COOK_FRAMES);
1027 err = nla_put_nested(msg, NL80211_ATTR_MNTR_FLAGS, flags);
1032 goto nla_put_failure;
1035 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
1038 printf("Failed to create interface %s.\n", ifname);
1042 ifidx = if_nametoindex(ifname);
1047 /* start listening for EAPOL on this interface */
1048 add_ifidx(drv, ifidx);
1052 case NL80211_IFTYPE_AP:
1053 os_strlcpy(ifreq.ifr_name, ifname, IFNAMSIZ);
1054 memcpy(ifreq.ifr_hwaddr.sa_data, addr, ETH_ALEN);
1055 ifreq.ifr_hwaddr.sa_family = ARPHRD_ETHER;
1057 if (ioctl(drv->ioctl_sock, SIOCSIFHWADDR, &ifreq)) {
1058 nl80211_remove_iface(drv, ifidx);
1062 case NL80211_IFTYPE_WDS:
1063 memset(&iwr, 0, sizeof(iwr));
1064 os_strlcpy(iwr.ifr_name, ifname, IFNAMSIZ);
1065 iwr.u.addr.sa_family = ARPHRD_ETHER;
1066 memcpy(iwr.u.addr.sa_data, addr, ETH_ALEN);
1067 if (ioctl(drv->ioctl_sock, SIOCSIWAP, &iwr))
1080 static int i802_bss_add(void *priv, const char *ifname, const u8 *bssid)
1085 * The kernel supports that when the low-level driver does,
1086 * but we currently don't because we need per-BSS data that
1087 * currently we can't handle easily.
1091 ifidx = nl80211_create_iface(priv, ifname, NL80211_IFTYPE_AP, bssid);
1094 if (hostapd_set_iface_flags(priv, ifname, 1)) {
1095 nl80211_remove_iface(priv, ifidx);
1102 static int i802_bss_remove(void *priv, const char *ifname)
1104 nl80211_remove_iface(priv, if_nametoindex(ifname));
1109 static int i802_set_beacon(const char *iface, void *priv,
1110 u8 *head, size_t head_len,
1111 u8 *tail, size_t tail_len)
1113 struct i802_driver_data *drv = priv;
1115 u8 cmd = NL80211_CMD_NEW_BEACON;
1118 msg = nlmsg_alloc();
1122 if (drv->beacon_set)
1123 cmd = NL80211_CMD_SET_BEACON;
1125 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1127 NLA_PUT(msg, NL80211_ATTR_BEACON_HEAD, head_len, head);
1128 NLA_PUT(msg, NL80211_ATTR_BEACON_TAIL, tail_len, tail);
1129 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
1130 NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, drv->beacon_int);
1132 if (!drv->dtim_period)
1133 drv->dtim_period = 2;
1134 NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
1136 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
1138 drv->beacon_set = 1;
1145 static int i802_del_beacon(struct i802_driver_data *drv)
1149 msg = nlmsg_alloc();
1153 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1154 0, NL80211_CMD_DEL_BEACON, 0);
1155 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1157 return send_and_recv_msgs(drv, msg, NULL, NULL);
1163 static int i802_set_ieee8021x(const char *ifname, void *priv, int enabled)
1165 struct i802_driver_data *drv = priv;
1168 * FIXME: This needs to be per interface (BSS)
1170 drv->ieee802_1x_active = enabled;
1175 static int i802_set_privacy(const char *ifname, void *priv, int enabled)
1177 struct i802_driver_data *drv = priv;
1180 memset(&iwr, 0, sizeof(iwr));
1182 os_strlcpy(iwr.ifr_name, ifname, IFNAMSIZ);
1183 iwr.u.param.flags = IW_AUTH_PRIVACY_INVOKED;
1184 iwr.u.param.value = enabled;
1186 ioctl(drv->ioctl_sock, SIOCSIWAUTH, &iwr);
1188 /* ignore errors, the kernel/driver might not care */
1193 static int i802_set_internal_bridge(void *priv, int value)
1199 static int i802_set_beacon_int(void *priv, int value)
1201 struct i802_driver_data *drv = priv;
1204 drv->beacon_int = value;
1206 if (!drv->beacon_set)
1209 msg = nlmsg_alloc();
1213 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1214 0, NL80211_CMD_SET_BEACON, 0);
1215 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1217 NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, value);
1219 return send_and_recv_msgs(drv, msg, NULL, NULL);
1225 static int i802_set_dtim_period(const char *iface, void *priv, int value)
1227 struct i802_driver_data *drv = priv;
1230 msg = nlmsg_alloc();
1234 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1235 0, NL80211_CMD_SET_BEACON, 0);
1236 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
1238 drv->dtim_period = value;
1239 NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
1241 return send_and_recv_msgs(drv, msg, NULL, NULL);
1247 static int i802_set_bss(void *priv, int cts, int preamble, int slot)
1249 struct i802_driver_data *drv = priv;
1252 msg = nlmsg_alloc();
1256 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
1257 NL80211_CMD_SET_BSS, 0);
1260 NLA_PUT_U8(msg, NL80211_ATTR_BSS_CTS_PROT, cts);
1262 NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_PREAMBLE, preamble);
1264 NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_SLOT_TIME, slot);
1266 /* TODO: multi-BSS support */
1267 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1269 return send_and_recv_msgs(drv, msg, NULL, NULL);
1275 static int i802_set_cts_protect(void *priv, int value)
1277 return i802_set_bss(priv, value, -1, -1);
1281 static int i802_set_preamble(void *priv, int value)
1283 return i802_set_bss(priv, -1, value, -1);
1287 static int i802_set_short_slot_time(void *priv, int value)
1289 return i802_set_bss(priv, -1, -1, value);
1293 static enum nl80211_iftype i802_if_type(enum hostapd_driver_if_type type)
1296 case HOSTAPD_IF_VLAN:
1297 return NL80211_IFTYPE_AP_VLAN;
1298 case HOSTAPD_IF_WDS:
1299 return NL80211_IFTYPE_WDS;
1305 static int i802_if_add(const char *iface, void *priv,
1306 enum hostapd_driver_if_type type, char *ifname,
1309 if (nl80211_create_iface(priv, ifname, i802_if_type(type), addr) < 0)
1315 static int i802_if_update(void *priv, enum hostapd_driver_if_type type,
1316 char *ifname, const u8 *addr)
1318 /* unused at the moment */
1323 static int i802_if_remove(void *priv, enum hostapd_driver_if_type type,
1324 const char *ifname, const u8 *addr)
1326 nl80211_remove_iface(priv, if_nametoindex(ifname));
1331 struct phy_info_arg {
1333 struct hostapd_hw_modes *modes;
1336 static int phy_info_handler(struct nl_msg *msg, void *arg)
1338 struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
1339 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
1340 struct phy_info_arg *phy_info = arg;
1342 struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1];
1344 struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1];
1345 static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
1346 [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
1347 [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
1348 [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
1349 [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
1350 [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
1351 [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
1354 struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1];
1355 static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = {
1356 [NL80211_BITRATE_ATTR_RATE] = { .type = NLA_U32 },
1357 [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE] = { .type = NLA_FLAG },
1360 struct nlattr *nl_band;
1361 struct nlattr *nl_freq;
1362 struct nlattr *nl_rate;
1363 int rem_band, rem_freq, rem_rate;
1364 struct hostapd_hw_modes *mode;
1365 int idx, mode_is_set;
1367 nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
1368 genlmsg_attrlen(gnlh, 0), NULL);
1370 if (!tb_msg[NL80211_ATTR_WIPHY_BANDS])
1373 nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) {
1374 mode = realloc(phy_info->modes, (*phy_info->num_modes + 1) * sizeof(*mode));
1377 phy_info->modes = mode;
1381 mode = &phy_info->modes[*(phy_info->num_modes)];
1382 memset(mode, 0, sizeof(*mode));
1383 *(phy_info->num_modes) += 1;
1385 nla_parse(tb_band, NL80211_BAND_ATTR_MAX, nla_data(nl_band),
1386 nla_len(nl_band), NULL);
1388 nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) {
1389 nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq),
1390 nla_len(nl_freq), freq_policy);
1391 if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
1393 mode->num_channels++;
1396 mode->channels = calloc(mode->num_channels, sizeof(struct hostapd_channel_data));
1397 if (!mode->channels)
1402 nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) {
1403 nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq),
1404 nla_len(nl_freq), freq_policy);
1405 if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
1408 mode->channels[idx].freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]);
1409 mode->channels[idx].flag = 0;
1412 /* crude heuristic */
1413 if (mode->channels[idx].freq < 4000)
1414 mode->mode = HOSTAPD_MODE_IEEE80211B;
1416 mode->mode = HOSTAPD_MODE_IEEE80211A;
1420 /* crude heuristic */
1421 if (mode->channels[idx].freq < 4000)
1422 if (mode->channels[idx].freq == 2848)
1423 mode->channels[idx].chan = 14;
1425 mode->channels[idx].chan = (mode->channels[idx].freq - 2407) / 5;
1427 mode->channels[idx].chan = mode->channels[idx].freq/5 - 1000;
1429 if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
1430 mode->channels[idx].flag |=
1431 HOSTAPD_CHAN_DISABLED;
1432 if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN])
1433 mode->channels[idx].flag |=
1434 HOSTAPD_CHAN_PASSIVE_SCAN;
1435 if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IBSS])
1436 mode->channels[idx].flag |=
1437 HOSTAPD_CHAN_NO_IBSS;
1438 if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR])
1439 mode->channels[idx].flag |=
1442 if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] &&
1443 !tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
1444 mode->channels[idx].max_tx_power =
1445 nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]) / 100;
1450 nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
1451 nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate),
1452 nla_len(nl_rate), rate_policy);
1453 if (!tb_rate[NL80211_BITRATE_ATTR_RATE])
1458 mode->rates = calloc(mode->num_rates, sizeof(struct hostapd_rate_data));
1464 nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
1465 nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate),
1466 nla_len(nl_rate), rate_policy);
1467 if (!tb_rate[NL80211_BITRATE_ATTR_RATE])
1469 mode->rates[idx].rate = nla_get_u32(tb_rate[NL80211_BITRATE_ATTR_RATE]);
1471 /* crude heuristic */
1472 if (mode->mode == HOSTAPD_MODE_IEEE80211B &&
1473 mode->rates[idx].rate > 200)
1474 mode->mode = HOSTAPD_MODE_IEEE80211G;
1476 if (tb_rate[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE])
1477 mode->rates[idx].flags |= HOSTAPD_RATE_PREAMBLE2;
1486 static struct hostapd_hw_modes *i802_add_11b(struct hostapd_hw_modes *modes,
1490 struct hostapd_hw_modes *mode11g = NULL, *nmodes, *mode;
1491 int i, mode11g_idx = -1;
1493 /* If only 802.11g mode is included, use it to construct matching
1494 * 802.11b mode data. */
1496 for (m = 0; m < *num_modes; m++) {
1497 if (modes[m].mode == HOSTAPD_MODE_IEEE80211B)
1498 return modes; /* 802.11b already included */
1499 if (modes[m].mode == HOSTAPD_MODE_IEEE80211G)
1503 if (mode11g_idx < 0)
1504 return modes; /* 2.4 GHz band not supported at all */
1506 nmodes = os_realloc(modes, (*num_modes + 1) * sizeof(*nmodes));
1508 return modes; /* Could not add 802.11b mode */
1510 mode = &nmodes[*num_modes];
1511 os_memset(mode, 0, sizeof(*mode));
1515 mode->mode = HOSTAPD_MODE_IEEE80211B;
1517 mode11g = &modes[mode11g_idx];
1518 mode->num_channels = mode11g->num_channels;
1519 mode->channels = os_malloc(mode11g->num_channels *
1520 sizeof(struct hostapd_channel_data));
1521 if (mode->channels == NULL) {
1523 return modes; /* Could not add 802.11b mode */
1525 os_memcpy(mode->channels, mode11g->channels,
1526 mode11g->num_channels * sizeof(struct hostapd_channel_data));
1528 mode->num_rates = 0;
1529 mode->rates = os_malloc(4 * sizeof(struct hostapd_rate_data));
1530 if (mode->rates == NULL) {
1531 os_free(mode->channels);
1533 return modes; /* Could not add 802.11b mode */
1536 for (i = 0; i < mode11g->num_rates; i++) {
1537 if (mode11g->rates[i].rate > 110 ||
1538 mode11g->rates[i].flags &
1539 (HOSTAPD_RATE_ERP | HOSTAPD_RATE_OFDM))
1541 mode->rates[mode->num_rates] = mode11g->rates[i];
1543 if (mode->num_rates == 4)
1547 if (mode->num_rates == 0) {
1548 os_free(mode->channels);
1549 os_free(mode->rates);
1551 return modes; /* No 802.11b rates */
1554 wpa_printf(MSG_DEBUG, "nl80211: Added 802.11b mode based on 802.11g "
1560 static struct hostapd_hw_modes *i802_get_hw_feature_data(void *priv,
1564 struct i802_driver_data *drv = priv;
1566 struct phy_info_arg result = {
1567 .num_modes = num_modes,
1574 msg = nlmsg_alloc();
1578 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1579 0, NL80211_CMD_GET_WIPHY, 0);
1581 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1583 if (send_and_recv_msgs(drv, msg, phy_info_handler, &result) == 0)
1584 return i802_add_11b(result.modes, num_modes);
1590 static int i802_set_sta_vlan(void *priv, const u8 *addr,
1591 const char *ifname, int vlan_id)
1593 struct i802_driver_data *drv = priv;
1596 msg = nlmsg_alloc();
1600 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1601 0, NL80211_CMD_SET_STATION, 0);
1603 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
1604 if_nametoindex(drv->iface));
1605 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
1606 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
1607 if_nametoindex(ifname));
1609 return send_and_recv_msgs(drv, msg, NULL, NULL);
1615 static int i802_set_country(void *priv, const char *country)
1617 struct i802_driver_data *drv = priv;
1621 msg = nlmsg_alloc();
1625 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1626 0, NL80211_CMD_REQ_SET_REG, 0);
1628 alpha2[0] = country[0];
1629 alpha2[1] = country[1];
1631 NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2, alpha2);
1633 return send_and_recv_msgs(drv, msg, NULL, NULL);
1639 static void handle_unknown_sta(struct hostapd_data *hapd, u8 *ta)
1641 struct sta_info *sta;
1643 sta = ap_get_sta(hapd, ta);
1644 if (!sta || !(sta->flags & WLAN_STA_ASSOC)) {
1645 printf("Data/PS-poll frame from not associated STA "
1646 MACSTR "\n", MAC2STR(ta));
1647 if (sta && (sta->flags & WLAN_STA_AUTH))
1648 hostapd_sta_disassoc(
1650 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
1654 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
1659 static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
1662 struct ieee80211_hdr *hdr;
1663 u16 fc, type, stype;
1664 struct sta_info *sta;
1666 hdr = (struct ieee80211_hdr *) buf;
1667 fc = le_to_host16(hdr->frame_control);
1669 type = WLAN_FC_GET_TYPE(fc);
1670 stype = WLAN_FC_GET_STYPE(fc);
1673 case WLAN_FC_TYPE_MGMT:
1674 wpa_printf(MSG_DEBUG, "MGMT (TX callback) %s",
1675 ok ? "ACK" : "fail");
1676 ieee802_11_mgmt_cb(hapd, buf, len, stype, ok);
1678 case WLAN_FC_TYPE_CTRL:
1679 wpa_printf(MSG_DEBUG, "CTRL (TX callback) %s",
1680 ok ? "ACK" : "fail");
1682 case WLAN_FC_TYPE_DATA:
1683 wpa_printf(MSG_DEBUG, "DATA (TX callback) %s",
1684 ok ? "ACK" : "fail");
1685 sta = ap_get_sta(hapd, hdr->addr1);
1686 if (sta && sta->flags & WLAN_STA_PENDING_POLL) {
1687 wpa_printf(MSG_DEBUG, "STA " MACSTR " %s pending "
1688 "activity poll", MAC2STR(sta->addr),
1689 ok ? "ACKed" : "did not ACK");
1691 sta->flags &= ~WLAN_STA_PENDING_POLL;
1694 ieee802_1x_tx_status(hapd, sta, buf, len, ok);
1697 printf("unknown TX callback frame type %d\n", type);
1703 static void handle_frame(struct hostapd_iface *iface, u8 *buf, size_t len,
1704 struct hostapd_frame_info *hfi,
1705 enum ieee80211_msg_type msg_type)
1707 struct ieee80211_hdr *hdr;
1708 u16 fc, type, stype;
1709 size_t data_len = len;
1710 struct hostapd_data *hapd = NULL;
1711 int broadcast_bssid = 0;
1716 * PS-Poll frames are 16 bytes. All other frames are
1717 * 24 bytes or longer.
1722 hdr = (struct ieee80211_hdr *) buf;
1723 fc = le_to_host16(hdr->frame_control);
1725 type = WLAN_FC_GET_TYPE(fc);
1726 stype = WLAN_FC_GET_STYPE(fc);
1729 case WLAN_FC_TYPE_DATA:
1732 switch (fc & (WLAN_FC_FROMDS | WLAN_FC_TODS)) {
1741 case WLAN_FC_TYPE_CTRL:
1742 /* discard non-ps-poll frames */
1743 if (stype != WLAN_FC_STYPE_PSPOLL)
1747 case WLAN_FC_TYPE_MGMT:
1755 /* find interface frame belongs to */
1756 for (i = 0; i < iface->num_bss; i++) {
1757 if (memcmp(bssid, iface->bss[i]->own_addr, ETH_ALEN) == 0) {
1758 hapd = iface->bss[i];
1764 hapd = iface->bss[0];
1766 if (bssid[0] != 0xff || bssid[1] != 0xff ||
1767 bssid[2] != 0xff || bssid[3] != 0xff ||
1768 bssid[4] != 0xff || bssid[5] != 0xff) {
1770 * Unknown BSSID - drop frame if this is not from
1771 * passive scanning or a beacon (at least ProbeReq
1772 * frames to other APs may be allowed through RX
1773 * filtering in the wlan hw/driver)
1775 if ((type != WLAN_FC_TYPE_MGMT ||
1776 stype != WLAN_FC_STYPE_BEACON))
1779 broadcast_bssid = 1;
1783 case ieee80211_msg_normal:
1784 /* continue processing */
1786 case ieee80211_msg_tx_callback_ack:
1787 handle_tx_callback(hapd, buf, data_len, 1);
1789 case ieee80211_msg_tx_callback_fail:
1790 handle_tx_callback(hapd, buf, data_len, 0);
1795 case WLAN_FC_TYPE_MGMT:
1796 if (stype != WLAN_FC_STYPE_BEACON &&
1797 stype != WLAN_FC_STYPE_PROBE_REQ)
1798 wpa_printf(MSG_MSGDUMP, "MGMT");
1799 if (broadcast_bssid) {
1800 for (i = 0; i < iface->num_bss; i++)
1801 ieee802_11_mgmt(iface->bss[i], buf, data_len,
1804 ieee802_11_mgmt(hapd, buf, data_len, stype, hfi);
1806 case WLAN_FC_TYPE_CTRL:
1807 /* can only get here with PS-Poll frames */
1808 wpa_printf(MSG_DEBUG, "CTRL");
1809 handle_unknown_sta(hapd, hdr->addr2);
1811 case WLAN_FC_TYPE_DATA:
1812 handle_unknown_sta(hapd, hdr->addr2);
1818 static void handle_eapol(int sock, void *eloop_ctx, void *sock_ctx)
1820 struct i802_driver_data *drv = eloop_ctx;
1821 struct hostapd_data *hapd = drv->hapd;
1822 struct sockaddr_ll lladdr;
1823 unsigned char buf[3000];
1825 socklen_t fromlen = sizeof(lladdr);
1827 len = recvfrom(sock, buf, sizeof(buf), 0,
1828 (struct sockaddr *)&lladdr, &fromlen);
1834 if (have_ifidx(drv, lladdr.sll_ifindex))
1835 ieee802_1x_receive(hapd, lladdr.sll_addr, buf, len);
1839 static void handle_monitor_read(int sock, void *eloop_ctx, void *sock_ctx)
1841 struct i802_driver_data *drv = eloop_ctx;
1843 unsigned char buf[3000];
1844 struct hostapd_data *hapd = drv->hapd;
1845 struct ieee80211_radiotap_iterator iter;
1847 struct hostapd_frame_info hfi;
1848 int injected = 0, failed = 0, msg_type, rxflags = 0;
1850 len = recv(sock, buf, sizeof(buf), 0);
1856 if (ieee80211_radiotap_iterator_init(&iter, (void*)buf, len)) {
1857 printf("received invalid radiotap frame\n");
1861 memset(&hfi, 0, sizeof(hfi));
1864 ret = ieee80211_radiotap_iterator_next(&iter);
1868 printf("received invalid radiotap frame (%d)\n", ret);
1871 switch (iter.this_arg_index) {
1872 case IEEE80211_RADIOTAP_FLAGS:
1873 if (*iter.this_arg & IEEE80211_RADIOTAP_F_FCS)
1876 case IEEE80211_RADIOTAP_RX_FLAGS:
1879 case IEEE80211_RADIOTAP_TX_FLAGS:
1881 failed = le_to_host16((*(uint16_t *) iter.this_arg)) &
1882 IEEE80211_RADIOTAP_F_TX_FAIL;
1884 case IEEE80211_RADIOTAP_DATA_RETRIES:
1886 case IEEE80211_RADIOTAP_CHANNEL:
1887 /* TODO convert from freq/flags to channel number
1892 case IEEE80211_RADIOTAP_RATE:
1893 hfi.datarate = *iter.this_arg * 5;
1895 case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
1896 hfi.ssi_signal = *iter.this_arg;
1901 if (rxflags && injected)
1905 msg_type = ieee80211_msg_normal;
1907 msg_type = ieee80211_msg_tx_callback_fail;
1909 msg_type = ieee80211_msg_tx_callback_ack;
1911 handle_frame(hapd->iface, buf + iter.max_length,
1912 len - iter.max_length, &hfi, msg_type);
1916 static int nl80211_create_monitor_interface(struct i802_driver_data *drv)
1919 struct sockaddr_ll ll;
1923 snprintf(buf, IFNAMSIZ, "mon.%s", drv->iface);
1924 buf[IFNAMSIZ - 1] = '\0';
1926 drv->monitor_ifidx =
1927 nl80211_create_iface(drv, buf, NL80211_IFTYPE_MONITOR, NULL);
1929 if (drv->monitor_ifidx < 0)
1932 if (hostapd_set_iface_flags(drv, buf, 1))
1935 memset(&ll, 0, sizeof(ll));
1936 ll.sll_family = AF_PACKET;
1937 ll.sll_ifindex = drv->monitor_ifidx;
1938 drv->monitor_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
1939 if (drv->monitor_sock < 0) {
1940 perror("socket[PF_PACKET,SOCK_RAW]");
1944 if (bind(drv->monitor_sock, (struct sockaddr *) &ll,
1946 perror("monitor socket bind");
1950 optlen = sizeof(optval);
1953 (drv->monitor_sock, SOL_SOCKET, SO_PRIORITY, &optval, optlen)) {
1954 perror("Failed to set socket priority");
1958 if (eloop_register_read_sock(drv->monitor_sock, handle_monitor_read,
1960 printf("Could not register monitor read socket\n");
1966 nl80211_remove_iface(drv, drv->monitor_ifidx);
1971 static int nl80211_set_master_mode(struct i802_driver_data *drv,
1977 msg = nlmsg_alloc();
1981 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1982 0, NL80211_CMD_SET_INTERFACE, 0);
1983 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
1984 if_nametoindex(ifname));
1985 NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_AP);
1987 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
1991 wpa_printf(MSG_ERROR, "Failed to set interface %s to master "
1997 static int i802_init_sockets(struct i802_driver_data *drv, const u8 *bssid)
2000 struct sockaddr_ll addr;
2002 drv->ioctl_sock = -1;
2004 drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
2005 if (drv->ioctl_sock < 0) {
2006 perror("socket[PF_INET,SOCK_DGRAM]");
2010 /* start listening for EAPOL on the default AP interface */
2011 add_ifidx(drv, if_nametoindex(drv->iface));
2013 if (hostapd_set_iface_flags(drv, drv->iface, 0))
2017 os_strlcpy(ifr.ifr_name, drv->iface, IFNAMSIZ);
2018 memcpy(ifr.ifr_hwaddr.sa_data, bssid, ETH_ALEN);
2019 ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
2021 if (ioctl(drv->ioctl_sock, SIOCSIFHWADDR, &ifr)) {
2022 perror("ioctl(SIOCSIFHWADDR)");
2028 * initialise generic netlink and nl80211
2030 drv->nl_cb = nl_cb_alloc(NL_CB_DEFAULT);
2032 printf("Failed to allocate netlink callbacks.\n");
2036 drv->nl_handle = nl_handle_alloc_cb(drv->nl_cb);
2037 if (!drv->nl_handle) {
2038 printf("Failed to allocate netlink handle.\n");
2042 if (genl_connect(drv->nl_handle)) {
2043 printf("Failed to connect to generic netlink.\n");
2047 drv->nl_cache = genl_ctrl_alloc_cache(drv->nl_handle);
2048 if (!drv->nl_cache) {
2049 printf("Failed to allocate generic netlink cache.\n");
2053 drv->nl80211 = genl_ctrl_search_by_name(drv->nl_cache, "nl80211");
2054 if (!drv->nl80211) {
2055 printf("nl80211 not found.\n");
2059 /* Initialise a monitor interface */
2060 if (nl80211_create_monitor_interface(drv))
2063 if (nl80211_set_master_mode(drv, drv->iface))
2066 if (hostapd_set_iface_flags(drv, drv->iface, 1))
2069 memset(&addr, 0, sizeof(addr));
2070 addr.sll_family = AF_PACKET;
2071 addr.sll_ifindex = ifr.ifr_ifindex;
2072 wpa_printf(MSG_DEBUG, "Opening raw packet socket for ifindex %d",
2075 drv->eapol_sock = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_PAE));
2076 if (drv->eapol_sock < 0) {
2077 perror("socket(PF_PACKET, SOCK_DGRAM, ETH_P_PAE)");
2081 if (eloop_register_read_sock(drv->eapol_sock, handle_eapol, drv, NULL))
2083 printf("Could not register read socket for eapol\n");
2087 memset(&ifr, 0, sizeof(ifr));
2088 os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
2089 if (ioctl(drv->ioctl_sock, SIOCGIFHWADDR, &ifr) != 0) {
2090 perror("ioctl(SIOCGIFHWADDR)");
2094 if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
2095 printf("Invalid HW-addr family 0x%04x\n",
2096 ifr.ifr_hwaddr.sa_family);
2099 memcpy(drv->hapd->own_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
2104 nl80211_remove_iface(drv, drv->monitor_ifidx);
2109 static int i802_get_inact_sec(void *priv, const u8 *addr)
2111 struct hostap_sta_driver_data data;
2114 data.inactive_msec = (unsigned long) -1;
2115 ret = i802_read_sta_data(priv, &data, addr);
2116 if (ret || data.inactive_msec == (unsigned long) -1)
2118 return data.inactive_msec / 1000;
2122 static int i802_sta_clear_stats(void *priv, const u8 *addr)
2132 hostapd_wireless_event_wireless_custom(struct i802_driver_data *drv,
2135 wpa_printf(MSG_DEBUG, "Custom wireless event: '%s'", custom);
2137 if (strncmp(custom, "MLME-MICHAELMICFAILURE.indication", 33) == 0) {
2140 pos = strstr(custom, "addr=");
2142 wpa_printf(MSG_DEBUG,
2143 "MLME-MICHAELMICFAILURE.indication "
2144 "without sender address ignored");
2148 if (hwaddr_aton(pos, addr) == 0) {
2149 ieee80211_michael_mic_failure(drv->hapd, addr, 1);
2151 wpa_printf(MSG_DEBUG,
2152 "MLME-MICHAELMICFAILURE.indication "
2153 "with invalid MAC address");
2159 static void hostapd_wireless_event_wireless(struct i802_driver_data *drv,
2160 char *data, int len)
2162 struct iw_event iwe_buf, *iwe = &iwe_buf;
2163 char *pos, *end, *custom, *buf;
2168 while (pos + IW_EV_LCP_LEN <= end) {
2169 /* Event data may be unaligned, so make a local, aligned copy
2170 * before processing. */
2171 memcpy(&iwe_buf, pos, IW_EV_LCP_LEN);
2172 wpa_printf(MSG_DEBUG, "Wireless event: cmd=0x%x len=%d",
2173 iwe->cmd, iwe->len);
2174 if (iwe->len <= IW_EV_LCP_LEN)
2177 custom = pos + IW_EV_POINT_LEN;
2178 if (drv->we_version > 18 &&
2179 (iwe->cmd == IWEVMICHAELMICFAILURE ||
2180 iwe->cmd == IWEVCUSTOM)) {
2181 /* WE-19 removed the pointer from struct iw_point */
2182 char *dpos = (char *) &iwe_buf.u.data.length;
2183 int dlen = dpos - (char *) &iwe_buf;
2184 memcpy(dpos, pos + IW_EV_LCP_LEN,
2185 sizeof(struct iw_event) - dlen);
2187 memcpy(&iwe_buf, pos, sizeof(struct iw_event));
2188 custom += IW_EV_POINT_OFF;
2193 if (custom + iwe->u.data.length > end)
2195 buf = malloc(iwe->u.data.length + 1);
2198 memcpy(buf, custom, iwe->u.data.length);
2199 buf[iwe->u.data.length] = '\0';
2200 hostapd_wireless_event_wireless_custom(drv, buf);
2210 static void hostapd_wireless_event_rtm_newlink(struct i802_driver_data *drv,
2211 struct nlmsghdr *h, int len)
2213 struct ifinfomsg *ifi;
2214 int attrlen, nlmsg_len, rta_len;
2215 struct rtattr *attr;
2217 if (len < (int) sizeof(*ifi))
2220 ifi = NLMSG_DATA(h);
2222 /* TODO: use ifi->ifi_index to filter out wireless events from other
2225 nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
2227 attrlen = h->nlmsg_len - nlmsg_len;
2231 attr = (struct rtattr *) (((char *) ifi) + nlmsg_len);
2233 rta_len = RTA_ALIGN(sizeof(struct rtattr));
2234 while (RTA_OK(attr, attrlen)) {
2235 if (attr->rta_type == IFLA_WIRELESS) {
2236 hostapd_wireless_event_wireless(
2237 drv, ((char *) attr) + rta_len,
2238 attr->rta_len - rta_len);
2240 attr = RTA_NEXT(attr, attrlen);
2245 static void hostapd_wireless_event_receive(int sock, void *eloop_ctx,
2250 struct sockaddr_nl from;
2253 struct i802_driver_data *drv = eloop_ctx;
2255 fromlen = sizeof(from);
2256 left = recvfrom(sock, buf, sizeof(buf), MSG_DONTWAIT,
2257 (struct sockaddr *) &from, &fromlen);
2259 if (errno != EINTR && errno != EAGAIN)
2260 perror("recvfrom(netlink)");
2264 h = (struct nlmsghdr *) buf;
2265 while (left >= (int) sizeof(*h)) {
2269 plen = len - sizeof(*h);
2270 if (len > left || plen < 0) {
2271 printf("Malformed netlink message: "
2272 "len=%d left=%d plen=%d\n",
2277 switch (h->nlmsg_type) {
2279 hostapd_wireless_event_rtm_newlink(drv, h, plen);
2283 len = NLMSG_ALIGN(len);
2285 h = (struct nlmsghdr *) ((char *) h + len);
2289 printf("%d extra bytes in the end of netlink message\n", left);
2294 static int hostap_get_we_version(struct i802_driver_data *drv)
2296 struct iw_range *range;
2301 drv->we_version = 0;
2304 * Use larger buffer than struct iw_range in order to allow the
2305 * structure to grow in the future.
2307 buflen = sizeof(struct iw_range) + 500;
2308 range = os_zalloc(buflen);
2312 memset(&iwr, 0, sizeof(iwr));
2313 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
2314 iwr.u.data.pointer = (caddr_t) range;
2315 iwr.u.data.length = buflen;
2317 minlen = ((char *) &range->enc_capa) - (char *) range +
2318 sizeof(range->enc_capa);
2320 if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) {
2321 perror("ioctl[SIOCGIWRANGE]");
2324 } else if (iwr.u.data.length >= minlen &&
2325 range->we_version_compiled >= 18) {
2326 wpa_printf(MSG_DEBUG, "SIOCGIWRANGE: WE(compiled)=%d "
2327 "WE(source)=%d enc_capa=0x%x",
2328 range->we_version_compiled,
2329 range->we_version_source,
2331 drv->we_version = range->we_version_compiled;
2339 static int i802_wireless_event_init(void *priv)
2341 struct i802_driver_data *drv = priv;
2343 struct sockaddr_nl local;
2345 hostap_get_we_version(drv);
2347 drv->wext_sock = -1;
2349 s = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
2351 perror("socket(PF_NETLINK,SOCK_RAW,NETLINK_ROUTE)");
2355 memset(&local, 0, sizeof(local));
2356 local.nl_family = AF_NETLINK;
2357 local.nl_groups = RTMGRP_LINK;
2358 if (bind(s, (struct sockaddr *) &local, sizeof(local)) < 0) {
2359 perror("bind(netlink)");
2364 eloop_register_read_sock(s, hostapd_wireless_event_receive, drv,
2372 static void i802_wireless_event_deinit(void *priv)
2374 struct i802_driver_data *drv = priv;
2375 if (drv->wext_sock < 0)
2377 eloop_unregister_read_sock(drv->wext_sock);
2378 close(drv->wext_sock);
2382 static int i802_sta_deauth(void *priv, const u8 *addr, int reason)
2384 struct i802_driver_data *drv = priv;
2385 struct ieee80211_mgmt mgmt;
2387 memset(&mgmt, 0, sizeof(mgmt));
2388 mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
2389 WLAN_FC_STYPE_DEAUTH);
2390 memcpy(mgmt.da, addr, ETH_ALEN);
2391 memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN);
2392 memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN);
2393 mgmt.u.deauth.reason_code = host_to_le16(reason);
2394 return i802_send_mgmt_frame(drv, &mgmt, IEEE80211_HDRLEN +
2395 sizeof(mgmt.u.deauth), 0);
2399 static int i802_sta_disassoc(void *priv, const u8 *addr, int reason)
2401 struct i802_driver_data *drv = priv;
2402 struct ieee80211_mgmt mgmt;
2404 memset(&mgmt, 0, sizeof(mgmt));
2405 mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
2406 WLAN_FC_STYPE_DISASSOC);
2407 memcpy(mgmt.da, addr, ETH_ALEN);
2408 memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN);
2409 memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN);
2410 mgmt.u.disassoc.reason_code = host_to_le16(reason);
2411 return i802_send_mgmt_frame(drv, &mgmt, IEEE80211_HDRLEN +
2412 sizeof(mgmt.u.disassoc), 0);
2416 static void *i802_init_bssid(struct hostapd_data *hapd, const u8 *bssid)
2418 struct i802_driver_data *drv;
2420 drv = os_zalloc(sizeof(struct i802_driver_data));
2422 printf("Could not allocate memory for i802 driver data\n");
2427 memcpy(drv->iface, hapd->conf->iface, sizeof(drv->iface));
2429 drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
2430 drv->if_indices = drv->default_if_indices;
2431 drv->bridge = if_nametoindex(hapd->conf->bridge);
2433 if (i802_init_sockets(drv, bssid))
2444 static void *i802_init(struct hostapd_data *hapd)
2446 return i802_init_bssid(hapd, NULL);
2450 static void i802_deinit(void *priv)
2452 struct i802_driver_data *drv = priv;
2454 if (drv->last_freq_ht) {
2455 /* Clear HT flags from the driver */
2456 struct hostapd_freq_params freq;
2457 os_memset(&freq, 0, sizeof(freq));
2458 freq.freq = drv->last_freq;
2459 i802_set_freq2(priv, &freq);
2462 i802_del_beacon(drv);
2464 /* remove monitor interface */
2465 nl80211_remove_iface(drv, drv->monitor_ifidx);
2467 (void) hostapd_set_iface_flags(drv, drv->iface, 0);
2469 if (drv->monitor_sock >= 0) {
2470 eloop_unregister_read_sock(drv->monitor_sock);
2471 close(drv->monitor_sock);
2473 if (drv->ioctl_sock >= 0)
2474 close(drv->ioctl_sock);
2475 if (drv->eapol_sock >= 0) {
2476 eloop_unregister_read_sock(drv->eapol_sock);
2477 close(drv->eapol_sock);
2480 genl_family_put(drv->nl80211);
2481 nl_cache_free(drv->nl_cache);
2482 nl_handle_destroy(drv->nl_handle);
2483 nl_cb_put(drv->nl_cb);
2485 if (drv->if_indices != drv->default_if_indices)
2486 free(drv->if_indices);
2492 const struct wpa_driver_ops wpa_driver_nl80211_ops = {
2495 .init_bssid = i802_init_bssid,
2496 .deinit = i802_deinit,
2497 .wireless_event_init = i802_wireless_event_init,
2498 .wireless_event_deinit = i802_wireless_event_deinit,
2499 .set_ieee8021x = i802_set_ieee8021x,
2500 .set_privacy = i802_set_privacy,
2501 .set_encryption = i802_set_encryption,
2502 .get_seqnum = i802_get_seqnum,
2503 .flush = i802_flush,
2504 .read_sta_data = i802_read_sta_data,
2505 .send_eapol = i802_send_eapol,
2506 .sta_set_flags = i802_sta_set_flags,
2507 .sta_deauth = i802_sta_deauth,
2508 .sta_disassoc = i802_sta_disassoc,
2509 .sta_remove = i802_sta_remove,
2510 .send_mgmt_frame = i802_send_mgmt_frame,
2511 .sta_add2 = i802_sta_add2,
2512 .get_inact_sec = i802_get_inact_sec,
2513 .sta_clear_stats = i802_sta_clear_stats,
2514 .set_freq2 = i802_set_freq2,
2515 .set_rts = i802_set_rts,
2516 .get_rts = i802_get_rts,
2517 .set_frag = i802_set_frag,
2518 .get_frag = i802_get_frag,
2519 .set_retry = i802_set_retry,
2520 .get_retry = i802_get_retry,
2521 .set_rate_sets = i802_set_rate_sets,
2522 .set_regulatory_domain = i802_set_regulatory_domain,
2523 .set_beacon = i802_set_beacon,
2524 .set_internal_bridge = i802_set_internal_bridge,
2525 .set_beacon_int = i802_set_beacon_int,
2526 .set_dtim_period = i802_set_dtim_period,
2527 .set_cts_protect = i802_set_cts_protect,
2528 .set_preamble = i802_set_preamble,
2529 .set_short_slot_time = i802_set_short_slot_time,
2530 .set_tx_queue_params = i802_set_tx_queue_params,
2531 .bss_add = i802_bss_add,
2532 .bss_remove = i802_bss_remove,
2533 .if_add = i802_if_add,
2534 .if_update = i802_if_update,
2535 .if_remove = i802_if_remove,
2536 .get_hw_feature_data = i802_get_hw_feature_data,
2537 .set_sta_vlan = i802_set_sta_vlan,
2538 .set_country = i802_set_country,