Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / drivers / staging / rtl8723au / os_dep / mlme_linux.c
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  ******************************************************************************/
15
16 #define _MLME_OSDEP_C_
17
18 #include <osdep_service.h>
19 #include <drv_types.h>
20 #include <mlme_osdep.h>
21
22 static struct rt_pmkid_list backupPMKIDList[NUM_PMKID_CACHE];
23
24 void rtw_reset_securitypriv23a(struct rtw_adapter *adapter)
25 {
26         u8      backupPMKIDIndex = 0;
27         u8      backupTKIPCountermeasure = 0x00;
28         unsigned long backupTKIPcountermeasure_time = 0;
29
30         if (adapter->securitypriv.dot11AuthAlgrthm ==
31             dot11AuthAlgrthm_8021X) { /* 802.1x */
32                 /*  We have to backup the PMK information for WiFi PMK
33                  *  Caching test item.
34                  *  Backup the btkip_countermeasure information.
35                  *  When the countermeasure is trigger, the driver have to
36                  *  disconnect with AP for 60 seconds.
37                  */
38                 memcpy(&backupPMKIDList[0], &adapter->securitypriv.PMKIDList[0],
39                        sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
40                 backupPMKIDIndex = adapter->securitypriv.PMKIDIndex;
41                 backupTKIPCountermeasure = adapter->securitypriv.btkip_countermeasure;
42                 backupTKIPcountermeasure_time = adapter->securitypriv.btkip_countermeasure_time;
43
44                 memset((unsigned char *)&adapter->securitypriv, 0,
45                        sizeof (struct security_priv));
46                 /* Restore the PMK information to securitypriv structure
47                  * for the following connection.
48                  */
49                 memcpy(&adapter->securitypriv.PMKIDList[0], &backupPMKIDList[0],
50                        sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
51                 adapter->securitypriv.PMKIDIndex = backupPMKIDIndex;
52                 adapter->securitypriv.btkip_countermeasure = backupTKIPCountermeasure;
53                 adapter->securitypriv.btkip_countermeasure_time = backupTKIPcountermeasure_time;
54
55                 adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
56                 adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
57         } else {  /* reset values in securitypriv */
58                 struct security_priv *psec_priv = &adapter->securitypriv;
59
60                 /* open system */
61                 psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
62                 psec_priv->dot11PrivacyAlgrthm = 0;
63                 psec_priv->dot11PrivacyKeyIndex = 0;
64
65                 psec_priv->dot118021XGrpPrivacy = 0;
66                 psec_priv->dot118021XGrpKeyid = 1;
67
68                 psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
69                 psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
70         }
71 }
72
73 void rtw_os_indicate_disconnect23a(struct rtw_adapter *adapter)
74 {
75         /* Do it first for tx broadcast pkt after disconnection issue! */
76         netif_carrier_off(adapter->pnetdev);
77
78         rtw_cfg80211_indicate_disconnect(adapter);
79
80         rtw_reset_securitypriv23a(adapter);
81 }