BOOL CNdasUnitDevice::CheckNDFSCompatibility() { ximeta::CAutoLock autolock(this); // // Unit devices other than disks are not allowed for NDFS // if (m_type != NDAS_UNITDEVICE_TYPE_DISK) { return FALSE; } // // LfsFilter compatibility check. // NDFS Major version should be same // WORD wHostNDFSVerMajor; BOOL fSuccess = ::LfsFiltCtlGetVersion( NULL, NULL, NULL, NULL, &wHostNDFSVerMajor, NULL); if (!fSuccess) { DBGPRT_ERR_EX(_FT("Getting LFS Filter Version failed:")); return FALSE; } // // Primary Host Info is valid for 30 seconds // DWORD dwMaxTickAllowance = 30 * 1000; if (0 != m_PrimaryHostInfo.NDFSCompatVersion && ::GetTickCount() < m_PrimaryHostInfo.LastUpdate + dwMaxTickAllowance) { // primary host info is valid return (wHostNDFSVerMajor == m_PrimaryHostInfo.NDFSCompatVersion); } // // No Primary Host Info is available (IX) // Use HIX to discover // CNdasHIXDiscover hixdisc(pGetNdasHostGuid()); fSuccess = hixdisc.Initialize(); if (!fSuccess) { DBGPRT_ERR_EX(_FT("HIXDiscover init failed: ")); return FALSE; } NDAS_UNITDEVICE_ID udid = GetUnitDeviceId(); hixdisc.Discover(udid,NHIX_UDA_SHRW_PRIM,1,1000); DWORD nHosts = hixdisc.GetHostCount(udid); if (0 == nHosts) { DBGPRT_ERR_EX(_FT("GetHostCount failed: ")); return FALSE; } GUID hostGuid; fSuccess = hixdisc.GetHostData(udid,0,NULL,&hostGuid,NULL,NULL); if (!fSuccess) { DBGPRT_ERR_EX(_FT("GetHostData failed: ")); return FALSE; } CNdasHostInfoCache* phic = pGetNdasHostInfoCache(); _ASSERTE(phic); // phic is not null (by pGetNdasHostInfoCache) CONST NDAS_HOST_INFO* pHostInfo = phic->GetHostInfo(&hostGuid); if (NULL == pHostInfo) { DBGPRT_ERR_EX(_FT("GetHostInfo failed: ")); return FALSE; } if (pHostInfo->NDASSWVerInfo.VersionMajor != wHostNDFSVerMajor) { DBGPRT_ERR(_FT("Host NDFS %d, Primary NDFS %d failed: "), wHostNDFSVerMajor, pHostInfo->NDASSWVerInfo.VersionMajor); return FALSE; } // // Primary and this host's NDFS compat version is same // return TRUE; }
STDMETHODIMP CNdasUnitImpl::CheckNdasfsCompatibility() { CAutoInstanceLock autolock(this); HRESULT hr; // Unit devices other than disks are not allowed for NDFS if (m_type != NDAS_UNITDEVICE_TYPE_DISK) { return E_FAIL; } // LfsFilter compatibility check. // NDFS Major version should be same WORD wHostNDFSVerMajor; BOOL success = ::LfsFiltCtlGetVersion( NULL, NULL, NULL, NULL, &wHostNDFSVerMajor, NULL ); if (!success) { ATLASSERT(FALSE); hr = HRESULT_FROM_WIN32(GetLastError()); hr = SUCCEEDED(hr) ? E_FAIL : hr; return hr; } ATLASSERT( wHostNDFSVerMajor == 0x0006 ); // Primary Host Info is valid for 30 seconds #if 0 DWORD dwMaxTickAllowance = 30 * 1000; if (0 != m_PrimaryHostInfo.NDFSCompatVersion && ::GetTickCount() < m_PrimaryHostInfo.LastUpdate + dwMaxTickAllowance) { // primary host info is valid return (wHostNDFSVerMajor == m_PrimaryHostInfo.NDFSCompatVersion); } #endif // No Primary Host Info is available (IX) // Use HIX to discover CNdasHIXDiscover hixdisc(pGetNdasHostGuid()); success = hixdisc.Initialize(); if (!success) { ATLASSERT(FALSE); hr = HRESULT_FROM_WIN32(GetLastError()); hr = SUCCEEDED(hr) ? E_FAIL : hr; return hr; } NDAS_UNITDEVICE_ID ndasUnitId; get_NdasUnitId( &ndasUnitId ); ATLASSERT( ndasUnitId.DeviceId.Reserved == 0 ); DWORD timeout = NdasServiceConfig::Get(nscWriteShareCheckTimeout); success = hixdisc.HixDiscover( ndasUnitId, NHIX_UDA_SHRW_PRIM, 1, timeout ); if (!success) { ATLASSERT(FALSE); hr = HRESULT_FROM_WIN32(GetLastError()); hr = SUCCEEDED(hr) ? E_FAIL : hr; XTLTRACE2(NDASSVC_NDASUNITDEVICE, TRACE_LEVEL_ERROR, "hixdisc.Discover failed, hr=0x%X\n", hr); return hr; } DWORD nHosts = hixdisc.GetHostCount(ndasUnitId); if (nHosts == 0) { hr = HRESULT_FROM_WIN32(GetLastError()); hr = SUCCEEDED(hr) ? E_FAIL : hr; XTLTRACE2(NDASSVC_NDASUNITDEVICE, TRACE_LEVEL_ERROR, "GetHostCount failed, hr=0x%X\n", hr); return hr; } GUID hostGuid; success = hixdisc.GetHostData( ndasUnitId, 0, NULL, &hostGuid, NULL, NULL ); if (!success) { ATLASSERT(FALSE); hr = HRESULT_FROM_WIN32(GetLastError()); hr = SUCCEEDED(hr) ? E_FAIL : hr; XTLTRACE2(NDASSVC_NDASUNITDEVICE, TRACE_LEVEL_ERROR, "GetHostData failed, hr=0x%X\n", hr); return hr; } CNdasHostInfoCache* phic = pGetNdasHostInfoCache(); XTLASSERT(phic); // phic is not null (by pGetNdasHostInfoCache) const NDAS_HOST_INFO* pHostInfo = phic->GetHostInfo(&hostGuid); if (pHostInfo == NULL) { ATLASSERT(FALSE); hr = HRESULT_FROM_WIN32(GetLastError()); hr = SUCCEEDED(hr) ? E_FAIL : hr; XTLTRACE2(NDASSVC_NDASUNITDEVICE, TRACE_LEVEL_ERROR, "GetHostInfo failed, hr=0x%X\n", hr); return hr; } // ReservedVerInfo contains NDFS Version Information if (pHostInfo->ReservedVerInfo.VersionMajor != wHostNDFSVerMajor) { NdasUiDbgCall( 1, "Host NDFS %d, Primary NDFS %d failed\n", wHostNDFSVerMajor, pHostInfo->ReservedVerInfo.VersionMajor ); return E_FAIL; } // Primary and this host's NDFS compatible version is same return S_OK; }
BOOL CNdasUnitDevice::CheckNDFSCompatibility() { InstanceAutoLock autolock(this); // // Unit devices other than disks are not allowed for NDFS // if (m_type != NDAS_UNITDEVICE_TYPE_DISK) { return FALSE; } // // LfsFilter compatibility check. // NDFS Major version should be same // WORD wHostNDFSVerMajor; BOOL fSuccess = ::LfsFiltCtlGetVersion( NULL, NULL, NULL, NULL, &wHostNDFSVerMajor, NULL); if (!fSuccess) { XTLTRACE2(NDASSVC_NDASUNITDEVICE, TRACE_LEVEL_ERROR, "Getting LFS Filter Version failed, error=0x%X\n", GetLastError()); return FALSE; } // // Primary Host Info is valid for 30 seconds // #if 0 DWORD dwMaxTickAllowance = 30 * 1000; if (0 != m_PrimaryHostInfo.NDFSCompatVersion && ::GetTickCount() < m_PrimaryHostInfo.LastUpdate + dwMaxTickAllowance) { // primary host info is valid return (wHostNDFSVerMajor == m_PrimaryHostInfo.NDFSCompatVersion); } #endif // // No Primary Host Info is available (IX) // Use HIX to discover // CNdasHIXDiscover hixdisc(pGetNdasHostGuid()); fSuccess = hixdisc.Initialize(); if (!fSuccess) { XTLTRACE2(NDASSVC_NDASUNITDEVICE, TRACE_LEVEL_ERROR, "HIXDiscover init failed, error=0x%X\n", GetLastError()); return FALSE; } NDAS_UNITDEVICE_ID udid = GetUnitDeviceId(); DWORD timeout = NdasServiceConfig::Get(nscWriteShareCheckTimeout); fSuccess = hixdisc.Discover(udid,NHIX_UDA_SHRW_PRIM,1,timeout); if (!fSuccess) { XTLTRACE2(NDASSVC_NDASUNITDEVICE, TRACE_LEVEL_ERROR, "hixdisc.Discover failed, error=0x%X\n", GetLastError()); return FALSE; } DWORD nHosts = hixdisc.GetHostCount(udid); if (0 == nHosts) { XTLTRACE2(NDASSVC_NDASUNITDEVICE, TRACE_LEVEL_ERROR, "GetHostCount failed, error=0x%X\n", GetLastError()); return FALSE; } GUID hostGuid; fSuccess = hixdisc.GetHostData(udid,0,NULL,&hostGuid,NULL,NULL); if (!fSuccess) { XTLTRACE2(NDASSVC_NDASUNITDEVICE, TRACE_LEVEL_ERROR, "GetHostData failed, error=0x%X\n", GetLastError()); return FALSE; } CNdasHostInfoCache* phic = pGetNdasHostInfoCache(); XTLASSERT(phic); // phic is not null (by pGetNdasHostInfoCache) const NDAS_HOST_INFO* pHostInfo = phic->GetHostInfo(&hostGuid); if (NULL == pHostInfo) { XTLTRACE2(NDASSVC_NDASUNITDEVICE, TRACE_LEVEL_ERROR, "GetHostInfo failed, error=0x%X\n", GetLastError()); return FALSE; } // // ReservedVerInfo contains NDFS Version Information // if (pHostInfo->ReservedVerInfo.VersionMajor != wHostNDFSVerMajor) { XTLTRACE2(NDASSVC_NDASUNITDEVICE, TRACE_LEVEL_ERROR, "Host NDFS %d, Primary NDFS %d failed.\n", wHostNDFSVerMajor, pHostInfo->ReservedVerInfo.VersionMajor); return FALSE; } // // Primary and this host's NDFS compatible version is same // return TRUE; }