Protocol802_11InstanceObject.cpp
Upload User: wujun2211
Upload Date: 2015-05-14
Package Size: 869k
Code Size: 18k
Development Platform:

Unix_Linux

  1. /*
  2. Copyright (c) 2008, Intel Corporation. 
  3. All rights reserved.
  4.  
  5. Redistribution and use in source and binary forms, with or without modification, 
  6. are permitted provided that the following conditions are met:
  7.     * Redistributions of source code must retain the above copyright notice, 
  8. this list of conditions and the following disclaimer.
  9.     * Redistributions in binary form must reproduce the above copyright notice, 
  10. this list of conditions and the following disclaimer in the documentation and/or 
  11. other materials provided with the distribution.
  12.     * Neither the name of Intel Corporation nor the names of its contributors 
  13. may be used to endorse or promote products derived from this software without 
  14. specific prior written permission.
  15.  
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
  17. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
  18. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
  19. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
  20. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
  21. BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
  22. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  23. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  24. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
  25. OF SUCH DAMAGE.
  26. */ //============================================================================== // Protocol802_11InstanceObject.cpp  //       Declaration of the class Protocol802_11Instance //============================================================================== #define DllExport // __declspec( dllexport ) //#include "../stdafx.h" #include "IntelMobile/Base/base_Exception.h" #include "IntelMobile/Base/base_InstanceObject.h" #include "./Protocol802_11InstanceObject.h" #include "inc/Base/base_Exception.h" #include "Utility/StringHelper.h" #include "inc/Base/VectorTemplateMacros.h" //============================================================================== // C_Tor() //============================================================================== Intel::Mobile::Network::Protocol802_11Instance::Protocol802_11Instance( void *pImpl ) : LinkProtocolInstance ( pImpl ), Bssid ( *this ), AtimWindow                      ( *this ), BeaconPeriod                    ( *this ), Frequency                ( *this ), DwellTime                       ( *this ), HopPattern                      ( *this ), HopSet                          ( *this ), FailedCount                     ( *this ), FcsErrorCount                   ( *this ), FrameDuplicateCount             ( *this ), MulticastReceivedFrameCount     ( *this ), MulticastTransmittedFrameCount  ( *this ), MultipleRetryCount              ( *this ), ReceivedFragmentCount           ( *this ), RetryCount                      ( *this ), RtsFailureCount                 ( *this ), RtsSuccessCount                 ( *this ), TransmittedFragmentCount        ( *this ), OperatingMode ( *this ), Rssi                            ( *this ), // RssiPercent ( *this ), ModulationTypes ( *this ), ModulationType ( *this ), Ssid ( *this ), RxAntennaId ( *this ), TxAntennaId ( *this ), PowerMode ( *this ), FragmentationThreshold ( *this ), //Extension Properties Channel (*this), AuthenticationMode (*this), Band (*this), //OpMode (*this), //Rate (*this), EncryptionMode (*this), EncryptionModes (*this), //IBSSTxPower (*this), AssociationState (*this), SecurityModes (*this), Qos (*this), //TxRate (*this), DataTxPackets (*this), DataRxPackets (*this), DataTxBytes (*this), DataRxBytes (*this), LinkQuality (*this), //ConnectionPreference (*this), //BandPreference (*this), //Review existing... //WepState (*this), //RTSThreshold (*this), //NumAntennas (*this), //ACKFailureCount (*this), //WepUndecryptableCount (*this), //DecryptSuccessCount (*this), //DecryptFailureCount (*this), //PrivacyFilter (*this), Associated( Intel::Mobile::Base::Event::eAssociated, *this ), Disassociated( Intel::Mobile::Base::Event::eDisassociated, *this ), StatisticsReset( Intel::Mobile::Base::Event::eStatisticsReset, *this ) { if ( m_pImpl != NULL ) { Intel::Mobile::BaseAPI::InstanceObject* pImpl = reinterpret_cast<Intel::Mobile::BaseAPI::InstanceObject*>(m_pImpl); Bssid.Init(pImpl->GetPropertyByName(IntelMobileText("Bssid"),IntelMobileText("ByteArray")) ); AtimWindow.Init(pImpl->GetPropertyByName(IntelMobileText("AtimWindow"),IntelMobileText("UInt")) ); BeaconPeriod.Init(pImpl->GetPropertyByName(IntelMobileText("BeaconPeriod"),IntelMobileText("UInt")) ); Frequency.Init(pImpl->GetPropertyByName(IntelMobileText("Frequency"),IntelMobileText("UInt")) ); DwellTime.Init(pImpl->GetPropertyByName(IntelMobileText("DwellTime"),IntelMobileText("UInt")) ); HopPattern.Init(pImpl->GetPropertyByName(IntelMobileText("HopPattern"),IntelMobileText("UInt")) ); HopSet.Init(pImpl->GetPropertyByName(IntelMobileText("HopSet"),IntelMobileText("UInt")) ); FailedCount.Init(pImpl->GetPropertyByName(IntelMobileText("FailedCount"),IntelMobileText("UInt64")) ); FcsErrorCount.Init(pImpl->GetPropertyByName(IntelMobileText("FcsErrorCount"),IntelMobileText("UInt64")) ); FrameDuplicateCount.Init(pImpl->GetPropertyByName(IntelMobileText("FrameDuplicateCount"),IntelMobileText("UInt64")) ); MulticastReceivedFrameCount.Init(pImpl->GetPropertyByName(IntelMobileText("MulticastReceivedFrameCount"),IntelMobileText("UInt64")) ); MulticastTransmittedFrameCount.Init(pImpl->GetPropertyByName(IntelMobileText("MulticastTransmittedFrameCount"),IntelMobileText("UInt64")) ); MultipleRetryCount.Init(pImpl->GetPropertyByName(IntelMobileText("MultipleRetryCount"),IntelMobileText("UInt64")) ); ReceivedFragmentCount.Init(pImpl->GetPropertyByName(IntelMobileText("ReceivedFragmentCount"),IntelMobileText("UInt64")) ); RetryCount.Init(pImpl->GetPropertyByName(IntelMobileText("RetryCount"),IntelMobileText("UInt64")) ); RtsFailureCount.Init(pImpl->GetPropertyByName(IntelMobileText("RtsFailureCount"),IntelMobileText("UInt64")) ); RtsSuccessCount.Init(pImpl->GetPropertyByName(IntelMobileText("RtsSuccessCount"),IntelMobileText("UInt64")) ); TransmittedFragmentCount.Init(pImpl->GetPropertyByName(IntelMobileText("TransmittedFragmentCount"),IntelMobileText("UInt64")) ); OperatingMode.Init(pImpl->GetPropertyByName(IntelMobileText("OperatingMode"),IntelMobileText("Int"), IntelMobileText("OperatingModeEnumProperty") )); Rssi.Init(pImpl->GetPropertyByName(IntelMobileText("Rssi"),IntelMobileText("Int")) ); // RssiPercent.Init(pImpl->GetPropertyByName(IntelMobileText("RssiPercent"),IntelMobileText("UInt")) ); ModulationTypes.Init(pImpl->GetPropertyByName(IntelMobileText("ModulationTypes"),IntelMobileText("IntArray"), IntelMobileText("ModulationTypeEnumArrayProperty")) ); ModulationType.Init(pImpl->GetPropertyByName(IntelMobileText("ModulationType"),IntelMobileText("Int"), IntelMobileText("ModulationTypeEnumProperty")) ); Ssid.Init(pImpl->GetPropertyByName(IntelMobileText("Ssid"),IntelMobileText("String")) ); RxAntennaId.Init(pImpl->GetPropertyByName(IntelMobileText("RxAntennaId"),IntelMobileText("UInt")) ); TxAntennaId.Init(pImpl->GetPropertyByName(IntelMobileText("TxAntennaId"),IntelMobileText("UInt")) ); PowerMode.Init(pImpl->GetPropertyByName(IntelMobileText("PowerMode"),IntelMobileText("Int"), IntelMobileText("WlanPowerModeEnumProperty")) ); FragmentationThreshold.Init(pImpl->GetPropertyByName(IntelMobileText("FragmentationThreshold"),IntelMobileText("UInt")) ); //Extension Properties Channel.Init(pImpl->GetPropertyByName(IntelMobileText("Channel"),IntelMobileText("UInt")) ); AuthenticationMode.Init(pImpl->GetPropertyByName(IntelMobileText("AuthenticationMode"),IntelMobileText("Int"), IntelMobileText("AuthenticationModeEnumProperty")) ); Band.Init(pImpl->GetPropertyByName(IntelMobileText("Band"),IntelMobileText("Int"), IntelMobileText("WlanBandEnumProperty")) ); //OpMode.Init(pImpl->GetPropertyByName(IntelMobileText("OpMode"),IntelMobileText("Byte"), IntelMobileText("OpModeTypeProperty")) ); //Rate.Init(pImpl->GetPropertyByName(IntelMobileText("Rate"),IntelMobileText("UInt64")) ); EncryptionMode.Init(pImpl->GetPropertyByName(IntelMobileText("EncryptionMode"),IntelMobileText("Int"), IntelMobileText("WlanEncryptionModeEnumProperty")) ); EncryptionModes.Init(pImpl->GetPropertyByName(IntelMobileText("EncryptionModes"),IntelMobileText("IntArray"), IntelMobileText("WlanEncryptionModeEnumArrayProperty")) ); //IBSSTxPower.Init(pImpl->GetPropertyByName(IntelMobileText("IBSSTxPower"),IntelMobileText("UInt"))); AssociationState.Init(pImpl->GetPropertyByName(IntelMobileText("AssociationState"),IntelMobileText("Int"), IntelMobileText("AssociationStateEnumProperty")) ); SecurityModes.Init(pImpl->GetPropertyByName(IntelMobileText("SecurityModes"), IntelMobileText("IntArray"), IntelMobileText("SecurityModeEnumArrayProperty")) ); Qos.Init(pImpl->GetPropertyByName(IntelMobileText("Qos"),IntelMobileText("Int"), IntelMobileText("QosEnumProperty")) ); //TxRate.Init(pImpl->GetPropertyByName(IntelMobileText("TxRate"),IntelMobileText("UInt64")) ); DataTxPackets.Init(pImpl->GetPropertyByName(IntelMobileText("DataTxPackets"),IntelMobileText("UInt64")) ); DataRxPackets.Init(pImpl->GetPropertyByName(IntelMobileText("DataRxPackets"),IntelMobileText("UInt64")) ); DataTxBytes.Init(pImpl->GetPropertyByName(IntelMobileText("DataTxBytes"),IntelMobileText("UInt64")) ); DataRxBytes.Init(pImpl->GetPropertyByName(IntelMobileText("DataRxBytes"),IntelMobileText("UInt64")) ); LinkQuality.Init(pImpl->GetPropertyByName(IntelMobileText("LinkQuality"),IntelMobileText("Int"), IntelMobileText("LinkQualityEnumProperty")) ); //ConnectionPreference.Init(pImpl->GetPropertyByName(IntelMobileText("ConnectionPreference"),IntelMobileText("Byte"), IntelMobileText("ConnectionPreferenceTypeProperty")) ); //BandPreference.Init(pImpl->GetPropertyByName(IntelMobileText("BandPreference"),IntelMobileText("Byte"), IntelMobileText("BandPreferenceTypeProperty")) ); //Review existing... //WepState.Init(pImpl->GetPropertyByName(IntelMobileText("WepState"),IntelMobileText("Byte"), IntelMobileText("WepStateTypeProperty")) ); //RTSThreshold.Init(pImpl->GetPropertyByName(IntelMobileText("RTSThreshold"),IntelMobileText("UInt64"))); //NumAntennas.Init(pImpl->GetPropertyByName(IntelMobileText("NumAntennas"),IntelMobileText("UInt64")) ); //ACKFailureCount.Init(pImpl->GetPropertyByName(IntelMobileText("ACKFailureCount"),IntelMobileText("UInt64")) ); //WepUndecryptableCount.Init(pImpl->GetPropertyByName(IntelMobileText("WepUndecryptableCount"),IntelMobileText("UInt64")) ); //DecryptSuccessCount.Init(pImpl->GetPropertyByName(IntelMobileText("DecryptSuccessCount"),IntelMobileText("UInt64")) ); //DecryptFailureCount.Init(pImpl->GetPropertyByName(IntelMobileText("DecryptFailureCount"),IntelMobileText("UInt64")) ); //PrivacyFilter.Init(pImpl->GetPropertyByName(IntelMobileText("PrivacyFilter"),IntelMobileText("Byte", IntelMobileText("PrivacyFilterTypeProperty")) ); } } //============================================================================== // D_Tor() //============================================================================== Intel::Mobile::Network::Protocol802_11Instance::~Protocol802_11Instance() { if (m_flag) { if (m_pImpl) { Intel::Mobile::BaseAPI::InstanceObject *pAPI_Instance = reinterpret_cast<Intel::Mobile::BaseAPI::InstanceObject*>(m_pImpl); if (pAPI_Instance) { delete pAPI_Instance; } m_pImpl = NULL; } } } //============================================================================== // ResetStatistics() //============================================================================== bool Intel::Mobile::Network::Protocol802_11Instance::ResetStatistics() { bool bValue = false; if (m_pImpl) { Intel::Mobile::BaseAPI::InstanceObject *pAPI_Instance = reinterpret_cast<Intel::Mobile::BaseAPI::InstanceObject *>(m_pImpl); if (pAPI_Instance) { TRYBLOCK { IntelMobileChar* infoString = pAPI_Instance->InvokeMethod( IntelMobileText("ResetStatistics"), IntelMobileText("") ); IntelMobileString wsRtn = infoString; delete []infoString; return  wsRtn.compare(IntelMobileText("true")) == 0 ? true : false; } CATCHBLOCK } else THROWNE(IntelMobileText("Intel::Mobile::Network::Protocol802_11Instance"), IntelMobileText("ResetStatistics")); } else THROWNE(IntelMobileText("Intel::Mobile::Network::Protocol802_11Instance"), IntelMobileText("ResetStatistics")); return bValue; } //============================================================================== // ScanAPs() //============================================================================== Intel::Mobile::Network::ApStructVector Intel::Mobile::Network::Protocol802_11Instance::ScanAps() { vector<ApStruct> ciVector; ApStructVector aiVector; if (m_pImpl) { Intel::Mobile::BaseAPI::InstanceObject *pAPI_Instance = reinterpret_cast<Intel::Mobile::BaseAPI::InstanceObject *>(m_pImpl); if (pAPI_Instance) { TRYBLOCK { IntelMobileChar data[8092]; IntelMobileChar* infoString = pAPI_Instance->InvokeMethod( IntelMobileText("ScanAps"), IntelMobileText("") ); //wcscpy( data, infoString ); strcpy( data, infoString ); delete[] infoString; IntelMobileChar line[256]; IntelMobileChar item[256]; IntelMobileChar itemitem[4]; IntelMobileString wstr; ApStruct sAPInfo; //IntelMobileChar* remain = wcsstr( data, IntelMobileText("<;>") ); IntelMobileChar* remain = strstr( data, IntelMobileText("<;>") ); while ( NULL != remain ) { size_t pos = remain - data + 1; //wcsncpy( line, data, pos - 1 ); strncpy( line, data, pos - 1 ); line[ pos -1 ] = 0; IntelMobileChar* itemremain; size_t itempos; unsigned char nEnumTemp; //itemremain = wcsstr( line, IntelMobileText("<,>" ); itemremain = strstr( line, IntelMobileText("<,>") ); itempos = itemremain - line + 1; strncpy( item, line, itempos - 1 ); item[ itempos-1 ] = 0; wstr = item; CStringHelper::Str2Param( wstr, nEnumTemp ); sAPInfo.AuthenticationMode = nEnumTemp; strcpy( line, line+itempos+2 ); itemremain = strstr( line, IntelMobileText("<,>") ); itempos = itemremain - line + 1; strncpy( item, line, itempos - 1 ); item[ itempos-1 ] = 0; //strcpy( sAPInfo.Ssid, item ); strcpy( sAPInfo.Ssid, item ); strcpy( line, line+itempos+2 ); itemremain = strstr( line, IntelMobileText("<,>") ); itempos = itemremain - line + 1; strncpy( item, line, itempos - 1 ); item[ itempos-1 ] = 0; wstr = item; CStringHelper::Str2Param( wstr, sAPInfo.Rssi ); strcpy( line, line+itempos+2 ); itemremain = strstr( line, IntelMobileText("<,>") ); itempos = itemremain - line + 1; strncpy( item, line, itempos - 1 ); item[ itempos-1 ] = 0; int j = 0; IntelMobileChar* itemitemremain = strstr( item, IntelMobileText("<:>") ); while ( NULL != itemitemremain ) { size_t itemitempos = itemitemremain - item + 1; strncpy( itemitem, item, itemitempos - 1 ); itemitem[ itemitempos -1 ] = 0; wstr = itemitem; CStringHelper::Str2Param( wstr, sAPInfo.Bssid[ j++ ] ); strcpy( item, item+itemitempos+2 ); itemitemremain = strstr( item, IntelMobileText("<:>") ); } strcpy( line, line+itempos+2 ); itemremain = strstr( line, IntelMobileText("<,>") ); itempos = itemremain - line + 1; strncpy( item, line, itempos - 1 ); item[ itempos-1 ] = 0; wstr = item; CStringHelper::Str2Param( wstr, nEnumTemp ); sAPInfo.Band = nEnumTemp; strcpy( line, line+itempos+2 ); itemremain = strstr( line, IntelMobileText("<,>") ); itempos = itemremain - line + 1; strncpy( item, line, itempos - 1 ); item[ itempos-1 ] = 0; wstr = item; CStringHelper::Str2Param( wstr, nEnumTemp ); sAPInfo.OperatingMode = nEnumTemp; strcpy( line, line+itempos+2 ); itemremain = strstr( line, IntelMobileText("<,>") ); itempos = itemremain - line + 1; strncpy( item, line, itempos - 1 ); item[ itempos-1 ] = 0; wstr = item; CStringHelper::Str2Param( wstr, sAPInfo.Encrypted ); strcpy( line, line+itempos+2 ); itemremain = strstr( line, IntelMobileText("<,>") ); itempos = itemremain - line + 1; strncpy( item, line, itempos - 1 ); item[ itempos-1 ] = 0; wstr = item; CStringHelper::Str2Param( wstr, sAPInfo.Channel ); strcpy( line, line+itempos+2 ); itemremain = strstr( line, IntelMobileText("<,>") ); itempos = itemremain - line + 1; strncpy( item, line, itempos - 1 ); item[ itempos-1 ] = 0; wstr = item; CStringHelper::Str2Param( wstr, nEnumTemp ); sAPInfo.EncryptionMode = nEnumTemp; strcpy( line, line+itempos+2 ); //ciVector.push_back( sAPInfo ); aiVector.Insert(sAPInfo); strcpy( data, data+pos+2 ); remain = strstr( data, IntelMobileText("<;>") ); } } CATCHBLOCK } else THROWNE(IntelMobileText("Intel::Mobile::Network::Protocol802_11Instance"), IntelMobileText("Scan")); } else THROWNE(IntelMobileText("Intel::Mobile::Network::Protocol802_11Instance"), IntelMobileText("Scan")); //return ApStructVector(ciVector); return aiVector; } // Generate VetorObject template
  27. namespace Intel
  28. {
  29. namespace Mobile
  30. {
  31. namespace Network
  32. {
  33. GENERATE_VECTOROBJECT(ApStruct);
  34. }
  35. }
  36. }