2008-12-05 05:01:41 +01:00
|
|
|
/* IEEE 802.11 SoftMAC layer
|
|
|
|
* Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
|
|
|
|
*
|
|
|
|
* Mostly extracted from the rtl8180-sa2400 driver for the
|
|
|
|
* in-kernel generic ieee802.11 stack.
|
|
|
|
*
|
|
|
|
* Some pieces of code might be stolen from ipw2100 driver
|
|
|
|
* copyright of who own it's copyright ;-)
|
|
|
|
*
|
|
|
|
* PS wx handler mostly stolen from hostap, copyright who
|
|
|
|
* own it's copyright ;-)
|
|
|
|
*
|
|
|
|
* released under the GPL
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-08-23 09:18:28 +02:00
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
|
2008-12-05 05:01:41 +01:00
|
|
|
#include "ieee80211.h"
|
|
|
|
|
|
|
|
/* FIXME: add A freqs */
|
|
|
|
|
|
|
|
const long ieee80211_wlan_frequencies[] = {
|
|
|
|
2412, 2417, 2422, 2427,
|
|
|
|
2432, 2437, 2442, 2447,
|
|
|
|
2452, 2457, 2462, 2467,
|
|
|
|
2472, 2484
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *b)
|
|
|
|
{
|
|
|
|
int ret;
|
2012-11-27 13:07:45 +01:00
|
|
|
struct iw_freq *fwrq = &wrqu->freq;
|
2009-01-07 23:31:57 +01:00
|
|
|
// printk("in %s\n",__func__);
|
2008-12-05 05:01:41 +01:00
|
|
|
down(&ieee->wx_sem);
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (ieee->iw_mode == IW_MODE_INFRA) {
|
2008-12-05 05:01:41 +01:00
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if setting by freq convert to channel */
|
|
|
|
if (fwrq->e == 1) {
|
|
|
|
if ((fwrq->m >= (int) 2.412e8 &&
|
|
|
|
fwrq->m <= (int) 2.487e8)) {
|
|
|
|
int f = fwrq->m / 100000;
|
|
|
|
int c = 0;
|
|
|
|
|
|
|
|
while ((c < 14) && (f != ieee80211_wlan_frequencies[c]))
|
|
|
|
c++;
|
|
|
|
|
|
|
|
/* hack to fall through */
|
|
|
|
fwrq->e = 0;
|
|
|
|
fwrq->m = c + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1) {
|
2008-12-05 05:01:41 +01:00
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
goto out;
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
} else { /* Set the channel */
|
2008-12-05 05:01:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
ieee->current_network.channel = fwrq->m;
|
|
|
|
ieee->set_chan(ieee->dev, ieee->current_network.channel);
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
|
|
|
|
if (ieee->state == IEEE80211_LINKED) {
|
2012-11-27 13:09:02 +01:00
|
|
|
ieee80211_stop_send_beacons(ieee);
|
|
|
|
ieee80211_start_send_beacons(ieee);
|
2008-12-05 05:01:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
out:
|
|
|
|
up(&ieee->wx_sem);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
|
|
|
|
struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *b)
|
|
|
|
{
|
2012-11-27 13:07:45 +01:00
|
|
|
struct iw_freq *fwrq = &wrqu->freq;
|
2008-12-05 05:01:41 +01:00
|
|
|
|
|
|
|
if (ieee->current_network.channel == 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
fwrq->m = ieee->current_network.channel;
|
|
|
|
fwrq->e = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
wrqu->ap_addr.sa_family = ARPHRD_ETHER;
|
|
|
|
|
|
|
|
if (ieee->iw_mode == IW_MODE_MONITOR)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* We want avoid to give to the user inconsistent infos*/
|
|
|
|
spin_lock_irqsave(&ieee->lock, flags);
|
|
|
|
|
|
|
|
if (ieee->state != IEEE80211_LINKED &&
|
|
|
|
ieee->state != IEEE80211_LINKED_SCANNING &&
|
|
|
|
ieee->wap_set == 0)
|
|
|
|
|
|
|
|
memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
|
|
|
|
else
|
|
|
|
memcpy(wrqu->ap_addr.sa_data,
|
|
|
|
ieee->current_network.bssid, ETH_ALEN);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&ieee->lock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *awrq,
|
|
|
|
char *extra)
|
|
|
|
{
|
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
short ifup = ieee->proto_started;//dev->flags & IFF_UP;
|
|
|
|
struct sockaddr *temp = (struct sockaddr *)awrq;
|
|
|
|
|
|
|
|
//printk("=======Set WAP:");
|
|
|
|
ieee->sync_scan_hurryup = 1;
|
|
|
|
|
|
|
|
down(&ieee->wx_sem);
|
|
|
|
/* use ifconfig hw ether */
|
2012-11-27 13:08:47 +01:00
|
|
|
if (ieee->iw_mode == IW_MODE_MASTER) {
|
2008-12-05 05:01:41 +01:00
|
|
|
ret = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (temp->sa_family != ARPHRD_ETHER) {
|
2008-12-05 05:01:41 +01:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ifup)
|
|
|
|
ieee80211_stop_protocol(ieee);
|
|
|
|
|
|
|
|
/* just to avoid to give inconsistent infos in the
|
|
|
|
* get wx method. not really needed otherwise
|
|
|
|
*/
|
|
|
|
spin_lock_irqsave(&ieee->lock, flags);
|
|
|
|
|
|
|
|
memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
|
2012-08-23 09:18:28 +02:00
|
|
|
ieee->wap_set = !is_zero_ether_addr(temp->sa_data);
|
2008-12-05 05:01:41 +01:00
|
|
|
//printk(" %x:%x:%x:%x:%x:%x\n", ieee->current_network.bssid[0],ieee->current_network.bssid[1],ieee->current_network.bssid[2],ieee->current_network.bssid[3],ieee->current_network.bssid[4],ieee->current_network.bssid[5]);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&ieee->lock, flags);
|
|
|
|
|
|
|
|
if (ifup)
|
|
|
|
ieee80211_start_protocol(ieee);
|
|
|
|
|
|
|
|
out:
|
|
|
|
up(&ieee->wx_sem);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-11-27 13:10:00 +01:00
|
|
|
int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,
|
2012-11-27 13:09:16 +01:00
|
|
|
union iwreq_data *wrqu, char *b)
|
2008-12-05 05:01:41 +01:00
|
|
|
{
|
2012-11-27 13:09:16 +01:00
|
|
|
int len, ret = 0;
|
2008-12-05 05:01:41 +01:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (ieee->iw_mode == IW_MODE_MONITOR)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* We want avoid to give to the user inconsistent infos*/
|
|
|
|
spin_lock_irqsave(&ieee->lock, flags);
|
|
|
|
|
|
|
|
if (ieee->current_network.ssid[0] == '\0' ||
|
|
|
|
ieee->current_network.ssid_len == 0){
|
|
|
|
ret = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ieee->state != IEEE80211_LINKED &&
|
|
|
|
ieee->state != IEEE80211_LINKED_SCANNING &&
|
|
|
|
ieee->ssid_set == 0){
|
|
|
|
ret = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
len = ieee->current_network.ssid_len;
|
|
|
|
wrqu->essid.length = len;
|
2012-11-27 13:09:16 +01:00
|
|
|
strncpy(b, ieee->current_network.ssid, len);
|
2008-12-05 05:01:41 +01:00
|
|
|
wrqu->essid.flags = 1;
|
|
|
|
|
|
|
|
out:
|
|
|
|
spin_unlock_irqrestore(&ieee->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
|
|
|
|
u32 target_rate = wrqu->bitrate.value;
|
|
|
|
|
|
|
|
//added by lizhaoming for auto mode
|
2012-11-27 13:09:31 +01:00
|
|
|
if (target_rate == -1)
|
2012-11-27 13:09:02 +01:00
|
|
|
ieee->rate = 110;
|
2012-11-27 13:09:31 +01:00
|
|
|
else
|
2012-11-27 13:09:02 +01:00
|
|
|
ieee->rate = target_rate/100000;
|
2012-11-27 13:09:31 +01:00
|
|
|
|
2008-12-05 05:01:41 +01:00
|
|
|
//FIXME: we might want to limit rate also in management protocols.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
|
|
|
|
wrqu->bitrate.value = ieee->rate * 100000;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *b)
|
|
|
|
{
|
|
|
|
|
|
|
|
ieee->sync_scan_hurryup = 1;
|
|
|
|
|
|
|
|
down(&ieee->wx_sem);
|
|
|
|
|
|
|
|
if (wrqu->mode == ieee->iw_mode)
|
|
|
|
goto out;
|
|
|
|
|
2012-11-27 13:09:31 +01:00
|
|
|
if (wrqu->mode == IW_MODE_MONITOR)
|
2008-12-05 05:01:41 +01:00
|
|
|
ieee->dev->type = ARPHRD_IEEE80211;
|
2012-11-27 13:09:31 +01:00
|
|
|
else
|
2008-12-05 05:01:41 +01:00
|
|
|
ieee->dev->type = ARPHRD_ETHER;
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (!ieee->proto_started) {
|
2008-12-05 05:01:41 +01:00
|
|
|
ieee->iw_mode = wrqu->mode;
|
2012-11-27 13:08:47 +01:00
|
|
|
} else {
|
2008-12-05 05:01:41 +01:00
|
|
|
ieee80211_stop_protocol(ieee);
|
|
|
|
ieee->iw_mode = wrqu->mode;
|
|
|
|
ieee80211_start_protocol(ieee);
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
up(&ieee->wx_sem);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ieee80211_wx_sync_scan_wq(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
|
|
|
|
short chan;
|
|
|
|
|
|
|
|
chan = ieee->current_network.channel;
|
|
|
|
|
|
|
|
if (ieee->data_hard_stop)
|
|
|
|
ieee->data_hard_stop(ieee->dev);
|
|
|
|
|
|
|
|
ieee80211_stop_send_beacons(ieee);
|
|
|
|
|
|
|
|
ieee->state = IEEE80211_LINKED_SCANNING;
|
|
|
|
ieee->link_change(ieee->dev);
|
|
|
|
|
|
|
|
ieee80211_start_scan_syncro(ieee);
|
|
|
|
|
|
|
|
ieee->set_chan(ieee->dev, chan);
|
|
|
|
|
|
|
|
ieee->state = IEEE80211_LINKED;
|
|
|
|
ieee->link_change(ieee->dev);
|
|
|
|
|
|
|
|
if (ieee->data_hard_resume)
|
|
|
|
ieee->data_hard_resume(ieee->dev);
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
|
2008-12-05 05:01:41 +01:00
|
|
|
ieee80211_start_send_beacons(ieee);
|
|
|
|
|
|
|
|
//YJ,add,080828, In prevent of lossing ping packet during scanning
|
|
|
|
//ieee80211_sta_ps_send_null_frame(ieee, false);
|
|
|
|
//YJ,add,080828,end
|
|
|
|
|
|
|
|
up(&ieee->wx_sem);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *b)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
down(&ieee->wx_sem);
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)) {
|
2008-12-05 05:01:41 +01:00
|
|
|
ret = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
//YJ,add,080828
|
|
|
|
//In prevent of lossing ping packet during scanning
|
|
|
|
//ieee80211_sta_ps_send_null_frame(ieee, true);
|
|
|
|
//YJ,add,080828,end
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (ieee->state == IEEE80211_LINKED) {
|
2008-12-05 05:01:41 +01:00
|
|
|
queue_work(ieee->wq, &ieee->wx_sync_scan_wq);
|
|
|
|
/* intentionally forget to up sem */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
up(&ieee->wx_sem);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
|
|
|
|
struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
|
2012-11-27 13:09:46 +01:00
|
|
|
int ret = 0, len;
|
2008-12-05 05:01:41 +01:00
|
|
|
short proto_started;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
ieee->sync_scan_hurryup = 1;
|
|
|
|
|
|
|
|
down(&ieee->wx_sem);
|
|
|
|
|
|
|
|
proto_started = ieee->proto_started;
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (wrqu->essid.length > IW_ESSID_MAX_SIZE) {
|
2012-11-27 13:09:46 +01:00
|
|
|
ret = -E2BIG;
|
2008-12-05 05:01:41 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (ieee->iw_mode == IW_MODE_MONITOR) {
|
2012-11-27 13:09:46 +01:00
|
|
|
ret = -1;
|
2008-12-05 05:01:41 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (proto_started)
|
2008-12-05 05:01:41 +01:00
|
|
|
ieee80211_stop_protocol(ieee);
|
|
|
|
|
|
|
|
/* this is just to be sure that the GET wx callback
|
2012-04-17 15:56:43 +02:00
|
|
|
* has consistent infos. not needed otherwise
|
2008-12-05 05:01:41 +01:00
|
|
|
*/
|
|
|
|
spin_lock_irqsave(&ieee->lock, flags);
|
|
|
|
|
|
|
|
if (wrqu->essid.flags && wrqu->essid.length) {
|
|
|
|
//YJ,modified,080819
|
|
|
|
len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length) : IW_ESSID_MAX_SIZE;
|
|
|
|
memset(ieee->current_network.ssid, 0, ieee->current_network.ssid_len); //YJ,add,080819
|
|
|
|
strncpy(ieee->current_network.ssid, extra, len);
|
|
|
|
ieee->current_network.ssid_len = len;
|
|
|
|
ieee->ssid_set = 1;
|
|
|
|
//YJ,modified,080819,end
|
|
|
|
|
|
|
|
//YJ,add,080819,for hidden ap
|
2012-11-27 13:08:47 +01:00
|
|
|
if (len == 0) {
|
2008-12-05 05:01:41 +01:00
|
|
|
memset(ieee->current_network.bssid, 0, ETH_ALEN);
|
|
|
|
ieee->current_network.capability = 0;
|
|
|
|
}
|
|
|
|
//YJ,add,080819,for hidden ap,end
|
2012-11-27 13:08:47 +01:00
|
|
|
} else {
|
2008-12-05 05:01:41 +01:00
|
|
|
ieee->ssid_set = 0;
|
|
|
|
ieee->current_network.ssid[0] = '\0';
|
|
|
|
ieee->current_network.ssid_len = 0;
|
|
|
|
}
|
|
|
|
//printk("==========set essid %s!\n",ieee->current_network.ssid);
|
|
|
|
spin_unlock_irqrestore(&ieee->lock, flags);
|
|
|
|
|
|
|
|
if (proto_started)
|
|
|
|
ieee80211_start_protocol(ieee);
|
|
|
|
out:
|
|
|
|
up(&ieee->wx_sem);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-11-27 13:10:00 +01:00
|
|
|
int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
|
2008-12-05 05:01:41 +01:00
|
|
|
union iwreq_data *wrqu, char *b)
|
|
|
|
{
|
|
|
|
|
|
|
|
wrqu->mode = ieee->iw_mode;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-27 13:10:00 +01:00
|
|
|
int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
|
2008-12-05 05:01:41 +01:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
|
|
|
|
int *parms = (int *)extra;
|
|
|
|
int enable = (parms[0] > 0);
|
|
|
|
short prev = ieee->raw_tx;
|
|
|
|
|
|
|
|
down(&ieee->wx_sem);
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (enable)
|
2008-12-05 05:01:41 +01:00
|
|
|
ieee->raw_tx = 1;
|
|
|
|
else
|
|
|
|
ieee->raw_tx = 0;
|
|
|
|
|
2012-11-27 13:10:14 +01:00
|
|
|
netdev_info(ieee->dev, "raw TX is %s\n",
|
|
|
|
ieee->raw_tx ? "enabled" : "disabled");
|
2008-12-05 05:01:41 +01:00
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (ieee->iw_mode == IW_MODE_MONITOR) {
|
|
|
|
if (prev == 0 && ieee->raw_tx) {
|
2008-12-05 05:01:41 +01:00
|
|
|
if (ieee->data_hard_resume)
|
|
|
|
ieee->data_hard_resume(ieee->dev);
|
|
|
|
|
|
|
|
netif_carrier_on(ieee->dev);
|
|
|
|
}
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (prev && ieee->raw_tx == 1)
|
2008-12-05 05:01:41 +01:00
|
|
|
netif_carrier_off(ieee->dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
up(&ieee->wx_sem);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ieee80211_wx_get_name(struct ieee80211_device *ieee,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2009-06-20 15:32:22 +02:00
|
|
|
strlcpy(wrqu->name, "802.11", IFNAMSIZ);
|
2012-11-27 13:08:47 +01:00
|
|
|
if (ieee->modulation & IEEE80211_CCK_MODULATION) {
|
2009-06-20 15:32:22 +02:00
|
|
|
strlcat(wrqu->name, "b", IFNAMSIZ);
|
2012-11-27 13:08:47 +01:00
|
|
|
if (ieee->modulation & IEEE80211_OFDM_MODULATION)
|
2009-06-20 15:32:22 +02:00
|
|
|
strlcat(wrqu->name, "/g", IFNAMSIZ);
|
2012-11-27 13:08:47 +01:00
|
|
|
} else if (ieee->modulation & IEEE80211_OFDM_MODULATION)
|
2009-06-20 15:32:22 +02:00
|
|
|
strlcat(wrqu->name, "g", IFNAMSIZ);
|
2008-12-05 05:01:41 +01:00
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if ((ieee->state == IEEE80211_LINKED) ||
|
2008-12-05 05:01:41 +01:00
|
|
|
(ieee->state == IEEE80211_LINKED_SCANNING))
|
2012-11-27 13:09:16 +01:00
|
|
|
strlcat(wrqu->name, " link", IFNAMSIZ);
|
2012-11-27 13:08:47 +01:00
|
|
|
else if (ieee->state != IEEE80211_NOLINK)
|
2012-11-27 13:09:16 +01:00
|
|
|
strlcat(wrqu->name, " .....", IFNAMSIZ);
|
2008-12-05 05:01:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* this is mostly stolen from hostap */
|
|
|
|
int ieee80211_wx_set_power(struct ieee80211_device *ieee,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if ((!ieee->sta_wake_up) ||
|
|
|
|
(!ieee->ps_request_tx_ack) ||
|
|
|
|
(!ieee->enter_sleep_state) ||
|
|
|
|
(!ieee->ps_is_queue_empty)) {
|
2008-12-05 05:01:41 +01:00
|
|
|
|
2010-01-31 21:02:08 +01:00
|
|
|
printk("ERROR. PS mode tried to be use but driver missed a callback\n\n");
|
2008-12-05 05:01:41 +01:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
down(&ieee->wx_sem);
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (wrqu->power.disabled) {
|
2008-12-05 05:01:41 +01:00
|
|
|
ieee->ps = IEEE80211_PS_DISABLED;
|
|
|
|
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
switch (wrqu->power.flags & IW_POWER_MODE) {
|
|
|
|
case IW_POWER_UNICAST_R:
|
|
|
|
ieee->ps = IEEE80211_PS_UNICAST;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case IW_POWER_ALL_R:
|
|
|
|
ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IW_POWER_ON:
|
|
|
|
ieee->ps = IEEE80211_PS_DISABLED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wrqu->power.flags & IW_POWER_TIMEOUT) {
|
|
|
|
|
|
|
|
ieee->ps_timeout = wrqu->power.value / 1000;
|
2012-11-27 13:09:16 +01:00
|
|
|
printk("Timeout %d\n", ieee->ps_timeout);
|
2008-12-05 05:01:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (wrqu->power.flags & IW_POWER_PERIOD) {
|
|
|
|
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
goto exit;
|
|
|
|
//wrq->value / 1024;
|
|
|
|
|
|
|
|
}
|
|
|
|
exit:
|
|
|
|
up(&ieee->wx_sem);
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is stolen from hostap */
|
|
|
|
int ieee80211_wx_get_power(struct ieee80211_device *ieee,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2012-11-27 13:09:46 +01:00
|
|
|
int ret = 0;
|
2008-12-05 05:01:41 +01:00
|
|
|
|
|
|
|
down(&ieee->wx_sem);
|
|
|
|
|
2012-11-27 13:08:47 +01:00
|
|
|
if (ieee->ps == IEEE80211_PS_DISABLED) {
|
2008-12-05 05:01:41 +01:00
|
|
|
wrqu->power.disabled = 1;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
wrqu->power.disabled = 0;
|
|
|
|
|
|
|
|
// if ((wrqu->power.flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
|
|
|
|
wrqu->power.flags = IW_POWER_TIMEOUT;
|
|
|
|
wrqu->power.value = ieee->ps_timeout * 1000;
|
|
|
|
// } else {
|
|
|
|
// ret = -EOPNOTSUPP;
|
|
|
|
// goto exit;
|
|
|
|
//wrqu->power.flags = IW_POWER_PERIOD;
|
|
|
|
//wrqu->power.value = ieee->current_network.dtim_period *
|
|
|
|
// ieee->current_network.beacon_interval * 1024;
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
if (ieee->ps & IEEE80211_PS_MBCAST)
|
|
|
|
wrqu->power.flags |= IW_POWER_ALL_R;
|
|
|
|
else
|
|
|
|
wrqu->power.flags |= IW_POWER_UNICAST_R;
|
|
|
|
|
|
|
|
exit:
|
|
|
|
up(&ieee->wx_sem);
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|