aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ps3_gelic_wireless.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/net/ps3_gelic_wireless.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/net/ps3_gelic_wireless.c')
-rw-r--r--drivers/net/ps3_gelic_wireless.c150
1 files changed, 8 insertions, 142 deletions
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c
index 227b141c4fbd..f0be507e5324 100644
--- a/drivers/net/ps3_gelic_wireless.c
+++ b/drivers/net/ps3_gelic_wireless.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/slab.h>
24 25
25#include <linux/etherdevice.h> 26#include <linux/etherdevice.h>
26#include <linux/ethtool.h> 27#include <linux/ethtool.h>
@@ -1389,113 +1390,6 @@ static int gelic_wl_get_mode(struct net_device *netdev,
1389 return 0; 1390 return 0;
1390} 1391}
1391 1392
1392#ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE
1393/* SIOCIWFIRSTPRIV */
1394static int hex2bin(u8 *str, u8 *bin, unsigned int len)
1395{
1396 unsigned int i;
1397 static unsigned char *hex = "0123456789ABCDEF";
1398 unsigned char *p, *q;
1399 u8 tmp;
1400
1401 if (len != WPA_PSK_LEN * 2)
1402 return -EINVAL;
1403
1404 for (i = 0; i < WPA_PSK_LEN * 2; i += 2) {
1405 p = strchr(hex, toupper(str[i]));
1406 q = strchr(hex, toupper(str[i + 1]));
1407 if (!p || !q) {
1408 pr_info("%s: unconvertible PSK digit=%d\n",
1409 __func__, i);
1410 return -EINVAL;
1411 }
1412 tmp = ((p - hex) << 4) + (q - hex);
1413 *bin++ = tmp;
1414 }
1415 return 0;
1416};
1417
1418static int gelic_wl_priv_set_psk(struct net_device *net_dev,
1419 struct iw_request_info *info,
1420 union iwreq_data *data, char *extra)
1421{
1422 struct gelic_wl_info *wl = port_wl(netdev_priv(net_dev));
1423 unsigned int len;
1424 unsigned long irqflag;
1425 int ret = 0;
1426
1427 pr_debug("%s:<- len=%d\n", __func__, data->data.length);
1428 len = data->data.length - 1;
1429 if (len <= 2)
1430 return -EINVAL;
1431
1432 spin_lock_irqsave(&wl->lock, irqflag);
1433 if (extra[0] == '"' && extra[len - 1] == '"') {
1434 pr_debug("%s: passphrase mode\n", __func__);
1435 /* pass phrase */
1436 if (GELIC_WL_EURUS_PSK_MAX_LEN < (len - 2)) {
1437 pr_info("%s: passphrase too long\n", __func__);
1438 ret = -E2BIG;
1439 goto out;
1440 }
1441 memset(wl->psk, 0, sizeof(wl->psk));
1442 wl->psk_len = len - 2;
1443 memcpy(wl->psk, &(extra[1]), wl->psk_len);
1444 wl->psk_type = GELIC_EURUS_WPA_PSK_PASSPHRASE;
1445 } else {
1446 ret = hex2bin(extra, wl->psk, len);
1447 if (ret)
1448 goto out;
1449 wl->psk_len = WPA_PSK_LEN;
1450 wl->psk_type = GELIC_EURUS_WPA_PSK_BIN;
1451 }
1452 set_bit(GELIC_WL_STAT_WPA_PSK_SET, &wl->stat);
1453out:
1454 spin_unlock_irqrestore(&wl->lock, irqflag);
1455 pr_debug("%s:->\n", __func__);
1456 return ret;
1457}
1458
1459static int gelic_wl_priv_get_psk(struct net_device *net_dev,
1460 struct iw_request_info *info,
1461 union iwreq_data *data, char *extra)
1462{
1463 struct gelic_wl_info *wl = port_wl(netdev_priv(net_dev));
1464 char *p;
1465 unsigned long irqflag;
1466 unsigned int i;
1467
1468 pr_debug("%s:<-\n", __func__);
1469 if (!capable(CAP_NET_ADMIN))
1470 return -EPERM;
1471
1472 spin_lock_irqsave(&wl->lock, irqflag);
1473 p = extra;
1474 if (test_bit(GELIC_WL_STAT_WPA_PSK_SET, &wl->stat)) {
1475 if (wl->psk_type == GELIC_EURUS_WPA_PSK_BIN) {
1476 for (i = 0; i < wl->psk_len; i++) {
1477 sprintf(p, "%02xu", wl->psk[i]);
1478 p += 2;
1479 }
1480 *p = '\0';
1481 data->data.length = wl->psk_len * 2;
1482 } else {
1483 *p++ = '"';
1484 memcpy(p, wl->psk, wl->psk_len);
1485 p += wl->psk_len;
1486 *p++ = '"';
1487 *p = '\0';
1488 data->data.length = wl->psk_len + 2;
1489 }
1490 } else
1491 /* no psk set */
1492 data->data.length = 0;
1493 spin_unlock_irqrestore(&wl->lock, irqflag);
1494 pr_debug("%s:-> %d\n", __func__, data->data.length);
1495 return 0;
1496}
1497#endif
1498
1499/* SIOCGIWNICKN */ 1393/* SIOCGIWNICKN */
1500static int gelic_wl_get_nick(struct net_device *net_dev, 1394static int gelic_wl_get_nick(struct net_device *net_dev,
1501 struct iw_request_info *info, 1395 struct iw_request_info *info,
@@ -1571,8 +1465,10 @@ static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan,
1571 init_completion(&wl->scan_done); 1465 init_completion(&wl->scan_done);
1572 /* 1466 /*
1573 * If we have already a bss list, don't try to get new 1467 * If we have already a bss list, don't try to get new
1468 * unless we are doing an ESSID scan
1574 */ 1469 */
1575 if (!always_scan && wl->scan_stat == GELIC_WL_SCAN_STAT_GOT_LIST) { 1470 if ((!essid_len && !always_scan)
1471 && wl->scan_stat == GELIC_WL_SCAN_STAT_GOT_LIST) {
1576 pr_debug("%s: already has the list\n", __func__); 1472 pr_debug("%s: already has the list\n", __func__);
1577 complete(&wl->scan_done); 1473 complete(&wl->scan_done);
1578 goto out; 1474 goto out;
@@ -1673,7 +1569,7 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
1673 } 1569 }
1674 } 1570 }
1675 1571
1676 /* put them in the newtork_list */ 1572 /* put them in the network_list */
1677 for (i = 0, scan_info_size = 0, scan_info = buf; 1573 for (i = 0, scan_info_size = 0, scan_info = buf;
1678 scan_info_size < data_len; 1574 scan_info_size < data_len;
1679 i++, scan_info_size += be16_to_cpu(scan_info->size), 1575 i++, scan_info_size += be16_to_cpu(scan_info->size),
@@ -2009,7 +1905,7 @@ static int gelic_wl_do_wpa_setup(struct gelic_wl_info *wl)
2009 /* PSK type */ 1905 /* PSK type */
2010 wpa->psk_type = cpu_to_be16(wl->psk_type); 1906 wpa->psk_type = cpu_to_be16(wl->psk_type);
2011#ifdef DEBUG 1907#ifdef DEBUG
2012 pr_debug("%s: sec=%s psktype=%s\nn", __func__, 1908 pr_debug("%s: sec=%s psktype=%s\n", __func__,
2013 wpasecstr(wpa->security), 1909 wpasecstr(wpa->security),
2014 (wpa->psk_type == GELIC_EURUS_WPA_PSK_BIN) ? 1910 (wpa->psk_type == GELIC_EURUS_WPA_PSK_BIN) ?
2015 "BIN" : "passphrase"); 1911 "BIN" : "passphrase");
@@ -2019,9 +1915,9 @@ static int gelic_wl_do_wpa_setup(struct gelic_wl_info *wl)
2019 * the debug log because this dumps your precious 1915 * the debug log because this dumps your precious
2020 * passphrase/key. 1916 * passphrase/key.
2021 */ 1917 */
2022 pr_debug("%s: psk=%s\n", 1918 pr_debug("%s: psk=%s\n", __func__,
2023 (wpa->psk_type == GELIC_EURUS_WPA_PSK_BIN) ? 1919 (wpa->psk_type == GELIC_EURUS_WPA_PSK_BIN) ?
2024 (char *)"N/A" : (char *)wpa->psk); 1920 "N/A" : wpa->psk);
2025#endif 1921#endif
2026#endif 1922#endif
2027 /* issue wpa setup */ 1923 /* issue wpa setup */
@@ -2406,40 +2302,10 @@ static const iw_handler gelic_wl_wext_handler[] =
2406 IW_IOCTL(SIOCGIWNICKN) = gelic_wl_get_nick, 2302 IW_IOCTL(SIOCGIWNICKN) = gelic_wl_get_nick,
2407}; 2303};
2408 2304
2409#ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE
2410static struct iw_priv_args gelic_wl_private_args[] =
2411{
2412 {
2413 .cmd = GELIC_WL_PRIV_SET_PSK,
2414 .set_args = IW_PRIV_TYPE_CHAR |
2415 (GELIC_WL_EURUS_PSK_MAX_LEN + 2),
2416 .name = "set_psk"
2417 },
2418 {
2419 .cmd = GELIC_WL_PRIV_GET_PSK,
2420 .get_args = IW_PRIV_TYPE_CHAR |
2421 (GELIC_WL_EURUS_PSK_MAX_LEN + 2),
2422 .name = "get_psk"
2423 }
2424};
2425
2426static const iw_handler gelic_wl_private_handler[] =
2427{
2428 gelic_wl_priv_set_psk,
2429 gelic_wl_priv_get_psk,
2430};
2431#endif
2432
2433static const struct iw_handler_def gelic_wl_wext_handler_def = { 2305static const struct iw_handler_def gelic_wl_wext_handler_def = {
2434 .num_standard = ARRAY_SIZE(gelic_wl_wext_handler), 2306 .num_standard = ARRAY_SIZE(gelic_wl_wext_handler),
2435 .standard = gelic_wl_wext_handler, 2307 .standard = gelic_wl_wext_handler,
2436 .get_wireless_stats = gelic_wl_get_wireless_stats, 2308 .get_wireless_stats = gelic_wl_get_wireless_stats,
2437#ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE
2438 .num_private = ARRAY_SIZE(gelic_wl_private_handler),
2439 .num_private_args = ARRAY_SIZE(gelic_wl_private_args),
2440 .private = gelic_wl_private_handler,
2441 .private_args = gelic_wl_private_args,
2442#endif
2443}; 2309};
2444 2310
2445static struct net_device * __devinit gelic_wl_alloc(struct gelic_card *card) 2311static struct net_device * __devinit gelic_wl_alloc(struct gelic_card *card)