1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#define _MLME_OSDEP_C_
30
31#include "osdep_service.h"
32#include "drv_types.h"
33#include "mlme_osdep.h"
34
35static void sitesurvey_ctrl_handler(void *FunctionContext)
36{
37 struct _adapter *adapter = (struct _adapter *)FunctionContext;
38
39 _r8712_sitesurvey_ctrl_handler(adapter);
40 _set_timer(&adapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
41 3000);
42}
43
44static void join_timeout_handler (void *FunctionContext)
45{
46 struct _adapter *adapter = (struct _adapter *)FunctionContext;
47 _r8712_join_timeout_handler(adapter);
48}
49
50static void _scan_timeout_handler (void *FunctionContext)
51{
52 struct _adapter *adapter = (struct _adapter *)FunctionContext;
53 r8712_scan_timeout_handler(adapter);
54}
55
56static void dhcp_timeout_handler (void *FunctionContext)
57{
58 struct _adapter *adapter = (struct _adapter *)FunctionContext;
59 _r8712_dhcp_timeout_handler(adapter);
60}
61
62static void wdg_timeout_handler (void *FunctionContext)
63{
64 struct _adapter *adapter = (struct _adapter *)FunctionContext;
65
66 _r8712_wdg_timeout_handler(adapter);
67
68 _set_timer(&adapter->mlmepriv.wdg_timer, 2000);
69}
70
71void r8712_init_mlme_timer(struct _adapter *padapter)
72{
73 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
74
75 _init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev,
76 join_timeout_handler, (pmlmepriv->nic_hdl));
77 _init_timer(&(pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer),
78 padapter->pnetdev, sitesurvey_ctrl_handler,
79 (u8 *)(pmlmepriv->nic_hdl));
80 _init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev,
81 _scan_timeout_handler, (pmlmepriv->nic_hdl));
82 _init_timer(&(pmlmepriv->dhcp_timer), padapter->pnetdev,
83 dhcp_timeout_handler, (u8 *)(pmlmepriv->nic_hdl));
84 _init_timer(&(pmlmepriv->wdg_timer), padapter->pnetdev,
85 wdg_timeout_handler, (u8 *)(pmlmepriv->nic_hdl));
86}
87
88void r8712_os_indicate_connect(struct _adapter *adapter)
89{
90 r8712_indicate_wx_assoc_event(adapter);
91 netif_carrier_on(adapter->pnetdev);
92}
93
94static struct RT_PMKID_LIST backupPMKIDList[NUM_PMKID_CACHE];
95void r8712_os_indicate_disconnect(struct _adapter *adapter)
96{
97 u8 backupPMKIDIndex = 0;
98 u8 backupTKIPCountermeasure = 0x00;
99
100 r8712_indicate_wx_disassoc_event(adapter);
101 netif_carrier_off(adapter->pnetdev);
102 if (adapter->securitypriv.AuthAlgrthm == 2) {
103
104
105
106
107
108
109 memset(&backupPMKIDList[0], 0x00, sizeof(
110 struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
111 memcpy(&backupPMKIDList[0], &adapter->securitypriv.
112 PMKIDList[0], sizeof(struct RT_PMKID_LIST) *
113 NUM_PMKID_CACHE);
114 backupPMKIDIndex = adapter->securitypriv.PMKIDIndex;
115 backupTKIPCountermeasure = adapter->securitypriv.
116 btkip_countermeasure;
117 memset((unsigned char *)&adapter->securitypriv, 0,
118 sizeof(struct security_priv));
119 _init_timer(&(adapter->securitypriv.tkip_timer),
120 adapter->pnetdev, r8712_use_tkipkey_handler,
121 adapter);
122
123
124 memcpy(&adapter->securitypriv.PMKIDList[0],
125 &backupPMKIDList[0],
126 sizeof(struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
127 adapter->securitypriv.PMKIDIndex = backupPMKIDIndex;
128 adapter->securitypriv.btkip_countermeasure =
129 backupTKIPCountermeasure;
130 } else {
131 struct security_priv *psec_priv = &adapter->securitypriv;
132
133 psec_priv->AuthAlgrthm = 0;
134 psec_priv->PrivacyAlgrthm = _NO_PRIVACY_;
135 psec_priv->PrivacyKeyIndex = 0;
136 psec_priv->XGrpPrivacy = _NO_PRIVACY_;
137 psec_priv->XGrpKeyid = 1;
138 psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
139 psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
140 psec_priv->wps_phase = false;
141 }
142}
143
144void r8712_report_sec_ie(struct _adapter *adapter, u8 authmode, u8 *sec_ie)
145{
146 uint len;
147 u8 *buff, *p, i;
148 union iwreq_data wrqu;
149
150 buff = NULL;
151 if (authmode == _WPA_IE_ID_) {
152 buff = _malloc(IW_CUSTOM_MAX);
153 if (buff == NULL)
154 return;
155 memset(buff, 0, IW_CUSTOM_MAX);
156 p = buff;
157 p += sprintf(p, "ASSOCINFO(ReqIEs=");
158 len = sec_ie[1] + 2;
159 len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
160 for (i = 0; i < len; i++)
161 p += sprintf(p, "%02x", sec_ie[i]);
162 p += sprintf(p, ")");
163 memset(&wrqu, 0, sizeof(wrqu));
164 wrqu.data.length = p-buff;
165 wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ?
166 wrqu.data.length : IW_CUSTOM_MAX;
167 wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
168 kfree(buff);
169 }
170}
171