Commit c7d4bd7d authored by Moritz Muehlenhoff's avatar Moritz Muehlenhoff Committed by Greg Kroah-Hartman

Staging: wlan-ng: p80211wext.c: Coding style cleanups

Signed-off-by: default avatarMoritz Muehlenhoff <jmm@debian.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e573aaa4
...@@ -79,16 +79,14 @@ static int p80211wext_giwessid(netdevice_t *dev, ...@@ -79,16 +79,14 @@ static int p80211wext_giwessid(netdevice_t *dev,
static u8 p80211_mhz_to_channel(u16 mhz) static u8 p80211_mhz_to_channel(u16 mhz)
{ {
if (mhz >= 5000) { if (mhz >= 5000)
return ((mhz - 5000) / 5); return (mhz - 5000) / 5;
}
if (mhz == 2482) if (mhz == 2482)
return 14; return 14;
if (mhz >= 2407) { if (mhz >= 2407)
return ((mhz - 2407) / 5); return (mhz - 2407) / 5;
}
return 0; return 0;
} }
...@@ -102,19 +100,15 @@ static u16 p80211_channel_to_mhz(u8 ch, int dot11a) ...@@ -102,19 +100,15 @@ static u16 p80211_channel_to_mhz(u8 ch, int dot11a)
return 0; return 0;
/* 5G */ /* 5G */
if (dot11a)
if (dot11a) { return 5000 + (5 * ch);
return (5000 + (5 * ch));
}
/* 2.4G */ /* 2.4G */
if (ch == 14) if (ch == 14)
return 2484; return 2484;
if ((ch < 14) && (ch > 0)) { if ((ch < 14) && (ch > 0))
return (2407 + (5 * ch)); return 2407 + (5 * ch);
}
return 0; return 0;
} }
...@@ -124,44 +118,41 @@ static const long p80211wext_channel_freq[] = { ...@@ -124,44 +118,41 @@ static const long p80211wext_channel_freq[] = {
2412, 2417, 2422, 2427, 2432, 2437, 2442, 2412, 2417, 2422, 2427, 2432, 2437, 2442,
2447, 2452, 2457, 2462, 2467, 2472, 2484 2447, 2452, 2457, 2462, 2467, 2472, 2484
}; };
#define NUM_CHANNELS ARRAY_SIZE(p80211wext_channel_freq) #define NUM_CHANNELS ARRAY_SIZE(p80211wext_channel_freq)
/* steal a spare bit to store the shared/opensystems state. should default to open if not set */ /* steal a spare bit to store the shared/opensystems state.
should default to open if not set */
#define HOSTWEP_SHAREDKEY BIT(3) #define HOSTWEP_SHAREDKEY BIT(3)
static int qual_as_percent(int snr)
/** function declarations =============== */ {
if (snr <= 0)
static int qual_as_percent(int snr ) { return 0;
if ( snr <= 0 ) if (snr <= 40)
return 0; return snr * 5 / 2;
if ( snr <= 40 ) return 100;
return snr*5/2;
return 100;
} }
static int p80211wext_dorequest(wlandevice_t *wlandev, u32 did, u32 data) static int p80211wext_dorequest(wlandevice_t *wlandev, u32 did, u32 data)
{ {
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
int result; int result;
msg.msgcode = DIDmsg_dot11req_mibset; msg.msgcode = DIDmsg_dot11req_mibset;
mibitem.did = did; mibitem.did = did;
mibitem.data = data; mibitem.data = data;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
return result; return result;
} }
static int p80211wext_autojoin(wlandevice_t *wlandev) static int p80211wext_autojoin(wlandevice_t *wlandev)
{ {
p80211msg_lnxreq_autojoin_t msg; p80211msg_lnxreq_autojoin_t msg;
struct iw_point data; struct iw_point data;
char ssid[IW_ESSID_MAX_SIZE]; char ssid[IW_ESSID_MAX_SIZE];
int result; int result;
...@@ -175,23 +166,22 @@ static int p80211wext_autojoin(wlandevice_t *wlandev) ...@@ -175,23 +166,22 @@ static int p80211wext_autojoin(wlandevice_t *wlandev)
goto exit; goto exit;
} }
if ( wlandev->hostwep & HOSTWEP_SHAREDKEY ) if (wlandev->hostwep & HOSTWEP_SHAREDKEY)
msg.authtype.data = P80211ENUM_authalg_sharedkey; msg.authtype.data = P80211ENUM_authalg_sharedkey;
else else
msg.authtype.data = P80211ENUM_authalg_opensystem; msg.authtype.data = P80211ENUM_authalg_opensystem;
msg.msgcode = DIDmsg_lnxreq_autojoin; msg.msgcode = DIDmsg_lnxreq_autojoin;
/* Trim the last '\0' to fit the SSID format */ /* Trim the last '\0' to fit the SSID format */
if (data.length && ssid[data.length-1] == '\0') { if (data.length && ssid[data.length - 1] == '\0')
data.length = data.length - 1; data.length = data.length - 1;
}
memcpy(msg.ssid.data.data, ssid, data.length); memcpy(msg.ssid.data.data, ssid, data.length);
msg.ssid.data.len = data.length; msg.ssid.data.len = data.length;
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -205,15 +195,15 @@ exit: ...@@ -205,15 +195,15 @@ exit:
} }
/* called by /proc/net/wireless */ /* called by /proc/net/wireless */
struct iw_statistics* p80211wext_get_wireless_stats (netdevice_t *dev) struct iw_statistics *p80211wext_get_wireless_stats(netdevice_t * dev)
{ {
p80211msg_lnxreq_commsquality_t quality; p80211msg_lnxreq_commsquality_t quality;
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
struct iw_statistics* wstats = &wlandev->wstats; struct iw_statistics *wstats = &wlandev->wstats;
int retval; int retval;
/* Check */ /* Check */
if ( (wlandev == NULL) || (wlandev->msdstate != WLAN_MSD_RUNNING) ) if ((wlandev == NULL) || (wlandev->msdstate != WLAN_MSD_RUNNING))
return NULL; return NULL;
/* XXX Only valid in station mode */ /* XXX Only valid in station mode */
...@@ -225,22 +215,22 @@ struct iw_statistics* p80211wext_get_wireless_stats (netdevice_t *dev) ...@@ -225,22 +215,22 @@ struct iw_statistics* p80211wext_get_wireless_stats (netdevice_t *dev)
quality.dbm.status = P80211ENUM_msgitem_status_data_ok; quality.dbm.status = P80211ENUM_msgitem_status_data_ok;
/* send message to nsd */ /* send message to nsd */
if ( wlandev->mlmerequest == NULL ) if (wlandev->mlmerequest == NULL)
return NULL; return NULL;
retval = wlandev->mlmerequest(wlandev, (p80211msg_t*) &quality); retval = wlandev->mlmerequest(wlandev, (p80211msg_t *)&quality);
wstats->qual.qual = qual_as_percent(quality.link.data); /* overall link quality */ wstats->qual.qual = qual_as_percent(quality.link.data); /* overall link quality */
wstats->qual.level = quality.level.data; /* instant signal level */ wstats->qual.level = quality.level.data; /* instant signal level */
wstats->qual.noise = quality.noise.data; /* instant noise level */ wstats->qual.noise = quality.noise.data; /* instant noise level */
wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
wstats->discard.code = wlandev->rx.decrypt_err; wstats->discard.code = wlandev->rx.decrypt_err;
wstats->discard.nwid = 0; wstats->discard.nwid = 0;
wstats->discard.misc = 0; wstats->discard.misc = 0;
wstats->discard.fragment = 0; // incomplete fragments wstats->discard.fragment = 0; /* incomplete fragments */
wstats->discard.retries = 0; // tx retries. wstats->discard.retries = 0; /* tx retries. */
wstats->miss.beacon = 0; wstats->miss.beacon = 0;
return wstats; return wstats;
...@@ -280,15 +270,15 @@ static int p80211wext_giwfreq(netdevice_t *dev, ...@@ -280,15 +270,15 @@ static int p80211wext_giwfreq(netdevice_t *dev,
struct iw_freq *freq, char *extra) struct iw_freq *freq, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
int result; int result;
int err = 0; int err = 0;
msg.msgcode = DIDmsg_dot11req_mibget; msg.msgcode = DIDmsg_dot11req_mibget;
mibitem.did = DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel; mibitem.did = DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -306,7 +296,7 @@ static int p80211wext_giwfreq(netdevice_t *dev, ...@@ -306,7 +296,7 @@ static int p80211wext_giwfreq(netdevice_t *dev,
freq->e = 1; freq->e = 1;
freq->m = p80211_channel_to_mhz(mibitem.data, 0) * 100000; freq->m = p80211_channel_to_mhz(mibitem.data, 0) * 100000;
exit: exit:
return err; return err;
} }
...@@ -315,8 +305,8 @@ static int p80211wext_siwfreq(netdevice_t *dev, ...@@ -315,8 +305,8 @@ static int p80211wext_siwfreq(netdevice_t *dev,
struct iw_freq *freq, char *extra) struct iw_freq *freq, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
int result; int result;
int err = 0; int err = 0;
...@@ -329,20 +319,20 @@ static int p80211wext_siwfreq(netdevice_t *dev, ...@@ -329,20 +319,20 @@ static int p80211wext_siwfreq(netdevice_t *dev,
mibitem.did = DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel; mibitem.did = DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel;
mibitem.status = P80211ENUM_msgitem_status_data_ok; mibitem.status = P80211ENUM_msgitem_status_data_ok;
if ( (freq->e == 0) && (freq->m <= 1000) ) if ((freq->e == 0) && (freq->m <= 1000))
mibitem.data = freq->m; mibitem.data = freq->m;
else else
mibitem.data = p80211_mhz_to_channel(freq->m); mibitem.data = p80211_mhz_to_channel(freq->m);
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
goto exit; goto exit;
} }
exit: exit:
return err; return err;
} }
...@@ -375,10 +365,10 @@ static int p80211wext_siwmode(netdevice_t *dev, ...@@ -375,10 +365,10 @@ static int p80211wext_siwmode(netdevice_t *dev,
__u32 *mode, char *extra) __u32 *mode, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
int result; int result;
int err = 0; int err = 0;
if (!wlan_wext_write) { if (!wlan_wext_write) {
err = (-EOPNOTSUPP); err = (-EOPNOTSUPP);
...@@ -416,29 +406,28 @@ static int p80211wext_siwmode(netdevice_t *dev, ...@@ -416,29 +406,28 @@ static int p80211wext_siwmode(netdevice_t *dev,
mibitem.did = DIDmib_p2_p2Static_p2CnfPortType; mibitem.did = DIDmib_p2_p2Static_p2CnfPortType;
mibitem.data = (*mode == IW_MODE_ADHOC) ? 0 : 1; mibitem.data = (*mode == IW_MODE_ADHOC) ? 0 : 1;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) if (result)
err = -EFAULT; err = -EFAULT;
exit: exit:
return err; return err;
} }
static int p80211wext_giwrange(netdevice_t *dev, static int p80211wext_giwrange(netdevice_t *dev,
struct iw_request_info *info, struct iw_request_info *info,
struct iw_point *data, char *extra) struct iw_point *data, char *extra)
{ {
struct iw_range *range = (struct iw_range *) extra; struct iw_range *range = (struct iw_range *)extra;
int i, val; int i, val;
// for backward compatability set size & zero everything we don't understand /* for backward compatability set size and zero everything we don't understand */
data->length = sizeof(*range); data->length = sizeof(*range);
memset(range,0,sizeof(*range)); memset(range, 0, sizeof(*range));
range->txpower_capa = IW_TXPOW_DBM; range->txpower_capa = IW_TXPOW_DBM;
// XXX what about min/max_pmp, min/max_pmt, etc. /* XXX what about min/max_pmp, min/max_pmt, etc. */
range->we_version_compiled = WIRELESS_EXT; range->we_version_compiled = WIRELESS_EXT;
range->we_version_source = 13; range->we_version_source = 13;
...@@ -448,18 +437,18 @@ static int p80211wext_giwrange(netdevice_t *dev, ...@@ -448,18 +437,18 @@ static int p80211wext_giwrange(netdevice_t *dev,
range->min_retry = 0; range->min_retry = 0;
range->max_retry = 255; range->max_retry = 255;
range->event_capa[0] = (IW_EVENT_CAPA_K_0 | //mode/freq/ssid range->event_capa[0] = (IW_EVENT_CAPA_K_0 | /* mode/freq/ssid */
IW_EVENT_CAPA_MASK(SIOCGIWAP) | IW_EVENT_CAPA_MASK(SIOCGIWAP) |
IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
range->event_capa[1] = IW_EVENT_CAPA_K_1; //encode range->event_capa[1] = IW_EVENT_CAPA_K_1; /* encode */
range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVQUAL) | range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVQUAL) |
IW_EVENT_CAPA_MASK(IWEVCUSTOM) ); IW_EVENT_CAPA_MASK(IWEVCUSTOM));
range->num_channels = NUM_CHANNELS; range->num_channels = NUM_CHANNELS;
/* XXX need to filter against the regulatory domain &| active set */ /* XXX need to filter against the regulatory domain &| active set */
val = 0; val = 0;
for (i = 0; i < NUM_CHANNELS ; i++) { for (i = 0; i < NUM_CHANNELS; i++) {
range->freq[val].i = i + 1; range->freq[val].i = i + 1;
range->freq[val].m = p80211wext_channel_freq[i] * 100000; range->freq[val].m = p80211wext_channel_freq[i] * 100000;
range->freq[val].e = 1; range->freq[val].e = 1;
...@@ -473,7 +462,7 @@ static int p80211wext_giwrange(netdevice_t *dev, ...@@ -473,7 +462,7 @@ static int p80211wext_giwrange(netdevice_t *dev,
range->max_qual.level = 0; range->max_qual.level = 0;
range->max_qual.noise = 0; range->max_qual.noise = 0;
range->sensitivity = 3; range->sensitivity = 3;
// XXX these need to be nsd-specific! /* XXX these need to be nsd-specific! */
range->min_rts = 0; range->min_rts = 0;
range->max_rts = 2347; range->max_rts = 2347;
...@@ -485,11 +474,11 @@ static int p80211wext_giwrange(netdevice_t *dev, ...@@ -485,11 +474,11 @@ static int p80211wext_giwrange(netdevice_t *dev,
range->encoding_size[0] = 5; range->encoding_size[0] = 5;
range->encoding_size[1] = 13; range->encoding_size[1] = 13;
// XXX what about num_bitrates/throughput? /* XXX what about num_bitrates/throughput? */
range->num_bitrates = 0; range->num_bitrates = 0;
/* estimated max throughput */ /* estimated max throughput */
// XXX need to cap it if we're running at ~2Mbps.. /* XXX need to cap it if we're running at ~2Mbps.. */
range->throughput = 5500000; range->throughput = 5500000;
return 0; return 0;
...@@ -545,7 +534,7 @@ static int p80211wext_giwencode(netdevice_t *dev, ...@@ -545,7 +534,7 @@ static int p80211wext_giwencode(netdevice_t *dev,
erq->length = wlandev->wep_keylens[i]; erq->length = wlandev->wep_keylens[i];
memcpy(key, wlandev->wep_keys[i], erq->length); memcpy(key, wlandev->wep_keys[i], erq->length);
exit: exit:
return err; return err;
} }
...@@ -554,8 +543,8 @@ static int p80211wext_siwencode(netdevice_t *dev, ...@@ -554,8 +543,8 @@ static int p80211wext_siwencode(netdevice_t *dev,
struct iw_point *erq, char *key) struct iw_point *erq, char *key)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
p80211item_pstr32_t pstr; p80211item_pstr32_t pstr;
int err = 0; int err = 0;
int result = 0; int result = 0;
...@@ -567,18 +556,20 @@ static int p80211wext_siwencode(netdevice_t *dev, ...@@ -567,18 +556,20 @@ static int p80211wext_siwencode(netdevice_t *dev,
} }
/* Check the Key index first. */ /* Check the Key index first. */
if((i = (erq->flags & IW_ENCODE_INDEX))) { if ((i = (erq->flags & IW_ENCODE_INDEX))) {
if ((i < 1) || (i > NUM_WEPKEYS)) { if ((i < 1) || (i > NUM_WEPKEYS)) {
err = -EINVAL; err = -EINVAL;
goto exit; goto exit;
} } else
else
i--; i--;
/* Set current key number only if no keys are given */ /* Set current key number only if no keys are given */
if (erq->flags & IW_ENCODE_NOKEY) { if (erq->flags & IW_ENCODE_NOKEY) {
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, i); result =
p80211wext_dorequest(wlandev,
DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
i);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -587,12 +578,12 @@ static int p80211wext_siwencode(netdevice_t *dev, ...@@ -587,12 +578,12 @@ static int p80211wext_siwencode(netdevice_t *dev,
} }
} else { } else {
// Use defaultkey if no Key Index /* Use defaultkey if no Key Index */
i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK; i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK;
} }
/* Check if there is no key information in the iwconfig request */ /* Check if there is no key information in the iwconfig request */
if((erq->flags & IW_ENCODE_NOKEY) == 0 ) { if ((erq->flags & IW_ENCODE_NOKEY) == 0) {
/*------------------------------------------------------------ /*------------------------------------------------------------
* If there is WEP Key for setting, check the Key Information * If there is WEP Key for setting, check the Key Information
...@@ -609,32 +600,35 @@ static int p80211wext_siwencode(netdevice_t *dev, ...@@ -609,32 +600,35 @@ static int p80211wext_siwencode(netdevice_t *dev,
memcpy(pstr.data.data, key, erq->length); memcpy(pstr.data.data, key, erq->length);
pstr.data.len = erq->length; pstr.data.len = erq->length;
switch(i) switch (i) {
{ case 0:
case 0: pstr.did =
pstr.did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0; DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
break; break;
case 1: case 1:
pstr.did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1; pstr.did =
break; DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
break;
case 2:
pstr.did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2; case 2:
break; pstr.did =
DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
case 3: break;
pstr.did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
break; case 3:
pstr.did =
default: DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
err = -EINVAL; break;
goto exit;
default:
err = -EINVAL;
goto exit;
} }
msg.msgcode = DIDmsg_dot11req_mibset; msg.msgcode = DIDmsg_dot11req_mibset;
memcpy(&msg.mibattribute.data, &pstr, sizeof(pstr)); memcpy(&msg.mibattribute.data, &pstr, sizeof(pstr));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -646,9 +640,15 @@ static int p80211wext_siwencode(netdevice_t *dev, ...@@ -646,9 +640,15 @@ static int p80211wext_siwencode(netdevice_t *dev,
/* Check the PrivacyInvoked flag */ /* Check the PrivacyInvoked flag */
if (erq->flags & IW_ENCODE_DISABLED) { if (erq->flags & IW_ENCODE_DISABLED) {
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_false); result =
p80211wext_dorequest(wlandev,
DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
P80211ENUM_truth_false);
} else { } else {
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_true); result =
p80211wext_dorequest(wlandev,
DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
P80211ENUM_truth_true);
} }
if (result) { if (result) {
...@@ -657,17 +657,22 @@ static int p80211wext_siwencode(netdevice_t *dev, ...@@ -657,17 +657,22 @@ static int p80211wext_siwencode(netdevice_t *dev,
} }
/* The security mode may be open or restricted, and its meaning /* The security mode may be open or restricted, and its meaning
depends on the card used. With most cards, in open mode no depends on the card used. With most cards, in open mode no
authentication is used and the card may also accept non- authentication is used and the card may also accept non-
encrypted sessions, whereas in restricted mode only encrypted encrypted sessions, whereas in restricted mode only encrypted
sessions are accepted and the card will use authentication if sessions are accepted and the card will use authentication if
available. available.
*/ */
if (erq->flags & IW_ENCODE_RESTRICTED) { if (erq->flags & IW_ENCODE_RESTRICTED) {
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_true); result =
} p80211wext_dorequest(wlandev,
else if (erq->flags & IW_ENCODE_OPEN) { DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_false); P80211ENUM_truth_true);
} else if (erq->flags & IW_ENCODE_OPEN) {
result =
p80211wext_dorequest(wlandev,
DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
P80211ENUM_truth_false);
} }
if (result) { if (result) {
...@@ -675,7 +680,7 @@ static int p80211wext_siwencode(netdevice_t *dev, ...@@ -675,7 +680,7 @@ static int p80211wext_siwencode(netdevice_t *dev,
goto exit; goto exit;
} }
exit: exit:
return err; return err;
} }
...@@ -695,7 +700,7 @@ static int p80211wext_giwessid(netdevice_t *dev, ...@@ -695,7 +700,7 @@ static int p80211wext_giwessid(netdevice_t *dev,
data->length++; data->length++;
#endif #endif
} else { } else {
memset(essid, 0, sizeof(wlandev->ssid.data)); memset(essid, 0, sizeof(wlandev->ssid.data));
data->length = 0; data->length = 0;
data->flags = 0; data->flags = 0;
} }
...@@ -708,7 +713,7 @@ static int p80211wext_siwessid(netdevice_t *dev, ...@@ -708,7 +713,7 @@ static int p80211wext_siwessid(netdevice_t *dev,
struct iw_point *data, char *essid) struct iw_point *data, char *essid)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211msg_lnxreq_autojoin_t msg; p80211msg_lnxreq_autojoin_t msg;
int result; int result;
int err = 0; int err = 0;
...@@ -719,41 +724,38 @@ static int p80211wext_siwessid(netdevice_t *dev, ...@@ -719,41 +724,38 @@ static int p80211wext_siwessid(netdevice_t *dev,
goto exit; goto exit;
} }
if (wlandev->hostwep & HOSTWEP_SHAREDKEY)
if ( wlandev->hostwep & HOSTWEP_SHAREDKEY ) msg.authtype.data = P80211ENUM_authalg_sharedkey;
msg.authtype.data = P80211ENUM_authalg_sharedkey;
else else
msg.authtype.data = P80211ENUM_authalg_opensystem; msg.authtype.data = P80211ENUM_authalg_opensystem;
msg.msgcode = DIDmsg_lnxreq_autojoin; msg.msgcode = DIDmsg_lnxreq_autojoin;
#if (WIRELESS_EXT < 21) #if (WIRELESS_EXT < 21)
if (length) length--; if (length)
length--;
#endif #endif
/* Trim the last '\0' to fit the SSID format */ /* Trim the last '\0' to fit the SSID format */
if (length && essid[length - 1] == '\0')
if (length && essid[length-1] == '\0') { length--;
length--;
}
memcpy(msg.ssid.data.data, essid, length); memcpy(msg.ssid.data.data, essid, length);
msg.ssid.data.len = length; msg.ssid.data.len = length;
pr_debug("autojoin_ssid for %s \n",essid); pr_debug("autojoin_ssid for %s \n", essid);
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
pr_debug("autojoin_ssid %d\n",result); pr_debug("autojoin_ssid %d\n", result);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
goto exit; goto exit;
} }
exit: exit:
return err; return err;
} }
static int p80211wext_siwcommit(netdevice_t *dev, static int p80211wext_siwcommit(netdevice_t *dev,
struct iw_request_info *info, struct iw_request_info *info,
struct iw_point *data, char *essid) struct iw_point *data, char *essid)
...@@ -769,25 +771,24 @@ static int p80211wext_siwcommit(netdevice_t *dev, ...@@ -769,25 +771,24 @@ static int p80211wext_siwcommit(netdevice_t *dev,
/* Auto Join */ /* Auto Join */
err = p80211wext_autojoin(wlandev); err = p80211wext_autojoin(wlandev);
exit: exit:
return err; return err;
} }
static int p80211wext_giwrate(netdevice_t *dev, static int p80211wext_giwrate(netdevice_t *dev,
struct iw_request_info *info, struct iw_request_info *info,
struct iw_param *rrq, char *extra) struct iw_param *rrq, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
int result; int result;
int err = 0; int err = 0;
msg.msgcode = DIDmsg_dot11req_mibget; msg.msgcode = DIDmsg_dot11req_mibget;
mibitem.did = DIDmib_p2_p2MAC_p2CurrentTxRate; mibitem.did = DIDmib_p2_p2MAC_p2CurrentTxRate;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -796,7 +797,7 @@ static int p80211wext_giwrate(netdevice_t *dev, ...@@ -796,7 +797,7 @@ static int p80211wext_giwrate(netdevice_t *dev,
memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem));
rrq->fixed = 0; /* can it change? */ rrq->fixed = 0; /* can it change? */
rrq->disabled = 0; rrq->disabled = 0;
rrq->value = 0; rrq->value = 0;
...@@ -821,7 +822,7 @@ static int p80211wext_giwrate(netdevice_t *dev, ...@@ -821,7 +822,7 @@ static int p80211wext_giwrate(netdevice_t *dev,
default: default:
err = -EINVAL; err = -EINVAL;
} }
exit: exit:
return err; return err;
} }
...@@ -830,15 +831,15 @@ static int p80211wext_giwrts(netdevice_t *dev, ...@@ -830,15 +831,15 @@ static int p80211wext_giwrts(netdevice_t *dev,
struct iw_param *rts, char *extra) struct iw_param *rts, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
int result; int result;
int err = 0; int err = 0;
msg.msgcode = DIDmsg_dot11req_mibget; msg.msgcode = DIDmsg_dot11req_mibget;
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold; mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -851,18 +852,17 @@ static int p80211wext_giwrts(netdevice_t *dev, ...@@ -851,18 +852,17 @@ static int p80211wext_giwrts(netdevice_t *dev,
rts->disabled = (rts->value == 2347); rts->disabled = (rts->value == 2347);
rts->fixed = 1; rts->fixed = 1;
exit: exit:
return err; return err;
} }
static int p80211wext_siwrts(netdevice_t *dev, static int p80211wext_siwrts(netdevice_t *dev,
struct iw_request_info *info, struct iw_request_info *info,
struct iw_param *rts, char *extra) struct iw_param *rts, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
int result; int result;
int err = 0; int err = 0;
...@@ -879,14 +879,14 @@ static int p80211wext_siwrts(netdevice_t *dev, ...@@ -879,14 +879,14 @@ static int p80211wext_siwrts(netdevice_t *dev,
mibitem.data = rts->value; mibitem.data = rts->value;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
goto exit; goto exit;
} }
exit: exit:
return err; return err;
} }
...@@ -895,15 +895,16 @@ static int p80211wext_giwfrag(netdevice_t *dev, ...@@ -895,15 +895,16 @@ static int p80211wext_giwfrag(netdevice_t *dev,
struct iw_param *frag, char *extra) struct iw_param *frag, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
int result; int result;
int err = 0; int err = 0;
msg.msgcode = DIDmsg_dot11req_mibget; msg.msgcode = DIDmsg_dot11req_mibget;
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold; mibitem.did =
DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -916,7 +917,7 @@ static int p80211wext_giwfrag(netdevice_t *dev, ...@@ -916,7 +917,7 @@ static int p80211wext_giwfrag(netdevice_t *dev,
frag->disabled = (frag->value == 2346); frag->disabled = (frag->value == 2346);
frag->fixed = 1; frag->fixed = 1;
exit: exit:
return err; return err;
} }
...@@ -925,8 +926,8 @@ static int p80211wext_siwfrag(netdevice_t *dev, ...@@ -925,8 +926,8 @@ static int p80211wext_siwfrag(netdevice_t *dev,
struct iw_param *frag, char *extra) struct iw_param *frag, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
int result; int result;
int err = 0; int err = 0;
...@@ -936,7 +937,8 @@ static int p80211wext_siwfrag(netdevice_t *dev, ...@@ -936,7 +937,8 @@ static int p80211wext_siwfrag(netdevice_t *dev,
} }
msg.msgcode = DIDmsg_dot11req_mibset; msg.msgcode = DIDmsg_dot11req_mibset;
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold; mibitem.did =
DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold;
if (frag->disabled) if (frag->disabled)
mibitem.data = 2346; mibitem.data = 2346;
...@@ -944,14 +946,14 @@ static int p80211wext_siwfrag(netdevice_t *dev, ...@@ -944,14 +946,14 @@ static int p80211wext_siwfrag(netdevice_t *dev,
mibitem.data = frag->value; mibitem.data = frag->value;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
goto exit; goto exit;
} }
exit: exit:
return err; return err;
} }
...@@ -968,8 +970,8 @@ static int p80211wext_giwretry(netdevice_t *dev, ...@@ -968,8 +970,8 @@ static int p80211wext_giwretry(netdevice_t *dev,
struct iw_param *rrq, char *extra) struct iw_param *rrq, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
int result; int result;
int err = 0; int err = 0;
u16 shortretry, longretry, lifetime; u16 shortretry, longretry, lifetime;
...@@ -978,7 +980,7 @@ static int p80211wext_giwretry(netdevice_t *dev, ...@@ -978,7 +980,7 @@ static int p80211wext_giwretry(netdevice_t *dev,
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit; mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -992,7 +994,7 @@ static int p80211wext_giwretry(netdevice_t *dev, ...@@ -992,7 +994,7 @@ static int p80211wext_giwretry(netdevice_t *dev,
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit; mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -1003,10 +1005,11 @@ static int p80211wext_giwretry(netdevice_t *dev, ...@@ -1003,10 +1005,11 @@ static int p80211wext_giwretry(netdevice_t *dev,
longretry = mibitem.data; longretry = mibitem.data;
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime; mibitem.did =
DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -1034,7 +1037,7 @@ static int p80211wext_giwretry(netdevice_t *dev, ...@@ -1034,7 +1037,7 @@ static int p80211wext_giwretry(netdevice_t *dev,
} }
} }
exit: exit:
return err; return err;
} }
...@@ -1044,8 +1047,8 @@ static int p80211wext_siwretry(netdevice_t *dev, ...@@ -1044,8 +1047,8 @@ static int p80211wext_siwretry(netdevice_t *dev,
struct iw_param *rrq, char *extra) struct iw_param *rrq, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
int result; int result;
int err = 0; int err = 0;
...@@ -1062,11 +1065,12 @@ static int p80211wext_siwretry(netdevice_t *dev, ...@@ -1062,11 +1065,12 @@ static int p80211wext_siwretry(netdevice_t *dev,
msg.msgcode = DIDmsg_dot11req_mibset; msg.msgcode = DIDmsg_dot11req_mibset;
if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime; mibitem.did =
mibitem.data = rrq->value /= 1024; DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime;
mibitem.data = rrq->value /= 1024;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -1074,11 +1078,13 @@ static int p80211wext_siwretry(netdevice_t *dev, ...@@ -1074,11 +1078,13 @@ static int p80211wext_siwretry(netdevice_t *dev,
} }
} else { } else {
if (rrq->flags & IW_RETRY_LONG) { if (rrq->flags & IW_RETRY_LONG) {
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit; mibitem.did =
DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit;
mibitem.data = rrq->value; mibitem.data = rrq->value;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem,
result = p80211req_dorequest(wlandev, (u8*)&msg); sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -1087,11 +1093,13 @@ static int p80211wext_siwretry(netdevice_t *dev, ...@@ -1087,11 +1093,13 @@ static int p80211wext_siwretry(netdevice_t *dev,
} }
if (rrq->flags & IW_RETRY_SHORT) { if (rrq->flags & IW_RETRY_SHORT) {
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit; mibitem.did =
DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit;
mibitem.data = rrq->value; mibitem.data = rrq->value;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem,
result = p80211req_dorequest(wlandev, (u8*)&msg); sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -1100,42 +1108,43 @@ static int p80211wext_siwretry(netdevice_t *dev, ...@@ -1100,42 +1108,43 @@ static int p80211wext_siwretry(netdevice_t *dev,
} }
} }
exit: exit:
return err; return err;
} }
static int p80211wext_siwtxpow(netdevice_t *dev, static int p80211wext_siwtxpow(netdevice_t *dev,
struct iw_request_info *info, struct iw_request_info *info,
struct iw_param *rrq, char *extra) struct iw_param *rrq, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
int result; int result;
int err = 0; int err = 0;
if (!wlan_wext_write) { if (!wlan_wext_write) {
err = (-EOPNOTSUPP); err = (-EOPNOTSUPP);
goto exit; goto exit;
} }
msg.msgcode = DIDmsg_dot11req_mibset; msg.msgcode = DIDmsg_dot11req_mibset;
mibitem.did = DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel; mibitem.did =
DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel;
if (rrq->fixed == 0) if (rrq->fixed == 0)
mibitem.data = 30; mibitem.data = 30;
else else
mibitem.data = rrq->value; mibitem.data = rrq->value;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
goto exit; goto exit;
} }
exit: exit:
return err; return err;
} }
static int p80211wext_giwtxpow(netdevice_t *dev, static int p80211wext_giwtxpow(netdevice_t *dev,
...@@ -1143,16 +1152,17 @@ static int p80211wext_giwtxpow(netdevice_t *dev, ...@@ -1143,16 +1152,17 @@ static int p80211wext_giwtxpow(netdevice_t *dev,
struct iw_param *rrq, char *extra) struct iw_param *rrq, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem; p80211item_uint32_t mibitem;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
int result; int result;
int err = 0; int err = 0;
msg.msgcode = DIDmsg_dot11req_mibget; msg.msgcode = DIDmsg_dot11req_mibget;
mibitem.did = DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel; mibitem.did =
DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel;
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) { if (result) {
err = -EFAULT; err = -EFAULT;
...@@ -1161,14 +1171,14 @@ static int p80211wext_giwtxpow(netdevice_t *dev, ...@@ -1161,14 +1171,14 @@ static int p80211wext_giwtxpow(netdevice_t *dev,
memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem));
// XXX handle OFF by setting disabled = 1; /* XXX handle OFF by setting disabled = 1; */
rrq->flags = 0; // IW_TXPOW_DBM; rrq->flags = 0; /* IW_TXPOW_DBM; */
rrq->disabled = 0; rrq->disabled = 0;
rrq->fixed = 0; rrq->fixed = 0;
rrq->value = mibitem.data; rrq->value = mibitem.data;
exit: exit:
return err; return err;
} }
...@@ -1177,30 +1187,31 @@ static int p80211wext_siwspy(netdevice_t *dev, ...@@ -1177,30 +1187,31 @@ static int p80211wext_siwspy(netdevice_t *dev,
struct iw_point *srq, char *extra) struct iw_point *srq, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
struct sockaddr address[IW_MAX_SPY]; struct sockaddr address[IW_MAX_SPY];
int number = srq->length; int number = srq->length;
int i; int i;
/* Copy the data from the input buffer */ /* Copy the data from the input buffer */
memcpy(address, extra, sizeof(struct sockaddr)*number); memcpy(address, extra, sizeof(struct sockaddr) * number);
wlandev->spy_number = 0; wlandev->spy_number = 0;
if (number > 0) { if (number > 0) {
/* extract the addresses */ /* extract the addresses */
for (i = 0; i < number; i++) { for (i = 0; i < number; i++) {
memcpy(wlandev->spy_address[i], address[i].sa_data, ETH_ALEN); memcpy(wlandev->spy_address[i], address[i].sa_data,
ETH_ALEN);
} }
/* reset stats */ /* reset stats */
memset(wlandev->spy_stat, 0, sizeof(struct iw_quality) * IW_MAX_SPY); memset(wlandev->spy_stat, 0,
sizeof(struct iw_quality) * IW_MAX_SPY);
/* set number of addresses */ /* set number of addresses */
wlandev->spy_number = number; wlandev->spy_number = number;
} }
return 0; return 0;
} }
...@@ -1212,63 +1223,66 @@ static int p80211wext_giwspy(netdevice_t *dev, ...@@ -1212,63 +1223,66 @@ static int p80211wext_giwspy(netdevice_t *dev,
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
struct sockaddr address[IW_MAX_SPY]; struct sockaddr address[IW_MAX_SPY];
struct iw_quality spy_stat[IW_MAX_SPY]; struct iw_quality spy_stat[IW_MAX_SPY];
int number; int number;
int i; int i;
number = wlandev->spy_number; number = wlandev->spy_number;
if (number > 0) { if (number > 0) {
/* populate address and spy struct's */ /* populate address and spy struct's */
for (i = 0; i < number; i++) { for (i = 0; i < number; i++) {
memcpy(address[i].sa_data, wlandev->spy_address[i], ETH_ALEN); memcpy(address[i].sa_data, wlandev->spy_address[i],
address[i].sa_family = AF_UNIX; ETH_ALEN);
memcpy(&spy_stat[i], &wlandev->spy_stat[i], sizeof(struct iw_quality)); address[i].sa_family = AF_UNIX;
} memcpy(&spy_stat[i], &wlandev->spy_stat[i],
sizeof(struct iw_quality));
}
/* reset update flag */ /* reset update flag */
for (i=0; i < number; i++) for (i = 0; i < number; i++)
wlandev->spy_stat[i].updated = 0; wlandev->spy_stat[i].updated = 0;
} }
/* push stuff to user space */ /* push stuff to user space */
srq->length = number; srq->length = number;
memcpy(extra, address, sizeof(struct sockaddr)*number); memcpy(extra, address, sizeof(struct sockaddr) * number);
memcpy(extra+sizeof(struct sockaddr)*number, spy_stat, sizeof(struct iw_quality)*number); memcpy(extra + sizeof(struct sockaddr) * number, spy_stat,
sizeof(struct iw_quality) * number);
return 0; return 0;
} }
static int prism2_result2err (int prism2_result) static int prism2_result2err(int prism2_result)
{ {
int err = 0; int err = 0;
switch (prism2_result) { switch (prism2_result) {
case P80211ENUM_resultcode_invalid_parameters: case P80211ENUM_resultcode_invalid_parameters:
err = -EINVAL; err = -EINVAL;
break; break;
case P80211ENUM_resultcode_implementation_failure: case P80211ENUM_resultcode_implementation_failure:
err = -EIO; err = -EIO;
break; break;
case P80211ENUM_resultcode_not_supported: case P80211ENUM_resultcode_not_supported:
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
break; break;
default: default:
err = 0; err = 0;
break; break;
} }
return err; return err;
} }
static int p80211wext_siwscan(netdevice_t *dev, static int p80211wext_siwscan(netdevice_t *dev,
struct iw_request_info *info, struct iw_request_info *info,
struct iw_point *srq, char *extra) struct iw_point *srq, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211msg_dot11req_scan_t msg; p80211msg_dot11req_scan_t msg;
int result; int result;
int err = 0; int err = 0;
int i = 0; int i = 0;
...@@ -1283,35 +1297,34 @@ static int p80211wext_siwscan(netdevice_t *dev, ...@@ -1283,35 +1297,34 @@ static int p80211wext_siwscan(netdevice_t *dev,
msg.msgcode = DIDmsg_dot11req_scan; msg.msgcode = DIDmsg_dot11req_scan;
msg.bsstype.data = P80211ENUM_bsstype_any; msg.bsstype.data = P80211ENUM_bsstype_any;
memset(&(msg.bssid.data), 0xFF, sizeof (p80211item_pstr6_t)); memset(&(msg.bssid.data), 0xFF, sizeof(p80211item_pstr6_t));
msg.bssid.data.len = 6; msg.bssid.data.len = 6;
msg.scantype.data = P80211ENUM_scantype_active; msg.scantype.data = P80211ENUM_scantype_active;
msg.probedelay.data = 0; msg.probedelay.data = 0;
for (i = 1; i <= 14; i++) for (i = 1; i <= 14; i++)
msg.channellist.data.data[i-1] = i; msg.channellist.data.data[i - 1] = i;
msg.channellist.data.len = 14; msg.channellist.data.len = 14;
msg.maxchanneltime.data = 250; msg.maxchanneltime.data = 250;
msg.minchanneltime.data = 200; msg.minchanneltime.data = 200;
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if (result) if (result)
err = prism2_result2err (msg.resultcode.data); err = prism2_result2err(msg.resultcode.data);
exit: exit:
return err; return err;
} }
/* Helper to translate scan into Wireless Extensions scan results. /* Helper to translate scan into Wireless Extensions scan results.
* Inspired by the prism54 code, which was in turn inspired by the * Inspired by the prism54 code, which was in turn inspired by the
* airo driver code. * airo driver code.
*/ */
static char * static char *wext_translate_bss(struct iw_request_info *info, char *current_ev,
wext_translate_bss(struct iw_request_info *info, char *current_ev, char *end_buf,
char *end_buf, p80211msg_dot11req_scan_results_t *bss) p80211msg_dot11req_scan_results_t *bss)
{ {
struct iw_event iwe; /* Temporary buffer */ struct iw_event iwe; /* Temporary buffer */
...@@ -1319,7 +1332,9 @@ wext_translate_bss(struct iw_request_info *info, char *current_ev, ...@@ -1319,7 +1332,9 @@ wext_translate_bss(struct iw_request_info *info, char *current_ev,
memcpy(iwe.u.ap_addr.sa_data, bss->bssid.data.data, WLAN_BSSID_LEN); memcpy(iwe.u.ap_addr.sa_data, bss->bssid.data.data, WLAN_BSSID_LEN);
iwe.u.ap_addr.sa_family = ARPHRD_ETHER; iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
iwe.cmd = SIOCGIWAP; iwe.cmd = SIOCGIWAP;
current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN); current_ev =
iwe_stream_add_event(info, current_ev, end_buf, &iwe,
IW_EV_ADDR_LEN);
/* The following entries will be displayed in the same order we give them */ /* The following entries will be displayed in the same order we give them */
...@@ -1328,33 +1343,39 @@ wext_translate_bss(struct iw_request_info *info, char *current_ev, ...@@ -1328,33 +1343,39 @@ wext_translate_bss(struct iw_request_info *info, char *current_ev,
char essid[IW_ESSID_MAX_SIZE + 1]; char essid[IW_ESSID_MAX_SIZE + 1];
int size; int size;
size = min_t(unsigned short, IW_ESSID_MAX_SIZE, bss->ssid.data.len); size =
memset(&essid, 0, sizeof (essid)); min_t(unsigned short, IW_ESSID_MAX_SIZE,
bss->ssid.data.len);
memset(&essid, 0, sizeof(essid));
memcpy(&essid, bss->ssid.data.data, size); memcpy(&essid, bss->ssid.data.data, size);
pr_debug(" essid size = %d\n", size); pr_debug(" essid size = %d\n", size);
iwe.u.data.length = size; iwe.u.data.length = size;
iwe.u.data.flags = 1; iwe.u.data.flags = 1;
iwe.cmd = SIOCGIWESSID; iwe.cmd = SIOCGIWESSID;
current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, &essid[0]); current_ev =
iwe_stream_add_point(info, current_ev, end_buf, &iwe,
&essid[0]);
pr_debug(" essid size OK.\n"); pr_debug(" essid size OK.\n");
} }
switch (bss->bsstype.data) { switch (bss->bsstype.data) {
case P80211ENUM_bsstype_infrastructure: case P80211ENUM_bsstype_infrastructure:
iwe.u.mode = IW_MODE_MASTER; iwe.u.mode = IW_MODE_MASTER;
break; break;
case P80211ENUM_bsstype_independent: case P80211ENUM_bsstype_independent:
iwe.u.mode = IW_MODE_ADHOC; iwe.u.mode = IW_MODE_ADHOC;
break; break;
default: default:
iwe.u.mode = 0; iwe.u.mode = 0;
break; break;
} }
iwe.cmd = SIOCGIWMODE; iwe.cmd = SIOCGIWMODE;
if (iwe.u.mode) if (iwe.u.mode)
current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN); current_ev =
iwe_stream_add_event(info, current_ev, end_buf, &iwe,
IW_EV_UINT_LEN);
/* Encryption capability */ /* Encryption capability */
if (bss->privacy.data == P80211ENUM_truth_true) if (bss->privacy.data == P80211ENUM_truth_true)
...@@ -1363,13 +1384,16 @@ wext_translate_bss(struct iw_request_info *info, char *current_ev, ...@@ -1363,13 +1384,16 @@ wext_translate_bss(struct iw_request_info *info, char *current_ev,
iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.flags = IW_ENCODE_DISABLED;
iwe.u.data.length = 0; iwe.u.data.length = 0;
iwe.cmd = SIOCGIWENCODE; iwe.cmd = SIOCGIWENCODE;
current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, NULL); current_ev =
iwe_stream_add_point(info, current_ev, end_buf, &iwe, NULL);
/* Add frequency. (short) bss->channel is the frequency in MHz */ /* Add frequency. (short) bss->channel is the frequency in MHz */
iwe.u.freq.m = bss->dschannel.data; iwe.u.freq.m = bss->dschannel.data;
iwe.u.freq.e = 0; iwe.u.freq.e = 0;
iwe.cmd = SIOCGIWFREQ; iwe.cmd = SIOCGIWFREQ;
current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); current_ev =
iwe_stream_add_event(info, current_ev, end_buf, &iwe,
IW_EV_FREQ_LEN);
/* Add quality statistics */ /* Add quality statistics */
iwe.u.qual.level = bss->signal.data; iwe.u.qual.level = bss->signal.data;
...@@ -1377,18 +1401,19 @@ wext_translate_bss(struct iw_request_info *info, char *current_ev, ...@@ -1377,18 +1401,19 @@ wext_translate_bss(struct iw_request_info *info, char *current_ev,
/* do a simple SNR for quality */ /* do a simple SNR for quality */
iwe.u.qual.qual = qual_as_percent(bss->signal.data - bss->noise.data); iwe.u.qual.qual = qual_as_percent(bss->signal.data - bss->noise.data);
iwe.cmd = IWEVQUAL; iwe.cmd = IWEVQUAL;
current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); current_ev =
iwe_stream_add_event(info, current_ev, end_buf, &iwe,
IW_EV_QUAL_LEN);
return current_ev; return current_ev;
} }
static int p80211wext_giwscan(netdevice_t *dev, static int p80211wext_giwscan(netdevice_t *dev,
struct iw_request_info *info, struct iw_request_info *info,
struct iw_point *srq, char *extra) struct iw_point *srq, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
p80211msg_dot11req_scan_results_t msg; p80211msg_dot11req_scan_results_t msg;
int result = 0; int result = 0;
int err = 0; int err = 0;
int i = 0; int i = 0;
...@@ -1404,109 +1429,115 @@ static int p80211wext_giwscan(netdevice_t *dev, ...@@ -1404,109 +1429,115 @@ static int p80211wext_giwscan(netdevice_t *dev,
msg.msgcode = DIDmsg_dot11req_scan_results; msg.msgcode = DIDmsg_dot11req_scan_results;
msg.bssindex.data = i; msg.bssindex.data = i;
result = p80211req_dorequest(wlandev, (u8*)&msg); result = p80211req_dorequest(wlandev, (u8 *)&msg);
if ((result != 0) || if ((result != 0) ||
(msg.resultcode.data != P80211ENUM_resultcode_success)) { (msg.resultcode.data != P80211ENUM_resultcode_success)) {
break; break;
} }
current_ev = wext_translate_bss(info, current_ev, extra + IW_SCAN_MAX_DATA, &msg); current_ev =
wext_translate_bss(info, current_ev,
extra + IW_SCAN_MAX_DATA, &msg);
scan_good = 1; scan_good = 1;
i++; i++;
} while (i < IW_MAX_AP); } while (i < IW_MAX_AP);
srq->length = (current_ev - extra); srq->length = (current_ev - extra);
srq->flags = 0; /* todo */ srq->flags = 0; /* todo */
if (result && !scan_good) if (result && !scan_good)
err = prism2_result2err (msg.resultcode.data); err = prism2_result2err(msg.resultcode.data);
return err; return err;
} }
/*****************************************************/ /* extra wireless extensions stuff to support NetworkManager (I hope) */
//extra wireless extensions stuff to support NetworkManager (I hope)
/* SIOCSIWENCODEEXT */ /* SIOCSIWENCODEEXT */
static int p80211wext_set_encodeext(struct net_device *dev, static int p80211wext_set_encodeext(struct net_device *dev,
struct iw_request_info *info, struct iw_request_info *info,
union iwreq_data *wrqu, char *extra) union iwreq_data *wrqu, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
p80211msg_dot11req_mibset_t msg; p80211msg_dot11req_mibset_t msg;
p80211item_pstr32_t *pstr; p80211item_pstr32_t *pstr;
int result = 0; int result = 0;
struct iw_point *encoding = &wrqu->encoding; struct iw_point *encoding = &wrqu->encoding;
int idx = encoding->flags & IW_ENCODE_INDEX; int idx = encoding->flags & IW_ENCODE_INDEX;
pr_debug("set_encode_ext flags[%d] alg[%d] keylen[%d]\n",ext->ext_flags,(int)ext->alg,(int)ext->key_len); pr_debug("set_encode_ext flags[%d] alg[%d] keylen[%d]\n",
ext->ext_flags, (int)ext->alg, (int)ext->key_len);
if ( ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY ) { if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
// set default key ? I'm not sure if this the the correct thing to do here /* set default key ? I'm not sure if this the the correct thing to do here */
if ( idx ) { if (idx) {
if (idx < 1 || idx > NUM_WEPKEYS) { if (idx < 1 || idx > NUM_WEPKEYS)
return -EINVAL; return -EINVAL;
} else else
idx--; idx--;
} }
pr_debug("setting default key (%d)\n",idx); pr_debug("setting default key (%d)\n", idx);
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, idx); result =
if ( result ) p80211wext_dorequest(wlandev,
return -EFAULT; DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
} idx);
if (result)
return -EFAULT;
if ( ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY ) { }
if (!(ext->alg & IW_ENCODE_ALG_WEP)) {
pr_debug("asked to set a non wep key :("); if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
return -EINVAL; if (!(ext->alg & IW_ENCODE_ALG_WEP)) {
} pr_debug("asked to set a non wep key :(");
if (idx) { return -EINVAL;
if (idx <1 || idx > NUM_WEPKEYS) }
return -EINVAL; if (idx) {
else if (idx < 1 || idx > NUM_WEPKEYS)
idx--; return -EINVAL;
} else
pr_debug("Set WEP key (%d)\n",idx); idx--;
wlandev->wep_keylens[idx] = ext->key_len; }
memcpy(wlandev->wep_keys[idx], ext->key, ext->key_len); pr_debug("Set WEP key (%d)\n", idx);
wlandev->wep_keylens[idx] = ext->key_len;
memset( &msg,0,sizeof(msg)); memcpy(wlandev->wep_keys[idx], ext->key, ext->key_len);
pstr = (p80211item_pstr32_t*)&msg.mibattribute.data;
memcpy(pstr->data.data, ext->key,ext->key_len); memset(&msg, 0, sizeof(msg));
pstr->data.len = ext->key_len; pstr = (p80211item_pstr32_t *)&msg.mibattribute.data;
switch (idx) { memcpy(pstr->data.data, ext->key, ext->key_len);
case 0: pstr->data.len = ext->key_len;
pstr->did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0; switch (idx) {
break; case 0:
case 1: pstr->did =
pstr->did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1; DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
break; break;
case 2: case 1:
pstr->did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2; pstr->did =
break; DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
case 3: break;
pstr->did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3; case 2:
break; pstr->did =
default: DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
break; break;
} case 3:
msg.msgcode = DIDmsg_dot11req_mibset; pstr->did =
result = p80211req_dorequest(wlandev,(u8*)&msg); DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
pr_debug("result (%d)\n",result); break;
} default:
return result; break;
}
msg.msgcode = DIDmsg_dot11req_mibset;
result = p80211req_dorequest(wlandev, (u8 *)&msg);
pr_debug("result (%d)\n", result);
}
return result;
} }
/* SIOCGIWENCODEEXT */ /* SIOCGIWENCODEEXT */
static int p80211wext_get_encodeext(struct net_device *dev, static int p80211wext_get_encodeext(struct net_device *dev,
struct iw_request_info *info, struct iw_request_info *info,
union iwreq_data *wrqu, char *extra) union iwreq_data *wrqu, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
...@@ -1516,22 +1547,24 @@ static int p80211wext_get_encodeext(struct net_device *dev, ...@@ -1516,22 +1547,24 @@ static int p80211wext_get_encodeext(struct net_device *dev,
int max_len; int max_len;
int idx; int idx;
pr_debug("get_encode_ext flags[%d] alg[%d] keylen[%d]\n",ext->ext_flags,(int)ext->alg,(int)ext->key_len); pr_debug("get_encode_ext flags[%d] alg[%d] keylen[%d]\n",
ext->ext_flags, (int)ext->alg, (int)ext->key_len);
max_len = encoding->length - sizeof(*ext); max_len = encoding->length - sizeof(*ext);
if ( max_len <= 0) { if (max_len <= 0) {
pr_debug("get_encodeext max_len [%d] invalid\n",max_len); pr_debug("get_encodeext max_len [%d] invalid\n",
max_len);
result = -EINVAL; result = -EINVAL;
goto exit; goto exit;
} }
idx = encoding->flags & IW_ENCODE_INDEX; idx = encoding->flags & IW_ENCODE_INDEX;
pr_debug("get_encode_ext index [%d]\n",idx); pr_debug("get_encode_ext index [%d]\n", idx);
if (idx) { if (idx) {
if (idx < 1 || idx > NUM_WEPKEYS ) { if (idx < 1 || idx > NUM_WEPKEYS) {
pr_debug("get_encode_ext invalid key index [%d]\n",idx); printk(KERN_DEBUG
"get_encode_ext invalid key index [%d]\n", idx);
result = -EINVAL; result = -EINVAL;
goto exit; goto exit;
} }
...@@ -1542,198 +1575,207 @@ static int p80211wext_get_encodeext(struct net_device *dev, ...@@ -1542,198 +1575,207 @@ static int p80211wext_get_encodeext(struct net_device *dev,
} }
encoding->flags = idx + 1; encoding->flags = idx + 1;
memset(ext,0,sizeof(*ext)); memset(ext, 0, sizeof(*ext));
ext->alg = IW_ENCODE_ALG_WEP; ext->alg = IW_ENCODE_ALG_WEP;
ext->key_len = wlandev->wep_keylens[idx]; ext->key_len = wlandev->wep_keylens[idx];
memcpy( ext->key, wlandev->wep_keys[idx] , ext->key_len ); memcpy(ext->key, wlandev->wep_keys[idx], ext->key_len);
encoding->flags |= IW_ENCODE_ENABLED; encoding->flags |= IW_ENCODE_ENABLED;
exit: exit:
return result; return result;
} }
/* SIOCSIWAUTH */ /* SIOCSIWAUTH */
static int p80211_wext_set_iwauth (struct net_device *dev, static int p80211_wext_set_iwauth(struct net_device *dev,
struct iw_request_info *info, struct iw_request_info *info,
union iwreq_data *wrqu, char *extra) union iwreq_data *wrqu, char *extra)
{ {
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
struct iw_param *param = &wrqu->param; struct iw_param *param = &wrqu->param;
int result =0; int result = 0;
pr_debug("set_iwauth flags[%d]\n",(int)param->flags & IW_AUTH_INDEX );
switch (param->flags & IW_AUTH_INDEX) {
case IW_AUTH_DROP_UNENCRYPTED:
pr_debug("drop_unencrypted %d\n",param->value);
if (param->value)
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_true);
else
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_false);
break;
case IW_AUTH_PRIVACY_INVOKED:
pr_debug("privacy invoked %d\n",param->value);
if ( param->value)
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_true);
else
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_false);
break;
case IW_AUTH_80211_AUTH_ALG:
if ( param->value & IW_AUTH_ALG_OPEN_SYSTEM ) {
pr_debug("set open_system\n");
wlandev->hostwep &= ~HOSTWEP_SHAREDKEY;
} else if ( param->value & IW_AUTH_ALG_SHARED_KEY) {
pr_debug("set shared key\n");
wlandev->hostwep |= HOSTWEP_SHAREDKEY;
} else {
/* don't know what to do know :( */
pr_debug("unknown AUTH_ALG (%d)\n",param->value);
result = -EINVAL;
}
break;
default:
break;
}
return result;
}
/* SIOCSIWAUTH */ pr_debug("set_iwauth flags[%d]\n",
static int p80211_wext_get_iwauth (struct net_device *dev, (int)param->flags & IW_AUTH_INDEX);
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra) switch (param->flags & IW_AUTH_INDEX) {
{ case IW_AUTH_DROP_UNENCRYPTED:
wlandevice_t *wlandev = dev->ml_priv; pr_debug("drop_unencrypted %d\n", param->value);
struct iw_param *param = &wrqu->param; if (param->value)
int result =0; result =
p80211wext_dorequest(wlandev,
DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
P80211ENUM_truth_true);
else
result =
p80211wext_dorequest(wlandev,
DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
P80211ENUM_truth_false);
break;
pr_debug("get_iwauth flags[%d]\n",(int)param->flags & IW_AUTH_INDEX ); case IW_AUTH_PRIVACY_INVOKED:
pr_debug("privacy invoked %d\n", param->value);
if (param->value)
result =
p80211wext_dorequest(wlandev,
DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
P80211ENUM_truth_true);
else
result =
p80211wext_dorequest(wlandev,
DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
P80211ENUM_truth_false);
break;
case IW_AUTH_80211_AUTH_ALG:
if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
pr_debug("set open_system\n");
wlandev->hostwep &= ~HOSTWEP_SHAREDKEY;
} else if (param->value & IW_AUTH_ALG_SHARED_KEY) {
pr_debug("set shared key\n");
wlandev->hostwep |= HOSTWEP_SHAREDKEY;
} else {
/* don't know what to do know */
pr_debug("unknown AUTH_ALG (%d)\n",
param->value);
result = -EINVAL;
}
break;
default:
break;
}
switch (param->flags & IW_AUTH_INDEX) { return result;
case IW_AUTH_DROP_UNENCRYPTED: }
param->value = wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED?1:0;
break;
case IW_AUTH_PRIVACY_INVOKED: /* SIOCSIWAUTH */
param->value = wlandev->hostwep & HOSTWEP_PRIVACYINVOKED?1:0; static int p80211_wext_get_iwauth(struct net_device *dev,
break; struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
wlandevice_t *wlandev = dev->ml_priv;
struct iw_param *param = &wrqu->param;
int result = 0;
case IW_AUTH_80211_AUTH_ALG: pr_debug("get_iwauth flags[%d]\n",
param->value = wlandev->hostwep & HOSTWEP_SHAREDKEY?IW_AUTH_ALG_SHARED_KEY:IW_AUTH_ALG_OPEN_SYSTEM; (int)param->flags & IW_AUTH_INDEX);
break;
switch (param->flags & IW_AUTH_INDEX) {
case IW_AUTH_DROP_UNENCRYPTED:
param->value =
wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED ? 1 : 0;
break;
default: case IW_AUTH_PRIVACY_INVOKED:
break; param->value =
} wlandev->hostwep & HOSTWEP_PRIVACYINVOKED ? 1 : 0;
break;
case IW_AUTH_80211_AUTH_ALG:
param->value =
wlandev->
hostwep & HOSTWEP_SHAREDKEY ? IW_AUTH_ALG_SHARED_KEY :
IW_AUTH_ALG_OPEN_SYSTEM;
break;
default:
break;
}
return result; return result;
} }
static iw_handler p80211wext_handlers[] = { static iw_handler p80211wext_handlers[] = {
(iw_handler) p80211wext_siwcommit, /* SIOCSIWCOMMIT */ (iw_handler) p80211wext_siwcommit, /* SIOCSIWCOMMIT */
(iw_handler) p80211wext_giwname, /* SIOCGIWNAME */ (iw_handler) p80211wext_giwname, /* SIOCGIWNAME */
(iw_handler) NULL, /* SIOCSIWNWID */ (iw_handler) NULL, /* SIOCSIWNWID */
(iw_handler) NULL, /* SIOCGIWNWID */ (iw_handler) NULL, /* SIOCGIWNWID */
(iw_handler) p80211wext_siwfreq, /* SIOCSIWFREQ */ (iw_handler) p80211wext_siwfreq, /* SIOCSIWFREQ */
(iw_handler) p80211wext_giwfreq, /* SIOCGIWFREQ */ (iw_handler) p80211wext_giwfreq, /* SIOCGIWFREQ */
(iw_handler) p80211wext_siwmode, /* SIOCSIWMODE */ (iw_handler) p80211wext_siwmode, /* SIOCSIWMODE */
(iw_handler) p80211wext_giwmode, /* SIOCGIWMODE */ (iw_handler) p80211wext_giwmode, /* SIOCGIWMODE */
(iw_handler) NULL, /* SIOCSIWSENS */ (iw_handler) NULL, /* SIOCSIWSENS */
(iw_handler) NULL, /* SIOCGIWSENS */ (iw_handler) NULL, /* SIOCGIWSENS */
(iw_handler) NULL, /* not used */ /* SIOCSIWRANGE */ (iw_handler) NULL, /* not used *//* SIOCSIWRANGE */
(iw_handler) p80211wext_giwrange, /* SIOCGIWRANGE */ (iw_handler) p80211wext_giwrange, /* SIOCGIWRANGE */
(iw_handler) NULL, /* not used */ /* SIOCSIWPRIV */ (iw_handler) NULL, /* not used *//* SIOCSIWPRIV */
(iw_handler) NULL, /* kernel code */ /* SIOCGIWPRIV */ (iw_handler) NULL, /* kernel code *//* SIOCGIWPRIV */
(iw_handler) NULL, /* not used */ /* SIOCSIWSTATS */ (iw_handler) NULL, /* not used *//* SIOCSIWSTATS */
(iw_handler) NULL, /* kernel code */ /* SIOCGIWSTATS */ (iw_handler) NULL, /* kernel code *//* SIOCGIWSTATS */
(iw_handler) p80211wext_siwspy, /* SIOCSIWSPY */ (iw_handler) p80211wext_siwspy, /* SIOCSIWSPY */
(iw_handler) p80211wext_giwspy, /* SIOCGIWSPY */ (iw_handler) p80211wext_giwspy, /* SIOCGIWSPY */
(iw_handler) NULL, /* -- hole -- */ (iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* -- hole -- */ (iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* SIOCSIWAP */ (iw_handler) NULL, /* SIOCSIWAP */
(iw_handler) p80211wext_giwap, /* SIOCGIWAP */ (iw_handler) p80211wext_giwap, /* SIOCGIWAP */
(iw_handler) NULL, /* -- hole -- */ (iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* SIOCGIWAPLIST */ (iw_handler) NULL, /* SIOCGIWAPLIST */
(iw_handler) p80211wext_siwscan, /* SIOCSIWSCAN */ (iw_handler) p80211wext_siwscan, /* SIOCSIWSCAN */
(iw_handler) p80211wext_giwscan, /* SIOCGIWSCAN */ (iw_handler) p80211wext_giwscan, /* SIOCGIWSCAN */
(iw_handler) p80211wext_siwessid, /* SIOCSIWESSID */ (iw_handler) p80211wext_siwessid, /* SIOCSIWESSID */
(iw_handler) p80211wext_giwessid, /* SIOCGIWESSID */ (iw_handler) p80211wext_giwessid, /* SIOCGIWESSID */
(iw_handler) NULL, /* SIOCSIWNICKN */ (iw_handler) NULL, /* SIOCSIWNICKN */
(iw_handler) p80211wext_giwessid, /* SIOCGIWNICKN */ (iw_handler) p80211wext_giwessid, /* SIOCGIWNICKN */
(iw_handler) NULL, /* -- hole -- */ (iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* -- hole -- */ (iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* SIOCSIWRATE */ (iw_handler) NULL, /* SIOCSIWRATE */
(iw_handler) p80211wext_giwrate, /* SIOCGIWRATE */ (iw_handler) p80211wext_giwrate, /* SIOCGIWRATE */
(iw_handler) p80211wext_siwrts, /* SIOCSIWRTS */ (iw_handler) p80211wext_siwrts, /* SIOCSIWRTS */
(iw_handler) p80211wext_giwrts, /* SIOCGIWRTS */ (iw_handler) p80211wext_giwrts, /* SIOCGIWRTS */
(iw_handler) p80211wext_siwfrag, /* SIOCSIWFRAG */ (iw_handler) p80211wext_siwfrag, /* SIOCSIWFRAG */
(iw_handler) p80211wext_giwfrag, /* SIOCGIWFRAG */ (iw_handler) p80211wext_giwfrag, /* SIOCGIWFRAG */
(iw_handler) p80211wext_siwtxpow, /* SIOCSIWTXPOW */ (iw_handler) p80211wext_siwtxpow, /* SIOCSIWTXPOW */
(iw_handler) p80211wext_giwtxpow, /* SIOCGIWTXPOW */ (iw_handler) p80211wext_giwtxpow, /* SIOCGIWTXPOW */
(iw_handler) p80211wext_siwretry, /* SIOCSIWRETRY */ (iw_handler) p80211wext_siwretry, /* SIOCSIWRETRY */
(iw_handler) p80211wext_giwretry, /* SIOCGIWRETRY */ (iw_handler) p80211wext_giwretry, /* SIOCGIWRETRY */
(iw_handler) p80211wext_siwencode, /* SIOCSIWENCODE */ (iw_handler) p80211wext_siwencode, /* SIOCSIWENCODE */
(iw_handler) p80211wext_giwencode, /* SIOCGIWENCODE */ (iw_handler) p80211wext_giwencode, /* SIOCGIWENCODE */
(iw_handler) NULL, /* SIOCSIWPOWER */ (iw_handler) NULL, /* SIOCSIWPOWER */
(iw_handler) NULL, /* SIOCGIWPOWER */ (iw_handler) NULL, /* SIOCGIWPOWER */
/* WPA operations */ /* WPA operations */
(iw_handler) NULL, /* -- hole -- */ (iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* -- hole -- */ (iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* SIOCSIWGENIE set generic IE */ (iw_handler) NULL, /* SIOCSIWGENIE set generic IE */
(iw_handler) NULL, /* SIOCGIWGENIE get generic IE */ (iw_handler) NULL, /* SIOCGIWGENIE get generic IE */
(iw_handler) p80211_wext_set_iwauth, /* SIOCSIWAUTH set authentication mode params */ (iw_handler) p80211_wext_set_iwauth, /* SIOCSIWAUTH set authentication mode params */
(iw_handler) p80211_wext_get_iwauth, /* SIOCGIWAUTH get authentication mode params */ (iw_handler) p80211_wext_get_iwauth, /* SIOCGIWAUTH get authentication mode params */
(iw_handler) p80211wext_set_encodeext, /* SIOCSIWENCODEEXT set encoding token & mode */ (iw_handler) p80211wext_set_encodeext, /* SIOCSIWENCODEEXT set encoding token & mode */
(iw_handler) p80211wext_get_encodeext, /* SIOCGIWENCODEEXT get encoding token & mode */ (iw_handler) p80211wext_get_encodeext, /* SIOCGIWENCODEEXT get encoding token & mode */
(iw_handler) NULL, /* SIOCSIWPMKSA PMKSA cache operation */ (iw_handler) NULL, /* SIOCSIWPMKSA PMKSA cache operation */
}; };
struct iw_handler_def p80211wext_handler_def = { struct iw_handler_def p80211wext_handler_def = {
.num_standard = ARRAY_SIZE(p80211wext_handlers), .num_standard = ARRAY_SIZE(p80211wext_handlers),
.num_private = 0, .num_private = 0,
.num_private_args = 0, .num_private_args = 0,
.standard = p80211wext_handlers, .standard = p80211wext_handlers,
.private = NULL, .private = NULL,
.private_args = NULL, .private_args = NULL,
.get_wireless_stats = p80211wext_get_wireless_stats .get_wireless_stats = p80211wext_get_wireless_stats
}; };
int p80211wext_event_associated(wlandevice_t *wlandev, int assoc) int p80211wext_event_associated(wlandevice_t *wlandev, int assoc)
{ {
union iwreq_data data; union iwreq_data data;
/* Send the association state first */ /* Send the association state first */
data.ap_addr.sa_family = ARPHRD_ETHER; data.ap_addr.sa_family = ARPHRD_ETHER;
if (assoc) { if (assoc)
memcpy(data.ap_addr.sa_data, wlandev->bssid, ETH_ALEN); memcpy(data.ap_addr.sa_data, wlandev->bssid, ETH_ALEN);
} else { else
memset(data.ap_addr.sa_data, 0, ETH_ALEN); memset(data.ap_addr.sa_data, 0, ETH_ALEN);
}
if (wlan_wext_write) if (wlan_wext_write)
wireless_send_event(wlandev->netdev, SIOCGIWAP, &data, NULL); wireless_send_event(wlandev->netdev, SIOCGIWAP, &data, NULL);
if (!assoc) goto done; if (!assoc)
goto done;
// XXX send association data, like IEs, etc etc. /* XXX send association data, like IEs, etc etc. */
done: done:
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment