2008-11-27 00:36:31 +03:00
|
|
|
/*
|
|
|
|
* cfg80211 - wext compat code
|
|
|
|
*
|
|
|
|
* This is temporary code until all wireless functionality is migrated
|
|
|
|
* into cfg80211, when that happens all the exports here go away and
|
|
|
|
* we directly assign the wireless handlers of wireless interfaces.
|
|
|
|
*
|
2009-05-11 15:54:58 +04:00
|
|
|
* Copyright 2008-2009 Johannes Berg <johannes@sipsolutions.net>
|
2008-11-27 00:36:31 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/wireless.h>
|
|
|
|
#include <linux/nl80211.h>
|
2009-04-19 21:57:45 +04:00
|
|
|
#include <linux/if_arp.h>
|
2009-05-11 15:54:58 +04:00
|
|
|
#include <linux/etherdevice.h>
|
2008-11-27 00:36:31 +03:00
|
|
|
#include <net/iw_handler.h>
|
|
|
|
#include <net/cfg80211.h>
|
|
|
|
#include "core.h"
|
|
|
|
|
|
|
|
int cfg80211_wext_giwname(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
char *name, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct ieee80211_supported_band *sband;
|
|
|
|
bool is_ht = false, is_a = false, is_b = false, is_g = false;
|
|
|
|
|
|
|
|
if (!wdev)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
sband = wdev->wiphy->bands[IEEE80211_BAND_5GHZ];
|
|
|
|
if (sband) {
|
|
|
|
is_a = true;
|
|
|
|
is_ht |= sband->ht_cap.ht_supported;
|
|
|
|
}
|
|
|
|
|
|
|
|
sband = wdev->wiphy->bands[IEEE80211_BAND_2GHZ];
|
|
|
|
if (sband) {
|
|
|
|
int i;
|
|
|
|
/* Check for mandatory rates */
|
|
|
|
for (i = 0; i < sband->n_bitrates; i++) {
|
|
|
|
if (sband->bitrates[i].bitrate == 10)
|
|
|
|
is_b = true;
|
|
|
|
if (sband->bitrates[i].bitrate == 60)
|
|
|
|
is_g = true;
|
|
|
|
}
|
|
|
|
is_ht |= sband->ht_cap.ht_supported;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(name, "IEEE 802.11");
|
|
|
|
if (is_a)
|
|
|
|
strcat(name, "a");
|
|
|
|
if (is_b)
|
|
|
|
strcat(name, "b");
|
|
|
|
if (is_g)
|
|
|
|
strcat(name, "g");
|
|
|
|
if (is_ht)
|
|
|
|
strcat(name, "n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-04-20 20:49:39 +04:00
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_giwname);
|
2008-11-27 01:31:40 +03:00
|
|
|
|
|
|
|
int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
u32 *mode, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev;
|
|
|
|
struct vif_params vifparams;
|
|
|
|
enum nl80211_iftype type;
|
2009-03-21 19:07:59 +03:00
|
|
|
int ret;
|
2008-11-27 01:31:40 +03:00
|
|
|
|
|
|
|
if (!wdev)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
|
|
|
|
if (!rdev->ops->change_virtual_intf)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
/* don't support changing VLANs, you just re-create them */
|
|
|
|
if (wdev->iftype == NL80211_IFTYPE_AP_VLAN)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
switch (*mode) {
|
|
|
|
case IW_MODE_INFRA:
|
|
|
|
type = NL80211_IFTYPE_STATION;
|
|
|
|
break;
|
|
|
|
case IW_MODE_ADHOC:
|
|
|
|
type = NL80211_IFTYPE_ADHOC;
|
|
|
|
break;
|
|
|
|
case IW_MODE_REPEAT:
|
|
|
|
type = NL80211_IFTYPE_WDS;
|
|
|
|
break;
|
|
|
|
case IW_MODE_MONITOR:
|
|
|
|
type = NL80211_IFTYPE_MONITOR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2009-03-21 19:07:59 +03:00
|
|
|
if (type == wdev->iftype)
|
|
|
|
return 0;
|
|
|
|
|
2008-11-27 01:31:40 +03:00
|
|
|
memset(&vifparams, 0, sizeof(vifparams));
|
|
|
|
|
2009-06-09 23:04:43 +04:00
|
|
|
ret = rdev->ops->change_virtual_intf(wdev->wiphy, dev, type,
|
2009-03-21 19:07:59 +03:00
|
|
|
NULL, &vifparams);
|
|
|
|
WARN_ON(!ret && wdev->iftype != type);
|
|
|
|
|
|
|
|
return ret;
|
2008-11-27 01:31:40 +03:00
|
|
|
}
|
2009-04-20 20:49:39 +04:00
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_siwmode);
|
2008-11-27 01:31:40 +03:00
|
|
|
|
|
|
|
int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
u32 *mode, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
if (!wdev)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
switch (wdev->iftype) {
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
*mode = IW_MODE_MASTER;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
*mode = IW_MODE_INFRA;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
*mode = IW_MODE_ADHOC;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_MONITOR:
|
|
|
|
*mode = IW_MODE_MONITOR;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_WDS:
|
|
|
|
*mode = IW_MODE_REPEAT;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_AP_VLAN:
|
|
|
|
*mode = IW_MODE_SECOND; /* FIXME */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*mode = IW_MODE_AUTO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2009-04-20 20:49:39 +04:00
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_giwmode);
|
2009-02-18 21:32:08 +03:00
|
|
|
|
|
|
|
|
|
|
|
int cfg80211_wext_giwrange(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *data, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct iw_range *range = (struct iw_range *) extra;
|
|
|
|
enum ieee80211_band band;
|
2009-07-06 21:40:51 +04:00
|
|
|
int i, c = 0;
|
2009-02-18 21:32:08 +03:00
|
|
|
|
|
|
|
if (!wdev)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
data->length = sizeof(struct iw_range);
|
|
|
|
memset(range, 0, sizeof(struct iw_range));
|
|
|
|
|
|
|
|
range->we_version_compiled = WIRELESS_EXT;
|
|
|
|
range->we_version_source = 21;
|
|
|
|
range->retry_capa = IW_RETRY_LIMIT;
|
|
|
|
range->retry_flags = IW_RETRY_LIMIT;
|
|
|
|
range->min_retry = 0;
|
|
|
|
range->max_retry = 255;
|
|
|
|
range->min_rts = 0;
|
|
|
|
range->max_rts = 2347;
|
|
|
|
range->min_frag = 256;
|
|
|
|
range->max_frag = 2346;
|
|
|
|
|
|
|
|
range->max_encoding_tokens = 4;
|
|
|
|
|
|
|
|
range->max_qual.updated = IW_QUAL_NOISE_INVALID;
|
|
|
|
|
|
|
|
switch (wdev->wiphy->signal_type) {
|
|
|
|
case CFG80211_SIGNAL_TYPE_NONE:
|
|
|
|
break;
|
|
|
|
case CFG80211_SIGNAL_TYPE_MBM:
|
|
|
|
range->max_qual.level = -110;
|
|
|
|
range->max_qual.qual = 70;
|
|
|
|
range->avg_qual.qual = 35;
|
|
|
|
range->max_qual.updated |= IW_QUAL_DBM;
|
|
|
|
range->max_qual.updated |= IW_QUAL_QUAL_UPDATED;
|
|
|
|
range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
|
|
|
break;
|
|
|
|
case CFG80211_SIGNAL_TYPE_UNSPEC:
|
|
|
|
range->max_qual.level = 100;
|
|
|
|
range->max_qual.qual = 100;
|
|
|
|
range->avg_qual.qual = 50;
|
|
|
|
range->max_qual.updated |= IW_QUAL_QUAL_UPDATED;
|
|
|
|
range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
range->avg_qual.level = range->max_qual.level / 2;
|
|
|
|
range->avg_qual.noise = range->max_qual.noise / 2;
|
|
|
|
range->avg_qual.updated = range->max_qual.updated;
|
|
|
|
|
2009-07-06 21:40:51 +04:00
|
|
|
for (i = 0; i < wdev->wiphy->n_cipher_suites; i++) {
|
|
|
|
switch (wdev->wiphy->cipher_suites[i]) {
|
2009-06-19 02:21:14 +04:00
|
|
|
case WLAN_CIPHER_SUITE_TKIP:
|
2009-06-19 02:21:17 +04:00
|
|
|
range->enc_capa |= (IW_ENC_CAPA_CIPHER_TKIP |
|
|
|
|
IW_ENC_CAPA_WPA);
|
2009-06-19 02:21:14 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WLAN_CIPHER_SUITE_CCMP:
|
2009-06-19 02:21:17 +04:00
|
|
|
range->enc_capa |= (IW_ENC_CAPA_CIPHER_CCMP |
|
|
|
|
IW_ENC_CAPA_WPA2);
|
2009-06-19 02:21:14 +04:00
|
|
|
break;
|
2009-06-19 02:21:16 +04:00
|
|
|
|
|
|
|
case WLAN_CIPHER_SUITE_WEP40:
|
|
|
|
range->encoding_size[range->num_encoding_sizes++] =
|
|
|
|
WLAN_KEY_LEN_WEP40;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WLAN_CIPHER_SUITE_WEP104:
|
|
|
|
range->encoding_size[range->num_encoding_sizes++] =
|
|
|
|
WLAN_KEY_LEN_WEP104;
|
|
|
|
break;
|
2009-06-19 02:21:14 +04:00
|
|
|
}
|
|
|
|
}
|
2009-02-18 21:32:08 +03:00
|
|
|
|
|
|
|
for (band = 0; band < IEEE80211_NUM_BANDS; band ++) {
|
|
|
|
struct ieee80211_supported_band *sband;
|
|
|
|
|
|
|
|
sband = wdev->wiphy->bands[band];
|
|
|
|
|
|
|
|
if (!sband)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) {
|
|
|
|
struct ieee80211_channel *chan = &sband->channels[i];
|
|
|
|
|
|
|
|
if (!(chan->flags & IEEE80211_CHAN_DISABLED)) {
|
|
|
|
range->freq[c].i =
|
|
|
|
ieee80211_frequency_to_channel(
|
|
|
|
chan->center_freq);
|
|
|
|
range->freq[c].m = chan->center_freq;
|
|
|
|
range->freq[c].e = 6;
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
range->num_channels = c;
|
|
|
|
range->num_frequency = c;
|
|
|
|
|
|
|
|
IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
|
|
|
|
IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
|
|
|
|
IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
|
|
|
|
|
2009-06-19 02:21:15 +04:00
|
|
|
if (wdev->wiphy->max_scan_ssids > 0)
|
|
|
|
range->scan_capa |= IW_SCAN_CAPA_ESSID;
|
2009-02-18 21:32:08 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-04-20 20:49:39 +04:00
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_giwrange);
|
2009-04-19 21:57:45 +04:00
|
|
|
|
2009-04-19 23:24:32 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cfg80211_wext_freq - get wext frequency for non-"auto"
|
|
|
|
* @wiphy: the wiphy
|
|
|
|
* @freq: the wext freq encoding
|
|
|
|
*
|
|
|
|
* Returns a channel, %NULL for auto, or an ERR_PTR for errors!
|
|
|
|
*/
|
|
|
|
struct ieee80211_channel *cfg80211_wext_freq(struct wiphy *wiphy,
|
|
|
|
struct iw_freq *freq)
|
|
|
|
{
|
2009-05-08 11:42:33 +04:00
|
|
|
struct ieee80211_channel *chan;
|
|
|
|
int f;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse frequency - return NULL for auto and
|
|
|
|
* -EINVAL for impossible things.
|
|
|
|
*/
|
2009-04-19 23:24:32 +04:00
|
|
|
if (freq->e == 0) {
|
|
|
|
if (freq->m < 0)
|
|
|
|
return NULL;
|
2009-05-08 11:42:33 +04:00
|
|
|
f = ieee80211_channel_to_frequency(freq->m);
|
2009-04-19 23:24:32 +04:00
|
|
|
} else {
|
|
|
|
int i, div = 1000000;
|
|
|
|
for (i = 0; i < freq->e; i++)
|
|
|
|
div /= 10;
|
2009-05-08 11:42:33 +04:00
|
|
|
if (div <= 0)
|
2009-04-19 23:24:32 +04:00
|
|
|
return ERR_PTR(-EINVAL);
|
2009-05-08 11:42:33 +04:00
|
|
|
f = freq->m / div;
|
2009-04-19 23:24:32 +04:00
|
|
|
}
|
|
|
|
|
2009-05-08 11:42:33 +04:00
|
|
|
/*
|
|
|
|
* Look up channel struct and return -EINVAL when
|
|
|
|
* it cannot be found.
|
|
|
|
*/
|
|
|
|
chan = ieee80211_get_channel(wiphy, f);
|
|
|
|
if (!chan)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
return chan;
|
2009-04-19 23:24:32 +04:00
|
|
|
}
|
2009-04-20 20:49:39 +04:00
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_freq);
|
2009-04-20 20:39:05 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_siwrts(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *rts, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
u32 orts = wdev->wiphy->rts_threshold;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (rts->disabled || !rts->fixed)
|
|
|
|
wdev->wiphy->rts_threshold = (u32) -1;
|
|
|
|
else if (rts->value < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
else
|
|
|
|
wdev->wiphy->rts_threshold = rts->value;
|
|
|
|
|
|
|
|
err = rdev->ops->set_wiphy_params(wdev->wiphy,
|
|
|
|
WIPHY_PARAM_RTS_THRESHOLD);
|
|
|
|
if (err)
|
|
|
|
wdev->wiphy->rts_threshold = orts;
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
2009-04-20 20:49:39 +04:00
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_siwrts);
|
2009-04-20 20:39:05 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_giwrts(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *rts, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
rts->value = wdev->wiphy->rts_threshold;
|
|
|
|
rts->disabled = rts->value == (u32) -1;
|
|
|
|
rts->fixed = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-04-20 20:49:39 +04:00
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_giwrts);
|
2009-04-20 20:39:05 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_siwfrag(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *frag, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
u32 ofrag = wdev->wiphy->frag_threshold;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (frag->disabled || !frag->fixed)
|
|
|
|
wdev->wiphy->frag_threshold = (u32) -1;
|
|
|
|
else if (frag->value < 256)
|
|
|
|
return -EINVAL;
|
|
|
|
else {
|
|
|
|
/* Fragment length must be even, so strip LSB. */
|
|
|
|
wdev->wiphy->frag_threshold = frag->value & ~0x1;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = rdev->ops->set_wiphy_params(wdev->wiphy,
|
|
|
|
WIPHY_PARAM_FRAG_THRESHOLD);
|
|
|
|
if (err)
|
|
|
|
wdev->wiphy->frag_threshold = ofrag;
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
2009-04-20 20:49:39 +04:00
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_siwfrag);
|
2009-04-20 20:39:05 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_giwfrag(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *frag, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
frag->value = wdev->wiphy->frag_threshold;
|
|
|
|
frag->disabled = frag->value == (u32) -1;
|
|
|
|
frag->fixed = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-04-20 20:49:39 +04:00
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_giwfrag);
|
2009-04-20 20:39:05 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_siwretry(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *retry, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
u32 changed = 0;
|
|
|
|
u8 olong = wdev->wiphy->retry_long;
|
|
|
|
u8 oshort = wdev->wiphy->retry_short;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (retry->disabled ||
|
|
|
|
(retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (retry->flags & IW_RETRY_LONG) {
|
|
|
|
wdev->wiphy->retry_long = retry->value;
|
|
|
|
changed |= WIPHY_PARAM_RETRY_LONG;
|
|
|
|
} else if (retry->flags & IW_RETRY_SHORT) {
|
|
|
|
wdev->wiphy->retry_short = retry->value;
|
|
|
|
changed |= WIPHY_PARAM_RETRY_SHORT;
|
|
|
|
} else {
|
|
|
|
wdev->wiphy->retry_short = retry->value;
|
|
|
|
wdev->wiphy->retry_long = retry->value;
|
|
|
|
changed |= WIPHY_PARAM_RETRY_LONG;
|
|
|
|
changed |= WIPHY_PARAM_RETRY_SHORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!changed)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err = rdev->ops->set_wiphy_params(wdev->wiphy, changed);
|
|
|
|
if (err) {
|
|
|
|
wdev->wiphy->retry_short = oshort;
|
|
|
|
wdev->wiphy->retry_long = olong;
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
2009-04-20 20:49:39 +04:00
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_siwretry);
|
2009-04-20 20:39:05 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_giwretry(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *retry, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
retry->disabled = 0;
|
|
|
|
|
|
|
|
if (retry->flags == 0 || (retry->flags & IW_RETRY_SHORT)) {
|
|
|
|
/*
|
|
|
|
* First return short value, iwconfig will ask long value
|
|
|
|
* later if needed
|
|
|
|
*/
|
|
|
|
retry->flags |= IW_RETRY_LIMIT;
|
|
|
|
retry->value = wdev->wiphy->retry_short;
|
|
|
|
if (wdev->wiphy->retry_long != wdev->wiphy->retry_short)
|
|
|
|
retry->flags |= IW_RETRY_LONG;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (retry->flags & IW_RETRY_LONG) {
|
|
|
|
retry->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
|
|
|
|
retry->value = wdev->wiphy->retry_long;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-04-20 20:49:39 +04:00
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_giwretry);
|
2009-05-11 15:54:58 +04:00
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *dev, const u8 *addr,
|
|
|
|
bool remove, bool tx_key, int idx,
|
|
|
|
struct key_params *params)
|
2009-05-11 15:54:58 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
int err, i;
|
|
|
|
|
|
|
|
if (!wdev->wext.keys) {
|
|
|
|
wdev->wext.keys = kzalloc(sizeof(*wdev->wext.keys),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!wdev->wext.keys)
|
|
|
|
return -ENOMEM;
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
wdev->wext.keys->params[i].key =
|
|
|
|
wdev->wext.keys->data[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_ADHOC &&
|
|
|
|
wdev->iftype != NL80211_IFTYPE_STATION)
|
|
|
|
return -EOPNOTSUPP;
|
2009-05-11 15:54:58 +04:00
|
|
|
|
|
|
|
if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (!wdev->current_bss)
|
|
|
|
return -ENOLINK;
|
|
|
|
|
2009-05-11 15:54:58 +04:00
|
|
|
if (!rdev->ops->set_default_mgmt_key)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (idx < 4 || idx > 5)
|
|
|
|
return -EINVAL;
|
|
|
|
} else if (idx < 0 || idx > 3)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (remove) {
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
err = 0;
|
|
|
|
if (wdev->current_bss)
|
|
|
|
err = rdev->ops->del_key(&rdev->wiphy, dev, idx, addr);
|
2009-05-11 15:54:58 +04:00
|
|
|
if (!err) {
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (!addr) {
|
|
|
|
wdev->wext.keys->params[idx].key_len = 0;
|
|
|
|
wdev->wext.keys->params[idx].cipher = 0;
|
|
|
|
}
|
2009-05-11 15:54:58 +04:00
|
|
|
if (idx == wdev->wext.default_key)
|
|
|
|
wdev->wext.default_key = -1;
|
|
|
|
else if (idx == wdev->wext.default_mgmt_key)
|
|
|
|
wdev->wext.default_mgmt_key = -1;
|
|
|
|
}
|
2009-05-18 21:56:36 +04:00
|
|
|
/*
|
|
|
|
* Applications using wireless extensions expect to be
|
|
|
|
* able to delete keys that don't exist, so allow that.
|
|
|
|
*/
|
|
|
|
if (err == -ENOENT)
|
|
|
|
return 0;
|
|
|
|
|
2009-05-11 15:54:58 +04:00
|
|
|
return err;
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
}
|
2009-05-11 15:54:58 +04:00
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (addr)
|
|
|
|
tx_key = false;
|
|
|
|
|
|
|
|
if (cfg80211_validate_key_settings(rdev, params, idx, addr))
|
|
|
|
return -EINVAL;
|
2009-05-11 15:54:58 +04:00
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
err = 0;
|
|
|
|
if (wdev->current_bss)
|
2009-05-11 15:54:58 +04:00
|
|
|
err = rdev->ops->add_key(&rdev->wiphy, dev, idx, addr, params);
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (!addr) {
|
|
|
|
wdev->wext.keys->params[idx] = *params;
|
|
|
|
memcpy(wdev->wext.keys->data[idx],
|
|
|
|
params->key, params->key_len);
|
|
|
|
wdev->wext.keys->params[idx].key =
|
|
|
|
wdev->wext.keys->data[idx];
|
|
|
|
}
|
2009-05-11 15:54:58 +04:00
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (params->cipher != WLAN_CIPHER_SUITE_AES_CMAC &&
|
|
|
|
(tx_key || (!addr && wdev->wext.default_key == -1))) {
|
|
|
|
if (wdev->current_bss)
|
2009-05-11 15:54:58 +04:00
|
|
|
err = rdev->ops->set_default_key(&rdev->wiphy,
|
|
|
|
dev, idx);
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (!err)
|
|
|
|
wdev->wext.default_key = idx;
|
|
|
|
return err;
|
|
|
|
}
|
2009-05-11 15:54:58 +04:00
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC &&
|
|
|
|
(tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) {
|
|
|
|
if (wdev->current_bss)
|
2009-05-11 15:54:58 +04:00
|
|
|
err = rdev->ops->set_default_mgmt_key(&rdev->wiphy,
|
|
|
|
dev, idx);
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (!err)
|
|
|
|
wdev->wext.default_mgmt_key = idx;
|
|
|
|
return err;
|
2009-05-11 15:54:58 +04:00
|
|
|
}
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *dev, const u8 *addr,
|
|
|
|
bool remove, bool tx_key, int idx,
|
|
|
|
struct key_params *params)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
wdev_lock(dev->ieee80211_ptr);
|
|
|
|
err = __cfg80211_set_encryption(rdev, dev, addr, remove,
|
|
|
|
tx_key, idx, params);
|
|
|
|
wdev_unlock(dev->ieee80211_ptr);
|
|
|
|
|
|
|
|
return err;
|
2009-05-11 15:54:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int cfg80211_wext_siwencode(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *erq, char *keybuf)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
int idx, err;
|
|
|
|
bool remove = false;
|
|
|
|
struct key_params params;
|
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION &&
|
|
|
|
wdev->iftype != NL80211_IFTYPE_ADHOC)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2009-05-11 15:54:58 +04:00
|
|
|
/* no use -- only MFP (set_default_mgmt_key) is optional */
|
|
|
|
if (!rdev->ops->del_key ||
|
|
|
|
!rdev->ops->add_key ||
|
|
|
|
!rdev->ops->set_default_key)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
idx = erq->flags & IW_ENCODE_INDEX;
|
|
|
|
if (idx == 0) {
|
|
|
|
idx = wdev->wext.default_key;
|
|
|
|
if (idx < 0)
|
|
|
|
idx = 0;
|
|
|
|
} else if (idx < 1 || idx > 4)
|
|
|
|
return -EINVAL;
|
|
|
|
else
|
|
|
|
idx--;
|
|
|
|
|
|
|
|
if (erq->flags & IW_ENCODE_DISABLED)
|
|
|
|
remove = true;
|
|
|
|
else if (erq->length == 0) {
|
|
|
|
/* No key data - just set the default TX key index */
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
err = 0;
|
|
|
|
wdev_lock(wdev);
|
|
|
|
if (wdev->current_bss)
|
|
|
|
err = rdev->ops->set_default_key(&rdev->wiphy,
|
|
|
|
dev, idx);
|
2009-05-11 15:54:58 +04:00
|
|
|
if (!err)
|
|
|
|
wdev->wext.default_key = idx;
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
wdev_unlock(wdev);
|
2009-05-11 15:54:58 +04:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
params.key = keybuf;
|
|
|
|
params.key_len = erq->length;
|
|
|
|
if (erq->length == 5)
|
|
|
|
params.cipher = WLAN_CIPHER_SUITE_WEP40;
|
|
|
|
else if (erq->length == 13)
|
|
|
|
params.cipher = WLAN_CIPHER_SUITE_WEP104;
|
|
|
|
else if (!remove)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return cfg80211_set_encryption(rdev, dev, NULL, remove,
|
|
|
|
wdev->wext.default_key == -1,
|
|
|
|
idx, ¶ms);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_siwencode);
|
|
|
|
|
|
|
|
int cfg80211_wext_siwencodeext(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *erq, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
|
|
|
|
const u8 *addr;
|
|
|
|
int idx;
|
|
|
|
bool remove = false;
|
|
|
|
struct key_params params;
|
|
|
|
u32 cipher;
|
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION &&
|
|
|
|
wdev->iftype != NL80211_IFTYPE_ADHOC)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2009-05-11 15:54:58 +04:00
|
|
|
/* no use -- only MFP (set_default_mgmt_key) is optional */
|
|
|
|
if (!rdev->ops->del_key ||
|
|
|
|
!rdev->ops->add_key ||
|
|
|
|
!rdev->ops->set_default_key)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
switch (ext->alg) {
|
|
|
|
case IW_ENCODE_ALG_NONE:
|
|
|
|
remove = true;
|
|
|
|
cipher = 0;
|
|
|
|
break;
|
|
|
|
case IW_ENCODE_ALG_WEP:
|
|
|
|
if (ext->key_len == 5)
|
|
|
|
cipher = WLAN_CIPHER_SUITE_WEP40;
|
|
|
|
else if (ext->key_len == 13)
|
|
|
|
cipher = WLAN_CIPHER_SUITE_WEP104;
|
|
|
|
else
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
case IW_ENCODE_ALG_TKIP:
|
|
|
|
cipher = WLAN_CIPHER_SUITE_TKIP;
|
|
|
|
break;
|
|
|
|
case IW_ENCODE_ALG_CCMP:
|
|
|
|
cipher = WLAN_CIPHER_SUITE_CCMP;
|
|
|
|
break;
|
|
|
|
case IW_ENCODE_ALG_AES_CMAC:
|
|
|
|
cipher = WLAN_CIPHER_SUITE_AES_CMAC;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (erq->flags & IW_ENCODE_DISABLED)
|
|
|
|
remove = true;
|
|
|
|
|
|
|
|
idx = erq->flags & IW_ENCODE_INDEX;
|
|
|
|
if (cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
|
|
|
|
if (idx < 4 || idx > 5) {
|
|
|
|
idx = wdev->wext.default_mgmt_key;
|
|
|
|
if (idx < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
} else
|
|
|
|
idx--;
|
|
|
|
} else {
|
|
|
|
if (idx < 1 || idx > 4) {
|
|
|
|
idx = wdev->wext.default_key;
|
|
|
|
if (idx < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
} else
|
|
|
|
idx--;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = ext->addr.sa_data;
|
|
|
|
if (is_broadcast_ether_addr(addr))
|
|
|
|
addr = NULL;
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
params.key = ext->key;
|
|
|
|
params.key_len = ext->key_len;
|
|
|
|
params.cipher = cipher;
|
|
|
|
|
2009-05-11 22:57:58 +04:00
|
|
|
if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
|
|
|
|
params.seq = ext->rx_seq;
|
|
|
|
params.seq_len = 6;
|
|
|
|
}
|
|
|
|
|
2009-05-11 15:54:58 +04:00
|
|
|
return cfg80211_set_encryption(
|
|
|
|
rdev, dev, addr, remove,
|
|
|
|
ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY,
|
|
|
|
idx, ¶ms);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_siwencodeext);
|
|
|
|
|
|
|
|
int cfg80211_wext_giwencode(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *erq, char *keybuf)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
int idx;
|
2009-05-11 15:54:58 +04:00
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION &&
|
|
|
|
wdev->iftype != NL80211_IFTYPE_ADHOC)
|
2009-05-11 15:54:58 +04:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
idx = erq->flags & IW_ENCODE_INDEX;
|
|
|
|
if (idx == 0) {
|
|
|
|
idx = wdev->wext.default_key;
|
|
|
|
if (idx < 0)
|
|
|
|
idx = 0;
|
|
|
|
} else if (idx < 1 || idx > 4)
|
|
|
|
return -EINVAL;
|
|
|
|
else
|
|
|
|
idx--;
|
|
|
|
|
|
|
|
erq->flags = idx + 1;
|
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (!wdev->wext.keys || !wdev->wext.keys->params[idx].cipher) {
|
2009-05-11 15:54:58 +04:00
|
|
|
erq->flags |= IW_ENCODE_DISABLED;
|
|
|
|
erq->length = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
erq->length = min_t(size_t, erq->length,
|
|
|
|
wdev->wext.keys->params[idx].key_len);
|
|
|
|
memcpy(keybuf, wdev->wext.keys->params[idx].key, erq->length);
|
|
|
|
erq->flags |= IW_ENCODE_ENABLED;
|
|
|
|
|
|
|
|
return 0;
|
2009-05-11 15:54:58 +04:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_giwencode);
|
2009-06-02 15:01:39 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_siwtxpower(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *data, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
enum tx_power_setting type;
|
|
|
|
int dbm = 0;
|
|
|
|
|
|
|
|
if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
|
|
|
|
return -EINVAL;
|
|
|
|
if (data->txpower.flags & IW_TXPOW_RANGE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!rdev->ops->set_tx_power)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
/* only change when not disabling */
|
|
|
|
if (!data->txpower.disabled) {
|
2009-06-02 15:01:41 +04:00
|
|
|
rfkill_set_sw_state(rdev->rfkill, false);
|
|
|
|
|
2009-06-02 15:01:39 +04:00
|
|
|
if (data->txpower.fixed) {
|
|
|
|
/*
|
|
|
|
* wext doesn't support negative values, see
|
|
|
|
* below where it's for automatic
|
|
|
|
*/
|
|
|
|
if (data->txpower.value < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
dbm = data->txpower.value;
|
|
|
|
type = TX_POWER_FIXED;
|
|
|
|
/* TODO: do regulatory check! */
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Automatic power level setting, max being the value
|
|
|
|
* passed in from userland.
|
|
|
|
*/
|
|
|
|
if (data->txpower.value < 0) {
|
|
|
|
type = TX_POWER_AUTOMATIC;
|
|
|
|
} else {
|
|
|
|
dbm = data->txpower.value;
|
|
|
|
type = TX_POWER_LIMITED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2009-06-02 15:01:41 +04:00
|
|
|
rfkill_set_sw_state(rdev->rfkill, true);
|
|
|
|
schedule_work(&rdev->rfkill_sync);
|
|
|
|
return 0;
|
2009-06-02 15:01:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rdev->ops->set_tx_power(wdev->wiphy, type, dbm);;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_siwtxpower);
|
|
|
|
|
|
|
|
int cfg80211_wext_giwtxpower(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *data, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
int err, val;
|
|
|
|
|
|
|
|
if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
|
|
|
|
return -EINVAL;
|
|
|
|
if (data->txpower.flags & IW_TXPOW_RANGE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!rdev->ops->get_tx_power)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
err = rdev->ops->get_tx_power(wdev->wiphy, &val);
|
2009-06-02 15:01:41 +04:00
|
|
|
if (err)
|
2009-06-02 15:01:39 +04:00
|
|
|
return err;
|
|
|
|
|
|
|
|
/* well... oh well */
|
|
|
|
data->txpower.fixed = 1;
|
2009-06-02 15:01:41 +04:00
|
|
|
data->txpower.disabled = rfkill_blocked(rdev->rfkill);
|
2009-06-02 15:01:39 +04:00
|
|
|
data->txpower.value = val;
|
|
|
|
data->txpower.flags = IW_TXPOW_DBM;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_giwtxpower);
|
2009-07-01 23:26:56 +04:00
|
|
|
|
|
|
|
static int cfg80211_set_auth_alg(struct wireless_dev *wdev,
|
|
|
|
s32 auth_alg)
|
|
|
|
{
|
|
|
|
int nr_alg = 0;
|
|
|
|
|
|
|
|
if (!auth_alg)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (auth_alg & ~(IW_AUTH_ALG_OPEN_SYSTEM |
|
|
|
|
IW_AUTH_ALG_SHARED_KEY |
|
|
|
|
IW_AUTH_ALG_LEAP))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (auth_alg & IW_AUTH_ALG_OPEN_SYSTEM) {
|
|
|
|
nr_alg++;
|
|
|
|
wdev->wext.connect.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auth_alg & IW_AUTH_ALG_SHARED_KEY) {
|
|
|
|
nr_alg++;
|
|
|
|
wdev->wext.connect.auth_type = NL80211_AUTHTYPE_SHARED_KEY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auth_alg & IW_AUTH_ALG_LEAP) {
|
|
|
|
nr_alg++;
|
|
|
|
wdev->wext.connect.auth_type = NL80211_AUTHTYPE_NETWORK_EAP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nr_alg > 1)
|
|
|
|
wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cfg80211_set_wpa_version(struct wireless_dev *wdev, u32 wpa_versions)
|
|
|
|
{
|
|
|
|
wdev->wext.connect.crypto.wpa_versions = 0;
|
|
|
|
|
|
|
|
if (wpa_versions & ~(IW_AUTH_WPA_VERSION_WPA |
|
|
|
|
IW_AUTH_WPA_VERSION_WPA2))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (wpa_versions & IW_AUTH_WPA_VERSION_WPA)
|
|
|
|
wdev->wext.connect.crypto.wpa_versions |=
|
|
|
|
NL80211_WPA_VERSION_1;
|
|
|
|
|
|
|
|
if (wpa_versions & IW_AUTH_WPA_VERSION_WPA2)
|
|
|
|
wdev->wext.connect.crypto.wpa_versions |=
|
|
|
|
NL80211_WPA_VERSION_2;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-07 05:56:10 +04:00
|
|
|
static int cfg80211_set_cipher_group(struct wireless_dev *wdev, u32 cipher)
|
2009-07-01 23:26:56 +04:00
|
|
|
{
|
|
|
|
wdev->wext.connect.crypto.cipher_group = 0;
|
|
|
|
|
|
|
|
if (cipher & IW_AUTH_CIPHER_WEP40)
|
|
|
|
wdev->wext.connect.crypto.cipher_group =
|
|
|
|
WLAN_CIPHER_SUITE_WEP40;
|
|
|
|
else if (cipher & IW_AUTH_CIPHER_WEP104)
|
|
|
|
wdev->wext.connect.crypto.cipher_group =
|
|
|
|
WLAN_CIPHER_SUITE_WEP104;
|
|
|
|
else if (cipher & IW_AUTH_CIPHER_TKIP)
|
|
|
|
wdev->wext.connect.crypto.cipher_group =
|
|
|
|
WLAN_CIPHER_SUITE_TKIP;
|
|
|
|
else if (cipher & IW_AUTH_CIPHER_CCMP)
|
|
|
|
wdev->wext.connect.crypto.cipher_group =
|
|
|
|
WLAN_CIPHER_SUITE_CCMP;
|
|
|
|
else if (cipher & IW_AUTH_CIPHER_AES_CMAC)
|
|
|
|
wdev->wext.connect.crypto.cipher_group =
|
|
|
|
WLAN_CIPHER_SUITE_AES_CMAC;
|
|
|
|
else
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-07 05:56:10 +04:00
|
|
|
static int cfg80211_set_cipher_pairwise(struct wireless_dev *wdev, u32 cipher)
|
2009-07-01 23:26:56 +04:00
|
|
|
{
|
|
|
|
int nr_ciphers = 0;
|
|
|
|
u32 *ciphers_pairwise = wdev->wext.connect.crypto.ciphers_pairwise;
|
|
|
|
|
|
|
|
if (cipher & IW_AUTH_CIPHER_WEP40) {
|
|
|
|
ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP40;
|
|
|
|
nr_ciphers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cipher & IW_AUTH_CIPHER_WEP104) {
|
|
|
|
ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP104;
|
|
|
|
nr_ciphers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cipher & IW_AUTH_CIPHER_TKIP) {
|
|
|
|
ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_TKIP;
|
|
|
|
nr_ciphers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cipher & IW_AUTH_CIPHER_CCMP) {
|
|
|
|
ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_CCMP;
|
|
|
|
nr_ciphers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cipher & IW_AUTH_CIPHER_AES_CMAC) {
|
|
|
|
ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_AES_CMAC;
|
|
|
|
nr_ciphers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
BUILD_BUG_ON(NL80211_MAX_NR_CIPHER_SUITES < 5);
|
|
|
|
|
|
|
|
wdev->wext.connect.crypto.n_ciphers_pairwise = nr_ciphers;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-07 05:56:10 +04:00
|
|
|
static int cfg80211_set_key_mgt(struct wireless_dev *wdev, u32 key_mgt)
|
2009-07-01 23:26:56 +04:00
|
|
|
{
|
|
|
|
int nr_akm_suites = 0;
|
|
|
|
|
|
|
|
if (key_mgt & ~(IW_AUTH_KEY_MGMT_802_1X |
|
|
|
|
IW_AUTH_KEY_MGMT_PSK))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (key_mgt & IW_AUTH_KEY_MGMT_802_1X) {
|
|
|
|
wdev->wext.connect.crypto.akm_suites[nr_akm_suites] =
|
|
|
|
WLAN_AKM_SUITE_8021X;
|
|
|
|
nr_akm_suites++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key_mgt & IW_AUTH_KEY_MGMT_PSK) {
|
|
|
|
wdev->wext.connect.crypto.akm_suites[nr_akm_suites] =
|
|
|
|
WLAN_AKM_SUITE_PSK;
|
|
|
|
nr_akm_suites++;
|
|
|
|
}
|
|
|
|
|
|
|
|
wdev->wext.connect.crypto.n_akm_suites = nr_akm_suites;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cfg80211_wext_siwauth(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *data, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
switch (data->flags & IW_AUTH_INDEX) {
|
|
|
|
case IW_AUTH_PRIVACY_INVOKED:
|
|
|
|
wdev->wext.connect.privacy = data->value;
|
|
|
|
return 0;
|
|
|
|
case IW_AUTH_WPA_VERSION:
|
|
|
|
return cfg80211_set_wpa_version(wdev, data->value);
|
|
|
|
case IW_AUTH_CIPHER_GROUP:
|
|
|
|
return cfg80211_set_cipher_group(wdev, data->value);
|
|
|
|
case IW_AUTH_KEY_MGMT:
|
|
|
|
return cfg80211_set_key_mgt(wdev, data->value);
|
|
|
|
case IW_AUTH_CIPHER_PAIRWISE:
|
|
|
|
return cfg80211_set_cipher_pairwise(wdev, data->value);
|
|
|
|
case IW_AUTH_80211_AUTH_ALG:
|
|
|
|
return cfg80211_set_auth_alg(wdev, data->value);
|
|
|
|
case IW_AUTH_WPA_ENABLED:
|
|
|
|
case IW_AUTH_RX_UNENCRYPTED_EAPOL:
|
|
|
|
case IW_AUTH_DROP_UNENCRYPTED:
|
|
|
|
case IW_AUTH_MFP:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_siwauth);
|
|
|
|
|
|
|
|
int cfg80211_wext_giwauth(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *data, char *extra)
|
|
|
|
{
|
|
|
|
/* XXX: what do we need? */
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_giwauth);
|
2009-07-01 23:26:57 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_siwpower(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *wrq, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
bool ps = wdev->wext.ps;
|
|
|
|
int timeout = wdev->wext.ps_timeout;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!rdev->ops->set_power_mgmt)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (wrq->disabled) {
|
|
|
|
ps = false;
|
|
|
|
} else {
|
|
|
|
switch (wrq->flags & IW_POWER_MODE) {
|
|
|
|
case IW_POWER_ON: /* If not specified */
|
|
|
|
case IW_POWER_MODE: /* If set all mask */
|
|
|
|
case IW_POWER_ALL_R: /* If explicitely state all */
|
|
|
|
ps = true;
|
|
|
|
break;
|
|
|
|
default: /* Otherwise we ignore */
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (wrq->flags & IW_POWER_TIMEOUT)
|
|
|
|
timeout = wrq->value / 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = rdev->ops->set_power_mgmt(wdev->wiphy, dev, ps, timeout);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
wdev->wext.ps = ps;
|
|
|
|
wdev->wext.ps_timeout = timeout;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_siwpower);
|
|
|
|
|
|
|
|
int cfg80211_wext_giwpower(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *wrq, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
wrq->disabled = !wdev->wext.ps;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_giwpower);
|
2009-07-01 23:26:58 +04:00
|
|
|
|
|
|
|
int cfg80211_wds_wext_siwap(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct sockaddr *addr, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (WARN_ON(wdev->iftype != NL80211_IFTYPE_WDS))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (addr->sa_family != ARPHRD_ETHER)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (netif_running(dev))
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
if (!rdev->ops->set_wds_peer)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
err = rdev->ops->set_wds_peer(wdev->wiphy, dev, (u8 *) &addr->sa_data);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
memcpy(&wdev->wext.bssid, (u8 *) &addr->sa_data, ETH_ALEN);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wds_wext_siwap);
|
|
|
|
|
|
|
|
int cfg80211_wds_wext_giwap(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct sockaddr *addr, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
if (WARN_ON(wdev->iftype != NL80211_IFTYPE_WDS))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
addr->sa_family = ARPHRD_ETHER;
|
|
|
|
memcpy(&addr->sa_data, wdev->wext.bssid, ETH_ALEN);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wds_wext_giwap);
|
2009-07-01 23:26:59 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_siwrate(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *rate, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
struct cfg80211_bitrate_mask mask;
|
|
|
|
|
|
|
|
if (!rdev->ops->set_bitrate_mask)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
mask.fixed = 0;
|
|
|
|
mask.maxrate = 0;
|
|
|
|
|
|
|
|
if (rate->value < 0) {
|
|
|
|
/* nothing */
|
|
|
|
} else if (rate->fixed) {
|
|
|
|
mask.fixed = rate->value / 1000; /* kbps */
|
|
|
|
} else {
|
|
|
|
mask.maxrate = rate->value / 1000; /* kbps */
|
|
|
|
}
|
|
|
|
|
|
|
|
return rdev->ops->set_bitrate_mask(wdev->wiphy, dev, NULL, &mask);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_siwrate);
|
|
|
|
|
|
|
|
int cfg80211_wext_giwrate(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *rate, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
/* we are under RTNL - globally locked - so can use a static struct */
|
|
|
|
static struct station_info sinfo;
|
2009-07-08 01:41:27 +04:00
|
|
|
u8 addr[ETH_ALEN];
|
2009-07-01 23:26:59 +04:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!rdev->ops->get_station)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2009-07-08 01:41:27 +04:00
|
|
|
err = 0;
|
|
|
|
wdev_lock(wdev);
|
2009-07-03 04:00:48 +04:00
|
|
|
if (wdev->current_bss)
|
2009-07-08 01:41:27 +04:00
|
|
|
memcpy(addr, wdev->current_bss->pub.bssid, ETH_ALEN);
|
2009-07-03 04:00:48 +04:00
|
|
|
else
|
2009-07-08 01:41:27 +04:00
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
wdev_unlock(wdev);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2009-07-01 23:26:59 +04:00
|
|
|
|
|
|
|
err = rdev->ops->get_station(&rdev->wiphy, dev, addr, &sinfo);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (!(sinfo.filled & STATION_INFO_TX_BITRATE))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
rate->value = 0;
|
|
|
|
|
|
|
|
if (!(sinfo.txrate.flags & RATE_INFO_FLAGS_MCS))
|
|
|
|
rate->value = 100000 * sinfo.txrate.legacy;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wext_giwrate);
|
2009-07-01 23:27:00 +04:00
|
|
|
|
|
|
|
/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
|
|
|
|
struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
/* we are under RTNL - globally locked - so can use static structs */
|
|
|
|
static struct iw_statistics wstats;
|
|
|
|
static struct station_info sinfo;
|
|
|
|
u8 *addr;
|
|
|
|
|
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!rdev->ops->get_station)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
addr = wdev->wext.connect.bssid;
|
|
|
|
if (!addr)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (rdev->ops->get_station(&rdev->wiphy, dev, addr, &sinfo))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
memset(&wstats, 0, sizeof(wstats));
|
|
|
|
|
|
|
|
switch (rdev->wiphy.signal_type) {
|
|
|
|
case CFG80211_SIGNAL_TYPE_MBM:
|
|
|
|
if (sinfo.filled & STATION_INFO_SIGNAL) {
|
|
|
|
int sig = sinfo.signal;
|
|
|
|
wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
|
|
|
wstats.qual.updated |= IW_QUAL_QUAL_UPDATED;
|
|
|
|
wstats.qual.updated |= IW_QUAL_DBM;
|
|
|
|
wstats.qual.level = sig;
|
|
|
|
if (sig < -110)
|
|
|
|
sig = -110;
|
|
|
|
else if (sig > -40)
|
|
|
|
sig = -40;
|
|
|
|
wstats.qual.qual = sig + 110;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CFG80211_SIGNAL_TYPE_UNSPEC:
|
|
|
|
if (sinfo.filled & STATION_INFO_SIGNAL) {
|
|
|
|
wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
|
|
|
wstats.qual.updated |= IW_QUAL_QUAL_UPDATED;
|
|
|
|
wstats.qual.level = sinfo.signal;
|
|
|
|
wstats.qual.qual = sinfo.signal;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
wstats.qual.updated |= IW_QUAL_LEVEL_INVALID;
|
|
|
|
wstats.qual.updated |= IW_QUAL_QUAL_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
wstats.qual.updated |= IW_QUAL_NOISE_INVALID;
|
|
|
|
|
|
|
|
return &wstats;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cfg80211_wireless_stats);
|