Release 4.7 drivers/staging/rtl8712/rtl871x_ioctl_set.c
/******************************************************************************
* rtl871x_ioctl_set.c
*
* Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
* Linux device driver for RTL8192SU
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* Modifications for inclusion into the Linux staging tree are
* Copyright(c) 2010 Larry Finger. All rights reserved.
*
* Contact information:
* WLAN FAE <wlanfae@realtek.com>
* Larry Finger <Larry.Finger@lwfinger.net>
*
******************************************************************************/
#define _RTL871X_IOCTL_SET_C_
#include "osdep_service.h"
#include "drv_types.h"
#include "rtl871x_ioctl_set.h"
#include "usb_osintf.h"
#include "usb_ops.h"
static u8 validate_ssid(struct ndis_802_11_ssid *ssid)
{
u8 i;
if (ssid->SsidLength > 32)
return false;
for (i = 0; i < ssid->SsidLength; i++) {
/* wifi, printable ascii code must be supported */
if (!((ssid->Ssid[i] >= 0x20) && (ssid->Ssid[i] <= 0x7e)))
return false;
}
return true;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
larry finger | larry finger | 76 | 100.00% | 1 | 100.00% |
| Total | 76 | 100.00% | 1 | 100.00% |
static u8 do_join(struct _adapter *padapter)
{
struct list_head *plist, *phead;
u8 *pibss = NULL;
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
struct __queue *queue = &(pmlmepriv->scanned_queue);
phead = &queue->queue;
plist = phead->next;
pmlmepriv->cur_network.join_res = -2;
pmlmepriv->fw_state |= _FW_UNDER_LINKING;
pmlmepriv->pscanned = plist;
pmlmepriv->to_join = true;
/* adhoc mode will start with an empty queue, but skip checking */
if (!check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) &&
list_empty(&queue->queue)) {
if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
pmlmepriv->fw_state ^= _FW_UNDER_LINKING;
/* when set_ssid/set_bssid for do_join(), but scanning queue
* is empty we try to issue sitesurvey firstly
*/
if (!pmlmepriv->sitesurveyctrl.traffic_busy)
r8712_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid);
return true;
} else {
int ret;
ret = r8712_select_and_join_from_scan(pmlmepriv);
if (ret == _SUCCESS)
mod_timer(&pmlmepriv->assoc_timer,
jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
else {
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
/* submit r8712_createbss_cmd to change to an
* ADHOC_MASTER pmlmepriv->lock has been
* acquired by caller...
*/
struct wlan_bssid_ex *pdev_network =
&(padapter->registrypriv.dev_network);
pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
pibss = padapter->registrypriv.dev_network.
MacAddress;
memcpy(&pdev_network->Ssid,
&pmlmepriv->assoc_ssid,
sizeof(struct ndis_802_11_ssid));
r8712_update_registrypriv_dev_network(padapter);
r8712_generate_random_ibss(pibss);
if (r8712_createbss_cmd(padapter) != _SUCCESS)
return false;
pmlmepriv->to_join = false;
} else {
/* can't associate ; reset under-linking */
if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
pmlmepriv->fw_state ^=
_FW_UNDER_LINKING;
/* when set_ssid/set_bssid for do_join(), but
* there are no desired bss in scanning queue
* we try to issue sitesurvey first
*/
if (!pmlmepriv->sitesurveyctrl.traffic_busy)
r8712_sitesurvey_cmd(padapter,
&pmlmepriv->assoc_ssid);
}
}
}
return true;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
larry finger | larry finger | 289 | 92.04% | 1 | 14.29% |
jeff chua | jeff chua | 9 | 2.87% | 1 | 14.29% |
james a shackleford | james a shackleford | 9 | 2.87% | 3 | 42.86% |
vaishali thakkar | vaishali thakkar | 6 | 1.91% | 1 | 14.29% |
tapasweni pathak | tapasweni pathak | 1 | 0.32% | 1 | 14.29% |
| Total | 314 | 100.00% | 7 | 100.00% |
u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid)
{
unsigned long irqL;
u8 status = true;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
if (is_zero_ether_addr(bssid) || is_broadcast_ether_addr(bssid)) {
status = false;
return status;
}
spin_lock_irqsave(&pmlmepriv->lock, irqL);
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY |
_FW_UNDER_LINKING)) {
status = check_fwstate(pmlmepriv, _FW_UNDER_LINKING);
goto _Abort_Set_BSSID;
}
if (check_fwstate(pmlmepriv,
_FW_LINKED | WIFI_ADHOC_MASTER_STATE)) {
if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid,
ETH_ALEN)) {
if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE))
goto _Abort_Set_BSSID; /* driver is in
* WIFI_ADHOC_MASTER_STATE */
} else {
r8712_disassoc_cmd(padapter);
if (check_fwstate(pmlmepriv, _FW_LINKED))
r8712_ind_disconnect(padapter);
r8712_free_assoc_resources(padapter);
if ((check_fwstate(pmlmepriv,
WIFI_ADHOC_MASTER_STATE))) {
_clr_fwstate_(pmlmepriv,
WIFI_ADHOC_MASTER_STATE);
set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
}
}
}
memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN);
pmlmepriv->assoc_by_bssid = true;
status = do_join(padapter);
goto done;
_Abort_Set_BSSID:
done:
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
larry finger | larry finger | 229 | 97.03% | 1 | 33.33% |
wei yongjun | wei yongjun | 6 | 2.54% | 1 | 33.33% |
tapasweni pathak | tapasweni pathak | 1 | 0.42% | 1 | 33.33% |
| Total | 236 | 100.00% | 3 | 100.00% |
void r8712_set_802_11_ssid(struct _adapter *padapter,
struct ndis_802_11_ssid *ssid)
{
unsigned long irqL;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_network *pnetwork = &pmlmepriv->cur_network;
if (!padapter->hw_init_completed)
return;
spin_lock_irqsave(&pmlmepriv->lock, irqL);
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) {
check_fwstate(pmlmepriv, _FW_UNDER_LINKING);
goto _Abort_Set_SSID;
}
if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) {
if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) &&
(!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid,
ssid->SsidLength))) {
if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
if (!r8712_is_same_ibss(padapter,
pnetwork)) {
/* if in WIFI_ADHOC_MASTER_STATE or
* WIFI_ADHOC_STATE, create bss or
* rejoin again
*/
r8712_disassoc_cmd(padapter);
if (check_fwstate(pmlmepriv,
_FW_LINKED))
r8712_ind_disconnect(padapter);
r8712_free_assoc_resources(padapter);
if (check_fwstate(pmlmepriv,
WIFI_ADHOC_MASTER_STATE)) {
_clr_fwstate_(pmlmepriv,
WIFI_ADHOC_MASTER_STATE);
set_fwstate(pmlmepriv,
WIFI_ADHOC_STATE);
}
} else {
goto _Abort_Set_SSID; /* driver is in
* WIFI_ADHOC_MASTER_STATE */
}
}
} else {
r8712_disassoc_cmd(padapter);
if (check_fwstate(pmlmepriv, _FW_LINKED))
r8712_ind_disconnect(padapter);
r8712_free_assoc_resources(padapter);
if (check_fwstate(pmlmepriv,
WIFI_ADHOC_MASTER_STATE)) {
_clr_fwstate_(pmlmepriv,
WIFI_ADHOC_MASTER_STATE);
set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
}
}
}
if (padapter->securitypriv.btkip_countermeasure)
goto _Abort_Set_SSID;
if (!validate_ssid(ssid))
goto _Abort_Set_SSID;
memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid));
pmlmepriv->assoc_by_bssid = false;
do_join(padapter);
goto done;
_Abort_Set_SSID:
done:
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
larry finger | larry finger | 323 | 98.18% | 1 | 33.33% |
tapasweni pathak | tapasweni pathak | 4 | 1.22% | 1 | 33.33% |
luis de bethencourt | luis de bethencourt | 2 | 0.61% | 1 | 33.33% |
| Total | 329 | 100.00% | 3 | 100.00% |
void r8712_set_802_11_infrastructure_mode(struct _adapter *padapter,
enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype)
{
unsigned long irqL;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_network *cur_network = &pmlmepriv->cur_network;
enum NDIS_802_11_NETWORK_INFRASTRUCTURE *pold_state =
&(cur_network->network.InfrastructureMode);
if (*pold_state != networktype) {
spin_lock_irqsave(&pmlmepriv->lock, irqL);
if (check_fwstate(pmlmepriv, _FW_LINKED) ||
(*pold_state == Ndis802_11IBSS))
r8712_disassoc_cmd(padapter);
if (check_fwstate(pmlmepriv,
_FW_LINKED | WIFI_ADHOC_MASTER_STATE))
r8712_free_assoc_resources(padapter);
if (check_fwstate(pmlmepriv, _FW_LINKED) ||
(*pold_state == Ndis802_11Infrastructure) ||
(*pold_state == Ndis802_11IBSS)) {
/* will clr Linked_state before this function,
* we must have checked whether issue dis-assoc_cmd or
* not */
r8712_ind_disconnect(padapter);
}
*pold_state = networktype;
/* clear WIFI_STATION_STATE; WIFI_AP_STATE; WIFI_ADHOC_STATE;
* WIFI_ADHOC_MASTER_STATE */
_clr_fwstate_(pmlmepriv, WIFI_STATION_STATE | WIFI_AP_STATE |
WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE);
switch (networktype) {
case Ndis802_11IBSS:
set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
break;
case Ndis802_11Infrastructure:
set_fwstate(pmlmepriv, WIFI_STATION_STATE);
break;
case Ndis802_11APMode:
set_fwstate(pmlmepriv, WIFI_AP_STATE);
break;
case Ndis802_11AutoUnknown:
case Ndis802_11InfrastructureMax:
break;
}
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
larry finger | larry finger | 212 | 99.07% | 1 | 33.33% |
justin mattock | justin mattock | 1 | 0.47% | 1 | 33.33% |
ali bahar | ali bahar | 1 | 0.47% | 1 | 33.33% |
| Total | 214 | 100.00% | 3 | 100.00% |
u8 r8712_set_802_11_disassociate(struct _adapter *padapter)
{
unsigned long irqL;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
spin_lock_irqsave(&pmlmepriv->lock, irqL);
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
r8712_disassoc_cmd(padapter);
r8712_ind_disconnect(padapter);
r8712_free_assoc_resources(padapter);
}
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
return true;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
larry finger | larry finger | 73 | 100.00% | 1 | 100.00% |
| Total | 73 | 100.00% | 1 | 100.00% |
u8 r8712_set_802_11_bssid_list_scan(struct _adapter *padapter)
{
struct mlme_priv *pmlmepriv = NULL;
unsigned long irqL;
u8 ret = true;
if (!padapter)
return false;
pmlmepriv = &padapter->mlmepriv;
if (!padapter->hw_init_completed)
return false;
spin_lock_irqsave(&pmlmepriv->lock, irqL);
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING) ||
pmlmepriv->sitesurveyctrl.traffic_busy) {
/* Scan or linking is in progress, do nothing. */
ret = (u8)check_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
} else {
r8712_free_network_queue(padapter);
ret = r8712_sitesurvey_cmd(padapter, NULL);
}
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
larry finger | larry finger | 121 | 98.37% | 1 | 50.00% |
tapasweni pathak | tapasweni pathak | 2 | 1.63% | 1 | 50.00% |
| Total | 123 | 100.00% | 2 | 100.00% |
u8 r8712_set_802_11_authentication_mode(struct _adapter *padapter,
enum NDIS_802_11_AUTHENTICATION_MODE authmode)
{
struct security_priv *psecuritypriv = &padapter->securitypriv;
u8 ret;
psecuritypriv->ndisauthtype = authmode;
if (psecuritypriv->ndisauthtype > 3)
psecuritypriv->AuthAlgrthm = 2; /* 802.1x */
if (r8712_set_auth(padapter, psecuritypriv) == _SUCCESS)
ret = true;
else
ret = false;
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
larry finger | larry finger | 71 | 100.00% | 1 | 100.00% |
| Total | 71 | 100.00% | 1 | 100.00% |
u8 r8712_set_802_11_add_wep(struct _adapter *padapter,
struct NDIS_802_11_WEP *wep)
{
sint keyid;
struct security_priv *psecuritypriv = &padapter->securitypriv;
keyid = wep->KeyIndex & 0x3fffffff;
if (keyid >= WEP_KEYS)
return false;
switch (wep->KeyLength) {
case 5:
psecuritypriv->PrivacyAlgrthm = _WEP40_;
break;
case 13:
psecuritypriv->PrivacyAlgrthm = _WEP104_;
break;
default:
psecuritypriv->PrivacyAlgrthm = _NO_PRIVACY_;
break;
}
memcpy(psecuritypriv->DefKey[keyid].skey, &wep->KeyMaterial,
wep->KeyLength);
psecuritypriv->DefKeylen[keyid] = wep->KeyLength;
psecuritypriv->PrivacyKeyIndex = keyid;
if (r8712_set_key(padapter, psecuritypriv, keyid) == _FAIL)
return false;
return _SUCCESS;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
larry finger | larry finger | 138 | 100.00% | 1 | 100.00% |
| Total | 138 | 100.00% | 1 | 100.00% |
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
larry finger | larry finger | 1551 | 97.36% | 1 | 9.09% |
jeff chua | jeff chua | 9 | 0.56% | 1 | 9.09% |
james a shackleford | james a shackleford | 9 | 0.56% | 3 | 27.27% |
tapasweni pathak | tapasweni pathak | 8 | 0.50% | 1 | 9.09% |
wei yongjun | wei yongjun | 6 | 0.38% | 1 | 9.09% |
vaishali thakkar | vaishali thakkar | 6 | 0.38% | 1 | 9.09% |
luis de bethencourt | luis de bethencourt | 2 | 0.13% | 1 | 9.09% |
ali bahar | ali bahar | 1 | 0.06% | 1 | 9.09% |
justin mattock | justin mattock | 1 | 0.06% | 1 | 9.09% |
| Total | 1593 | 100.00% | 11 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.