1 /******************************************************************************
3 * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of version 2 of the GNU General Public License as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
21 * The full GNU General Public License is included in this distribution in the
22 * file called LICENSE.
24 * Contact Information:
25 * James P. Ketrenos <ipw2100-admin@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
28 *****************************************************************************/
30 #include <net/mac80211.h>
32 #include "iwl-eeprom.h"
37 #include "iwl-helpers.h"
39 int iwl_send_static_wepkey_cmd(struct iwl_priv
*priv
, u8 send_if_empty
)
42 u8 buff
[sizeof(struct iwl_wep_cmd
) +
43 sizeof(struct iwl_wep_key
) * WEP_KEYS_MAX
];
44 struct iwl_wep_cmd
*wep_cmd
= (struct iwl_wep_cmd
*)buff
;
45 size_t cmd_size
= sizeof(struct iwl_wep_cmd
);
46 struct iwl_host_cmd cmd
= {
49 .meta
.flags
= CMD_ASYNC
,
52 memset(wep_cmd
, 0, cmd_size
+
53 (sizeof(struct iwl_wep_key
) * WEP_KEYS_MAX
));
55 for (i
= 0; i
< WEP_KEYS_MAX
; i
++) {
56 wep_cmd
->key
[i
].key_index
= i
;
57 if (priv
->wep_keys
[i
].key_size
) {
58 wep_cmd
->key
[i
].key_offset
= i
;
61 wep_cmd
->key
[i
].key_offset
= WEP_INVALID_OFFSET
;
64 wep_cmd
->key
[i
].key_size
= priv
->wep_keys
[i
].key_size
;
65 memcpy(&wep_cmd
->key
[i
].key
[3], priv
->wep_keys
[i
].key
,
66 priv
->wep_keys
[i
].key_size
);
69 wep_cmd
->global_key_type
= WEP_KEY_WEP_TYPE
;
70 wep_cmd
->num_keys
= WEP_KEYS_MAX
;
72 cmd_size
+= sizeof(struct iwl_wep_key
) * WEP_KEYS_MAX
;
76 if (not_empty
|| send_if_empty
)
77 return iwl_send_cmd(priv
, &cmd
);
82 int iwl_remove_default_wep_key(struct iwl_priv
*priv
,
83 struct ieee80211_key_conf
*key
)
88 spin_lock_irqsave(&priv
->sta_lock
, flags
);
89 priv
->default_wep_key
--;
90 memset(&priv
->wep_keys
[key
->keyidx
], 0, sizeof(priv
->wep_keys
[0]));
91 ret
= iwl_send_static_wepkey_cmd(priv
, 1);
92 spin_unlock_irqrestore(&priv
->sta_lock
, flags
);
97 int iwl_set_default_wep_key(struct iwl_priv
*priv
,
98 struct ieee80211_key_conf
*keyconf
)
103 keyconf
->flags
&= ~IEEE80211_KEY_FLAG_GENERATE_IV
;
104 keyconf
->hw_key_idx
= keyconf
->keyidx
;
105 priv
->stations
[IWL_AP_ID
].keyinfo
.alg
= ALG_WEP
;
107 spin_lock_irqsave(&priv
->sta_lock
, flags
);
108 priv
->default_wep_key
++;
110 priv
->wep_keys
[keyconf
->keyidx
].key_size
= keyconf
->keylen
;
111 memcpy(&priv
->wep_keys
[keyconf
->keyidx
].key
, &keyconf
->key
,
114 ret
= iwl_send_static_wepkey_cmd(priv
, 0);
115 spin_unlock_irqrestore(&priv
->sta_lock
, flags
);