linux/drivers/staging/r8188eu/os_dep/mlme_linux.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0
   2/* Copyright(c) 2007 - 2011 Realtek Corporation. i*/
   3
   4#define _MLME_OSDEP_C_
   5
   6#include "../include/osdep_service.h"
   7#include "../include/drv_types.h"
   8#include "../include/mlme_osdep.h"
   9
  10void rtw_join_timeout_handler (struct timer_list *t)
  11{
  12        struct adapter *adapter = from_timer(adapter, t, mlmepriv.assoc_timer);
  13
  14        _rtw_join_timeout_handler(adapter);
  15}
  16
  17void _rtw_scan_timeout_handler (struct timer_list *t)
  18{
  19        struct adapter *adapter = from_timer(adapter, t, mlmepriv.scan_to_timer);
  20
  21        rtw_scan_timeout_handler(adapter);
  22}
  23
  24static void _dynamic_check_timer_handlder(struct timer_list *t)
  25{
  26        struct adapter *adapter = from_timer(adapter, t, mlmepriv.dynamic_chk_timer);
  27
  28        if (adapter->registrypriv.mp_mode == 1)
  29                return;
  30        rtw_dynamic_check_timer_handlder(adapter);
  31        _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000);
  32}
  33
  34void rtw_init_mlme_timer(struct adapter *padapter)
  35{
  36        struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
  37
  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);
  41}
  42
  43void rtw_os_indicate_connect(struct adapter *adapter)
  44{
  45
  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);
  50
  51}
  52
  53void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted)
  54{
  55        indicate_wx_scan_complete_event(padapter);
  56}
  57
  58static struct rt_pmkid_list backup_pmkid[NUM_PMKID_CACHE];
  59
  60void rtw_reset_securitypriv(struct adapter *adapter)
  61{
  62        u8      backup_index = 0;
  63        u8      backup_counter = 0x00;
  64        u32     backup_time = 0;
  65
  66        if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
  67                /* 802.1x */
  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));
  77
  78                /*  Restore the PMK information to securitypriv structure for the following connection. */
  79                memcpy(&adapter->securitypriv.PMKIDList[0],
  80                            &backup_pmkid[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;
  87        } else {
  88                /* reset values in securitypriv */
  89                struct security_priv *psec_priv = &adapter->securitypriv;
  90
  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;
  98        }
  99}
 100
 101void rtw_os_indicate_disconnect(struct adapter *adapter)
 102{
 103
 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);
 107}
 108
 109void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
 110{
 111        uint    len;
 112        u8      *buff, *p, i;
 113        union iwreq_data wrqu;
 114
 115        buff = NULL;
 116        if (authmode == _WPA_IE_ID_) {
 117                buff = kzalloc(IW_CUSTOM_MAX, GFP_KERNEL);
 118                if (!buff)
 119                        return;
 120                p = buff;
 121                p += sprintf(p, "ASSOCINFO(ReqIEs =");
 122                len = sec_ie[1] + 2;
 123                len =  (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
 124                for (i = 0; i < len; i++)
 125                        p += sprintf(p, "%02x", sec_ie[i]);
 126                p += sprintf(p, ")");
 127                memset(&wrqu, 0, sizeof(wrqu));
 128                wrqu.data.length = p - buff;
 129                wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ?
 130                                   wrqu.data.length : IW_CUSTOM_MAX;
 131                wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
 132                kfree(buff);
 133        }
 134}
 135
 136static void _survey_timer_hdl(struct timer_list *t)
 137{
 138        struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.survey_timer);
 139
 140        survey_timer_hdl(padapter);
 141}
 142
 143static void _link_timer_hdl(struct timer_list *t)
 144{
 145        struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.link_timer);
 146        link_timer_hdl(padapter);
 147}
 148
 149static void _addba_timer_hdl(struct timer_list *t)
 150{
 151        struct sta_info *psta = from_timer(psta, t, addba_retry_timer);
 152        addba_timer_hdl(psta);
 153}
 154
 155void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta)
 156{
 157        timer_setup(&psta->addba_retry_timer, _addba_timer_hdl, 0);
 158}
 159
 160void init_mlme_ext_timer(struct adapter *padapter)
 161{
 162        struct  mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 163
 164        timer_setup(&pmlmeext->survey_timer, _survey_timer_hdl, 0);
 165        timer_setup(&pmlmeext->link_timer, _link_timer_hdl, 0);
 166}
 167
 168#ifdef CONFIG_88EU_AP_MODE
 169
 170void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *psta)
 171{
 172        union iwreq_data wrqu;
 173        struct sta_priv *pstapriv = &padapter->stapriv;
 174
 175        if (!psta)
 176                return;
 177
 178        if (psta->aid > NUM_STA)
 179                return;
 180
 181        if (pstapriv->sta_aid[psta->aid - 1] != psta)
 182                return;
 183
 184        wrqu.addr.sa_family = ARPHRD_ETHER;
 185
 186        memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
 187
 188        DBG_88E("+rtw_indicate_sta_assoc_event\n");
 189
 190        wireless_send_event(padapter->pnetdev, IWEVREGISTERED, &wrqu, NULL);
 191}
 192
 193void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta)
 194{
 195        union iwreq_data wrqu;
 196        struct sta_priv *pstapriv = &padapter->stapriv;
 197
 198        if (!psta)
 199                return;
 200
 201        if (psta->aid > NUM_STA)
 202                return;
 203
 204        if (pstapriv->sta_aid[psta->aid - 1] != psta)
 205                return;
 206
 207        wrqu.addr.sa_family = ARPHRD_ETHER;
 208
 209        memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
 210
 211        DBG_88E("+rtw_indicate_sta_disassoc_event\n");
 212
 213        wireless_send_event(padapter->pnetdev, IWEVEXPIRED, &wrqu, NULL);
 214}
 215
 216#endif
 217