2007-05-05 14:45:53 -04: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 15:14:40 -04:00
|
|
|
#include "led.h"
|
|
|
|
#include "rate.h"
|
2007-05-05 14:45:53 -04:00
|
|
|
#include "wpa.h"
|
|
|
|
#include "aes_ccm.h"
|
|
|
|
|
2007-09-14 11:10:25 -04:00
|
|
|
|
2007-05-05 14:45:53 -04:00
|
|
|
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 07:42:25 -04:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
|
|
|
struct ieee80211_channel *chan;
|
2007-05-05 14:45:53 -04:00
|
|
|
|
2009-02-15 06:44:28 -05:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
|
2009-04-19 15:25:43 -04:00
|
|
|
return cfg80211_ibss_wext_siwfreq(dev, info, freq, extra);
|
2009-02-15 06:44:28 -05:00
|
|
|
else if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
2009-07-01 15:26:56 -04:00
|
|
|
return cfg80211_mgd_wext_siwfreq(dev, info, freq, extra);
|
2007-05-05 14:45:53 -04:00
|
|
|
|
|
|
|
/* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */
|
|
|
|
if (freq->e == 0) {
|
2009-07-01 15:26:56 -04:00
|
|
|
if (freq->m < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
else
|
2009-06-15 07:42:25 -04:00
|
|
|
chan = ieee80211_get_channel(local->hw.wiphy,
|
2008-01-24 13:38:38 -05:00
|
|
|
ieee80211_channel_to_frequency(freq->m));
|
2007-05-05 14:45:53 -04:00
|
|
|
} else {
|
|
|
|
int i, div = 1000000;
|
|
|
|
for (i = 0; i < freq->e; i++)
|
|
|
|
div /= 10;
|
2009-06-15 07:42:25 -04:00
|
|
|
if (div <= 0)
|
2007-05-05 14:45:53 -04:00
|
|
|
return -EINVAL;
|
2009-06-15 07:42:25 -04:00
|
|
|
chan = ieee80211_get_channel(local->hw.wiphy, freq->m / div);
|
2007-05-05 14:45:53 -04:00
|
|
|
}
|
2009-06-15 07:42:25 -04: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;
|
|
|
|
|
|
|
|
local->oper_channel = chan;
|
|
|
|
local->oper_channel_type = NL80211_CHAN_NO_HT;
|
|
|
|
ieee80211_hw_config(local, 0);
|
|
|
|
|
|
|
|
return 0;
|
2007-05-05 14:45:53 -04: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 15:25:43 -04: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);
|
2009-07-01 15:26:56 -04:00
|
|
|
else if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
|
|
|
return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra);
|
2007-05-05 14:45:53 -04:00
|
|
|
|
2009-05-04 11:52:10 -04:00
|
|
|
freq->m = local->oper_channel->center_freq;
|
2007-05-05 14:45:53 -04: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 15:25:43 -04:00
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
2007-05-05 14:45:53 -04:00
|
|
|
|
2009-04-19 15:25:43 -04:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
|
|
|
|
return cfg80211_ibss_wext_siwessid(dev, info, data, ssid);
|
2009-07-01 15:26:56 -04:00
|
|
|
else if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
|
|
|
return cfg80211_mgd_wext_siwessid(dev, info, data, ssid);
|
2007-05-05 14:45:53 -04:00
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ieee80211_ioctl_giwessid(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *data, char *ssid)
|
|
|
|
{
|
|
|
|
struct ieee80211_sub_if_data *sdata;
|
2009-04-19 15:25:43 -04:00
|
|
|
|
2007-05-05 14:45:53 -04:00
|
|
|
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
2009-04-19 15:25:43 -04:00
|
|
|
|
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
|
|
|
|
return cfg80211_ibss_wext_giwessid(dev, info, data, ssid);
|
2009-07-01 15:26:56 -04:00
|
|
|
else if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
|
|
|
return cfg80211_mgd_wext_giwessid(dev, info, data, ssid);
|
2007-05-05 14:45:53 -04:00
|
|
|
|
|
|
|
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 15:25:43 -04: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 14:45:53 -04:00
|
|
|
|
2009-07-01 15:26:56 -04:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
|
|
|
return cfg80211_mgd_wext_siwap(dev, info, ap_addr, extra);
|
2009-03-21 12:08:43 -04:00
|
|
|
|
2009-07-01 15:26:58 -04:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_WDS)
|
|
|
|
return cfg80211_wds_wext_siwap(dev, info, ap_addr, extra);
|
2007-05-05 14:45:53 -04: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 15:25:43 -04: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 14:45:53 -04:00
|
|
|
|
2009-07-01 15:26:56 -04:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
|
|
|
return cfg80211_mgd_wext_giwap(dev, info, ap_addr, extra);
|
|
|
|
|
2009-07-01 15:26:58 -04:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_WDS)
|
|
|
|
return cfg80211_wds_wext_giwap(dev, info, ap_addr, extra);
|
2007-05-05 14:45:53 -04:00
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Structures to export the Wireless Handlers */
|
|
|
|
|
|
|
|
static const iw_handler ieee80211_handler[] =
|
|
|
|
{
|
|
|
|
(iw_handler) NULL, /* SIOCSIWCOMMIT */
|
2008-11-26 16:36:31 -05:00
|
|
|
(iw_handler) cfg80211_wext_giwname, /* SIOCGIWNAME */
|
2007-05-05 14:45:53 -04:00
|
|
|
(iw_handler) NULL, /* SIOCSIWNWID */
|
|
|
|
(iw_handler) NULL, /* SIOCGIWNWID */
|
|
|
|
(iw_handler) ieee80211_ioctl_siwfreq, /* SIOCSIWFREQ */
|
|
|
|
(iw_handler) ieee80211_ioctl_giwfreq, /* SIOCGIWFREQ */
|
2008-11-26 17:31:40 -05:00
|
|
|
(iw_handler) cfg80211_wext_siwmode, /* SIOCSIWMODE */
|
|
|
|
(iw_handler) cfg80211_wext_giwmode, /* SIOCGIWMODE */
|
2007-05-05 14:45:53 -04:00
|
|
|
(iw_handler) NULL, /* SIOCSIWSENS */
|
|
|
|
(iw_handler) NULL, /* SIOCGIWSENS */
|
|
|
|
(iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
|
2009-02-18 13:32:08 -05:00
|
|
|
(iw_handler) cfg80211_wext_giwrange, /* SIOCGIWRANGE */
|
2007-05-05 14:45:53 -04: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 11:10:24 -04:00
|
|
|
(iw_handler) NULL, /* SIOCSIWSPY */
|
|
|
|
(iw_handler) NULL, /* SIOCGIWSPY */
|
|
|
|
(iw_handler) NULL, /* SIOCSIWTHRSPY */
|
|
|
|
(iw_handler) NULL, /* SIOCGIWTHRSPY */
|
2007-05-05 14:45:53 -04:00
|
|
|
(iw_handler) ieee80211_ioctl_siwap, /* SIOCSIWAP */
|
|
|
|
(iw_handler) ieee80211_ioctl_giwap, /* SIOCGIWAP */
|
2009-04-19 13:57:45 -04:00
|
|
|
(iw_handler) cfg80211_wext_siwmlme, /* SIOCSIWMLME */
|
2007-05-05 14:45:53 -04:00
|
|
|
(iw_handler) NULL, /* SIOCGIWAPLIST */
|
2009-02-10 15:25:55 -05:00
|
|
|
(iw_handler) cfg80211_wext_siwscan, /* SIOCSIWSCAN */
|
|
|
|
(iw_handler) cfg80211_wext_giwscan, /* SIOCGIWSCAN */
|
2007-05-05 14:45:53 -04: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 -- */
|
2009-07-01 15:26:59 -04:00
|
|
|
(iw_handler) cfg80211_wext_siwrate, /* SIOCSIWRATE */
|
|
|
|
(iw_handler) cfg80211_wext_giwrate, /* SIOCGIWRATE */
|
2009-04-20 12:39:05 -04: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 07:01:39 -04:00
|
|
|
(iw_handler) cfg80211_wext_siwtxpower, /* SIOCSIWTXPOW */
|
|
|
|
(iw_handler) cfg80211_wext_giwtxpower, /* SIOCGIWTXPOW */
|
2009-04-20 12:39:05 -04:00
|
|
|
(iw_handler) cfg80211_wext_siwretry, /* SIOCSIWRETRY */
|
|
|
|
(iw_handler) cfg80211_wext_giwretry, /* SIOCGIWRETRY */
|
2009-05-11 07:54:58 -04:00
|
|
|
(iw_handler) cfg80211_wext_siwencode, /* SIOCSIWENCODE */
|
|
|
|
(iw_handler) cfg80211_wext_giwencode, /* SIOCGIWENCODE */
|
2009-07-01 15:26:57 -04:00
|
|
|
(iw_handler) cfg80211_wext_siwpower, /* SIOCSIWPOWER */
|
|
|
|
(iw_handler) cfg80211_wext_giwpower, /* SIOCGIWPOWER */
|
2007-05-05 14:45:53 -04:00
|
|
|
(iw_handler) NULL, /* -- hole -- */
|
|
|
|
(iw_handler) NULL, /* -- hole -- */
|
2009-07-01 15:26:56 -04:00
|
|
|
(iw_handler) cfg80211_wext_siwgenie, /* SIOCSIWGENIE */
|
2007-05-05 14:45:53 -04:00
|
|
|
(iw_handler) NULL, /* SIOCGIWGENIE */
|
2009-07-01 15:26:56 -04:00
|
|
|
(iw_handler) cfg80211_wext_siwauth, /* SIOCSIWAUTH */
|
|
|
|
(iw_handler) cfg80211_wext_giwauth, /* SIOCGIWAUTH */
|
2009-05-11 07:54:58 -04:00
|
|
|
(iw_handler) cfg80211_wext_siwencodeext, /* SIOCSIWENCODEEXT */
|
2007-05-05 14:45:53 -04: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,
|
2009-07-01 15:27:00 -04:00
|
|
|
.get_wireless_stats = cfg80211_wireless_stats,
|
2007-05-05 14:45:53 -04:00
|
|
|
};
|