/// <summary> /// NTTrans set quota request additional. /// </summary> /// <param name="messageId">Message ID used to identify the message.</param> /// <param name="sessionId"> /// Set this value to 0 to request a new session setup, or set this value to a previously established session /// identifier to request reauthenticate to an existing session. /// </param> /// <param name="treeId"> /// This field identifies the subdirectory (or tree) (also referred as a share in this document) on the /// server that the client is accessing. /// </param> /// <param name="fid">The file identifier.</param> /// <param name="isSigned"> /// Indicate whether the SUT has message signing enabled or required. /// </param> /// <param name="requestPara">NTTrans set quota request parameter.</param> public void NtTransSetQuotaRequestAdditional( int messageId, int sessionId, int treeId, int fid, bool isSigned, NtTransSetQuotaRequestParameter requestPara) { #region Create Packet SmbNtTransSetQuotaRequestPacket smbPacket = new SmbNtTransSetQuotaRequestPacket(); ushort uid = (ushort)this.uId[(uint)sessionId]; ushort fileId = (ushort)this.fId[(uint)fid]; string sid = Site.Properties["SutLoginAdminUserFullPathName"]; byte[] sidByte = this.GetSid(sid); uint nextEntryOffset = uint.MinValue; ulong quotaUsed = ulong.MinValue; ulong changeTime = ulong.MinValue; quotaUsed++; smbPacket = this.smbClientStack.CreateNTTransSetQuotaRequest( fileId, nextEntryOffset, changeTime, (ulong)quotaUsed, this.quotaThreshold, this.quotalimit, sidByte); if (isSigned) { NamespaceCifs.CifsClientPerConnection connection = this.smbClientStack.Context.GetConnection(ConnectionId); NamespaceCifs.CifsClientPerSession session = this.smbClientStack.Context.GetSession(ConnectionId, uid); smbPacket.Sign(connection.ClientNextSendSequenceNumber, session.SessionKey); } bool isVaildFileId = true; if (requestPara == NtTransSetQuotaRequestParameter.FileIdErrror) { isVaildFileId = false; } if (!isVaildFileId) { NT_TRANSACT_SET_QUOTA_Request_NT_Trans_Parameters setQuotaParameters = smbPacket.NtTransParameters; setQuotaParameters.Fid = ushort.MaxValue; smbPacket.NtTransParameters = setQuotaParameters; } if ((requestPara == NtTransSetQuotaRequestParameter.AccessDenied)) { NT_TRANSACT_SET_QUOTA_Request_NT_Trans_Data setQuotaData = smbPacket.NtTransData; setQuotaData.QuotaLimit = ulong.MaxValue; smbPacket.NtTransData = setQuotaData; } bool isVaildQuotaInfo = true; if (requestPara == NtTransSetQuotaRequestParameter.QuotaInfoError) { isVaildQuotaInfo = false; } if (!isVaildQuotaInfo) { NT_TRANSACT_SET_QUOTA_Request_NT_Trans_Data setQuotaData = smbPacket.NtTransData; setQuotaData.QuotaLimit = ulong.MaxValue; setQuotaData.QuotaThreshold = ulong.MaxValue; setQuotaData.QuotaUsed = ulong.MaxValue; setQuotaData.NextEntryOffset = uint.MaxValue; setQuotaData.ChangeTime = ulong.MaxValue; smbPacket.NtTransData = setQuotaData; } #endregion #region Send and Receive ExpectPacket this.smbClientStack.SendPacket(smbPacket); StackPacket response = this.smbClientStack.ExpectPacket(this.timeout); NamespaceCifs.SmbPacket smbPacketResponse = (NamespaceCifs.SmbPacket)response; this.QueryUidTable(smbPacketResponse); this.QueryTidTable(smbPacketResponse); VerifyTransport(smbPacketResponse); VerifyCommonMessageSyntax(smbPacketResponse); if (response.GetType() == typeof(SmbErrorResponsePacket)) { SmbErrorResponsePacket smbErrorResponsePacket = response as SmbErrorResponsePacket; NamespaceCifs.SmbHeader smbErrorHeader = smbErrorResponsePacket.SmbHeader; //f temp code (How To Trigger InvalidParameter TDQ) if (!isVaildQuotaInfo && !bool.Parse(Site.Properties["IsTDQ33005Fixed"])) { this.ErrorNtTransSetQuotaResponseAdditional( smbErrorHeader.Mid + this.addMidMark, MessageStatus.InvalidParameter); } //Workaround temp code (FILEID ERROR TDI) else if ((requestPara == NtTransSetQuotaRequestParameter.FileIdErrror) && !bool.Parse(Site.Properties["IsTDI33008Fixed"])) { this.ErrorNtTransSetQuotaResponseAdditional( smbErrorHeader.Mid + this.addMidMark, MessageStatus.StatusInvalidHandle); } else { this.ErrorNtTransSetQuotaResponseAdditional( smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status); } } else { SmbNtTransSetQuotaResponsePacket smbNtTransSetQuotaPacket = response as SmbNtTransSetQuotaResponsePacket; NamespaceCifs.SmbHeader ntTransSetQuotaResponseHeader = smbNtTransSetQuotaPacket.SmbHeader; VerifyMessageSyntaxNtTransactSetQuotaRequest( smbNtTransSetQuotaPacket, ntTransSetQuotaResponseHeader.Status); //Workaround temp code (Expected AccessDenied, actually Success) if ((requestPara == NtTransSetQuotaRequestParameter.AccessDenied) && !bool.Parse(Site.Properties["IsTDI50461Fixed"])) { this.ErrorNtTransSetQuotaResponseAdditional( ntTransSetQuotaResponseHeader.Mid + this.addMidMark, MessageStatus.AccessDenied); } else { this.NtTransSetQuotaResponseAdditional( ntTransSetQuotaResponseHeader.Mid + this.addMidMark, this.QueryUidTable(smbPacketResponse), this.QueryTidTable(smbPacketResponse), (smbPacketResponse).IsSignRequired, (MessageStatus)ntTransSetQuotaResponseHeader.Status); } } #endregion }
public static void NtTransSetQuotaRequestAdditional( int messageId, int sessionId, int treeId, int fId, bool isSigned, NtTransSetQuotaRequestParameter requestPara) { Condition.IsTrue(smbConnection.openedFiles.ContainsKey(fId)); Condition.IsTrue(smbConnection.openedFiles[fId].treeId == treeId); Checker.CheckRequest(smbConnection, messageId, sessionId, treeId, isSigned, smbState); if (createFileAccess == 1) { // Created file is readonly. Condition.IsTrue(requestPara == NtTransSetQuotaRequestParameter.AccessDenied); } else { Condition.IsTrue(requestPara != NtTransSetQuotaRequestParameter.AccessDenied); } smbRequest = new NTTransactSetQuotaRequestAdditional( messageId, sessionId, treeId, fId, isSigned, requestPara); Update.UpdateRequest(smbConnection, smbRequest); }
/// <summary> /// NT_TRANSACT_SET_QUOTA Client Request. /// </summary> /// <param name="messageId">This is used to associate a response with a request.</param> /// <param name="sessionId"> /// Set this value to 0 to request a new session setup, or set this value to a previously established session /// identifier to request the re-authentication of an existing session. /// </param> /// <param name="treeId">This is used to indicate the share that the client is accessing.</param> /// <param name="isSigned">It indicates whether the SUT has message signing enabled or required.</param> /// <param name="fId">The SMB file identifier of the target directory.</param> /// <param name="requestPara">NT_TRANSACT_SET_QUOTA request parameter.</param> public NTTransactSetQuotaRequestAdditional( int messageId, int sessionId, int treeId, int fId, bool isSigned, NtTransSetQuotaRequestParameter requestPara) : base(messageId, Command.NtTransactSetQuotaAdditional) { this.sessionId = sessionId; this.treeId = treeId; this.fId = fId; this.isSigned = isSigned; this.requestPara = requestPara; }