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

📄 instance_networkadapter.cpp

📁 270的linux说明
💻 CPP
字号:
/*

Copyright (c) 2008, Intel Corporation. 

All rights reserved.

 

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:


    * Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation and/or 
other materials provided with the distribution.

    * Neither the name of Intel Corporation nor the names of its contributors 
may be used to endorse or promote products derived from this software without 
specific prior written permission.

 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.

*///==============================================================================// Instance_NetworkAdapter.cpp//// //==============================================================================//#include "stdafx.h"#include "Instance_NetworkAdapter.h"#include "Instance_LinkProtocol.h"#include "define.h"#include "netdev_lib.h"//==============================================================================////	DefaultNetworkAdapterInstanceObject implementation////==============================================================================bool	DefaultNetworkAdapterInstanceObject::Initialize( /*in*/ const IntelMobileString& pszFullInterfaceId ){	_Log(IntelMobileText("DefaultNetworkAdapterInstanceObject::Initialize(%s)"), pszFullInterfaceId.c_str());	// TODO: change the internal key	try	{		Lock();		m_sKey = pszFullInterfaceId;		Unlock();	}	catch(...)	{		Unlock();		THROWIMEXCEPTION("8004308C");	}	// TODO: initialize the static properties' value here	return true;}//==============================================================================DefaultNetworkAdapterInstanceObject::~DefaultNetworkAdapterInstanceObject(){ 	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: DefaultNetworkAdapterInstanceObject::~DefaultNetworkAdapterInstanceObject()") );}//==============================================================================//==============================================================================//// Network Adapter Attributes////==============================================================================//==============================================================================//// These all return the true value.  If there is an error, throw // an appropriate HRESULT.  These need to return the true value// because the override the virtual GetValue() function in the // Property base class.void AdapterLinkClass::GetValueImpl(){ 	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: AdapterLinkclass::GetValueImpl()") );	DefaultNetworkAdapterInstanceObject* pThis = reinterpret_cast<DefaultNetworkAdapterInstanceObject*>(_pThis);	if ( !pThis )		return;	try{		pThis->Lock();		netdev_dev netdev;		if(netdev_get_device(pThis->GetKey().c_str(), netdev) != NETDEV_SUCCESS)		{			throw;		}		netdev_type type;		if(netdev_get_type(netdev, type) != NETDEV_SUCCESS)		{			this->SetNull(true);			return;		}		else		{			if(type == TYPE_802_3)				this->SetValueImpl( NetworkAdapterAdapterLinkEnum::LinkProtocol802_3 );			else if(type == TYPE_802_11)				this->SetValueImpl( NetworkAdapterAdapterLinkEnum::LinkProtocol802_11);			else if(type == TYPE_BLUETOOTH)				this->SetValueImpl( NetworkAdapterAdapterLinkEnum::Bluetooth);			else				this->SetValueImpl( NetworkAdapterAdapterLinkEnum::Unknown);		}		pThis->Unlock();	}catch(...)	{		pThis->Unlock();		THROWIMEXCEPTION("8004308D");	}}//===========================================================================void AutoSenseClass::GetValueImpl(){ 	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: AutoSenseclass::GetValueImpl()") );	//FIXME: hard code there	this->SetValueImpl( true );}//===========================================================================void DescriptionClass::GetValueImpl(){ 	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: Descriptionclass::GetValueImpl()") );	DefaultNetworkAdapterInstanceObject* pThis = reinterpret_cast<DefaultNetworkAdapterInstanceObject*>(_pThis);	if ( !pThis )		return;	try	{		pThis->Lock();		this->SetValueImpl(pThis->GetKey().c_str());		pThis->Unlock();	}	catch(...)	{		pThis->Unlock();		THROWIMEXCEPTION("8004308F");	}	}//=========================================================================void DeviceIdClass::GetValueImpl(){	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: DeviceIdclass::GetValueImpl()") );	DefaultNetworkAdapterInstanceObject* pThis = reinterpret_cast<DefaultNetworkAdapterInstanceObject*>(_pThis);	if ( !pThis )		return;	try{		pThis->Lock();		this->SetValueImpl(pThis->GetKey().c_str());		pThis->Unlock();	}	catch(...)	{		pThis->Unlock();	}}//==========================================================================void FullDeviceIdClass::GetValueImpl(){	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: FullDeviceIdclass::GetValueImpl()") ); // Static, will never have to update this since it was defined in constructor	this->SetNull(true);	}//==========================================================================void IndexClass::GetValueImpl(){	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: Indexclass::GetValueImpl()") );	DefaultNetworkAdapterInstanceObject* pThis = reinterpret_cast<DefaultNetworkAdapterInstanceObject*>(_pThis);	if ( !pThis )		return;	try	{		netdev_dev netdev;		if(netdev_get_device(pThis->GetKey().c_str(), netdev) != NETDEV_SUCCESS)		{			throw;		}		int Index = netdev.index;		pThis->Lock();		if(Index > 0)		{			this->SetValueImpl( Index );		}		else		{			this->SetNull(true);		}		pThis->Unlock();	}	catch(...)	{		pThis->Unlock();		THROWIMEXCEPTION("80043090");	}	}//==========================================================================void ManufacturerClass::GetValueImpl(){ 	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: Manufacturerclass::GetValueImpl()") );	this->SetNull( true );}//==========================================================================void NameClass::GetValueImpl(){ 	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: Nameclass::GetValueImpl()") );	try	{		DefaultNetworkAdapterInstanceObject* pThis = reinterpret_cast<DefaultNetworkAdapterInstanceObject*>(_pThis);		if ( !pThis )			return;		IntelMobileString szTemp = pThis->GetKey();		this->SetValueImpl(szTemp.c_str());		pThis->Unlock();	}	catch(...)	{		Unlock();		THROWIMEXCEPTION("8004308E");	}}//==========================================================================void ConnectionIdClass::GetValueImpl(){ 	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: ConnectionIdclass::GetValueImpl()") );	this->SetNull( true );}//==========================================================================void ConnectionStateClass::GetValueImpl(){ 	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: ConnectionStateclass::GetValueImpl()") );	DefaultNetworkAdapterInstanceObject* pThis = reinterpret_cast<DefaultNetworkAdapterInstanceObject*>(_pThis);	if ( !pThis )		return;	try	{		pThis->Lock();		netdev_dev netdev;		if(netdev_get_device(pThis->GetKey().c_str(), netdev) != NETDEV_SUCCESS)		{			throw;		}		netdev_enabled enabled;		netdev_running running;		netdev_ipaddr ipaddr;				char index = 0;		if(netdev_get_enabled(netdev, enabled) != NETDEV_SUCCESS)		{			this->SetNull(true);			return;		}		if(netdev_get_running(netdev, running) != NETDEV_SUCCESS)		{			this->SetNull(true);			return;		}		if(netdev_get_ipaddr(netdev, ipaddr) != NETDEV_SUCCESS)		{			this->SetNull(true);			return;		}		if(enabled == ENABLED_UP)			index |= 0x1;		if(running = RUNNING_RUN)			index |= 0x2;		if(ipaddr != 0)			index |= 0x4;		static IntelMobileNetworkAdapterConnectionStateEnum ConnectionStateArray[8] = {			NetworkAdapterConnectionStateEnum::HardwareDisabled, /*0x0*/			NetworkAdapterConnectionStateEnum::Disconnected, /*0x1*/			NetworkAdapterConnectionStateEnum::Unknown, /*0x2*/			NetworkAdapterConnectionStateEnum::Connecting, /*0x3*/			NetworkAdapterConnectionStateEnum::Unknown, /*0x4*/			NetworkAdapterConnectionStateEnum::Unknown, /*0x5*/			NetworkAdapterConnectionStateEnum::Unknown, /*0x6*/			NetworkAdapterConnectionStateEnum::Connected		};		this->SetValueImpl(ConnectionStateArray[index]);		pThis->Unlock();	}	catch(...)	{		pThis->Unlock();		THROWIMEXCEPTION("8004308E");	}}//===========================================================================================void PnpDeviceIdClass::GetValueImpl(){	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: PnpDeviceIdStateclass::GetValueImpl()") );	this->SetNull( true );}//===========================================================================================void NdiUpperClass::GetValueImpl(){	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: NdiUpperclass::GetValueImpl()") );	this->SetNull( true );}//===========================================================================================void NdiLowerClass::GetValueImpl(){	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: NdiLowerclass::GetValueImpl()") );	this->SetNull( true );}//===========================================================================================void EnabledClass::GetValueImpl(){	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: Enabledclass::GetValueImpl()") );	DefaultNetworkAdapterInstanceObject* pThis = reinterpret_cast<DefaultNetworkAdapterInstanceObject*>(_pThis);	if ( !pThis )		return;	try	{		pThis->Lock();		netdev_dev netdev;		if(netdev_get_device(pThis->GetKey().c_str(), netdev) != NETDEV_SUCCESS)		{			throw;		}		netdev_enabled enabled;		if(netdev_get_enabled(netdev, enabled) != NETDEV_SUCCESS)		{			this->SetNull(true);			return;		}		bool bValue;		if(enabled == ENABLED_UP)			bValue = true;		else			bValue = false;		this->SetValueImpl( bValue );		pThis->Unlock();	}	catch(...)	{		pThis->Unlock();		THROWIMEXCEPTION("80043092");	}}//====================================================================================void ProtocolsClass::GetValueImpl(){	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: Protocolsclass::GetValueImpl()") );	DefaultNetworkAdapterInstanceObject* pThis = reinterpret_cast<DefaultNetworkAdapterInstanceObject*>(_pThis);	if ( !pThis )		return;	try{		pThis->Lock();		this->Clear();		IntelMobileString szTemp = pThis->GetKey();		this->InsertValueImpl(szTemp);		pThis->Unlock();	}	catch(...)	{		pThis->Unlock();		THROWIMEXCEPTION("80043092");	}}

⌨️ 快捷键说明

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