/// <summary>
 /// Deep copy constructor.
 /// </summary>
 public SmbTrans2SetFsInformationRequestPacket(SmbTrans2SetFsInformationRequestPacket packet)
     : base(packet)
 {
     this.InitDefaultValue();
 }
 /// <summary>
 /// Deep copy constructor.
 /// </summary>
 public SmbTrans2SetFsInformationRequestPacket(SmbTrans2SetFsInformationRequestPacket packet)
     : base(packet)
 {
     this.InitDefaultValue();
 }
        /// <summary>
        /// to create a Trans2SetFsInformation request packet.
        /// </summary>
        /// <param name="messageId">This field SHOULD be the multiplex ID that is used to associate a response with a
        /// request.</param>
        /// <param name="uid">This field SHOULD identify the authenticated instance of the user.</param>
        /// <param name="treeId">This field identifies the subdirectory (or tree) on the server that the client is
        /// accessing.</param>
        /// <param name="flags">An 8-bit field of 1-bit flags describing various features in effect for the
        /// message</param>
        /// <param name="flags2">A 16-bit field of 1-bit flags that represent various features in effect for the
        /// message. Unspecified bits are reserved and MUST be zero.</param>
        /// <param name="maxParameterCount">The maximum number of parameter bytes that the client will accept in the
        /// transaction reply. The server MUST NOT return more than this number of parameter bytes.</param>
        /// <param name="maxDataCount">The maximum number of data bytes that the client will accept in the transaction
        /// reply. The server MUST NOT return more than this number of data bytes.</param>
        /// <param name="maxSetupCount">Maximum number of setup bytes that the client will accept in the transaction
        /// reply. The server MUST NOT return more than this number of setup bytes</param>
        /// <param name="smbParametersFlags">A set of bit flags that alter the behavior of the requested operation.
        /// Unused bit fields MUST be set to zero by the client sending the request, and MUST be ignored by the server
        /// receiving the request. The client MAY set either or both of the following bit flags</param>
        /// <param name="timeout">The number of milliseconds the server SHOULD wait for completion of the transaction
        /// before generating a timeout. A value of zero indicates that the operation MUST NOT block.</param>
        /// <param name="name">This field is present but not used in SMB_COM_TRANSACTION2 requests. If Unicode support
        /// has been negotiated, then this field MUST be aligned to a 16-bit boundary and MUST consist of two null bytes
        /// (a null-terminator). If Unicode support has not been negotiated this field will contain only one null
        /// byte.</param>
        /// <returns>a Trans2SetFsInformation request packet</returns>
        public SmbTrans2SetFsInformationRequestPacket CreateTrans2SetFsInformationRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort maxParameterCount,
            ushort maxDataCount,
            byte maxSetupCount,
            Trans2SmbParametersFlags smbParametersFlags,
            uint timeout,
            string name)
        {
            if (name == null)
            {
                name = string.Empty;
            }

            SmbTrans2SetFsInformationRequestPacket packet = new SmbTrans2SetFsInformationRequestPacket();
            packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_TRANSACTION2,
                messageId, uid, treeId, flags, flags2);

            // Set Smb_Parameters
            SMB_COM_TRANSACTION2_Request_SMB_Parameters smbParameters =
                new SMB_COM_TRANSACTION2_Request_SMB_Parameters();
            smbParameters.MaxParameterCount = maxParameterCount;
            smbParameters.MaxDataCount = maxDataCount;
            smbParameters.MaxSetupCount = maxSetupCount;
            smbParameters.Flags = (ushort)smbParametersFlags;
            smbParameters.Timeout = timeout;
            smbParameters.SetupCount = 1; // the correct count in word of the Setup is always 1.
            smbParameters.Setup = new ushort[] { (ushort)Trans2SubCommand.TRANS2_SET_FS_INFORMATION };
            smbParameters.WordCount = (byte)(CifsMessageUtils.GetSize<SMB_COM_TRANSACTION2_Request_SMB_Parameters>(
                smbParameters) / NumBytesOfWord);

            // Set Smb_Data
            SMB_COM_TRANSACTION2_Request_SMB_Data smbData = new SMB_COM_TRANSACTION2_Request_SMB_Data();
            smbData.Name = CifsMessageUtils.ToSmbStringBytes(name,
                (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;
            packet.UpdateCountAndOffset();

            return packet;
        }
        public SmbTrans2SetFsInformationFinalResponsePacket CreateTrans2SetFsInformationFinalResponse(
            CifsServerPerConnection connection,
            SmbTrans2SetFsInformationRequestPacket request)
        {
            SmbTrans2SetFsInformationFinalResponsePacket response = new SmbTrans2SetFsInformationFinalResponsePacket();
            SmbHeader smbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);

            if ((smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_NT_STATUS) == SmbFlags2.SMB_FLAGS2_NT_STATUS)
            {
                smbHeader.Status = (uint)NTSTATUS.STATUS_SMB_NO_SUPPORT;
            }
            else
            {
                SmbStatus smbStatus = new SmbStatus();
                smbStatus.ErrorClass = SmbErrorClass.ERRSRV;
                smbStatus.Reserved = 0;
                smbStatus.ErrorCode = (ushort)SmbErrorCodeOfERRSRV.ERRnosupport;
                smbHeader.Status = smbStatus;
            }
            response.SmbHeader = smbHeader;

            response.UpdateCountAndOffset();

            return response;
        }