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>
35 #include "ieee802_11.h"
36 #include "hw_features.h"
39 #include "radiotap_iter.h"
42 /* libnl 2.0 compatibility code */
43 #define nl_handle_alloc_cb nl_socket_alloc_cb
44 #define nl_handle_destroy nl_socket_free
45 #endif /* CONFIG_LIBNL20 */
47 static const u8 rfc1042_header[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
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 int i802_sta_deauth(void *priv, const u8 *addr, int reason);
85 static int i802_sta_disassoc(void *priv, const u8 *addr, int reason);
88 static void add_ifidx(struct i802_driver_data *drv, int ifidx)
93 for (i = 0; i < drv->num_if_indices; i++) {
94 if (drv->if_indices[i] == 0) {
95 drv->if_indices[i] = ifidx;
100 if (drv->if_indices != drv->default_if_indices)
101 old = drv->if_indices;
105 drv->if_indices = realloc(old,
106 sizeof(int) * (drv->num_if_indices + 1));
107 if (!drv->if_indices) {
109 drv->if_indices = drv->default_if_indices;
111 drv->if_indices = old;
112 wpa_printf(MSG_ERROR, "Failed to reallocate memory for "
114 wpa_printf(MSG_ERROR, "Ignoring EAPOL on interface %d", ifidx);
117 drv->if_indices[drv->num_if_indices] = ifidx;
118 drv->num_if_indices++;
122 static void del_ifidx(struct i802_driver_data *drv, int ifidx)
126 for (i = 0; i < drv->num_if_indices; i++) {
127 if (drv->if_indices[i] == ifidx) {
128 drv->if_indices[i] = 0;
135 static int have_ifidx(struct i802_driver_data *drv, int ifidx)
139 if (ifidx == drv->bridge)
142 for (i = 0; i < drv->num_if_indices; i++)
143 if (drv->if_indices[i] == ifidx)
151 static int ack_handler(struct nl_msg *msg, void *arg)
158 static int finish_handler(struct nl_msg *msg, void *arg)
165 static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
173 static int send_and_recv_msgs(struct i802_driver_data *drv,
175 int (*valid_handler)(struct nl_msg *, void *),
181 cb = nl_cb_clone(drv->nl_cb);
185 err = nl_send_auto_complete(drv->nl_handle, msg);
191 nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err);
192 nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
193 nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
196 nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
197 valid_handler, valid_data);
200 nl_recvmsgs(drv->nl_handle, cb);
207 static int hostapd_set_iface_flags(struct i802_driver_data *drv,
208 const char *ifname, int dev_up)
212 if (drv->ioctl_sock < 0)
215 memset(&ifr, 0, sizeof(ifr));
216 os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
218 if (ioctl(drv->ioctl_sock, SIOCGIFFLAGS, &ifr) != 0) {
219 perror("ioctl[SIOCGIFFLAGS]");
220 wpa_printf(MSG_DEBUG, "Could not read interface flags (%s)",
226 ifr.ifr_flags |= IFF_UP;
228 ifr.ifr_flags &= ~IFF_UP;
230 if (ioctl(drv->ioctl_sock, SIOCSIFFLAGS, &ifr) != 0) {
231 perror("ioctl[SIOCSIFFLAGS]");
239 static int nl_set_encr(int ifindex, struct i802_driver_data *drv,
240 const char *alg, const u8 *addr, int idx, const u8 *key,
241 size_t key_len, int txkey)
250 if (strcmp(alg, "none") == 0) {
251 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
252 0, NL80211_CMD_DEL_KEY, 0);
254 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
255 0, NL80211_CMD_NEW_KEY, 0);
256 NLA_PUT(msg, NL80211_ATTR_KEY_DATA, key_len, key);
257 if (strcmp(alg, "WEP") == 0) {
259 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
262 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
264 } else if (strcmp(alg, "TKIP") == 0)
265 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC02);
266 else if (strcmp(alg, "CCMP") == 0)
267 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC04);
268 else if (strcmp(alg, "IGTK") == 0)
269 NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC06);
271 wpa_printf(MSG_ERROR, "%s: Unsupported encryption "
272 "algorithm '%s'", __func__, alg);
279 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
280 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
281 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
283 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
288 * If we failed or don't need to set the default TX key (below),
291 if (ret || !txkey || addr)
298 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
299 0, NL80211_CMD_SET_KEY, 0);
300 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
301 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
302 if (strcmp(alg, "IGTK") == 0)
303 NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT_MGMT);
305 NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT);
307 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
316 static int i802_set_encryption(const char *iface, void *priv, const char *alg,
317 const u8 *addr, int idx, const u8 *key,
318 size_t key_len, int txkey)
320 struct i802_driver_data *drv = priv;
323 ret = nl_set_encr(if_nametoindex(iface), drv, alg, addr, idx, key,
332 static inline int min_int(int a, int b)
340 static int get_key_handler(struct nl_msg *msg, void *arg)
342 struct nlattr *tb[NL80211_ATTR_MAX + 1];
343 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
345 nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
346 genlmsg_attrlen(gnlh, 0), NULL);
349 * TODO: validate the key index and mac address!
350 * Otherwise, there's a race condition as soon as
351 * the kernel starts sending key notifications.
354 if (tb[NL80211_ATTR_KEY_SEQ])
355 memcpy(arg, nla_data(tb[NL80211_ATTR_KEY_SEQ]),
356 min_int(nla_len(tb[NL80211_ATTR_KEY_SEQ]), 6));
361 static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr,
364 struct i802_driver_data *drv = priv;
371 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
372 0, NL80211_CMD_GET_KEY, 0);
375 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
376 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
377 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
381 return send_and_recv_msgs(drv, msg, get_key_handler, seq);
387 static int i802_set_rate_sets(void *priv, int *supp_rates, int *basic_rates,
390 struct i802_driver_data *drv = priv;
392 u8 rates[NL80211_MAX_SUPP_RATES];
400 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
401 NL80211_CMD_SET_BSS, 0);
403 for (i = 0; i < NL80211_MAX_SUPP_RATES && basic_rates[i] >= 0; i++)
404 rates[rates_len++] = basic_rates[i] / 5;
406 NLA_PUT(msg, NL80211_ATTR_BSS_BASIC_RATES, rates_len, rates);
408 /* TODO: multi-BSS support */
409 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
411 return send_and_recv_msgs(drv, msg, NULL, NULL);
417 static int i802_send_frame(void *priv, const void *data, size_t len,
418 int encrypt, int flags)
421 0x00, 0x00, /* radiotap version */
422 0x0e, 0x00, /* radiotap length */
423 0x02, 0xc0, 0x00, 0x00, /* bmap: flags, tx and rx flags */
424 IEEE80211_RADIOTAP_F_FRAG, /* F_FRAG (fragment if required) */
426 0x00, 0x00, /* RX and TX flags to indicate that */
427 0x00, 0x00, /* this is the injected frame directly */
429 struct i802_driver_data *drv = priv;
430 struct iovec iov[2] = {
432 .iov_base = &rtap_hdr,
433 .iov_len = sizeof(rtap_hdr),
436 .iov_base = (void*)data,
440 struct msghdr msg = {
451 rtap_hdr[8] |= IEEE80211_RADIOTAP_F_WEP;
453 return sendmsg(drv->monitor_sock, &msg, flags);
456 static int i802_send_mgmt_frame(void *priv, const void *data, size_t len,
459 struct ieee80211_mgmt *mgmt;
460 int do_not_encrypt = 0;
463 mgmt = (struct ieee80211_mgmt *) data;
464 fc = le_to_host16(mgmt->frame_control);
466 if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
467 WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_AUTH) {
469 * Only one of the authentication frame types is encrypted.
470 * In order for static WEP encryption to work properly (i.e.,
471 * to not encrypt the frame), we need to tell mac80211 about
472 * the frames that must not be encrypted.
474 u16 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
475 u16 auth_trans = le_to_host16(mgmt->u.auth.auth_transaction);
476 if (auth_alg == WLAN_AUTH_OPEN ||
477 (auth_alg == WLAN_AUTH_SHARED_KEY && auth_trans != 3))
481 return i802_send_frame(priv, data, len, !do_not_encrypt, flags);
484 /* Set kernel driver on given frequency (MHz) */
485 static int i802_set_freq2(void *priv, struct hostapd_freq_params *freq)
487 struct i802_driver_data *drv = priv;
494 drv->last_freq = freq->freq;
495 drv->last_freq_ht = freq->ht_enabled;
497 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
498 NL80211_CMD_SET_WIPHY, 0);
500 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
501 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq->freq);
502 if (freq->ht_enabled) {
503 switch (freq->sec_channel_offset) {
505 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
506 NL80211_CHAN_HT40MINUS);
509 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
510 NL80211_CHAN_HT40PLUS);
513 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
519 if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
526 static int i802_set_rts(void *priv, int rts)
528 struct i802_driver_data *drv = priv;
531 memset(&iwr, 0, sizeof(iwr));
532 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
533 iwr.u.rts.value = rts;
536 if (ioctl(drv->ioctl_sock, SIOCSIWRTS, &iwr) < 0) {
537 perror("ioctl[SIOCSIWRTS]");
545 static int i802_get_rts(void *priv, int *rts)
547 struct i802_driver_data *drv = priv;
550 memset(&iwr, 0, sizeof(iwr));
551 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
553 if (ioctl(drv->ioctl_sock, SIOCGIWRTS, &iwr) < 0) {
554 perror("ioctl[SIOCGIWRTS]");
558 *rts = iwr.u.rts.value;
564 static int i802_set_frag(void *priv, int frag)
566 struct i802_driver_data *drv = priv;
569 memset(&iwr, 0, sizeof(iwr));
570 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
571 iwr.u.frag.value = frag;
572 iwr.u.frag.fixed = 1;
574 if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
575 perror("ioctl[SIOCSIWFRAG]");
583 static int i802_get_frag(void *priv, int *frag)
585 struct i802_driver_data *drv = priv;
588 memset(&iwr, 0, sizeof(iwr));
589 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
591 if (ioctl(drv->ioctl_sock, SIOCGIWFRAG, &iwr) < 0) {
592 perror("ioctl[SIOCGIWFRAG]");
596 *frag = iwr.u.frag.value;
602 static int i802_set_retry(void *priv, int short_retry, int long_retry)
604 struct i802_driver_data *drv = priv;
607 memset(&iwr, 0, sizeof(iwr));
608 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
610 iwr.u.retry.value = short_retry;
611 iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
612 if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
613 perror("ioctl[SIOCSIWRETRY(short)]");
617 iwr.u.retry.value = long_retry;
618 iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
619 if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
620 perror("ioctl[SIOCSIWRETRY(long)]");
628 static int i802_get_retry(void *priv, int *short_retry, int *long_retry)
630 struct i802_driver_data *drv = priv;
633 memset(&iwr, 0, sizeof(iwr));
634 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
636 iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
637 if (ioctl(drv->ioctl_sock, SIOCGIWRETRY, &iwr) < 0) {
638 perror("ioctl[SIOCGIWFRAG(short)]");
641 *short_retry = iwr.u.retry.value;
643 iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
644 if (ioctl(drv->ioctl_sock, SIOCGIWRETRY, &iwr) < 0) {
645 perror("ioctl[SIOCGIWFRAG(long)]");
648 *long_retry = iwr.u.retry.value;
654 static int i802_flush(void *priv)
656 struct i802_driver_data *drv = priv;
663 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
664 0, NL80211_CMD_DEL_STATION, 0);
667 * XXX: FIX! this needs to flush all VLANs too
669 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
670 if_nametoindex(drv->iface));
672 return send_and_recv_msgs(drv, msg, NULL, NULL);
678 static int get_sta_handler(struct nl_msg *msg, void *arg)
680 struct nlattr *tb[NL80211_ATTR_MAX + 1];
681 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
682 struct hostap_sta_driver_data *data = arg;
683 struct nlattr *stats[NL80211_STA_INFO_MAX + 1];
684 static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
685 [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
686 [NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 },
687 [NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 },
690 nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
691 genlmsg_attrlen(gnlh, 0), NULL);
694 * TODO: validate the interface and mac address!
695 * Otherwise, there's a race condition as soon as
696 * the kernel starts sending station notifications.
699 if (!tb[NL80211_ATTR_STA_INFO]) {
700 wpa_printf(MSG_DEBUG, "sta stats missing!");
703 if (nla_parse_nested(stats, NL80211_STA_INFO_MAX,
704 tb[NL80211_ATTR_STA_INFO],
706 wpa_printf(MSG_DEBUG, "failed to parse nested attributes!");
710 if (stats[NL80211_STA_INFO_INACTIVE_TIME])
711 data->inactive_msec =
712 nla_get_u32(stats[NL80211_STA_INFO_INACTIVE_TIME]);
713 if (stats[NL80211_STA_INFO_RX_BYTES])
714 data->rx_bytes = nla_get_u32(stats[NL80211_STA_INFO_RX_BYTES]);
715 if (stats[NL80211_STA_INFO_TX_BYTES])
716 data->rx_bytes = nla_get_u32(stats[NL80211_STA_INFO_TX_BYTES]);
721 static int i802_read_sta_data(void *priv, struct hostap_sta_driver_data *data,
724 struct i802_driver_data *drv = priv;
731 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
732 0, NL80211_CMD_GET_STATION, 0);
734 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
735 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
737 return send_and_recv_msgs(drv, msg, get_sta_handler, data);
743 static int i802_send_eapol(void *priv, const u8 *addr, const u8 *data,
744 size_t data_len, int encrypt, const u8 *own_addr)
746 struct i802_driver_data *drv = priv;
747 struct ieee80211_hdr *hdr;
752 int qos = sta->flags & WLAN_STA_WME;
757 len = sizeof(*hdr) + (qos ? 2 : 0) + sizeof(rfc1042_header) + 2 +
759 hdr = os_zalloc(len);
761 printf("malloc() failed for i802_send_data(len=%lu)\n",
762 (unsigned long) len);
767 IEEE80211_FC(WLAN_FC_TYPE_DATA, WLAN_FC_STYPE_DATA);
768 hdr->frame_control |= host_to_le16(WLAN_FC_FROMDS);
770 hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
771 #if 0 /* To be enabled if qos determination is added above */
773 hdr->frame_control |=
774 host_to_le16(WLAN_FC_STYPE_QOS_DATA << 4);
778 memcpy(hdr->IEEE80211_DA_FROMDS, addr, ETH_ALEN);
779 memcpy(hdr->IEEE80211_BSSID_FROMDS, own_addr, ETH_ALEN);
780 memcpy(hdr->IEEE80211_SA_FROMDS, own_addr, ETH_ALEN);
781 pos = (u8 *) (hdr + 1);
783 #if 0 /* To be enabled if qos determination is added above */
785 /* add an empty QoS header if needed */
792 memcpy(pos, rfc1042_header, sizeof(rfc1042_header));
793 pos += sizeof(rfc1042_header);
794 WPA_PUT_BE16(pos, ETH_P_PAE);
796 memcpy(pos, data, data_len);
798 res = i802_send_frame(drv, (u8 *) hdr, len, encrypt, 0);
802 perror("i802_send_eapol: send");
803 printf("i802_send_eapol - packet len: %lu - failed\n",
804 (unsigned long) len);
811 static int i802_sta_add2(const char *ifname, void *priv,
812 struct hostapd_sta_add_params *params)
814 struct i802_driver_data *drv = priv;
822 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
823 0, NL80211_CMD_NEW_STATION, 0);
825 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
826 if_nametoindex(drv->iface));
827 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, params->addr);
828 NLA_PUT_U16(msg, NL80211_ATTR_STA_AID, params->aid);
829 NLA_PUT(msg, NL80211_ATTR_STA_SUPPORTED_RATES, params->supp_rates_len,
831 NLA_PUT_U16(msg, NL80211_ATTR_STA_LISTEN_INTERVAL,
832 params->listen_interval);
834 #ifdef CONFIG_IEEE80211N
835 if (params->ht_capabilities) {
836 NLA_PUT(msg, NL80211_ATTR_HT_CAPABILITY,
837 params->ht_capabilities->length,
838 ¶ms->ht_capabilities->data);
840 #endif /* CONFIG_IEEE80211N */
842 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
850 static int i802_sta_remove(void *priv, const u8 *addr)
852 struct i802_driver_data *drv = priv;
860 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
861 0, NL80211_CMD_DEL_STATION, 0);
863 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
864 if_nametoindex(drv->iface));
865 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
867 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
876 static int i802_sta_set_flags(void *priv, const u8 *addr,
877 int total_flags, int flags_or, int flags_and)
879 struct i802_driver_data *drv = priv;
880 struct nl_msg *msg, *flags = NULL;
886 flags = nlmsg_alloc();
892 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
893 0, NL80211_CMD_SET_STATION, 0);
895 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
896 if_nametoindex(drv->iface));
897 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
899 if (total_flags & WLAN_STA_AUTHORIZED || !drv->ieee802_1x_active)
900 NLA_PUT_FLAG(flags, NL80211_STA_FLAG_AUTHORIZED);
902 if (total_flags & WLAN_STA_WME)
903 NLA_PUT_FLAG(flags, NL80211_STA_FLAG_WME);
905 if (total_flags & WLAN_STA_SHORT_PREAMBLE)
906 NLA_PUT_FLAG(flags, NL80211_STA_FLAG_SHORT_PREAMBLE);
908 if (total_flags & WLAN_STA_MFP)
909 NLA_PUT_FLAG(flags, NL80211_STA_FLAG_MFP);
911 if (nla_put_nested(msg, NL80211_ATTR_STA_FLAGS, flags))
912 goto nla_put_failure;
916 return send_and_recv_msgs(drv, msg, NULL, NULL);
923 static int i802_set_regulatory_domain(void *priv, unsigned int rd)
929 static int i802_set_tx_queue_params(void *priv, int queue, int aifs,
930 int cw_min, int cw_max, int burst_time)
932 struct i802_driver_data *drv = priv;
934 struct nlattr *txq, *params;
940 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
941 0, NL80211_CMD_SET_WIPHY, 0);
943 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
945 txq = nla_nest_start(msg, NL80211_ATTR_WIPHY_TXQ_PARAMS);
947 goto nla_put_failure;
949 /* We are only sending parameters for a single TXQ at a time */
950 params = nla_nest_start(msg, 1);
952 goto nla_put_failure;
954 NLA_PUT_U8(msg, NL80211_TXQ_ATTR_QUEUE, queue);
955 /* Burst time is configured in units of 0.1 msec and TXOP parameter in
956 * 32 usec, so need to convert the value here. */
957 NLA_PUT_U16(msg, NL80211_TXQ_ATTR_TXOP, (burst_time * 100 + 16) / 32);
958 NLA_PUT_U16(msg, NL80211_TXQ_ATTR_CWMIN, cw_min);
959 NLA_PUT_U16(msg, NL80211_TXQ_ATTR_CWMAX, cw_max);
960 NLA_PUT_U8(msg, NL80211_TXQ_ATTR_AIFS, aifs);
962 nla_nest_end(msg, params);
964 nla_nest_end(msg, txq);
966 if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
973 static void nl80211_remove_iface(struct i802_driver_data *drv, int ifidx)
977 /* stop listening for EAPOL on this interface */
978 del_ifidx(drv, ifidx);
982 goto nla_put_failure;
984 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
985 0, NL80211_CMD_DEL_INTERFACE, 0);
986 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifidx);
988 if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
991 printf("Failed to remove interface.\n");
995 static int nl80211_create_iface(struct i802_driver_data *drv,
997 enum nl80211_iftype iftype,
1000 struct nl_msg *msg, *flags = NULL;
1006 msg = nlmsg_alloc();
1010 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1011 0, NL80211_CMD_NEW_INTERFACE, 0);
1012 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1013 NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, ifname);
1014 NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, iftype);
1016 if (iftype == NL80211_IFTYPE_MONITOR) {
1019 flags = nlmsg_alloc();
1021 goto nla_put_failure;
1023 NLA_PUT_FLAG(flags, NL80211_MNTR_FLAG_COOK_FRAMES);
1025 err = nla_put_nested(msg, NL80211_ATTR_MNTR_FLAGS, flags);
1030 goto nla_put_failure;
1033 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
1036 printf("Failed to create interface %s.\n", ifname);
1040 ifidx = if_nametoindex(ifname);
1045 /* start listening for EAPOL on this interface */
1046 add_ifidx(drv, ifidx);
1050 case NL80211_IFTYPE_AP:
1051 os_strlcpy(ifreq.ifr_name, ifname, IFNAMSIZ);
1052 memcpy(ifreq.ifr_hwaddr.sa_data, addr, ETH_ALEN);
1053 ifreq.ifr_hwaddr.sa_family = ARPHRD_ETHER;
1055 if (ioctl(drv->ioctl_sock, SIOCSIFHWADDR, &ifreq)) {
1056 nl80211_remove_iface(drv, ifidx);
1060 case NL80211_IFTYPE_WDS:
1061 memset(&iwr, 0, sizeof(iwr));
1062 os_strlcpy(iwr.ifr_name, ifname, IFNAMSIZ);
1063 iwr.u.addr.sa_family = ARPHRD_ETHER;
1064 memcpy(iwr.u.addr.sa_data, addr, ETH_ALEN);
1065 if (ioctl(drv->ioctl_sock, SIOCSIWAP, &iwr))
1078 static int i802_bss_add(void *priv, const char *ifname, const u8 *bssid)
1083 * The kernel supports that when the low-level driver does,
1084 * but we currently don't because we need per-BSS data that
1085 * currently we can't handle easily.
1089 ifidx = nl80211_create_iface(priv, ifname, NL80211_IFTYPE_AP, bssid);
1092 if (hostapd_set_iface_flags(priv, ifname, 1)) {
1093 nl80211_remove_iface(priv, ifidx);
1100 static int i802_bss_remove(void *priv, const char *ifname)
1102 nl80211_remove_iface(priv, if_nametoindex(ifname));
1107 static int i802_set_beacon(const char *iface, void *priv,
1108 u8 *head, size_t head_len,
1109 u8 *tail, size_t tail_len)
1111 struct i802_driver_data *drv = priv;
1113 u8 cmd = NL80211_CMD_NEW_BEACON;
1116 msg = nlmsg_alloc();
1120 if (drv->beacon_set)
1121 cmd = NL80211_CMD_SET_BEACON;
1123 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1125 NLA_PUT(msg, NL80211_ATTR_BEACON_HEAD, head_len, head);
1126 NLA_PUT(msg, NL80211_ATTR_BEACON_TAIL, tail_len, tail);
1127 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
1128 NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, drv->beacon_int);
1130 if (!drv->dtim_period)
1131 drv->dtim_period = 2;
1132 NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
1134 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
1136 drv->beacon_set = 1;
1143 static int i802_del_beacon(struct i802_driver_data *drv)
1147 msg = nlmsg_alloc();
1151 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1152 0, NL80211_CMD_DEL_BEACON, 0);
1153 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1155 return send_and_recv_msgs(drv, msg, NULL, NULL);
1161 static int i802_set_ieee8021x(const char *ifname, void *priv, int enabled)
1163 struct i802_driver_data *drv = priv;
1166 * FIXME: This needs to be per interface (BSS)
1168 drv->ieee802_1x_active = enabled;
1173 static int i802_set_privacy(const char *ifname, void *priv, int enabled)
1175 struct i802_driver_data *drv = priv;
1178 memset(&iwr, 0, sizeof(iwr));
1180 os_strlcpy(iwr.ifr_name, ifname, IFNAMSIZ);
1181 iwr.u.param.flags = IW_AUTH_PRIVACY_INVOKED;
1182 iwr.u.param.value = enabled;
1184 ioctl(drv->ioctl_sock, SIOCSIWAUTH, &iwr);
1186 /* ignore errors, the kernel/driver might not care */
1191 static int i802_set_internal_bridge(void *priv, int value)
1197 static int i802_set_beacon_int(void *priv, int value)
1199 struct i802_driver_data *drv = priv;
1202 drv->beacon_int = value;
1204 if (!drv->beacon_set)
1207 msg = nlmsg_alloc();
1211 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1212 0, NL80211_CMD_SET_BEACON, 0);
1213 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1215 NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, value);
1217 return send_and_recv_msgs(drv, msg, NULL, NULL);
1223 static int i802_set_dtim_period(const char *iface, void *priv, int value)
1225 struct i802_driver_data *drv = priv;
1228 msg = nlmsg_alloc();
1232 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1233 0, NL80211_CMD_SET_BEACON, 0);
1234 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
1236 drv->dtim_period = value;
1237 NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
1239 return send_and_recv_msgs(drv, msg, NULL, NULL);
1245 static int i802_set_bss(void *priv, int cts, int preamble, int slot)
1247 struct i802_driver_data *drv = priv;
1250 msg = nlmsg_alloc();
1254 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
1255 NL80211_CMD_SET_BSS, 0);
1258 NLA_PUT_U8(msg, NL80211_ATTR_BSS_CTS_PROT, cts);
1260 NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_PREAMBLE, preamble);
1262 NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_SLOT_TIME, slot);
1264 /* TODO: multi-BSS support */
1265 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1267 return send_and_recv_msgs(drv, msg, NULL, NULL);
1273 static int i802_set_cts_protect(void *priv, int value)
1275 return i802_set_bss(priv, value, -1, -1);
1279 static int i802_set_preamble(void *priv, int value)
1281 return i802_set_bss(priv, -1, value, -1);
1285 static int i802_set_short_slot_time(void *priv, int value)
1287 return i802_set_bss(priv, -1, -1, value);
1291 static enum nl80211_iftype i802_if_type(enum hostapd_driver_if_type type)
1294 case HOSTAPD_IF_VLAN:
1295 return NL80211_IFTYPE_AP_VLAN;
1296 case HOSTAPD_IF_WDS:
1297 return NL80211_IFTYPE_WDS;
1303 static int i802_if_add(const char *iface, void *priv,
1304 enum hostapd_driver_if_type type, char *ifname,
1307 if (nl80211_create_iface(priv, ifname, i802_if_type(type), addr) < 0)
1313 static int i802_if_update(void *priv, enum hostapd_driver_if_type type,
1314 char *ifname, const u8 *addr)
1316 /* unused at the moment */
1321 static int i802_if_remove(void *priv, enum hostapd_driver_if_type type,
1322 const char *ifname, const u8 *addr)
1324 nl80211_remove_iface(priv, if_nametoindex(ifname));
1329 struct phy_info_arg {
1331 struct hostapd_hw_modes *modes;
1334 static int phy_info_handler(struct nl_msg *msg, void *arg)
1336 struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
1337 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
1338 struct phy_info_arg *phy_info = arg;
1340 struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1];
1342 struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1];
1343 static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
1344 [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
1345 [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
1346 [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
1347 [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
1348 [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
1349 [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
1352 struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1];
1353 static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = {
1354 [NL80211_BITRATE_ATTR_RATE] = { .type = NLA_U32 },
1355 [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE] = { .type = NLA_FLAG },
1358 struct nlattr *nl_band;
1359 struct nlattr *nl_freq;
1360 struct nlattr *nl_rate;
1361 int rem_band, rem_freq, rem_rate;
1362 struct hostapd_hw_modes *mode;
1363 int idx, mode_is_set;
1365 nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
1366 genlmsg_attrlen(gnlh, 0), NULL);
1368 if (!tb_msg[NL80211_ATTR_WIPHY_BANDS])
1371 nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) {
1372 mode = realloc(phy_info->modes, (*phy_info->num_modes + 1) * sizeof(*mode));
1375 phy_info->modes = mode;
1379 mode = &phy_info->modes[*(phy_info->num_modes)];
1380 memset(mode, 0, sizeof(*mode));
1381 *(phy_info->num_modes) += 1;
1383 nla_parse(tb_band, NL80211_BAND_ATTR_MAX, nla_data(nl_band),
1384 nla_len(nl_band), NULL);
1386 nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) {
1387 nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq),
1388 nla_len(nl_freq), freq_policy);
1389 if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
1391 mode->num_channels++;
1394 mode->channels = calloc(mode->num_channels, sizeof(struct hostapd_channel_data));
1395 if (!mode->channels)
1400 nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) {
1401 nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq),
1402 nla_len(nl_freq), freq_policy);
1403 if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
1406 mode->channels[idx].freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]);
1407 mode->channels[idx].flag = 0;
1410 /* crude heuristic */
1411 if (mode->channels[idx].freq < 4000)
1412 mode->mode = HOSTAPD_MODE_IEEE80211B;
1414 mode->mode = HOSTAPD_MODE_IEEE80211A;
1418 /* crude heuristic */
1419 if (mode->channels[idx].freq < 4000)
1420 if (mode->channels[idx].freq == 2848)
1421 mode->channels[idx].chan = 14;
1423 mode->channels[idx].chan = (mode->channels[idx].freq - 2407) / 5;
1425 mode->channels[idx].chan = mode->channels[idx].freq/5 - 1000;
1427 if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
1428 mode->channels[idx].flag |=
1429 HOSTAPD_CHAN_DISABLED;
1430 if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN])
1431 mode->channels[idx].flag |=
1432 HOSTAPD_CHAN_PASSIVE_SCAN;
1433 if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IBSS])
1434 mode->channels[idx].flag |=
1435 HOSTAPD_CHAN_NO_IBSS;
1436 if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR])
1437 mode->channels[idx].flag |=
1440 if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] &&
1441 !tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
1442 mode->channels[idx].max_tx_power =
1443 nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]) / 100;
1448 nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
1449 nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate),
1450 nla_len(nl_rate), rate_policy);
1451 if (!tb_rate[NL80211_BITRATE_ATTR_RATE])
1456 mode->rates = calloc(mode->num_rates, sizeof(struct hostapd_rate_data));
1462 nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
1463 nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate),
1464 nla_len(nl_rate), rate_policy);
1465 if (!tb_rate[NL80211_BITRATE_ATTR_RATE])
1467 mode->rates[idx].rate = nla_get_u32(tb_rate[NL80211_BITRATE_ATTR_RATE]);
1469 /* crude heuristic */
1470 if (mode->mode == HOSTAPD_MODE_IEEE80211B &&
1471 mode->rates[idx].rate > 200)
1472 mode->mode = HOSTAPD_MODE_IEEE80211G;
1474 if (tb_rate[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE])
1475 mode->rates[idx].flags |= HOSTAPD_RATE_PREAMBLE2;
1484 static struct hostapd_hw_modes *i802_add_11b(struct hostapd_hw_modes *modes,
1488 struct hostapd_hw_modes *mode11g = NULL, *nmodes, *mode;
1489 int i, mode11g_idx = -1;
1491 /* If only 802.11g mode is included, use it to construct matching
1492 * 802.11b mode data. */
1494 for (m = 0; m < *num_modes; m++) {
1495 if (modes[m].mode == HOSTAPD_MODE_IEEE80211B)
1496 return modes; /* 802.11b already included */
1497 if (modes[m].mode == HOSTAPD_MODE_IEEE80211G)
1501 if (mode11g_idx < 0)
1502 return modes; /* 2.4 GHz band not supported at all */
1504 nmodes = os_realloc(modes, (*num_modes + 1) * sizeof(*nmodes));
1506 return modes; /* Could not add 802.11b mode */
1508 mode = &nmodes[*num_modes];
1509 os_memset(mode, 0, sizeof(*mode));
1513 mode->mode = HOSTAPD_MODE_IEEE80211B;
1515 mode11g = &modes[mode11g_idx];
1516 mode->num_channels = mode11g->num_channels;
1517 mode->channels = os_malloc(mode11g->num_channels *
1518 sizeof(struct hostapd_channel_data));
1519 if (mode->channels == NULL) {
1521 return modes; /* Could not add 802.11b mode */
1523 os_memcpy(mode->channels, mode11g->channels,
1524 mode11g->num_channels * sizeof(struct hostapd_channel_data));
1526 mode->num_rates = 0;
1527 mode->rates = os_malloc(4 * sizeof(struct hostapd_rate_data));
1528 if (mode->rates == NULL) {
1529 os_free(mode->channels);
1531 return modes; /* Could not add 802.11b mode */
1534 for (i = 0; i < mode11g->num_rates; i++) {
1535 if (mode11g->rates[i].rate > 110 ||
1536 mode11g->rates[i].flags &
1537 (HOSTAPD_RATE_ERP | HOSTAPD_RATE_OFDM))
1539 mode->rates[mode->num_rates] = mode11g->rates[i];
1541 if (mode->num_rates == 4)
1545 if (mode->num_rates == 0) {
1546 os_free(mode->channels);
1547 os_free(mode->rates);
1549 return modes; /* No 802.11b rates */
1552 wpa_printf(MSG_DEBUG, "nl80211: Added 802.11b mode based on 802.11g "
1558 static struct hostapd_hw_modes *i802_get_hw_feature_data(void *priv,
1562 struct i802_driver_data *drv = priv;
1564 struct phy_info_arg result = {
1565 .num_modes = num_modes,
1572 msg = nlmsg_alloc();
1576 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1577 0, NL80211_CMD_GET_WIPHY, 0);
1579 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
1581 if (send_and_recv_msgs(drv, msg, phy_info_handler, &result) == 0)
1582 return i802_add_11b(result.modes, num_modes);
1588 static int i802_set_sta_vlan(void *priv, const u8 *addr,
1589 const char *ifname, int vlan_id)
1591 struct i802_driver_data *drv = priv;
1594 msg = nlmsg_alloc();
1598 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1599 0, NL80211_CMD_SET_STATION, 0);
1601 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
1602 if_nametoindex(drv->iface));
1603 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
1604 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
1605 if_nametoindex(ifname));
1607 return send_and_recv_msgs(drv, msg, NULL, NULL);
1613 static int i802_set_country(void *priv, const char *country)
1615 struct i802_driver_data *drv = priv;
1619 msg = nlmsg_alloc();
1623 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1624 0, NL80211_CMD_REQ_SET_REG, 0);
1626 alpha2[0] = country[0];
1627 alpha2[1] = country[1];
1629 NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2, alpha2);
1631 return send_and_recv_msgs(drv, msg, NULL, NULL);
1637 static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
1640 struct ieee80211_hdr *hdr;
1641 u16 fc, type, stype;
1643 hdr = (struct ieee80211_hdr *) buf;
1644 fc = le_to_host16(hdr->frame_control);
1646 type = WLAN_FC_GET_TYPE(fc);
1647 stype = WLAN_FC_GET_STYPE(fc);
1650 case WLAN_FC_TYPE_MGMT:
1651 wpa_printf(MSG_DEBUG, "MGMT (TX callback) %s",
1652 ok ? "ACK" : "fail");
1653 ieee802_11_mgmt_cb(hapd, buf, len, stype, ok);
1655 case WLAN_FC_TYPE_CTRL:
1656 wpa_printf(MSG_DEBUG, "CTRL (TX callback) %s",
1657 ok ? "ACK" : "fail");
1659 case WLAN_FC_TYPE_DATA:
1660 wpa_printf(MSG_DEBUG, "DATA (TX callback) %s",
1661 ok ? "ACK" : "fail");
1662 hostapd_tx_status(hapd, hdr->addr1, buf, len, ok);
1665 printf("unknown TX callback frame type %d\n", type);
1671 static void handle_frame(struct i802_driver_data *drv,
1672 struct hostapd_iface *iface, u8 *buf, size_t len,
1673 struct hostapd_frame_info *hfi,
1674 enum ieee80211_msg_type msg_type)
1676 struct ieee80211_hdr *hdr;
1677 u16 fc, type, stype;
1678 size_t data_len = len;
1679 struct hostapd_data *hapd = NULL;
1680 int broadcast_bssid = 0;
1685 * PS-Poll frames are 16 bytes. All other frames are
1686 * 24 bytes or longer.
1691 hdr = (struct ieee80211_hdr *) buf;
1692 fc = le_to_host16(hdr->frame_control);
1694 type = WLAN_FC_GET_TYPE(fc);
1695 stype = WLAN_FC_GET_STYPE(fc);
1698 case WLAN_FC_TYPE_DATA:
1701 switch (fc & (WLAN_FC_FROMDS | WLAN_FC_TODS)) {
1710 case WLAN_FC_TYPE_CTRL:
1711 /* discard non-ps-poll frames */
1712 if (stype != WLAN_FC_STYPE_PSPOLL)
1716 case WLAN_FC_TYPE_MGMT:
1724 /* find interface frame belongs to */
1725 for (i = 0; i < iface->num_bss; i++) {
1726 if (memcmp(bssid, iface->bss[i]->own_addr, ETH_ALEN) == 0) {
1727 hapd = iface->bss[i];
1733 hapd = iface->bss[0];
1735 if (bssid[0] != 0xff || bssid[1] != 0xff ||
1736 bssid[2] != 0xff || bssid[3] != 0xff ||
1737 bssid[4] != 0xff || bssid[5] != 0xff) {
1739 * Unknown BSSID - drop frame if this is not from
1740 * passive scanning or a beacon (at least ProbeReq
1741 * frames to other APs may be allowed through RX
1742 * filtering in the wlan hw/driver)
1744 if ((type != WLAN_FC_TYPE_MGMT ||
1745 stype != WLAN_FC_STYPE_BEACON))
1748 broadcast_bssid = 1;
1752 case ieee80211_msg_normal:
1753 /* continue processing */
1755 case ieee80211_msg_tx_callback_ack:
1756 handle_tx_callback(hapd, buf, data_len, 1);
1758 case ieee80211_msg_tx_callback_fail:
1759 handle_tx_callback(hapd, buf, data_len, 0);
1764 case WLAN_FC_TYPE_MGMT:
1765 if (stype != WLAN_FC_STYPE_BEACON &&
1766 stype != WLAN_FC_STYPE_PROBE_REQ)
1767 wpa_printf(MSG_MSGDUMP, "MGMT");
1768 if (broadcast_bssid) {
1769 for (i = 0; i < iface->num_bss; i++)
1770 ieee802_11_mgmt(iface->bss[i], buf, data_len,
1773 ieee802_11_mgmt(hapd, buf, data_len, stype, hfi);
1775 case WLAN_FC_TYPE_CTRL:
1776 /* can only get here with PS-Poll frames */
1777 wpa_printf(MSG_DEBUG, "CTRL");
1778 hostapd_rx_from_unknown_sta(drv->hapd, hdr->addr2);
1780 case WLAN_FC_TYPE_DATA:
1781 hostapd_rx_from_unknown_sta(drv->hapd, hdr->addr2);
1787 static void handle_eapol(int sock, void *eloop_ctx, void *sock_ctx)
1789 struct i802_driver_data *drv = eloop_ctx;
1790 struct hostapd_data *hapd = drv->hapd;
1791 struct sockaddr_ll lladdr;
1792 unsigned char buf[3000];
1794 socklen_t fromlen = sizeof(lladdr);
1796 len = recvfrom(sock, buf, sizeof(buf), 0,
1797 (struct sockaddr *)&lladdr, &fromlen);
1803 if (have_ifidx(drv, lladdr.sll_ifindex))
1804 hostapd_eapol_receive(hapd, lladdr.sll_addr, buf, len);
1808 static void handle_monitor_read(int sock, void *eloop_ctx, void *sock_ctx)
1810 struct i802_driver_data *drv = eloop_ctx;
1812 unsigned char buf[3000];
1813 struct hostapd_data *hapd = drv->hapd;
1814 struct ieee80211_radiotap_iterator iter;
1816 struct hostapd_frame_info hfi;
1817 int injected = 0, failed = 0, msg_type, rxflags = 0;
1819 len = recv(sock, buf, sizeof(buf), 0);
1825 if (ieee80211_radiotap_iterator_init(&iter, (void*)buf, len)) {
1826 printf("received invalid radiotap frame\n");
1830 memset(&hfi, 0, sizeof(hfi));
1833 ret = ieee80211_radiotap_iterator_next(&iter);
1837 printf("received invalid radiotap frame (%d)\n", ret);
1840 switch (iter.this_arg_index) {
1841 case IEEE80211_RADIOTAP_FLAGS:
1842 if (*iter.this_arg & IEEE80211_RADIOTAP_F_FCS)
1845 case IEEE80211_RADIOTAP_RX_FLAGS:
1848 case IEEE80211_RADIOTAP_TX_FLAGS:
1850 failed = le_to_host16((*(uint16_t *) iter.this_arg)) &
1851 IEEE80211_RADIOTAP_F_TX_FAIL;
1853 case IEEE80211_RADIOTAP_DATA_RETRIES:
1855 case IEEE80211_RADIOTAP_CHANNEL:
1856 /* TODO convert from freq/flags to channel number
1861 case IEEE80211_RADIOTAP_RATE:
1862 hfi.datarate = *iter.this_arg * 5;
1864 case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
1865 hfi.ssi_signal = *iter.this_arg;
1870 if (rxflags && injected)
1874 msg_type = ieee80211_msg_normal;
1876 msg_type = ieee80211_msg_tx_callback_fail;
1878 msg_type = ieee80211_msg_tx_callback_ack;
1880 handle_frame(drv, hapd->iface, buf + iter.max_length,
1881 len - iter.max_length, &hfi, msg_type);
1885 static int nl80211_create_monitor_interface(struct i802_driver_data *drv)
1888 struct sockaddr_ll ll;
1892 snprintf(buf, IFNAMSIZ, "mon.%s", drv->iface);
1893 buf[IFNAMSIZ - 1] = '\0';
1895 drv->monitor_ifidx =
1896 nl80211_create_iface(drv, buf, NL80211_IFTYPE_MONITOR, NULL);
1898 if (drv->monitor_ifidx < 0)
1901 if (hostapd_set_iface_flags(drv, buf, 1))
1904 memset(&ll, 0, sizeof(ll));
1905 ll.sll_family = AF_PACKET;
1906 ll.sll_ifindex = drv->monitor_ifidx;
1907 drv->monitor_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
1908 if (drv->monitor_sock < 0) {
1909 perror("socket[PF_PACKET,SOCK_RAW]");
1913 if (bind(drv->monitor_sock, (struct sockaddr *) &ll,
1915 perror("monitor socket bind");
1919 optlen = sizeof(optval);
1922 (drv->monitor_sock, SOL_SOCKET, SO_PRIORITY, &optval, optlen)) {
1923 perror("Failed to set socket priority");
1927 if (eloop_register_read_sock(drv->monitor_sock, handle_monitor_read,
1929 printf("Could not register monitor read socket\n");
1935 nl80211_remove_iface(drv, drv->monitor_ifidx);
1940 static int nl80211_set_master_mode(struct i802_driver_data *drv,
1946 msg = nlmsg_alloc();
1950 genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
1951 0, NL80211_CMD_SET_INTERFACE, 0);
1952 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
1953 if_nametoindex(ifname));
1954 NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_AP);
1956 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
1960 wpa_printf(MSG_ERROR, "Failed to set interface %s to master "
1966 static int i802_init_sockets(struct i802_driver_data *drv, const u8 *bssid)
1969 struct sockaddr_ll addr;
1971 drv->ioctl_sock = -1;
1973 drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
1974 if (drv->ioctl_sock < 0) {
1975 perror("socket[PF_INET,SOCK_DGRAM]");
1979 /* start listening for EAPOL on the default AP interface */
1980 add_ifidx(drv, if_nametoindex(drv->iface));
1982 if (hostapd_set_iface_flags(drv, drv->iface, 0))
1986 os_strlcpy(ifr.ifr_name, drv->iface, IFNAMSIZ);
1987 memcpy(ifr.ifr_hwaddr.sa_data, bssid, ETH_ALEN);
1988 ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
1990 if (ioctl(drv->ioctl_sock, SIOCSIFHWADDR, &ifr)) {
1991 perror("ioctl(SIOCSIFHWADDR)");
1997 * initialise generic netlink and nl80211
1999 drv->nl_cb = nl_cb_alloc(NL_CB_DEFAULT);
2001 printf("Failed to allocate netlink callbacks.\n");
2005 drv->nl_handle = nl_handle_alloc_cb(drv->nl_cb);
2006 if (!drv->nl_handle) {
2007 printf("Failed to allocate netlink handle.\n");
2011 if (genl_connect(drv->nl_handle)) {
2012 printf("Failed to connect to generic netlink.\n");
2016 #ifdef CONFIG_LIBNL20
2017 if (genl_ctrl_alloc_cache(drv->nl_handle, &drv->nl_cache) < 0) {
2018 printf("Failed to allocate generic netlink cache.\n");
2021 #else /* CONFIG_LIBNL20 */
2022 drv->nl_cache = genl_ctrl_alloc_cache(drv->nl_handle);
2023 if (!drv->nl_cache) {
2024 printf("Failed to allocate generic netlink cache.\n");
2027 #endif /* CONFIG_LIBNL20 */
2029 drv->nl80211 = genl_ctrl_search_by_name(drv->nl_cache, "nl80211");
2030 if (!drv->nl80211) {
2031 printf("nl80211 not found.\n");
2035 /* Initialise a monitor interface */
2036 if (nl80211_create_monitor_interface(drv))
2039 if (nl80211_set_master_mode(drv, drv->iface))
2042 if (hostapd_set_iface_flags(drv, drv->iface, 1))
2045 memset(&addr, 0, sizeof(addr));
2046 addr.sll_family = AF_PACKET;
2047 addr.sll_ifindex = ifr.ifr_ifindex;
2048 wpa_printf(MSG_DEBUG, "Opening raw packet socket for ifindex %d",
2051 drv->eapol_sock = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_PAE));
2052 if (drv->eapol_sock < 0) {
2053 perror("socket(PF_PACKET, SOCK_DGRAM, ETH_P_PAE)");
2057 if (eloop_register_read_sock(drv->eapol_sock, handle_eapol, drv, NULL))
2059 printf("Could not register read socket for eapol\n");
2063 memset(&ifr, 0, sizeof(ifr));
2064 os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
2065 if (ioctl(drv->ioctl_sock, SIOCGIFHWADDR, &ifr) != 0) {
2066 perror("ioctl(SIOCGIFHWADDR)");
2070 if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
2071 printf("Invalid HW-addr family 0x%04x\n",
2072 ifr.ifr_hwaddr.sa_family);
2075 memcpy(drv->hapd->own_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
2080 nl80211_remove_iface(drv, drv->monitor_ifidx);
2085 static int i802_get_inact_sec(void *priv, const u8 *addr)
2087 struct hostap_sta_driver_data data;
2090 data.inactive_msec = (unsigned long) -1;
2091 ret = i802_read_sta_data(priv, &data, addr);
2092 if (ret || data.inactive_msec == (unsigned long) -1)
2094 return data.inactive_msec / 1000;
2098 static int i802_sta_clear_stats(void *priv, const u8 *addr)
2108 hostapd_wireless_event_wireless_custom(struct i802_driver_data *drv,
2111 wpa_printf(MSG_DEBUG, "Custom wireless event: '%s'", custom);
2113 if (strncmp(custom, "MLME-MICHAELMICFAILURE.indication", 33) == 0) {
2116 pos = strstr(custom, "addr=");
2118 wpa_printf(MSG_DEBUG,
2119 "MLME-MICHAELMICFAILURE.indication "
2120 "without sender address ignored");
2124 if (hwaddr_aton(pos, addr) == 0) {
2125 ieee80211_michael_mic_failure(drv->hapd, addr, 1);
2127 wpa_printf(MSG_DEBUG,
2128 "MLME-MICHAELMICFAILURE.indication "
2129 "with invalid MAC address");
2135 static void hostapd_wireless_event_wireless(struct i802_driver_data *drv,
2136 char *data, int len)
2138 struct iw_event iwe_buf, *iwe = &iwe_buf;
2139 char *pos, *end, *custom, *buf;
2144 while (pos + IW_EV_LCP_LEN <= end) {
2145 /* Event data may be unaligned, so make a local, aligned copy
2146 * before processing. */
2147 memcpy(&iwe_buf, pos, IW_EV_LCP_LEN);
2148 wpa_printf(MSG_DEBUG, "Wireless event: cmd=0x%x len=%d",
2149 iwe->cmd, iwe->len);
2150 if (iwe->len <= IW_EV_LCP_LEN)
2153 custom = pos + IW_EV_POINT_LEN;
2154 if (drv->we_version > 18 &&
2155 (iwe->cmd == IWEVMICHAELMICFAILURE ||
2156 iwe->cmd == IWEVCUSTOM)) {
2157 /* WE-19 removed the pointer from struct iw_point */
2158 char *dpos = (char *) &iwe_buf.u.data.length;
2159 int dlen = dpos - (char *) &iwe_buf;
2160 memcpy(dpos, pos + IW_EV_LCP_LEN,
2161 sizeof(struct iw_event) - dlen);
2163 memcpy(&iwe_buf, pos, sizeof(struct iw_event));
2164 custom += IW_EV_POINT_OFF;
2169 if (custom + iwe->u.data.length > end)
2171 buf = malloc(iwe->u.data.length + 1);
2174 memcpy(buf, custom, iwe->u.data.length);
2175 buf[iwe->u.data.length] = '\0';
2176 hostapd_wireless_event_wireless_custom(drv, buf);
2186 static void hostapd_wireless_event_rtm_newlink(struct i802_driver_data *drv,
2187 struct nlmsghdr *h, int len)
2189 struct ifinfomsg *ifi;
2190 int attrlen, nlmsg_len, rta_len;
2191 struct rtattr *attr;
2193 if (len < (int) sizeof(*ifi))
2196 ifi = NLMSG_DATA(h);
2198 /* TODO: use ifi->ifi_index to filter out wireless events from other
2201 nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
2203 attrlen = h->nlmsg_len - nlmsg_len;
2207 attr = (struct rtattr *) (((char *) ifi) + nlmsg_len);
2209 rta_len = RTA_ALIGN(sizeof(struct rtattr));
2210 while (RTA_OK(attr, attrlen)) {
2211 if (attr->rta_type == IFLA_WIRELESS) {
2212 hostapd_wireless_event_wireless(
2213 drv, ((char *) attr) + rta_len,
2214 attr->rta_len - rta_len);
2216 attr = RTA_NEXT(attr, attrlen);
2221 static void hostapd_wireless_event_receive(int sock, void *eloop_ctx,
2226 struct sockaddr_nl from;
2229 struct i802_driver_data *drv = eloop_ctx;
2231 fromlen = sizeof(from);
2232 left = recvfrom(sock, buf, sizeof(buf), MSG_DONTWAIT,
2233 (struct sockaddr *) &from, &fromlen);
2235 if (errno != EINTR && errno != EAGAIN)
2236 perror("recvfrom(netlink)");
2240 h = (struct nlmsghdr *) buf;
2241 while (left >= (int) sizeof(*h)) {
2245 plen = len - sizeof(*h);
2246 if (len > left || plen < 0) {
2247 printf("Malformed netlink message: "
2248 "len=%d left=%d plen=%d\n",
2253 switch (h->nlmsg_type) {
2255 hostapd_wireless_event_rtm_newlink(drv, h, plen);
2259 len = NLMSG_ALIGN(len);
2261 h = (struct nlmsghdr *) ((char *) h + len);
2265 printf("%d extra bytes in the end of netlink message\n", left);
2270 static int hostap_get_we_version(struct i802_driver_data *drv)
2272 struct iw_range *range;
2277 drv->we_version = 0;
2280 * Use larger buffer than struct iw_range in order to allow the
2281 * structure to grow in the future.
2283 buflen = sizeof(struct iw_range) + 500;
2284 range = os_zalloc(buflen);
2288 memset(&iwr, 0, sizeof(iwr));
2289 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
2290 iwr.u.data.pointer = (caddr_t) range;
2291 iwr.u.data.length = buflen;
2293 minlen = ((char *) &range->enc_capa) - (char *) range +
2294 sizeof(range->enc_capa);
2296 if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) {
2297 perror("ioctl[SIOCGIWRANGE]");
2300 } else if (iwr.u.data.length >= minlen &&
2301 range->we_version_compiled >= 18) {
2302 wpa_printf(MSG_DEBUG, "SIOCGIWRANGE: WE(compiled)=%d "
2303 "WE(source)=%d enc_capa=0x%x",
2304 range->we_version_compiled,
2305 range->we_version_source,
2307 drv->we_version = range->we_version_compiled;
2315 static int i802_wireless_event_init(void *priv)
2317 struct i802_driver_data *drv = priv;
2319 struct sockaddr_nl local;
2321 hostap_get_we_version(drv);
2323 drv->wext_sock = -1;
2325 s = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
2327 perror("socket(PF_NETLINK,SOCK_RAW,NETLINK_ROUTE)");
2331 memset(&local, 0, sizeof(local));
2332 local.nl_family = AF_NETLINK;
2333 local.nl_groups = RTMGRP_LINK;
2334 if (bind(s, (struct sockaddr *) &local, sizeof(local)) < 0) {
2335 perror("bind(netlink)");
2340 eloop_register_read_sock(s, hostapd_wireless_event_receive, drv,
2348 static void i802_wireless_event_deinit(void *priv)
2350 struct i802_driver_data *drv = priv;
2351 if (drv->wext_sock < 0)
2353 eloop_unregister_read_sock(drv->wext_sock);
2354 close(drv->wext_sock);
2358 static int i802_sta_deauth(void *priv, const u8 *addr, int reason)
2360 struct i802_driver_data *drv = priv;
2361 struct ieee80211_mgmt mgmt;
2363 memset(&mgmt, 0, sizeof(mgmt));
2364 mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
2365 WLAN_FC_STYPE_DEAUTH);
2366 memcpy(mgmt.da, addr, ETH_ALEN);
2367 memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN);
2368 memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN);
2369 mgmt.u.deauth.reason_code = host_to_le16(reason);
2370 return i802_send_mgmt_frame(drv, &mgmt, IEEE80211_HDRLEN +
2371 sizeof(mgmt.u.deauth), 0);
2375 static int i802_sta_disassoc(void *priv, const u8 *addr, int reason)
2377 struct i802_driver_data *drv = priv;
2378 struct ieee80211_mgmt mgmt;
2380 memset(&mgmt, 0, sizeof(mgmt));
2381 mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
2382 WLAN_FC_STYPE_DISASSOC);
2383 memcpy(mgmt.da, addr, ETH_ALEN);
2384 memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN);
2385 memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN);
2386 mgmt.u.disassoc.reason_code = host_to_le16(reason);
2387 return i802_send_mgmt_frame(drv, &mgmt, IEEE80211_HDRLEN +
2388 sizeof(mgmt.u.disassoc), 0);
2392 static void *i802_init_bssid(struct hostapd_data *hapd, const u8 *bssid)
2394 struct i802_driver_data *drv;
2396 drv = os_zalloc(sizeof(struct i802_driver_data));
2398 printf("Could not allocate memory for i802 driver data\n");
2403 memcpy(drv->iface, hapd->conf->iface, sizeof(drv->iface));
2405 drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
2406 drv->if_indices = drv->default_if_indices;
2407 drv->bridge = if_nametoindex(hapd->conf->bridge);
2409 if (i802_init_sockets(drv, bssid))
2420 static void *i802_init(struct hostapd_data *hapd)
2422 return i802_init_bssid(hapd, NULL);
2426 static void i802_deinit(void *priv)
2428 struct i802_driver_data *drv = priv;
2430 if (drv->last_freq_ht) {
2431 /* Clear HT flags from the driver */
2432 struct hostapd_freq_params freq;
2433 os_memset(&freq, 0, sizeof(freq));
2434 freq.freq = drv->last_freq;
2435 i802_set_freq2(priv, &freq);
2438 i802_del_beacon(drv);
2440 /* remove monitor interface */
2441 nl80211_remove_iface(drv, drv->monitor_ifidx);
2443 (void) hostapd_set_iface_flags(drv, drv->iface, 0);
2445 if (drv->monitor_sock >= 0) {
2446 eloop_unregister_read_sock(drv->monitor_sock);
2447 close(drv->monitor_sock);
2449 if (drv->ioctl_sock >= 0)
2450 close(drv->ioctl_sock);
2451 if (drv->eapol_sock >= 0) {
2452 eloop_unregister_read_sock(drv->eapol_sock);
2453 close(drv->eapol_sock);
2456 genl_family_put(drv->nl80211);
2457 nl_cache_free(drv->nl_cache);
2458 nl_handle_destroy(drv->nl_handle);
2459 nl_cb_put(drv->nl_cb);
2461 if (drv->if_indices != drv->default_if_indices)
2462 free(drv->if_indices);
2468 const struct wpa_driver_ops wpa_driver_nl80211_ops = {
2471 .init_bssid = i802_init_bssid,
2472 .deinit = i802_deinit,
2473 .wireless_event_init = i802_wireless_event_init,
2474 .wireless_event_deinit = i802_wireless_event_deinit,
2475 .set_ieee8021x = i802_set_ieee8021x,
2476 .set_privacy = i802_set_privacy,
2477 .set_encryption = i802_set_encryption,
2478 .get_seqnum = i802_get_seqnum,
2479 .flush = i802_flush,
2480 .read_sta_data = i802_read_sta_data,
2481 .send_eapol = i802_send_eapol,
2482 .sta_set_flags = i802_sta_set_flags,
2483 .sta_deauth = i802_sta_deauth,
2484 .sta_disassoc = i802_sta_disassoc,
2485 .sta_remove = i802_sta_remove,
2486 .send_mgmt_frame = i802_send_mgmt_frame,
2487 .sta_add2 = i802_sta_add2,
2488 .get_inact_sec = i802_get_inact_sec,
2489 .sta_clear_stats = i802_sta_clear_stats,
2490 .set_freq2 = i802_set_freq2,
2491 .set_rts = i802_set_rts,
2492 .get_rts = i802_get_rts,
2493 .set_frag = i802_set_frag,
2494 .get_frag = i802_get_frag,
2495 .set_retry = i802_set_retry,
2496 .get_retry = i802_get_retry,
2497 .set_rate_sets = i802_set_rate_sets,
2498 .set_regulatory_domain = i802_set_regulatory_domain,
2499 .set_beacon = i802_set_beacon,
2500 .set_internal_bridge = i802_set_internal_bridge,
2501 .set_beacon_int = i802_set_beacon_int,
2502 .set_dtim_period = i802_set_dtim_period,
2503 .set_cts_protect = i802_set_cts_protect,
2504 .set_preamble = i802_set_preamble,
2505 .set_short_slot_time = i802_set_short_slot_time,
2506 .set_tx_queue_params = i802_set_tx_queue_params,
2507 .bss_add = i802_bss_add,
2508 .bss_remove = i802_bss_remove,
2509 .if_add = i802_if_add,
2510 .if_update = i802_if_update,
2511 .if_remove = i802_if_remove,
2512 .get_hw_feature_data = i802_get_hw_feature_data,
2513 .set_sta_vlan = i802_set_sta_vlan,
2514 .set_country = i802_set_country,