diff options
Diffstat (limited to 'drivers/staging/rtl8187se/r8180_wx.c')
-rw-r--r-- | drivers/staging/rtl8187se/r8180_wx.c | 257 |
1 files changed, 128 insertions, 129 deletions
diff --git a/drivers/staging/rtl8187se/r8180_wx.c b/drivers/staging/rtl8187se/r8180_wx.c index 4e01653e098a..9b676e027cad 100644 --- a/drivers/staging/rtl8187se/r8180_wx.c +++ b/drivers/staging/rtl8187se/r8180_wx.c @@ -21,9 +21,10 @@ #include "r8180.h" #include "r8180_hw.h" +#include <net/iw_handler.h> #include "ieee80211/dot11d.h" -u32 rtl8180_rates[] = {1000000, 2000000, 5500000, 11000000, +static u32 rtl8180_rates[] = {1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000}; #define RATE_COUNT ARRAY_SIZE(rtl8180_rates) @@ -61,7 +62,7 @@ static int r8180_wx_set_key(struct net_device *dev, return 0; if (erq->length > 0) { - u32* tkey = (u32*) key; + u32 *tkey = (u32 *) key; priv->key0[0] = tkey[0]; priv->key0[1] = tkey[1]; priv->key0[2] = tkey[2]; @@ -74,8 +75,9 @@ static int r8180_wx_set_key(struct net_device *dev, } -static int r8180_wx_set_beaconinterval(struct net_device *dev, struct iw_request_info *aa, - union iwreq_data *wrqu, char *b) +static int r8180_wx_set_beaconinterval(struct net_device *dev, + struct iw_request_info *aa, + union iwreq_data *wrqu, char *b) { int *parms = (int *)b; int bi = parms[0]; @@ -295,7 +297,7 @@ static int rtl8180_wx_get_range(struct net_device *dev, } if (val == IW_MAX_FREQUENCIES) - break; + break; } range->num_frequency = val; @@ -311,14 +313,14 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, { struct r8180_priv *priv = ieee80211_priv(dev); int ret; - struct ieee80211_device* ieee = priv->ieee80211; + struct ieee80211_device *ieee = priv->ieee80211; if (priv->ieee80211->bHwRadioOff) return 0; if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { - struct iw_scan_req* req = (struct iw_scan_req*)b; + struct iw_scan_req *req = (struct iw_scan_req *)b; if (req->essid_len) { ieee->current_network.ssid_len = req->essid_len; memcpy(ieee->current_network.ssid, req->essid, req->essid_len); @@ -473,9 +475,8 @@ static int r8180_wx_get_frag(struct net_device *dev, static int r8180_wx_set_wap(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *awrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *awrq, char *extra) { int ret; struct r8180_priv *priv = ieee80211_priv(dev); @@ -516,7 +517,8 @@ static int r8180_wx_set_enc(struct net_device *dev, down(&priv->wx_sem); - if (priv->hw_wep) ret = r8180_wx_set_key(dev, info, wrqu, key); + if (priv->hw_wep) + ret = r8180_wx_set_key(dev, info, wrqu, key); else { DMESG("Setting SW wep key"); ret = ieee80211_wx_set_encode(priv->ieee80211, info, wrqu, key); @@ -537,11 +539,13 @@ static int r8180_wx_get_enc(struct net_device *dev, } -static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union - iwreq_data *wrqu, char *p) { +static int r8180_wx_set_scan_type(struct net_device *dev, + struct iw_request_info *aa, + union iwreq_data *wrqu, char *p) +{ struct r8180_priv *priv = ieee80211_priv(dev); - int *parms = (int*)p; + int *parms = (int *)p; int mode = parms[0]; if (priv->ieee80211->bHwRadioOff) @@ -553,8 +557,8 @@ static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info } static int r8180_wx_set_retry(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); int err = 0; @@ -601,8 +605,8 @@ exit: } static int r8180_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); @@ -625,8 +629,8 @@ static int r8180_wx_get_retry(struct net_device *dev, } static int r8180_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); if (priv->rf_set_sens == NULL) @@ -637,8 +641,8 @@ static int r8180_wx_get_sens(struct net_device *dev, static int r8180_wx_set_sens(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); @@ -666,8 +670,8 @@ exit: static int r8180_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); int ret; @@ -686,8 +690,8 @@ static int r8180_wx_set_rawtx(struct net_device *dev, } static int r8180_wx_get_power(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret; struct r8180_priv *priv = ieee80211_priv(dev); @@ -702,8 +706,8 @@ static int r8180_wx_get_power(struct net_device *dev, } static int r8180_wx_set_power(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret; struct r8180_priv *priv = ieee80211_priv(dev); @@ -728,8 +732,8 @@ static int r8180_wx_set_power(struct net_device *dev, } static int r8180_wx_set_rts(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); @@ -750,8 +754,8 @@ static int r8180_wx_set_rts(struct net_device *dev, return 0; } static int r8180_wx_get_rts(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); @@ -841,8 +845,8 @@ static int r8180_wx_set_iwmode(struct net_device *dev, return ret; } static int r8180_wx_get_preamble(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); @@ -858,8 +862,8 @@ static int r8180_wx_get_preamble(struct net_device *dev, return 0; } static int r8180_wx_set_preamble(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); int ret = 0; @@ -872,7 +876,7 @@ static int r8180_wx_set_preamble(struct net_device *dev, if (*extra < 0 || *extra > 2) ret = -1; else - priv->plcp_preamble_mode = *((short *)extra) ; + priv->plcp_preamble_mode = *((short *)extra); @@ -881,8 +885,8 @@ static int r8180_wx_set_preamble(struct net_device *dev, return ret; } static int r8180_wx_get_siglevel(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); int ret = 0; @@ -900,8 +904,8 @@ static int r8180_wx_get_siglevel(struct net_device *dev, return ret; } static int r8180_wx_get_sigqual(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); int ret = 0; @@ -959,8 +963,8 @@ static int r8180_wx_reset_stats(struct net_device *dev, } static int r8180_wx_radio_on(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); @@ -978,8 +982,8 @@ static int r8180_wx_radio_on(struct net_device *dev, } static int r8180_wx_radio_off(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); @@ -996,8 +1000,8 @@ static int r8180_wx_radio_off(struct net_device *dev, } static int r8180_wx_get_channelplan(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); @@ -1013,8 +1017,8 @@ static int r8180_wx_get_channelplan(struct net_device *dev, return 0; } static int r8180_wx_set_channelplan(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); int *val = (int *)extra; @@ -1035,7 +1039,7 @@ static int r8180_wx_set_channelplan(struct net_device *dev, /* Set new channel map */ for (i = 1; i <= DefaultChannelPlan[*val].Len; i++) GET_DOT11D_INFO(priv->ieee80211)->channel_map[DefaultChannelPlan[*val].Channel[i-1]] = 1; - + } up(&priv->wx_sem); @@ -1043,8 +1047,8 @@ static int r8180_wx_set_channelplan(struct net_device *dev, } static int r8180_wx_get_version(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); /* struct ieee80211_device *ieee; */ @@ -1059,8 +1063,8 @@ static int r8180_wx_get_version(struct net_device *dev, /* added by amy 080818 */ /*receive datarate from user typing valid rate is from 2 to 108 (1 - 54M), if input 0, return to normal rate adaptive. */ static int r8180_wx_set_forcerate(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); u8 forcerate = *extra; @@ -1070,8 +1074,7 @@ static int r8180_wx_set_forcerate(struct net_device *dev, printk("==============>%s(): forcerate is %d\n", __func__, forcerate); if ((forcerate == 2) || (forcerate == 4) || (forcerate == 11) || (forcerate == 22) || (forcerate == 12) || (forcerate == 18) || (forcerate == 24) || (forcerate == 36) || (forcerate == 48) || (forcerate == 72) || - (forcerate == 96) || (forcerate == 108)) - { + (forcerate == 96) || (forcerate == 108)) { priv->ForcedDataRate = 1; priv->ieee80211->rate = forcerate * 5; } else if (forcerate == 0) { @@ -1084,8 +1087,8 @@ static int r8180_wx_set_forcerate(struct net_device *dev, } static int r8180_wx_set_enc_ext(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8180_priv *priv = ieee80211_priv(dev); @@ -1118,8 +1121,8 @@ static int r8180_wx_set_auth(struct net_device *dev, } static int r8180_wx_set_mlme(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret = 0; struct r8180_priv *priv = ieee80211_priv(dev); @@ -1156,65 +1159,48 @@ static int r8180_wx_set_gen_ie(struct net_device *dev, } -static iw_handler r8180_wx_handlers[] = { - NULL, /* SIOCSIWCOMMIT */ - r8180_wx_get_name, /* SIOCGIWNAME */ - dummy, /* SIOCSIWNWID */ - dummy, /* SIOCGIWNWID */ - r8180_wx_set_freq, /* SIOCSIWFREQ */ - r8180_wx_get_freq, /* SIOCGIWFREQ */ - r8180_wx_set_mode, /* SIOCSIWMODE */ - r8180_wx_get_mode, /* SIOCGIWMODE */ - r8180_wx_set_sens, /* SIOCSIWSENS */ - r8180_wx_get_sens, /* SIOCGIWSENS */ - NULL, /* SIOCSIWRANGE */ - rtl8180_wx_get_range, /* SIOCGIWRANGE */ - NULL, /* SIOCSIWPRIV */ - NULL, /* SIOCGIWPRIV */ - NULL, /* SIOCSIWSTATS */ - NULL, /* SIOCGIWSTATS */ - dummy, /* SIOCSIWSPY */ - dummy, /* SIOCGIWSPY */ - NULL, /* SIOCGIWTHRSPY */ - NULL, /* SIOCWIWTHRSPY */ - r8180_wx_set_wap, /* SIOCSIWAP */ - r8180_wx_get_wap, /* SIOCGIWAP */ - r8180_wx_set_mlme, /* SIOCSIWMLME*/ - dummy, /* SIOCGIWAPLIST -- deprecated */ - r8180_wx_set_scan, /* SIOCSIWSCAN */ - r8180_wx_get_scan, /* SIOCGIWSCAN */ - r8180_wx_set_essid, /* SIOCSIWESSID */ - r8180_wx_get_essid, /* SIOCGIWESSID */ - dummy, /* SIOCSIWNICKN */ - dummy, /* SIOCGIWNICKN */ - NULL, /* -- hole -- */ - NULL, /* -- hole -- */ - r8180_wx_set_rate, /* SIOCSIWRATE */ - r8180_wx_get_rate, /* SIOCGIWRATE */ - r8180_wx_set_rts, /* SIOCSIWRTS */ - r8180_wx_get_rts, /* SIOCGIWRTS */ - r8180_wx_set_frag, /* SIOCSIWFRAG */ - r8180_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ - r8180_wx_set_retry, /* SIOCSIWRETRY */ - r8180_wx_get_retry, /* SIOCGIWRETRY */ - r8180_wx_set_enc, /* SIOCSIWENCODE */ - r8180_wx_get_enc, /* SIOCGIWENCODE */ - r8180_wx_set_power, /* SIOCSIWPOWER */ - r8180_wx_get_power, /* SIOCGIWPOWER */ - NULL, /*---hole---*/ - NULL, /*---hole---*/ - r8180_wx_set_gen_ie, /* SIOCSIWGENIE */ - NULL, /* SIOCSIWGENIE */ - r8180_wx_set_auth, /* SIOCSIWAUTH */ - NULL, /* SIOCSIWAUTH */ - r8180_wx_set_enc_ext, /* SIOCSIWENCODEEXT */ - NULL, /* SIOCSIWENCODEEXT */ - NULL, /* SIOCSIWPMKSA */ - NULL, /*---hole---*/ -}; +static const iw_handler r8180_wx_handlers[] = { + IW_HANDLER(SIOCGIWNAME, r8180_wx_get_name), + IW_HANDLER(SIOCSIWNWID, dummy), + IW_HANDLER(SIOCGIWNWID, dummy), + IW_HANDLER(SIOCSIWFREQ, r8180_wx_set_freq), + IW_HANDLER(SIOCGIWFREQ, r8180_wx_get_freq), + IW_HANDLER(SIOCSIWMODE, r8180_wx_set_mode), + IW_HANDLER(SIOCGIWMODE, r8180_wx_get_mode), + IW_HANDLER(SIOCSIWSENS, r8180_wx_set_sens), + IW_HANDLER(SIOCGIWSENS, r8180_wx_get_sens), + IW_HANDLER(SIOCGIWRANGE, rtl8180_wx_get_range), + IW_HANDLER(SIOCSIWSPY, dummy), + IW_HANDLER(SIOCGIWSPY, dummy), + IW_HANDLER(SIOCSIWAP, r8180_wx_set_wap), + IW_HANDLER(SIOCGIWAP, r8180_wx_get_wap), + IW_HANDLER(SIOCSIWMLME, r8180_wx_set_mlme), + IW_HANDLER(SIOCGIWAPLIST, dummy), /* deprecated */ + IW_HANDLER(SIOCSIWSCAN, r8180_wx_set_scan), + IW_HANDLER(SIOCGIWSCAN, r8180_wx_get_scan), + IW_HANDLER(SIOCSIWESSID, r8180_wx_set_essid), + IW_HANDLER(SIOCGIWESSID, r8180_wx_get_essid), + IW_HANDLER(SIOCSIWNICKN, dummy), + IW_HANDLER(SIOCGIWNICKN, dummy), + IW_HANDLER(SIOCSIWRATE, r8180_wx_set_rate), + IW_HANDLER(SIOCGIWRATE, r8180_wx_get_rate), + IW_HANDLER(SIOCSIWRTS, r8180_wx_set_rts), + IW_HANDLER(SIOCGIWRTS, r8180_wx_get_rts), + IW_HANDLER(SIOCSIWFRAG, r8180_wx_set_frag), + IW_HANDLER(SIOCGIWFRAG, r8180_wx_get_frag), + IW_HANDLER(SIOCSIWTXPOW, dummy), + IW_HANDLER(SIOCGIWTXPOW, dummy), + IW_HANDLER(SIOCSIWRETRY, r8180_wx_set_retry), + IW_HANDLER(SIOCGIWRETRY, r8180_wx_get_retry), + IW_HANDLER(SIOCSIWENCODE, r8180_wx_set_enc), + IW_HANDLER(SIOCGIWENCODE, r8180_wx_get_enc), + IW_HANDLER(SIOCSIWPOWER, r8180_wx_set_power), + IW_HANDLER(SIOCGIWPOWER, r8180_wx_get_power), + IW_HANDLER(SIOCSIWGENIE, r8180_wx_set_gen_ie), + IW_HANDLER(SIOCSIWAUTH, r8180_wx_set_auth), + IW_HANDLER(SIOCSIWENCODEEXT, r8180_wx_set_enc_ext), +}; static const struct iw_priv_args r8180_private_args[] = { { @@ -1350,7 +1336,7 @@ static iw_handler r8180_private_handler[] = { }; static inline int is_same_network(struct ieee80211_network *src, - struct ieee80211_network *dst, + struct ieee80211_network *dst, struct ieee80211_device *ieee) { /* A network is only a duplicate if the channel, BSSID, ESSID @@ -1358,22 +1344,35 @@ static inline int is_same_network(struct ieee80211_network *src, * We treat all <hidden> with the same BSSID and channel * as one network */ - return (((src->ssid_len == dst->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) && /* YJ,mod, 080819,for hidden ap */ - (src->channel == dst->channel) && - !memcmp(src->bssid, dst->bssid, ETH_ALEN) && - (!memcmp(src->ssid, dst->ssid, src->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) && /* YJ,mod, 080819,for hidden ap */ - ((src->capability & WLAN_CAPABILITY_IBSS) == - (dst->capability & WLAN_CAPABILITY_IBSS)) && - ((src->capability & WLAN_CAPABILITY_BSS) == - (dst->capability & WLAN_CAPABILITY_BSS))); + if (src->channel != dst->channel) + return 0; + + if (memcmp(src->bssid, dst->bssid, ETH_ALEN) != 0) + return 0; + + if (ieee->iw_mode != IW_MODE_INFRA) { + if (src->ssid_len != dst->ssid_len) + return 0; + if (memcmp(src->ssid, dst->ssid, src->ssid_len) != 0) + return 0; + } + + if ((src->capability & WLAN_CAPABILITY_IBSS) != + (dst->capability & WLAN_CAPABILITY_IBSS)) + return 0; + if ((src->capability & WLAN_CAPABILITY_BSS) != + (dst->capability & WLAN_CAPABILITY_BSS)) + return 0; + + return 1; } /* WB modified to show signal to GUI on 18-01-2008 */ static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) { struct r8180_priv *priv = ieee80211_priv(dev); - struct ieee80211_device* ieee = priv->ieee80211; - struct iw_statistics* wstats = &priv->wstats; + struct ieee80211_device *ieee = priv->ieee80211; + struct iw_statistics *wstats = &priv->wstats; int tmp_level = 0; int tmp_qual = 0; int tmp_noise = 0; |