/// <summary>
        /// Create NTTransSetQuota request for client to set quota on server. 
        /// </summary>
        /// <param name = "messageId">the id of message, used to identity the request and the server response. </param>
        /// <param name = "sessionUid">the valid session id, must be response by server of the session setup request. </param>
        /// <param name = "treeId">the valid tree connect id, must be response by server of the tree connect. </param>
        /// <param name = "flags">
        /// The Flags field contains individual flags, as specified in [CIFS] sections 2.4.2 and 3.1.1. 
        /// </param>
        /// <param name = "flags2">
        /// The Flags2 field contains individual bit flags that, depending on the negotiated SMB dialect, indicate   
        /// various client and server capabilities. 
        /// </param>
        /// <param name = "fileId">the valid file id to operation on, response by server. </param>
        /// <param name = "nextEntryOffset">
        /// An offset to the start of the subsequent entry from the start of this entry, or 0 for the final entry. 
        /// </param>
        /// <param name = "changeTime">This value MUST be the time the quota was last changed, in TIME format. </param>
        /// <param name = "quotaUsed">
        /// The amount of quota, in bytes, used by this user. This field is formatted as a LARGE_INTEGER, as specified 
        ///  in [CIFS] section 2.4.2. 
        /// </param>
        /// <param name = "quotaThreshold">
        /// The quota warning limit, in bytes, for this user. This field is formatted as a LARGE_INTEGER, as specified 
        ///  in [CIFS] section 2.4.2. 
        /// </param>
        /// <param name = "quotaLimit">
        /// The quota limit, in bytes, for this user. This field is formatted as a LARGE_INTEGER, as specified in  
        /// [CIFS] section 2.4.2. 
        /// </param>
        /// <param name = "sid">
        /// The security identifier of this user. For details, see [MS-DTYP] section 2.4.2. Note that [CIFS] sections  
        /// 4.3.4, 4.3.4.7, 4.3.5, and 4.3.5.6 use Sid as the field name for a search handle. In [XOPEN-SMB], the  
        /// search handle field is called a findfirst_dirhandle or findnext_dirhandle. These are better field names 
        /// for a search handle. this param can not be null.
        /// </param>
        /// <returns>a nt transaction set quota request packet </returns>
        /// <exception cref="ArgumentNullException">sid can not be null.</exception>
        private SmbNtTransSetQuotaRequestPacket CreateNTTransSetQuotaRequest(
            ushort messageId,
            ushort sessionUid,
            ushort treeId,
            SmbHeader_Flags_Values flags,
            SmbHeader_Flags2_Values flags2,
            ushort fileId,
            uint nextEntryOffset,
            ulong changeTime,
            ulong quotaUsed,
            ulong quotaThreshold,
            ulong quotaLimit,
            byte[] sid)
        {
            if (sid == null)
            {
                throw new ArgumentNullException("sid");
            }

            SmbNtTransSetQuotaRequestPacket packet = new SmbNtTransSetQuotaRequestPacket();
            packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_NT_TRANSACT,
                messageId, sessionUid, treeId, (SmbFlags)flags, (SmbFlags2)flags2);

            // Set Smb_Parameters
            SMB_COM_NT_TRANSACT_Request_SMB_Parameters smbParameters =
                new SMB_COM_NT_TRANSACT_Request_SMB_Parameters();
            smbParameters.MaxSetupCount = this.capability.MaxSetupCount;
            smbParameters.MaxParameterCount = this.capability.MaxParameterCount;
            smbParameters.MaxDataCount = this.capability.MaxDataCount;
            smbParameters.SetupCount = 0; // the correct count in word of the Setup is always 0.
            smbParameters.Function = (NtTransSubCommand)SmbNtTransSubCommand.NT_TRANSACT_SET_QUOTA;
            smbParameters.Setup = new ushort[0];
            smbParameters.WordCount = (byte)(CifsMessageUtils.GetSize<SMB_COM_NT_TRANSACT_Request_SMB_Parameters>(
                smbParameters) / SmbCapability.NUM_BYTES_OF_WORD);

            // Set Smb_Data
            SMB_COM_NT_TRANSACT_Request_SMB_Data smbData = new SMB_COM_NT_TRANSACT_Request_SMB_Data();

            // Set Nt Transaction Parameters
            NT_TRANSACT_SET_QUOTA_Request_NT_Trans_Parameters
                ntTransParameters = new NT_TRANSACT_SET_QUOTA_Request_NT_Trans_Parameters();
            ntTransParameters.Fid = fileId;

            // Set Nt Transaction Data
            NT_TRANSACT_SET_QUOTA_Request_NT_Trans_Data
                ntTransData = new NT_TRANSACT_SET_QUOTA_Request_NT_Trans_Data();
            ntTransData.NextEntryOffset = nextEntryOffset;
            ntTransData.SidLength = (uint)sid.Length;
            ntTransData.ChangeTime = changeTime;
            ntTransData.QuotaUsed = quotaUsed;
            ntTransData.QuotaThreshold = quotaThreshold;
            ntTransData.QuotaLimit = quotaLimit;
            ntTransData.Sid = sid;

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;
            packet.NtTransParameters = ntTransParameters;
            packet.NtTransData = ntTransData;
            packet.UpdateCountAndOffset();

            return packet;
        }
 /// <summary>
 /// to decode the NtTrans data: from the general NtTransDada to the concrete NtTrans Data. 
 /// </summary>
 protected override void DecodeNtTransData()
 {
     this.ntTransData =
         CifsMessageUtils.ToStuct<NT_TRANSACT_SET_QUOTA_Request_NT_Trans_Data>(
         this.smbData.NT_Trans_Data);
 }