/// <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 }
/// <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 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="quotaInfo">The amount of quota, in bytes, used by this user.</param> public void NtTransSetQuotaRequest( int messageId, int sessionId, int treeId, int fid, bool isSigned, int quotaUsed) { #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 changeTime = uint.MinValue; 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); } #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; this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status); } else { SmbNtTransSetQuotaResponsePacket smbNtTransSetQuotaPacket = response as SmbNtTransSetQuotaResponsePacket; NamespaceCifs.SmbHeader ntTransSetQuotaResponseHeader = smbNtTransSetQuotaPacket.SmbHeader; VerifyMessageSyntaxNtTransactSetQuotaRequest( smbNtTransSetQuotaPacket, ntTransSetQuotaResponseHeader.Status); this.NtTransSetQuotaResponse( ntTransSetQuotaResponseHeader.Mid + this.addMidMark, this.QueryUidTable(smbPacketResponse), this.QueryTidTable(smbPacketResponse), (smbPacketResponse).IsSignRequired, (MessageStatus)ntTransSetQuotaResponseHeader.Status); } #endregion }