Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1 | /* Copyright (C) 2006, Red Hat, Inc. */ |
| 2 | |
John W. Linville | 7e272fc | 2008-09-24 18:13:14 -0400 | [diff] [blame] | 3 | #include <linux/types.h> |
Dan Williams | 3cf2093 | 2007-05-25 17:28:30 -0400 | [diff] [blame] | 4 | #include <linux/etherdevice.h> |
Johannes Berg | 2c706002 | 2008-10-30 22:09:54 +0100 | [diff] [blame] | 5 | #include <linux/ieee80211.h> |
| 6 | #include <linux/if_arp.h> |
John W. Linville | 7e272fc | 2008-09-24 18:13:14 -0400 | [diff] [blame] | 7 | #include <net/lib80211.h> |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 8 | |
| 9 | #include "assoc.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 10 | #include "decl.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 11 | #include "host.h" |
Holger Schurig | 245bf20 | 2008-04-02 16:27:42 +0200 | [diff] [blame] | 12 | #include "scan.h" |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 13 | #include "cmd.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 14 | |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 15 | static int lbs_adhoc_post(struct lbs_private *priv, struct cmd_header *resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 16 | |
Ihar Hrachyshka | 5a6e043 | 2008-01-25 14:15:00 +0100 | [diff] [blame] | 17 | static const u8 bssid_any[ETH_ALEN] __attribute__ ((aligned (2))) = |
| 18 | { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
| 19 | static const u8 bssid_off[ETH_ALEN] __attribute__ ((aligned (2))) = |
| 20 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 21 | |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 22 | /* The firmware needs certain bits masked out of the beacon-derviced capability |
| 23 | * field when associating/joining to BSSs. |
| 24 | */ |
| 25 | #define CAPINFO_MASK (~(0xda00)) |
| 26 | |
| 27 | |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 28 | /** |
| 29 | * @brief This function finds common rates between rates and card rates. |
| 30 | * |
| 31 | * It will fill common rates in rates as output if found. |
| 32 | * |
| 33 | * NOTE: Setting the MSB of the basic rates need to be taken |
| 34 | * care, either before or after calling this function |
| 35 | * |
| 36 | * @param priv A pointer to struct lbs_private structure |
| 37 | * @param rates the buffer which keeps input and output |
| 38 | * @param rates_size the size of rate1 buffer; new size of buffer on return |
| 39 | * |
| 40 | * @return 0 on success, or -1 on error |
| 41 | */ |
| 42 | static int get_common_rates(struct lbs_private *priv, |
| 43 | u8 *rates, |
| 44 | u16 *rates_size) |
| 45 | { |
| 46 | u8 *card_rates = lbs_bg_rates; |
| 47 | size_t num_card_rates = sizeof(lbs_bg_rates); |
| 48 | int ret = 0, i, j; |
| 49 | u8 tmp[30]; |
| 50 | size_t tmp_size = 0; |
| 51 | |
| 52 | /* For each rate in card_rates that exists in rate1, copy to tmp */ |
| 53 | for (i = 0; card_rates[i] && (i < num_card_rates); i++) { |
| 54 | for (j = 0; rates[j] && (j < *rates_size); j++) { |
| 55 | if (rates[j] == card_rates[i]) |
| 56 | tmp[tmp_size++] = card_rates[i]; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | lbs_deb_hex(LBS_DEB_JOIN, "AP rates ", rates, *rates_size); |
| 61 | lbs_deb_hex(LBS_DEB_JOIN, "card rates ", card_rates, num_card_rates); |
| 62 | lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size); |
| 63 | lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate); |
| 64 | |
| 65 | if (!priv->enablehwauto) { |
| 66 | for (i = 0; i < tmp_size; i++) { |
| 67 | if (tmp[i] == priv->cur_rate) |
| 68 | goto done; |
| 69 | } |
| 70 | lbs_pr_alert("Previously set fixed data rate %#x isn't " |
| 71 | "compatible with the network.\n", priv->cur_rate); |
| 72 | ret = -1; |
| 73 | goto done; |
| 74 | } |
| 75 | ret = 0; |
| 76 | |
| 77 | done: |
| 78 | memset(rates, 0, *rates_size); |
| 79 | *rates_size = min_t(int, tmp_size, *rates_size); |
| 80 | memcpy(rates, tmp, *rates_size); |
| 81 | return ret; |
| 82 | } |
| 83 | |
| 84 | |
| 85 | /** |
| 86 | * @brief Sets the MSB on basic rates as the firmware requires |
| 87 | * |
| 88 | * Scan through an array and set the MSB for basic data rates. |
| 89 | * |
| 90 | * @param rates buffer of data rates |
| 91 | * @param len size of buffer |
| 92 | */ |
| 93 | static void lbs_set_basic_rate_flags(u8 *rates, size_t len) |
| 94 | { |
| 95 | int i; |
| 96 | |
| 97 | for (i = 0; i < len; i++) { |
| 98 | if (rates[i] == 0x02 || rates[i] == 0x04 || |
| 99 | rates[i] == 0x0b || rates[i] == 0x16) |
| 100 | rates[i] |= 0x80; |
| 101 | } |
| 102 | } |
| 103 | |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 104 | |
| 105 | /** |
| 106 | * @brief Associate to a specific BSS discovered in a scan |
| 107 | * |
| 108 | * @param priv A pointer to struct lbs_private structure |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 109 | * @param assoc_req The association request describing the BSS to associate with |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 110 | * |
| 111 | * @return 0-success, otherwise fail |
| 112 | */ |
| 113 | static int lbs_associate(struct lbs_private *priv, |
| 114 | struct assoc_request *assoc_req) |
| 115 | { |
| 116 | int ret; |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 117 | u8 preamble = RADIO_PREAMBLE_LONG; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 118 | |
| 119 | lbs_deb_enter(LBS_DEB_ASSOC); |
| 120 | |
| 121 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_AUTHENTICATE, |
| 122 | 0, CMD_OPTION_WAITFORRSP, |
| 123 | 0, assoc_req->bss.bssid); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 124 | if (ret) |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 125 | goto out; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 126 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 127 | /* Use short preamble only when both the BSS and firmware support it */ |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 128 | if ((priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) && |
| 129 | (assoc_req->bss.capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 130 | preamble = RADIO_PREAMBLE_SHORT; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 131 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 132 | ret = lbs_set_radio(priv, preamble, 1); |
| 133 | if (ret) |
| 134 | goto out; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 135 | |
| 136 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_ASSOCIATE, |
| 137 | 0, CMD_OPTION_WAITFORRSP, 0, assoc_req); |
| 138 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 139 | out: |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 140 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
| 141 | return ret; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * @brief Join an adhoc network found in a previous scan |
| 146 | * |
| 147 | * @param priv A pointer to struct lbs_private structure |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 148 | * @param assoc_req The association request describing the BSS to join |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 149 | * |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 150 | * @return 0 on success, error on failure |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 151 | */ |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 152 | static int lbs_adhoc_join(struct lbs_private *priv, |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 153 | struct assoc_request *assoc_req) |
| 154 | { |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 155 | struct cmd_ds_802_11_ad_hoc_join cmd; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 156 | struct bss_descriptor *bss = &assoc_req->bss; |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 157 | u8 preamble = RADIO_PREAMBLE_LONG; |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 158 | DECLARE_SSID_BUF(ssid); |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 159 | u16 ratesize = 0; |
| 160 | int ret = 0; |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 161 | |
| 162 | lbs_deb_enter(LBS_DEB_ASSOC); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 163 | |
| 164 | lbs_deb_join("current SSID '%s', ssid length %u\n", |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 165 | print_ssid(ssid, priv->curbssparams.ssid, |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 166 | priv->curbssparams.ssid_len), |
| 167 | priv->curbssparams.ssid_len); |
| 168 | lbs_deb_join("requested ssid '%s', ssid length %u\n", |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 169 | print_ssid(ssid, bss->ssid, bss->ssid_len), |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 170 | bss->ssid_len); |
| 171 | |
| 172 | /* check if the requested SSID is already joined */ |
| 173 | if (priv->curbssparams.ssid_len && |
| 174 | !lbs_ssid_cmp(priv->curbssparams.ssid, |
| 175 | priv->curbssparams.ssid_len, |
| 176 | bss->ssid, bss->ssid_len) && |
| 177 | (priv->mode == IW_MODE_ADHOC) && |
| 178 | (priv->connect_status == LBS_CONNECTED)) { |
| 179 | union iwreq_data wrqu; |
| 180 | |
| 181 | lbs_deb_join("ADHOC_J_CMD: New ad-hoc SSID is the same as " |
| 182 | "current, not attempting to re-join"); |
| 183 | |
| 184 | /* Send the re-association event though, because the association |
| 185 | * request really was successful, even if just a null-op. |
| 186 | */ |
| 187 | memset(&wrqu, 0, sizeof(wrqu)); |
| 188 | memcpy(wrqu.ap_addr.sa_data, priv->curbssparams.bssid, |
| 189 | ETH_ALEN); |
| 190 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 191 | wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); |
| 192 | goto out; |
| 193 | } |
| 194 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 195 | /* Use short preamble only when both the BSS and firmware support it */ |
| 196 | if ((priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) && |
| 197 | (bss->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) { |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 198 | lbs_deb_join("AdhocJoin: Short preamble\n"); |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 199 | preamble = RADIO_PREAMBLE_SHORT; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 200 | } |
| 201 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 202 | ret = lbs_set_radio(priv, preamble, 1); |
| 203 | if (ret) |
| 204 | goto out; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 205 | |
| 206 | lbs_deb_join("AdhocJoin: channel = %d\n", assoc_req->channel); |
| 207 | lbs_deb_join("AdhocJoin: band = %c\n", assoc_req->band); |
| 208 | |
| 209 | priv->adhoccreate = 0; |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 210 | priv->curbssparams.channel = bss->channel; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 211 | |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 212 | /* Build the join command */ |
| 213 | memset(&cmd, 0, sizeof(cmd)); |
| 214 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 215 | |
| 216 | cmd.bss.type = CMD_BSS_TYPE_IBSS; |
| 217 | cmd.bss.beaconperiod = cpu_to_le16(bss->beaconperiod); |
| 218 | |
| 219 | memcpy(&cmd.bss.bssid, &bss->bssid, ETH_ALEN); |
| 220 | memcpy(&cmd.bss.ssid, &bss->ssid, bss->ssid_len); |
| 221 | |
Dan Williams | 5fd164e | 2009-05-22 20:01:21 -0400 | [diff] [blame] | 222 | memcpy(&cmd.bss.ds, &bss->phy.ds, sizeof(struct ieee_ie_ds_param_set)); |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 223 | |
Dan Williams | 5fd164e | 2009-05-22 20:01:21 -0400 | [diff] [blame] | 224 | memcpy(&cmd.bss.ibss, &bss->ss.ibss, |
| 225 | sizeof(struct ieee_ie_ibss_param_set)); |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 226 | |
| 227 | cmd.bss.capability = cpu_to_le16(bss->capability & CAPINFO_MASK); |
| 228 | lbs_deb_join("ADHOC_J_CMD: tmpcap=%4X CAPINFO_MASK=%4X\n", |
| 229 | bss->capability, CAPINFO_MASK); |
| 230 | |
| 231 | /* information on BSSID descriptor passed to FW */ |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 232 | lbs_deb_join("ADHOC_J_CMD: BSSID = %pM, SSID = '%s'\n", |
| 233 | cmd.bss.bssid, cmd.bss.ssid); |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 234 | |
| 235 | /* Only v8 and below support setting these */ |
| 236 | if (priv->fwrelease < 0x09000000) { |
| 237 | /* failtimeout */ |
| 238 | cmd.failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT); |
| 239 | /* probedelay */ |
| 240 | cmd.probedelay = cpu_to_le16(CMD_SCAN_PROBE_DELAY_TIME); |
| 241 | } |
| 242 | |
| 243 | /* Copy Data rates from the rates recorded in scan response */ |
| 244 | memset(cmd.bss.rates, 0, sizeof(cmd.bss.rates)); |
| 245 | ratesize = min_t(u16, sizeof(cmd.bss.rates), MAX_RATES); |
| 246 | memcpy(cmd.bss.rates, bss->rates, ratesize); |
| 247 | if (get_common_rates(priv, cmd.bss.rates, &ratesize)) { |
| 248 | lbs_deb_join("ADHOC_JOIN: get_common_rates returned error.\n"); |
| 249 | ret = -1; |
| 250 | goto out; |
| 251 | } |
| 252 | |
| 253 | /* Copy the ad-hoc creation rates into Current BSS state structure */ |
| 254 | memset(&priv->curbssparams.rates, 0, sizeof(priv->curbssparams.rates)); |
| 255 | memcpy(&priv->curbssparams.rates, cmd.bss.rates, ratesize); |
| 256 | |
| 257 | /* Set MSB on basic rates as the firmware requires, but _after_ |
| 258 | * copying to current bss rates. |
| 259 | */ |
| 260 | lbs_set_basic_rate_flags(cmd.bss.rates, ratesize); |
| 261 | |
Dan Williams | 5fd164e | 2009-05-22 20:01:21 -0400 | [diff] [blame] | 262 | cmd.bss.ibss.atimwindow = bss->atimwindow; |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 263 | |
| 264 | if (assoc_req->secinfo.wep_enabled) { |
| 265 | u16 tmp = le16_to_cpu(cmd.bss.capability); |
| 266 | tmp |= WLAN_CAPABILITY_PRIVACY; |
| 267 | cmd.bss.capability = cpu_to_le16(tmp); |
| 268 | } |
| 269 | |
| 270 | if (priv->psmode == LBS802_11POWERMODEMAX_PSP) { |
| 271 | __le32 local_ps_mode = cpu_to_le32(LBS802_11POWERMODECAM); |
| 272 | |
| 273 | /* wake up first */ |
| 274 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_PS_MODE, |
| 275 | CMD_ACT_SET, 0, 0, |
| 276 | &local_ps_mode); |
| 277 | if (ret) { |
| 278 | ret = -1; |
| 279 | goto out; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | if (lbs_parse_dnld_countryinfo_11d(priv, bss)) { |
| 284 | ret = -1; |
| 285 | goto out; |
| 286 | } |
| 287 | |
| 288 | ret = lbs_cmd_with_response(priv, CMD_802_11_AD_HOC_JOIN, &cmd); |
| 289 | if (ret == 0) |
| 290 | ret = lbs_adhoc_post(priv, (struct cmd_header *) &cmd); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 291 | |
| 292 | out: |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 293 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 294 | return ret; |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * @brief Start an Adhoc Network |
| 299 | * |
| 300 | * @param priv A pointer to struct lbs_private structure |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 301 | * @param assoc_req The association request describing the BSS to start |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 302 | * |
| 303 | * @return 0 on success, error on failure |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 304 | */ |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 305 | static int lbs_adhoc_start(struct lbs_private *priv, |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 306 | struct assoc_request *assoc_req) |
| 307 | { |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 308 | struct cmd_ds_802_11_ad_hoc_start cmd; |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 309 | u8 preamble = RADIO_PREAMBLE_LONG; |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 310 | size_t ratesize = 0; |
| 311 | u16 tmpcap = 0; |
| 312 | int ret = 0; |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 313 | DECLARE_SSID_BUF(ssid); |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 314 | |
| 315 | lbs_deb_enter(LBS_DEB_ASSOC); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 316 | |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 317 | if (priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) { |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 318 | lbs_deb_join("ADHOC_START: Will use short preamble\n"); |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 319 | preamble = RADIO_PREAMBLE_SHORT; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 320 | } |
| 321 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 322 | ret = lbs_set_radio(priv, preamble, 1); |
| 323 | if (ret) |
| 324 | goto out; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 325 | |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 326 | /* Build the start command */ |
| 327 | memset(&cmd, 0, sizeof(cmd)); |
| 328 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 329 | |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 330 | memcpy(cmd.ssid, assoc_req->ssid, assoc_req->ssid_len); |
| 331 | |
| 332 | lbs_deb_join("ADHOC_START: SSID '%s', ssid length %u\n", |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 333 | print_ssid(ssid, assoc_req->ssid, assoc_req->ssid_len), |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 334 | assoc_req->ssid_len); |
| 335 | |
| 336 | cmd.bsstype = CMD_BSS_TYPE_IBSS; |
| 337 | |
| 338 | if (priv->beacon_period == 0) |
| 339 | priv->beacon_period = MRVDRV_BEACON_INTERVAL; |
| 340 | cmd.beaconperiod = cpu_to_le16(priv->beacon_period); |
| 341 | |
| 342 | WARN_ON(!assoc_req->channel); |
| 343 | |
| 344 | /* set Physical parameter set */ |
Dan Williams | 75b6a61 | 2009-05-22 20:03:09 -0400 | [diff] [blame^] | 345 | cmd.ds.header.id = WLAN_EID_DS_PARAMS; |
| 346 | cmd.ds.header.len = 1; |
Dan Williams | 5fd164e | 2009-05-22 20:01:21 -0400 | [diff] [blame] | 347 | cmd.ds.channel = assoc_req->channel; |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 348 | |
| 349 | /* set IBSS parameter set */ |
Dan Williams | 75b6a61 | 2009-05-22 20:03:09 -0400 | [diff] [blame^] | 350 | cmd.ibss.header.id = WLAN_EID_IBSS_PARAMS; |
| 351 | cmd.ibss.header.len = 2; |
Dan Williams | 5fd164e | 2009-05-22 20:01:21 -0400 | [diff] [blame] | 352 | cmd.ibss.atimwindow = cpu_to_le16(0); |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 353 | |
| 354 | /* set capability info */ |
| 355 | tmpcap = WLAN_CAPABILITY_IBSS; |
| 356 | if (assoc_req->secinfo.wep_enabled) { |
| 357 | lbs_deb_join("ADHOC_START: WEP enabled, setting privacy on\n"); |
| 358 | tmpcap |= WLAN_CAPABILITY_PRIVACY; |
| 359 | } else |
| 360 | lbs_deb_join("ADHOC_START: WEP disabled, setting privacy off\n"); |
| 361 | |
| 362 | cmd.capability = cpu_to_le16(tmpcap); |
| 363 | |
| 364 | /* Only v8 and below support setting probe delay */ |
| 365 | if (priv->fwrelease < 0x09000000) |
| 366 | cmd.probedelay = cpu_to_le16(CMD_SCAN_PROBE_DELAY_TIME); |
| 367 | |
| 368 | ratesize = min(sizeof(cmd.rates), sizeof(lbs_bg_rates)); |
| 369 | memcpy(cmd.rates, lbs_bg_rates, ratesize); |
| 370 | |
| 371 | /* Copy the ad-hoc creating rates into Current BSS state structure */ |
| 372 | memset(&priv->curbssparams.rates, 0, sizeof(priv->curbssparams.rates)); |
| 373 | memcpy(&priv->curbssparams.rates, &cmd.rates, ratesize); |
| 374 | |
| 375 | /* Set MSB on basic rates as the firmware requires, but _after_ |
| 376 | * copying to current bss rates. |
| 377 | */ |
| 378 | lbs_set_basic_rate_flags(cmd.rates, ratesize); |
| 379 | |
| 380 | lbs_deb_join("ADHOC_START: rates=%02x %02x %02x %02x\n", |
| 381 | cmd.rates[0], cmd.rates[1], cmd.rates[2], cmd.rates[3]); |
| 382 | |
| 383 | if (lbs_create_dnld_countryinfo_11d(priv)) { |
| 384 | lbs_deb_join("ADHOC_START: dnld_countryinfo_11d failed\n"); |
| 385 | ret = -1; |
| 386 | goto out; |
| 387 | } |
| 388 | |
| 389 | lbs_deb_join("ADHOC_START: Starting Ad-Hoc BSS on channel %d, band %d\n", |
| 390 | assoc_req->channel, assoc_req->band); |
| 391 | |
| 392 | priv->adhoccreate = 1; |
| 393 | priv->mode = IW_MODE_ADHOC; |
| 394 | |
| 395 | ret = lbs_cmd_with_response(priv, CMD_802_11_AD_HOC_START, &cmd); |
| 396 | if (ret == 0) |
| 397 | ret = lbs_adhoc_post(priv, (struct cmd_header *) &cmd); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 398 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 399 | out: |
| 400 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 401 | return ret; |
| 402 | } |
| 403 | |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 404 | /** |
| 405 | * @brief Stop and Ad-Hoc network and exit Ad-Hoc mode |
| 406 | * |
| 407 | * @param priv A pointer to struct lbs_private structure |
| 408 | * @return 0 on success, or an error |
| 409 | */ |
| 410 | int lbs_adhoc_stop(struct lbs_private *priv) |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 411 | { |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 412 | struct cmd_ds_802_11_ad_hoc_stop cmd; |
| 413 | int ret; |
| 414 | |
| 415 | lbs_deb_enter(LBS_DEB_JOIN); |
| 416 | |
| 417 | memset(&cmd, 0, sizeof (cmd)); |
| 418 | cmd.hdr.size = cpu_to_le16 (sizeof (cmd)); |
| 419 | |
| 420 | ret = lbs_cmd_with_response(priv, CMD_802_11_AD_HOC_STOP, &cmd); |
| 421 | |
| 422 | /* Clean up everything even if there was an error */ |
| 423 | lbs_mac_event_disconnected(priv); |
| 424 | |
| 425 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
| 426 | return ret; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 427 | } |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 428 | |
Holger Schurig | 245bf20 | 2008-04-02 16:27:42 +0200 | [diff] [blame] | 429 | static inline int match_bss_no_security(struct lbs_802_11_security *secinfo, |
| 430 | struct bss_descriptor *match_bss) |
| 431 | { |
| 432 | if (!secinfo->wep_enabled && !secinfo->WPAenabled |
| 433 | && !secinfo->WPA2enabled |
Johannes Berg | 2c706002 | 2008-10-30 22:09:54 +0100 | [diff] [blame] | 434 | && match_bss->wpa_ie[0] != WLAN_EID_GENERIC |
| 435 | && match_bss->rsn_ie[0] != WLAN_EID_RSN |
Holger Schurig | 245bf20 | 2008-04-02 16:27:42 +0200 | [diff] [blame] | 436 | && !(match_bss->capability & WLAN_CAPABILITY_PRIVACY)) |
| 437 | return 1; |
| 438 | else |
| 439 | return 0; |
| 440 | } |
| 441 | |
| 442 | static inline int match_bss_static_wep(struct lbs_802_11_security *secinfo, |
| 443 | struct bss_descriptor *match_bss) |
| 444 | { |
| 445 | if (secinfo->wep_enabled && !secinfo->WPAenabled |
| 446 | && !secinfo->WPA2enabled |
| 447 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) |
| 448 | return 1; |
| 449 | else |
| 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | static inline int match_bss_wpa(struct lbs_802_11_security *secinfo, |
| 454 | struct bss_descriptor *match_bss) |
| 455 | { |
| 456 | if (!secinfo->wep_enabled && secinfo->WPAenabled |
Johannes Berg | 2c706002 | 2008-10-30 22:09:54 +0100 | [diff] [blame] | 457 | && (match_bss->wpa_ie[0] == WLAN_EID_GENERIC) |
Holger Schurig | 245bf20 | 2008-04-02 16:27:42 +0200 | [diff] [blame] | 458 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G |
| 459 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY) */ |
| 460 | ) |
| 461 | return 1; |
| 462 | else |
| 463 | return 0; |
| 464 | } |
| 465 | |
| 466 | static inline int match_bss_wpa2(struct lbs_802_11_security *secinfo, |
| 467 | struct bss_descriptor *match_bss) |
| 468 | { |
| 469 | if (!secinfo->wep_enabled && secinfo->WPA2enabled && |
Johannes Berg | 2c706002 | 2008-10-30 22:09:54 +0100 | [diff] [blame] | 470 | (match_bss->rsn_ie[0] == WLAN_EID_RSN) |
Holger Schurig | 245bf20 | 2008-04-02 16:27:42 +0200 | [diff] [blame] | 471 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G |
| 472 | (match_bss->capability & WLAN_CAPABILITY_PRIVACY) */ |
| 473 | ) |
| 474 | return 1; |
| 475 | else |
| 476 | return 0; |
| 477 | } |
| 478 | |
| 479 | static inline int match_bss_dynamic_wep(struct lbs_802_11_security *secinfo, |
| 480 | struct bss_descriptor *match_bss) |
| 481 | { |
| 482 | if (!secinfo->wep_enabled && !secinfo->WPAenabled |
| 483 | && !secinfo->WPA2enabled |
Johannes Berg | 2c706002 | 2008-10-30 22:09:54 +0100 | [diff] [blame] | 484 | && (match_bss->wpa_ie[0] != WLAN_EID_GENERIC) |
| 485 | && (match_bss->rsn_ie[0] != WLAN_EID_RSN) |
Holger Schurig | 245bf20 | 2008-04-02 16:27:42 +0200 | [diff] [blame] | 486 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) |
| 487 | return 1; |
| 488 | else |
| 489 | return 0; |
| 490 | } |
| 491 | |
| 492 | /** |
| 493 | * @brief Check if a scanned network compatible with the driver settings |
| 494 | * |
| 495 | * WEP WPA WPA2 ad-hoc encrypt Network |
| 496 | * enabled enabled enabled AES mode privacy WPA WPA2 Compatible |
| 497 | * 0 0 0 0 NONE 0 0 0 yes No security |
| 498 | * 1 0 0 0 NONE 1 0 0 yes Static WEP |
| 499 | * 0 1 0 0 x 1x 1 x yes WPA |
| 500 | * 0 0 1 0 x 1x x 1 yes WPA2 |
| 501 | * 0 0 0 1 NONE 1 0 0 yes Ad-hoc AES |
| 502 | * 0 0 0 0 !=NONE 1 0 0 yes Dynamic WEP |
| 503 | * |
| 504 | * |
| 505 | * @param priv A pointer to struct lbs_private |
| 506 | * @param index Index in scantable to check against current driver settings |
| 507 | * @param mode Network mode: Infrastructure or IBSS |
| 508 | * |
| 509 | * @return Index in scantable, or error code if negative |
| 510 | */ |
| 511 | static int is_network_compatible(struct lbs_private *priv, |
| 512 | struct bss_descriptor *bss, uint8_t mode) |
| 513 | { |
| 514 | int matched = 0; |
| 515 | |
| 516 | lbs_deb_enter(LBS_DEB_SCAN); |
| 517 | |
| 518 | if (bss->mode != mode) |
| 519 | goto done; |
| 520 | |
| 521 | matched = match_bss_no_security(&priv->secinfo, bss); |
| 522 | if (matched) |
| 523 | goto done; |
| 524 | matched = match_bss_static_wep(&priv->secinfo, bss); |
| 525 | if (matched) |
| 526 | goto done; |
| 527 | matched = match_bss_wpa(&priv->secinfo, bss); |
| 528 | if (matched) { |
| 529 | lbs_deb_scan("is_network_compatible() WPA: wpa_ie 0x%x " |
| 530 | "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s " |
| 531 | "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0], |
| 532 | priv->secinfo.wep_enabled ? "e" : "d", |
| 533 | priv->secinfo.WPAenabled ? "e" : "d", |
| 534 | priv->secinfo.WPA2enabled ? "e" : "d", |
| 535 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); |
| 536 | goto done; |
| 537 | } |
| 538 | matched = match_bss_wpa2(&priv->secinfo, bss); |
| 539 | if (matched) { |
| 540 | lbs_deb_scan("is_network_compatible() WPA2: wpa_ie 0x%x " |
| 541 | "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s " |
| 542 | "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0], |
| 543 | priv->secinfo.wep_enabled ? "e" : "d", |
| 544 | priv->secinfo.WPAenabled ? "e" : "d", |
| 545 | priv->secinfo.WPA2enabled ? "e" : "d", |
| 546 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); |
| 547 | goto done; |
| 548 | } |
| 549 | matched = match_bss_dynamic_wep(&priv->secinfo, bss); |
| 550 | if (matched) { |
| 551 | lbs_deb_scan("is_network_compatible() dynamic WEP: " |
| 552 | "wpa_ie 0x%x wpa2_ie 0x%x privacy 0x%x\n", |
| 553 | bss->wpa_ie[0], bss->rsn_ie[0], |
| 554 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); |
| 555 | goto done; |
| 556 | } |
| 557 | |
| 558 | /* bss security settings don't match those configured on card */ |
| 559 | lbs_deb_scan("is_network_compatible() FAILED: wpa_ie 0x%x " |
| 560 | "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s privacy 0x%x\n", |
| 561 | bss->wpa_ie[0], bss->rsn_ie[0], |
| 562 | priv->secinfo.wep_enabled ? "e" : "d", |
| 563 | priv->secinfo.WPAenabled ? "e" : "d", |
| 564 | priv->secinfo.WPA2enabled ? "e" : "d", |
| 565 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); |
| 566 | |
| 567 | done: |
| 568 | lbs_deb_leave_args(LBS_DEB_SCAN, "matched: %d", matched); |
| 569 | return matched; |
| 570 | } |
| 571 | |
| 572 | /** |
| 573 | * @brief This function finds a specific compatible BSSID in the scan list |
| 574 | * |
| 575 | * Used in association code |
| 576 | * |
| 577 | * @param priv A pointer to struct lbs_private |
| 578 | * @param bssid BSSID to find in the scan list |
| 579 | * @param mode Network mode: Infrastructure or IBSS |
| 580 | * |
| 581 | * @return index in BSSID list, or error return code (< 0) |
| 582 | */ |
| 583 | static struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_private *priv, |
| 584 | uint8_t *bssid, uint8_t mode) |
| 585 | { |
| 586 | struct bss_descriptor *iter_bss; |
| 587 | struct bss_descriptor *found_bss = NULL; |
| 588 | |
| 589 | lbs_deb_enter(LBS_DEB_SCAN); |
| 590 | |
| 591 | if (!bssid) |
| 592 | goto out; |
| 593 | |
| 594 | lbs_deb_hex(LBS_DEB_SCAN, "looking for", bssid, ETH_ALEN); |
| 595 | |
| 596 | /* Look through the scan table for a compatible match. The loop will |
| 597 | * continue past a matched bssid that is not compatible in case there |
| 598 | * is an AP with multiple SSIDs assigned to the same BSSID |
| 599 | */ |
| 600 | mutex_lock(&priv->lock); |
| 601 | list_for_each_entry(iter_bss, &priv->network_list, list) { |
| 602 | if (compare_ether_addr(iter_bss->bssid, bssid)) |
| 603 | continue; /* bssid doesn't match */ |
| 604 | switch (mode) { |
| 605 | case IW_MODE_INFRA: |
| 606 | case IW_MODE_ADHOC: |
| 607 | if (!is_network_compatible(priv, iter_bss, mode)) |
| 608 | break; |
| 609 | found_bss = iter_bss; |
| 610 | break; |
| 611 | default: |
| 612 | found_bss = iter_bss; |
| 613 | break; |
| 614 | } |
| 615 | } |
| 616 | mutex_unlock(&priv->lock); |
| 617 | |
| 618 | out: |
| 619 | lbs_deb_leave_args(LBS_DEB_SCAN, "found_bss %p", found_bss); |
| 620 | return found_bss; |
| 621 | } |
| 622 | |
| 623 | /** |
| 624 | * @brief This function finds ssid in ssid list. |
| 625 | * |
| 626 | * Used in association code |
| 627 | * |
| 628 | * @param priv A pointer to struct lbs_private |
| 629 | * @param ssid SSID to find in the list |
| 630 | * @param bssid BSSID to qualify the SSID selection (if provided) |
| 631 | * @param mode Network mode: Infrastructure or IBSS |
| 632 | * |
| 633 | * @return index in BSSID list |
| 634 | */ |
| 635 | static struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_private *priv, |
| 636 | uint8_t *ssid, uint8_t ssid_len, |
| 637 | uint8_t *bssid, uint8_t mode, |
| 638 | int channel) |
| 639 | { |
| 640 | u32 bestrssi = 0; |
| 641 | struct bss_descriptor *iter_bss = NULL; |
| 642 | struct bss_descriptor *found_bss = NULL; |
| 643 | struct bss_descriptor *tmp_oldest = NULL; |
| 644 | |
| 645 | lbs_deb_enter(LBS_DEB_SCAN); |
| 646 | |
| 647 | mutex_lock(&priv->lock); |
| 648 | |
| 649 | list_for_each_entry(iter_bss, &priv->network_list, list) { |
| 650 | if (!tmp_oldest || |
| 651 | (iter_bss->last_scanned < tmp_oldest->last_scanned)) |
| 652 | tmp_oldest = iter_bss; |
| 653 | |
| 654 | if (lbs_ssid_cmp(iter_bss->ssid, iter_bss->ssid_len, |
| 655 | ssid, ssid_len) != 0) |
| 656 | continue; /* ssid doesn't match */ |
| 657 | if (bssid && compare_ether_addr(iter_bss->bssid, bssid) != 0) |
| 658 | continue; /* bssid doesn't match */ |
| 659 | if ((channel > 0) && (iter_bss->channel != channel)) |
| 660 | continue; /* channel doesn't match */ |
| 661 | |
| 662 | switch (mode) { |
| 663 | case IW_MODE_INFRA: |
| 664 | case IW_MODE_ADHOC: |
| 665 | if (!is_network_compatible(priv, iter_bss, mode)) |
| 666 | break; |
| 667 | |
| 668 | if (bssid) { |
| 669 | /* Found requested BSSID */ |
| 670 | found_bss = iter_bss; |
| 671 | goto out; |
| 672 | } |
| 673 | |
| 674 | if (SCAN_RSSI(iter_bss->rssi) > bestrssi) { |
| 675 | bestrssi = SCAN_RSSI(iter_bss->rssi); |
| 676 | found_bss = iter_bss; |
| 677 | } |
| 678 | break; |
| 679 | case IW_MODE_AUTO: |
| 680 | default: |
| 681 | if (SCAN_RSSI(iter_bss->rssi) > bestrssi) { |
| 682 | bestrssi = SCAN_RSSI(iter_bss->rssi); |
| 683 | found_bss = iter_bss; |
| 684 | } |
| 685 | break; |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | out: |
| 690 | mutex_unlock(&priv->lock); |
| 691 | lbs_deb_leave_args(LBS_DEB_SCAN, "found_bss %p", found_bss); |
| 692 | return found_bss; |
| 693 | } |
| 694 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 695 | static int assoc_helper_essid(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 696 | struct assoc_request * assoc_req) |
| 697 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 698 | int ret = 0; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 699 | struct bss_descriptor * bss; |
Dan Williams | aeea0ab | 2007-05-25 22:30:48 -0400 | [diff] [blame] | 700 | int channel = -1; |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 701 | DECLARE_SSID_BUF(ssid); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 702 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 703 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 704 | |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 705 | /* FIXME: take channel into account when picking SSIDs if a channel |
| 706 | * is set. |
| 707 | */ |
| 708 | |
Dan Williams | aeea0ab | 2007-05-25 22:30:48 -0400 | [diff] [blame] | 709 | if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) |
| 710 | channel = assoc_req->channel; |
| 711 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 712 | lbs_deb_assoc("SSID '%s' requested\n", |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 713 | print_ssid(ssid, assoc_req->ssid, assoc_req->ssid_len)); |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 714 | if (assoc_req->mode == IW_MODE_INFRA) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 715 | lbs_send_specific_ssid_scan(priv, assoc_req->ssid, |
Holger Schurig | 52933d8 | 2008-03-05 07:05:32 +0100 | [diff] [blame] | 716 | assoc_req->ssid_len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 717 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 718 | bss = lbs_find_ssid_in_list(priv, assoc_req->ssid, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 719 | assoc_req->ssid_len, NULL, IW_MODE_INFRA, channel); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 720 | if (bss != NULL) { |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 721 | memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor)); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 722 | ret = lbs_associate(priv, assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 723 | } else { |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 724 | lbs_deb_assoc("SSID not found; cannot associate\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 725 | } |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 726 | } else if (assoc_req->mode == IW_MODE_ADHOC) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 727 | /* Scan for the network, do not save previous results. Stale |
| 728 | * scan data will cause us to join a non-existant adhoc network |
| 729 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 730 | lbs_send_specific_ssid_scan(priv, assoc_req->ssid, |
Holger Schurig | 52933d8 | 2008-03-05 07:05:32 +0100 | [diff] [blame] | 731 | assoc_req->ssid_len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 732 | |
| 733 | /* Search for the requested SSID in the scan table */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 734 | bss = lbs_find_ssid_in_list(priv, assoc_req->ssid, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 735 | assoc_req->ssid_len, NULL, IW_MODE_ADHOC, channel); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 736 | if (bss != NULL) { |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 737 | lbs_deb_assoc("SSID found, will join\n"); |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 738 | memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor)); |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 739 | lbs_adhoc_join(priv, assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 740 | } else { |
| 741 | /* else send START command */ |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 742 | lbs_deb_assoc("SSID not found, creating adhoc network\n"); |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 743 | memcpy(&assoc_req->bss.ssid, &assoc_req->ssid, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 744 | IW_ESSID_MAX_SIZE); |
| 745 | assoc_req->bss.ssid_len = assoc_req->ssid_len; |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 746 | lbs_adhoc_start(priv, assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 747 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 748 | } |
| 749 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 750 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 751 | return ret; |
| 752 | } |
| 753 | |
| 754 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 755 | static int assoc_helper_bssid(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 756 | struct assoc_request * assoc_req) |
| 757 | { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 758 | int ret = 0; |
| 759 | struct bss_descriptor * bss; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 760 | |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 761 | lbs_deb_enter_args(LBS_DEB_ASSOC, "BSSID %pM", assoc_req->bssid); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 762 | |
| 763 | /* Search for index position in list for requested MAC */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 764 | bss = lbs_find_bssid_in_list(priv, assoc_req->bssid, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 765 | assoc_req->mode); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 766 | if (bss == NULL) { |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 767 | lbs_deb_assoc("ASSOC: WAP: BSSID %pM not found, " |
| 768 | "cannot associate.\n", assoc_req->bssid); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 769 | goto out; |
| 770 | } |
| 771 | |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 772 | memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor)); |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 773 | if (assoc_req->mode == IW_MODE_INFRA) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 774 | ret = lbs_associate(priv, assoc_req); |
| 775 | lbs_deb_assoc("ASSOC: lbs_associate(bssid) returned %d\n", ret); |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 776 | } else if (assoc_req->mode == IW_MODE_ADHOC) { |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 777 | lbs_adhoc_join(priv, assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 778 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 779 | |
| 780 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 781 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 782 | return ret; |
| 783 | } |
| 784 | |
| 785 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 786 | static int assoc_helper_associate(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 787 | struct assoc_request * assoc_req) |
| 788 | { |
| 789 | int ret = 0, done = 0; |
| 790 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 791 | lbs_deb_enter(LBS_DEB_ASSOC); |
| 792 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 793 | /* If we're given and 'any' BSSID, try associating based on SSID */ |
| 794 | |
| 795 | if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { |
Dan Williams | 3cf2093 | 2007-05-25 17:28:30 -0400 | [diff] [blame] | 796 | if (compare_ether_addr(bssid_any, assoc_req->bssid) |
| 797 | && compare_ether_addr(bssid_off, assoc_req->bssid)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 798 | ret = assoc_helper_bssid(priv, assoc_req); |
| 799 | done = 1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 800 | } |
| 801 | } |
| 802 | |
| 803 | if (!done && test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { |
| 804 | ret = assoc_helper_essid(priv, assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 805 | } |
| 806 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 807 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 808 | return ret; |
| 809 | } |
| 810 | |
| 811 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 812 | static int assoc_helper_mode(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 813 | struct assoc_request * assoc_req) |
| 814 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 815 | int ret = 0; |
| 816 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 817 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 818 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 819 | if (assoc_req->mode == priv->mode) |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 820 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 821 | |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 822 | if (assoc_req->mode == IW_MODE_INFRA) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 823 | if (priv->psstate != PS_STATE_FULL_POWER) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 824 | lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 825 | priv->psmode = LBS802_11POWERMODECAM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 826 | } |
| 827 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 828 | priv->mode = assoc_req->mode; |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 829 | ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_BSS_TYPE, assoc_req->mode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 830 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 831 | done: |
| 832 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 833 | return ret; |
| 834 | } |
| 835 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 836 | static int assoc_helper_channel(struct lbs_private *priv, |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 837 | struct assoc_request * assoc_req) |
| 838 | { |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 839 | int ret = 0; |
| 840 | |
| 841 | lbs_deb_enter(LBS_DEB_ASSOC); |
| 842 | |
David Woodhouse | 9f46257 | 2007-12-12 22:50:21 -0500 | [diff] [blame] | 843 | ret = lbs_update_channel(priv); |
David Woodhouse | d1a469f | 2007-12-16 17:21:00 -0500 | [diff] [blame] | 844 | if (ret) { |
David Woodhouse | 23d36ee | 2007-12-12 00:14:21 -0500 | [diff] [blame] | 845 | lbs_deb_assoc("ASSOC: channel: error getting channel.\n"); |
David Woodhouse | d1a469f | 2007-12-16 17:21:00 -0500 | [diff] [blame] | 846 | goto done; |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 847 | } |
| 848 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 849 | if (assoc_req->channel == priv->curbssparams.channel) |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 850 | goto done; |
| 851 | |
David Woodhouse | 8642f1f | 2007-12-11 20:03:01 -0500 | [diff] [blame] | 852 | if (priv->mesh_dev) { |
David Woodhouse | 8606213 | 2007-12-13 00:32:36 -0500 | [diff] [blame] | 853 | /* Change mesh channel first; 21.p21 firmware won't let |
| 854 | you change channel otherwise (even though it'll return |
| 855 | an error to this */ |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 856 | lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_STOP, |
| 857 | assoc_req->channel); |
David Woodhouse | 8642f1f | 2007-12-11 20:03:01 -0500 | [diff] [blame] | 858 | } |
| 859 | |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 860 | lbs_deb_assoc("ASSOC: channel: %d -> %d\n", |
David Woodhouse | 8606213 | 2007-12-13 00:32:36 -0500 | [diff] [blame] | 861 | priv->curbssparams.channel, assoc_req->channel); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 862 | |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 863 | ret = lbs_set_channel(priv, assoc_req->channel); |
| 864 | if (ret < 0) |
David Woodhouse | 23d36ee | 2007-12-12 00:14:21 -0500 | [diff] [blame] | 865 | lbs_deb_assoc("ASSOC: channel: error setting channel.\n"); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 866 | |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 867 | /* FIXME: shouldn't need to grab the channel _again_ after setting |
| 868 | * it since the firmware is supposed to return the new channel, but |
| 869 | * whatever... */ |
David Woodhouse | 9f46257 | 2007-12-12 22:50:21 -0500 | [diff] [blame] | 870 | ret = lbs_update_channel(priv); |
David Woodhouse | d1a469f | 2007-12-16 17:21:00 -0500 | [diff] [blame] | 871 | if (ret) { |
David Woodhouse | 23d36ee | 2007-12-12 00:14:21 -0500 | [diff] [blame] | 872 | lbs_deb_assoc("ASSOC: channel: error getting channel.\n"); |
David Woodhouse | d1a469f | 2007-12-16 17:21:00 -0500 | [diff] [blame] | 873 | goto done; |
| 874 | } |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 875 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 876 | if (assoc_req->channel != priv->curbssparams.channel) { |
David Woodhouse | 88ae291 | 2007-12-11 19:57:05 -0500 | [diff] [blame] | 877 | lbs_deb_assoc("ASSOC: channel: failed to update channel to %d\n", |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 878 | assoc_req->channel); |
David Woodhouse | 8642f1f | 2007-12-11 20:03:01 -0500 | [diff] [blame] | 879 | goto restore_mesh; |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | if ( assoc_req->secinfo.wep_enabled |
| 883 | && (assoc_req->wep_keys[0].len |
| 884 | || assoc_req->wep_keys[1].len |
| 885 | || assoc_req->wep_keys[2].len |
| 886 | || assoc_req->wep_keys[3].len)) { |
| 887 | /* Make sure WEP keys are re-sent to firmware */ |
| 888 | set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); |
| 889 | } |
| 890 | |
| 891 | /* Must restart/rejoin adhoc networks after channel change */ |
David Woodhouse | 23d36ee | 2007-12-12 00:14:21 -0500 | [diff] [blame] | 892 | set_bit(ASSOC_FLAG_SSID, &assoc_req->flags); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 893 | |
David Woodhouse | 8642f1f | 2007-12-11 20:03:01 -0500 | [diff] [blame] | 894 | restore_mesh: |
| 895 | if (priv->mesh_dev) |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 896 | lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, |
| 897 | priv->curbssparams.channel); |
David Woodhouse | 8642f1f | 2007-12-11 20:03:01 -0500 | [diff] [blame] | 898 | |
| 899 | done: |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 900 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
| 901 | return ret; |
| 902 | } |
| 903 | |
| 904 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 905 | static int assoc_helper_wep_keys(struct lbs_private *priv, |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 906 | struct assoc_request *assoc_req) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 907 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 908 | int i; |
| 909 | int ret = 0; |
| 910 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 911 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 912 | |
| 913 | /* Set or remove WEP keys */ |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 914 | if (assoc_req->wep_keys[0].len || assoc_req->wep_keys[1].len || |
| 915 | assoc_req->wep_keys[2].len || assoc_req->wep_keys[3].len) |
| 916 | ret = lbs_cmd_802_11_set_wep(priv, CMD_ACT_ADD, assoc_req); |
| 917 | else |
| 918 | ret = lbs_cmd_802_11_set_wep(priv, CMD_ACT_REMOVE, assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 919 | |
| 920 | if (ret) |
| 921 | goto out; |
| 922 | |
| 923 | /* enable/disable the MAC's WEP packet filter */ |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 924 | if (assoc_req->secinfo.wep_enabled) |
Holger Schurig | d9e9778 | 2008-03-12 16:06:43 +0100 | [diff] [blame] | 925 | priv->mac_control |= CMD_ACT_MAC_WEP_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 926 | else |
Holger Schurig | d9e9778 | 2008-03-12 16:06:43 +0100 | [diff] [blame] | 927 | priv->mac_control &= ~CMD_ACT_MAC_WEP_ENABLE; |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 928 | |
Holger Schurig | c97329e | 2008-03-18 11:20:21 +0100 | [diff] [blame] | 929 | lbs_set_mac_control(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 930 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 931 | mutex_lock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 932 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 933 | /* Copy WEP keys into priv wep key fields */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 934 | for (i = 0; i < 4; i++) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 935 | memcpy(&priv->wep_keys[i], &assoc_req->wep_keys[i], |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 936 | sizeof(struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 937 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 938 | priv->wep_tx_keyidx = assoc_req->wep_tx_keyidx; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 939 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 940 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 941 | |
| 942 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 943 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 944 | return ret; |
| 945 | } |
| 946 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 947 | static int assoc_helper_secinfo(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 948 | struct assoc_request * assoc_req) |
| 949 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 950 | int ret = 0; |
David Woodhouse | 4f59abf | 2007-12-18 00:47:17 -0500 | [diff] [blame] | 951 | uint16_t do_wpa; |
| 952 | uint16_t rsn = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 953 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 954 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 955 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 956 | memcpy(&priv->secinfo, &assoc_req->secinfo, |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 957 | sizeof(struct lbs_802_11_security)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 958 | |
Holger Schurig | c97329e | 2008-03-18 11:20:21 +0100 | [diff] [blame] | 959 | lbs_set_mac_control(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 960 | |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 961 | /* If RSN is already enabled, don't try to enable it again, since |
| 962 | * ENABLE_RSN resets internal state machines and will clobber the |
| 963 | * 4-way WPA handshake. |
| 964 | */ |
| 965 | |
| 966 | /* Get RSN enabled/disabled */ |
David Woodhouse | 4f59abf | 2007-12-18 00:47:17 -0500 | [diff] [blame] | 967 | ret = lbs_cmd_802_11_enable_rsn(priv, CMD_ACT_GET, &rsn); |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 968 | if (ret) { |
David Woodhouse | 23d36ee | 2007-12-12 00:14:21 -0500 | [diff] [blame] | 969 | lbs_deb_assoc("Failed to get RSN status: %d\n", ret); |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 970 | goto out; |
| 971 | } |
| 972 | |
| 973 | /* Don't re-enable RSN if it's already enabled */ |
David Woodhouse | 4f59abf | 2007-12-18 00:47:17 -0500 | [diff] [blame] | 974 | do_wpa = assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled; |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 975 | if (do_wpa == rsn) |
| 976 | goto out; |
| 977 | |
| 978 | /* Set RSN enabled/disabled */ |
David Woodhouse | 4f59abf | 2007-12-18 00:47:17 -0500 | [diff] [blame] | 979 | ret = lbs_cmd_802_11_enable_rsn(priv, CMD_ACT_SET, &do_wpa); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 980 | |
| 981 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 982 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 983 | return ret; |
| 984 | } |
| 985 | |
| 986 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 987 | static int assoc_helper_wpa_keys(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 988 | struct assoc_request * assoc_req) |
| 989 | { |
| 990 | int ret = 0; |
Dan Williams | 2bcde51 | 2007-10-03 10:37:45 -0400 | [diff] [blame] | 991 | unsigned int flags = assoc_req->flags; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 992 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 993 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 994 | |
Dan Williams | 2bcde51 | 2007-10-03 10:37:45 -0400 | [diff] [blame] | 995 | /* Work around older firmware bug where WPA unicast and multicast |
| 996 | * keys must be set independently. Seen in SDIO parts with firmware |
| 997 | * version 5.0.11p0. |
| 998 | */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 999 | |
Dan Williams | 2bcde51 | 2007-10-03 10:37:45 -0400 | [diff] [blame] | 1000 | if (test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) { |
| 1001 | clear_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags); |
David Woodhouse | 9e1228d | 2008-03-03 12:15:39 +0100 | [diff] [blame] | 1002 | ret = lbs_cmd_802_11_key_material(priv, CMD_ACT_SET, assoc_req); |
Dan Williams | 2bcde51 | 2007-10-03 10:37:45 -0400 | [diff] [blame] | 1003 | assoc_req->flags = flags; |
| 1004 | } |
| 1005 | |
| 1006 | if (ret) |
| 1007 | goto out; |
| 1008 | |
| 1009 | if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) { |
| 1010 | clear_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); |
| 1011 | |
David Woodhouse | 9e1228d | 2008-03-03 12:15:39 +0100 | [diff] [blame] | 1012 | ret = lbs_cmd_802_11_key_material(priv, CMD_ACT_SET, assoc_req); |
Dan Williams | 2bcde51 | 2007-10-03 10:37:45 -0400 | [diff] [blame] | 1013 | assoc_req->flags = flags; |
| 1014 | } |
| 1015 | |
| 1016 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1017 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1018 | return ret; |
| 1019 | } |
| 1020 | |
| 1021 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1022 | static int assoc_helper_wpa_ie(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1023 | struct assoc_request * assoc_req) |
| 1024 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1025 | int ret = 0; |
| 1026 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1027 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1028 | |
| 1029 | if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1030 | memcpy(&priv->wpa_ie, &assoc_req->wpa_ie, assoc_req->wpa_ie_len); |
| 1031 | priv->wpa_ie_len = assoc_req->wpa_ie_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1032 | } else { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1033 | memset(&priv->wpa_ie, 0, MAX_WPA_IE_LEN); |
| 1034 | priv->wpa_ie_len = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1035 | } |
| 1036 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1037 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1038 | return ret; |
| 1039 | } |
| 1040 | |
| 1041 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1042 | static int should_deauth_infrastructure(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1043 | struct assoc_request * assoc_req) |
| 1044 | { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1045 | int ret = 0; |
| 1046 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1047 | if (priv->connect_status != LBS_CONNECTED) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1048 | return 0; |
| 1049 | |
Holger Schurig | 52507c2 | 2008-01-28 17:25:53 +0100 | [diff] [blame] | 1050 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1051 | if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1052 | lbs_deb_assoc("Deauthenticating due to new SSID\n"); |
| 1053 | ret = 1; |
| 1054 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1055 | } |
| 1056 | |
| 1057 | if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1058 | if (priv->secinfo.auth_mode != assoc_req->secinfo.auth_mode) { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1059 | lbs_deb_assoc("Deauthenticating due to new security\n"); |
| 1060 | ret = 1; |
| 1061 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1066 | lbs_deb_assoc("Deauthenticating due to new BSSID\n"); |
| 1067 | ret = 1; |
| 1068 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1069 | } |
| 1070 | |
Luis Carlos Cobo Rus | fff47f1 | 2007-05-30 12:16:13 -0400 | [diff] [blame] | 1071 | if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1072 | lbs_deb_assoc("Deauthenticating due to channel switch\n"); |
| 1073 | ret = 1; |
| 1074 | goto out; |
Luis Carlos Cobo Rus | fff47f1 | 2007-05-30 12:16:13 -0400 | [diff] [blame] | 1075 | } |
| 1076 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1077 | /* FIXME: deal with 'auto' mode somehow */ |
| 1078 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1079 | if (assoc_req->mode != IW_MODE_INFRA) { |
| 1080 | lbs_deb_assoc("Deauthenticating due to leaving " |
| 1081 | "infra mode\n"); |
| 1082 | ret = 1; |
| 1083 | goto out; |
| 1084 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1085 | } |
| 1086 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1087 | out: |
| 1088 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
Holger Schurig | 52507c2 | 2008-01-28 17:25:53 +0100 | [diff] [blame] | 1089 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1090 | } |
| 1091 | |
| 1092 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1093 | static int should_stop_adhoc(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1094 | struct assoc_request * assoc_req) |
| 1095 | { |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1096 | lbs_deb_enter(LBS_DEB_ASSOC); |
| 1097 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1098 | if (priv->connect_status != LBS_CONNECTED) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1099 | return 0; |
| 1100 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1101 | if (lbs_ssid_cmp(priv->curbssparams.ssid, |
| 1102 | priv->curbssparams.ssid_len, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1103 | assoc_req->ssid, assoc_req->ssid_len) != 0) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1104 | return 1; |
| 1105 | |
| 1106 | /* FIXME: deal with 'auto' mode somehow */ |
| 1107 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 1108 | if (assoc_req->mode != IW_MODE_ADHOC) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1109 | return 1; |
| 1110 | } |
| 1111 | |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 1112 | if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1113 | if (assoc_req->channel != priv->curbssparams.channel) |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 1114 | return 1; |
| 1115 | } |
| 1116 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1117 | lbs_deb_leave(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1118 | return 0; |
| 1119 | } |
| 1120 | |
| 1121 | |
Holger Schurig | 245bf20 | 2008-04-02 16:27:42 +0200 | [diff] [blame] | 1122 | /** |
| 1123 | * @brief This function finds the best SSID in the Scan List |
| 1124 | * |
| 1125 | * Search the scan table for the best SSID that also matches the current |
| 1126 | * adapter network preference (infrastructure or adhoc) |
| 1127 | * |
| 1128 | * @param priv A pointer to struct lbs_private |
| 1129 | * |
| 1130 | * @return index in BSSID list |
| 1131 | */ |
| 1132 | static struct bss_descriptor *lbs_find_best_ssid_in_list( |
| 1133 | struct lbs_private *priv, uint8_t mode) |
| 1134 | { |
| 1135 | uint8_t bestrssi = 0; |
| 1136 | struct bss_descriptor *iter_bss; |
| 1137 | struct bss_descriptor *best_bss = NULL; |
| 1138 | |
| 1139 | lbs_deb_enter(LBS_DEB_SCAN); |
| 1140 | |
| 1141 | mutex_lock(&priv->lock); |
| 1142 | |
| 1143 | list_for_each_entry(iter_bss, &priv->network_list, list) { |
| 1144 | switch (mode) { |
| 1145 | case IW_MODE_INFRA: |
| 1146 | case IW_MODE_ADHOC: |
| 1147 | if (!is_network_compatible(priv, iter_bss, mode)) |
| 1148 | break; |
| 1149 | if (SCAN_RSSI(iter_bss->rssi) <= bestrssi) |
| 1150 | break; |
| 1151 | bestrssi = SCAN_RSSI(iter_bss->rssi); |
| 1152 | best_bss = iter_bss; |
| 1153 | break; |
| 1154 | case IW_MODE_AUTO: |
| 1155 | default: |
| 1156 | if (SCAN_RSSI(iter_bss->rssi) <= bestrssi) |
| 1157 | break; |
| 1158 | bestrssi = SCAN_RSSI(iter_bss->rssi); |
| 1159 | best_bss = iter_bss; |
| 1160 | break; |
| 1161 | } |
| 1162 | } |
| 1163 | |
| 1164 | mutex_unlock(&priv->lock); |
| 1165 | lbs_deb_leave_args(LBS_DEB_SCAN, "best_bss %p", best_bss); |
| 1166 | return best_bss; |
| 1167 | } |
| 1168 | |
| 1169 | /** |
| 1170 | * @brief Find the best AP |
| 1171 | * |
| 1172 | * Used from association worker. |
| 1173 | * |
| 1174 | * @param priv A pointer to struct lbs_private structure |
| 1175 | * @param pSSID A pointer to AP's ssid |
| 1176 | * |
| 1177 | * @return 0--success, otherwise--fail |
| 1178 | */ |
| 1179 | static int lbs_find_best_network_ssid(struct lbs_private *priv, |
| 1180 | uint8_t *out_ssid, uint8_t *out_ssid_len, uint8_t preferred_mode, |
| 1181 | uint8_t *out_mode) |
| 1182 | { |
| 1183 | int ret = -1; |
| 1184 | struct bss_descriptor *found; |
| 1185 | |
| 1186 | lbs_deb_enter(LBS_DEB_SCAN); |
| 1187 | |
| 1188 | priv->scan_ssid_len = 0; |
| 1189 | lbs_scan_networks(priv, 1); |
| 1190 | if (priv->surpriseremoved) |
| 1191 | goto out; |
| 1192 | |
| 1193 | found = lbs_find_best_ssid_in_list(priv, preferred_mode); |
| 1194 | if (found && (found->ssid_len > 0)) { |
| 1195 | memcpy(out_ssid, &found->ssid, IW_ESSID_MAX_SIZE); |
| 1196 | *out_ssid_len = found->ssid_len; |
| 1197 | *out_mode = found->mode; |
| 1198 | ret = 0; |
| 1199 | } |
| 1200 | |
| 1201 | out: |
| 1202 | lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); |
| 1203 | return ret; |
| 1204 | } |
| 1205 | |
| 1206 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1207 | void lbs_association_worker(struct work_struct *work) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1208 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1209 | struct lbs_private *priv = container_of(work, struct lbs_private, |
| 1210 | assoc_work.work); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1211 | struct assoc_request * assoc_req = NULL; |
| 1212 | int ret = 0; |
| 1213 | int find_any_ssid = 0; |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 1214 | DECLARE_SSID_BUF(ssid); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1215 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1216 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1217 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1218 | mutex_lock(&priv->lock); |
| 1219 | assoc_req = priv->pending_assoc_req; |
| 1220 | priv->pending_assoc_req = NULL; |
| 1221 | priv->in_progress_assoc_req = assoc_req; |
| 1222 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1223 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1224 | if (!assoc_req) |
| 1225 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1226 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1227 | lbs_deb_assoc( |
| 1228 | "Association Request:\n" |
| 1229 | " flags: 0x%08lx\n" |
| 1230 | " SSID: '%s'\n" |
| 1231 | " chann: %d\n" |
| 1232 | " band: %d\n" |
| 1233 | " mode: %d\n" |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 1234 | " BSSID: %pM\n" |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1235 | " secinfo: %s%s%s\n" |
| 1236 | " auth_mode: %d\n", |
| 1237 | assoc_req->flags, |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 1238 | print_ssid(ssid, assoc_req->ssid, assoc_req->ssid_len), |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1239 | assoc_req->channel, assoc_req->band, assoc_req->mode, |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 1240 | assoc_req->bssid, |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1241 | assoc_req->secinfo.WPAenabled ? " WPA" : "", |
| 1242 | assoc_req->secinfo.WPA2enabled ? " WPA2" : "", |
| 1243 | assoc_req->secinfo.wep_enabled ? " WEP" : "", |
| 1244 | assoc_req->secinfo.auth_mode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1245 | |
| 1246 | /* If 'any' SSID was specified, find an SSID to associate with */ |
| 1247 | if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags) |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1248 | && !assoc_req->ssid_len) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1249 | find_any_ssid = 1; |
| 1250 | |
| 1251 | /* But don't use 'any' SSID if there's a valid locked BSSID to use */ |
| 1252 | if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { |
Dan Williams | 3cf2093 | 2007-05-25 17:28:30 -0400 | [diff] [blame] | 1253 | if (compare_ether_addr(assoc_req->bssid, bssid_any) |
| 1254 | && compare_ether_addr(assoc_req->bssid, bssid_off)) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1255 | find_any_ssid = 0; |
| 1256 | } |
| 1257 | |
| 1258 | if (find_any_ssid) { |
Holger Schurig | 877cb0d | 2008-04-02 16:34:51 +0200 | [diff] [blame] | 1259 | u8 new_mode = assoc_req->mode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1260 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1261 | ret = lbs_find_best_network_ssid(priv, assoc_req->ssid, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1262 | &assoc_req->ssid_len, assoc_req->mode, &new_mode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1263 | if (ret) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1264 | lbs_deb_assoc("Could not find best network\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1265 | ret = -ENETUNREACH; |
| 1266 | goto out; |
| 1267 | } |
| 1268 | |
| 1269 | /* Ensure we switch to the mode of the AP */ |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 1270 | if (assoc_req->mode == IW_MODE_AUTO) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1271 | set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); |
| 1272 | assoc_req->mode = new_mode; |
| 1273 | } |
| 1274 | } |
| 1275 | |
| 1276 | /* |
| 1277 | * Check if the attributes being changing require deauthentication |
| 1278 | * from the currently associated infrastructure access point. |
| 1279 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1280 | if (priv->mode == IW_MODE_INFRA) { |
| 1281 | if (should_deauth_infrastructure(priv, assoc_req)) { |
Dan Williams | 191bb40 | 2008-08-21 17:46:18 -0400 | [diff] [blame] | 1282 | ret = lbs_cmd_80211_deauthenticate(priv, |
| 1283 | priv->curbssparams.bssid, |
| 1284 | WLAN_REASON_DEAUTH_LEAVING); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1285 | if (ret) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1286 | lbs_deb_assoc("Deauthentication due to new " |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1287 | "configuration request failed: %d\n", |
| 1288 | ret); |
| 1289 | } |
| 1290 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1291 | } else if (priv->mode == IW_MODE_ADHOC) { |
| 1292 | if (should_stop_adhoc(priv, assoc_req)) { |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 1293 | ret = lbs_adhoc_stop(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1294 | if (ret) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1295 | lbs_deb_assoc("Teardown of AdHoc network due to " |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1296 | "new configuration request failed: %d\n", |
| 1297 | ret); |
| 1298 | } |
| 1299 | |
| 1300 | } |
| 1301 | } |
| 1302 | |
| 1303 | /* Send the various configuration bits to the firmware */ |
| 1304 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { |
| 1305 | ret = assoc_helper_mode(priv, assoc_req); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1306 | if (ret) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1307 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1308 | } |
| 1309 | |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 1310 | if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) { |
| 1311 | ret = assoc_helper_channel(priv, assoc_req); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1312 | if (ret) |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 1313 | goto out; |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 1314 | } |
| 1315 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1316 | if ( test_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags) |
| 1317 | || test_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags)) { |
| 1318 | ret = assoc_helper_wep_keys(priv, assoc_req); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1319 | if (ret) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1320 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1321 | } |
| 1322 | |
| 1323 | if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { |
| 1324 | ret = assoc_helper_secinfo(priv, assoc_req); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1325 | if (ret) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1326 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1327 | } |
| 1328 | |
| 1329 | if (test_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags)) { |
| 1330 | ret = assoc_helper_wpa_ie(priv, assoc_req); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1331 | if (ret) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1332 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1333 | } |
| 1334 | |
| 1335 | if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags) |
| 1336 | || test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) { |
| 1337 | ret = assoc_helper_wpa_keys(priv, assoc_req); |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1338 | if (ret) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1339 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1340 | } |
| 1341 | |
| 1342 | /* SSID/BSSID should be the _last_ config option set, because they |
| 1343 | * trigger the association attempt. |
| 1344 | */ |
| 1345 | if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags) |
| 1346 | || test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { |
| 1347 | int success = 1; |
| 1348 | |
| 1349 | ret = assoc_helper_associate(priv, assoc_req); |
| 1350 | if (ret) { |
Holger Schurig | 9184346 | 2007-11-28 14:05:02 +0100 | [diff] [blame] | 1351 | lbs_deb_assoc("ASSOC: association unsuccessful: %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1352 | ret); |
| 1353 | success = 0; |
| 1354 | } |
| 1355 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1356 | if (priv->connect_status != LBS_CONNECTED) { |
Holger Schurig | 9184346 | 2007-11-28 14:05:02 +0100 | [diff] [blame] | 1357 | lbs_deb_assoc("ASSOC: association unsuccessful, " |
| 1358 | "not connected\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1359 | success = 0; |
| 1360 | } |
| 1361 | |
| 1362 | if (success) { |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 1363 | lbs_deb_assoc("associated to %pM\n", |
| 1364 | priv->curbssparams.bssid); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1365 | lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1366 | CMD_802_11_RSSI, |
| 1367 | 0, CMD_OPTION_WAITFORRSP, 0, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1368 | } else { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1369 | ret = -1; |
| 1370 | } |
| 1371 | } |
| 1372 | |
| 1373 | out: |
| 1374 | if (ret) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1375 | lbs_deb_assoc("ASSOC: reconfiguration attempt unsuccessful: %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1376 | ret); |
| 1377 | } |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 1378 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1379 | mutex_lock(&priv->lock); |
| 1380 | priv->in_progress_assoc_req = NULL; |
| 1381 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1382 | kfree(assoc_req); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1383 | |
| 1384 | done: |
| 1385 | lbs_deb_leave(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1386 | } |
| 1387 | |
| 1388 | |
| 1389 | /* |
| 1390 | * Caller MUST hold any necessary locks |
| 1391 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1392 | struct assoc_request *lbs_get_association_request(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1393 | { |
| 1394 | struct assoc_request * assoc_req; |
| 1395 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1396 | lbs_deb_enter(LBS_DEB_ASSOC); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1397 | if (!priv->pending_assoc_req) { |
| 1398 | priv->pending_assoc_req = kzalloc(sizeof(struct assoc_request), |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 1399 | GFP_KERNEL); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1400 | if (!priv->pending_assoc_req) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1401 | lbs_pr_info("Not enough memory to allocate association" |
| 1402 | " request!\n"); |
| 1403 | return NULL; |
| 1404 | } |
| 1405 | } |
| 1406 | |
| 1407 | /* Copy current configuration attributes to the association request, |
| 1408 | * but don't overwrite any that are already set. |
| 1409 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1410 | assoc_req = priv->pending_assoc_req; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1411 | if (!test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1412 | memcpy(&assoc_req->ssid, &priv->curbssparams.ssid, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1413 | IW_ESSID_MAX_SIZE); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1414 | assoc_req->ssid_len = priv->curbssparams.ssid_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1415 | } |
| 1416 | |
| 1417 | if (!test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1418 | assoc_req->channel = priv->curbssparams.channel; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1419 | |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 1420 | if (!test_bit(ASSOC_FLAG_BAND, &assoc_req->flags)) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1421 | assoc_req->band = priv->curbssparams.band; |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 1422 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1423 | if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1424 | assoc_req->mode = priv->mode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1425 | |
| 1426 | if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1427 | memcpy(&assoc_req->bssid, priv->curbssparams.bssid, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1428 | ETH_ALEN); |
| 1429 | } |
| 1430 | |
| 1431 | if (!test_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags)) { |
| 1432 | int i; |
| 1433 | for (i = 0; i < 4; i++) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1434 | memcpy(&assoc_req->wep_keys[i], &priv->wep_keys[i], |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1435 | sizeof(struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | if (!test_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags)) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1440 | assoc_req->wep_tx_keyidx = priv->wep_tx_keyidx; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1441 | |
| 1442 | if (!test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1443 | memcpy(&assoc_req->wpa_mcast_key, &priv->wpa_mcast_key, |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1444 | sizeof(struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1445 | } |
| 1446 | |
| 1447 | if (!test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1448 | memcpy(&assoc_req->wpa_unicast_key, &priv->wpa_unicast_key, |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1449 | sizeof(struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1450 | } |
| 1451 | |
| 1452 | if (!test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1453 | memcpy(&assoc_req->secinfo, &priv->secinfo, |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1454 | sizeof(struct lbs_802_11_security)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1455 | } |
| 1456 | |
| 1457 | if (!test_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1458 | memcpy(&assoc_req->wpa_ie, &priv->wpa_ie, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1459 | MAX_WPA_IE_LEN); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1460 | assoc_req->wpa_ie_len = priv->wpa_ie_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1461 | } |
| 1462 | |
Holger Schurig | 0765af4 | 2007-10-15 12:55:56 +0200 | [diff] [blame] | 1463 | lbs_deb_leave(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1464 | return assoc_req; |
| 1465 | } |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1466 | |
| 1467 | |
| 1468 | /** |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1469 | * @brief This function prepares command of authenticate. |
| 1470 | * |
| 1471 | * @param priv A pointer to struct lbs_private structure |
| 1472 | * @param cmd A pointer to cmd_ds_command structure |
| 1473 | * @param pdata_buf Void cast of pointer to a BSSID to authenticate with |
| 1474 | * |
| 1475 | * @return 0 or -1 |
| 1476 | */ |
| 1477 | int lbs_cmd_80211_authenticate(struct lbs_private *priv, |
| 1478 | struct cmd_ds_command *cmd, |
| 1479 | void *pdata_buf) |
| 1480 | { |
| 1481 | struct cmd_ds_802_11_authenticate *pauthenticate = &cmd->params.auth; |
| 1482 | int ret = -1; |
| 1483 | u8 *bssid = pdata_buf; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1484 | |
| 1485 | lbs_deb_enter(LBS_DEB_JOIN); |
| 1486 | |
| 1487 | cmd->command = cpu_to_le16(CMD_802_11_AUTHENTICATE); |
| 1488 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate) |
| 1489 | + S_DS_GEN); |
| 1490 | |
| 1491 | /* translate auth mode to 802.11 defined wire value */ |
| 1492 | switch (priv->secinfo.auth_mode) { |
| 1493 | case IW_AUTH_ALG_OPEN_SYSTEM: |
| 1494 | pauthenticate->authtype = 0x00; |
| 1495 | break; |
| 1496 | case IW_AUTH_ALG_SHARED_KEY: |
| 1497 | pauthenticate->authtype = 0x01; |
| 1498 | break; |
| 1499 | case IW_AUTH_ALG_LEAP: |
| 1500 | pauthenticate->authtype = 0x80; |
| 1501 | break; |
| 1502 | default: |
| 1503 | lbs_deb_join("AUTH_CMD: invalid auth alg 0x%X\n", |
| 1504 | priv->secinfo.auth_mode); |
| 1505 | goto out; |
| 1506 | } |
| 1507 | |
| 1508 | memcpy(pauthenticate->macaddr, bssid, ETH_ALEN); |
| 1509 | |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 1510 | lbs_deb_join("AUTH_CMD: BSSID %pM, auth 0x%x\n", |
| 1511 | bssid, pauthenticate->authtype); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1512 | ret = 0; |
| 1513 | |
| 1514 | out: |
| 1515 | lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret); |
| 1516 | return ret; |
| 1517 | } |
| 1518 | |
Dan Williams | 191bb40 | 2008-08-21 17:46:18 -0400 | [diff] [blame] | 1519 | /** |
| 1520 | * @brief Deauthenticate from a specific BSS |
| 1521 | * |
| 1522 | * @param priv A pointer to struct lbs_private structure |
| 1523 | * @param bssid The specific BSS to deauthenticate from |
| 1524 | * @param reason The 802.11 sec. 7.3.1.7 Reason Code for deauthenticating |
| 1525 | * |
| 1526 | * @return 0 on success, error on failure |
| 1527 | */ |
| 1528 | int lbs_cmd_80211_deauthenticate(struct lbs_private *priv, u8 bssid[ETH_ALEN], |
| 1529 | u16 reason) |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1530 | { |
Dan Williams | 191bb40 | 2008-08-21 17:46:18 -0400 | [diff] [blame] | 1531 | struct cmd_ds_802_11_deauthenticate cmd; |
| 1532 | int ret; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1533 | |
| 1534 | lbs_deb_enter(LBS_DEB_JOIN); |
| 1535 | |
Dan Williams | 191bb40 | 2008-08-21 17:46:18 -0400 | [diff] [blame] | 1536 | memset(&cmd, 0, sizeof(cmd)); |
| 1537 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 1538 | memcpy(cmd.macaddr, &bssid[0], ETH_ALEN); |
| 1539 | cmd.reasoncode = cpu_to_le16(reason); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1540 | |
Dan Williams | 191bb40 | 2008-08-21 17:46:18 -0400 | [diff] [blame] | 1541 | ret = lbs_cmd_with_response(priv, CMD_802_11_DEAUTHENTICATE, &cmd); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1542 | |
Dan Williams | 191bb40 | 2008-08-21 17:46:18 -0400 | [diff] [blame] | 1543 | /* Clean up everything even if there was an error; can't assume that |
| 1544 | * we're still authenticated to the AP after trying to deauth. |
| 1545 | */ |
| 1546 | lbs_mac_event_disconnected(priv); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1547 | |
| 1548 | lbs_deb_leave(LBS_DEB_JOIN); |
Dan Williams | 191bb40 | 2008-08-21 17:46:18 -0400 | [diff] [blame] | 1549 | return ret; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1550 | } |
| 1551 | |
| 1552 | int lbs_cmd_80211_associate(struct lbs_private *priv, |
| 1553 | struct cmd_ds_command *cmd, void *pdata_buf) |
| 1554 | { |
| 1555 | struct cmd_ds_802_11_associate *passo = &cmd->params.associate; |
| 1556 | int ret = 0; |
| 1557 | struct assoc_request *assoc_req = pdata_buf; |
| 1558 | struct bss_descriptor *bss = &assoc_req->bss; |
| 1559 | u8 *pos; |
| 1560 | u16 tmpcap, tmplen; |
Dan Williams | 75b6a61 | 2009-05-22 20:03:09 -0400 | [diff] [blame^] | 1561 | struct mrvl_ie_ssid_param_set *ssid; |
| 1562 | struct mrvl_ie_ds_param_set *ds; |
| 1563 | struct mrvl_ie_cf_param_set *cf; |
| 1564 | struct mrvl_ie_rates_param_set *rates; |
| 1565 | struct mrvl_ie_rsn_param_set *rsn; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1566 | |
| 1567 | lbs_deb_enter(LBS_DEB_ASSOC); |
| 1568 | |
| 1569 | pos = (u8 *) passo; |
| 1570 | |
| 1571 | if (!priv) { |
| 1572 | ret = -1; |
| 1573 | goto done; |
| 1574 | } |
| 1575 | |
| 1576 | cmd->command = cpu_to_le16(CMD_802_11_ASSOCIATE); |
| 1577 | |
| 1578 | memcpy(passo->peerstaaddr, bss->bssid, sizeof(passo->peerstaaddr)); |
| 1579 | pos += sizeof(passo->peerstaaddr); |
| 1580 | |
| 1581 | /* set the listen interval */ |
| 1582 | passo->listeninterval = cpu_to_le16(MRVDRV_DEFAULT_LISTEN_INTERVAL); |
| 1583 | |
| 1584 | pos += sizeof(passo->capability); |
| 1585 | pos += sizeof(passo->listeninterval); |
| 1586 | pos += sizeof(passo->bcnperiod); |
| 1587 | pos += sizeof(passo->dtimperiod); |
| 1588 | |
Dan Williams | 75b6a61 | 2009-05-22 20:03:09 -0400 | [diff] [blame^] | 1589 | ssid = (struct mrvl_ie_ssid_param_set *) pos; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1590 | ssid->header.type = cpu_to_le16(TLV_TYPE_SSID); |
| 1591 | tmplen = bss->ssid_len; |
| 1592 | ssid->header.len = cpu_to_le16(tmplen); |
| 1593 | memcpy(ssid->ssid, bss->ssid, tmplen); |
| 1594 | pos += sizeof(ssid->header) + tmplen; |
| 1595 | |
Dan Williams | 75b6a61 | 2009-05-22 20:03:09 -0400 | [diff] [blame^] | 1596 | ds = (struct mrvl_ie_ds_param_set *) pos; |
Dan Williams | 5fd164e | 2009-05-22 20:01:21 -0400 | [diff] [blame] | 1597 | ds->header.type = cpu_to_le16(TLV_TYPE_PHY_DS); |
| 1598 | ds->header.len = cpu_to_le16(1); |
| 1599 | ds->channel = bss->phy.ds.channel; |
| 1600 | pos += sizeof(ds->header) + 1; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1601 | |
Dan Williams | 75b6a61 | 2009-05-22 20:03:09 -0400 | [diff] [blame^] | 1602 | cf = (struct mrvl_ie_cf_param_set *) pos; |
Dan Williams | 5fd164e | 2009-05-22 20:01:21 -0400 | [diff] [blame] | 1603 | cf->header.type = cpu_to_le16(TLV_TYPE_CF); |
| 1604 | tmplen = sizeof(*cf) - sizeof (cf->header); |
| 1605 | cf->header.len = cpu_to_le16(tmplen); |
| 1606 | /* IE payload should be zeroed, firmware fills it in for us */ |
| 1607 | pos += sizeof(*cf); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1608 | |
Dan Williams | 75b6a61 | 2009-05-22 20:03:09 -0400 | [diff] [blame^] | 1609 | rates = (struct mrvl_ie_rates_param_set *) pos; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1610 | rates->header.type = cpu_to_le16(TLV_TYPE_RATES); |
| 1611 | memcpy(&rates->rates, &bss->rates, MAX_RATES); |
| 1612 | tmplen = MAX_RATES; |
| 1613 | if (get_common_rates(priv, rates->rates, &tmplen)) { |
| 1614 | ret = -1; |
| 1615 | goto done; |
| 1616 | } |
| 1617 | pos += sizeof(rates->header) + tmplen; |
| 1618 | rates->header.len = cpu_to_le16(tmplen); |
| 1619 | lbs_deb_assoc("ASSOC_CMD: num rates %u\n", tmplen); |
| 1620 | |
| 1621 | /* Copy the infra. association rates into Current BSS state structure */ |
| 1622 | memset(&priv->curbssparams.rates, 0, sizeof(priv->curbssparams.rates)); |
| 1623 | memcpy(&priv->curbssparams.rates, &rates->rates, tmplen); |
| 1624 | |
| 1625 | /* Set MSB on basic rates as the firmware requires, but _after_ |
| 1626 | * copying to current bss rates. |
| 1627 | */ |
| 1628 | lbs_set_basic_rate_flags(rates->rates, tmplen); |
| 1629 | |
| 1630 | if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) { |
Dan Williams | 75b6a61 | 2009-05-22 20:03:09 -0400 | [diff] [blame^] | 1631 | rsn = (struct mrvl_ie_rsn_param_set *) pos; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1632 | /* WPA_IE or WPA2_IE */ |
| 1633 | rsn->header.type = cpu_to_le16((u16) assoc_req->wpa_ie[0]); |
| 1634 | tmplen = (u16) assoc_req->wpa_ie[1]; |
| 1635 | rsn->header.len = cpu_to_le16(tmplen); |
| 1636 | memcpy(rsn->rsnie, &assoc_req->wpa_ie[2], tmplen); |
| 1637 | lbs_deb_hex(LBS_DEB_JOIN, "ASSOC_CMD: RSN IE", (u8 *) rsn, |
| 1638 | sizeof(rsn->header) + tmplen); |
| 1639 | pos += sizeof(rsn->header) + tmplen; |
| 1640 | } |
| 1641 | |
| 1642 | /* update curbssparams */ |
Dan Williams | 5fd164e | 2009-05-22 20:01:21 -0400 | [diff] [blame] | 1643 | priv->curbssparams.channel = bss->phy.ds.channel; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1644 | |
| 1645 | if (lbs_parse_dnld_countryinfo_11d(priv, bss)) { |
| 1646 | ret = -1; |
| 1647 | goto done; |
| 1648 | } |
| 1649 | |
| 1650 | cmd->size = cpu_to_le16((u16) (pos - (u8 *) passo) + S_DS_GEN); |
| 1651 | |
| 1652 | /* set the capability info */ |
| 1653 | tmpcap = (bss->capability & CAPINFO_MASK); |
| 1654 | if (bss->mode == IW_MODE_INFRA) |
| 1655 | tmpcap |= WLAN_CAPABILITY_ESS; |
| 1656 | passo->capability = cpu_to_le16(tmpcap); |
| 1657 | lbs_deb_assoc("ASSOC_CMD: capability 0x%04x\n", tmpcap); |
| 1658 | |
| 1659 | done: |
| 1660 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
| 1661 | return ret; |
| 1662 | } |
| 1663 | |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1664 | int lbs_ret_80211_associate(struct lbs_private *priv, |
| 1665 | struct cmd_ds_command *resp) |
| 1666 | { |
| 1667 | int ret = 0; |
| 1668 | union iwreq_data wrqu; |
Dan Williams | 5fd164e | 2009-05-22 20:01:21 -0400 | [diff] [blame] | 1669 | struct ieee_assoc_response *passocrsp; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1670 | struct bss_descriptor *bss; |
| 1671 | u16 status_code; |
| 1672 | |
| 1673 | lbs_deb_enter(LBS_DEB_ASSOC); |
| 1674 | |
| 1675 | if (!priv->in_progress_assoc_req) { |
| 1676 | lbs_deb_assoc("ASSOC_RESP: no in-progress assoc request\n"); |
| 1677 | ret = -1; |
| 1678 | goto done; |
| 1679 | } |
| 1680 | bss = &priv->in_progress_assoc_req->bss; |
| 1681 | |
Dan Williams | 5fd164e | 2009-05-22 20:01:21 -0400 | [diff] [blame] | 1682 | passocrsp = (struct ieee_assoc_response *) &resp->params; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1683 | |
| 1684 | /* |
| 1685 | * Older FW versions map the IEEE 802.11 Status Code in the association |
| 1686 | * response to the following values returned in passocrsp->statuscode: |
| 1687 | * |
| 1688 | * IEEE Status Code Marvell Status Code |
| 1689 | * 0 -> 0x0000 ASSOC_RESULT_SUCCESS |
| 1690 | * 13 -> 0x0004 ASSOC_RESULT_AUTH_REFUSED |
| 1691 | * 14 -> 0x0004 ASSOC_RESULT_AUTH_REFUSED |
| 1692 | * 15 -> 0x0004 ASSOC_RESULT_AUTH_REFUSED |
| 1693 | * 16 -> 0x0004 ASSOC_RESULT_AUTH_REFUSED |
| 1694 | * others -> 0x0003 ASSOC_RESULT_REFUSED |
| 1695 | * |
| 1696 | * Other response codes: |
| 1697 | * 0x0001 -> ASSOC_RESULT_INVALID_PARAMETERS (unused) |
| 1698 | * 0x0002 -> ASSOC_RESULT_TIMEOUT (internal timer expired waiting for |
| 1699 | * association response from the AP) |
| 1700 | */ |
| 1701 | |
| 1702 | status_code = le16_to_cpu(passocrsp->statuscode); |
| 1703 | switch (status_code) { |
| 1704 | case 0x00: |
| 1705 | break; |
| 1706 | case 0x01: |
| 1707 | lbs_deb_assoc("ASSOC_RESP: invalid parameters\n"); |
| 1708 | break; |
| 1709 | case 0x02: |
| 1710 | lbs_deb_assoc("ASSOC_RESP: internal timer " |
| 1711 | "expired while waiting for the AP\n"); |
| 1712 | break; |
| 1713 | case 0x03: |
| 1714 | lbs_deb_assoc("ASSOC_RESP: association " |
| 1715 | "refused by AP\n"); |
| 1716 | break; |
| 1717 | case 0x04: |
| 1718 | lbs_deb_assoc("ASSOC_RESP: authentication " |
| 1719 | "refused by AP\n"); |
| 1720 | break; |
| 1721 | default: |
| 1722 | lbs_deb_assoc("ASSOC_RESP: failure reason 0x%02x " |
| 1723 | " unknown\n", status_code); |
| 1724 | break; |
| 1725 | } |
| 1726 | |
| 1727 | if (status_code) { |
| 1728 | lbs_mac_event_disconnected(priv); |
| 1729 | ret = -1; |
| 1730 | goto done; |
| 1731 | } |
| 1732 | |
| 1733 | lbs_deb_hex(LBS_DEB_ASSOC, "ASSOC_RESP", (void *)&resp->params, |
| 1734 | le16_to_cpu(resp->size) - S_DS_GEN); |
| 1735 | |
| 1736 | /* Send a Media Connected event, according to the Spec */ |
| 1737 | priv->connect_status = LBS_CONNECTED; |
| 1738 | |
| 1739 | /* Update current SSID and BSSID */ |
| 1740 | memcpy(&priv->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE); |
| 1741 | priv->curbssparams.ssid_len = bss->ssid_len; |
| 1742 | memcpy(priv->curbssparams.bssid, bss->bssid, ETH_ALEN); |
| 1743 | |
| 1744 | priv->SNR[TYPE_RXPD][TYPE_AVG] = 0; |
| 1745 | priv->NF[TYPE_RXPD][TYPE_AVG] = 0; |
| 1746 | |
| 1747 | memset(priv->rawSNR, 0x00, sizeof(priv->rawSNR)); |
| 1748 | memset(priv->rawNF, 0x00, sizeof(priv->rawNF)); |
| 1749 | priv->nextSNRNF = 0; |
| 1750 | priv->numSNRNF = 0; |
| 1751 | |
| 1752 | netif_carrier_on(priv->dev); |
| 1753 | if (!priv->tx_pending_len) |
| 1754 | netif_wake_queue(priv->dev); |
| 1755 | |
| 1756 | memcpy(wrqu.ap_addr.sa_data, priv->curbssparams.bssid, ETH_ALEN); |
| 1757 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 1758 | wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); |
| 1759 | |
| 1760 | done: |
| 1761 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
| 1762 | return ret; |
| 1763 | } |
| 1764 | |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 1765 | static int lbs_adhoc_post(struct lbs_private *priv, struct cmd_header *resp) |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1766 | { |
| 1767 | int ret = 0; |
| 1768 | u16 command = le16_to_cpu(resp->command); |
| 1769 | u16 result = le16_to_cpu(resp->result); |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 1770 | struct cmd_ds_802_11_ad_hoc_result *adhoc_resp; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1771 | union iwreq_data wrqu; |
| 1772 | struct bss_descriptor *bss; |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 1773 | DECLARE_SSID_BUF(ssid); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1774 | |
| 1775 | lbs_deb_enter(LBS_DEB_JOIN); |
| 1776 | |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 1777 | adhoc_resp = (struct cmd_ds_802_11_ad_hoc_result *) resp; |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1778 | |
| 1779 | if (!priv->in_progress_assoc_req) { |
| 1780 | lbs_deb_join("ADHOC_RESP: no in-progress association " |
| 1781 | "request\n"); |
| 1782 | ret = -1; |
| 1783 | goto done; |
| 1784 | } |
| 1785 | bss = &priv->in_progress_assoc_req->bss; |
| 1786 | |
| 1787 | /* |
| 1788 | * Join result code 0 --> SUCCESS |
| 1789 | */ |
| 1790 | if (result) { |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 1791 | lbs_deb_join("ADHOC_RESP: failed (result 0x%X)\n", result); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1792 | if (priv->connect_status == LBS_CONNECTED) |
| 1793 | lbs_mac_event_disconnected(priv); |
| 1794 | ret = -1; |
| 1795 | goto done; |
| 1796 | } |
| 1797 | |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1798 | /* Send a Media Connected event, according to the Spec */ |
| 1799 | priv->connect_status = LBS_CONNECTED; |
| 1800 | |
| 1801 | if (command == CMD_RET(CMD_802_11_AD_HOC_START)) { |
| 1802 | /* Update the created network descriptor with the new BSSID */ |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 1803 | memcpy(bss->bssid, adhoc_resp->bssid, ETH_ALEN); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1804 | } |
| 1805 | |
| 1806 | /* Set the BSSID from the joined/started descriptor */ |
| 1807 | memcpy(&priv->curbssparams.bssid, bss->bssid, ETH_ALEN); |
| 1808 | |
| 1809 | /* Set the new SSID to current SSID */ |
| 1810 | memcpy(&priv->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE); |
| 1811 | priv->curbssparams.ssid_len = bss->ssid_len; |
| 1812 | |
| 1813 | netif_carrier_on(priv->dev); |
| 1814 | if (!priv->tx_pending_len) |
| 1815 | netif_wake_queue(priv->dev); |
| 1816 | |
| 1817 | memset(&wrqu, 0, sizeof(wrqu)); |
| 1818 | memcpy(wrqu.ap_addr.sa_data, priv->curbssparams.bssid, ETH_ALEN); |
| 1819 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 1820 | wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); |
| 1821 | |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 1822 | lbs_deb_join("ADHOC_RESP: Joined/started '%s', BSSID %pM, channel %d\n", |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 1823 | print_ssid(ssid, bss->ssid, bss->ssid_len), |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 1824 | priv->curbssparams.bssid, |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 1825 | priv->curbssparams.channel); |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 1826 | |
| 1827 | done: |
| 1828 | lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret); |
| 1829 | return ret; |
| 1830 | } |
| 1831 | |