libertas: make association debug output nicer
[linux-2.6.git] / drivers / net / wireless / libertas / assoc.c
blob4360deac943bd1578fa08980ecc7d9dc59aa2fc0
1 /* Copyright (C) 2006, Red Hat, Inc. */
3 #include <linux/bitops.h>
4 #include <net/ieee80211.h>
5 #include <linux/etherdevice.h>
7 #include "assoc.h"
8 #include "join.h"
9 #include "decl.h"
10 #include "hostcmd.h"
11 #include "host.h"
12 #include "cmd.h"
15 static const u8 bssid_any[ETH_ALEN] __attribute__ ((aligned (2))) =
16 { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
17 static const u8 bssid_off[ETH_ALEN] __attribute__ ((aligned (2))) =
18 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
21 static int assoc_helper_essid(struct lbs_private *priv,
22 struct assoc_request * assoc_req)
24 int ret = 0;
25 struct bss_descriptor * bss;
26 int channel = -1;
28 lbs_deb_enter(LBS_DEB_ASSOC);
30 /* FIXME: take channel into account when picking SSIDs if a channel
31 * is set.
34 if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags))
35 channel = assoc_req->channel;
37 lbs_deb_assoc("SSID '%s' requested\n",
38 escape_essid(assoc_req->ssid, assoc_req->ssid_len));
39 if (assoc_req->mode == IW_MODE_INFRA) {
40 lbs_send_specific_ssid_scan(priv, assoc_req->ssid,
41 assoc_req->ssid_len, 0);
43 bss = lbs_find_ssid_in_list(priv, assoc_req->ssid,
44 assoc_req->ssid_len, NULL, IW_MODE_INFRA, channel);
45 if (bss != NULL) {
46 memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor));
47 ret = lbs_associate(priv, assoc_req);
48 } else {
49 lbs_deb_assoc("SSID not found; cannot associate\n");
51 } else if (assoc_req->mode == IW_MODE_ADHOC) {
52 /* Scan for the network, do not save previous results. Stale
53 * scan data will cause us to join a non-existant adhoc network
55 lbs_send_specific_ssid_scan(priv, assoc_req->ssid,
56 assoc_req->ssid_len, 1);
58 /* Search for the requested SSID in the scan table */
59 bss = lbs_find_ssid_in_list(priv, assoc_req->ssid,
60 assoc_req->ssid_len, NULL, IW_MODE_ADHOC, channel);
61 if (bss != NULL) {
62 lbs_deb_assoc("SSID found, will join\n");
63 memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor));
64 lbs_join_adhoc_network(priv, assoc_req);
65 } else {
66 /* else send START command */
67 lbs_deb_assoc("SSID not found, creating adhoc network\n");
68 memcpy(&assoc_req->bss.ssid, &assoc_req->ssid,
69 IW_ESSID_MAX_SIZE);
70 assoc_req->bss.ssid_len = assoc_req->ssid_len;
71 lbs_start_adhoc_network(priv, assoc_req);
75 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
76 return ret;
80 static int assoc_helper_bssid(struct lbs_private *priv,
81 struct assoc_request * assoc_req)
83 int ret = 0;
84 struct bss_descriptor * bss;
85 DECLARE_MAC_BUF(mac);
87 lbs_deb_enter_args(LBS_DEB_ASSOC, "BSSID %s",
88 print_mac(mac, assoc_req->bssid));
90 /* Search for index position in list for requested MAC */
91 bss = lbs_find_bssid_in_list(priv, assoc_req->bssid,
92 assoc_req->mode);
93 if (bss == NULL) {
94 lbs_deb_assoc("ASSOC: WAP: BSSID %s not found, "
95 "cannot associate.\n", print_mac(mac, assoc_req->bssid));
96 goto out;
99 memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor));
100 if (assoc_req->mode == IW_MODE_INFRA) {
101 ret = lbs_associate(priv, assoc_req);
102 lbs_deb_assoc("ASSOC: lbs_associate(bssid) returned %d\n", ret);
103 } else if (assoc_req->mode == IW_MODE_ADHOC) {
104 lbs_join_adhoc_network(priv, assoc_req);
107 out:
108 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
109 return ret;
113 static int assoc_helper_associate(struct lbs_private *priv,
114 struct assoc_request * assoc_req)
116 int ret = 0, done = 0;
118 lbs_deb_enter(LBS_DEB_ASSOC);
120 /* If we're given and 'any' BSSID, try associating based on SSID */
122 if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) {
123 if (compare_ether_addr(bssid_any, assoc_req->bssid)
124 && compare_ether_addr(bssid_off, assoc_req->bssid)) {
125 ret = assoc_helper_bssid(priv, assoc_req);
126 done = 1;
130 if (!done && test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) {
131 ret = assoc_helper_essid(priv, assoc_req);
134 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
135 return ret;
139 static int assoc_helper_mode(struct lbs_private *priv,
140 struct assoc_request * assoc_req)
142 int ret = 0;
144 lbs_deb_enter(LBS_DEB_ASSOC);
146 if (assoc_req->mode == priv->mode)
147 goto done;
149 if (assoc_req->mode == IW_MODE_INFRA) {
150 if (priv->psstate != PS_STATE_FULL_POWER)
151 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
152 priv->psmode = LBS802_11POWERMODECAM;
155 priv->mode = assoc_req->mode;
156 ret = lbs_prepare_and_send_command(priv,
157 CMD_802_11_SNMP_MIB,
158 0, CMD_OPTION_WAITFORRSP,
159 OID_802_11_INFRASTRUCTURE_MODE,
160 /* Shoot me now */ (void *) (size_t) assoc_req->mode);
162 done:
163 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
164 return ret;
168 int lbs_update_channel(struct lbs_private *priv)
170 int ret;
172 /* the channel in f/w could be out of sync; get the current channel */
173 lbs_deb_enter(LBS_DEB_ASSOC);
175 ret = lbs_get_channel(priv);
176 if (ret > 0) {
177 priv->curbssparams.channel = ret;
178 ret = 0;
180 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
181 return ret;
184 void lbs_sync_channel(struct work_struct *work)
186 struct lbs_private *priv = container_of(work, struct lbs_private,
187 sync_channel);
189 lbs_deb_enter(LBS_DEB_ASSOC);
190 if (lbs_update_channel(priv))
191 lbs_pr_info("Channel synchronization failed.");
192 lbs_deb_leave(LBS_DEB_ASSOC);
195 static int assoc_helper_channel(struct lbs_private *priv,
196 struct assoc_request * assoc_req)
198 int ret = 0;
200 lbs_deb_enter(LBS_DEB_ASSOC);
202 ret = lbs_update_channel(priv);
203 if (ret) {
204 lbs_deb_assoc("ASSOC: channel: error getting channel.\n");
205 goto done;
208 if (assoc_req->channel == priv->curbssparams.channel)
209 goto done;
211 if (priv->mesh_dev) {
212 /* Change mesh channel first; 21.p21 firmware won't let
213 you change channel otherwise (even though it'll return
214 an error to this */
215 lbs_mesh_config(priv, 0, assoc_req->channel);
218 lbs_deb_assoc("ASSOC: channel: %d -> %d\n",
219 priv->curbssparams.channel, assoc_req->channel);
221 ret = lbs_set_channel(priv, assoc_req->channel);
222 if (ret < 0)
223 lbs_deb_assoc("ASSOC: channel: error setting channel.\n");
225 /* FIXME: shouldn't need to grab the channel _again_ after setting
226 * it since the firmware is supposed to return the new channel, but
227 * whatever... */
228 ret = lbs_update_channel(priv);
229 if (ret) {
230 lbs_deb_assoc("ASSOC: channel: error getting channel.\n");
231 goto done;
234 if (assoc_req->channel != priv->curbssparams.channel) {
235 lbs_deb_assoc("ASSOC: channel: failed to update channel to %d\n",
236 assoc_req->channel);
237 goto restore_mesh;
240 if ( assoc_req->secinfo.wep_enabled
241 && (assoc_req->wep_keys[0].len
242 || assoc_req->wep_keys[1].len
243 || assoc_req->wep_keys[2].len
244 || assoc_req->wep_keys[3].len)) {
245 /* Make sure WEP keys are re-sent to firmware */
246 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
249 /* Must restart/rejoin adhoc networks after channel change */
250 set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
252 restore_mesh:
253 if (priv->mesh_dev)
254 lbs_mesh_config(priv, 1, priv->curbssparams.channel);
256 done:
257 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
258 return ret;
262 static int assoc_helper_wep_keys(struct lbs_private *priv,
263 struct assoc_request *assoc_req)
265 int i;
266 int ret = 0;
268 lbs_deb_enter(LBS_DEB_ASSOC);
270 /* Set or remove WEP keys */
271 if (assoc_req->wep_keys[0].len || assoc_req->wep_keys[1].len ||
272 assoc_req->wep_keys[2].len || assoc_req->wep_keys[3].len)
273 ret = lbs_cmd_802_11_set_wep(priv, CMD_ACT_ADD, assoc_req);
274 else
275 ret = lbs_cmd_802_11_set_wep(priv, CMD_ACT_REMOVE, assoc_req);
277 if (ret)
278 goto out;
280 /* enable/disable the MAC's WEP packet filter */
281 if (assoc_req->secinfo.wep_enabled)
282 priv->currentpacketfilter |= CMD_ACT_MAC_WEP_ENABLE;
283 else
284 priv->currentpacketfilter &= ~CMD_ACT_MAC_WEP_ENABLE;
286 ret = lbs_set_mac_packet_filter(priv);
287 if (ret)
288 goto out;
290 mutex_lock(&priv->lock);
292 /* Copy WEP keys into priv wep key fields */
293 for (i = 0; i < 4; i++) {
294 memcpy(&priv->wep_keys[i], &assoc_req->wep_keys[i],
295 sizeof(struct enc_key));
297 priv->wep_tx_keyidx = assoc_req->wep_tx_keyidx;
299 mutex_unlock(&priv->lock);
301 out:
302 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
303 return ret;
306 static int assoc_helper_secinfo(struct lbs_private *priv,
307 struct assoc_request * assoc_req)
309 int ret = 0;
310 uint16_t do_wpa;
311 uint16_t rsn = 0;
313 lbs_deb_enter(LBS_DEB_ASSOC);
315 memcpy(&priv->secinfo, &assoc_req->secinfo,
316 sizeof(struct lbs_802_11_security));
318 ret = lbs_set_mac_packet_filter(priv);
319 if (ret)
320 goto out;
322 /* If RSN is already enabled, don't try to enable it again, since
323 * ENABLE_RSN resets internal state machines and will clobber the
324 * 4-way WPA handshake.
327 /* Get RSN enabled/disabled */
328 ret = lbs_cmd_802_11_enable_rsn(priv, CMD_ACT_GET, &rsn);
329 if (ret) {
330 lbs_deb_assoc("Failed to get RSN status: %d\n", ret);
331 goto out;
334 /* Don't re-enable RSN if it's already enabled */
335 do_wpa = assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled;
336 if (do_wpa == rsn)
337 goto out;
339 /* Set RSN enabled/disabled */
340 ret = lbs_cmd_802_11_enable_rsn(priv, CMD_ACT_SET, &do_wpa);
342 out:
343 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
344 return ret;
348 static int assoc_helper_wpa_keys(struct lbs_private *priv,
349 struct assoc_request * assoc_req)
351 int ret = 0;
352 unsigned int flags = assoc_req->flags;
354 lbs_deb_enter(LBS_DEB_ASSOC);
356 /* Work around older firmware bug where WPA unicast and multicast
357 * keys must be set independently. Seen in SDIO parts with firmware
358 * version 5.0.11p0.
361 if (test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) {
362 clear_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
363 ret = lbs_prepare_and_send_command(priv,
364 CMD_802_11_KEY_MATERIAL,
365 CMD_ACT_SET,
366 CMD_OPTION_WAITFORRSP,
367 0, assoc_req);
368 assoc_req->flags = flags;
371 if (ret)
372 goto out;
374 if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) {
375 clear_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
377 ret = lbs_prepare_and_send_command(priv,
378 CMD_802_11_KEY_MATERIAL,
379 CMD_ACT_SET,
380 CMD_OPTION_WAITFORRSP,
381 0, assoc_req);
382 assoc_req->flags = flags;
385 out:
386 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
387 return ret;
391 static int assoc_helper_wpa_ie(struct lbs_private *priv,
392 struct assoc_request * assoc_req)
394 int ret = 0;
396 lbs_deb_enter(LBS_DEB_ASSOC);
398 if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) {
399 memcpy(&priv->wpa_ie, &assoc_req->wpa_ie, assoc_req->wpa_ie_len);
400 priv->wpa_ie_len = assoc_req->wpa_ie_len;
401 } else {
402 memset(&priv->wpa_ie, 0, MAX_WPA_IE_LEN);
403 priv->wpa_ie_len = 0;
406 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
407 return ret;
411 static int should_deauth_infrastructure(struct lbs_private *priv,
412 struct assoc_request * assoc_req)
414 int ret = 0;
416 if (priv->connect_status != LBS_CONNECTED)
417 return 0;
419 lbs_deb_enter(LBS_DEB_ASSOC);
420 if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) {
421 lbs_deb_assoc("Deauthenticating due to new SSID\n");
422 ret = 1;
423 goto out;
426 if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) {
427 if (priv->secinfo.auth_mode != assoc_req->secinfo.auth_mode) {
428 lbs_deb_assoc("Deauthenticating due to new security\n");
429 ret = 1;
430 goto out;
434 if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) {
435 lbs_deb_assoc("Deauthenticating due to new BSSID\n");
436 ret = 1;
437 goto out;
440 if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) {
441 lbs_deb_assoc("Deauthenticating due to channel switch\n");
442 ret = 1;
443 goto out;
446 /* FIXME: deal with 'auto' mode somehow */
447 if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) {
448 if (assoc_req->mode != IW_MODE_INFRA) {
449 lbs_deb_assoc("Deauthenticating due to leaving "
450 "infra mode\n");
451 ret = 1;
452 goto out;
456 out:
457 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
458 return ret;
462 static int should_stop_adhoc(struct lbs_private *priv,
463 struct assoc_request * assoc_req)
465 lbs_deb_enter(LBS_DEB_ASSOC);
467 if (priv->connect_status != LBS_CONNECTED)
468 return 0;
470 if (lbs_ssid_cmp(priv->curbssparams.ssid,
471 priv->curbssparams.ssid_len,
472 assoc_req->ssid, assoc_req->ssid_len) != 0)
473 return 1;
475 /* FIXME: deal with 'auto' mode somehow */
476 if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) {
477 if (assoc_req->mode != IW_MODE_ADHOC)
478 return 1;
481 if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) {
482 if (assoc_req->channel != priv->curbssparams.channel)
483 return 1;
486 lbs_deb_leave(LBS_DEB_ASSOC);
487 return 0;
491 void lbs_association_worker(struct work_struct *work)
493 struct lbs_private *priv = container_of(work, struct lbs_private,
494 assoc_work.work);
495 struct assoc_request * assoc_req = NULL;
496 int ret = 0;
497 int find_any_ssid = 0;
498 DECLARE_MAC_BUF(mac);
500 lbs_deb_enter(LBS_DEB_ASSOC);
502 mutex_lock(&priv->lock);
503 assoc_req = priv->pending_assoc_req;
504 priv->pending_assoc_req = NULL;
505 priv->in_progress_assoc_req = assoc_req;
506 mutex_unlock(&priv->lock);
508 if (!assoc_req)
509 goto done;
511 lbs_deb_assoc(
512 "Association Request:\n"
513 " flags: 0x%08lx\n"
514 " SSID: '%s'\n"
515 " chann: %d\n"
516 " band: %d\n"
517 " mode: %d\n"
518 " BSSID: %s\n"
519 " secinfo: %s%s%s\n"
520 " auth_mode: %d\n",
521 assoc_req->flags,
522 escape_essid(assoc_req->ssid, assoc_req->ssid_len),
523 assoc_req->channel, assoc_req->band, assoc_req->mode,
524 print_mac(mac, assoc_req->bssid),
525 assoc_req->secinfo.WPAenabled ? " WPA" : "",
526 assoc_req->secinfo.WPA2enabled ? " WPA2" : "",
527 assoc_req->secinfo.wep_enabled ? " WEP" : "",
528 assoc_req->secinfo.auth_mode);
530 /* If 'any' SSID was specified, find an SSID to associate with */
531 if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)
532 && !assoc_req->ssid_len)
533 find_any_ssid = 1;
535 /* But don't use 'any' SSID if there's a valid locked BSSID to use */
536 if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) {
537 if (compare_ether_addr(assoc_req->bssid, bssid_any)
538 && compare_ether_addr(assoc_req->bssid, bssid_off))
539 find_any_ssid = 0;
542 if (find_any_ssid) {
543 u8 new_mode;
545 ret = lbs_find_best_network_ssid(priv, assoc_req->ssid,
546 &assoc_req->ssid_len, assoc_req->mode, &new_mode);
547 if (ret) {
548 lbs_deb_assoc("Could not find best network\n");
549 ret = -ENETUNREACH;
550 goto out;
553 /* Ensure we switch to the mode of the AP */
554 if (assoc_req->mode == IW_MODE_AUTO) {
555 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
556 assoc_req->mode = new_mode;
561 * Check if the attributes being changing require deauthentication
562 * from the currently associated infrastructure access point.
564 if (priv->mode == IW_MODE_INFRA) {
565 if (should_deauth_infrastructure(priv, assoc_req)) {
566 ret = lbs_send_deauthentication(priv);
567 if (ret) {
568 lbs_deb_assoc("Deauthentication due to new "
569 "configuration request failed: %d\n",
570 ret);
573 } else if (priv->mode == IW_MODE_ADHOC) {
574 if (should_stop_adhoc(priv, assoc_req)) {
575 ret = lbs_stop_adhoc_network(priv);
576 if (ret) {
577 lbs_deb_assoc("Teardown of AdHoc network due to "
578 "new configuration request failed: %d\n",
579 ret);
585 /* Send the various configuration bits to the firmware */
586 if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) {
587 ret = assoc_helper_mode(priv, assoc_req);
588 if (ret)
589 goto out;
592 if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) {
593 ret = assoc_helper_channel(priv, assoc_req);
594 if (ret)
595 goto out;
598 if ( test_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags)
599 || test_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags)) {
600 ret = assoc_helper_wep_keys(priv, assoc_req);
601 if (ret)
602 goto out;
605 if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) {
606 ret = assoc_helper_secinfo(priv, assoc_req);
607 if (ret)
608 goto out;
611 if (test_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags)) {
612 ret = assoc_helper_wpa_ie(priv, assoc_req);
613 if (ret)
614 goto out;
617 if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)
618 || test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) {
619 ret = assoc_helper_wpa_keys(priv, assoc_req);
620 if (ret)
621 goto out;
624 /* SSID/BSSID should be the _last_ config option set, because they
625 * trigger the association attempt.
627 if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)
628 || test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) {
629 int success = 1;
631 ret = assoc_helper_associate(priv, assoc_req);
632 if (ret) {
633 lbs_deb_assoc("ASSOC: association unsuccessful: %d\n",
634 ret);
635 success = 0;
638 if (priv->connect_status != LBS_CONNECTED) {
639 lbs_deb_assoc("ASSOC: association unsuccessful, "
640 "not connected\n");
641 success = 0;
644 if (success) {
645 lbs_deb_assoc("associated to %s\n",
646 print_mac(mac, priv->curbssparams.bssid));
647 lbs_prepare_and_send_command(priv,
648 CMD_802_11_RSSI,
649 0, CMD_OPTION_WAITFORRSP, 0, NULL);
651 lbs_prepare_and_send_command(priv,
652 CMD_802_11_GET_LOG,
653 0, CMD_OPTION_WAITFORRSP, 0, NULL);
654 } else {
655 ret = -1;
659 out:
660 if (ret) {
661 lbs_deb_assoc("ASSOC: reconfiguration attempt unsuccessful: %d\n",
662 ret);
665 mutex_lock(&priv->lock);
666 priv->in_progress_assoc_req = NULL;
667 mutex_unlock(&priv->lock);
668 kfree(assoc_req);
670 done:
671 lbs_deb_leave(LBS_DEB_ASSOC);
676 * Caller MUST hold any necessary locks
678 struct assoc_request *lbs_get_association_request(struct lbs_private *priv)
680 struct assoc_request * assoc_req;
682 lbs_deb_enter(LBS_DEB_ASSOC);
683 if (!priv->pending_assoc_req) {
684 priv->pending_assoc_req = kzalloc(sizeof(struct assoc_request),
685 GFP_KERNEL);
686 if (!priv->pending_assoc_req) {
687 lbs_pr_info("Not enough memory to allocate association"
688 " request!\n");
689 return NULL;
693 /* Copy current configuration attributes to the association request,
694 * but don't overwrite any that are already set.
696 assoc_req = priv->pending_assoc_req;
697 if (!test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) {
698 memcpy(&assoc_req->ssid, &priv->curbssparams.ssid,
699 IW_ESSID_MAX_SIZE);
700 assoc_req->ssid_len = priv->curbssparams.ssid_len;
703 if (!test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags))
704 assoc_req->channel = priv->curbssparams.channel;
706 if (!test_bit(ASSOC_FLAG_BAND, &assoc_req->flags))
707 assoc_req->band = priv->curbssparams.band;
709 if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags))
710 assoc_req->mode = priv->mode;
712 if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) {
713 memcpy(&assoc_req->bssid, priv->curbssparams.bssid,
714 ETH_ALEN);
717 if (!test_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags)) {
718 int i;
719 for (i = 0; i < 4; i++) {
720 memcpy(&assoc_req->wep_keys[i], &priv->wep_keys[i],
721 sizeof(struct enc_key));
725 if (!test_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags))
726 assoc_req->wep_tx_keyidx = priv->wep_tx_keyidx;
728 if (!test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) {
729 memcpy(&assoc_req->wpa_mcast_key, &priv->wpa_mcast_key,
730 sizeof(struct enc_key));
733 if (!test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) {
734 memcpy(&assoc_req->wpa_unicast_key, &priv->wpa_unicast_key,
735 sizeof(struct enc_key));
738 if (!test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) {
739 memcpy(&assoc_req->secinfo, &priv->secinfo,
740 sizeof(struct lbs_802_11_security));
743 if (!test_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags)) {
744 memcpy(&assoc_req->wpa_ie, &priv->wpa_ie,
745 MAX_WPA_IE_LEN);
746 assoc_req->wpa_ie_len = priv->wpa_ie_len;
749 lbs_deb_leave(LBS_DEB_ASSOC);
750 return assoc_req;