0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #define _MLME_OSDEP_C_
0018
0019 #include "osdep_service.h"
0020 #include "drv_types.h"
0021 #include "mlme_osdep.h"
0022
0023 static void sitesurvey_ctrl_handler(struct timer_list *t)
0024 {
0025 struct _adapter *adapter =
0026 from_timer(adapter, t,
0027 mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer);
0028
0029 _r8712_sitesurvey_ctrl_handler(adapter);
0030 mod_timer(&adapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
0031 jiffies + msecs_to_jiffies(3000));
0032 }
0033
0034 static void join_timeout_handler (struct timer_list *t)
0035 {
0036 struct _adapter *adapter =
0037 from_timer(adapter, t, mlmepriv.assoc_timer);
0038
0039 _r8712_join_timeout_handler(adapter);
0040 }
0041
0042 static void _scan_timeout_handler (struct timer_list *t)
0043 {
0044 struct _adapter *adapter =
0045 from_timer(adapter, t, mlmepriv.scan_to_timer);
0046
0047 r8712_scan_timeout_handler(adapter);
0048 }
0049
0050 static void dhcp_timeout_handler (struct timer_list *t)
0051 {
0052 struct _adapter *adapter =
0053 from_timer(adapter, t, mlmepriv.dhcp_timer);
0054
0055 _r8712_dhcp_timeout_handler(adapter);
0056 }
0057
0058 static void wdg_timeout_handler (struct timer_list *t)
0059 {
0060 struct _adapter *adapter =
0061 from_timer(adapter, t, mlmepriv.wdg_timer);
0062
0063 r8712_wdg_wk_cmd(adapter);
0064
0065 mod_timer(&adapter->mlmepriv.wdg_timer,
0066 jiffies + msecs_to_jiffies(2000));
0067 }
0068
0069 void r8712_init_mlme_timer(struct _adapter *adapter)
0070 {
0071 struct mlme_priv *mlmepriv = &adapter->mlmepriv;
0072
0073 timer_setup(&mlmepriv->assoc_timer, join_timeout_handler, 0);
0074 timer_setup(&mlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer,
0075 sitesurvey_ctrl_handler, 0);
0076 timer_setup(&mlmepriv->scan_to_timer, _scan_timeout_handler, 0);
0077 timer_setup(&mlmepriv->dhcp_timer, dhcp_timeout_handler, 0);
0078 timer_setup(&mlmepriv->wdg_timer, wdg_timeout_handler, 0);
0079 }
0080
0081 void r8712_os_indicate_connect(struct _adapter *adapter)
0082 {
0083 r8712_indicate_wx_assoc_event(adapter);
0084 netif_carrier_on(adapter->pnetdev);
0085 }
0086
0087 static struct RT_PMKID_LIST backupPMKIDList[NUM_PMKID_CACHE];
0088 void r8712_os_indicate_disconnect(struct _adapter *adapter)
0089 {
0090 u8 backupPMKIDIndex = 0;
0091 u8 backupTKIPCountermeasure = 0x00;
0092
0093 r8712_indicate_wx_disassoc_event(adapter);
0094 netif_carrier_off(adapter->pnetdev);
0095 if (adapter->securitypriv.AuthAlgrthm == 2) {
0096
0097
0098
0099
0100
0101
0102 memcpy(&backupPMKIDList[0],
0103 &adapter->securitypriv.PMKIDList[0],
0104 sizeof(struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
0105 backupPMKIDIndex = adapter->securitypriv.PMKIDIndex;
0106 backupTKIPCountermeasure =
0107 adapter->securitypriv.btkip_countermeasure;
0108 memset((unsigned char *)&adapter->securitypriv, 0,
0109 sizeof(struct security_priv));
0110 timer_setup(&adapter->securitypriv.tkip_timer,
0111 r8712_use_tkipkey_handler, 0);
0112
0113
0114
0115 memcpy(&adapter->securitypriv.PMKIDList[0],
0116 &backupPMKIDList[0],
0117 sizeof(struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
0118 adapter->securitypriv.PMKIDIndex = backupPMKIDIndex;
0119 adapter->securitypriv.btkip_countermeasure =
0120 backupTKIPCountermeasure;
0121 } else {
0122 struct security_priv *sec_priv = &adapter->securitypriv;
0123
0124 sec_priv->AuthAlgrthm = 0;
0125 sec_priv->PrivacyAlgrthm = _NO_PRIVACY_;
0126 sec_priv->PrivacyKeyIndex = 0;
0127 sec_priv->XGrpPrivacy = _NO_PRIVACY_;
0128 sec_priv->XGrpKeyid = 1;
0129 sec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
0130 sec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
0131 sec_priv->wps_phase = false;
0132 }
0133 }
0134
0135 void r8712_report_sec_ie(struct _adapter *adapter, u8 authmode, u8 *sec_ie)
0136 {
0137 uint len;
0138 u8 *buff, *p, i;
0139 union iwreq_data wrqu;
0140
0141 buff = NULL;
0142 if (authmode == _WPA_IE_ID_) {
0143 buff = kzalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
0144 if (!buff)
0145 return;
0146 p = buff;
0147 p += sprintf(p, "ASSOCINFO(ReqIEs=");
0148 len = sec_ie[1] + 2;
0149 len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
0150 for (i = 0; i < len; i++)
0151 p += sprintf(p, "%02x", sec_ie[i]);
0152 p += sprintf(p, ")");
0153 memset(&wrqu, 0, sizeof(wrqu));
0154 wrqu.data.length = p - buff;
0155 wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ?
0156 wrqu.data.length : IW_CUSTOM_MAX;
0157 wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
0158 kfree(buff);
0159 }
0160 }