2015-08-18 19:03:09 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2019-11-09 10:12:08 +00:00
|
|
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
|
|
|
*
|
2015-08-18 19:03:09 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
2019-11-09 10:12:08 +00:00
|
|
|
*****************************************************************************/
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define _MLME_OSDEP_C_
|
|
|
|
|
|
|
|
#include <drv_types.h>
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef RTK_DMP_PLATFORM
|
|
|
|
void Linkup_workitem_callback(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv = container_of(work, struct mlme_priv, Linkup_workitem);
|
|
|
|
_adapter *padapter = container_of(pmlmepriv, _adapter, mlmepriv);
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12))
|
2015-08-18 19:03:09 +00:00
|
|
|
kobject_uevent(&padapter->pnetdev->dev.kobj, KOBJ_LINKUP);
|
|
|
|
#else
|
|
|
|
kobject_hotplug(&padapter->pnetdev->class_dev.kobj, KOBJ_LINKUP);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Linkdown_workitem_callback(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv = container_of(work, struct mlme_priv, Linkdown_workitem);
|
|
|
|
_adapter *padapter = container_of(pmlmepriv, _adapter, mlmepriv);
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12))
|
2015-08-18 19:03:09 +00:00
|
|
|
kobject_uevent(&padapter->pnetdev->dev.kobj, KOBJ_LINKDOWN);
|
|
|
|
#else
|
|
|
|
kobject_hotplug(&padapter->pnetdev->class_dev.kobj, KOBJ_LINKDOWN);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern void rtw_indicate_wx_assoc_event(_adapter *padapter);
|
|
|
|
extern void rtw_indicate_wx_disassoc_event(_adapter *padapter);
|
|
|
|
|
|
|
|
void rtw_os_indicate_connect(_adapter *adapter)
|
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
|
|
|
|
|
|
|
#ifdef CONFIG_IOCTL_CFG80211
|
2019-11-09 10:12:08 +00:00
|
|
|
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) ||
|
|
|
|
(check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == _TRUE))
|
2015-08-18 19:03:09 +00:00
|
|
|
rtw_cfg80211_ibss_indicate_connect(adapter);
|
|
|
|
else
|
|
|
|
rtw_cfg80211_indicate_connect(adapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* CONFIG_IOCTL_CFG80211 */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
rtw_indicate_wx_assoc_event(adapter);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTW_MESH
|
|
|
|
#if CONFIG_RTW_MESH_CTO_MGATE_CARRIER
|
|
|
|
if (!rtw_mesh_cto_mgate_required(adapter))
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
rtw_netif_carrier_on(adapter->pnetdev);
|
|
|
|
|
|
|
|
if (adapter->pid[2] != 0)
|
2015-08-18 19:03:09 +00:00
|
|
|
rtw_signal_process(adapter->pid[2], SIGALRM);
|
|
|
|
|
|
|
|
#ifdef RTK_DMP_PLATFORM
|
|
|
|
_set_workitem(&adapter->mlmepriv.Linkup_workitem);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void indicate_wx_scan_complete_event(_adapter *padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
void rtw_os_indicate_scan_done(_adapter *padapter, bool aborted)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
|
|
|
#ifdef CONFIG_IOCTL_CFG80211
|
|
|
|
rtw_cfg80211_indicate_scan_done(padapter, aborted);
|
|
|
|
#endif
|
|
|
|
indicate_wx_scan_complete_event(padapter);
|
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
static RT_PMKID_LIST backupPMKIDList[NUM_PMKID_CACHE];
|
|
|
|
void rtw_reset_securitypriv(_adapter *adapter)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
|
|
|
u8 backupPMKIDIndex = 0;
|
|
|
|
u8 backupTKIPCountermeasure = 0x00;
|
|
|
|
u32 backupTKIPcountermeasure_time = 0;
|
2019-11-09 10:12:08 +00:00
|
|
|
/* add for CONFIG_IEEE80211W, none 11w also can use */
|
2015-08-18 19:03:09 +00:00
|
|
|
_irqL irqL;
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
_enter_critical_bh(&adapter->security_key_mutex, &irqL);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { /* 802.1x */
|
|
|
|
/* Added by Albert 2009/02/18 */
|
|
|
|
/* We have to backup the PMK information for WiFi PMK Caching test item. */
|
|
|
|
/* */
|
|
|
|
/* Backup the btkip_countermeasure information. */
|
|
|
|
/* When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */
|
|
|
|
|
2021-10-11 10:07:17 +00:00
|
|
|
memset(&backupPMKIDList[0], 0x00, sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2021-10-12 14:53:20 +00:00
|
|
|
memcpy(&backupPMKIDList[0], &adapter->securitypriv.PMKIDList[0], sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
|
2015-08-18 19:03:09 +00:00
|
|
|
backupPMKIDIndex = adapter->securitypriv.PMKIDIndex;
|
|
|
|
backupTKIPCountermeasure = adapter->securitypriv.btkip_countermeasure;
|
2019-11-09 10:12:08 +00:00
|
|
|
backupTKIPcountermeasure_time = adapter->securitypriv.btkip_countermeasure_time;
|
2021-10-11 10:07:17 +00:00
|
|
|
memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv));
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
/* Added by Albert 2009/02/18 */
|
|
|
|
/* Restore the PMK information to securitypriv structure for the following connection. */
|
2021-10-12 14:53:20 +00:00
|
|
|
memcpy(&adapter->securitypriv.PMKIDList[0], &backupPMKIDList[0], sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
|
2015-08-18 19:03:09 +00:00
|
|
|
adapter->securitypriv.PMKIDIndex = backupPMKIDIndex;
|
|
|
|
adapter->securitypriv.btkip_countermeasure = backupTKIPCountermeasure;
|
2019-11-09 10:12:08 +00:00
|
|
|
adapter->securitypriv.btkip_countermeasure_time = backupTKIPcountermeasure_time;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
|
|
|
|
adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
adapter->securitypriv.extauth_status = WLAN_STATUS_UNSPECIFIED_FAILURE;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
} else { /* reset values in securitypriv */
|
|
|
|
/* if(adapter->mlmepriv.fw_state & WIFI_STATION_STATE) */
|
|
|
|
/* { */
|
|
|
|
struct security_priv *psec_priv = &adapter->securitypriv;
|
|
|
|
|
|
|
|
psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
|
2015-08-18 19:03:09 +00:00
|
|
|
psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
|
|
|
|
psec_priv->dot11PrivacyKeyIndex = 0;
|
|
|
|
|
|
|
|
psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_;
|
|
|
|
psec_priv->dot118021XGrpKeyid = 1;
|
|
|
|
|
|
|
|
psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
|
|
|
|
psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
|
2019-11-09 10:12:08 +00:00
|
|
|
/* } */
|
|
|
|
|
|
|
|
psec_priv->extauth_status = WLAN_STATUS_UNSPECIFIED_FAILURE;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
/* add for CONFIG_IEEE80211W, none 11w also can use */
|
2015-08-18 19:03:09 +00:00
|
|
|
_exit_critical_bh(&adapter->security_key_mutex, &irqL);
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO(FUNC_ADPT_FMT" - End to Disconnect\n", FUNC_ADPT_ARG(adapter));
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
void rtw_os_indicate_disconnect(_adapter *adapter, u16 reason, u8 locally_generated)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
/* RT_PMKID_LIST backupPMKIDList[NUM_PMKID_CACHE]; */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_netif_carrier_off(adapter->pnetdev); /* Do it first for tx broadcast pkt after disconnection issue! */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_IOCTL_CFG80211
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_cfg80211_indicate_disconnect(adapter, reason, locally_generated);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* CONFIG_IOCTL_CFG80211 */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
rtw_indicate_wx_disassoc_event(adapter);
|
|
|
|
|
|
|
|
#ifdef RTK_DMP_PLATFORM
|
|
|
|
_set_workitem(&adapter->mlmepriv.Linkdown_workitem);
|
|
|
|
#endif
|
2019-11-09 10:12:08 +00:00
|
|
|
/* modify for CONFIG_IEEE80211W, none 11w also can use the same command */
|
|
|
|
rtw_reset_securitypriv_cmd(adapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
void rtw_report_sec_ie(_adapter *adapter, u8 authmode, u8 *sec_ie)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
|
|
|
uint len;
|
2019-11-09 10:12:08 +00:00
|
|
|
u8 *buff, *p, i;
|
2015-08-18 19:03:09 +00:00
|
|
|
union iwreq_data wrqu;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buff = NULL;
|
2021-10-21 16:42:12 +00:00
|
|
|
if (authmode == WLAN_EID_VENDOR_SPECIFIC) {
|
2017-05-11 18:35:20 +00:00
|
|
|
|
|
|
|
buff = rtw_zmalloc(IW_CUSTOM_MAX);
|
|
|
|
if (NULL == buff) {
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO(FUNC_ADPT_FMT ": alloc memory FAIL!!\n",
|
|
|
|
FUNC_ADPT_ARG(adapter));
|
2017-05-11 18:35:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
p = buff;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
p += sprintf(p, "ASSOCINFO(ReqIEs=");
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
len = sec_ie[1] + 2;
|
|
|
|
len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
p += sprintf(p, "%02x", sec_ie[i]);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
p += sprintf(p, ")");
|
2017-05-11 18:35:20 +00:00
|
|
|
|
2021-10-11 10:07:17 +00:00
|
|
|
memset(&wrqu, 0, sizeof(wrqu));
|
2017-05-11 18:35:20 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
wrqu.data.length = p - buff;
|
2017-05-11 18:35:20 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? wrqu.data.length : IW_CUSTOM_MAX;
|
2017-05-11 18:35:20 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
#ifndef CONFIG_IOCTL_CFG80211
|
2019-11-09 10:12:08 +00:00
|
|
|
wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
2017-05-11 18:35:20 +00:00
|
|
|
rtw_mfree(buff, IW_CUSTOM_MAX);
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_AP_MODE
|
|
|
|
|
|
|
|
void rtw_indicate_sta_assoc_event(_adapter *padapter, struct sta_info *psta)
|
|
|
|
{
|
|
|
|
union iwreq_data wrqu;
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (psta == NULL)
|
2015-08-18 19:03:09 +00:00
|
|
|
return;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (psta->cmn.aid > pstapriv->max_aid)
|
2015-08-18 19:03:09 +00:00
|
|
|
return;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (pstapriv->sta_aid[psta->cmn.aid - 1] != psta)
|
2015-08-18 19:03:09 +00:00
|
|
|
return;
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
wrqu.addr.sa_family = ARPHRD_ETHER;
|
|
|
|
|
2021-10-12 14:53:20 +00:00
|
|
|
memcpy(wrqu.addr.sa_data, psta->cmn.mac_addr, ETH_ALEN);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
RTW_INFO("+rtw_indicate_sta_assoc_event\n");
|
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
#ifndef CONFIG_IOCTL_CFG80211
|
|
|
|
wireless_send_event(padapter->pnetdev, IWEVREGISTERED, &wrqu, NULL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_indicate_sta_disassoc_event(_adapter *padapter, struct sta_info *psta)
|
|
|
|
{
|
|
|
|
union iwreq_data wrqu;
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (psta == NULL)
|
2015-08-18 19:03:09 +00:00
|
|
|
return;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (psta->cmn.aid > pstapriv->max_aid)
|
2015-08-18 19:03:09 +00:00
|
|
|
return;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (pstapriv->sta_aid[psta->cmn.aid - 1] != psta)
|
2015-08-18 19:03:09 +00:00
|
|
|
return;
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
wrqu.addr.sa_family = ARPHRD_ETHER;
|
|
|
|
|
2021-10-12 14:53:20 +00:00
|
|
|
memcpy(wrqu.addr.sa_data, psta->cmn.mac_addr, ETH_ALEN);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
RTW_INFO("+rtw_indicate_sta_disassoc_event\n");
|
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
#ifndef CONFIG_IOCTL_CFG80211
|
|
|
|
wireless_send_event(padapter->pnetdev, IWEVEXPIRED, &wrqu, NULL);
|
|
|
|
#endif
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_HOSTAPD_MLME
|
|
|
|
|
|
|
|
static int mgnt_xmit_entry(struct sk_buff *skb, struct net_device *pnetdev)
|
|
|
|
{
|
|
|
|
struct hostapd_priv *phostapdpriv = rtw_netdev_priv(pnetdev);
|
|
|
|
_adapter *padapter = (_adapter *)phostapdpriv->padapter;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* RTW_INFO("%s\n", __FUNCTION__); */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
return rtw_hal_hostap_mgnt_xmit_entry(padapter, skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mgnt_netdev_open(struct net_device *pnetdev)
|
|
|
|
{
|
|
|
|
struct hostapd_priv *phostapdpriv = rtw_netdev_priv(pnetdev);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("mgnt_netdev_open: MAC Address:" MAC_FMT "\n", MAC_ARG(pnetdev->dev_addr));
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
init_usb_anchor(&phostapdpriv->anchored);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_netif_wake_queue(pnetdev);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_netif_carrier_on(pnetdev);
|
|
|
|
|
|
|
|
/* rtw_write16(phostapdpriv->padapter, 0x0116, 0x0100); */ /* only excluding beacon */
|
|
|
|
|
|
|
|
return 0;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
static int mgnt_netdev_close(struct net_device *pnetdev)
|
|
|
|
{
|
|
|
|
struct hostapd_priv *phostapdpriv = rtw_netdev_priv(pnetdev);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("%s\n", __FUNCTION__);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
usb_kill_anchored_urbs(&phostapdpriv->anchored);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_netif_carrier_off(pnetdev);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_netif_stop_queue(pnetdev);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* rtw_write16(phostapdpriv->padapter, 0x0116, 0x3f3f); */
|
|
|
|
|
|
|
|
return 0;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29))
|
2015-08-18 19:03:09 +00:00
|
|
|
static const struct net_device_ops rtl871x_mgnt_netdev_ops = {
|
|
|
|
.ndo_open = mgnt_netdev_open,
|
2019-11-09 10:12:08 +00:00
|
|
|
.ndo_stop = mgnt_netdev_close,
|
|
|
|
.ndo_start_xmit = mgnt_xmit_entry,
|
|
|
|
#if 0
|
|
|
|
.ndo_set_mac_address = r871x_net_set_mac_address,
|
|
|
|
.ndo_get_stats = r871x_net_get_stats,
|
|
|
|
.ndo_do_ioctl = r871x_mp_ioctl,
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int hostapd_mode_init(_adapter *padapter)
|
|
|
|
{
|
|
|
|
unsigned char mac[ETH_ALEN];
|
|
|
|
struct hostapd_priv *phostapdpriv;
|
|
|
|
struct net_device *pnetdev;
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
pnetdev = rtw_alloc_etherdev(sizeof(struct hostapd_priv));
|
2015-08-18 19:03:09 +00:00
|
|
|
if (!pnetdev)
|
2019-11-09 10:12:08 +00:00
|
|
|
return -ENOMEM;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* SET_MODULE_OWNER(pnetdev); */
|
|
|
|
ether_setup(pnetdev);
|
|
|
|
|
|
|
|
/* pnetdev->type = ARPHRD_IEEE80211; */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
phostapdpriv = rtw_netdev_priv(pnetdev);
|
|
|
|
phostapdpriv->pmgnt_netdev = pnetdev;
|
2019-11-09 10:12:08 +00:00
|
|
|
phostapdpriv->padapter = padapter;
|
2015-08-18 19:03:09 +00:00
|
|
|
padapter->phostapdpriv = phostapdpriv;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* pnetdev->init = NULL; */
|
|
|
|
|
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29))
|
|
|
|
|
|
|
|
RTW_INFO("register rtl871x_mgnt_netdev_ops to netdev_ops\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
pnetdev->netdev_ops = &rtl871x_mgnt_netdev_ops;
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
pnetdev->open = mgnt_netdev_open;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
pnetdev->stop = mgnt_netdev_close;
|
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
pnetdev->hard_start_xmit = mgnt_xmit_entry;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* pnetdev->set_mac_address = r871x_net_set_mac_address; */
|
|
|
|
|
|
|
|
/* pnetdev->get_stats = r871x_net_get_stats; */
|
|
|
|
|
|
|
|
/* pnetdev->do_ioctl = r871x_mp_ioctl; */
|
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
pnetdev->watchdog_timeo = HZ; /* 1 second timeout */
|
|
|
|
|
|
|
|
/* pnetdev->wireless_handlers = NULL; */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (dev_alloc_name(pnetdev, "mgnt.wlan%d") < 0)
|
|
|
|
RTW_INFO("hostapd_mode_init(): dev_alloc_name, fail!\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* SET_NETDEV_DEV(pnetdev, pintfpriv->udev); */
|
|
|
|
|
|
|
|
|
|
|
|
mac[0] = 0x00;
|
|
|
|
mac[1] = 0xe0;
|
|
|
|
mac[2] = 0x4c;
|
|
|
|
mac[3] = 0x87;
|
|
|
|
mac[4] = 0x11;
|
|
|
|
mac[5] = 0x12;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2021-10-12 14:53:20 +00:00
|
|
|
memcpy(pnetdev->dev_addr, mac, ETH_ALEN);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
rtw_netif_carrier_off(pnetdev);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Tell the network stack we exist */
|
2019-11-09 10:12:08 +00:00
|
|
|
if (register_netdev(pnetdev) != 0) {
|
|
|
|
RTW_INFO("hostapd_mode_init(): register_netdev fail!\n");
|
|
|
|
|
|
|
|
if (pnetdev)
|
2015-08-18 19:03:09 +00:00
|
|
|
rtw_free_netdev(pnetdev);
|
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
return 0;
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void hostapd_mode_unload(_adapter *padapter)
|
|
|
|
{
|
|
|
|
struct hostapd_priv *phostapdpriv = padapter->phostapdpriv;
|
|
|
|
struct net_device *pnetdev = phostapdpriv->pmgnt_netdev;
|
|
|
|
|
|
|
|
unregister_netdev(pnetdev);
|
|
|
|
rtw_free_netdev(pnetdev);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|