1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2007 - 2011 Realtek Corporation. i*/
6 #include <osdep_service.h>
8 #include <mlme_osdep.h>
10 void rtw_join_timeout_handler (struct timer_list *t)
12 struct adapter *adapter = from_timer(adapter, t, mlmepriv.assoc_timer);
14 _rtw_join_timeout_handler(adapter);
17 void _rtw_scan_timeout_handler (struct timer_list *t)
19 struct adapter *adapter = from_timer(adapter, t, mlmepriv.scan_to_timer);
21 rtw_scan_timeout_handler(adapter);
24 static void _dynamic_check_timer_handlder(struct timer_list *t)
26 struct adapter *adapter = from_timer(adapter, t, mlmepriv.dynamic_chk_timer);
28 if (adapter->registrypriv.mp_mode == 1)
30 rtw_dynamic_check_timer_handlder(adapter);
31 _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000);
34 void rtw_init_mlme_timer(struct adapter *padapter)
36 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
38 timer_setup(&pmlmepriv->assoc_timer, rtw_join_timeout_handler, 0);
39 timer_setup(&pmlmepriv->scan_to_timer, _rtw_scan_timeout_handler, 0);
40 timer_setup(&pmlmepriv->dynamic_chk_timer, _dynamic_check_timer_handlder, 0);
43 void rtw_os_indicate_connect(struct adapter *adapter)
46 rtw_indicate_wx_assoc_event(adapter);
47 netif_carrier_on(adapter->pnetdev);
48 if (adapter->pid[2] != 0)
49 rtw_signal_process(adapter->pid[2], SIGALRM);
53 void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted)
55 indicate_wx_scan_complete_event(padapter);
58 static struct rt_pmkid_list backup_pmkid[NUM_PMKID_CACHE];
60 void rtw_reset_securitypriv(struct adapter *adapter)
63 u8 backup_counter = 0x00;
66 if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
68 /* We have to backup the PMK information for WiFi PMK Caching test item. */
69 /* Backup the btkip_countermeasure information. */
70 /* When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */
71 memset(&backup_pmkid[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
72 memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
73 backup_index = adapter->securitypriv.PMKIDIndex;
74 backup_counter = adapter->securitypriv.btkip_countermeasure;
75 backup_time = adapter->securitypriv.btkip_countermeasure_time;
76 memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv));
78 /* Restore the PMK information to securitypriv structure for the following connection. */
79 memcpy(&adapter->securitypriv.PMKIDList[0],
81 sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
82 adapter->securitypriv.PMKIDIndex = backup_index;
83 adapter->securitypriv.btkip_countermeasure = backup_counter;
84 adapter->securitypriv.btkip_countermeasure_time = backup_time;
85 adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
86 adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
88 /* reset values in securitypriv */
89 struct security_priv *psec_priv = &adapter->securitypriv;
91 psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
92 psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
93 psec_priv->dot11PrivacyKeyIndex = 0;
94 psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_;
95 psec_priv->dot118021XGrpKeyid = 1;
96 psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
97 psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
101 void rtw_os_indicate_disconnect(struct adapter *adapter)
104 netif_carrier_off(adapter->pnetdev); /* Do it first for tx broadcast pkt after disconnection issue! */
105 rtw_indicate_wx_disassoc_event(adapter);
106 rtw_reset_securitypriv(adapter);
110 void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
114 union iwreq_data wrqu;
116 RT_TRACE(_module_mlme_osdep_c_, _drv_info_,
117 ("+rtw_report_sec_ie, authmode=%d\n", authmode));
119 if (authmode == _WPA_IE_ID_) {
120 RT_TRACE(_module_mlme_osdep_c_, _drv_info_,
121 ("rtw_report_sec_ie, authmode=%d\n", authmode));
122 buff = rtw_malloc(IW_CUSTOM_MAX);
125 memset(buff, 0, IW_CUSTOM_MAX);
127 p += sprintf(p, "ASSOCINFO(ReqIEs =");
129 len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
130 for (i = 0; i < len; i++)
131 p += sprintf(p, "%02x", sec_ie[i]);
132 p += sprintf(p, ")");
133 memset(&wrqu, 0, sizeof(wrqu));
134 wrqu.data.length = p-buff;
135 wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ?
136 wrqu.data.length : IW_CUSTOM_MAX;
137 wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
142 static void _survey_timer_hdl(struct timer_list *t)
144 struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.survey_timer);
146 survey_timer_hdl(padapter);
149 static void _link_timer_hdl(struct timer_list *t)
151 struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.link_timer);
152 link_timer_hdl(padapter);
155 static void _addba_timer_hdl(struct timer_list *t)
157 struct sta_info *psta = from_timer(psta, t, addba_retry_timer);
158 addba_timer_hdl(psta);
161 void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta)
163 timer_setup(&psta->addba_retry_timer, _addba_timer_hdl, 0);
166 void init_mlme_ext_timer(struct adapter *padapter)
168 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
170 timer_setup(&pmlmeext->survey_timer, _survey_timer_hdl, 0);
171 timer_setup(&pmlmeext->link_timer, _link_timer_hdl, 0);
174 #ifdef CONFIG_88EU_AP_MODE
176 void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *psta)
178 union iwreq_data wrqu;
179 struct sta_priv *pstapriv = &padapter->stapriv;
184 if (psta->aid > NUM_STA)
187 if (pstapriv->sta_aid[psta->aid - 1] != psta)
190 wrqu.addr.sa_family = ARPHRD_ETHER;
192 memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
194 DBG_88E("+rtw_indicate_sta_assoc_event\n");
196 wireless_send_event(padapter->pnetdev, IWEVREGISTERED, &wrqu, NULL);
199 void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta)
201 union iwreq_data wrqu;
202 struct sta_priv *pstapriv = &padapter->stapriv;
207 if (psta->aid > NUM_STA)
210 if (pstapriv->sta_aid[psta->aid - 1] != psta)
213 wrqu.addr.sa_family = ARPHRD_ETHER;
215 memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
217 DBG_88E("+rtw_indicate_sta_disassoc_event\n");
219 wireless_send_event(padapter->pnetdev, IWEVEXPIRED, &wrqu, NULL);