2007-05-05 12:45:53 -06:00
|
|
|
/*
|
|
|
|
* Copyright 2002-2005, Instant802 Networks, Inc.
|
|
|
|
* Copyright 2005-2006, Devicescape Software, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/wireless.h>
|
|
|
|
#include <net/iw_handler.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
|
|
|
|
#include <net/mac80211.h>
|
|
|
|
#include "ieee80211_i.h"
|
2008-04-08 13:14:40 -06:00
|
|
|
#include "led.h"
|
|
|
|
#include "rate.h"
|
2007-05-05 12:45:53 -06:00
|
|
|
#include "wpa.h"
|
|
|
|
#include "aes_ccm.h"
|
|
|
|
|
2007-09-14 09:10:25 -06:00
|
|
|
|
2007-05-05 12:45:53 -06:00
|
|
|
static int ieee80211_ioctl_siwgenie(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *data, char *extra)
|
|
|
|
{
|
|
|
|
struct ieee80211_sub_if_data *sdata;
|
|
|
|
|
2007-09-26 09:53:20 -06:00
|
|
|
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
|
|
|
|
2009-02-15 04:44:28 -07:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION) {
|
2008-08-02 18:04:37 -06:00
|
|
|
int ret = ieee80211_sta_set_extra_ie(sdata, extra, data->length);
|
2009-05-19 14:16:25 -06:00
|
|
|
if (ret && ret != -EALREADY)
|
2007-05-05 12:45:53 -06:00
|
|
|
return ret;
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL;
|
2009-03-19 05:39:22 -06:00
|
|
|
sdata->u.mgd.flags &= ~IEEE80211_STA_EXT_SME;
|
2009-05-11 12:57:57 -06:00
|
|
|
sdata->u.mgd.flags &= ~IEEE80211_STA_CONTROL_PORT;
|
2009-05-19 14:16:25 -06:00
|
|
|
if (ret != -EALREADY)
|
|
|
|
ieee80211_sta_req_auth(sdata);
|
2007-05-05 12:45:53 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ieee80211_ioctl_siwfreq(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_freq *freq, char *extra)
|
|
|
|
{
|
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
2009-06-15 05:42:25 -06:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
|
|
|
struct ieee80211_channel *chan;
|
2007-05-05 12:45:53 -06:00
|
|
|
|
2009-02-15 04:44:28 -07:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
|
2009-04-19 13:25:43 -06:00
|
|
|
return cfg80211_ibss_wext_siwfreq(dev, info, freq, extra);
|
2009-02-15 04:44:28 -07:00
|
|
|
else if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
|
|
|
sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_CHANNEL_SEL;
|
2007-05-05 12:45:53 -06:00
|
|
|
|
|
|
|
/* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */
|
|
|
|
if (freq->e == 0) {
|
|
|
|
if (freq->m < 0) {
|
2009-04-19 13:25:43 -06:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.flags |=
|
2007-08-28 15:01:54 -06:00
|
|
|
IEEE80211_STA_AUTO_CHANNEL_SEL;
|
2007-05-05 12:45:53 -06:00
|
|
|
return 0;
|
|
|
|
} else
|
2009-06-15 05:42:25 -06:00
|
|
|
chan = ieee80211_get_channel(local->hw.wiphy,
|
2008-01-24 11:38:38 -07:00
|
|
|
ieee80211_channel_to_frequency(freq->m));
|
2007-05-05 12:45:53 -06:00
|
|
|
} else {
|
|
|
|
int i, div = 1000000;
|
|
|
|
for (i = 0; i < freq->e; i++)
|
|
|
|
div /= 10;
|
2009-06-15 05:42:25 -06:00
|
|
|
if (div <= 0)
|
2007-05-05 12:45:53 -06:00
|
|
|
return -EINVAL;
|
2009-06-15 05:42:25 -06:00
|
|
|
chan = ieee80211_get_channel(local->hw.wiphy, freq->m / div);
|
2007-05-05 12:45:53 -06:00
|
|
|
}
|
2009-06-15 05:42:25 -06:00
|
|
|
|
|
|
|
if (!chan)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (chan->flags & IEEE80211_CHAN_DISABLED)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* no change except maybe auto -> fixed, ignore the HT
|
|
|
|
* setting so you can fix a channel you're on already
|
|
|
|
*/
|
|
|
|
if (local->oper_channel == chan)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
|
|
|
ieee80211_sta_req_auth(sdata);
|
|
|
|
|
|
|
|
local->oper_channel = chan;
|
|
|
|
local->oper_channel_type = NL80211_CHAN_NO_HT;
|
|
|
|
ieee80211_hw_config(local, 0);
|
|
|
|
|
|
|
|
return 0;
|
2007-05-05 12:45:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ieee80211_ioctl_giwfreq(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_freq *freq, char *extra)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
|
2009-04-19 13:25:43 -06:00
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
|
|
|
|
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
|
|
|
|
return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra);
|
2007-05-05 12:45:53 -06:00
|
|
|
|
2009-05-04 09:52:10 -06:00
|
|
|
freq->m = local->oper_channel->center_freq;
|
2007-05-05 12:45:53 -06:00
|
|
|
freq->e = 6;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ieee80211_ioctl_siwessid(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *data, char *ssid)
|
|
|
|
{
|
2009-04-19 13:25:43 -06:00
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
2007-05-05 12:45:53 -06:00
|
|
|
size_t len = data->length;
|
2009-02-15 04:44:28 -07:00
|
|
|
int ret;
|
2007-05-05 12:45:53 -06:00
|
|
|
|
2009-04-19 13:25:43 -06:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
|
|
|
|
return cfg80211_ibss_wext_siwessid(dev, info, data, ssid);
|
|
|
|
|
2007-05-05 12:45:53 -06:00
|
|
|
/* iwconfig uses nul termination in SSID.. */
|
|
|
|
if (len > 0 && ssid[len - 1] == '\0')
|
|
|
|
len--;
|
|
|
|
|
2009-02-15 04:44:28 -07:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION) {
|
2007-08-28 15:01:54 -06:00
|
|
|
if (data->flags)
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_SSID_SEL;
|
2007-08-28 15:01:54 -06:00
|
|
|
else
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.flags |= IEEE80211_STA_AUTO_SSID_SEL;
|
|
|
|
|
2008-08-02 18:04:37 -06:00
|
|
|
ret = ieee80211_sta_set_ssid(sdata, ssid, len);
|
2007-05-05 12:45:53 -06:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2009-02-15 04:44:28 -07:00
|
|
|
|
2009-03-19 05:39:22 -06:00
|
|
|
sdata->u.mgd.flags &= ~IEEE80211_STA_EXT_SME;
|
2009-05-11 12:57:57 -06:00
|
|
|
sdata->u.mgd.flags &= ~IEEE80211_STA_CONTROL_PORT;
|
2009-02-15 04:44:28 -07:00
|
|
|
ieee80211_sta_req_auth(sdata);
|
2007-05-05 12:45:53 -06:00
|
|
|
return 0;
|
2009-04-19 13:25:43 -06:00
|
|
|
}
|
2007-05-05 12:45:53 -06:00
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ieee80211_ioctl_giwessid(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *data, char *ssid)
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
struct ieee80211_sub_if_data *sdata;
|
2009-04-19 13:25:43 -06:00
|
|
|
|
2007-05-05 12:45:53 -06:00
|
|
|
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
2009-04-19 13:25:43 -06:00
|
|
|
|
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
|
|
|
|
return cfg80211_ibss_wext_giwessid(dev, info, data, ssid);
|
|
|
|
|
2009-02-15 04:44:28 -07:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION) {
|
2008-08-02 18:04:37 -06:00
|
|
|
int res = ieee80211_sta_get_ssid(sdata, ssid, &len);
|
2007-05-05 12:45:53 -06:00
|
|
|
if (res == 0) {
|
|
|
|
data->length = len;
|
|
|
|
data->flags = 1;
|
|
|
|
} else
|
|
|
|
data->flags = 0;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ieee80211_ioctl_siwap(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct sockaddr *ap_addr, char *extra)
|
|
|
|
{
|
2009-04-19 13:25:43 -06:00
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
|
|
|
|
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
|
|
|
|
return cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra);
|
2007-05-05 12:45:53 -06:00
|
|
|
|
2009-02-15 04:44:28 -07:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION) {
|
2007-05-05 12:45:53 -06:00
|
|
|
int ret;
|
2009-03-21 10:08:43 -06:00
|
|
|
|
2007-08-28 15:01:54 -06:00
|
|
|
if (is_zero_ether_addr((u8 *) &ap_addr->sa_data))
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.flags |= IEEE80211_STA_AUTO_BSSID_SEL |
|
2007-08-28 15:01:54 -06:00
|
|
|
IEEE80211_STA_AUTO_CHANNEL_SEL;
|
|
|
|
else if (is_broadcast_ether_addr((u8 *) &ap_addr->sa_data))
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.flags |= IEEE80211_STA_AUTO_BSSID_SEL;
|
2007-05-05 12:45:53 -06:00
|
|
|
else
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL;
|
2008-08-02 18:04:37 -06:00
|
|
|
ret = ieee80211_sta_set_bssid(sdata, (u8 *) &ap_addr->sa_data);
|
2007-05-05 12:45:53 -06:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2009-03-19 05:39:22 -06:00
|
|
|
sdata->u.mgd.flags &= ~IEEE80211_STA_EXT_SME;
|
2009-05-11 12:57:57 -06:00
|
|
|
sdata->u.mgd.flags &= ~IEEE80211_STA_CONTROL_PORT;
|
2009-02-15 04:44:28 -07:00
|
|
|
ieee80211_sta_req_auth(sdata);
|
2007-05-05 12:45:53 -06:00
|
|
|
return 0;
|
2008-09-10 16:01:58 -06:00
|
|
|
} else if (sdata->vif.type == NL80211_IFTYPE_WDS) {
|
2008-02-25 08:27:49 -07:00
|
|
|
/*
|
|
|
|
* If it is necessary to update the WDS peer address
|
|
|
|
* while the interface is running, then we need to do
|
|
|
|
* more work here, namely if it is running we need to
|
|
|
|
* add a new and remove the old STA entry, this is
|
|
|
|
* normally handled by _open() and _stop().
|
|
|
|
*/
|
|
|
|
if (netif_running(dev))
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
memcpy(&sdata->u.wds.remote_addr, (u8 *) &ap_addr->sa_data,
|
|
|
|
ETH_ALEN);
|
|
|
|
|
|
|
|
return 0;
|
2007-05-05 12:45:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ieee80211_ioctl_giwap(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct sockaddr *ap_addr, char *extra)
|
|
|
|
{
|
2009-04-19 13:25:43 -06:00
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
|
|
|
|
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
|
|
|
|
return cfg80211_ibss_wext_giwap(dev, info, ap_addr, extra);
|
2007-05-05 12:45:53 -06:00
|
|
|
|
2009-02-15 04:44:28 -07:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION) {
|
|
|
|
if (sdata->u.mgd.state == IEEE80211_STA_MLME_ASSOCIATED) {
|
2008-05-23 11:15:26 -06:00
|
|
|
ap_addr->sa_family = ARPHRD_ETHER;
|
2009-02-15 04:44:28 -07:00
|
|
|
memcpy(&ap_addr->sa_data, sdata->u.mgd.bssid, ETH_ALEN);
|
|
|
|
} else
|
2008-05-23 11:15:26 -06:00
|
|
|
memset(&ap_addr->sa_data, 0, ETH_ALEN);
|
2009-02-15 04:44:28 -07:00
|
|
|
return 0;
|
2008-09-10 16:01:58 -06:00
|
|
|
} else if (sdata->vif.type == NL80211_IFTYPE_WDS) {
|
2007-05-05 12:45:53 -06:00
|
|
|
ap_addr->sa_family = ARPHRD_ETHER;
|
|
|
|
memcpy(&ap_addr->sa_data, sdata->u.wds.remote_addr, ETH_ALEN);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-10 11:32:10 -06:00
|
|
|
static int ieee80211_ioctl_siwrate(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *rate, char *extra)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
|
2008-01-24 11:38:38 -07:00
|
|
|
int i, err = -EINVAL;
|
2007-07-10 11:32:10 -06:00
|
|
|
u32 target_rate = rate->value / 100000;
|
|
|
|
struct ieee80211_sub_if_data *sdata;
|
2008-01-24 11:38:38 -07:00
|
|
|
struct ieee80211_supported_band *sband;
|
2007-07-10 11:32:10 -06:00
|
|
|
|
|
|
|
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
2008-01-24 11:38:38 -07:00
|
|
|
|
|
|
|
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
|
|
|
|
|
2007-07-10 11:32:10 -06:00
|
|
|
/* target_rate = -1, rate->fixed = 0 means auto only, so use all rates
|
|
|
|
* target_rate = X, rate->fixed = 1 means only rate X
|
|
|
|
* target_rate = X, rate->fixed = 0 means all rates <= X */
|
mac80211: make master netdev handling sane
Currently, almost every interface type has a 'bss' pointer
pointing to BSS information. This BSS information, however,
is for a _local_ BSS, not for the BSS we joined, so having
it on a STA mode interface makes little sense, but now they
have it pointing to the master device, which is an AP mode
virtual interface. However, except for some bitrate control
data, this pointer is only used in AP/VLAN modes (for power
saving stations.)
Overall, it is not necessary to even have the master netdev
be a valid virtual interface, and it doesn't have to be on
the list of interfaces either.
This patch changes the master netdev to be special, it now
- no longer is on the list of virtual interfaces, which
lets me remove a lot of tests for that
- no longer has sub_if_data attached, since that isn't used
Additionally, this patch changes some vlan/ap mode handling
that is related to these 'bss' pointers described above (but
in the VLAN case they actually make sense because there they
point to the AP they belong to); it also adds some debugging
code to IEEE80211_DEV_TO_SUB_IF to validate it is not called
on the master netdev any more.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-07-09 06:40:34 -06:00
|
|
|
sdata->max_ratectrl_rateidx = -1;
|
|
|
|
sdata->force_unicast_rateidx = -1;
|
2007-07-10 11:32:10 -06:00
|
|
|
if (rate->value < 0)
|
|
|
|
return 0;
|
2008-01-24 11:38:38 -07:00
|
|
|
|
|
|
|
for (i=0; i< sband->n_bitrates; i++) {
|
|
|
|
struct ieee80211_rate *brate = &sband->bitrates[i];
|
|
|
|
int this_rate = brate->bitrate;
|
2007-07-10 11:32:10 -06:00
|
|
|
|
|
|
|
if (target_rate == this_rate) {
|
mac80211: make master netdev handling sane
Currently, almost every interface type has a 'bss' pointer
pointing to BSS information. This BSS information, however,
is for a _local_ BSS, not for the BSS we joined, so having
it on a STA mode interface makes little sense, but now they
have it pointing to the master device, which is an AP mode
virtual interface. However, except for some bitrate control
data, this pointer is only used in AP/VLAN modes (for power
saving stations.)
Overall, it is not necessary to even have the master netdev
be a valid virtual interface, and it doesn't have to be on
the list of interfaces either.
This patch changes the master netdev to be special, it now
- no longer is on the list of virtual interfaces, which
lets me remove a lot of tests for that
- no longer has sub_if_data attached, since that isn't used
Additionally, this patch changes some vlan/ap mode handling
that is related to these 'bss' pointers described above (but
in the VLAN case they actually make sense because there they
point to the AP they belong to); it also adds some debugging
code to IEEE80211_DEV_TO_SUB_IF to validate it is not called
on the master netdev any more.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-07-09 06:40:34 -06:00
|
|
|
sdata->max_ratectrl_rateidx = i;
|
2007-07-10 11:32:10 -06:00
|
|
|
if (rate->fixed)
|
mac80211: make master netdev handling sane
Currently, almost every interface type has a 'bss' pointer
pointing to BSS information. This BSS information, however,
is for a _local_ BSS, not for the BSS we joined, so having
it on a STA mode interface makes little sense, but now they
have it pointing to the master device, which is an AP mode
virtual interface. However, except for some bitrate control
data, this pointer is only used in AP/VLAN modes (for power
saving stations.)
Overall, it is not necessary to even have the master netdev
be a valid virtual interface, and it doesn't have to be on
the list of interfaces either.
This patch changes the master netdev to be special, it now
- no longer is on the list of virtual interfaces, which
lets me remove a lot of tests for that
- no longer has sub_if_data attached, since that isn't used
Additionally, this patch changes some vlan/ap mode handling
that is related to these 'bss' pointers described above (but
in the VLAN case they actually make sense because there they
point to the AP they belong to); it also adds some debugging
code to IEEE80211_DEV_TO_SUB_IF to validate it is not called
on the master netdev any more.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-07-09 06:40:34 -06:00
|
|
|
sdata->force_unicast_rateidx = i;
|
2008-01-24 11:38:38 -07:00
|
|
|
err = 0;
|
|
|
|
break;
|
2007-07-10 11:32:10 -06:00
|
|
|
}
|
|
|
|
}
|
2008-01-24 11:38:38 -07:00
|
|
|
return err;
|
2007-07-10 11:32:10 -06:00
|
|
|
}
|
|
|
|
|
2007-06-10 18:57:33 -06:00
|
|
|
static int ieee80211_ioctl_giwrate(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *rate, char *extra)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
|
|
|
|
struct sta_info *sta;
|
|
|
|
struct ieee80211_sub_if_data *sdata;
|
2008-01-24 11:38:38 -07:00
|
|
|
struct ieee80211_supported_band *sband;
|
2007-06-10 18:57:33 -06:00
|
|
|
|
|
|
|
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
2008-01-24 11:38:38 -07:00
|
|
|
|
2008-09-10 16:01:58 -06:00
|
|
|
if (sdata->vif.type != NL80211_IFTYPE_STATION)
|
2007-06-10 18:57:33 -06:00
|
|
|
return -EOPNOTSUPP;
|
2008-01-24 11:38:38 -07:00
|
|
|
|
|
|
|
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
|
|
|
|
|
2008-04-04 15:40:35 -06:00
|
|
|
rcu_read_lock();
|
|
|
|
|
2009-02-15 04:44:28 -07:00
|
|
|
sta = sta_info_get(local, sdata->u.mgd.bssid);
|
2008-04-04 15:40:35 -06:00
|
|
|
|
2008-10-21 04:40:02 -06:00
|
|
|
if (sta && !(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS))
|
|
|
|
rate->value = sband->bitrates[sta->last_tx_rate.idx].bitrate;
|
2007-06-10 18:57:33 -06:00
|
|
|
else
|
|
|
|
rate->value = 0;
|
2008-04-04 15:40:35 -06:00
|
|
|
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
if (!sta)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2008-01-24 11:38:38 -07:00
|
|
|
rate->value *= 100000;
|
2008-02-25 08:27:46 -07:00
|
|
|
|
2007-06-10 18:57:33 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-07-04 02:49:31 -06:00
|
|
|
static int ieee80211_ioctl_siwpower(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *wrq,
|
|
|
|
char *extra)
|
|
|
|
{
|
2008-12-18 14:35:13 -07:00
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
2008-07-04 02:49:31 -06:00
|
|
|
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
|
|
|
|
struct ieee80211_conf *conf = &local->hw.conf;
|
2009-04-16 05:17:24 -06:00
|
|
|
int timeout = 0;
|
2008-12-18 14:35:13 -07:00
|
|
|
bool ps;
|
|
|
|
|
2009-01-07 10:28:20 -07:00
|
|
|
if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2008-12-18 14:35:13 -07:00
|
|
|
if (sdata->vif.type != NL80211_IFTYPE_STATION)
|
|
|
|
return -EINVAL;
|
2008-07-04 02:49:31 -06:00
|
|
|
|
|
|
|
if (wrq->disabled) {
|
2008-12-18 14:35:13 -07:00
|
|
|
ps = false;
|
2008-12-18 14:35:27 -07:00
|
|
|
timeout = 0;
|
2008-12-18 14:35:13 -07:00
|
|
|
goto set;
|
2008-07-04 02:49:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
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 */
|
2008-12-18 14:35:13 -07:00
|
|
|
ps = true;
|
2008-07-04 02:49:31 -06:00
|
|
|
break;
|
2008-12-18 14:35:27 -07:00
|
|
|
default: /* Otherwise we ignore */
|
2009-01-06 10:12:35 -07:00
|
|
|
return -EINVAL;
|
2008-07-04 02:49:31 -06:00
|
|
|
}
|
|
|
|
|
2009-01-06 10:12:35 -07:00
|
|
|
if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2008-12-18 14:35:27 -07:00
|
|
|
if (wrq->flags & IW_POWER_TIMEOUT)
|
|
|
|
timeout = wrq->value / 1000;
|
2008-12-18 14:35:13 -07:00
|
|
|
|
2009-01-07 10:28:20 -07:00
|
|
|
set:
|
2009-04-16 05:17:24 -06:00
|
|
|
if (ps == sdata->u.mgd.powersave && timeout == conf->dynamic_ps_timeout)
|
|
|
|
return 0;
|
2008-12-18 14:35:27 -07:00
|
|
|
|
2009-04-16 05:17:24 -06:00
|
|
|
sdata->u.mgd.powersave = ps;
|
2009-01-06 10:13:18 -07:00
|
|
|
conf->dynamic_ps_timeout = timeout;
|
2008-12-18 14:35:13 -07:00
|
|
|
|
2009-01-07 10:28:20 -07:00
|
|
|
if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
|
2009-04-22 04:40:07 -06:00
|
|
|
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
|
2009-01-07 10:28:20 -07:00
|
|
|
|
2009-04-16 05:17:25 -06:00
|
|
|
ieee80211_recalc_ps(local, -1);
|
2008-12-18 14:35:13 -07:00
|
|
|
|
2009-04-16 05:17:24 -06:00
|
|
|
return 0;
|
2008-07-04 02:49:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ieee80211_ioctl_giwpower(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu,
|
|
|
|
char *extra)
|
|
|
|
{
|
2009-04-16 05:17:24 -06:00
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
2008-07-04 02:49:31 -06:00
|
|
|
|
2009-04-16 05:17:24 -06:00
|
|
|
wrqu->power.disabled = !sdata->u.mgd.powersave;
|
2008-07-04 02:49:31 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-05-05 12:45:53 -06:00
|
|
|
static int ieee80211_ioctl_siwauth(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *data, char *extra)
|
|
|
|
{
|
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
switch (data->flags & IW_AUTH_INDEX) {
|
|
|
|
case IW_AUTH_WPA_VERSION:
|
|
|
|
case IW_AUTH_CIPHER_GROUP:
|
|
|
|
case IW_AUTH_WPA_ENABLED:
|
|
|
|
case IW_AUTH_RX_UNENCRYPTED_EAPOL:
|
|
|
|
case IW_AUTH_KEY_MGMT:
|
2009-01-08 04:32:03 -07:00
|
|
|
case IW_AUTH_CIPHER_GROUP_MGMT:
|
2007-11-03 07:11:10 -06:00
|
|
|
break;
|
2008-12-23 09:00:50 -07:00
|
|
|
case IW_AUTH_CIPHER_PAIRWISE:
|
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION) {
|
|
|
|
if (data->value & (IW_AUTH_CIPHER_WEP40 |
|
|
|
|
IW_AUTH_CIPHER_WEP104 | IW_AUTH_CIPHER_TKIP))
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.flags |=
|
2008-12-23 09:00:50 -07:00
|
|
|
IEEE80211_STA_TKIP_WEP_USED;
|
|
|
|
else
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.flags &=
|
2008-12-23 09:00:50 -07:00
|
|
|
~IEEE80211_STA_TKIP_WEP_USED;
|
|
|
|
}
|
|
|
|
break;
|
2007-11-28 03:04:21 -07:00
|
|
|
case IW_AUTH_DROP_UNENCRYPTED:
|
|
|
|
sdata->drop_unencrypted = !!data->value;
|
|
|
|
break;
|
2007-11-03 07:11:10 -06:00
|
|
|
case IW_AUTH_PRIVACY_INVOKED:
|
2008-09-10 16:01:58 -06:00
|
|
|
if (sdata->vif.type != NL80211_IFTYPE_STATION)
|
2007-05-05 12:45:53 -06:00
|
|
|
ret = -EINVAL;
|
|
|
|
else {
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.flags &= ~IEEE80211_STA_PRIVACY_INVOKED;
|
2007-05-05 12:45:53 -06:00
|
|
|
/*
|
2007-11-03 07:11:10 -06:00
|
|
|
* Privacy invoked by wpa_supplicant, store the
|
|
|
|
* value and allow associating to a protected
|
|
|
|
* network without having a key up front.
|
2007-05-05 12:45:53 -06:00
|
|
|
*/
|
2007-11-03 07:11:10 -06:00
|
|
|
if (data->value)
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.flags |=
|
2007-11-03 07:11:10 -06:00
|
|
|
IEEE80211_STA_PRIVACY_INVOKED;
|
2007-05-05 12:45:53 -06:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IW_AUTH_80211_AUTH_ALG:
|
2009-02-15 04:44:28 -07:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
|
|
|
sdata->u.mgd.auth_algs = data->value;
|
2007-05-05 12:45:53 -06:00
|
|
|
else
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
break;
|
2009-01-08 04:32:05 -07:00
|
|
|
case IW_AUTH_MFP:
|
2009-01-08 04:32:11 -07:00
|
|
|
if (!(sdata->local->hw.flags & IEEE80211_HW_MFP_CAPABLE)) {
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
2009-02-15 04:44:28 -07:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION) {
|
2009-02-10 13:25:40 -07:00
|
|
|
switch (data->value) {
|
|
|
|
case IW_AUTH_MFP_DISABLED:
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.mfp = IEEE80211_MFP_DISABLED;
|
2009-02-10 13:25:40 -07:00
|
|
|
break;
|
|
|
|
case IW_AUTH_MFP_OPTIONAL:
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.mfp = IEEE80211_MFP_OPTIONAL;
|
2009-02-10 13:25:40 -07:00
|
|
|
break;
|
|
|
|
case IW_AUTH_MFP_REQUIRED:
|
2009-02-15 04:44:28 -07:00
|
|
|
sdata->u.mgd.mfp = IEEE80211_MFP_REQUIRED;
|
2009-02-10 13:25:40 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
} else
|
2009-01-08 04:32:05 -07:00
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
break;
|
2007-05-05 12:45:53 -06:00
|
|
|
default:
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
|
|
|
|
static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
|
|
|
|
struct iw_statistics *wstats = &local->wstats;
|
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
|
|
|
struct sta_info *sta = NULL;
|
|
|
|
|
2008-04-10 07:36:09 -06:00
|
|
|
rcu_read_lock();
|
|
|
|
|
2009-02-15 04:44:28 -07:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
|
|
|
sta = sta_info_get(local, sdata->u.mgd.bssid);
|
|
|
|
|
2007-05-05 12:45:53 -06:00
|
|
|
if (!sta) {
|
|
|
|
wstats->discard.fragment = 0;
|
|
|
|
wstats->discard.misc = 0;
|
|
|
|
wstats->qual.qual = 0;
|
|
|
|
wstats->qual.level = 0;
|
|
|
|
wstats->qual.noise = 0;
|
|
|
|
wstats->qual.updated = IW_QUAL_ALL_INVALID;
|
|
|
|
} else {
|
2009-02-27 15:33:55 -07:00
|
|
|
wstats->qual.updated = 0;
|
|
|
|
/*
|
|
|
|
* mirror what cfg80211 does for iwrange/scan results,
|
|
|
|
* otherwise userspace gets confused.
|
|
|
|
*/
|
|
|
|
if (local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC |
|
|
|
|
IEEE80211_HW_SIGNAL_DBM)) {
|
|
|
|
wstats->qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
|
|
|
wstats->qual.updated |= IW_QUAL_QUAL_UPDATED;
|
|
|
|
} else {
|
|
|
|
wstats->qual.updated |= IW_QUAL_LEVEL_INVALID;
|
|
|
|
wstats->qual.updated |= IW_QUAL_QUAL_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) {
|
|
|
|
wstats->qual.level = sta->last_signal;
|
|
|
|
wstats->qual.qual = sta->last_signal;
|
|
|
|
} else if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) {
|
|
|
|
int sig = sta->last_signal;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (local->hw.flags & IEEE80211_HW_NOISE_DBM) {
|
|
|
|
/*
|
|
|
|
* This assumes that if driver reports noise, it also
|
|
|
|
* reports signal in dBm.
|
|
|
|
*/
|
|
|
|
wstats->qual.noise = sta->last_noise;
|
|
|
|
wstats->qual.updated |= IW_QUAL_NOISE_UPDATED;
|
|
|
|
} else {
|
|
|
|
wstats->qual.updated |= IW_QUAL_NOISE_INVALID;
|
|
|
|
}
|
2007-05-05 12:45:53 -06:00
|
|
|
}
|
2008-04-10 07:36:09 -06:00
|
|
|
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
2007-05-05 12:45:53 -06:00
|
|
|
return wstats;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ieee80211_ioctl_giwauth(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *data, char *extra)
|
|
|
|
{
|
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
switch (data->flags & IW_AUTH_INDEX) {
|
|
|
|
case IW_AUTH_80211_AUTH_ALG:
|
2009-02-15 04:44:28 -07:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
|
|
|
data->value = sdata->u.mgd.auth_algs;
|
2007-05-05 12:45:53 -06:00
|
|
|
else
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Structures to export the Wireless Handlers */
|
|
|
|
|
|
|
|
static const iw_handler ieee80211_handler[] =
|
|
|
|
{
|
|
|
|
(iw_handler) NULL, /* SIOCSIWCOMMIT */
|
2008-11-26 14:36:31 -07:00
|
|
|
(iw_handler) cfg80211_wext_giwname, /* SIOCGIWNAME */
|
2007-05-05 12:45:53 -06:00
|
|
|
(iw_handler) NULL, /* SIOCSIWNWID */
|
|
|
|
(iw_handler) NULL, /* SIOCGIWNWID */
|
|
|
|
(iw_handler) ieee80211_ioctl_siwfreq, /* SIOCSIWFREQ */
|
|
|
|
(iw_handler) ieee80211_ioctl_giwfreq, /* SIOCGIWFREQ */
|
2008-11-26 15:31:40 -07:00
|
|
|
(iw_handler) cfg80211_wext_siwmode, /* SIOCSIWMODE */
|
|
|
|
(iw_handler) cfg80211_wext_giwmode, /* SIOCGIWMODE */
|
2007-05-05 12:45:53 -06:00
|
|
|
(iw_handler) NULL, /* SIOCSIWSENS */
|
|
|
|
(iw_handler) NULL, /* SIOCGIWSENS */
|
|
|
|
(iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
|
2009-02-18 11:32:08 -07:00
|
|
|
(iw_handler) cfg80211_wext_giwrange, /* SIOCGIWRANGE */
|
2007-05-05 12:45:53 -06:00
|
|
|
(iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
|
|
|
|
(iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
|
|
|
|
(iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
|
|
|
|
(iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */
|
2007-09-14 09:10:24 -06:00
|
|
|
(iw_handler) NULL, /* SIOCSIWSPY */
|
|
|
|
(iw_handler) NULL, /* SIOCGIWSPY */
|
|
|
|
(iw_handler) NULL, /* SIOCSIWTHRSPY */
|
|
|
|
(iw_handler) NULL, /* SIOCGIWTHRSPY */
|
2007-05-05 12:45:53 -06:00
|
|
|
(iw_handler) ieee80211_ioctl_siwap, /* SIOCSIWAP */
|
|
|
|
(iw_handler) ieee80211_ioctl_giwap, /* SIOCGIWAP */
|
2009-04-19 11:57:45 -06:00
|
|
|
(iw_handler) cfg80211_wext_siwmlme, /* SIOCSIWMLME */
|
2007-05-05 12:45:53 -06:00
|
|
|
(iw_handler) NULL, /* SIOCGIWAPLIST */
|
2009-02-10 13:25:55 -07:00
|
|
|
(iw_handler) cfg80211_wext_siwscan, /* SIOCSIWSCAN */
|
|
|
|
(iw_handler) cfg80211_wext_giwscan, /* SIOCGIWSCAN */
|
2007-05-05 12:45:53 -06:00
|
|
|
(iw_handler) ieee80211_ioctl_siwessid, /* SIOCSIWESSID */
|
|
|
|
(iw_handler) ieee80211_ioctl_giwessid, /* SIOCGIWESSID */
|
|
|
|
(iw_handler) NULL, /* SIOCSIWNICKN */
|
|
|
|
(iw_handler) NULL, /* SIOCGIWNICKN */
|
|
|
|
(iw_handler) NULL, /* -- hole -- */
|
|
|
|
(iw_handler) NULL, /* -- hole -- */
|
2007-07-10 11:32:10 -06:00
|
|
|
(iw_handler) ieee80211_ioctl_siwrate, /* SIOCSIWRATE */
|
2007-06-10 18:57:33 -06:00
|
|
|
(iw_handler) ieee80211_ioctl_giwrate, /* SIOCGIWRATE */
|
2009-04-20 10:39:05 -06:00
|
|
|
(iw_handler) cfg80211_wext_siwrts, /* SIOCSIWRTS */
|
|
|
|
(iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */
|
|
|
|
(iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */
|
|
|
|
(iw_handler) cfg80211_wext_giwfrag, /* SIOCGIWFRAG */
|
2009-06-02 05:01:39 -06:00
|
|
|
(iw_handler) cfg80211_wext_siwtxpower, /* SIOCSIWTXPOW */
|
|
|
|
(iw_handler) cfg80211_wext_giwtxpower, /* SIOCGIWTXPOW */
|
2009-04-20 10:39:05 -06:00
|
|
|
(iw_handler) cfg80211_wext_siwretry, /* SIOCSIWRETRY */
|
|
|
|
(iw_handler) cfg80211_wext_giwretry, /* SIOCGIWRETRY */
|
2009-05-11 05:54:58 -06:00
|
|
|
(iw_handler) cfg80211_wext_siwencode, /* SIOCSIWENCODE */
|
|
|
|
(iw_handler) cfg80211_wext_giwencode, /* SIOCGIWENCODE */
|
2008-07-04 02:49:31 -06:00
|
|
|
(iw_handler) ieee80211_ioctl_siwpower, /* SIOCSIWPOWER */
|
|
|
|
(iw_handler) ieee80211_ioctl_giwpower, /* SIOCGIWPOWER */
|
2007-05-05 12:45:53 -06:00
|
|
|
(iw_handler) NULL, /* -- hole -- */
|
|
|
|
(iw_handler) NULL, /* -- hole -- */
|
|
|
|
(iw_handler) ieee80211_ioctl_siwgenie, /* SIOCSIWGENIE */
|
|
|
|
(iw_handler) NULL, /* SIOCGIWGENIE */
|
|
|
|
(iw_handler) ieee80211_ioctl_siwauth, /* SIOCSIWAUTH */
|
|
|
|
(iw_handler) ieee80211_ioctl_giwauth, /* SIOCGIWAUTH */
|
2009-05-11 05:54:58 -06:00
|
|
|
(iw_handler) cfg80211_wext_siwencodeext, /* SIOCSIWENCODEEXT */
|
2007-05-05 12:45:53 -06:00
|
|
|
(iw_handler) NULL, /* SIOCGIWENCODEEXT */
|
|
|
|
(iw_handler) NULL, /* SIOCSIWPMKSA */
|
|
|
|
(iw_handler) NULL, /* -- hole -- */
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct iw_handler_def ieee80211_iw_handler_def =
|
|
|
|
{
|
|
|
|
.num_standard = ARRAY_SIZE(ieee80211_handler),
|
|
|
|
.standard = (iw_handler *) ieee80211_handler,
|
|
|
|
.get_wireless_stats = ieee80211_get_wireless_stats,
|
|
|
|
};
|