mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 16:41:58 +00:00
Staging: wlan-ng: p80211wext.c: Coding style cleanups
Signed-off-by: Moritz Muehlenhoff <jmm@debian.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
e573aaa4fd
commit
c7d4bd7d29
@ -79,16 +79,14 @@ static int p80211wext_giwessid(netdevice_t *dev,
|
||||
|
||||
static u8 p80211_mhz_to_channel(u16 mhz)
|
||||
{
|
||||
if (mhz >= 5000) {
|
||||
return ((mhz - 5000) / 5);
|
||||
}
|
||||
if (mhz >= 5000)
|
||||
return (mhz - 5000) / 5;
|
||||
|
||||
if (mhz == 2482)
|
||||
return 14;
|
||||
|
||||
if (mhz >= 2407) {
|
||||
return ((mhz - 2407) / 5);
|
||||
}
|
||||
if (mhz >= 2407)
|
||||
return (mhz - 2407) / 5;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -102,19 +100,15 @@ static u16 p80211_channel_to_mhz(u8 ch, int dot11a)
|
||||
return 0;
|
||||
|
||||
/* 5G */
|
||||
|
||||
if (dot11a) {
|
||||
return (5000 + (5 * ch));
|
||||
}
|
||||
if (dot11a)
|
||||
return 5000 + (5 * ch);
|
||||
|
||||
/* 2.4G */
|
||||
|
||||
if (ch == 14)
|
||||
return 2484;
|
||||
|
||||
if ((ch < 14) && (ch > 0)) {
|
||||
return (2407 + (5 * ch));
|
||||
}
|
||||
if ((ch < 14) && (ch > 0))
|
||||
return 2407 + (5 * ch);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -124,15 +118,15 @@ static const long p80211wext_channel_freq[] = {
|
||||
2412, 2417, 2422, 2427, 2432, 2437, 2442,
|
||||
2447, 2452, 2457, 2462, 2467, 2472, 2484
|
||||
};
|
||||
|
||||
#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)
|
||||
|
||||
|
||||
/** function declarations =============== */
|
||||
|
||||
static int qual_as_percent(int snr ) {
|
||||
static int qual_as_percent(int snr)
|
||||
{
|
||||
if (snr <= 0)
|
||||
return 0;
|
||||
if (snr <= 40)
|
||||
@ -140,9 +134,6 @@ static int qual_as_percent(int snr ) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static int p80211wext_dorequest(wlandevice_t *wlandev, u32 did, u32 data)
|
||||
{
|
||||
p80211msg_dot11req_mibset_t msg;
|
||||
@ -184,9 +175,8 @@ static int p80211wext_autojoin(wlandevice_t *wlandev)
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
memcpy(msg.ssid.data.data, ssid, data.length);
|
||||
msg.ssid.data.len = data.length;
|
||||
@ -239,8 +229,8 @@ struct iw_statistics* p80211wext_get_wireless_stats (netdevice_t *dev)
|
||||
wstats->discard.nwid = 0;
|
||||
wstats->discard.misc = 0;
|
||||
|
||||
wstats->discard.fragment = 0; // incomplete fragments
|
||||
wstats->discard.retries = 0; // tx retries.
|
||||
wstats->discard.fragment = 0; /* incomplete fragments */
|
||||
wstats->discard.retries = 0; /* tx retries. */
|
||||
wstats->miss.beacon = 0;
|
||||
|
||||
return wstats;
|
||||
@ -425,7 +415,6 @@ static int p80211wext_siwmode(netdevice_t *dev,
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
static int p80211wext_giwrange(netdevice_t *dev,
|
||||
struct iw_request_info *info,
|
||||
struct iw_point *data, char *extra)
|
||||
@ -433,12 +422,12 @@ static int p80211wext_giwrange(netdevice_t *dev,
|
||||
struct iw_range *range = (struct iw_range *)extra;
|
||||
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);
|
||||
memset(range, 0, sizeof(*range));
|
||||
|
||||
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_source = 13;
|
||||
@ -448,10 +437,10 @@ static int p80211wext_giwrange(netdevice_t *dev,
|
||||
range->min_retry = 0;
|
||||
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(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) |
|
||||
IW_EVENT_CAPA_MASK(IWEVCUSTOM));
|
||||
|
||||
@ -473,7 +462,7 @@ static int p80211wext_giwrange(netdevice_t *dev,
|
||||
range->max_qual.level = 0;
|
||||
range->max_qual.noise = 0;
|
||||
range->sensitivity = 3;
|
||||
// XXX these need to be nsd-specific!
|
||||
/* XXX these need to be nsd-specific! */
|
||||
|
||||
range->min_rts = 0;
|
||||
range->max_rts = 2347;
|
||||
@ -485,11 +474,11 @@ static int p80211wext_giwrange(netdevice_t *dev,
|
||||
range->encoding_size[0] = 5;
|
||||
range->encoding_size[1] = 13;
|
||||
|
||||
// XXX what about num_bitrates/throughput?
|
||||
/* XXX what about num_bitrates/throughput? */
|
||||
range->num_bitrates = 0;
|
||||
|
||||
/* 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;
|
||||
|
||||
return 0;
|
||||
@ -572,13 +561,15 @@ static int p80211wext_siwencode(netdevice_t *dev,
|
||||
if ((i < 1) || (i > NUM_WEPKEYS)) {
|
||||
err = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
} else
|
||||
i--;
|
||||
|
||||
/* Set current key number only if no keys are given */
|
||||
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) {
|
||||
err = -EFAULT;
|
||||
@ -587,7 +578,7 @@ static int p80211wext_siwencode(netdevice_t *dev,
|
||||
}
|
||||
|
||||
} else {
|
||||
// Use defaultkey if no Key Index
|
||||
/* Use defaultkey if no Key Index */
|
||||
i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK;
|
||||
}
|
||||
|
||||
@ -609,22 +600,25 @@ static int p80211wext_siwencode(netdevice_t *dev,
|
||||
memcpy(pstr.data.data, key, erq->length);
|
||||
pstr.data.len = erq->length;
|
||||
|
||||
switch(i)
|
||||
{
|
||||
switch (i) {
|
||||
case 0:
|
||||
pstr.did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
|
||||
pstr.did =
|
||||
DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
pstr.did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
|
||||
pstr.did =
|
||||
DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
pstr.did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
|
||||
pstr.did =
|
||||
DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
pstr.did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
|
||||
pstr.did =
|
||||
DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -646,9 +640,15 @@ static int p80211wext_siwencode(netdevice_t *dev,
|
||||
|
||||
/* Check the PrivacyInvoked flag */
|
||||
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 {
|
||||
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_true);
|
||||
result =
|
||||
p80211wext_dorequest(wlandev,
|
||||
DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
|
||||
P80211ENUM_truth_true);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
@ -664,10 +664,15 @@ static int p80211wext_siwencode(netdevice_t *dev,
|
||||
available.
|
||||
*/
|
||||
if (erq->flags & IW_ENCODE_RESTRICTED) {
|
||||
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_true);
|
||||
}
|
||||
else if (erq->flags & IW_ENCODE_OPEN) {
|
||||
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_false);
|
||||
result =
|
||||
p80211wext_dorequest(wlandev,
|
||||
DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
|
||||
P80211ENUM_truth_true);
|
||||
} else if (erq->flags & IW_ENCODE_OPEN) {
|
||||
result =
|
||||
p80211wext_dorequest(wlandev,
|
||||
DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
|
||||
P80211ENUM_truth_false);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
@ -719,7 +724,6 @@ static int p80211wext_siwessid(netdevice_t *dev,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
||||
if (wlandev->hostwep & HOSTWEP_SHAREDKEY)
|
||||
msg.authtype.data = P80211ENUM_authalg_sharedkey;
|
||||
else
|
||||
@ -728,14 +732,13 @@ static int p80211wext_siwessid(netdevice_t *dev,
|
||||
msg.msgcode = DIDmsg_lnxreq_autojoin;
|
||||
|
||||
#if (WIRELESS_EXT < 21)
|
||||
if (length) length--;
|
||||
if (length)
|
||||
length--;
|
||||
#endif
|
||||
|
||||
/* Trim the last '\0' to fit the SSID format */
|
||||
|
||||
if (length && essid[length-1] == '\0') {
|
||||
if (length && essid[length - 1] == '\0')
|
||||
length--;
|
||||
}
|
||||
|
||||
memcpy(msg.ssid.data.data, essid, length);
|
||||
msg.ssid.data.len = length;
|
||||
@ -753,7 +756,6 @@ static int p80211wext_siwessid(netdevice_t *dev,
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
static int p80211wext_siwcommit(netdevice_t *dev,
|
||||
struct iw_request_info *info,
|
||||
struct iw_point *data, char *essid)
|
||||
@ -773,7 +775,6 @@ static int p80211wext_siwcommit(netdevice_t *dev,
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
static int p80211wext_giwrate(netdevice_t *dev,
|
||||
struct iw_request_info *info,
|
||||
struct iw_param *rrq, char *extra)
|
||||
@ -855,7 +856,6 @@ static int p80211wext_giwrts(netdevice_t *dev,
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
static int p80211wext_siwrts(netdevice_t *dev,
|
||||
struct iw_request_info *info,
|
||||
struct iw_param *rts, char *extra)
|
||||
@ -901,7 +901,8 @@ static int p80211wext_giwfrag(netdevice_t *dev,
|
||||
int err = 0;
|
||||
|
||||
msg.msgcode = DIDmsg_dot11req_mibget;
|
||||
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold;
|
||||
mibitem.did =
|
||||
DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold;
|
||||
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
|
||||
result = p80211req_dorequest(wlandev, (u8 *)&msg);
|
||||
|
||||
@ -936,7 +937,8 @@ static int p80211wext_siwfrag(netdevice_t *dev,
|
||||
}
|
||||
|
||||
msg.msgcode = DIDmsg_dot11req_mibset;
|
||||
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold;
|
||||
mibitem.did =
|
||||
DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold;
|
||||
|
||||
if (frag->disabled)
|
||||
mibitem.data = 2346;
|
||||
@ -1003,7 +1005,8 @@ static int p80211wext_giwretry(netdevice_t *dev,
|
||||
|
||||
longretry = mibitem.data;
|
||||
|
||||
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime;
|
||||
mibitem.did =
|
||||
DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime;
|
||||
|
||||
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
|
||||
result = p80211req_dorequest(wlandev, (u8 *)&msg);
|
||||
@ -1062,7 +1065,8 @@ static int p80211wext_siwretry(netdevice_t *dev,
|
||||
msg.msgcode = DIDmsg_dot11req_mibset;
|
||||
|
||||
if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
|
||||
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime;
|
||||
mibitem.did =
|
||||
DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime;
|
||||
mibitem.data = rrq->value /= 1024;
|
||||
|
||||
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
|
||||
@ -1074,10 +1078,12 @@ static int p80211wext_siwretry(netdevice_t *dev,
|
||||
}
|
||||
} else {
|
||||
if (rrq->flags & IW_RETRY_LONG) {
|
||||
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit;
|
||||
mibitem.did =
|
||||
DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit;
|
||||
mibitem.data = rrq->value;
|
||||
|
||||
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
|
||||
memcpy(&msg.mibattribute.data, &mibitem,
|
||||
sizeof(mibitem));
|
||||
result = p80211req_dorequest(wlandev, (u8 *)&msg);
|
||||
|
||||
if (result) {
|
||||
@ -1087,10 +1093,12 @@ static int p80211wext_siwretry(netdevice_t *dev,
|
||||
}
|
||||
|
||||
if (rrq->flags & IW_RETRY_SHORT) {
|
||||
mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit;
|
||||
mibitem.did =
|
||||
DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit;
|
||||
mibitem.data = rrq->value;
|
||||
|
||||
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
|
||||
memcpy(&msg.mibattribute.data, &mibitem,
|
||||
sizeof(mibitem));
|
||||
result = p80211req_dorequest(wlandev, (u8 *)&msg);
|
||||
|
||||
if (result) {
|
||||
@ -1121,7 +1129,8 @@ static int p80211wext_siwtxpow(netdevice_t *dev,
|
||||
}
|
||||
|
||||
msg.msgcode = DIDmsg_dot11req_mibset;
|
||||
mibitem.did = DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel;
|
||||
mibitem.did =
|
||||
DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel;
|
||||
if (rrq->fixed == 0)
|
||||
mibitem.data = 30;
|
||||
else
|
||||
@ -1149,7 +1158,8 @@ static int p80211wext_giwtxpow(netdevice_t *dev,
|
||||
int err = 0;
|
||||
|
||||
msg.msgcode = DIDmsg_dot11req_mibget;
|
||||
mibitem.did = DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel;
|
||||
mibitem.did =
|
||||
DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel;
|
||||
|
||||
memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
|
||||
result = p80211req_dorequest(wlandev, (u8 *)&msg);
|
||||
@ -1161,9 +1171,9 @@ static int p80211wext_giwtxpow(netdevice_t *dev,
|
||||
|
||||
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->fixed = 0;
|
||||
rrq->value = mibitem.data;
|
||||
@ -1181,7 +1191,6 @@ static int p80211wext_siwspy(netdevice_t *dev,
|
||||
int number = srq->length;
|
||||
int i;
|
||||
|
||||
|
||||
/* Copy the data from the input buffer */
|
||||
memcpy(address, extra, sizeof(struct sockaddr) * number);
|
||||
|
||||
@ -1192,11 +1201,13 @@ static int p80211wext_siwspy(netdevice_t *dev,
|
||||
/* extract the addresses */
|
||||
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 */
|
||||
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 */
|
||||
wlandev->spy_number = number;
|
||||
@ -1223,9 +1234,11 @@ static int p80211wext_giwspy(netdevice_t *dev,
|
||||
|
||||
/* populate address and spy struct's */
|
||||
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],
|
||||
ETH_ALEN);
|
||||
address[i].sa_family = AF_UNIX;
|
||||
memcpy(&spy_stat[i], &wlandev->spy_stat[i], sizeof(struct iw_quality));
|
||||
memcpy(&spy_stat[i], &wlandev->spy_stat[i],
|
||||
sizeof(struct iw_quality));
|
||||
}
|
||||
|
||||
/* reset update flag */
|
||||
@ -1236,7 +1249,8 @@ static int p80211wext_giwspy(netdevice_t *dev,
|
||||
/* push stuff to user space */
|
||||
srq->length = 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;
|
||||
}
|
||||
@ -1304,14 +1318,13 @@ static int p80211wext_siwscan(netdevice_t *dev,
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* Helper to translate scan into Wireless Extensions scan results.
|
||||
* Inspired by the prism54 code, which was in turn inspired by the
|
||||
* airo driver code.
|
||||
*/
|
||||
static char *
|
||||
wext_translate_bss(struct iw_request_info *info, char *current_ev,
|
||||
char *end_buf, p80211msg_dot11req_scan_results_t *bss)
|
||||
static char *wext_translate_bss(struct iw_request_info *info, char *current_ev,
|
||||
char *end_buf,
|
||||
p80211msg_dot11req_scan_results_t *bss)
|
||||
{
|
||||
struct iw_event iwe; /* Temporary buffer */
|
||||
|
||||
@ -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);
|
||||
iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
|
||||
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 */
|
||||
|
||||
@ -1328,14 +1343,18 @@ wext_translate_bss(struct iw_request_info *info, char *current_ev,
|
||||
char essid[IW_ESSID_MAX_SIZE + 1];
|
||||
int size;
|
||||
|
||||
size = min_t(unsigned short, IW_ESSID_MAX_SIZE, bss->ssid.data.len);
|
||||
size =
|
||||
min_t(unsigned short, IW_ESSID_MAX_SIZE,
|
||||
bss->ssid.data.len);
|
||||
memset(&essid, 0, sizeof(essid));
|
||||
memcpy(&essid, bss->ssid.data.data, size);
|
||||
pr_debug(" essid size = %d\n", size);
|
||||
iwe.u.data.length = size;
|
||||
iwe.u.data.flags = 1;
|
||||
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");
|
||||
}
|
||||
|
||||
@ -1354,7 +1373,9 @@ wext_translate_bss(struct iw_request_info *info, char *current_ev,
|
||||
}
|
||||
iwe.cmd = SIOCGIWMODE;
|
||||
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 */
|
||||
if (bss->privacy.data == P80211ENUM_truth_true)
|
||||
@ -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.length = 0;
|
||||
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 */
|
||||
iwe.u.freq.m = bss->dschannel.data;
|
||||
iwe.u.freq.e = 0;
|
||||
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 */
|
||||
iwe.u.qual.level = bss->signal.data;
|
||||
@ -1377,12 +1401,13 @@ wext_translate_bss(struct iw_request_info *info, char *current_ev,
|
||||
/* do a simple SNR for quality */
|
||||
iwe.u.qual.qual = qual_as_percent(bss->signal.data - bss->noise.data);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
static int p80211wext_giwscan(netdevice_t *dev,
|
||||
struct iw_request_info *info,
|
||||
struct iw_point *srq, char *extra)
|
||||
@ -1410,7 +1435,9 @@ static int p80211wext_giwscan(netdevice_t *dev,
|
||||
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;
|
||||
i++;
|
||||
} while (i < IW_MAX_AP);
|
||||
@ -1424,8 +1451,7 @@ static int p80211wext_giwscan(netdevice_t *dev,
|
||||
return err;
|
||||
}
|
||||
|
||||
/*****************************************************/
|
||||
//extra wireless extensions stuff to support NetworkManager (I hope)
|
||||
/* extra wireless extensions stuff to support NetworkManager (I hope) */
|
||||
|
||||
/* SIOCSIWENCODEEXT */
|
||||
static int p80211wext_set_encodeext(struct net_device *dev,
|
||||
@ -1441,25 +1467,27 @@ static int p80211wext_set_encodeext(struct net_device *dev,
|
||||
struct iw_point *encoding = &wrqu->encoding;
|
||||
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) {
|
||||
// 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 < 1 || idx > NUM_WEPKEYS) {
|
||||
if (idx < 1 || idx > NUM_WEPKEYS)
|
||||
return -EINVAL;
|
||||
} else
|
||||
else
|
||||
idx--;
|
||||
}
|
||||
pr_debug("setting default key (%d)\n", idx);
|
||||
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, idx);
|
||||
result =
|
||||
p80211wext_dorequest(wlandev,
|
||||
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 :(");
|
||||
@ -1481,16 +1509,20 @@ static int p80211wext_set_encodeext(struct net_device *dev,
|
||||
pstr->data.len = ext->key_len;
|
||||
switch (idx) {
|
||||
case 0:
|
||||
pstr->did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
|
||||
pstr->did =
|
||||
DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
|
||||
break;
|
||||
case 1:
|
||||
pstr->did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
|
||||
pstr->did =
|
||||
DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
|
||||
break;
|
||||
case 2:
|
||||
pstr->did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
|
||||
pstr->did =
|
||||
DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
|
||||
break;
|
||||
case 3:
|
||||
pstr->did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
|
||||
pstr->did =
|
||||
DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -1506,7 +1538,6 @@ static int p80211wext_set_encodeext(struct net_device *dev,
|
||||
static int p80211wext_get_encodeext(struct net_device *dev,
|
||||
struct iw_request_info *info,
|
||||
union iwreq_data *wrqu, char *extra)
|
||||
|
||||
{
|
||||
wlandevice_t *wlandev = dev->ml_priv;
|
||||
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
|
||||
@ -1516,12 +1547,13 @@ static int p80211wext_get_encodeext(struct net_device *dev,
|
||||
int max_len;
|
||||
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);
|
||||
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;
|
||||
goto exit;
|
||||
}
|
||||
@ -1531,7 +1563,8 @@ static int p80211wext_get_encodeext(struct net_device *dev,
|
||||
|
||||
if (idx) {
|
||||
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;
|
||||
goto exit;
|
||||
}
|
||||
@ -1553,7 +1586,6 @@ exit:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* SIOCSIWAUTH */
|
||||
static int p80211_wext_set_iwauth(struct net_device *dev,
|
||||
struct iw_request_info *info,
|
||||
@ -1563,23 +1595,36 @@ static int p80211_wext_set_iwauth (struct net_device *dev,
|
||||
struct iw_param *param = &wrqu->param;
|
||||
int result = 0;
|
||||
|
||||
pr_debug("set_iwauth flags[%d]\n",(int)param->flags & IW_AUTH_INDEX );
|
||||
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);
|
||||
result =
|
||||
p80211wext_dorequest(wlandev,
|
||||
DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
|
||||
P80211ENUM_truth_true);
|
||||
else
|
||||
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_false);
|
||||
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);
|
||||
result =
|
||||
p80211wext_dorequest(wlandev,
|
||||
DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
|
||||
P80211ENUM_truth_true);
|
||||
else
|
||||
result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_false);
|
||||
result =
|
||||
p80211wext_dorequest(wlandev,
|
||||
DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
|
||||
P80211ENUM_truth_false);
|
||||
|
||||
break;
|
||||
|
||||
@ -1591,8 +1636,9 @@ static int p80211_wext_set_iwauth (struct net_device *dev,
|
||||
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);
|
||||
/* don't know what to do know */
|
||||
pr_debug("unknown AUTH_ALG (%d)\n",
|
||||
param->value);
|
||||
result = -EINVAL;
|
||||
}
|
||||
break;
|
||||
@ -1601,8 +1647,6 @@ static int p80211_wext_set_iwauth (struct net_device *dev,
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1615,28 +1659,31 @@ static int p80211_wext_get_iwauth (struct net_device *dev,
|
||||
struct iw_param *param = &wrqu->param;
|
||||
int result = 0;
|
||||
|
||||
pr_debug("get_iwauth flags[%d]\n",(int)param->flags & IW_AUTH_INDEX );
|
||||
pr_debug("get_iwauth flags[%d]\n",
|
||||
(int)param->flags & IW_AUTH_INDEX);
|
||||
|
||||
switch (param->flags & IW_AUTH_INDEX) {
|
||||
case IW_AUTH_DROP_UNENCRYPTED:
|
||||
param->value = wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED?1:0;
|
||||
param->value =
|
||||
wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED ? 1 : 0;
|
||||
break;
|
||||
|
||||
case IW_AUTH_PRIVACY_INVOKED:
|
||||
param->value = wlandev->hostwep & HOSTWEP_PRIVACYINVOKED?1:0;
|
||||
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;
|
||||
param->value =
|
||||
wlandev->
|
||||
hostwep & HOSTWEP_SHAREDKEY ? IW_AUTH_ALG_SHARED_KEY :
|
||||
IW_AUTH_ALG_OPEN_SYSTEM;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1710,30 +1757,25 @@ struct iw_handler_def p80211wext_handler_def = {
|
||||
.get_wireless_stats = p80211wext_get_wireless_stats
|
||||
};
|
||||
|
||||
|
||||
int p80211wext_event_associated(wlandevice_t *wlandev, int assoc)
|
||||
{
|
||||
union iwreq_data data;
|
||||
|
||||
/* Send the association state first */
|
||||
data.ap_addr.sa_family = ARPHRD_ETHER;
|
||||
if (assoc) {
|
||||
if (assoc)
|
||||
memcpy(data.ap_addr.sa_data, wlandev->bssid, ETH_ALEN);
|
||||
} else {
|
||||
else
|
||||
memset(data.ap_addr.sa_data, 0, ETH_ALEN);
|
||||
}
|
||||
|
||||
if (wlan_wext_write)
|
||||
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:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user