⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 encryptionpage.cpp

📁 atmel芯片的Linux驱动程序。很多802.11协议的无限网卡都使用该芯片
💻 CPP
📖 第 1 页 / 共 2 页
字号:
}void CEncryptionPage::UpdateKeyControls( int which_encryption ){	bool enable_wepmode = true;	int keysize = SHORT_WEP_KEY_SIZE;	int hex_multiply = mHexOut ? 2 : 1;	if(which_encryption == WEP_DISABLED) {		enable_wepmode = false;		SetKeyToUse(NONE);	} else if (which_encryption == WEP_128bit) {		keysize = LONG_WEP_KEY_SIZE;	}				for(int i=0; i<4; i++) {		if(enable_wepmode)			mTxKey[i]->SetMaxLength( keysize * hex_multiply );		else	mTxKey[i]->Clear();	}	if( mChAuthType->IsEnabled( ) != enable_wepmode )	{#if 0 // Obsolete		mChWepMode->Enable( enable_wepmode );#endif // 0        		mChAuthType->Enable( enable_wepmode );		mChWepkeyToUse->Enable( enable_wepmode );	}	return;}void CEncryptionPage::OnIdle( wxIdleEvent &event ){	int current_key = mChEncryption->GetSelection( );	if( mLastKey != current_key )	{		switch( mLastKey )		{			// Disabled			case 0:				break;			// 64 bit			// 128 bit			case 1:			case 2:				mKeys[ mLastKey - 1 ][ 0 ] = mTxKey[0]->GetValue( );				mKeys[ mLastKey - 1 ][ 1 ] = mTxKey[1]->GetValue( );				mKeys[ mLastKey - 1 ][ 2 ] = mTxKey[2]->GetValue( );				mKeys[ mLastKey - 1 ][ 3 ] = mTxKey[3]->GetValue( );			default:				break;		}		switch( current_key )		{			// Disabled			case 0:				mTxKey[0]->SetValue( _( "" ) );				mTxKey[1]->SetValue( _( "" ) );				mTxKey[2]->SetValue( _( "" ) );				mTxKey[3]->SetValue( _( "" ) );				break;			// 64 bit			// 128 bit			case 1:			case 2:				mTxKey[0]->SetValue( mKeys[ current_key - 1 ][ 0 ] );				mTxKey[1]->SetValue( mKeys[ current_key - 1 ][ 1 ] );				mTxKey[2]->SetValue( mKeys[ current_key - 1 ][ 2 ] );				mTxKey[3]->SetValue( mKeys[ current_key - 1 ][ 3 ] );				break;			default:				break;		}		mLastKey = current_key;		UpdateKeyControls( current_key );	}	if( mChWepkeyToUse->IsEnabled( ) )	{		SetKeyToUse( mChWepkeyToUse->GetSelection( ) + 1 );	}	else	{		SetKeyToUse( NONE );	}	event.Skip( );	return; }void CEncryptionPage::SetKeyToUse( int whichkey ){	for(int i=0; i<4; i++) 		mTxKey[i]->Enable(whichkey == i+1 ? true : false);	return;}// Higher update levelvoid CEncryptionPage::UpdateWinterPage( ){	CWinterModel *model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL );	CVnetDeviceBase *device = ( CVnetDeviceBase * ) CAccessor::Access( AID_CURRENTDEVICE );	CWepInfoData *data = ( CWepInfoData * ) model->GetChild( MC_WEPINFODATA );	if( device->GetWepInfo( data ) == false )	{		::wxMessageBox( _( "Failed to read WEP info." ), wxT( "Winter" ), wxICON_HAND, ( CWinterFrame * ) CAccessor::Access( AID_FRAME ) );		return;	}	TransferToControls( );	return;}int CEncryptionPage::TestControlValues( ){	return 0;}int CEncryptionPage::TransferToControls( CWinterModel *model ){	int keysize = SHORT_WEP_KEY_SIZE;	//bool hexout = mRbKeyInputTypeHex->GetValue(); 	if( model == NULL )	{		model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL );	}	CWepInfoData *wepinfo_data = ( CWepInfoData * ) model->GetChild( MC_WEPINFODATA );	CWinterStringsProvider *sp = ( CWinterStringsProvider * ) CAccessor::Access( AID_STRINGSPROVIDER );// EncryptionLevel	mChEncryption->SetStringSelection( sp->EncryptionStrings[ ( int ) wepinfo_data->GetEncryptionLevel( ) ] );        if(  ( ( int ) wepinfo_data->GetEncryptionLevel( ) ) == 0 )        {                for( int c = 0; c < 4; c++ )                {                        mTxKey[ c ]->Enable( false );                }                mChWepkeyToUse->Enable( false );                mChAuthType->Enable( false );                return 0;        }#if 0 // Obsolete//WepMode	mChWepMode->SetStringSelection( sp->WepModeStrings[ ( int ) wepinfo_data->GetWepMode( ) ] );#endif // 0//AuthType	mChAuthType->SetStringSelection( sp->AuthTypeStrings[ ( int ) wepinfo_data->GetAuthenticationType( ) ] );//WepKeysToUse	if( ( int ) wepinfo_data->GetWepKeyToUse( ) != 0 )	{#ifdef ATMEL_WLAN		mChWepkeyToUse->SetStringSelection( sp->WepKeysStrings[ ( int ) wepinfo_data->GetWepKeyToUse( ) ] );#else		mChWepkeyToUse->SetStringSelection( sp->WepKeysStrings[ ( int ) wepinfo_data->GetWepKeyToUse( ) - 1 ] );#endif	}	else	{		// XXX: This code is kept so as to correct some differences between PCMCIA and USB devices. Hope these differences do not cause problems somewhere else in the code.		mChWepkeyToUse->SetStringSelection( sp->WepKeysStrings[ 0 ] );	}//WepKeys	UCHAR encryption = mChEncryption->GetSelection( );	if( encryption == WEP_128bit ) {		keysize= LONG_WEP_KEY_SIZE;	}		if( encryption != WEP_DISABLED )	{		wxString keyformat = mHexOut ? wxT("%02X") : wxT("%c");		UCHAR *key = new UCHAR[ keysize + 1 ];		for(int i=0; i<MAX_ENCRYPTION_KEYS; i++)		{			memset( key, 0, keysize + 1 );			memcpy( key, wepinfo_data->GetWepKey( i ), keysize );			wxString temp = wxT("");			for(int j=0; j<keysize; j++) {				if(key[j]=='\0') break;				temp += wxString::Format(keyformat, key[j]);			}				mTxKey[i]->SetValue( temp );			//wxString::Format( keyformat, key ) );		}		delete key;	}		return 0;}int CEncryptionPage::TransferToModel( CWinterModel *model ){	int keysize = SHORT_WEP_KEY_SIZE;	//bool hexout=false;		if( model == NULL )	{		model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL );	}	CWepInfoData *wepinfo_data = ( CWepInfoData * ) model->GetChild( MC_WEPINFODATA );	CWinterStringsProvider *sp = ( CWinterStringsProvider * ) CAccessor::Access( AID_STRINGSPROVIDER );//EncryptionLevel	wepinfo_data->SetEncryptionLevel( sp->EncryptionStrings.Index( mChEncryption->GetStringSelection( ) ) );//WepMode// WepMode is not supported any more. Default it to 0 to avoid undefined// behaviour.	wepinfo_data->SetWepMode( 0 );//AuthType	wepinfo_data->SetAuthenticationType( sp->AuthTypeStrings.Index( mChAuthType->GetStringSelection( ) ) );//WepKeysToUse#ifndef ATMEL_WLAN	wepinfo_data->SetWepKeyToUse( sp->WepKeysStrings.Index( mChWepkeyToUse->GetStringSelection( ) ) + 1 );#else	wepinfo_data->SetWepKeyToUse( sp->WepKeysStrings.Index( mChWepkeyToUse->GetStringSelection( ) ) );#endif//WepKeys	UCHAR encryption = mChEncryption->GetSelection( );	if( encryption == WEP_128bit ) {		keysize= LONG_WEP_KEY_SIZE;	}		//if(mRbKeyInputTypeHex->GetValue()) {//#ifdef ATMEL_WLAN	if ( encryption != WEP_DISABLED ) {		UCHAR *key = new UCHAR[ keysize + 1 ];		for(int i=0; i<MAX_ENCRYPTION_KEYS; i++)		{			wxString tx_key = mTxKey[i]->GetValue();			memset( key, 0, keysize + 1 );			if(mHexOut) {				unsigned long temp;				for (int j=0; j< keysize<<1; j+=2) {					(tx_key.Mid(j,2)).ToULong(&temp, 16);					key[j>>1] = (UCHAR)temp;				}				} else {					strcpy( ( char * ) key, tx_key.c_str( ) );			}			wepinfo_data->SetWepKey( key, i );		}		delete key;	}		return 0;}void CEncryptionPage::OnInputTypeSelect(wxCommandEvent &event){//	::wxMessageBox(test);	TransferToModel();	mHexOut = mRbKeyInputTypeHex->GetValue();	UpdateKeyControls(mChEncryption->GetSelection( ));	TransferToControls();		event.Skip();	return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -