qed: Change metadata needed for SPQ entries
[deliverable/linux.git] / drivers / staging / rtl8188eu / os_dep / mlme_linux.c
CommitLineData
a2c60d42
LF
1/******************************************************************************
2 *
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 *
19 ******************************************************************************/
20
21
22#define _MLME_OSDEP_C_
23
24#include <osdep_service.h>
25#include <drv_types.h>
26#include <mlme_osdep.h>
27
a2c60d42
LF
28void rtw_init_mlme_timer(struct adapter *padapter)
29{
30 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
31
28af7ea8
VT
32 setup_timer(&pmlmepriv->assoc_timer, _rtw_join_timeout_handler,
33 (unsigned long)padapter);
34 setup_timer(&pmlmepriv->scan_to_timer, rtw_scan_timeout_handler,
35 (unsigned long)padapter);
36 setup_timer(&pmlmepriv->dynamic_chk_timer,
37 rtw_dynamic_check_timer_handlder, (unsigned long)padapter);
a2c60d42
LF
38}
39
40void rtw_os_indicate_connect(struct adapter *adapter)
41{
a2c60d42
LF
42 rtw_indicate_wx_assoc_event(adapter);
43 netif_carrier_on(adapter->pnetdev);
a2c60d42
LF
44}
45
46void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted)
47{
48 indicate_wx_scan_complete_event(padapter);
49}
50
51static struct rt_pmkid_list backup_pmkid[NUM_PMKID_CACHE];
52
53void rtw_reset_securitypriv(struct adapter *adapter)
54{
55 u8 backup_index = 0;
56 u8 backup_counter = 0x00;
57 u32 backup_time = 0;
58
59 if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
60 /* 802.1x */
61 /* We have to backup the PMK information for WiFi PMK Caching test item. */
62 /* Backup the btkip_countermeasure information. */
63 /* When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */
a2c60d42
LF
64 memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
65 backup_index = adapter->securitypriv.PMKIDIndex;
66 backup_counter = adapter->securitypriv.btkip_countermeasure;
67 backup_time = adapter->securitypriv.btkip_countermeasure_time;
1ce39848 68 memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv));
a2c60d42
LF
69
70 /* Restore the PMK information to securitypriv structure for the following connection. */
71 memcpy(&adapter->securitypriv.PMKIDList[0],
72 &backup_pmkid[0],
73 sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
74 adapter->securitypriv.PMKIDIndex = backup_index;
75 adapter->securitypriv.btkip_countermeasure = backup_counter;
76 adapter->securitypriv.btkip_countermeasure_time = backup_time;
77 adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
78 adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
79 } else {
80 /* reset values in securitypriv */
81 struct security_priv *psec_priv = &adapter->securitypriv;
82
2ff4e79f 83 psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
a2c60d42
LF
84 psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
85 psec_priv->dot11PrivacyKeyIndex = 0;
86 psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_;
87 psec_priv->dot118021XGrpKeyid = 1;
88 psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
89 psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
90 }
91}
92
93void rtw_os_indicate_disconnect(struct adapter *adapter)
94{
a2c60d42
LF
95 netif_carrier_off(adapter->pnetdev); /* Do it first for tx broadcast pkt after disconnection issue! */
96 rtw_indicate_wx_disassoc_event(adapter);
97 rtw_reset_securitypriv(adapter);
a2c60d42
LF
98}
99
100void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
101{
102 uint len;
103 u8 *buff, *p, i;
104 union iwreq_data wrqu;
105
a2c60d42
LF
106 RT_TRACE(_module_mlme_osdep_c_, _drv_info_,
107 ("+rtw_report_sec_ie, authmode=%d\n", authmode));
108 buff = NULL;
109 if (authmode == _WPA_IE_ID_) {
110 RT_TRACE(_module_mlme_osdep_c_, _drv_info_,
111 ("rtw_report_sec_ie, authmode=%d\n", authmode));
112 buff = rtw_malloc(IW_CUSTOM_MAX);
113 if (!buff)
f578b5d3 114 return;
1ce39848 115 memset(buff, 0, IW_CUSTOM_MAX);
a2c60d42
LF
116 p = buff;
117 p += sprintf(p, "ASSOCINFO(ReqIEs =");
118 len = sec_ie[1]+2;
ad8d8cd3 119 len = min_t(uint, len, IW_CUSTOM_MAX);
a2c60d42
LF
120 for (i = 0; i < len; i++)
121 p += sprintf(p, "%02x", sec_ie[i]);
122 p += sprintf(p, ")");
1ce39848 123 memset(&wrqu, 0, sizeof(wrqu));
a2c60d42 124 wrqu.data.length = p-buff;
ad8d8cd3 125 wrqu.data.length = min_t(__u16, wrqu.data.length, IW_CUSTOM_MAX);
a2c60d42
LF
126 wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
127 kfree(buff);
128 }
a2c60d42
LF
129}
130
a2c60d42
LF
131void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta)
132{
28af7ea8
VT
133 setup_timer(&psta->addba_retry_timer, addba_timer_hdl,
134 (unsigned long)psta);
a2c60d42
LF
135}
136
137void init_mlme_ext_timer(struct adapter *padapter)
138{
139 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
140
28af7ea8
VT
141 setup_timer(&pmlmeext->survey_timer, survey_timer_hdl,
142 (unsigned long)padapter);
143 setup_timer(&pmlmeext->link_timer, link_timer_hdl,
144 (unsigned long)padapter);
a2c60d42
LF
145}
146
147#ifdef CONFIG_88EU_AP_MODE
148
149void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *psta)
150{
151 union iwreq_data wrqu;
152 struct sta_priv *pstapriv = &padapter->stapriv;
153
a08cd2b7 154 if (!psta)
a2c60d42
LF
155 return;
156
157 if (psta->aid > NUM_STA)
158 return;
159
160 if (pstapriv->sta_aid[psta->aid - 1] != psta)
161 return;
162
163
164 wrqu.addr.sa_family = ARPHRD_ETHER;
165
166 memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
167
168 DBG_88E("+rtw_indicate_sta_assoc_event\n");
169
170 wireless_send_event(padapter->pnetdev, IWEVREGISTERED, &wrqu, NULL);
171}
172
173void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta)
174{
175 union iwreq_data wrqu;
176 struct sta_priv *pstapriv = &padapter->stapriv;
177
a08cd2b7 178 if (!psta)
a2c60d42
LF
179 return;
180
181 if (psta->aid > NUM_STA)
182 return;
183
184 if (pstapriv->sta_aid[psta->aid - 1] != psta)
185 return;
186
187
188 wrqu.addr.sa_family = ARPHRD_ETHER;
189
190 memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
191
192 DBG_88E("+rtw_indicate_sta_disassoc_event\n");
193
194 wireless_send_event(padapter->pnetdev, IWEVEXPIRED, &wrqu, NULL);
195}
196
197#endif
This page took 0.38124 seconds and 5 git commands to generate.