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(); }
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(""); }
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())); }