35 #include <linux/slab.h>
36 #include <linux/module.h>
40 #include <linux/wireless.h>
44 static const char *libipw_modes[] = {
45 "?",
"a",
"b",
"ab",
"g",
"ag",
"bg",
"abg"
48 static inline unsigned int elapsed_jiffies_msecs(
unsigned long start)
58 #define MAX_CUSTOM_LEN 64
59 static char *libipw_translate_scan(
struct libipw_device *ieee,
60 char *start,
char *
stop,
75 start = iwe_stream_add_event(info, start, stop, &iwe,
IW_EV_ADDR_LEN);
83 start = iwe_stream_add_point(info, start, stop,
89 libipw_modes[network->
mode]);
90 start = iwe_stream_add_event(info, start, stop, &iwe,
IW_EV_CHAR_LEN);
100 start = iwe_stream_add_event(info, start, stop,
110 start = iwe_stream_add_event(info, start, stop, &iwe,
IW_EV_FREQ_LEN);
118 iwe.
u.
data.length = 0;
119 start = iwe_stream_add_point(info, start, stop,
120 &iwe, network->
ssid);
125 current_val = start + iwe_stream_lcp_len(info);
130 for (i = 0, j = 0; i < network->
rates_len;) {
131 if (j < network->rates_ex_len &&
133 (network->
rates[i] & 0x7F)))
134 rate = network->
rates_ex[j++] & 0x7F;
136 rate = network->
rates[i++] & 0x7F;
138 iwe.
u.
bitrate.value = ((rate & 0x7f) * 500000);
140 current_val = iwe_stream_add_value(info, start, current_val,
146 iwe.
u.
bitrate.value = ((rate & 0x7f) * 500000);
148 current_val = iwe_stream_add_value(info, start, current_val,
152 if ((current_val - start) > iwe_stream_lcp_len(info))
166 iwe.
u.
qual.qual = 100;
175 network->
stats.rssi))) /
179 if (iwe.
u.
qual.qual > 100)
180 iwe.
u.
qual.qual = 100;
181 else if (iwe.
u.
qual.qual < 1)
187 iwe.
u.
qual.noise = 0;
194 iwe.
u.
qual.level = 0;
199 start = iwe_stream_add_event(info, start, stop, &iwe,
IW_EV_QUAL_LEN);
205 if (iwe.
u.
data.length)
206 start = iwe_stream_add_point(info, start, stop, &iwe, custom);
208 memset(&iwe, 0,
sizeof(iwe));
214 start = iwe_stream_add_point(info, start, stop, &iwe, buf);
217 memset(&iwe, 0,
sizeof(iwe));
223 start = iwe_stream_add_point(info, start, stop, &iwe, buf);
231 " Last beacon: %ums ago",
234 if (iwe.
u.
data.length)
235 start = iwe_stream_add_point(info, start, stop, &iwe, custom);
256 start = iwe_stream_add_point(info, start, stop, &iwe, custom);
262 #define SCAN_ITEM_SIZE 128
273 char *
stop = ev + wrqu->
data.length;
290 ev = libipw_translate_scan(ieee, ev, stop, network,
294 "%pM)' due to age (%ums).\n",
298 elapsed_jiffies_msecs(
303 spin_unlock_irqrestore(&ieee->
lock, flags);
306 wrqu->
data.flags = 0;
341 "provided" :
"default");
346 if (key_provided && *crypt) {
378 if (*crypt !=
NULL && (*crypt)->ops !=
NULL &&
379 strcmp((*crypt)->ops->name,
"WEP") != 0) {
385 if (*crypt ==
NULL && host_crypto) {
391 if (new_crypt ==
NULL)
394 if (!new_crypt->
ops) {
395 request_module(
"lib80211_crypt_wep");
399 if (new_crypt->
ops && try_module_get(new_crypt->
ops->owner))
400 new_crypt->
priv = new_crypt->
ops->init(key);
402 if (!new_crypt->
ops || !new_crypt->
priv) {
407 "load module lib80211_crypt_wep\n", dev->
name);
415 len = erq->
length <= 5 ? 5 : 13;
425 (*crypt)->ops->set_key(sec.
keys[key], len,
NULL,
436 NULL, (*crypt)->priv);
442 (*crypt)->ops->set_key(sec.
keys[key], 13,
NULL,
464 "OPEN" :
"SHARED KEY");
500 erq->
flags = key + 1;
585 goto skip_host_crypt;
590 module =
"lib80211_crypt_wep";
594 module =
"lib80211_crypt_tkip";
598 module =
"lib80211_crypt_ccmp";
609 request_module(module);
619 if (*crypt ==
NULL || (*crypt)->ops != ops) {
624 new_crypt = kzalloc(
sizeof(*new_crypt),
GFP_KERNEL);
625 if (new_crypt ==
NULL) {
630 if (new_crypt->
ops && try_module_get(new_crypt->
ops->owner))
631 new_crypt->
priv = new_crypt->
ops->init(idx);
640 if (ext->
key_len > 0 && (*crypt)->ops->set_key &&
642 (*crypt)->priv) < 0) {
690 int idx, max_key_len;
692 max_key_len = encoding->
length -
sizeof(*ext);
709 encoding->
flags = idx + 1;
710 memset(ext, 0,
sizeof(*ext));