Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1 | /* Copyright (C) 2006, Red Hat, Inc. */ |
| 2 | |
| 3 | #include <linux/bitops.h> |
| 4 | #include <net/ieee80211.h> |
Dan Williams | 3cf20931 | 2007-05-25 17:28:30 -0400 | [diff] [blame] | 5 | #include <linux/etherdevice.h> |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 6 | |
| 7 | #include "assoc.h" |
| 8 | #include "join.h" |
| 9 | #include "decl.h" |
| 10 | #include "hostcmd.h" |
| 11 | #include "host.h" |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 12 | #include "cmd.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 13 | |
| 14 | |
| 15 | static const u8 bssid_any[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
| 16 | static const u8 bssid_off[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
| 17 | |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 18 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 19 | static int assoc_helper_essid(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 20 | struct assoc_request * assoc_req) |
| 21 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 22 | int ret = 0; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 23 | struct bss_descriptor * bss; |
Dan Williams | aeea0ab | 2007-05-25 22:30:48 -0400 | [diff] [blame] | 24 | int channel = -1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 25 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 26 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 27 | |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 28 | /* FIXME: take channel into account when picking SSIDs if a channel |
| 29 | * is set. |
| 30 | */ |
| 31 | |
Dan Williams | aeea0ab | 2007-05-25 22:30:48 -0400 | [diff] [blame] | 32 | if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) |
| 33 | channel = assoc_req->channel; |
| 34 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 35 | lbs_deb_assoc("SSID '%s' requested\n", |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 36 | escape_essid(assoc_req->ssid, assoc_req->ssid_len)); |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 37 | if (assoc_req->mode == IW_MODE_INFRA) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 38 | lbs_send_specific_ssid_scan(priv, assoc_req->ssid, |
Holger Schurig | 6e22a85 | 2007-08-02 13:05:32 -0400 | [diff] [blame] | 39 | assoc_req->ssid_len, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 40 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 41 | bss = lbs_find_ssid_in_list(priv, assoc_req->ssid, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 42 | assoc_req->ssid_len, NULL, IW_MODE_INFRA, channel); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 43 | if (bss != NULL) { |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 44 | memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor)); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 45 | ret = lbs_associate(priv, assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 46 | } else { |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 47 | lbs_deb_assoc("SSID not found; cannot associate\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 48 | } |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 49 | } else if (assoc_req->mode == IW_MODE_ADHOC) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 50 | /* Scan for the network, do not save previous results. Stale |
| 51 | * scan data will cause us to join a non-existant adhoc network |
| 52 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 53 | lbs_send_specific_ssid_scan(priv, assoc_req->ssid, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 54 | assoc_req->ssid_len, 1); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 55 | |
| 56 | /* Search for the requested SSID in the scan table */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 57 | bss = lbs_find_ssid_in_list(priv, assoc_req->ssid, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 58 | assoc_req->ssid_len, NULL, IW_MODE_ADHOC, channel); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 59 | if (bss != NULL) { |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 60 | lbs_deb_assoc("SSID found, will join\n"); |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 61 | memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor)); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 62 | lbs_join_adhoc_network(priv, assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 63 | } else { |
| 64 | /* else send START command */ |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 65 | lbs_deb_assoc("SSID not found, creating adhoc network\n"); |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 66 | memcpy(&assoc_req->bss.ssid, &assoc_req->ssid, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 67 | IW_ESSID_MAX_SIZE); |
| 68 | assoc_req->bss.ssid_len = assoc_req->ssid_len; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 69 | lbs_start_adhoc_network(priv, assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 70 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 71 | } |
| 72 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 73 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 74 | return ret; |
| 75 | } |
| 76 | |
| 77 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 78 | static int assoc_helper_bssid(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 79 | struct assoc_request * assoc_req) |
| 80 | { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 81 | int ret = 0; |
| 82 | struct bss_descriptor * bss; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 83 | DECLARE_MAC_BUF(mac); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 84 | |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 85 | lbs_deb_enter_args(LBS_DEB_ASSOC, "BSSID %s", |
| 86 | print_mac(mac, assoc_req->bssid)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 87 | |
| 88 | /* Search for index position in list for requested MAC */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 89 | bss = lbs_find_bssid_in_list(priv, assoc_req->bssid, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 90 | assoc_req->mode); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 91 | if (bss == NULL) { |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 92 | lbs_deb_assoc("ASSOC: WAP: BSSID %s not found, " |
| 93 | "cannot associate.\n", print_mac(mac, assoc_req->bssid)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 94 | goto out; |
| 95 | } |
| 96 | |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 97 | memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor)); |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 98 | if (assoc_req->mode == IW_MODE_INFRA) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 99 | ret = lbs_associate(priv, assoc_req); |
| 100 | lbs_deb_assoc("ASSOC: lbs_associate(bssid) returned %d\n", ret); |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 101 | } else if (assoc_req->mode == IW_MODE_ADHOC) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 102 | lbs_join_adhoc_network(priv, assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 103 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 104 | |
| 105 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 106 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 107 | return ret; |
| 108 | } |
| 109 | |
| 110 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 111 | static int assoc_helper_associate(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 112 | struct assoc_request * assoc_req) |
| 113 | { |
| 114 | int ret = 0, done = 0; |
| 115 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 116 | lbs_deb_enter(LBS_DEB_ASSOC); |
| 117 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 118 | /* If we're given and 'any' BSSID, try associating based on SSID */ |
| 119 | |
| 120 | if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { |
Dan Williams | 3cf20931 | 2007-05-25 17:28:30 -0400 | [diff] [blame] | 121 | if (compare_ether_addr(bssid_any, assoc_req->bssid) |
| 122 | && compare_ether_addr(bssid_off, assoc_req->bssid)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 123 | ret = assoc_helper_bssid(priv, assoc_req); |
| 124 | done = 1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 125 | } |
| 126 | } |
| 127 | |
| 128 | if (!done && test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { |
| 129 | ret = assoc_helper_essid(priv, assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 130 | } |
| 131 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 132 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 133 | return ret; |
| 134 | } |
| 135 | |
| 136 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 137 | static int assoc_helper_mode(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 138 | struct assoc_request * assoc_req) |
| 139 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 140 | int ret = 0; |
| 141 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 142 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 143 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 144 | if (assoc_req->mode == priv->mode) |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 145 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 146 | |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 147 | if (assoc_req->mode == IW_MODE_INFRA) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 148 | if (priv->psstate != PS_STATE_FULL_POWER) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 149 | lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 150 | priv->psmode = LBS802_11POWERMODECAM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 151 | } |
| 152 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 153 | priv->mode = assoc_req->mode; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 154 | ret = lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 155 | CMD_802_11_SNMP_MIB, |
| 156 | 0, CMD_OPTION_WAITFORRSP, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 157 | OID_802_11_INFRASTRUCTURE_MODE, |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 158 | /* Shoot me now */ (void *) (size_t) assoc_req->mode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 159 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 160 | done: |
| 161 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 162 | return ret; |
| 163 | } |
| 164 | |
| 165 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 166 | static int update_channel(struct lbs_private *priv) |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 167 | { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 168 | int ret; |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 169 | |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 170 | /* the channel in f/w could be out of sync, get the current channel */ |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 171 | lbs_deb_enter(LBS_DEB_ASSOC); |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 172 | |
| 173 | ret = lbs_get_channel(priv); |
| 174 | if (ret > 0) |
| 175 | priv->curbssparams.channel = (u8) ret; |
| 176 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 177 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
| 178 | return ret; |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 179 | } |
| 180 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 181 | void lbs_sync_channel(struct work_struct *work) |
Luis Carlos Cobo Rus | b8bedef | 2007-05-30 12:14:34 -0400 | [diff] [blame] | 182 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 183 | struct lbs_private *priv = container_of(work, struct lbs_private, |
| 184 | sync_channel); |
Luis Carlos Cobo Rus | b8bedef | 2007-05-30 12:14:34 -0400 | [diff] [blame] | 185 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 186 | lbs_deb_enter(LBS_DEB_ASSOC); |
Luis Carlos Cobo Rus | b8bedef | 2007-05-30 12:14:34 -0400 | [diff] [blame] | 187 | if (update_channel(priv) != 0) |
| 188 | lbs_pr_info("Channel synchronization failed."); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 189 | lbs_deb_leave(LBS_DEB_ASSOC); |
Luis Carlos Cobo Rus | b8bedef | 2007-05-30 12:14:34 -0400 | [diff] [blame] | 190 | } |
| 191 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 192 | static int assoc_helper_channel(struct lbs_private *priv, |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 193 | struct assoc_request * assoc_req) |
| 194 | { |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 195 | int ret = 0; |
| 196 | |
| 197 | lbs_deb_enter(LBS_DEB_ASSOC); |
| 198 | |
| 199 | ret = update_channel(priv); |
| 200 | if (ret < 0) { |
| 201 | lbs_deb_assoc("ASSOC: channel: error getting channel."); |
| 202 | } |
| 203 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 204 | if (assoc_req->channel == priv->curbssparams.channel) |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 205 | goto done; |
| 206 | |
| 207 | lbs_deb_assoc("ASSOC: channel: %d -> %d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 208 | priv->curbssparams.channel, assoc_req->channel); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 209 | |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 210 | ret = lbs_set_channel(priv, assoc_req->channel); |
| 211 | if (ret < 0) |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 212 | lbs_deb_assoc("ASSOC: channel: error setting channel."); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 213 | |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 214 | /* FIXME: shouldn't need to grab the channel _again_ after setting |
| 215 | * it since the firmware is supposed to return the new channel, but |
| 216 | * whatever... */ |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 217 | ret = update_channel(priv); |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 218 | if (ret < 0) |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 219 | lbs_deb_assoc("ASSOC: channel: error getting channel."); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 220 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 221 | if (assoc_req->channel != priv->curbssparams.channel) { |
David Woodhouse | 88ae291 | 2007-12-11 19:57:05 -0500 | [diff] [blame^] | 222 | lbs_deb_assoc("ASSOC: channel: failed to update channel to %d\n", |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 223 | assoc_req->channel); |
| 224 | goto done; |
| 225 | } |
| 226 | |
| 227 | if ( assoc_req->secinfo.wep_enabled |
| 228 | && (assoc_req->wep_keys[0].len |
| 229 | || assoc_req->wep_keys[1].len |
| 230 | || assoc_req->wep_keys[2].len |
| 231 | || assoc_req->wep_keys[3].len)) { |
| 232 | /* Make sure WEP keys are re-sent to firmware */ |
| 233 | set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); |
| 234 | } |
| 235 | |
| 236 | /* Must restart/rejoin adhoc networks after channel change */ |
| 237 | set_bit(ASSOC_FLAG_SSID, &assoc_req->flags); |
| 238 | |
| 239 | done: |
| 240 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
| 241 | return ret; |
| 242 | } |
| 243 | |
| 244 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 245 | static int assoc_helper_wep_keys(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 246 | struct assoc_request * assoc_req) |
| 247 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 248 | int i; |
| 249 | int ret = 0; |
| 250 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 251 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 252 | |
| 253 | /* Set or remove WEP keys */ |
| 254 | if ( assoc_req->wep_keys[0].len |
| 255 | || assoc_req->wep_keys[1].len |
| 256 | || assoc_req->wep_keys[2].len |
| 257 | || assoc_req->wep_keys[3].len) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 258 | ret = lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 259 | CMD_802_11_SET_WEP, |
| 260 | CMD_ACT_ADD, |
| 261 | CMD_OPTION_WAITFORRSP, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 262 | 0, assoc_req); |
| 263 | } else { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 264 | ret = lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 265 | CMD_802_11_SET_WEP, |
| 266 | CMD_ACT_REMOVE, |
| 267 | CMD_OPTION_WAITFORRSP, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 268 | 0, NULL); |
| 269 | } |
| 270 | |
| 271 | if (ret) |
| 272 | goto out; |
| 273 | |
| 274 | /* enable/disable the MAC's WEP packet filter */ |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 275 | if (assoc_req->secinfo.wep_enabled) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 276 | priv->currentpacketfilter |= CMD_ACT_MAC_WEP_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 277 | else |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 278 | priv->currentpacketfilter &= ~CMD_ACT_MAC_WEP_ENABLE; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 279 | ret = lbs_set_mac_packet_filter(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 280 | if (ret) |
| 281 | goto out; |
| 282 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 283 | mutex_lock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 284 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 285 | /* Copy WEP keys into priv wep key fields */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 286 | for (i = 0; i < 4; i++) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 287 | memcpy(&priv->wep_keys[i], &assoc_req->wep_keys[i], |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 288 | sizeof(struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 289 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 290 | priv->wep_tx_keyidx = assoc_req->wep_tx_keyidx; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 291 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 292 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 293 | |
| 294 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 295 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 296 | return ret; |
| 297 | } |
| 298 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 299 | static int assoc_helper_secinfo(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 300 | struct assoc_request * assoc_req) |
| 301 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 302 | int ret = 0; |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 303 | u32 do_wpa; |
| 304 | u32 rsn = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 305 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 306 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 307 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 308 | memcpy(&priv->secinfo, &assoc_req->secinfo, |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 309 | sizeof(struct lbs_802_11_security)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 310 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 311 | ret = lbs_set_mac_packet_filter(priv); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 312 | if (ret) |
| 313 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 314 | |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 315 | /* If RSN is already enabled, don't try to enable it again, since |
| 316 | * ENABLE_RSN resets internal state machines and will clobber the |
| 317 | * 4-way WPA handshake. |
| 318 | */ |
| 319 | |
| 320 | /* Get RSN enabled/disabled */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 321 | ret = lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 322 | CMD_802_11_ENABLE_RSN, |
| 323 | CMD_ACT_GET, |
| 324 | CMD_OPTION_WAITFORRSP, |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 325 | 0, &rsn); |
| 326 | if (ret) { |
| 327 | lbs_deb_assoc("Failed to get RSN status: %d", ret); |
| 328 | goto out; |
| 329 | } |
| 330 | |
| 331 | /* Don't re-enable RSN if it's already enabled */ |
| 332 | do_wpa = (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled); |
| 333 | if (do_wpa == rsn) |
| 334 | goto out; |
| 335 | |
| 336 | /* Set RSN enabled/disabled */ |
| 337 | rsn = do_wpa; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 338 | ret = lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 339 | CMD_802_11_ENABLE_RSN, |
| 340 | CMD_ACT_SET, |
| 341 | CMD_OPTION_WAITFORRSP, |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 342 | 0, &rsn); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 343 | |
| 344 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 345 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 346 | return ret; |
| 347 | } |
| 348 | |
| 349 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 350 | static int assoc_helper_wpa_keys(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 351 | struct assoc_request * assoc_req) |
| 352 | { |
| 353 | int ret = 0; |
Dan Williams | 2bcde51 | 2007-10-03 10:37:45 -0400 | [diff] [blame] | 354 | unsigned int flags = assoc_req->flags; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 355 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 356 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 357 | |
Dan Williams | 2bcde51 | 2007-10-03 10:37:45 -0400 | [diff] [blame] | 358 | /* Work around older firmware bug where WPA unicast and multicast |
| 359 | * keys must be set independently. Seen in SDIO parts with firmware |
| 360 | * version 5.0.11p0. |
| 361 | */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 362 | |
Dan Williams | 2bcde51 | 2007-10-03 10:37:45 -0400 | [diff] [blame] | 363 | if (test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) { |
| 364 | clear_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 365 | ret = lbs_prepare_and_send_command(priv, |
Dan Williams | 2bcde51 | 2007-10-03 10:37:45 -0400 | [diff] [blame] | 366 | CMD_802_11_KEY_MATERIAL, |
| 367 | CMD_ACT_SET, |
| 368 | CMD_OPTION_WAITFORRSP, |
| 369 | 0, assoc_req); |
| 370 | assoc_req->flags = flags; |
| 371 | } |
| 372 | |
| 373 | if (ret) |
| 374 | goto out; |
| 375 | |
| 376 | if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) { |
| 377 | clear_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); |
| 378 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 379 | ret = lbs_prepare_and_send_command(priv, |
Dan Williams | 2bcde51 | 2007-10-03 10:37:45 -0400 | [diff] [blame] | 380 | CMD_802_11_KEY_MATERIAL, |
| 381 | CMD_ACT_SET, |
| 382 | CMD_OPTION_WAITFORRSP, |
| 383 | 0, assoc_req); |
| 384 | assoc_req->flags = flags; |
| 385 | } |
| 386 | |
| 387 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 388 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 389 | return ret; |
| 390 | } |
| 391 | |
| 392 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 393 | static int assoc_helper_wpa_ie(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 394 | struct assoc_request * assoc_req) |
| 395 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 396 | int ret = 0; |
| 397 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 398 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 399 | |
| 400 | if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 401 | memcpy(&priv->wpa_ie, &assoc_req->wpa_ie, assoc_req->wpa_ie_len); |
| 402 | priv->wpa_ie_len = assoc_req->wpa_ie_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 403 | } else { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 404 | memset(&priv->wpa_ie, 0, MAX_WPA_IE_LEN); |
| 405 | priv->wpa_ie_len = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 406 | } |
| 407 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 408 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 409 | return ret; |
| 410 | } |
| 411 | |
| 412 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 413 | static int should_deauth_infrastructure(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 414 | struct assoc_request * assoc_req) |
| 415 | { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 416 | int ret = 0; |
| 417 | |
| 418 | lbs_deb_enter(LBS_DEB_ASSOC); |
| 419 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 420 | if (priv->connect_status != LBS_CONNECTED) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 421 | return 0; |
| 422 | |
| 423 | if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 424 | lbs_deb_assoc("Deauthenticating due to new SSID\n"); |
| 425 | ret = 1; |
| 426 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 430 | if (priv->secinfo.auth_mode != assoc_req->secinfo.auth_mode) { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 431 | lbs_deb_assoc("Deauthenticating due to new security\n"); |
| 432 | ret = 1; |
| 433 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 434 | } |
| 435 | } |
| 436 | |
| 437 | if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 438 | lbs_deb_assoc("Deauthenticating due to new BSSID\n"); |
| 439 | ret = 1; |
| 440 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 441 | } |
| 442 | |
Luis Carlos Cobo Rus | fff47f1 | 2007-05-30 12:16:13 -0400 | [diff] [blame] | 443 | if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 444 | lbs_deb_assoc("Deauthenticating due to channel switch\n"); |
| 445 | ret = 1; |
| 446 | goto out; |
Luis Carlos Cobo Rus | fff47f1 | 2007-05-30 12:16:13 -0400 | [diff] [blame] | 447 | } |
| 448 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 449 | /* FIXME: deal with 'auto' mode somehow */ |
| 450 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 451 | if (assoc_req->mode != IW_MODE_INFRA) { |
| 452 | lbs_deb_assoc("Deauthenticating due to leaving " |
| 453 | "infra mode\n"); |
| 454 | ret = 1; |
| 455 | goto out; |
| 456 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 457 | } |
| 458 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 459 | out: |
| 460 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 461 | return 0; |
| 462 | } |
| 463 | |
| 464 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 465 | static int should_stop_adhoc(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 466 | struct assoc_request * assoc_req) |
| 467 | { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 468 | lbs_deb_enter(LBS_DEB_ASSOC); |
| 469 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 470 | if (priv->connect_status != LBS_CONNECTED) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 471 | return 0; |
| 472 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 473 | if (lbs_ssid_cmp(priv->curbssparams.ssid, |
| 474 | priv->curbssparams.ssid_len, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 475 | assoc_req->ssid, assoc_req->ssid_len) != 0) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 476 | return 1; |
| 477 | |
| 478 | /* FIXME: deal with 'auto' mode somehow */ |
| 479 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 480 | if (assoc_req->mode != IW_MODE_ADHOC) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 481 | return 1; |
| 482 | } |
| 483 | |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 484 | if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 485 | if (assoc_req->channel != priv->curbssparams.channel) |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 486 | return 1; |
| 487 | } |
| 488 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 489 | lbs_deb_leave(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 490 | return 0; |
| 491 | } |
| 492 | |
| 493 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 494 | void lbs_association_worker(struct work_struct *work) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 495 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 496 | struct lbs_private *priv = container_of(work, struct lbs_private, |
| 497 | assoc_work.work); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 498 | struct assoc_request * assoc_req = NULL; |
| 499 | int ret = 0; |
| 500 | int find_any_ssid = 0; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 501 | DECLARE_MAC_BUF(mac); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 502 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 503 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 504 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 505 | mutex_lock(&priv->lock); |
| 506 | assoc_req = priv->pending_assoc_req; |
| 507 | priv->pending_assoc_req = NULL; |
| 508 | priv->in_progress_assoc_req = assoc_req; |
| 509 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 510 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 511 | if (!assoc_req) |
| 512 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 513 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 514 | lbs_deb_assoc( |
| 515 | "Association Request:\n" |
| 516 | " flags: 0x%08lx\n" |
| 517 | " SSID: '%s'\n" |
| 518 | " chann: %d\n" |
| 519 | " band: %d\n" |
| 520 | " mode: %d\n" |
| 521 | " BSSID: %s\n" |
| 522 | " secinfo: %s%s%s\n" |
| 523 | " auth_mode: %d\n", |
| 524 | assoc_req->flags, |
| 525 | escape_essid(assoc_req->ssid, assoc_req->ssid_len), |
| 526 | assoc_req->channel, assoc_req->band, assoc_req->mode, |
| 527 | print_mac(mac, assoc_req->bssid), |
| 528 | assoc_req->secinfo.WPAenabled ? " WPA" : "", |
| 529 | assoc_req->secinfo.WPA2enabled ? " WPA2" : "", |
| 530 | assoc_req->secinfo.wep_enabled ? " WEP" : "", |
| 531 | assoc_req->secinfo.auth_mode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 532 | |
| 533 | /* If 'any' SSID was specified, find an SSID to associate with */ |
| 534 | if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags) |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 535 | && !assoc_req->ssid_len) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 536 | find_any_ssid = 1; |
| 537 | |
| 538 | /* But don't use 'any' SSID if there's a valid locked BSSID to use */ |
| 539 | if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { |
Dan Williams | 3cf20931 | 2007-05-25 17:28:30 -0400 | [diff] [blame] | 540 | if (compare_ether_addr(assoc_req->bssid, bssid_any) |
| 541 | && compare_ether_addr(assoc_req->bssid, bssid_off)) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 542 | find_any_ssid = 0; |
| 543 | } |
| 544 | |
| 545 | if (find_any_ssid) { |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 546 | u8 new_mode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 547 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 548 | ret = lbs_find_best_network_ssid(priv, assoc_req->ssid, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 549 | &assoc_req->ssid_len, assoc_req->mode, &new_mode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 550 | if (ret) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 551 | lbs_deb_assoc("Could not find best network\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 552 | ret = -ENETUNREACH; |
| 553 | goto out; |
| 554 | } |
| 555 | |
| 556 | /* Ensure we switch to the mode of the AP */ |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 557 | if (assoc_req->mode == IW_MODE_AUTO) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 558 | set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); |
| 559 | assoc_req->mode = new_mode; |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | /* |
| 564 | * Check if the attributes being changing require deauthentication |
| 565 | * from the currently associated infrastructure access point. |
| 566 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 567 | if (priv->mode == IW_MODE_INFRA) { |
| 568 | if (should_deauth_infrastructure(priv, assoc_req)) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 569 | ret = lbs_send_deauthentication(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 570 | if (ret) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 571 | lbs_deb_assoc("Deauthentication due to new " |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 572 | "configuration request failed: %d\n", |
| 573 | ret); |
| 574 | } |
| 575 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 576 | } else if (priv->mode == IW_MODE_ADHOC) { |
| 577 | if (should_stop_adhoc(priv, assoc_req)) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 578 | ret = lbs_stop_adhoc_network(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 579 | if (ret) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 580 | lbs_deb_assoc("Teardown of AdHoc network due to " |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 581 | "new configuration request failed: %d\n", |
| 582 | ret); |
| 583 | } |
| 584 | |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | /* Send the various configuration bits to the firmware */ |
| 589 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { |
| 590 | ret = assoc_helper_mode(priv, assoc_req); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 591 | if (ret) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 592 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 593 | } |
| 594 | |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 595 | if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) { |
| 596 | ret = assoc_helper_channel(priv, assoc_req); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 597 | if (ret) |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 598 | goto out; |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 599 | } |
| 600 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 601 | if ( test_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags) |
| 602 | || test_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags)) { |
| 603 | ret = assoc_helper_wep_keys(priv, assoc_req); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 604 | if (ret) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 605 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { |
| 609 | ret = assoc_helper_secinfo(priv, assoc_req); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 610 | if (ret) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 611 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | if (test_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags)) { |
| 615 | ret = assoc_helper_wpa_ie(priv, assoc_req); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 616 | if (ret) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 617 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags) |
| 621 | || test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) { |
| 622 | ret = assoc_helper_wpa_keys(priv, assoc_req); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 623 | if (ret) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 624 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | /* SSID/BSSID should be the _last_ config option set, because they |
| 628 | * trigger the association attempt. |
| 629 | */ |
| 630 | if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags) |
| 631 | || test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { |
| 632 | int success = 1; |
| 633 | |
| 634 | ret = assoc_helper_associate(priv, assoc_req); |
| 635 | if (ret) { |
Holger Schurig | 9184346 | 2007-11-28 14:05:02 +0100 | [diff] [blame] | 636 | lbs_deb_assoc("ASSOC: association unsuccessful: %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 637 | ret); |
| 638 | success = 0; |
| 639 | } |
| 640 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 641 | if (priv->connect_status != LBS_CONNECTED) { |
Holger Schurig | 9184346 | 2007-11-28 14:05:02 +0100 | [diff] [blame] | 642 | lbs_deb_assoc("ASSOC: association unsuccessful, " |
| 643 | "not connected\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 644 | success = 0; |
| 645 | } |
| 646 | |
| 647 | if (success) { |
Holger Schurig | 9184346 | 2007-11-28 14:05:02 +0100 | [diff] [blame] | 648 | lbs_deb_assoc("ASSOC: associated to '%s', %s\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 649 | escape_essid(priv->curbssparams.ssid, |
| 650 | priv->curbssparams.ssid_len), |
| 651 | print_mac(mac, priv->curbssparams.bssid)); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 652 | lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 653 | CMD_802_11_RSSI, |
| 654 | 0, CMD_OPTION_WAITFORRSP, 0, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 655 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 656 | lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 657 | CMD_802_11_GET_LOG, |
| 658 | 0, CMD_OPTION_WAITFORRSP, 0, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 659 | } else { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 660 | ret = -1; |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | out: |
| 665 | if (ret) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 666 | lbs_deb_assoc("ASSOC: reconfiguration attempt unsuccessful: %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 667 | ret); |
| 668 | } |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 669 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 670 | mutex_lock(&priv->lock); |
| 671 | priv->in_progress_assoc_req = NULL; |
| 672 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 673 | kfree(assoc_req); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 674 | |
| 675 | done: |
| 676 | lbs_deb_leave(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | |
| 680 | /* |
| 681 | * Caller MUST hold any necessary locks |
| 682 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 683 | struct assoc_request *lbs_get_association_request(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 684 | { |
| 685 | struct assoc_request * assoc_req; |
| 686 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 687 | lbs_deb_enter(LBS_DEB_ASSOC); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 688 | if (!priv->pending_assoc_req) { |
| 689 | priv->pending_assoc_req = kzalloc(sizeof(struct assoc_request), |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 690 | GFP_KERNEL); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 691 | if (!priv->pending_assoc_req) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 692 | lbs_pr_info("Not enough memory to allocate association" |
| 693 | " request!\n"); |
| 694 | return NULL; |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | /* Copy current configuration attributes to the association request, |
| 699 | * but don't overwrite any that are already set. |
| 700 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 701 | assoc_req = priv->pending_assoc_req; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 702 | if (!test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 703 | memcpy(&assoc_req->ssid, &priv->curbssparams.ssid, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 704 | IW_ESSID_MAX_SIZE); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 705 | assoc_req->ssid_len = priv->curbssparams.ssid_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 706 | } |
| 707 | |
| 708 | if (!test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 709 | assoc_req->channel = priv->curbssparams.channel; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 710 | |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 711 | if (!test_bit(ASSOC_FLAG_BAND, &assoc_req->flags)) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 712 | assoc_req->band = priv->curbssparams.band; |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 713 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 714 | if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 715 | assoc_req->mode = priv->mode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 716 | |
| 717 | if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 718 | memcpy(&assoc_req->bssid, priv->curbssparams.bssid, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 719 | ETH_ALEN); |
| 720 | } |
| 721 | |
| 722 | if (!test_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags)) { |
| 723 | int i; |
| 724 | for (i = 0; i < 4; i++) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 725 | memcpy(&assoc_req->wep_keys[i], &priv->wep_keys[i], |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 726 | sizeof(struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 727 | } |
| 728 | } |
| 729 | |
| 730 | if (!test_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags)) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 731 | assoc_req->wep_tx_keyidx = priv->wep_tx_keyidx; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 732 | |
| 733 | if (!test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 734 | memcpy(&assoc_req->wpa_mcast_key, &priv->wpa_mcast_key, |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 735 | sizeof(struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | if (!test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 739 | memcpy(&assoc_req->wpa_unicast_key, &priv->wpa_unicast_key, |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 740 | sizeof(struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 741 | } |
| 742 | |
| 743 | if (!test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 744 | memcpy(&assoc_req->secinfo, &priv->secinfo, |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 745 | sizeof(struct lbs_802_11_security)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | if (!test_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 749 | memcpy(&assoc_req->wpa_ie, &priv->wpa_ie, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 750 | MAX_WPA_IE_LEN); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 751 | assoc_req->wpa_ie_len = priv->wpa_ie_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 752 | } |
| 753 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 754 | lbs_deb_leave(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 755 | return assoc_req; |
| 756 | } |