BOOL CNdasDeviceComm::Initialize(BOOL bWriteAccess) { m_bWriteAccess = bWriteAccess; InitializeLANSCSIPath(); LPX_ADDRESS local, remote; local = m_pDevice->GetLocalLpxAddress(); remote = m_pDevice->GetRemoteLpxAddress(); SOCKET sock = CreateLpxConnection(&remote, &local); if (INVALID_SOCKET == sock) { DPErrorEx(_FT("CreateLpxConnection failed: ")); return FALSE; } m_lspath.HWType = m_pDevice->GetHWType(); m_lspath.HWVersion = m_pDevice->GetHWVersion(); m_lspath.connsock = sock; INT iResult = Login(&m_lspath, LOGIN_TYPE_NORMAL); if (0 != iResult) { // TODO: LANDISK_ERROR_BADKEY? DPErrorEx(_FT("Login failed (ret %d): "), iResult); ::closesocket(sock); return FALSE; } m_bInitialized = TRUE; return TRUE; }
BOOL CNdasDevice::GetDeviceInfo( const LPX_ADDRESS& localAddress, const LPX_ADDRESS& remoteAddress, UCHAR ucType, UCHAR ucVersion) { ximeta::CAutoLock autolock(this); // // Get Device Information // LANSCSI_PATH lspath = {0}; // Discover does not need any user id lspath.iUserID = 0x0000; lspath.iPassword = GetHWPassword(); lspath.HWType = ucType; lspath.HWVersion = ucVersion; lspath.HWProtoType = ucType; lspath.HWProtoVersion = (LANSCSIIDE_VERSION_1_1 == ucVersion) ? LSIDEPROTO_VERSION_1_1 : LSIDEPROTO_VERSION_1_0; // // create an LPX (auto) socket // AutoSocket autoSock = CreateLpxConnection(&remoteAddress, &localAddress); // // autoSock will close the handle when it goes out of scope // if (INVALID_SOCKET == (SOCKET) autoSock) { // // TODO: EVENTLOG NDAS_DEVICE_ERROR_LPX_SOCKET_FAILED // DBGPRT_ERR_EX(_FT("Error Create Connection: ")); SetLastDeviceError(NDAS_DEVICE_ERROR_LPX_SOCKET_FAILED); return FALSE; } // // Discover // lspath.connsock = autoSock; INT iResult = Discovery(&lspath); if (0 != iResult) { // // TODO: EVENTLOG NDAS_DEVICE_ERROR_DISCOVER_FAILED // DBGPRT_ERR_EX(_FT("Discovery failed! - returned (%d) : "), iResult); SetLastDeviceError(NDAS_DEVICE_ERROR_DISCOVER_FAILED); return FALSE; } // // If discovering succeeded, set pController's // LANSCSI path to discovered LANSCSI path // m_hwInfo.nMaxRequestBlocks = lspath.iMaxBlocks; m_hwInfo.nSlots = lspath.iNumberofSlot; m_hwInfo.nTargets = lspath.iNRTargets; m_hwInfo.nMaxTargets = lspath.iMaxTargets; m_hwInfo.nMaxLUs = lspath.iMaxLUs; ::CopyMemory(&m_localLpxAddress, &localAddress, sizeof(LPX_ADDRESS)); ::CopyMemory(&m_remoteLpxAddress, &remoteAddress, sizeof(LPX_ADDRESS)); // // actual hardware type and version is filled in lspath // m_hwInfo.ucType = lspath.HWType; m_hwInfo.ucVersion = lspath.HWVersion; // // at discovery only lspath.PerTarget[i].NORWHost and NOROHost are valid. // for (DWORD i = 0; i < MAX_NDAS_UNITDEVICE_COUNT; i++) { m_fUnitDevicePresent[i] = lspath.PerTarget[i].bPresent; if (NULL != m_pUnitDevices[i]) { m_pUnitDevices[i]->SetHostUsageCount( lspath.PerTarget[i].NRROHost, lspath.PerTarget[i].NRRWHost); } } return TRUE; }