2013-05-08 21:45:39 +00:00
/******************************************************************************
*
* Copyright ( c ) 2007 - 2012 Realtek Corporation . All rights reserved .
2014-12-19 06:59:46 +00:00
*
2013-05-08 21:45:39 +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 .
*
* You should have received a copy of the GNU General Public License along with
* this program ; if not , write to the Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 , USA
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# define _RTW_IOCTL_SET_C_
2014-12-11 21:15:04 +00:00
# include <drv_conf.h>
2013-05-08 21:45:39 +00:00
# include <osdep_service.h>
# include <drv_types.h>
# include <rtw_ioctl_set.h>
# include <hal_intf.h>
# include <usb_osintf.h>
# include <usb_ops.h>
2014-12-28 17:13:03 +00:00
void indicate_wx_scan_complete_event ( struct adapter * padapter ) ;
2013-05-08 21:45:39 +00:00
# define IS_MAC_ADDRESS_BROADCAST(addr) \
2014-12-11 21:15:04 +00:00
( \
( ( addr [ 0 ] = = 0xff ) & & ( addr [ 1 ] = = 0xff ) & & \
2013-05-08 21:45:39 +00:00
( addr [ 2 ] = = 0xff ) & & ( addr [ 3 ] = = 0xff ) & & \
2014-12-29 02:13:24 +00:00
( addr [ 4 ] = = 0xff ) & & ( addr [ 5 ] = = 0xff ) ) ? true : false \
2013-05-08 21:45:39 +00:00
)
2014-12-11 21:15:04 +00:00
u8 rtw_validate_bssid ( u8 * bssid )
{
2014-12-29 02:13:24 +00:00
u8 ret = true ;
2014-12-11 21:15:04 +00:00
if ( is_zero_mac_addr ( bssid )
| | is_broadcast_mac_addr ( bssid )
| | is_multicast_mac_addr ( bssid )
2014-12-19 06:59:46 +00:00
) {
2014-12-29 02:13:24 +00:00
ret = false ;
2014-12-11 21:15:04 +00:00
}
return ret ;
}
2015-03-14 23:14:05 +00:00
u8 rtw_validate_ssid ( struct ndis_802_11_ssid * ssid )
2013-05-08 21:45:39 +00:00
{
u8 i ;
2015-08-15 18:19:16 +00:00
u8 ret = true ;
2014-12-11 21:15:04 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-08 21:45:39 +00:00
if ( ssid - > SsidLength > 32 ) {
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " ssid length >32 \n " ) ) ;
2015-08-15 18:19:16 +00:00
ret = false ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-11 21:15:04 +00:00
# ifdef CONFIG_VALIDATE_SSID
2015-08-15 18:06:32 +00:00
for ( i = 0 ; i < ssid - > SsidLength ; i + + )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* wifi, printable ascii code must be supported */
2015-08-15 18:24:16 +00:00
if ( ! ( ( ssid - > Ssid [ i ] > = 0x20 ) & & ( ssid - > Ssid [ i ] < = 0x7e ) ) ) {
2013-05-08 21:45:39 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " ssid has nonprintabl ascii \n " ) ) ;
2015-08-15 18:19:16 +00:00
ret = false ;
2013-05-08 21:45:39 +00:00
break ;
}
}
2014-12-11 21:15:04 +00:00
# endif /* CONFIG_VALIDATE_SSID */
2013-05-08 21:45:39 +00:00
2014-12-19 06:59:46 +00:00
exit :
2014-12-11 21:15:04 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-08 21:45:39 +00:00
return ret ;
}
2014-12-17 23:13:53 +00:00
u8 rtw_do_join ( struct adapter * padapter ) ;
u8 rtw_do_join ( struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
struct list_head * plist , * phead ;
2014-12-11 21:15:04 +00:00
u8 * pibss = NULL ;
2013-05-08 21:45:39 +00:00
struct mlme_priv * pmlmepriv = & ( padapter - > mlmepriv ) ;
2015-03-16 13:54:18 +00:00
struct __queue * queue = & ( pmlmepriv - > scanned_queue ) ;
2015-08-15 18:19:16 +00:00
u8 ret = _SUCCESS ;
2014-12-11 21:15:04 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-08 21:45:39 +00:00
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & ( pmlmepriv - > scanned_queue . lock ) ) ;
2013-05-08 21:45:39 +00:00
phead = get_list_head ( queue ) ;
plist = get_next ( phead ) ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " \n rtw_do_join: phead = %p; plist = %p \n \n \n " , phead , plist ) ) ;
2013-05-08 21:45:39 +00:00
pmlmepriv - > cur_network . join_res = - 2 ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
set_fwstate ( pmlmepriv , _FW_UNDER_LINKING ) ;
pmlmepriv - > pscanned = plist ;
2014-12-29 02:13:24 +00:00
pmlmepriv - > to_join = true ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
if ( _rtw_queue_empty ( queue ) = = true )
2014-12-19 06:59:46 +00:00
{
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & ( pmlmepriv - > scanned_queue . lock ) ) ;
2013-05-08 21:45:39 +00:00
_clr_fwstate_ ( pmlmepriv , _FW_UNDER_LINKING ) ;
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* when set_ssid/set_bssid for rtw_do_join(), but scanning queue is empty */
/* we try to issue sitesurvey firstly */
2014-12-19 06:59:46 +00:00
2014-12-29 02:13:24 +00:00
if ( pmlmepriv - > LinkDetectInfo . bBusyTraffic = = false
2014-12-11 21:15:04 +00:00
| | rtw_to_roaming ( padapter ) > 0
)
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " rtw_do_join(): site survey if scanned_queue is empty \n . " ) ) ;
2015-02-19 21:34:32 +00:00
/* submit site_survey_cmd */
2015-08-15 18:19:16 +00:00
if ( _SUCCESS ! = ( ret = rtw_sitesurvey_cmd ( padapter , & pmlmepriv - > assoc_ssid , 1 , NULL , 0 ) ) ) {
2014-12-29 02:13:24 +00:00
pmlmepriv - > to_join = false ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " rtw_do_join(): site survey return error \n . " ) ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
}
else
{
2014-12-29 02:13:24 +00:00
pmlmepriv - > to_join = false ;
2013-05-08 21:45:39 +00:00
ret = _FAIL ;
}
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
goto exit ;
2014-12-19 06:59:46 +00:00
}
else
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
int select_ret ;
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & ( pmlmepriv - > scanned_queue . lock ) ) ;
2015-08-15 18:19:16 +00:00
if ( ( select_ret = rtw_select_and_join_from_scanned_queue ( pmlmepriv ) ) = = _SUCCESS )
2014-12-11 21:15:04 +00:00
{
2014-12-29 02:13:24 +00:00
pmlmepriv - > to_join = false ;
2013-05-08 21:45:39 +00:00
_set_timer ( & pmlmepriv - > assoc_timer , MAX_JOIN_TIMEOUT ) ;
2014-12-11 21:15:04 +00:00
}
2014-12-19 06:59:46 +00:00
else
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
if ( check_fwstate ( pmlmepriv , WIFI_ADHOC_STATE ) = = true )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* submit createbss_cmd to change to a ADHOC_MASTER */
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* pmlmepriv->lock has been acquired by caller... */
2015-03-07 00:26:23 +00:00
struct wlan_bssid_ex * pdev_network = & ( padapter - > registrypriv . dev_network ) ;
2013-05-08 21:45:39 +00:00
pmlmepriv - > fw_state = WIFI_ADHOC_MASTER_STATE ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
pibss = padapter - > registrypriv . dev_network . MacAddress ;
2015-03-14 23:14:05 +00:00
memset ( & pdev_network - > Ssid , 0 , sizeof ( struct ndis_802_11_ssid ) ) ;
memcpy ( & pdev_network - > Ssid , & pmlmepriv - > assoc_ssid , sizeof ( struct ndis_802_11_ssid ) ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
rtw_update_registrypriv_dev_network ( padapter ) ;
rtw_generate_random_ibss ( pibss ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( rtw_createbss_cmd ( padapter ) ! = _SUCCESS )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " ***Error =>do_goin: rtw_createbss_cmd status FAIL*** \n " ) ) ;
2014-12-29 02:13:24 +00:00
ret = false ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-29 02:13:24 +00:00
pmlmepriv - > to_join = false ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " ***Error => rtw_select_and_join_from_scanned_queue FAIL under STA_Mode*** \n " ) ) ;
2014-12-11 21:15:04 +00:00
2014-12-29 02:00:11 +00:00
} else {
2015-02-19 21:34:32 +00:00
/* can't associate ; reset under-linking */
2013-05-08 21:45:39 +00:00
_clr_fwstate_ ( pmlmepriv , _FW_UNDER_LINKING ) ;
2015-02-19 21:34:32 +00:00
/* when set_ssid/set_bssid for rtw_do_join(), but there are no desired bss in scanning queue */
/* we try to issue sitesurvey firstly */
2015-08-15 18:19:16 +00:00
if ( pmlmepriv - > LinkDetectInfo . bBusyTraffic = = false
2014-12-11 21:15:04 +00:00
| | rtw_to_roaming ( padapter ) > 0
)
{
2015-08-15 18:00:19 +00:00
/* DBG_871X("rtw_do_join() when no desired bss in scanning queue\n"); */
2015-08-15 18:24:16 +00:00
if ( _SUCCESS ! = ( ret = rtw_sitesurvey_cmd ( padapter , & pmlmepriv - > assoc_ssid , 1 , NULL , 0 ) ) ) {
2014-12-29 02:13:24 +00:00
pmlmepriv - > to_join = false ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " do_join(): site survey return error \n . " ) ) ;
2014-12-11 21:15:04 +00:00
}
2014-12-19 06:59:46 +00:00
}
2014-12-11 21:15:04 +00:00
else
{
2013-05-08 21:45:39 +00:00
ret = _FAIL ;
2014-12-29 02:13:24 +00:00
pmlmepriv - > to_join = false ;
2013-05-08 21:45:39 +00:00
}
}
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2013-05-19 04:28:07 +00:00
2014-12-11 21:15:04 +00:00
}
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
exit :
2015-01-26 22:20:25 +00:00
;
2014-12-19 06:59:46 +00:00
return ret ;
2013-05-08 21:45:39 +00:00
}
2014-12-17 23:13:53 +00:00
u8 rtw_set_802_11_bssid ( struct adapter * padapter , u8 * bssid )
2014-12-19 06:59:46 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
2015-08-15 18:19:16 +00:00
u8 status = _SUCCESS ;
2014-12-11 21:15:04 +00:00
u32 cur_time = 0 ;
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
DBG_871X_LEVEL ( _drv_always_ , " set bssid:%pM \n " , bssid ) ;
2015-08-15 18:22:58 +00:00
if ( ( bssid [ 0 ] = = 0x00 & & bssid [ 1 ] = = 0x00 & & bssid [ 2 ] = = 0x00 & & bssid [ 3 ] = = 0x00 & & bssid [ 4 ] = = 0x00 & & bssid [ 5 ] = = 0x00 ) | |
( bssid [ 0 ] = = 0xFF & & bssid [ 1 ] = = 0xFF & & bssid [ 2 ] = = 0xFF & & bssid [ 3 ] = = 0xFF & & bssid [ 4 ] = = 0xFF & & bssid [ 5 ] = = 0xFF ) )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
status = _FAIL ;
goto exit ;
}
2014-12-19 06:59:46 +00:00
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & pmlmepriv - > lock ) ;
2013-05-19 04:28:07 +00:00
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
DBG_871X ( " Set BSSID under fw_state =0x%08x \n " , get_fwstate ( pmlmepriv ) ) ;
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , _FW_UNDER_SURVEY ) = = true ) {
2013-05-08 21:45:39 +00:00
goto handle_tkip_countermeasure ;
2014-12-29 02:13:24 +00:00
} else if ( check_fwstate ( pmlmepriv , _FW_UNDER_LINKING ) = = true ) {
2013-05-08 21:45:39 +00:00
goto release_mlme_lock ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , _FW_LINKED | WIFI_ADHOC_MASTER_STATE ) = = true )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE \n " ) ) ;
2014-12-29 02:13:24 +00:00
if ( _rtw_memcmp ( & pmlmepriv - > cur_network . network . MacAddress , bssid , ETH_ALEN ) = = true )
2014-12-19 06:59:46 +00:00
{
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , WIFI_STATION_STATE ) = = false )
2015-02-19 21:34:32 +00:00
goto release_mlme_lock ; /* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */
2013-05-08 21:45:39 +00:00
} else {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " Set BSSID not the same bssid \n " ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " set_bssid = " MAC_FMT " \n " , MAC_ARG ( bssid ) ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " cur_bssid = " MAC_FMT " \n " , MAC_ARG ( pmlmepriv - > cur_network . network . MacAddress ) ) ) ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
rtw_disassoc_cmd ( padapter , 0 , true ) ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , _FW_LINKED ) = = true )
2013-05-08 21:45:39 +00:00
rtw_indicate_disconnect ( padapter ) ;
rtw_free_assoc_resources ( padapter , 1 ) ;
2014-12-29 02:13:24 +00:00
if ( ( check_fwstate ( pmlmepriv , WIFI_ADHOC_MASTER_STATE ) = = true ) ) {
2013-05-08 21:45:39 +00:00
_clr_fwstate_ ( pmlmepriv , WIFI_ADHOC_MASTER_STATE ) ;
set_fwstate ( pmlmepriv , WIFI_ADHOC_STATE ) ;
2014-12-19 06:59:46 +00:00
}
2013-05-08 21:45:39 +00:00
}
}
handle_tkip_countermeasure :
2014-12-11 21:15:04 +00:00
if ( rtw_handle_tkip_countermeasure ( padapter , __func__ ) = = _FAIL ) {
status = _FAIL ;
goto release_mlme_lock ;
2013-05-08 21:45:39 +00:00
}
2015-02-19 20:50:04 +00:00
memcpy ( & pmlmepriv - > assoc_bssid , bssid , ETH_ALEN ) ;
2015-08-15 18:19:16 +00:00
pmlmepriv - > assoc_by_bssid = true ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , _FW_UNDER_SURVEY ) = = true ) {
pmlmepriv - > to_join = true ;
2014-12-11 21:15:04 +00:00
}
else {
2013-05-08 21:45:39 +00:00
status = rtw_do_join ( padapter ) ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
release_mlme_lock :
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & pmlmepriv - > lock ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
exit :
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ ,
2015-08-15 18:19:16 +00:00
( " rtw_set_802_11_bssid: status =%d \n " , status ) ) ;
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-19 04:28:07 +00:00
2013-05-08 21:45:39 +00:00
return status ;
}
2015-03-14 23:14:05 +00:00
u8 rtw_set_802_11_ssid ( struct adapter * padapter , struct ndis_802_11_ssid * ssid )
2014-12-19 06:59:46 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
2013-05-08 21:45:39 +00:00
u8 status = _SUCCESS ;
u32 cur_time = 0 ;
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
struct wlan_network * pnetwork = & pmlmepriv - > cur_network ;
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
DBG_871X_LEVEL ( _drv_always_ , " set ssid [%s] fw_state =0x%08x \n " ,
2014-12-19 06:59:46 +00:00
ssid - > Ssid , get_fwstate ( pmlmepriv ) ) ;
2013-05-19 04:28:07 +00:00
2015-08-15 18:24:16 +00:00
if ( padapter - > hw_init_completed = = false ) {
2013-05-08 21:45:39 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ ,
2015-08-15 18:19:16 +00:00
( " set_ssid: hw_init_completed ==false =>exit!!! \n " ) ) ;
2013-05-08 21:45:39 +00:00
status = _FAIL ;
goto exit ;
}
2014-12-19 06:59:46 +00:00
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & pmlmepriv - > lock ) ;
2013-05-19 04:28:07 +00:00
2015-08-15 18:19:16 +00:00
DBG_871X ( " Set SSID under fw_state =0x%08x \n " , get_fwstate ( pmlmepriv ) ) ;
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , _FW_UNDER_SURVEY ) = = true ) {
2013-05-08 21:45:39 +00:00
goto handle_tkip_countermeasure ;
2014-12-29 02:13:24 +00:00
} else if ( check_fwstate ( pmlmepriv , _FW_UNDER_LINKING ) = = true ) {
2013-05-08 21:45:39 +00:00
goto release_mlme_lock ;
}
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , _FW_LINKED | WIFI_ADHOC_MASTER_STATE ) = = true )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ ,
( " set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE \n " ) ) ;
if ( ( pmlmepriv - > assoc_ssid . SsidLength = = ssid - > SsidLength ) & &
2014-12-29 02:13:24 +00:00
( _rtw_memcmp ( & pmlmepriv - > assoc_ssid . Ssid , ssid - > Ssid , ssid - > SsidLength ) = = true ) )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:02:34 +00:00
if ( ( check_fwstate ( pmlmepriv , WIFI_STATION_STATE ) = = false ) )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ ,
2015-08-15 18:19:16 +00:00
( " Set SSID is the same ssid, fw_state =0x%08x \n " ,
2013-05-08 21:45:39 +00:00
get_fwstate ( pmlmepriv ) ) ) ;
2015-08-15 18:02:34 +00:00
if ( rtw_is_same_ibss ( padapter , pnetwork ) = = false ) {
2015-02-19 21:34:32 +00:00
/* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */
2014-12-29 02:13:24 +00:00
rtw_disassoc_cmd ( padapter , 0 , true ) ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , _FW_LINKED ) = = true )
2013-05-08 21:45:39 +00:00
rtw_indicate_disconnect ( padapter ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
rtw_free_assoc_resources ( padapter , 1 ) ;
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , WIFI_ADHOC_MASTER_STATE ) = = true ) {
2013-05-08 21:45:39 +00:00
_clr_fwstate_ ( pmlmepriv , WIFI_ADHOC_MASTER_STATE ) ;
set_fwstate ( pmlmepriv , WIFI_ADHOC_STATE ) ;
}
2015-02-25 02:32:00 +00:00
} else {
2015-02-19 21:34:32 +00:00
goto release_mlme_lock ; /* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */
2014-12-11 21:15:04 +00:00
}
2015-02-25 02:32:00 +00:00
} else {
2013-05-08 21:45:39 +00:00
rtw_lps_ctrl_wk_cmd ( padapter , LPS_CTRL_JOINBSS , 1 ) ;
}
2015-02-25 02:32:00 +00:00
} else {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " Set SSID not the same ssid \n " ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " set_ssid =[%s] len =0x%x \n " , ssid - > Ssid , ( unsigned int ) ssid - > SsidLength ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " assoc_ssid =[%s] len =0x%x \n " , pmlmepriv - > assoc_ssid . Ssid , ( unsigned int ) pmlmepriv - > assoc_ssid . SsidLength ) ) ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
rtw_disassoc_cmd ( padapter , 0 , true ) ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , _FW_LINKED ) = = true )
2013-05-08 21:45:39 +00:00
rtw_indicate_disconnect ( padapter ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
rtw_free_assoc_resources ( padapter , 1 ) ;
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , WIFI_ADHOC_MASTER_STATE ) = = true ) {
2013-05-08 21:45:39 +00:00
_clr_fwstate_ ( pmlmepriv , WIFI_ADHOC_MASTER_STATE ) ;
set_fwstate ( pmlmepriv , WIFI_ADHOC_STATE ) ;
}
2014-12-19 06:59:46 +00:00
}
2013-05-08 21:45:39 +00:00
}
handle_tkip_countermeasure :
2014-12-11 21:15:04 +00:00
if ( rtw_handle_tkip_countermeasure ( padapter , __func__ ) = = _FAIL ) {
status = _FAIL ;
goto release_mlme_lock ;
}
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
if ( rtw_validate_ssid ( ssid ) = = false ) {
2014-12-11 21:15:04 +00:00
status = _FAIL ;
goto release_mlme_lock ;
2013-05-08 21:45:39 +00:00
}
2015-03-14 23:14:05 +00:00
memcpy ( & pmlmepriv - > assoc_ssid , ssid , sizeof ( struct ndis_802_11_ssid ) ) ;
2015-08-15 18:19:16 +00:00
pmlmepriv - > assoc_by_bssid = false ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , _FW_UNDER_SURVEY ) = = true ) {
pmlmepriv - > to_join = true ;
2014-12-11 21:15:04 +00:00
}
else {
2013-05-08 21:45:39 +00:00
status = rtw_do_join ( padapter ) ;
}
release_mlme_lock :
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & pmlmepriv - > lock ) ;
2013-05-08 21:45:39 +00:00
exit :
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ ,
2015-08-15 18:19:16 +00:00
( " -rtw_set_802_11_ssid: status =%d \n " , status ) ) ;
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-01 22:31:15 +00:00
2013-05-08 21:45:39 +00:00
return status ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2015-03-14 23:14:05 +00:00
u8 rtw_set_802_11_connect ( struct adapter * padapter , u8 * bssid , struct ndis_802_11_ssid * ssid )
2013-05-08 21:45:39 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
2014-12-11 21:15:04 +00:00
u8 status = _SUCCESS ;
u32 cur_time = 0 ;
2014-12-29 02:13:24 +00:00
bool bssid_valid = true ;
bool ssid_valid = true ;
2014-12-11 21:15:04 +00:00
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
2013-05-19 04:28:07 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-19 04:28:07 +00:00
2014-12-29 02:13:24 +00:00
if ( ! ssid | | rtw_validate_ssid ( ssid ) = = false )
ssid_valid = false ;
2013-05-19 04:28:07 +00:00
2014-12-29 02:13:24 +00:00
if ( ! bssid | | rtw_validate_bssid ( bssid ) = = false )
bssid_valid = false ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
if ( ssid_valid = = false & & bssid_valid = = false ) {
2014-12-11 21:15:04 +00:00
DBG_871X ( FUNC_ADPT_FMT " ssid:%p, ssid_valid:%d, bssid:%p, bssid_valid:%d \n " ,
FUNC_ADPT_ARG ( padapter ) , ssid , ssid_valid , bssid , bssid_valid ) ;
status = _FAIL ;
goto exit ;
}
2015-08-15 18:24:16 +00:00
if ( padapter - > hw_init_completed = = false ) {
2014-12-11 21:15:04 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ ,
2015-08-15 18:19:16 +00:00
( " set_ssid: hw_init_completed ==false =>exit!!! \n " ) ) ;
2014-12-11 21:15:04 +00:00
status = _FAIL ;
goto exit ;
}
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & pmlmepriv - > lock ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
DBG_871X_LEVEL ( _drv_always_ , FUNC_ADPT_FMT " fw_state =0x%08x \n " ,
2014-12-11 21:15:04 +00:00
FUNC_ADPT_ARG ( padapter ) , get_fwstate ( pmlmepriv ) ) ;
2013-05-19 04:28:07 +00:00
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , _FW_UNDER_SURVEY ) = = true ) {
2014-12-11 21:15:04 +00:00
goto handle_tkip_countermeasure ;
2014-12-29 02:13:24 +00:00
} else if ( check_fwstate ( pmlmepriv , _FW_UNDER_LINKING ) = = true ) {
2014-12-11 21:15:04 +00:00
goto release_mlme_lock ;
}
handle_tkip_countermeasure :
if ( rtw_handle_tkip_countermeasure ( padapter , __func__ ) = = _FAIL ) {
status = _FAIL ;
goto release_mlme_lock ;
}
if ( ssid & & ssid_valid )
2015-03-14 23:14:05 +00:00
memcpy ( & pmlmepriv - > assoc_ssid , ssid , sizeof ( struct ndis_802_11_ssid ) ) ;
2014-12-11 21:15:04 +00:00
if ( bssid & & bssid_valid ) {
2015-02-19 20:50:04 +00:00
memcpy ( & pmlmepriv - > assoc_bssid , bssid , ETH_ALEN ) ;
2014-12-29 02:13:24 +00:00
pmlmepriv - > assoc_by_bssid = true ;
2014-12-11 21:15:04 +00:00
}
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , _FW_UNDER_SURVEY ) = = true ) {
pmlmepriv - > to_join = true ;
2014-12-11 21:15:04 +00:00
}
else {
status = rtw_do_join ( padapter ) ;
}
release_mlme_lock :
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & pmlmepriv - > lock ) ;
2014-12-11 21:15:04 +00:00
exit :
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
return status ;
}
2014-12-19 06:59:46 +00:00
u8 rtw_set_802_11_infrastructure_mode ( struct adapter * padapter ,
2015-03-14 23:14:05 +00:00
enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype )
2014-12-11 21:15:04 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
2014-12-11 21:15:04 +00:00
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
struct wlan_network * cur_network = & pmlmepriv - > cur_network ;
2015-03-14 23:14:05 +00:00
enum NDIS_802_11_NETWORK_INFRASTRUCTURE * pold_state = & ( cur_network - > network . InfrastructureMode ) ;
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_notice_ ,
( " +rtw_set_802_11_infrastructure_mode: old =%d new =%d fw_state =0x%08x \n " ,
2014-12-11 21:15:04 +00:00
* pold_state , networktype , get_fwstate ( pmlmepriv ) ) ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( * pold_state ! = networktype )
2014-12-11 21:15:04 +00:00
{
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & pmlmepriv - > lock ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " change mode! " ) ) ;
/* DBG_871X("change mode, old_mode =%d, new_mode =%d, fw_state =0x%x\n", *pold_state, networktype, get_fwstate(pmlmepriv)); */
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
if ( * pold_state = = Ndis802_11APMode ) {
2015-02-19 21:34:32 +00:00
/* change to other mode from Ndis802_11APMode */
2014-12-11 21:15:04 +00:00
cur_network - > join_res = - 1 ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
stop_ap_mode ( padapter ) ;
}
2015-08-15 18:19:16 +00:00
if ( ( check_fwstate ( pmlmepriv , _FW_LINKED ) = = true ) | | ( * pold_state = = Ndis802_11IBSS ) )
2014-12-29 02:13:24 +00:00
rtw_disassoc_cmd ( padapter , 0 , true ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
if ( ( check_fwstate ( pmlmepriv , _FW_LINKED ) = = true ) | |
( check_fwstate ( pmlmepriv , WIFI_ADHOC_MASTER_STATE ) = = true ) )
2013-05-08 21:45:39 +00:00
rtw_free_assoc_resources ( padapter , 1 ) ;
2015-08-15 18:02:34 +00:00
if ( ( * pold_state = = Ndis802_11Infrastructure ) | | ( * pold_state = = Ndis802_11IBSS ) )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:02:34 +00:00
if ( check_fwstate ( pmlmepriv , _FW_LINKED ) = = true )
2014-12-19 06:59:46 +00:00
{
2015-02-19 21:34:32 +00:00
rtw_indicate_disconnect ( padapter ) ; /* will clr Linked_state; before this function, we must have chked whether issue dis-assoc_cmd or not */
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
* pold_state = networktype ;
_clr_fwstate_ ( pmlmepriv , ~ WIFI_NULL_STATE ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:05:44 +00:00
switch ( networktype ) {
2015-02-20 15:52:14 +00:00
case Ndis802_11IBSS :
set_fwstate ( pmlmepriv , WIFI_ADHOC_STATE ) ;
break ;
case Ndis802_11Infrastructure :
set_fwstate ( pmlmepriv , WIFI_STATION_STATE ) ;
break ;
case Ndis802_11APMode :
set_fwstate ( pmlmepriv , WIFI_AP_STATE ) ;
start_ap_mode ( padapter ) ;
/* rtw_indicate_connect(padapter); */
break ;
case Ndis802_11AutoUnknown :
case Ndis802_11InfrastructureMax :
break ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* SecClearAllKeys(adapter); */
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* RT_TRACE(COMP_OID_SET, DBG_LOUD, ("set_infrastructure: fw_state:%x after changing mode\n", */
/* get_fwstate(pmlmepriv) )); */
2014-12-11 21:15:04 +00:00
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & pmlmepriv - > lock ) ;
2013-05-08 21:45:39 +00:00
}
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2014-12-29 02:13:24 +00:00
return true ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
2014-12-17 23:13:53 +00:00
u8 rtw_set_802_11_disassociate ( struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
2014-12-11 21:15:04 +00:00
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
2013-05-08 21:45:39 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-08 21:45:39 +00:00
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & pmlmepriv - > lock ) ;
2014-12-11 21:15:04 +00:00
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , _FW_LINKED ) = = true )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " MgntActrtw_set_802_11_disassociate: rtw_indicate_disconnect \n " ) ) ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
rtw_disassoc_cmd ( padapter , 0 , true ) ;
2013-05-08 21:45:39 +00:00
rtw_indicate_disconnect ( padapter ) ;
2015-02-19 21:34:32 +00:00
/* modify for CONFIG_IEEE80211W, none 11w can use it */
2014-12-11 21:15:04 +00:00
rtw_free_assoc_resources_cmd ( padapter ) ;
2014-12-19 06:59:46 +00:00
rtw_pwr_wakeup ( padapter ) ;
2013-05-08 21:45:39 +00:00
}
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & pmlmepriv - > lock ) ;
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-19 04:28:07 +00:00
2014-12-29 02:13:24 +00:00
return true ;
2013-05-08 21:45:39 +00:00
}
2015-03-14 23:14:05 +00:00
u8 rtw_set_802_11_bssid_list_scan ( struct adapter * padapter , struct ndis_802_11_ssid * pssid , int ssid_max_num )
2014-12-19 06:59:46 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
2015-08-15 18:19:16 +00:00
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
u8 res = true ;
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-19 04:28:07 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " +rtw_set_802_11_bssid_list_scan(), fw_state =%x \n " , get_fwstate ( pmlmepriv ) ) ) ;
2013-05-08 21:45:39 +00:00
if ( padapter = = NULL ) {
2015-08-15 18:19:16 +00:00
res = false ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-08-15 18:24:16 +00:00
if ( padapter - > hw_init_completed = = false ) {
2014-12-29 02:13:24 +00:00
res = false ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " \n ===rtw_set_802_11_bssid_list_scan:hw_init_completed ==false === \n " ) ) ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-19 06:59:46 +00:00
2014-12-29 02:13:24 +00:00
if ( ( check_fwstate ( pmlmepriv , _FW_UNDER_SURVEY | _FW_UNDER_LINKING ) = = true ) | |
( pmlmepriv - > LinkDetectInfo . bBusyTraffic = = true ) )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* Scan or linking is in progress, do nothing. */
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " rtw_set_802_11_bssid_list_scan fail since fw_state = %x \n " , get_fwstate ( pmlmepriv ) ) ) ;
2014-12-29 02:13:24 +00:00
res = true ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:24:16 +00:00
if ( check_fwstate ( pmlmepriv , ( _FW_UNDER_SURVEY | _FW_UNDER_LINKING ) ) = = true ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " \n ###_FW_UNDER_SURVEY|_FW_UNDER_LINKING \n \n " ) ) ;
2013-05-08 21:45:39 +00:00
} else {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " \n ###pmlmepriv->sitesurveyctrl.traffic_busy ==true \n \n " ) ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
} else {
2013-05-08 21:45:39 +00:00
if ( rtw_is_scan_deny ( padapter ) ) {
2014-12-11 21:15:04 +00:00
DBG_871X ( FUNC_ADPT_FMT " : scan deny \n " , FUNC_ADPT_ARG ( padapter ) ) ;
2013-05-08 21:45:39 +00:00
indicate_wx_scan_complete_event ( padapter ) ;
return _SUCCESS ;
}
2014-12-19 06:59:46 +00:00
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & pmlmepriv - > lock ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
res = rtw_sitesurvey_cmd ( padapter , pssid , ssid_max_num , NULL , 0 ) ;
2014-12-19 06:59:46 +00:00
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & pmlmepriv - > lock ) ;
2013-05-08 21:45:39 +00:00
}
exit :
2014-12-19 06:59:46 +00:00
return res ;
2013-05-08 21:45:39 +00:00
}
2015-03-14 23:14:05 +00:00
u8 rtw_set_802_11_authentication_mode ( struct adapter * padapter , enum NDIS_802_11_AUTHENTICATION_MODE authmode )
2013-05-08 21:45:39 +00:00
{
struct security_priv * psecuritypriv = & padapter - > securitypriv ;
int res ;
u8 ret ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " set_802_11_auth.mode(): mode =%x \n " , authmode ) ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
psecuritypriv - > ndisauthtype = authmode ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " rtw_set_802_11_authentication_mode:psecuritypriv->ndisauthtype =%d " , psecuritypriv - > ndisauthtype ) ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( psecuritypriv - > ndisauthtype > 3 )
2015-08-15 18:19:16 +00:00
psecuritypriv - > dot11AuthAlgrthm = dot11AuthAlgrthm_8021X ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
res = rtw_set_auth ( padapter , psecuritypriv ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
if ( res = = _SUCCESS )
ret = true ;
2013-05-08 21:45:39 +00:00
else
2015-08-15 18:19:16 +00:00
ret = false ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
}
2015-08-15 18:24:16 +00:00
u8 rtw_set_802_11_add_wep ( struct adapter * padapter , struct ndis_802_11_wep * wep ) {
2014-12-11 21:15:04 +00:00
u8 bdefaultkey ;
u8 btransmitkey ;
2015-08-15 18:19:16 +00:00
sint keyid , res ;
struct security_priv * psecuritypriv = & ( padapter - > securitypriv ) ;
u8 ret = _SUCCESS ;
2013-05-08 21:45:39 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
bdefaultkey = ( wep - > KeyIndex & 0x40000000 ) > 0 ? false : true ; /* for ??? */
btransmitkey = ( wep - > KeyIndex & 0x80000000 ) > 0 ? true : false ; /* for ??? */
keyid = wep - > KeyIndex & 0x3fffffff ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( keyid > 4 )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " MgntActrtw_set_802_11_add_wep:keyid>4 =>fail \n " ) ) ;
ret = false ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-19 06:59:46 +00:00
2015-08-15 18:05:44 +00:00
switch ( wep - > KeyLength ) {
2015-03-10 16:18:03 +00:00
case 5 :
2015-08-15 18:19:16 +00:00
psecuritypriv - > dot11PrivacyAlgrthm = _WEP40_ ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " MgntActrtw_set_802_11_add_wep:wep->KeyLength =5 \n " ) ) ;
2015-03-10 16:18:03 +00:00
break ;
case 13 :
2015-08-15 18:19:16 +00:00
psecuritypriv - > dot11PrivacyAlgrthm = _WEP104_ ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " MgntActrtw_set_802_11_add_wep:wep->KeyLength =13 \n " ) ) ;
2015-03-10 16:18:03 +00:00
break ;
default :
2015-08-15 18:19:16 +00:00
psecuritypriv - > dot11PrivacyAlgrthm = _NO_PRIVACY_ ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " MgntActrtw_set_802_11_add_wep:wep->KeyLength!=5 or 13 \n " ) ) ;
2015-03-10 16:18:03 +00:00
break ;
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ ,
( " rtw_set_802_11_add_wep:befor memcpy, wep->KeyLength =0x%x wep->KeyIndex =0x%x keyid =%x \n " ,
wep - > KeyLength , wep - > KeyIndex , keyid ) ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
memcpy ( & ( psecuritypriv - > dot11DefKey [ keyid ] . skey [ 0 ] ) , & ( wep - > KeyMaterial ) , wep - > KeyLength ) ;
2014-12-11 21:15:04 +00:00
psecuritypriv - > dot11DefKeylen [ keyid ] = wep - > KeyLength ;
2015-08-15 18:19:16 +00:00
psecuritypriv - > dot11PrivacyKeyIndex = keyid ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " rtw_set_802_11_add_wep:security key material : %x %x %x %x %x %x %x %x %x %x %x %x %x \n " ,
psecuritypriv - > dot11DefKey [ keyid ] . skey [ 0 ] , psecuritypriv - > dot11DefKey [ keyid ] . skey [ 1 ] , psecuritypriv - > dot11DefKey [ keyid ] . skey [ 2 ] ,
psecuritypriv - > dot11DefKey [ keyid ] . skey [ 3 ] , psecuritypriv - > dot11DefKey [ keyid ] . skey [ 4 ] , psecuritypriv - > dot11DefKey [ keyid ] . skey [ 5 ] ,
psecuritypriv - > dot11DefKey [ keyid ] . skey [ 6 ] , psecuritypriv - > dot11DefKey [ keyid ] . skey [ 7 ] , psecuritypriv - > dot11DefKey [ keyid ] . skey [ 8 ] ,
psecuritypriv - > dot11DefKey [ keyid ] . skey [ 9 ] , psecuritypriv - > dot11DefKey [ keyid ] . skey [ 10 ] , psecuritypriv - > dot11DefKey [ keyid ] . skey [ 11 ] ,
2014-12-11 21:15:04 +00:00
psecuritypriv - > dot11DefKey [ keyid ] . skey [ 12 ] ) ) ;
2015-08-15 18:19:16 +00:00
res = rtw_set_key ( padapter , psecuritypriv , keyid , 1 , true ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
if ( res = = _FAIL )
ret = false ;
2013-05-08 21:45:39 +00:00
exit :
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-01 22:31:15 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:24:16 +00:00
u8 rtw_set_802_11_remove_wep ( struct adapter * padapter , u32 keyindex ) {
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
u8 ret = _SUCCESS ;
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-19 04:28:07 +00:00
2015-08-15 18:24:16 +00:00
if ( keyindex > = 0x80000000 | | padapter = = NULL ) {
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
ret = false ;
2013-05-08 21:45:39 +00:00
goto exit ;
2014-12-11 21:15:04 +00:00
}
2014-12-19 06:59:46 +00:00
else
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
int res ;
2015-08-15 18:19:16 +00:00
struct security_priv * psecuritypriv = & ( padapter - > securitypriv ) ;
2015-08-15 18:24:16 +00:00
if ( keyindex < 4 ) {
2014-12-19 06:59:46 +00:00
2015-02-19 20:58:09 +00:00
memset ( & psecuritypriv - > dot11DefKey [ keyindex ] , 0 , 16 ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
res = rtw_set_key ( padapter , psecuritypriv , keyindex , 0 , true ) ;
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
psecuritypriv - > dot11DefKeylen [ keyindex ] = 0 ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
if ( res = = _FAIL )
ret = _FAIL ;
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
}
else
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
exit :
2015-01-26 22:20:25 +00:00
;
2013-05-19 04:28:07 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:24:16 +00:00
u8 rtw_set_802_11_add_key ( struct adapter * padapter , struct ndis_802_11_key * key ) {
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
uint encryptionalgo ;
2014-12-11 21:15:04 +00:00
u8 * pbssid ;
2013-05-08 21:45:39 +00:00
struct sta_info * stainfo ;
2014-12-29 02:13:24 +00:00
u8 bgroup = false ;
2015-02-19 21:34:32 +00:00
u8 bgrouptkey = false ; /* can be remove later */
2015-08-15 18:19:16 +00:00
u8 ret = _SUCCESS ;
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2015-08-15 18:24:16 +00:00
if ( ( ( key - > KeyIndex & 0x80000000 ) = = 0 ) & & ( ( key - > KeyIndex & 0x40000000 ) > 0 ) ) {
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* It is invalid to clear bit 31 and set bit 30. If the miniport driver encounters this combination, */
/* it must fail the request and return NDIS_STATUS_INVALID_DATA. */
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " rtw_set_802_11_add_key: ((key->KeyIndex & 0x80000000) == 0)[=%d] " , ( int ) ( key - > KeyIndex & 0x80000000 ) = = 0 ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " rtw_set_802_11_add_key:((key->KeyIndex & 0x40000000) > 0)[=%d] " , ( int ) ( key - > KeyIndex & 0x40000000 ) > 0 ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_info_ , ( " rtw_set_802_11_add_key: key->KeyIndex =%d \n " , ( int ) key - > KeyIndex ) ) ;
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-08-15 18:02:34 +00:00
if ( key - > KeyIndex & 0x40000000 )
2014-12-19 06:59:46 +00:00
{
2015-02-19 21:34:32 +00:00
/* Pairwise key */
2013-05-19 04:28:07 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " OID_802_11_ADD_KEY: +++++ Pairwise key +++++ \n " ) ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
pbssid = get_bssid ( & padapter - > mlmepriv ) ;
stainfo = rtw_get_stainfo ( & padapter - > stapriv , pbssid ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:24:16 +00:00
if ( ( stainfo ! = NULL ) & & ( padapter - > securitypriv . dot11AuthAlgrthm = = dot11AuthAlgrthm_8021X ) ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " OID_802_11_ADD_KEY:( stainfo!=NULL)&&(Adapter->securitypriv.dot11AuthAlgrthm ==dot11AuthAlgrthm_8021X) \n " ) ) ;
encryptionalgo = stainfo - > dot118021XPrivacy ;
2014-12-11 21:15:04 +00:00
}
2015-08-15 18:27:00 +00:00
else {
2015-08-15 18:22:58 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " OID_802_11_ADD_KEY: stainfo == NULL)||(Adapter->securitypriv.dot11AuthAlgrthm!=dot11AuthAlgrthm_8021X) \n " ) ) ;
2015-08-15 18:19:16 +00:00
encryptionalgo = padapter - > securitypriv . dot11PrivacyAlgrthm ;
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " rtw_set_802_11_add_key: (encryptionalgo ==%d)! \n " , encryptionalgo ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " rtw_set_802_11_add_key: (Adapter->securitypriv.dot11PrivacyAlgrthm ==%d)! \n " , padapter - > securitypriv . dot11PrivacyAlgrthm ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " rtw_set_802_11_add_key: (Adapter->securitypriv.dot11AuthAlgrthm ==%d)! \n " , padapter - > securitypriv . dot11AuthAlgrthm ) ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:24:16 +00:00
if ( ( stainfo ! = NULL ) ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " rtw_set_802_11_add_key: (stainfo->dot118021XPrivacy ==%d)! \n " , stainfo - > dot118021XPrivacy ) ) ;
2014-12-11 21:15:04 +00:00
}
2014-12-19 06:59:46 +00:00
2015-08-15 18:24:16 +00:00
if ( key - > KeyIndex & 0x000000FF ) {
2015-02-19 21:34:32 +00:00
/* The key index is specified in the lower 8 bits by values of zero to 255. */
/* The key index should be set to zero for a Pairwise key, and the driver should fail with */
/* NDIS_STATUS_INVALID_DATA if the lower 8 bits is not zero */
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " key->KeyIndex & 0x000000FF. \n " ) ) ;
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-02-19 21:34:32 +00:00
/* check BSSID */
2015-08-15 18:24:16 +00:00
if ( IS_MAC_ADDRESS_BROADCAST ( key - > BSSID ) = = true ) {
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " MacAddr_isBcst(key->BSSID) \n " ) ) ;
ret = false ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-02-19 21:34:32 +00:00
/* Check key length for TKIP. */
2015-08-15 18:02:34 +00:00
/* if (encryptionAlgorithm == RT_ENC_TKIP_ENCRYPTION && key->KeyLength != 32) */
2015-08-15 18:24:16 +00:00
if ( ( encryptionalgo = = _TKIP_ ) & & ( key - > KeyLength ! = 32 ) ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " TKIP KeyLength:0x%x != 32 \n " , key - > KeyLength ) ) ;
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2015-02-19 21:34:32 +00:00
/* Check key length for AES. */
2015-08-15 18:19:16 +00:00
if ( ( encryptionalgo = = _AES_ ) & & ( key - > KeyLength ! = 16 ) ) {
2015-02-19 21:34:32 +00:00
/* For our supplicant, EAPPkt9x.vxd, cannot differentiate TKIP and AES case. */
2015-08-15 18:02:34 +00:00
if ( key - > KeyLength = = 32 ) {
2014-12-19 06:59:46 +00:00
key - > KeyLength = 16 ;
2013-05-08 21:45:39 +00:00
} else {
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
}
2015-02-19 21:34:32 +00:00
/* Check key length for WEP. For NDTEST, 2005.01.27, by rcnjko. */
2015-03-10 16:18:03 +00:00
if ( ( encryptionalgo = = _WEP40_ & & key - > KeyLength ! = 5 ) | |
2015-08-15 18:19:16 +00:00
( encryptionalgo = = _WEP104_ & & key - > KeyLength ! = 13 ) ) {
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " WEP KeyLength:0x%x != 5 or 13 \n " , key - > KeyLength ) ) ;
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-29 02:13:24 +00:00
bgroup = false ;
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* Check the pairwise key. Added by Annie, 2005-07-06. */
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " ------------------------------------------ \n " ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " [Pairwise Key set] \n " ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " ------------------------------------------ \n " ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " key index: 0x%8x(0x%8x) \n " , key - > KeyIndex , ( key - > KeyIndex & 0x3 ) ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " key Length: %d \n " , key - > KeyLength ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " ------------------------------------------ \n " ) ) ;
2015-03-10 16:18:03 +00:00
} else {
2015-08-15 18:22:58 +00:00
/* Group key - KeyIndex(BIT30 == 0) */
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " OID_802_11_ADD_KEY: +++++ Group key +++++ \n " ) ) ;
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* when add wep key through add key and didn't assigned encryption type before */
2015-08-15 18:22:58 +00:00
if ( ( padapter - > securitypriv . ndisauthtype < = 3 ) & & ( padapter - > securitypriv . dot118021XGrpPrivacy = = 0 ) )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " keylen =%d( Adapter->securitypriv.dot11PrivacyAlgrthm =%x )padapter->securitypriv.dot118021XGrpPrivacy(%x) \n " , key - > KeyLength , padapter - > securitypriv . dot11PrivacyAlgrthm , padapter - > securitypriv . dot118021XGrpPrivacy ) ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:05:44 +00:00
switch ( key - > KeyLength )
2014-12-11 21:15:04 +00:00
{
case 5 :
2015-08-15 18:19:16 +00:00
padapter - > securitypriv . dot11PrivacyAlgrthm = _WEP40_ ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " Adapter->securitypriv.dot11PrivacyAlgrthm = %x key->KeyLength =%u \n " , padapter - > securitypriv . dot11PrivacyAlgrthm , key - > KeyLength ) ) ;
2014-12-11 21:15:04 +00:00
break ;
case 13 :
2015-08-15 18:19:16 +00:00
padapter - > securitypriv . dot11PrivacyAlgrthm = _WEP104_ ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " Adapter->securitypriv.dot11PrivacyAlgrthm = %x key->KeyLength =%u \n " , padapter - > securitypriv . dot11PrivacyAlgrthm , key - > KeyLength ) ) ;
2014-12-11 21:15:04 +00:00
break ;
default :
2015-08-15 18:19:16 +00:00
padapter - > securitypriv . dot11PrivacyAlgrthm = _NO_PRIVACY_ ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " Adapter->securitypriv.dot11PrivacyAlgrthm = %x key->KeyLength =%u \n " , padapter - > securitypriv . dot11PrivacyAlgrthm , key - > KeyLength ) ) ;
2014-12-11 21:15:04 +00:00
break ;
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
encryptionalgo = padapter - > securitypriv . dot11PrivacyAlgrthm ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " Adapter->securitypriv.dot11PrivacyAlgrthm =%x \n " , padapter - > securitypriv . dot11PrivacyAlgrthm ) ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
else
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
encryptionalgo = padapter - > securitypriv . dot118021XGrpPrivacy ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " ( Adapter->securitypriv.dot11PrivacyAlgrthm =%x )encryptionalgo(%x) =padapter->securitypriv.dot118021XGrpPrivacy(%x)keylen =%d \n " , padapter - > securitypriv . dot11PrivacyAlgrthm , encryptionalgo , padapter - > securitypriv . dot118021XGrpPrivacy , key - > KeyLength ) ) ;
2013-05-19 04:28:07 +00:00
2014-12-11 21:15:04 +00:00
}
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
if ( ( check_fwstate ( & padapter - > mlmepriv , WIFI_ADHOC_STATE ) = = true ) & & ( IS_MAC_ADDRESS_BROADCAST ( key - > BSSID ) = = false ) ) {
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " IBSS but BSSID is not Broadcast Address. \n " ) ) ;
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-02-19 21:34:32 +00:00
/* Check key length for TKIP */
2015-08-15 18:19:16 +00:00
if ( ( encryptionalgo = = _TKIP_ ) & & ( key - > KeyLength ! = 32 ) ) {
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " TKIP GTK KeyLength:%u != 32 \n " , key - > KeyLength ) ) ;
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
} else if ( encryptionalgo = = _AES_ & & ( key - > KeyLength ! = 16 & & key - > KeyLength ! = 32 ) ) {
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* Check key length for AES */
2015-08-15 18:19:16 +00:00
/* For NDTEST, we allow keylen =32 in this case. 2005.01.27, by rcnjko. */
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " <=== SetInfo, OID_802_11_ADD_KEY: AES GTK KeyLength:%u != 16 or 32 \n " , key - > KeyLength ) ) ;
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-02-19 21:34:32 +00:00
/* Change the key length for EAPPkt9x.vxd. Added by Annie, 2005-11-03. */
2015-08-15 18:19:16 +00:00
if ( ( encryptionalgo = = _AES_ ) & & ( key - > KeyLength = = 32 ) ) {
2014-12-19 06:59:46 +00:00
key - > KeyLength = 16 ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " AES key length changed: %u \n " , key - > KeyLength ) ) ;
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:02:34 +00:00
if ( key - > KeyIndex & 0x8000000 ) { /* error ??? 0x8000_0000 */
2014-12-29 02:13:24 +00:00
bgrouptkey = true ;
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:19:16 +00:00
if ( ( check_fwstate ( & padapter - > mlmepriv , WIFI_ADHOC_STATE ) = = true ) & & ( check_fwstate ( & padapter - > mlmepriv , _FW_LINKED ) = = true ) )
2014-12-11 21:15:04 +00:00
{
2014-12-29 02:13:24 +00:00
bgrouptkey = true ;
2014-12-11 21:15:04 +00:00
}
2013-05-19 04:28:07 +00:00
2014-12-29 02:13:24 +00:00
bgroup = true ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " ------------------------------------------ \n " ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " [Group Key set] \n " ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " ------------------------------------------ \n " ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " key index: 0x%8x(0x%8x) \n " , key - > KeyIndex , ( key - > KeyIndex & 0x3 ) ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " key Length: %d \n " , key - > KeyLength ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " ------------------------------------------ \n " ) ) ;
2014-12-19 06:59:46 +00:00
}
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* If WEP encryption algorithm, just call rtw_set_802_11_add_wep(). */
2015-08-15 18:19:16 +00:00
if ( ( padapter - > securitypriv . dot11AuthAlgrthm ! = dot11AuthAlgrthm_8021X ) & & ( encryptionalgo = = _WEP40_ | | encryptionalgo = = _WEP104_ ) )
2014-12-11 21:15:04 +00:00
{
2014-12-19 06:59:46 +00:00
u8 ret ;
u32 keyindex ;
2015-03-14 23:14:05 +00:00
u32 len = FIELD_OFFSET ( struct ndis_802_11_key , KeyMaterial ) + key - > KeyLength ;
struct ndis_802_11_wep * wep = & padapter - > securitypriv . ndiswep ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " OID_802_11_ADD_KEY: +++++ WEP key +++++ \n " ) ) ;
2013-05-08 21:45:39 +00:00
wep - > Length = len ;
keyindex = key - > KeyIndex & 0x7fffffff ;
wep - > KeyIndex = keyindex ;
wep - > KeyLength = key - > KeyLength ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " OID_802_11_ADD_KEY:Before memcpy \n " ) ) ;
2013-05-19 04:28:07 +00:00
2015-02-19 20:50:04 +00:00
memcpy ( wep - > KeyMaterial , key - > KeyMaterial , key - > KeyLength ) ;
memcpy ( & ( padapter - > securitypriv . dot11DefKey [ keyindex ] . skey [ 0 ] ) , key - > KeyMaterial , key - > KeyLength ) ;
2013-05-19 04:28:07 +00:00
2014-12-19 06:59:46 +00:00
padapter - > securitypriv . dot11DefKeylen [ keyindex ] = key - > KeyLength ;
2015-08-15 18:19:16 +00:00
padapter - > securitypriv . dot11PrivacyKeyIndex = keyindex ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
ret = rtw_set_802_11_add_wep ( padapter , wep ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
goto exit ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
2015-08-15 18:24:16 +00:00
if ( key - > KeyIndex & 0x20000000 ) {
2015-02-19 21:34:32 +00:00
/* SetRSC */
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " OID_802_11_ADD_KEY: +++++ SetRSC+++++ \n " ) ) ;
2015-08-15 18:02:34 +00:00
if ( bgroup = = true )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
unsigned long long keysrc = key - > KeyRSC & 0x00FFFFFFFFFFFFULL ;
2015-02-19 20:50:04 +00:00
memcpy ( & padapter - > securitypriv . dot11Grprxpn , & keysrc , 8 ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
else
{
2015-08-15 18:19:16 +00:00
unsigned long long keysrc = key - > KeyRSC & 0x00FFFFFFFFFFFFULL ;
2015-02-19 20:50:04 +00:00
memcpy ( & padapter - > securitypriv . dot11Grptxpn , & keysrc , 8 ) ;
2014-12-19 06:59:46 +00:00
}
2013-05-08 21:45:39 +00:00
}
2015-02-19 21:34:32 +00:00
/* Indicate this key idx is used for TX */
/* Save the key in KeyMaterial */
2015-08-15 18:02:34 +00:00
if ( bgroup = = true ) /* Group transmit key */
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
int res ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( bgrouptkey = = true )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:19:16 +00:00
padapter - > securitypriv . dot118021XGrpKeyid = ( u8 ) key - > KeyIndex ;
2014-12-11 21:15:04 +00:00
}
2014-12-19 06:59:46 +00:00
2015-08-15 18:24:16 +00:00
if ( ( key - > KeyIndex & 0x3 ) = = 0 ) {
2013-05-08 21:45:39 +00:00
ret = _FAIL ;
goto exit ;
2014-12-19 06:59:46 +00:00
}
2015-02-19 20:58:09 +00:00
memset ( & padapter - > securitypriv . dot118021XGrpKey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] , 0 , 16 ) ;
memset ( & padapter - > securitypriv . dot118021XGrptxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] , 0 , 16 ) ;
memset ( & padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] , 0 , 16 ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( ( key - > KeyIndex & 0x10000000 ) )
2014-12-11 21:15:04 +00:00
{
2015-02-19 20:50:04 +00:00
memcpy ( & padapter - > securitypriv . dot118021XGrptxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] , key - > KeyMaterial + 16 , 8 ) ;
memcpy ( & padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] , key - > KeyMaterial + 24 , 8 ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " \n rtw_set_802_11_add_key:rx mic :0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x \n " ,
padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] . skey [ 0 ] , padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex - 1 ) & 0x03 ) ] . skey [ 1 ] ,
padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] . skey [ 2 ] , padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex - 1 ) & 0x03 ) ] . skey [ 3 ] ,
padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] . skey [ 4 ] , padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex - 1 ) & 0x03 ) ] . skey [ 5 ] ,
padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] . skey [ 6 ] , padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex - 1 ) & 0x03 ) ] . skey [ 7 ] ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " \n rtw_set_802_11_add_key:set Group mic key!!!!!!!! \n " ) ) ;
2013-05-19 04:28:07 +00:00
2014-12-11 21:15:04 +00:00
}
else
{
2015-02-19 20:50:04 +00:00
memcpy ( & padapter - > securitypriv . dot118021XGrptxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] , key - > KeyMaterial + 24 , 8 ) ;
memcpy ( & padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] , key - > KeyMaterial + 16 , 8 ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " \n rtw_set_802_11_add_key:rx mic :0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x \n " ,
padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] . skey [ 0 ] , padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex - 1 ) & 0x03 ) ] . skey [ 1 ] ,
padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] . skey [ 2 ] , padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex - 1 ) & 0x03 ) ] . skey [ 3 ] ,
padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] . skey [ 4 ] , padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex - 1 ) & 0x03 ) ] . skey [ 5 ] ,
padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] . skey [ 6 ] , padapter - > securitypriv . dot118021XGrprxmickey [ ( u8 ) ( ( key - > KeyIndex - 1 ) & 0x03 ) ] . skey [ 7 ] ) ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " \n rtw_set_802_11_add_key:set Group mic key!!!!!!!! \n " ) ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2015-02-19 21:34:32 +00:00
/* set group key by index */
2015-02-19 20:50:04 +00:00
memcpy ( & padapter - > securitypriv . dot118021XGrpKey [ ( u8 ) ( ( key - > KeyIndex ) & 0x03 ) ] , key - > KeyMaterial , key - > KeyLength ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
key - > KeyIndex = key - > KeyIndex & 0x03 ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
padapter - > securitypriv . binstallGrpkey = true ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
padapter - > securitypriv . bcheck_grpkey = false ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " reset group key " ) ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
res = rtw_set_key ( padapter , & padapter - > securitypriv , key - > KeyIndex , 1 , true ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
if ( res = = _FAIL )
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
}
2015-02-19 21:34:32 +00:00
else /* Pairwise Key */
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
u8 res ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
pbssid = get_bssid ( & padapter - > mlmepriv ) ;
stainfo = rtw_get_stainfo ( & padapter - > stapriv , pbssid ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( stainfo ! = NULL )
2014-12-19 06:59:46 +00:00
{
2015-02-19 21:34:32 +00:00
memset ( & stainfo - > dot118021x_UncstKey , 0 , 16 ) ; /* clear keybuffer */
2014-12-19 06:59:46 +00:00
2015-02-19 20:50:04 +00:00
memcpy ( & stainfo - > dot118021x_UncstKey , key - > KeyMaterial , 16 ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
if ( encryptionalgo = = _TKIP_ )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
padapter - > securitypriv . busetkipkey = false ;
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* _set_timer(&padapter->securitypriv.tkip_timer, 50); */
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " \n ==========_set_timer \n " ) ) ;
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* if TKIP, save the Receive/Transmit MIC key in KeyMaterial[128-255] */
2015-08-15 18:24:16 +00:00
if ( ( key - > KeyIndex & 0x10000000 ) ) {
2015-02-19 20:50:04 +00:00
memcpy ( & stainfo - > dot11tkiptxmickey , key - > KeyMaterial + 16 , 8 ) ;
memcpy ( & stainfo - > dot11tkiprxmickey , key - > KeyMaterial + 24 , 8 ) ;
2013-05-08 21:45:39 +00:00
} else {
2015-02-19 20:50:04 +00:00
memcpy ( & stainfo - > dot11tkiptxmickey , key - > KeyMaterial + 24 , 8 ) ;
memcpy ( & stainfo - > dot11tkiprxmickey , key - > KeyMaterial + 16 , 8 ) ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
}
2015-08-15 18:02:34 +00:00
else if ( encryptionalgo = = _AES_ )
2014-12-19 06:59:46 +00:00
{
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* Set key to CAM through H2C command */
2015-08-15 18:02:34 +00:00
if ( bgrouptkey ) /* never go to here */
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
res = rtw_setstakey_cmd ( padapter , ( unsigned char * ) stainfo , false , true ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " \n rtw_set_802_11_add_key:rtw_setstakey_cmd(group) \n " ) ) ;
2014-12-11 21:15:04 +00:00
}
2015-08-15 18:27:00 +00:00
else {
2015-08-15 18:19:16 +00:00
res = rtw_setstakey_cmd ( padapter , ( unsigned char * ) stainfo , true , true ) ;
RT_TRACE ( _module_rtl871x_ioctl_set_c_ , _drv_err_ , ( " \n rtw_set_802_11_add_key:rtw_setstakey_cmd(unicast) \n " ) ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( res = = false )
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
exit :
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-19 04:28:07 +00:00
2014-12-19 06:59:46 +00:00
return ret ;
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:24:16 +00:00
u8 rtw_set_802_11_remove_key ( struct adapter * padapter , struct ndis_802_11_remove_key * key ) {
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
uint encryptionalgo ;
u8 * pbssid ;
2013-05-08 21:45:39 +00:00
struct sta_info * stainfo ;
2014-12-29 02:13:24 +00:00
u8 bgroup = ( key - > KeyIndex & 0x4000000 ) > 0 ? false : true ;
2013-05-08 21:45:39 +00:00
u8 keyIndex = ( u8 ) key - > KeyIndex & 0x03 ;
2015-08-15 18:19:16 +00:00
u8 ret = _SUCCESS ;
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-19 04:28:07 +00:00
2013-05-08 21:45:39 +00:00
if ( ( key - > KeyIndex & 0xbffffffc ) > 0 ) {
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-29 02:13:24 +00:00
if ( bgroup = = true ) {
2015-08-15 18:19:16 +00:00
encryptionalgo = padapter - > securitypriv . dot118021XGrpPrivacy ;
2015-02-19 21:34:32 +00:00
/* clear group key by index */
/* NdisZeroMemory(Adapter->MgntInfo.SecurityInfo.KeyBuf[keyIndex], MAX_WEP_KEY_LEN); */
/* Adapter->MgntInfo.SecurityInfo.KeyLen[keyIndex] = 0; */
2014-12-19 06:59:46 +00:00
2015-02-19 20:58:09 +00:00
memset ( & padapter - > securitypriv . dot118021XGrpKey [ keyIndex ] , 0 , 16 ) ;
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* \todo Send a H2C Command to Firmware for removing this Key in CAM Entry. */
2013-05-08 21:45:39 +00:00
} else {
2015-08-15 18:19:16 +00:00
pbssid = get_bssid ( & padapter - > mlmepriv ) ;
stainfo = rtw_get_stainfo ( & padapter - > stapriv , pbssid ) ;
2015-08-15 18:24:16 +00:00
if ( stainfo ! = NULL ) {
2015-08-15 18:19:16 +00:00
encryptionalgo = stainfo - > dot118021XPrivacy ;
2013-05-08 21:45:39 +00:00
2015-03-10 16:18:03 +00:00
/* clear key by BSSID */
memset ( & stainfo - > dot118021x_UncstKey , 0 , 16 ) ;
2014-12-11 21:15:04 +00:00
2015-03-10 16:18:03 +00:00
/* \todo Send a H2C Command to Firmware for disable this Key in CAM Entry. */
2015-08-15 18:27:00 +00:00
} else {
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
}
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
exit :
2014-12-29 02:13:24 +00:00
return true ;
2013-05-08 21:45:39 +00:00
}
/*
2014-12-19 06:59:46 +00:00
* rtw_get_cur_max_rate -
2014-12-17 23:13:53 +00:00
* @ adapter : pointer to struct adapter structure
2014-12-19 06:59:46 +00:00
*
2013-05-08 21:45:39 +00:00
* Return 0 or 100 Kbps
*/
2014-12-17 23:13:53 +00:00
u16 rtw_get_cur_max_rate ( struct adapter * adapter )
2013-05-08 21:45:39 +00:00
{
int i = 0 ;
u8 * p ;
u16 rate = 0 , max_rate = 0 ;
struct mlme_ext_priv * pmlmeext = & adapter - > mlmeextpriv ;
struct mlme_ext_info * pmlmeinfo = & ( pmlmeext - > mlmext_info ) ;
struct registry_priv * pregistrypriv = & adapter - > registrypriv ;
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
2015-03-07 00:26:23 +00:00
struct wlan_bssid_ex * pcur_bss = & pmlmepriv - > cur_network . network ;
2015-04-08 18:43:40 +00:00
struct ieee80211_ht_cap * pht_capie ;
2013-05-08 21:45:39 +00:00
u8 rf_type = 0 ;
2015-08-15 18:19:16 +00:00
u8 bw_40MHz = 0 , short_GI_20 = 0 , short_GI_40 = 0 ;
u16 mcs_rate = 0 ;
2014-12-19 06:59:46 +00:00
u32 ht_ielen = 0 ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( ( check_fwstate ( pmlmepriv , _FW_LINKED ) ! = true )
2014-12-29 02:13:24 +00:00
& & ( check_fwstate ( pmlmepriv , WIFI_ADHOC_MASTER_STATE ) ! = true ) )
2013-05-08 21:45:39 +00:00
return 0 ;
if ( pmlmeext - > cur_wireless_mode & ( WIRELESS_11_24N | WIRELESS_11_5N ) ) {
p = rtw_get_ie ( & pcur_bss - > IEs [ 12 ] , _HT_CAPABILITY_IE_ , & ht_ielen , pcur_bss - > IELength - 12 ) ;
2015-08-15 18:02:34 +00:00
if ( p & & ht_ielen > 0 )
2014-12-11 21:15:04 +00:00
{
2015-04-08 18:43:40 +00:00
pht_capie = ( struct ieee80211_ht_cap * ) ( p + 2 ) ;
2014-12-19 06:59:46 +00:00
2015-04-08 18:43:40 +00:00
memcpy ( & mcs_rate , pht_capie - > mcs . rx_mask , 2 ) ;
2013-05-19 04:28:07 +00:00
2015-02-19 21:34:32 +00:00
/* bw_40MHz = (pht_capie->cap_info&IEEE80211_HT_CAP_SUP_WIDTH) ? 1:0; */
/* cur_bwmod is updated by beacon, pmlmeinfo is updated by association response */
2014-12-11 21:15:04 +00:00
bw_40MHz = ( pmlmeext - > cur_bwmode & & ( HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH & pmlmeinfo - > HT_info . infos [ 0 ] ) ) ? 1 : 0 ;
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* short_GI = (pht_capie->cap_info&(IEEE80211_HT_CAP_SGI_20|IEEE80211_HT_CAP_SGI_40)) ? 1:0; */
2015-01-28 05:14:58 +00:00
short_GI_20 = ( le16_to_cpu ( pmlmeinfo - > HT_caps . u . HT_cap_element . HT_caps_info ) & IEEE80211_HT_CAP_SGI_20 ) ? 1 : 0 ;
short_GI_40 = ( le16_to_cpu ( pmlmeinfo - > HT_caps . u . HT_cap_element . HT_caps_info ) & IEEE80211_HT_CAP_SGI_40 ) ? 1 : 0 ;
2013-05-08 21:45:39 +00:00
rtw_hal_get_hwreg ( adapter , HW_VAR_RF_TYPE , ( u8 * ) ( & rf_type ) ) ;
max_rate = rtw_mcs_rate (
rf_type ,
2014-12-19 06:59:46 +00:00
bw_40MHz & ( pregistrypriv - > cbw40_enable ) ,
2013-05-08 21:45:39 +00:00
short_GI_20 ,
short_GI_40 ,
pmlmeinfo - > HT_caps . u . HT_cap_element . MCS_rate
) ;
}
2014-12-19 06:59:46 +00:00
}
2014-12-11 21:15:04 +00:00
else
{
2015-08-15 18:04:12 +00:00
while ( ( pcur_bss - > SupportedRates [ i ] ! = 0 ) & & ( pcur_bss - > SupportedRates [ i ] ! = 0xFF ) )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
rate = pcur_bss - > SupportedRates [ i ] & 0x7F ;
2015-08-15 18:02:34 +00:00
if ( rate > max_rate )
2013-05-08 21:45:39 +00:00
max_rate = rate ;
i + + ;
}
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
max_rate = max_rate * 10 / 2 ;
}
return max_rate ;
}
/*
2014-12-19 06:59:46 +00:00
* rtw_set_scan_mode -
2014-12-17 23:13:53 +00:00
* @ adapter : pointer to struct adapter structure
2014-12-19 06:59:46 +00:00
* @ scan_mode :
*
2013-05-08 21:45:39 +00:00
* Return _SUCCESS or _FAIL
*/
2014-12-17 23:13:53 +00:00
int rtw_set_scan_mode ( struct adapter * adapter , RT_SCAN_TYPE scan_mode )
2013-05-08 21:45:39 +00:00
{
2015-08-15 18:02:34 +00:00
if ( scan_mode ! = SCAN_ACTIVE & & scan_mode ! = SCAN_PASSIVE )
2013-05-08 21:45:39 +00:00
return _FAIL ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
adapter - > mlmepriv . scan_mode = scan_mode ;
return _SUCCESS ;
}
/*
2014-12-19 06:59:46 +00:00
* rtw_set_channel_plan -
2014-12-17 23:13:53 +00:00
* @ adapter : pointer to struct adapter structure
2014-12-19 06:59:46 +00:00
* @ channel_plan :
*
2013-05-08 21:45:39 +00:00
* Return _SUCCESS or _FAIL
*/
2014-12-17 23:13:53 +00:00
int rtw_set_channel_plan ( struct adapter * adapter , u8 channel_plan )
2013-05-08 21:45:39 +00:00
{
2014-12-11 21:15:04 +00:00
struct registry_priv * pregistrypriv = & adapter - > registrypriv ;
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
2015-02-19 21:34:32 +00:00
/* handle by cmd_thread to sync with scan operation */
2013-05-08 21:45:39 +00:00
return rtw_set_chplan_cmd ( adapter , channel_plan , 1 ) ;
}
/*
2014-12-19 06:59:46 +00:00
* rtw_set_country -
2014-12-17 23:13:53 +00:00
* @ adapter : pointer to struct adapter structure
2013-05-08 21:45:39 +00:00
* @ country_code : string of country code
2014-12-19 06:59:46 +00:00
*
2013-05-08 21:45:39 +00:00
* Return _SUCCESS or _FAIL
*/
2014-12-17 23:13:53 +00:00
int rtw_set_country ( struct adapter * adapter , const char * country_code )
2013-05-08 21:45:39 +00:00
{
int channel_plan = RT_CHANNEL_DOMAIN_WORLD_WIDE_5G ;
2014-12-11 21:15:04 +00:00
DBG_871X ( " %s country_code:%s \n " , __func__ , country_code ) ;
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* TODO: should have a table to match country code and RT_CHANNEL_DOMAIN */
/* TODO: should consider 2-character and 3-character country code */
2015-08-15 18:02:34 +00:00
if ( 0 = = strcmp ( country_code , " US " ) )
2013-05-08 21:45:39 +00:00
channel_plan = RT_CHANNEL_DOMAIN_FCC ;
2015-08-15 18:02:34 +00:00
else if ( 0 = = strcmp ( country_code , " EU " ) )
2013-05-08 21:45:39 +00:00
channel_plan = RT_CHANNEL_DOMAIN_ETSI ;
2015-08-15 18:02:34 +00:00
else if ( 0 = = strcmp ( country_code , " JP " ) )
2013-05-08 21:45:39 +00:00
channel_plan = RT_CHANNEL_DOMAIN_MKK ;
2015-08-15 18:02:34 +00:00
else if ( 0 = = strcmp ( country_code , " CN " ) )
2013-05-08 21:45:39 +00:00
channel_plan = RT_CHANNEL_DOMAIN_CHINA ;
2015-08-15 18:02:34 +00:00
else if ( 0 = = strcmp ( country_code , " IN " ) )
2014-12-11 21:15:04 +00:00
channel_plan = RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN ;
2013-05-08 21:45:39 +00:00
else
2014-12-11 21:15:04 +00:00
DBG_871X ( " %s unknown country_code:%s \n " , __FUNCTION__ , country_code ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
return rtw_set_channel_plan ( adapter , channel_plan ) ;
}