LPCTSTR CNetworkAdapterList::GetHash() { COcsCrypto myHash; CNetworkAdapter myObject; POSITION pos; BOOL bContinue; CString csToHash; if (GetCount() == 0) return NULL; if (!myHash.HashInit()) return NULL; pos = GetHeadPosition(); bContinue = (pos != NULL); if (bContinue) // There is one record => get the first myObject = GetNext( pos); while (bContinue) { csToHash.Format( _T( "%s%s%s%s%s%s%s%s%s"), myObject.GetDescription(), myObject.GetType(), myObject.GetTypeMIB(), myObject.GetMACAddress(), myObject.GetOperationalStatus(), myObject.GetIPAddress(), myObject.GetIPNetMask(), myObject.GetGateway(), myObject.GetDhcpServer()); myHash.HashUpdate( csToHash); bContinue = (pos != NULL); if (bContinue) myObject = GetNext( pos); } return myHash.HashFinal(); }
BOOL CNetworkAdapterList::SetIpAddrEntry(LONG lIfIndex, LPCTSTR lpstrIPAddr, LPCTSTR lpstrIPNetMask, LPCTSTR lpstrNetNumber) { CNetworkAdapter cAdapter; POSITION pPosCur, pPosNext; pPosNext = GetHeadPosition(); pPosCur = GetHeadPosition(); while (pPosNext != NULL) { cAdapter = GetNext( pPosNext); if (cAdapter.GetIfIndex() == lIfIndex) { // That's the adapter to update cAdapter.SetIPAddress( lpstrIPAddr); cAdapter.SetIPNetMask( lpstrIPNetMask); cAdapter.SetNetNumber( lpstrNetNumber ); SetAt( pPosCur, cAdapter); return TRUE; } // Browse the next adapter and save the adapter position in the list pPosCur = pPosNext; } return FALSE; }
/* static */ void UIMachineSettingsNetworkPage::updateGenericProperties(CNetworkAdapter &adapter, const QString &strPropText) { /* Parse new properties: */ QStringList newProps = strPropText.split("\n"); QHash<QString, QString> hash; /* Save new properties: */ for (int i = 0; i < newProps.size(); ++i) { QString strLine = newProps[i]; int iSplitPos = strLine.indexOf("="); if (iSplitPos) { QString strKey = strLine.left(iSplitPos); QString strVal = strLine.mid(iSplitPos+1); adapter.SetProperty(strKey, strVal); hash[strKey] = strVal; } } /* Removing deleted properties: */ QVector<QString> names; QVector<QString> props; props = adapter.GetProperties(QString(), names); for (int i = 0; i < names.size(); ++i) { QString strName = names[i]; QString strValue = props[i]; if (strValue != hash[strName]) adapter.SetProperty(strName, hash[strName]); } }
/* Concatenate MAC adresses in a CString and return it */ CString CDeviceid::getMacs() { CSysInfo cSysinfo; CNetworkAdapter cObject; CNetworkAdapterList cNetworkAdapterList; POSITION position; BOOL bContinue; CString csMacConcat; m_csMacConcat.Empty(); if (!CIPHelper::GetNetworkAdaptersJustMAC(&cNetworkAdapterList)) return m_csMacConcat; position = cNetworkAdapterList.GetHeadPosition(); bContinue = (position != NULL); if (bContinue) cObject = cNetworkAdapterList.GetNext(position); while (bContinue) { bContinue = (position != NULL); csMacConcat += cObject.GetMACAddress(); if (position != NULL) cObject = cNetworkAdapterList.GetNext( position ); } m_csMacConcat = csMacConcat; return m_csMacConcat; }
CString CNetworkAdapterList::GetIpByGateway(CString gtw) { CNetworkAdapter cAdapter; POSITION pPosNext; pPosNext = GetHeadPosition(); while (pPosNext != NULL) { cAdapter = GetNext( pPosNext); if (gtw.Compare(cAdapter.GetGateway()) == 0 ) { return cAdapter.GetIPAddress(); } } return _T(""); }
CString CNetworkAdapterList::GetMaskByNetNumber(CString nbr) { CNetworkAdapter cAdapter; POSITION pPosNext; pPosNext = GetHeadPosition(); while (pPosNext != NULL) { cAdapter = GetNext( pPosNext); if (nbr.Compare(cAdapter.GetNetNumber()) == 0 ) { return cAdapter.GetIPNetMask(); } } return _T(""); }
BOOL CNetworkAdapterList::SetIpAddrEntry(LPCTSTR lpstrMAC, LPCTSTR lpstrIPAddr, LPCTSTR lpstrIPNetMask , LPCTSTR lpstrGateway, LPCTSTR lpstrDhcpServer, LPCTSTR lpstrNetNumber) { CNetworkAdapter cAdapter; POSITION pPosCur, pPosNext; pPosNext = GetHeadPosition(); pPosCur = GetHeadPosition(); while (pPosNext != NULL) { cAdapter = GetNext( pPosNext); if (_tcscmp( cAdapter.GetMACAddress(), lpstrMAC) ==0) { // That's the adapter to update cAdapter.SetIPAddress( lpstrIPAddr); cAdapter.SetIPNetMask( lpstrIPNetMask); cAdapter.SetGateway( lpstrGateway); cAdapter.SetDhcpServer( lpstrDhcpServer); cAdapter.SetNetNumber( lpstrNetNumber ); SetAt( pPosCur, cAdapter); return TRUE; } // Browse the next adapter and save the adapter position in the list pPosCur = pPosNext; } return FALSE; }
// Didier LIROULET 2005-10-17 BEGIN BOOL CNetworkAdapterList::SetIpRouteEntry(LONG lIfIndex, LPCTSTR lpstrGateway) { CNetworkAdapter cAdapter; POSITION pPosCur, pPosNext; pPosNext = GetHeadPosition(); pPosCur = GetHeadPosition(); while (pPosNext != NULL) { cAdapter = GetNext( pPosNext); if (cAdapter.GetIfIndex() == lIfIndex) { // That's the adapter to update cAdapter.SetGateway( lpstrGateway); SetAt( pPosCur, cAdapter); return TRUE; } // Browse the next adapter and save the adapter position in the list pPosCur = pPosNext; } return FALSE; }
/* static */ QString UIMachineSettingsNetworkPage::summarizeGenericProperties(const CNetworkAdapter &adapter) { /* Prepare formatted string: */ QVector<QString> names; QVector<QString> props; props = adapter.GetProperties(QString(), names); QString strResult; /* Load generic properties: */ for (int i = 0; i < names.size(); ++i) { strResult += names[i] + "=" + props[i]; if (i < names.size() - 1) strResult += "\n"; } /* Return formatted string: */ return strResult; }
/* Save data from cache to corresponding external object(s), * this task COULD be performed in other than GUI thread: */ void UIMachineSettingsNetworkPage::saveFromCacheTo(QVariant &data) { /* Fetch data to machine: */ UISettingsPageMachine::fetchData(data); /* Check if network data was changed: */ if (m_cache.wasChanged()) { /* For each network adapter: */ for (int iSlot = 0; iSlot < m_pTwAdapters->count(); ++iSlot) { /* Check if adapter data was changed: */ const UICacheSettingsMachineNetworkAdapter &adapterCache = m_cache.child(iSlot); if (adapterCache.wasChanged()) { /* Check if adapter still valid: */ CNetworkAdapter adapter = m_machine.GetNetworkAdapter(iSlot); if (!adapter.isNull()) { /* Get adapter data from cache: */ const UIDataSettingsMachineNetworkAdapter &adapterData = adapterCache.data(); /* Store adapter data: */ if (isMachineOffline()) { /* Basic attributes: */ adapter.SetEnabled(adapterData.m_fAdapterEnabled); adapter.SetAdapterType(adapterData.m_adapterType); adapter.SetMACAddress(adapterData.m_strMACAddress); } if (isMachineInValidMode()) { /* Attachment type: */ switch (adapterData.m_attachmentType) { case KNetworkAttachmentType_Bridged: adapter.SetBridgedInterface(adapterData.m_strBridgedAdapterName); break; case KNetworkAttachmentType_Internal: adapter.SetInternalNetwork(adapterData.m_strInternalNetworkName); break; case KNetworkAttachmentType_HostOnly: adapter.SetHostOnlyInterface(adapterData.m_strHostInterfaceName); break; case KNetworkAttachmentType_Generic: adapter.SetGenericDriver(adapterData.m_strGenericDriverName); updateGenericProperties(adapter, adapterData.m_strGenericProperties); break; default: break; } adapter.SetAttachmentType(adapterData.m_attachmentType); /* Advanced attributes: */ adapter.SetPromiscModePolicy(adapterData.m_promiscuousMode); /* Cable connected flag: */ adapter.SetCableConnected(adapterData.m_fCableConnected); /* Redirect options: */ QVector<QString> oldRedirects = adapter.GetNATEngine().GetRedirects(); for (int i = 0; i < oldRedirects.size(); ++i) adapter.GetNATEngine().RemoveRedirect(oldRedirects[i].section(',', 0, 0)); UIPortForwardingDataList newRedirects = adapterData.m_redirects; for (int i = 0; i < newRedirects.size(); ++i) { UIPortForwardingData newRedirect = newRedirects[i]; adapter.GetNATEngine().AddRedirect(newRedirect.name, newRedirect.protocol, newRedirect.hostIp, newRedirect.hostPort.value(), newRedirect.guestIp, newRedirect.guestPort.value()); } } } } } } /* Upload machine to data: */ UISettingsPageMachine::uploadData(data); }
BOOL CIPHelper::GetNetworkAdapters(CNetworkAdapterList *pList) { HINSTANCE hDll; DWORD (WINAPI *lpfnGetAdaptersInfo)( PIP_ADAPTER_INFO myInfo, ULONG *pLength); DWORD (WINAPI *lpfnGetIfTable)( PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder); PMIB_IFTABLE pIfTable; PMIB_IFROW pIfEntry; PIP_ADAPTER_INFO pAdapterTable, pAdapterInfo; ULONG ulLength = 0; UINT uIndex = 0; DWORD dwIndex; CNetworkAdapter cAdapter; PIP_ADDR_STRING pAddressList; CString csMAC, csAddress, csGateway, csDhcpServer; AddLog( _T( "IpHlpAPI GetNetworkAdapters...\n")); // Reset network adapter list content while (!(pList->GetCount() == 0)) pList->RemoveHead(); // Load the IpHlpAPI dll and get the addresses of necessary functions if ((hDll = LoadLibrary(_T( "iphlpapi.dll"))) < (HINSTANCE) HINSTANCE_ERROR) { // Cannot load IpHlpAPI MIB AddLog( _T( "IpHlpAPI GetNetworkAdapters: Failed because unable to load <iphlpapi.dll> !\n")); hDll = NULL; return FALSE; } if ((*(FARPROC*)&lpfnGetIfTable = GetProcAddress( hDll, _T( "GetIfTable"))) == NULL) { // Tell the user that we could not find a usable IpHlpAPI DLL. FreeLibrary( hDll); AddLog( _T( "IpHlpAPI GetNetworkAdapters: Failed because unable to load <iphlpapi.dll> !\n")); return FALSE; } if ((*(FARPROC*)&lpfnGetAdaptersInfo = GetProcAddress( hDll, _T( "GetAdaptersInfo"))) == NULL) { // Tell the user that we could not find a usable IpHlpAPI DLL. FreeLibrary( hDll); AddLog( _T( "IpHlpAPI GetNetworkAdapters: Failed because unable to load <iphlpapi.dll> !\n")); return FALSE; } // Call GetIfTable to get memory size AddLog( _T( "IpHlpAPI GetNetworkAdapters: Calling GetIfTable to determine network adapter properties...")); pIfTable = NULL; ulLength = 0; switch( lpfnGetIfTable( pIfTable, &ulLength, TRUE)) { case NO_ERROR: // No error => no adapters FreeLibrary( hDll); AddLog( _T( "Failed because no network adapters !\n")); return FALSE; case ERROR_NOT_SUPPORTED: // Not supported FreeLibrary( hDll); AddLog( _T( "Failed because OS not support GetIfTable API function !\n" )); return FALSE; case ERROR_BUFFER_OVERFLOW: // We must allocate memory case ERROR_INSUFFICIENT_BUFFER: break; default: FreeLibrary( hDll); AddLog( _T( "Failed because unknown error !\n" )); return FALSE; } if ((pIfTable = (PMIB_IFTABLE) malloc( ulLength+1)) == NULL) { FreeLibrary( hDll); AddLog( _T( "Failed because memory error !\n" )); return FALSE; } // Recall GetIfTable switch( lpfnGetIfTable( pIfTable, &ulLength, TRUE)) { case NO_ERROR: // No error break; case ERROR_NOT_SUPPORTED: // Not supported free( pIfTable); FreeLibrary( hDll); AddLog( _T( "Failed because OS not support GetIfTable API function !\n" )); return FALSE; case ERROR_BUFFER_OVERFLOW: // We have allocated needed memory, but not sufficient case ERROR_INSUFFICIENT_BUFFER: free( pIfTable); FreeLibrary( hDll); AddLog( _T( "Failed because memory error !\n" )); return FALSE; default: free( pIfTable); FreeLibrary( hDll); AddLog( _T( "Failed because unknown error !\n" )); return FALSE; } /* // Dump IfTable AddLog("\n=== DEBUG : dump IfTable ===\n"); for (dwIndex = 0; dwIndex < pIfTable->dwNumEntries; dwIndex ++) { // char wszName[MAX_INTERFACE_NAME_LEN]; // WideCharToMultiByte(CP_ACP, 0, pIfTable->table[dwIndex].wszName, -1, wszName, MAX_INTERFACE_NAME_LEN, NULL, NULL); AddLog("+ Interface #%d\n", dwIndex); // AddLog("\twszName = %s\n", wszName); AddLog("\tdwIndex = %d\n", pIfTable->table[dwIndex].dwIndex); AddLog("\tdwType = %d\n", pIfTable->table[dwIndex].dwType); AddLog("\tdwMtu = %d\n", pIfTable->table[dwIndex].dwMtu); AddLog("\tdwSpeed = %d\n", pIfTable->table[dwIndex].dwSpeed); AddLog("\tdwPhysAddrLen = %d\n", pIfTable->table[dwIndex].dwPhysAddrLen); AddLog("\tbPhysAddr ="); for (DWORD i=0 ; i<pIfTable->table[dwIndex].dwPhysAddrLen ; i++) AddLog(" %02x", pIfTable->table[dwIndex].bPhysAddr[i]); AddLog("\n"); AddLog("\tbPhysAddr = %d\n", pIfTable->table[dwIndex].dwPhysAddrLen); AddLog("\tdwAdminStatus = %d\n", pIfTable->table[dwIndex].dwAdminStatus); AddLog("\tdwOperStatus = %d\n", pIfTable->table[dwIndex].dwOperStatus); AddLog("\tdwLastChange = %d\n", pIfTable->table[dwIndex].dwLastChange); AddLog("\tbDescr = %s\n", pIfTable->table[dwIndex].bDescr); } */ // Call GetAdptersInfo with length to 0 to get size of required buffer AddLog( _T( "OK\nIpHlpAPI GetNetworkAdapters: Calling GetAdapterInfo to determine IP Infos...")); pAdapterTable = NULL; switch( lpfnGetAdaptersInfo( pAdapterTable, &ulLength)) { case NO_ERROR: // No error => no adapters case ERROR_NO_DATA: free( pIfTable); FreeLibrary( hDll); AddLog( _T( "Failed because no network adapters !\n")); return FALSE; case ERROR_NOT_SUPPORTED: // Not supported free( pIfTable); FreeLibrary( hDll); AddLog( _T( "Failed because OS not support GetAdaptersInfo API function !\n" )); return FALSE; case ERROR_BUFFER_OVERFLOW: // We must allocate memory break; default: free( pIfTable); FreeLibrary( hDll); AddLog( _T( "Failed because unknown error !\n" )); return FALSE; } if ((pAdapterTable = (PIP_ADAPTER_INFO) malloc( ulLength+1)) == NULL) { FreeLibrary( hDll); AddLog( _T( "Failed because memory error !\n" )); return FALSE; } // Recall GetAdptersInfo switch( lpfnGetAdaptersInfo( pAdapterTable, &ulLength)) { case 0: // No error break; case ERROR_NO_DATA: // No adapters free( pIfTable); free( pAdapterTable); FreeLibrary( hDll); AddLog( _T( "Failed because no network adapters !\n")); return FALSE; case ERROR_NOT_SUPPORTED: // Not supported free( pIfTable); free( pAdapterTable); FreeLibrary( hDll); AddLog( _T( "Failed because OS not support GetAdaptersInfo API function !\n" )); return FALSE; case ERROR_BUFFER_OVERFLOW: // We have allocated needed memory, but not sufficient free( pIfTable); free( pAdapterTable); FreeLibrary( hDll); AddLog( _T( "Failed because memory error !\n" )); return FALSE; default: free( pIfTable); free( pAdapterTable); FreeLibrary( hDll); AddLog( _T( "Failed because unknown error !\n" )); return FALSE; } /* // Dump IfTable AddLog("\n=== DEBUG : dump AdaptersInfo ===\n"); for (dwIndex=0, pAdapterInfo=pAdapterTable ; pAdapterInfo != NULL ; pAdapterInfo = pAdapterInfo->Next, dwIndex++) { AddLog("+ Adaptater #%d\n", dwIndex); AddLog("\tAdapterName = %s\n", pAdapterInfo->AdapterName); AddLog("\tDescription = %s\n", pAdapterInfo->Description); AddLog("\tAddressLength = %d\n", pAdapterInfo->AddressLength); AddLog("\tAddress ="); for (DWORD i=0 ; i<pAdapterInfo->AddressLength ; i++) AddLog(" %02x", pAdapterInfo->Address[i]); AddLog("\n"); AddLog("\tIndex = %d\n", pAdapterInfo->Index); AddLog("\tType = %d\n", pAdapterInfo->Type); AddLog("\tDhcpEnabled = %d\n", pAdapterInfo->DhcpEnabled); } AddLog("=== DEBUG : fin===\n"); */ // Call GetIfEntry for each interface for (dwIndex = 0; dwIndex < pIfTable->dwNumEntries; dwIndex ++) if (!IsLoopback( pIfTable->table[dwIndex].dwType)) { pIfEntry = &(pIfTable->table[dwIndex]); // Get the Index cAdapter.SetIfIndex( pIfEntry->dwIndex); // Get the type cAdapter.SetType( GetAdapterType( pIfEntry->dwType)); // Get the MIB type cAdapter.SetTypeMIB( GetIfType( pIfEntry->dwType)); // Get the description _tcsncpy( csAddress.GetBuffer( pIfEntry->dwDescrLen), (LPCTSTR) pIfEntry->bDescr, (size_t) pIfEntry->dwDescrLen); csAddress.ReleaseBuffer( (int) pIfEntry->dwDescrLen); cAdapter.SetDescription( csAddress); // Get MAC Address csMAC.Format( _T("%02X:%02X:%02X:%02X:%02X:%02X"), pIfEntry->bPhysAddr[0], pIfEntry->bPhysAddr[1], pIfEntry->bPhysAddr[2], pIfEntry->bPhysAddr[3], pIfEntry->bPhysAddr[4], pIfEntry->bPhysAddr[5]); cAdapter.SetMACAddress( csMAC); // Get the Speed cAdapter.SetSpeed( pIfEntry->dwSpeed); // Get the status cAdapter.SetIpHelperStatus( pIfEntry->dwOperStatus); // AddLog("+ IfTable => %s\n", csMAC); // Now parse the Adapter info for (pAdapterInfo=pAdapterTable ; pAdapterInfo != NULL ; pAdapterInfo = pAdapterInfo->Next) // Check the MAC Address (bad idea) //if (pIfEntry->dwPhysAddrLen==pAdapterInfo->AddressLength && !memcmp(pIfEntry->bPhysAddr, pAdapterInfo->Address, pAdapterInfo->AddressLength)) // Check the AdapterIndex (better idea) if (pIfEntry->dwIndex == pAdapterInfo->Index) { // AddLog("++ AdapterTable : %02X:%02X:%02X:%02X:%02X:%02X\n", pAdapterInfo->Address[0], pAdapterInfo->Address[1], pAdapterInfo->Address[2], pAdapterInfo->Address[3], pAdapterInfo->Address[4], pAdapterInfo->Address[5]); // Get Gateways pAddressList = &(pAdapterInfo->GatewayList); csGateway = _T(""); do { csGateway += pAddressList->IpAddress.String; pAddressList = pAddressList->Next; if( pAddressList != NULL ) csGateway += _T( ","); } while( pAddressList != NULL ); cAdapter.SetGateway(csGateway); // Get DHCP server pAddressList = &(pAdapterInfo->DhcpServer); csDhcpServer = _T(""); do { csDhcpServer += pAddressList->IpAddress.String; pAddressList = pAddressList->Next; if( pAddressList != NULL ) csDhcpServer += _T( ","); } while( pAddressList != NULL ); cAdapter.SetDhcpServer(csDhcpServer); // Get IP addresses and NetMasks pAddressList = &(pAdapterInfo->IpAddressList); do { in_addr ipa; ULONG ipAdr, ipMsk, nbRez; cAdapter.SetIPAddress( pAddressList->IpAddress.String ); cAdapter.SetIPNetMask( pAddressList->IpMask.String ); // Update network number if possible if( inet_addr( pAddressList->IpAddress.String ) != INADDR_NONE ){ ipAdr = ntohl(inet_addr ( pAddressList->IpAddress.String )); ipMsk = ntohl(inet_addr ( pAddressList->IpMask.String )); nbRez = ipAdr & ipMsk ; ipa.S_un.S_addr = htonl(nbRez); cAdapter.SetNetNumber( inet_ntoa(ipa) ); } // Create en Adapter entry for each Adapter/Address pList->AddTail( cAdapter); uIndex ++; pAddressList = pAddressList->Next; } while( pAddressList != NULL ); // End If sameMac Address } // End For each interface } // Free memory free( pIfTable); free( pAdapterTable); // Unload library FreeLibrary( hDll); AddLog( _T( "OK\n")); if (uIndex > 0) { AddLog( _T( "IpHlpAPI GetNetworkAdapters: OK (%u objects).\n"), uIndex); return TRUE; } AddLog( _T( "IpHlpAPI GetNetworkAdapters: Failed because no network adapter object !\n")); return FALSE; }
void UIVMInformationDialog::retranslateUi() { sltUpdateDetails(); AssertReturnVoid(!m_session.isNull()); CMachine machine = m_session.GetMachine(); AssertReturnVoid(!machine.isNull()); /* Setup dialog title: */ setWindowTitle(tr("%1 - Session Information").arg(machine.GetName())); /* Translate tabs: */ m_pTabWidget->setTabText(0, tr("Configuration &Details")); m_pTabWidget->setTabText(1, tr("&Runtime Information")); /* Clear counter names initially: */ m_names.clear(); m_units.clear(); m_links.clear(); /* Storage statistics: */ CSystemProperties sp = vboxGlobal().virtualBox().GetSystemProperties(); CStorageControllerVector controllers = m_session.GetMachine().GetStorageControllers(); int iIDECount = 0, iSATACount = 0, iSCSICount = 0; foreach (const CStorageController &controller, controllers) { switch (controller.GetBus()) { case KStorageBus_IDE: { for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus(KStorageBus_IDE); ++i) { for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus(KStorageBus_IDE); ++j) { /* Names: */ m_names[QString("/Devices/IDE%1/ATA%2/Unit%3/*DMA") .arg(iIDECount).arg(i).arg(j)] = tr("DMA Transfers"); m_names[QString("/Devices/IDE%1/ATA%2/Unit%3/*PIO") .arg(iIDECount).arg(i).arg(j)] = tr("PIO Transfers"); m_names[QString("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes") .arg(iIDECount).arg(i).arg(j)] = tr("Data Read"); m_names[QString("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes") .arg(iIDECount).arg(i).arg(j)] = tr("Data Written"); /* Units: */ m_units[QString("/Devices/IDE%1/ATA%2/Unit%3/*DMA") .arg(iIDECount).arg(i).arg(j)] = "[B]"; m_units[QString("/Devices/IDE%1/ATA%2/Unit%3/*PIO") .arg(iIDECount).arg(i).arg(j)] = "[B]"; m_units[QString("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes") .arg(iIDECount).arg(i).arg(j)] = "B"; m_units[QString("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes") .arg(iIDECount).arg(i).arg(j)] = "B"; /* Belongs to */ m_links[QString("/Devices/IDE%1/ATA%2/Unit%3").arg(iIDECount).arg(i).arg(j)] = QStringList() << QString("/Devices/IDE%1/ATA%2/Unit%3/*DMA").arg(iIDECount).arg(i).arg(j) << QString("/Devices/IDE%1/ATA%2/Unit%3/*PIO").arg(iIDECount).arg(i).arg(j) << QString("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes").arg(iIDECount).arg(i).arg(j) << QString("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes").arg(iIDECount).arg(i).arg(j); } } ++iIDECount; break; } case KStorageBus_SATA: { for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus(KStorageBus_SATA); ++i) { for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus(KStorageBus_SATA); ++j) { /* Names: */ m_names[QString("/Devices/SATA%1/Port%2/DMA").arg(iSATACount).arg(i)] = tr("DMA Transfers"); m_names[QString("/Devices/SATA%1/Port%2/ReadBytes").arg(iSATACount).arg(i)] = tr("Data Read"); m_names[QString("/Devices/SATA%1/Port%2/WrittenBytes").arg(iSATACount).arg(i)] = tr("Data Written"); /* Units: */ m_units[QString("/Devices/SATA%1/Port%2/DMA").arg(iSATACount).arg(i)] = "[B]"; m_units[QString("/Devices/SATA%1/Port%2/ReadBytes").arg(iSATACount).arg(i)] = "B"; m_units[QString("/Devices/SATA%1/Port%2/WrittenBytes").arg(iSATACount).arg(i)] = "B"; /* Belongs to: */ m_links[QString("/Devices/SATA%1/Port%2").arg(iSATACount).arg(i)] = QStringList() << QString("/Devices/SATA%1/Port%2/DMA").arg(iSATACount).arg(i) << QString("/Devices/SATA%1/Port%2/ReadBytes").arg(iSATACount).arg(i) << QString("/Devices/SATA%1/Port%2/WrittenBytes").arg(iSATACount).arg(i); } } ++iSATACount; break; } case KStorageBus_SCSI: { for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus(KStorageBus_SCSI); ++i) { for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus(KStorageBus_SCSI); ++j) { /* Names: */ m_names[QString("/Devices/SCSI%1/%2/ReadBytes").arg(iSCSICount).arg(i)] = tr("Data Read"); m_names[QString("/Devices/SCSI%1/%2/WrittenBytes").arg(iSCSICount).arg(i)] = tr("Data Written"); /* Units: */ m_units[QString("/Devices/SCSI%1/%2/ReadBytes").arg(iSCSICount).arg(i)] = "B"; m_units[QString("/Devices/SCSI%1/%2/WrittenBytes").arg(iSCSICount).arg(i)] = "B"; /* Belongs to: */ m_links[QString("/Devices/SCSI%1/%2").arg(iSCSICount).arg(i)] = QStringList() << QString("/Devices/SCSI%1/%2/ReadBytes").arg(iSCSICount).arg(i) << QString("/Devices/SCSI%1/%2/WrittenBytes").arg(iSCSICount).arg(i); } } ++iSCSICount; break; } default: break; } } /* Network statistics: */ ulong count = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(KChipsetType_PIIX3); for (ulong i = 0; i < count; ++i) { CNetworkAdapter na = machine.GetNetworkAdapter(i); KNetworkAdapterType ty = na.GetAdapterType(); const char *name; switch (ty) { case KNetworkAdapterType_I82540EM: case KNetworkAdapterType_I82543GC: case KNetworkAdapterType_I82545EM: name = "E1k"; break; case KNetworkAdapterType_Virtio: name = "VNet"; break; default: name = "PCNet"; break; } /* Names: */ m_names[QString("/Devices/%1%2/TransmitBytes").arg(name).arg(i)] = tr("Data Transmitted"); m_names[QString("/Devices/%1%2/ReceiveBytes").arg(name).arg(i)] = tr("Data Received"); /* Units: */ m_units[QString("/Devices/%1%2/TransmitBytes").arg(name).arg(i)] = "B"; m_units[QString("/Devices/%1%2/ReceiveBytes").arg(name).arg(i)] = "B"; /* Belongs to: */ m_links[QString("NA%1").arg(i)] = QStringList() << QString("/Devices/%1%2/TransmitBytes").arg(name).arg(i) << QString("/Devices/%1%2/ReceiveBytes").arg(name).arg(i); } /* Statistics page update: */ refreshStatistics(); }
int CNetworkAdapter::operator==(CNetworkAdapter cObject) const { return ((m_csNetNumber == cObject.GetNetNumber()) && (m_lIndex == cObject.GetIfIndex()) && (m_csDescription == cObject.GetDescription()) && (m_csType == cObject.GetType()) && (m_csTypeMIB == cObject.GetTypeMIB()) && (m_csSpeed == cObject.GetSpeed()) && (m_ulSpeed == cObject.GetByteSpeed()) && (m_csHWAddr == cObject.GetMACAddress()) && (m_csOperStatus == cObject.GetOperationalStatus()) && (m_csIPAddr == cObject.GetIPAddress()) && (m_csIPNetMask == cObject.GetIPNetMask()) && (m_csGateway == cObject.GetGateway()) && (m_csDhcpServer == cObject.GetDhcpServer())); }