//---------------------------------------------------------------------------- // // Copyright (C) 2008 Intel Corporation // // File: GeneralInfoFlow.cpp // // Contents: Api code for Intel(R) Active Management Technology // (Intel� AMT) GeneralInfo Sample. // // Notes: This file contains the GeneralInfoFlow class implementation. // //---------------------------------------------------------------------------- #include "GeneralInfoFlow.h" #include "AMT_GeneralSettings.h" #include "AMT_AuthorizationService.h" #include "CIM_BIOSElement.h" #include "CIM_SoftwareIdentity.h" #include "AMT_SetupAndConfigurationService.h" #include "AMT_WebUIService.h" #include "AMT_RedirectionService.h" #include "AMT_TLSProtocolEndpoint.h" #include "AMT_TLSSettingData.h" #include "AMT_CryptographicCapabilities.h" //#include "CIM_SoftwareInstallationService.h" #include "AMT_EthernetPortSettings.h" #include "CIM_RemotePort.h" #include "CIM_RedirectionService.h" #include "CommonDefinitions.h" #include "StatusStrings.h" #include "IPS_TLSProvisioningRecord.h" #include #include using namespace Intel::Manageability::Cim::Typed; using std::tr1::shared_ptr; #pragma region HELP_METHODS /* * Description: Retrieving the core version * Arguments: * wsmanClient - The client to connect * coreVersion - The AMT core version */ void GetCoreVersion(ICimWsmanClient *wsmanClient, std::string &coreVersion) { CIM_SoftwareIdentity softwareIdentity(wsmanClient); softwareIdentity.InstanceID("AMT FW Core Version"); softwareIdentity.Get(); coreVersion = softwareIdentity.VersionString(); } //END: function GetCoreVersion #pragma endregion #pragma region METHODS void GetPrivacyLevel(ICimWsmanClient *wsmanClient) { cout << "---------------Get Privacy Level--------------" << endl; AMT_GeneralSettings generalSettings(wsmanClient); generalSettings.InstanceID("Intel(r) AMT: General Settings"); generalSettings.Get(); if(generalSettings.PrivacyLevelExists()) { cout << "Privacy Level: " ; switch(generalSettings.PrivacyLevel()) { case Default: cout << "Default" << endl; break; case Enhanced: cout << "Enhanced" << endl; break; case Extreme: cout << "Extreme" << endl; break; } } else { cout << "Privacy Level is not supported" << endl; } } void GetAuditProvisioningRecord(ICimWsmanClient *wsmanClient) { cout << endl << "---------------Get audit provisioning record---------------" << endl; string fwCoreVersion; GetCoreVersion(wsmanClient, fwCoreVersion); if (Version(fwCoreVersion) < Version("6.1.0")) cout << endl << "Audit Provisioning Record is not supported" << endl; else { IPS_ProvisioningAuditRecord provisioningAuditRecord; vector> ProvisioningAuditRecord = provisioningAuditRecord.Enumerate(wsmanClient); if(ProvisioningAuditRecord.size()==0) { cout << endl << "No Provisioning Audit Record was found" << endl; } else { if(ProvisioningAuditRecord.size() > 1) { cout << endl << "Found more than one Provisioning Audit Record, using the first one" << endl; } if(ProvisioningAuditRecord.at(0)->ObjectType().compare("IPS_TLSProvisioningRecord")==0) { cout << endl << "The provisioning type is: TLS" << endl; IPS_TLSProvisioningRecord* TLSProvisioningRecord = dynamic_cast(ProvisioningAuditRecord[0].get()); if(TLSProvisioningRecord == NULL) { cout << endl << "No additional information was found" << endl; } else { if(TLSProvisioningRecord->ProvisioningTLSModeExists()) { cout << "Provisioning TLS Mode: " << (int)TLSProvisioningRecord->ProvisioningTLSMode() << endl; } if(TLSProvisioningRecord->SecureDNSExists()) { string boolString = (TLSProvisioningRecord->SecureDNS() == true) ? "true" : "false"; cout << "Secure DNS: " << boolString << endl; } if(TLSProvisioningRecord->HostInitiatedExists()) { string boolString = TLSProvisioningRecord->HostInitiated() == true ? "true" : "false"; cout << "Host Initiated: " << boolString << endl; } if(TLSProvisioningRecord->ProvServerFQDNExists()) { cout << "Provisioning Server FQDN: " << TLSProvisioningRecord->ProvServerFQDN() << endl; } if(TLSProvisioningRecord->SelectedHashDataExists()) { cout << "Selected Hash Data: "; for (unsigned int i=0 ; i < TLSProvisioningRecord->SelectedHashData().Length() ; i++) { cout << (int)TLSProvisioningRecord->SelectedHashData().Data()[i] << " "; } cout << endl; } if(TLSProvisioningRecord->SelectedHashTypeExists()) { char boolString = TLSProvisioningRecord->SelectedHashType()== NULL ? '0' : TLSProvisioningRecord->SelectedHashType(); cout << "Selected Hash Type: " << boolString << endl; } if(TLSProvisioningRecord->AdditionalCaSerialNumsExists()) { string boolString = TLSProvisioningRecord->AdditionalCaSerialNums()== true ? "true" : "false"; cout << "Additional CA Serial Numbers: " << boolString << endl; if(TLSProvisioningRecord->CaCertificateSerialsExists()) { cout << "CA Certificate Serials: " << TLSProvisioningRecord->CaCertificateSerials() << endl; } else { cout << "CA Certificate Serials: " << endl; } } else { if(TLSProvisioningRecord->CaCertificateSerialsExists()) { cout << "CA Certificate Serials: " << TLSProvisioningRecord->CaCertificateSerials() << endl; } } if(TLSProvisioningRecord->HashIsOemDefaultExists()) { string boolString = TLSProvisioningRecord->HashIsOemDefault() == true ? "true" : "false"; cout << "Hash Is OEM Default: " << boolString << endl; } if(TLSProvisioningRecord->IsTimeValidExists()) { string boolString = TLSProvisioningRecord->IsTimeValid() == true ? "true" : "false"; cout << "Is Time Valid: " << boolString << endl; } if(TLSProvisioningRecord->ProvServerIPExists()) { cout << "Provisioning Server IP: " << TLSProvisioningRecord->ProvServerIP() << endl; } } } else if(ProvisioningAuditRecord.at(0)->ObjectType().compare("IPS_ManualProvisioningRecord")==0) { cout << endl << "The provisioning type : Manual" << endl; } else if(ProvisioningAuditRecord.at(0)->ObjectType().compare("IPS_ClientProvisioningRecord")==0) { cout << endl << "The provisioning type : Client" << endl; } } } }//END: function GetAuditProvisionRecord /* * Description: Getting the host name * Arguments: * wsmanClient - The client to connect. */ void GetHostName(ICimWsmanClient *wsmanClient) { cout << endl << "---------------Get HostName--------------" << endl; AMT_GeneralSettings generalSettings(wsmanClient); generalSettings.InstanceID("Intel(r) AMT: General Settings"); generalSettings.Get(); cout << "AMT HostName: " << generalSettings.HostName() << endl; } //END: function GetHostName /* * Description: Getting the administrator's ACL status * Arguments: * wsmanClient - The client to connect. */ void GetAdminAclStatus(ICimWsmanClient *wsmanClient) { cout << endl << "---------------Get Admin ACL Status--------------" << endl; AMT_AuthorizationService authorizationService(wsmanClient); AMT_AuthorizationService::GetAdminAclEntryStatus_OUTPUT output; unsigned int response = authorizationService.GetAdminAclEntryStatus(output); if (response != PT_STATUS_SUCCESS) { wchar_t message[100]; int bufferMax = 100; GetStatusString(response, message, bufferMax); size_t origsize = wcsnlen_s(message, 100) + 1; size_t convertedChars = 0; char charMessage[100]; #if defined (_WIN32) || defined (_WIN64) wcstombs_s(&convertedChars, charMessage, origsize, message, _TRUNCATE); strcat_s(charMessage, " (char *)"); throw exception(charMessage); #else size_t n = wcslen(message); size_t max = (n+1) * 2; char *buf = new char[max]; wcstombs(buf, message, max - 1); throw runtime_error(buf); #endif } cout << "AdminAclEntryStatus IsDefault: "; if(output.IsDefault()) { cout << "True" << endl; } else { cout << "False" << endl; } } //END: function GetAdminAclStatus /* * Description: Getting the administrator's network ACL status * Arguments: * wsmanClient - The client to connect. */ void GetAdminNetAclStatus(ICimWsmanClient *wsmanClient) { cout << endl << "---------------Get Admin Net ACL Status--------------" << endl; AMT_AuthorizationService authorizationService(wsmanClient); AMT_AuthorizationService::GetAdminNetAclEntryStatus_OUTPUT output; unsigned int response = authorizationService.GetAdminNetAclEntryStatus(output); if (response != PT_STATUS_SUCCESS) { wchar_t message[100]; int bufferMax = 100; GetStatusString(response, message, bufferMax); size_t origsize = wcsnlen_s(message, 100) + 1; size_t convertedChars = 0; char charMessage[100]; #if defined (_WIN32) || defined (_WIN64) wcstombs_s(&convertedChars, charMessage, origsize, message, _TRUNCATE); strcat_s(charMessage, " (char *)"); throw exception(charMessage); #else size_t n = wcslen(message); size_t max = (n+1) * 2; char *buf = new char[max]; wcstombs(buf, message, max - 1); throw runtime_error(buf); #endif } cout << "AdminNetAclEntryStatus IsDefault: "; if(output.IsDefault()) { cout << "True" << endl; } else { cout << "False" << endl; } } //END: function GetAdminNetAclStatus /* * Description: Getting the code versions * Arguments: * wsmanClient - The client to connect. */ void GetCodeVersions(ICimWsmanClient *wsmanClient) { using std::tr1::shared_ptr; cout << endl << "---------------Get Code Versions--------------" << endl; //Get Bios version CIM_BIOSElement bIOSElement(wsmanClient); bIOSElement.Name("Primary BIOS"); bIOSElement.Get(); cout << "BIOS Version: " << bIOSElement.Version() << endl; CIM_SoftwareIdentity softwareIdentity; vector> siVec = softwareIdentity.Enumerate(wsmanClient); for(unsigned int i = 0; i < siVec.size(); i++) { CIM_SoftwareIdentity* curPtr = (CIM_SoftwareIdentity*)siVec[i].get(); if(0 != curPtr->InstanceID().compare("AMT FW Core Version")) { cout << curPtr->InstanceID() << ": " << curPtr->VersionString().c_str() << endl; if (0==curPtr->InstanceID().compare(SKU_STRING)) { int version = -1; #pragma warning(disable:4996) sscanf(curPtr->VersionString().c_str(), "%d", &version); #pragma warning(default:4996) if (-1 != version) { bool firstOccurance = true; for (int i=0 ; i Version(FIRST_VERSION_SUPPORTING_KVM) || Version(fwCoreVersion) == Version(FIRST_VERSION_SUPPORTING_KVM)) { CIM_RedirectionService redirectionService(wsmanClient); redirectionService.Name("Intel(r) AMT KVM Redirection Service"); redirectionService.Get(); if (redirectionService.EnabledState() < KVM_ENABLED_STATE_STRINGS_LENGTH) { cout << "\tKVM:\t" << KVM_ENABLED_STATE_STRINGS[redirectionService.EnabledState()] << endl; } } } //END: function GetEnabledInterfaces /* * Description: Getting the security parameters * Arguments: * wsmanClient - The client to connect. */ void GetSecurityParameters(ICimWsmanClient *wsmanClient) { cout << endl << "---------------Get Security Parameters--------------" << endl; AMT_SetupAndConfigurationService setupAndConfigurationService(wsmanClient); setupAndConfigurationService.Name("Intel(r) AMT Setup and Configuration Service"); setupAndConfigurationService.Get(); cout << "Enterprise mode: "; if (setupAndConfigurationService.ProvisioningMode() == ProvisioningModeEnterprise) { cout << "True" << endl; } else { cout << "False" << endl; } AMT_TLSSettingData TLSSettingData(wsmanClient); TLSSettingData.InstanceID("Intel(r) AMT 802.3 TLS Settings"); TLSSettingData.Get(); cout << "TLS Enabled:"; cout << (TLSSettingData.Enabled()? "True":"False") << endl; AMT_CryptographicCapabilities cryptographicCapabilities(wsmanClient); cryptographicCapabilities.InstanceID("Intel(r) AMT: Cryptographic Capabilities 0"); cryptographicCapabilities.Get(); cout << "HW CryptoEnabled:"; if (cryptographicCapabilities.HardwareAcceleration() == 1) { cout << "True" << endl; } else { cout << "False" << endl; } cout << "Provisioning state: "; switch(setupAndConfigurationService.ProvisioningState()) { case ProvisioningStatePre: cout << "Pre Provisioning state" << endl; break; case ProvisioningStatePost: cout << "Post Provisioning state" << endl; break; case ProvisioningStateIn: cout << "In Provisioning state" << endl; break; default: cout << "Unknown Error" << endl; } AMT_GeneralSettings generalSettings(wsmanClient); generalSettings.InstanceID("Intel(r) AMT: General Settings"); generalSettings.Get(); cout << "Network Interface Enabled: "; cout << ((generalSettings.NetworkInterfaceEnabled())? "True":"False") << endl; AMT_RedirectionService redirectionService(wsmanClient); redirectionService .Name("Intel(r) AMT Redirection Service"); redirectionService.Get(); cout << "IDER Enabled: "; cout << (((IDER == redirectionService.EnabledState()) || (IDER_SOL == redirectionService.EnabledState()))? "True":"False") << endl; AMT_EthernetPortSettings ethernetPortSettings; vector> Vec = ethernetPortSettings.Enumerate(wsmanClient); for(unsigned int i = 0; i < Vec.size(); i++) { AMT_EthernetPortSettings curObj = *((AMT_EthernetPortSettings*)Vec[i].get()); cout << curObj.InstanceID() << " (" << curObj.MACAddress() << ") - Link Is Up: "; cout << (curObj.LinkIsUp()? "True":"False") << endl; } } //END: function GetSecurityParameters /* * Description: Getting the configuration server's information * Arguments: * wsmanClient - The client to connect. */ void GetConfigServerInfo(ICimWsmanClient *wsmanClient) { cout << endl << "---------------Get Config server info--------------" << endl; CIM_RemotePort remotePort(wsmanClient); remotePort.Name("Intel(r) AMT Remote Port"); remotePort.Get(); if (remotePort.InfoFormat() == 2) { cout << "Host Name: " <