/// <summary>
        /// Deep copy constructor.
        /// </summary>
        public SmbLogoffAndxRequestPacket(SmbLogoffAndxRequestPacket packet)
            : base(packet)
        {
            this.InitDefaultValue();

            this.smbParameters.WordCount = packet.SmbParameters.WordCount;
            this.smbParameters.AndXCommand = packet.SmbParameters.AndXCommand;
            this.smbParameters.AndXReserved = packet.SmbParameters.AndXReserved;
            this.smbParameters.AndXOffset = packet.SmbParameters.AndXOffset;
            this.smbData.ByteCount = packet.SmbData.ByteCount;
        }
        /// <summary>
        /// Deep copy constructor.
        /// </summary>
        public SmbLogoffAndxRequestPacket(SmbLogoffAndxRequestPacket packet)
            : base(packet)
        {
            this.InitDefaultValue();

            this.smbParameters.WordCount    = packet.SmbParameters.WordCount;
            this.smbParameters.AndXCommand  = packet.SmbParameters.AndXCommand;
            this.smbParameters.AndXReserved = packet.SmbParameters.AndXReserved;
            this.smbParameters.AndXOffset   = packet.SmbParameters.AndXOffset;
            this.smbData.ByteCount          = packet.SmbData.ByteCount;
        }
        /// <summary>
        /// Expect log off and server will send back log off response
        /// </summary>
        /// <param name="timeout">Timeout</param>
        /// <returns>The endpoint of client</returns>
        public override FsEndpoint ExpectLogOff(TimeSpan timeout)
        {
            CifsServerPerConnection connection;

            SmbLogoffAndxRequestPacket request =
                this.cifsServer.ExpectPacket(timeout, out connection) as SmbLogoffAndxRequestPacket;

            SmbLogoffAndxResponsePacket response = this.cifsServer.CreateLogoffAndxResponse(connection, request, null);

            this.cifsServer.SendPacket(response, connection);

            return(this.fsEndpoints[connection.Identity]);
        }
        /// <summary>
        /// to create a LogoffAndx 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="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="andxPacket">the andx packet.</param>
        /// <returns>a LogoffAndx request packet</returns>
        public SmbLogoffAndxRequestPacket CreateLogoffAndxRequest(
            ushort messageId,
            ushort uid,
            SmbFlags flags,
            SmbFlags2 flags2,
            SmbPacket andxPacket)
        {
            SmbLogoffAndxRequestPacket packet = new SmbLogoffAndxRequestPacket();

            packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_LOGOFF_ANDX,
                messageId, uid, 0, flags, flags2);

            SMB_COM_LOGOFF_ANDX_Request_SMB_Parameters smbParameters =
                new SMB_COM_LOGOFF_ANDX_Request_SMB_Parameters();
            smbParameters.AndXReserved = 0;
            if (andxPacket == null)
            {
                smbParameters.AndXCommand = SmbCommand.SMB_COM_NO_ANDX_COMMAND;
            }
            else
            {
                smbParameters.AndXCommand = andxPacket.SmbHeader.Command;
            }
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_LOGOFF_ANDX_Request_SMB_Data smbData = new SMB_COM_LOGOFF_ANDX_Request_SMB_Data();
            smbData.ByteCount = 0;

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;
            packet.AndxPacket = andxPacket;

            return packet;
        }
        public SmbLogoffAndxResponsePacket CreateLogoffAndxResponse(
            CifsServerPerConnection connection,
            SmbLogoffAndxRequestPacket request,
            SmbPacket andxPacket)
        {
            SmbLogoffAndxResponsePacket response = new SmbLogoffAndxResponsePacket();
            response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);

            SMB_COM_LOGOFF_ANDX_Response_SMB_Parameters smbParameters = response.SmbParameters;
            smbParameters.AndXCommand =
                andxPacket != null ? andxPacket.SmbHeader.Command : SmbCommand.SMB_COM_NO_ANDX_COMMAND;
            smbParameters.AndXReserved = 0x00;
            smbParameters.AndXOffset = (ushort)(response.HeaderSize + Marshal.SizeOf(response.SmbParameters)
                    + Marshal.SizeOf(response.SmbData));
            smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2);
            response.SmbParameters = smbParameters;

            SMB_COM_LOGOFF_ANDX_Response_SMB_Data smbData = response.SmbData;
            smbData.ByteCount = 0x0000;

            response.AndxPacket = andxPacket;
            response.UpdateHeader();

            return response;
        }