diff options
Diffstat (limited to 'drivers/net/ps3_gelic_wireless.c')
-rw-r--r-- | drivers/net/ps3_gelic_wireless.c | 149 |
1 files changed, 7 insertions, 142 deletions
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c index 227b141c4fbd..2663b2fdc0bb 100644 --- a/drivers/net/ps3_gelic_wireless.c +++ b/drivers/net/ps3_gelic_wireless.c | |||
@@ -1389,113 +1389,6 @@ static int gelic_wl_get_mode(struct net_device *netdev, | |||
1389 | return 0; | 1389 | return 0; |
1390 | } | 1390 | } |
1391 | 1391 | ||
1392 | #ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE | ||
1393 | /* SIOCIWFIRSTPRIV */ | ||
1394 | static 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 | |||
1418 | static 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); | ||
1453 | out: | ||
1454 | spin_unlock_irqrestore(&wl->lock, irqflag); | ||
1455 | pr_debug("%s:->\n", __func__); | ||
1456 | return ret; | ||
1457 | } | ||
1458 | |||
1459 | static 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 */ | 1392 | /* SIOCGIWNICKN */ |
1500 | static int gelic_wl_get_nick(struct net_device *net_dev, | 1393 | static int gelic_wl_get_nick(struct net_device *net_dev, |
1501 | struct iw_request_info *info, | 1394 | struct iw_request_info *info, |
@@ -1571,8 +1464,10 @@ static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan, | |||
1571 | init_completion(&wl->scan_done); | 1464 | init_completion(&wl->scan_done); |
1572 | /* | 1465 | /* |
1573 | * If we have already a bss list, don't try to get new | 1466 | * If we have already a bss list, don't try to get new |
1467 | * unless we are doing an ESSID scan | ||
1574 | */ | 1468 | */ |
1575 | if (!always_scan && wl->scan_stat == GELIC_WL_SCAN_STAT_GOT_LIST) { | 1469 | if ((!essid_len && !always_scan) |
1470 | && wl->scan_stat == GELIC_WL_SCAN_STAT_GOT_LIST) { | ||
1576 | pr_debug("%s: already has the list\n", __func__); | 1471 | pr_debug("%s: already has the list\n", __func__); |
1577 | complete(&wl->scan_done); | 1472 | complete(&wl->scan_done); |
1578 | goto out; | 1473 | goto out; |
@@ -1673,7 +1568,7 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl) | |||
1673 | } | 1568 | } |
1674 | } | 1569 | } |
1675 | 1570 | ||
1676 | /* put them in the newtork_list */ | 1571 | /* put them in the network_list */ |
1677 | for (i = 0, scan_info_size = 0, scan_info = buf; | 1572 | for (i = 0, scan_info_size = 0, scan_info = buf; |
1678 | scan_info_size < data_len; | 1573 | scan_info_size < data_len; |
1679 | i++, scan_info_size += be16_to_cpu(scan_info->size), | 1574 | i++, scan_info_size += be16_to_cpu(scan_info->size), |
@@ -2009,7 +1904,7 @@ static int gelic_wl_do_wpa_setup(struct gelic_wl_info *wl) | |||
2009 | /* PSK type */ | 1904 | /* PSK type */ |
2010 | wpa->psk_type = cpu_to_be16(wl->psk_type); | 1905 | wpa->psk_type = cpu_to_be16(wl->psk_type); |
2011 | #ifdef DEBUG | 1906 | #ifdef DEBUG |
2012 | pr_debug("%s: sec=%s psktype=%s\nn", __func__, | 1907 | pr_debug("%s: sec=%s psktype=%s\n", __func__, |
2013 | wpasecstr(wpa->security), | 1908 | wpasecstr(wpa->security), |
2014 | (wpa->psk_type == GELIC_EURUS_WPA_PSK_BIN) ? | 1909 | (wpa->psk_type == GELIC_EURUS_WPA_PSK_BIN) ? |
2015 | "BIN" : "passphrase"); | 1910 | "BIN" : "passphrase"); |
@@ -2019,9 +1914,9 @@ static int gelic_wl_do_wpa_setup(struct gelic_wl_info *wl) | |||
2019 | * the debug log because this dumps your precious | 1914 | * the debug log because this dumps your precious |
2020 | * passphrase/key. | 1915 | * passphrase/key. |
2021 | */ | 1916 | */ |
2022 | pr_debug("%s: psk=%s\n", | 1917 | pr_debug("%s: psk=%s\n", __func__, |
2023 | (wpa->psk_type == GELIC_EURUS_WPA_PSK_BIN) ? | 1918 | (wpa->psk_type == GELIC_EURUS_WPA_PSK_BIN) ? |
2024 | (char *)"N/A" : (char *)wpa->psk); | 1919 | "N/A" : wpa->psk); |
2025 | #endif | 1920 | #endif |
2026 | #endif | 1921 | #endif |
2027 | /* issue wpa setup */ | 1922 | /* issue wpa setup */ |
@@ -2406,40 +2301,10 @@ static const iw_handler gelic_wl_wext_handler[] = | |||
2406 | IW_IOCTL(SIOCGIWNICKN) = gelic_wl_get_nick, | 2301 | IW_IOCTL(SIOCGIWNICKN) = gelic_wl_get_nick, |
2407 | }; | 2302 | }; |
2408 | 2303 | ||
2409 | #ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE | ||
2410 | static 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 | |||
2426 | static const iw_handler gelic_wl_private_handler[] = | ||
2427 | { | ||
2428 | gelic_wl_priv_set_psk, | ||
2429 | gelic_wl_priv_get_psk, | ||
2430 | }; | ||
2431 | #endif | ||
2432 | |||
2433 | static const struct iw_handler_def gelic_wl_wext_handler_def = { | 2304 | static const struct iw_handler_def gelic_wl_wext_handler_def = { |
2434 | .num_standard = ARRAY_SIZE(gelic_wl_wext_handler), | 2305 | .num_standard = ARRAY_SIZE(gelic_wl_wext_handler), |
2435 | .standard = gelic_wl_wext_handler, | 2306 | .standard = gelic_wl_wext_handler, |
2436 | .get_wireless_stats = gelic_wl_get_wireless_stats, | 2307 | .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 | }; | 2308 | }; |
2444 | 2309 | ||
2445 | static struct net_device * __devinit gelic_wl_alloc(struct gelic_card *card) | 2310 | static struct net_device * __devinit gelic_wl_alloc(struct gelic_card *card) |