NTSTATUS LspReconnect( IN OUT PLANSCSI_SESSION LSS, IN LSTRANS_TYPE LstransType ) { NTSTATUS ntStatus; ASSERT(LSS); ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); ntStatus = LstransOpenAddress(&LSS->SourceAddress, &LSS->AddressFile); if( !NT_SUCCESS(ntStatus) ) { goto cleanup; } ntStatus = LstransOpenConnection(NULL, LstransType, &LSS->ConnectionFile); if( !NT_SUCCESS(ntStatus) ) { LstransCloseAddress(&LSS->AddressFile); goto cleanup; } ntStatus = LstransAssociate(&LSS->AddressFile, &LSS->ConnectionFile); if( !NT_SUCCESS(ntStatus) ) { LstransCloseConnection(&LSS->ConnectionFile); LstransCloseAddress(&LSS->AddressFile); goto cleanup; } ntStatus = LstransConnect(&LSS->ConnectionFile, &LSS->LSNodeAddress, &LSS->TimeOuts[0]); if( !NT_SUCCESS(ntStatus) ) { LstransDisassociate(&LSS->ConnectionFile); LstransCloseConnection(&LSS->ConnectionFile); LstransCloseAddress(&LSS->AddressFile); goto cleanup; } cleanup: return ntStatus; }
NTSTATUS LspReconnectAndLogin( IN OUT PLANSCSI_SESSION LSS, IN LSTRANS_TYPE LstransType ) { NTSTATUS ntStatus; LSSLOGIN_INFO LoginInfo; LSPROTO_TYPE LSProto; ASSERT(LSS); LoginInfo.LoginType = LOGIN_TYPE_NORMAL; RtlCopyMemory(&LoginInfo.UserID, &LSS->UserID, LSPROTO_USERID_LENGTH); RtlCopyMemory(&LoginInfo.Password, &LSS->Password, LSPROTO_PASSWORD_LENGTH); LoginInfo.MaxBlocksPerRequest = LSS->MaxBlocksPerRequest; LoginInfo.LanscsiTargetID = LSS->LanscsiTargetID; LoginInfo.LanscsiLU = LSS->LanscsiLU; LoginInfo.HWType = LSS->HWType; LoginInfo.HWVersion = LSS->HWVersion; ntStatus = LspLookupProtocol(LSS->HWType, LSS->HWVersion, &LSProto); if(!NT_SUCCESS(ntStatus)) { KDPrintM(DBG_PROTO_ERROR, ("HWVersion wrong.\n")); return STATUS_NOT_IMPLEMENTED; } ntStatus = LstransOpenAddress(&LSS->SourceAddress, &LSS->AddressFile); if( !NT_SUCCESS(ntStatus) ) { goto cleanup; } ntStatus = LstransOpenConnection(NULL, LstransType, &LSS->ConnectionFile); if( !NT_SUCCESS(ntStatus) ) { LstransCloseAddress(&LSS->AddressFile); goto cleanup; } ntStatus = LstransAssociate(&LSS->AddressFile, &LSS->ConnectionFile); if( !NT_SUCCESS(ntStatus) ) { LstransCloseConnection(&LSS->ConnectionFile); LstransCloseAddress(&LSS->AddressFile); goto cleanup; } ntStatus = LstransConnect(&LSS->ConnectionFile, &LSS->LSNodeAddress, &LSS->TimeOuts[0]); if( !NT_SUCCESS(ntStatus) ) { LstransDisassociate(&LSS->ConnectionFile); LstransCloseConnection(&LSS->ConnectionFile); LstransCloseAddress(&LSS->AddressFile); goto cleanup; } /* ntStatus = LstransRegisterDisconnectHandler( &LSS->AddressFile, LspDisconHandler, &LSS ); if( !NT_SUCCESS(ntStatus) ) { LstransDisassociate(&LSS->AddressFile, &LSS->ConnectionFile); LstransCloseConnection(&LSS->ConnectionFile); LstransCloseAddress(&LSS->AddressFile); goto cleanup; } */ ntStatus = LspLogin( LSS, &LoginInfo, LSProto ); if(!NT_SUCCESS(ntStatus)) { LstransDisconnect(&LSS->ConnectionFile, 0); LstransDisassociate(&LSS->ConnectionFile); LstransCloseConnection(&LSS->ConnectionFile); LstransCloseAddress(&LSS->AddressFile); goto cleanup; } cleanup: return ntStatus; }
NTSTATUS LspConnect( IN OUT PLANSCSI_SESSION LSS, IN PTA_LSTRANS_ADDRESS SrcAddr, IN PTA_LSTRANS_ADDRESS DestAddr ) { NTSTATUS ntStatus; ASSERT(LSS); ASSERT(DestAddr); if(SrcAddr->Address[0].AddressType != DestAddr->Address[0].AddressType) return STATUS_INVALID_PARAMETER; // // Save dest and src addresses // RtlCopyMemory(&LSS->LSNodeAddress, DestAddr, sizeof(TA_LSTRANS_ADDRESS)); if(SrcAddr) RtlCopyMemory(&LSS->SourceAddress, SrcAddr, sizeof(TA_LSTRANS_ADDRESS)); ntStatus = LstransOpenAddress(SrcAddr, &LSS->AddressFile); if( !NT_SUCCESS(ntStatus) ) { goto cleanup; } ntStatus = LstransOpenConnection(NULL, DestAddr->Address[0].AddressType, &LSS->ConnectionFile); if( !NT_SUCCESS(ntStatus) ) { LstransCloseAddress(&LSS->AddressFile); goto cleanup; } ntStatus = LstransAssociate(&LSS->AddressFile, &LSS->ConnectionFile); if( !NT_SUCCESS(ntStatus) ) { LstransCloseConnection(&LSS->ConnectionFile); LstransCloseAddress(&LSS->AddressFile); goto cleanup; } ntStatus = LstransConnect(&LSS->ConnectionFile, DestAddr, &LSS->TimeOuts[0]); if( !NT_SUCCESS(ntStatus) ) { LstransDisassociate(&LSS->ConnectionFile); LstransCloseConnection(&LSS->ConnectionFile); LstransCloseAddress(&LSS->AddressFile); goto cleanup; } /* ntStatus = LstransRegisterDisconnectHandler( &LSS->AddressFile, LspDisconHandler, &LSS ); if( !NT_SUCCESS(ntStatus) ) { LstransDisassociate(&LSS->AddressFile, &LSS->ConnectionFile); LstransCloseConnection(&LSS->ConnectionFile); LstransCloseAddress(&LSS->AddressFile); goto cleanup; } */ cleanup: return ntStatus; }
NTSTATUS LspConnect( IN OUT PLANSCSI_SESSION LSS, IN PTA_LSTRANS_ADDRESS SrcAddr, IN PTA_LSTRANS_ADDRESS DestAddr, IN PLSTRANS_OVERLAPPED Overlapped, IN PLARGE_INTEGER TimeOut ) { NTSTATUS ntStatus; NDASSCSI_ASSERT( TimeOut == NULL || TimeOut->QuadPart < 0 ); ASSERT(LSS); ASSERT(SrcAddr); ASSERT(DestAddr); if(SrcAddr->Address[0].AddressType != DestAddr->Address[0].AddressType) return STATUS_INVALID_PARAMETER; // // Save dest and src addresses // RtlCopyMemory(&LSS->LSNodeAddress, DestAddr, sizeof(TA_LSTRANS_ADDRESS)); RtlCopyMemory(&LSS->BindAddress, SrcAddr, sizeof(TA_LSTRANS_ADDRESS)); ntStatus = LstransOpenAddress(SrcAddr, &LSS->AddressFile); if( !NT_SUCCESS(ntStatus) ) { goto cleanup; } ntStatus = LstransOpenConnection(NULL, DestAddr->Address[0].AddressType, &LSS->ConnectionFile); if( !NT_SUCCESS(ntStatus) ) { LstransCloseAddress(&LSS->AddressFile); goto cleanup; } ntStatus = LstransAssociate(&LSS->AddressFile, &LSS->ConnectionFile); if( !NT_SUCCESS(ntStatus) ) { LstransCloseConnection(&LSS->ConnectionFile); LstransCloseAddress(&LSS->AddressFile); goto cleanup; } ntStatus = LstransConnect( &LSS->ConnectionFile, DestAddr, IF_NULL_TIMEOUT_THEN_DEFAULT(LSS, TimeOut), Overlapped); if( !NT_SUCCESS(ntStatus) ) { LstransDisassociate(&LSS->ConnectionFile); LstransCloseConnection(&LSS->ConnectionFile); LstransCloseAddress(&LSS->AddressFile); goto cleanup; } LSS->DataEncryptAlgo = 0; LSS->EncryptBuffer = NULL; /* ntStatus = LstransRegisterDisconnectHandler( &LSS->AddressFile, LspDisconHandler, &LSS ); if( !NT_SUCCESS(ntStatus) ) { LstransDisassociate(&LSS->AddressFile, &LSS->ConnectionFile); LstransCloseConnection(&LSS->ConnectionFile); LstransCloseAddress(&LSS->AddressFile); goto cleanup; } */ cleanup: return ntStatus; }