public void Trans2FindFirst2RequestInvalidFileToken(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            bool isReparse,
            InformationLevel informationLevel,
            int gmtTokenIndex,
            bool isFlagsKnowsLongNameSet,
            bool isGmtPatten)
        {
            #region Create Packet

            SmbTrans2FindFirst2RequestPacket smbPacket = new SmbTrans2FindFirst2RequestPacket();

            ushort uid = (ushort)this.uId[(uint)sessionId];
            ushort tid = (ushort)this.tId[(uint)treeId];
            NamespaceCifs.Trans2SmbParametersFlags transactOptions = NamespaceCifs.Trans2SmbParametersFlags.NONE;
            string fileName = Site.Properties["SmbTestCaseBadGmt"].ToString();

            ushort searchCount = ushort.Parse(Site.Properties["SmbTransportSearchCount"]);
            NamespaceCifs.Trans2FindFlags findFlags
                = (NamespaceCifs.Trans2FindFlags)(ushort.Parse(Site.Properties["SmbTransportFindFlags"]));

            NamespaceCifs.SmbFileAttributes searchAttributes = NamespaceCifs.SmbFileAttributes.SMB_FILE_ATTRIBUTE_NORMAL;

            NamespaceCifs.Trans2FindFirst2SearchStorageType searchStorageType =
                NamespaceCifs.Trans2FindFirst2SearchStorageType.FILE_NON_DIRECTORY_FILE;

            isReparse = true;
            isFlagsKnowsLongNameSet = true;

            smbPacket = this.smbClientStack.CreateTrans2FindFirst2Request(
                tid,
                fileName,
                transactOptions,
                searchCount,
                findFlags,
                searchAttributes,
                searchStorageType,
                isReparse,
                isFlagsKnowsLongNameSet,
                FindInformationLevel.SMB_INFO_STANDARD);

            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;

                if (smbErrorHeader.Status == (uint)MessageStatus.StatusInvalidInfoClass)
                {
                    smbErrorHeader.Status = (uint)MessageStatus.NotSupported;
                }
                this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status);
            }
            else
            {
                NamespaceCifs.TRANS2_FIND_FIRST2_Request_Trans2_Parameters trans2FindFirst2RequestHeader
                    = smbPacket.Trans2Parameters;

                SmbTrans2FindFirst2ResponsePacket smbTrans2FindFirst2Packet
                    = response as SmbTrans2FindFirst2ResponsePacket;
                NamespaceCifs.SmbHeader smbTrans2FindFirst2ResponseHeader = smbTrans2FindFirst2Packet.SmbHeader;
                NamespaceCifs.TRANS2_FIND_FIRST2_Response_Trans2_Parameters trans2FindFirst2ResponseHeader
                    = smbTrans2FindFirst2Packet.Trans2Parameters;

                bool isFileIDEqualZero = false;
                bool isReturnEnumPreviousVersion = false;
                ushort inforLevel = (ushort)trans2FindFirst2RequestHeader.InformationLevel;
                if (inforLevel ==
                    this.informationLevelBytes[(ushort)InformationLevel.SmbFindFileIdFullDirectoryInfo])
                {
                    if (smbTrans2FindFirst2Packet.SmbData.Trans2_Data.Length != uint.MinValue)
                    {
                        NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket fsccFullDirectoryPacket
                            = new NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket();

                        fsccFullDirectoryPacket.FromBytes(smbTrans2FindFirst2Packet.SmbData.Trans2_Data);

                        NamespaceFscc.FileFullDirectoryInformation fullDirectoryInformation
                            = new NamespaceFscc.FileFullDirectoryInformation();

                        fullDirectoryInformation = fsccFullDirectoryPacket.Payload;
                        if (fullDirectoryInformation.FileNameLength == uint.MinValue)
                        {
                            isFileIDEqualZero = true;
                        }

                        VerifyMessageSyntaxSmbFindFileIdFullDirectoryInfo(fullDirectoryInformation);

                        this.isfindIdFullDirectoryInfo = true;
                    }
                }
                else if (inforLevel ==
                    this.informationLevelBytes[(ushort)InformationLevel.SmbFindFileIdBothDirectoryInfo])
                {
                    if (smbTrans2FindFirst2Packet.SmbData.Trans2_Data.Length != uint.MinValue)
                    {
                        NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket fsccBothDirectoryPacket
                            = new NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket();

                        fsccBothDirectoryPacket.FromBytes(smbTrans2FindFirst2Packet.SmbData.Trans2_Data);

                        NamespaceFscc.FileBothDirectoryInformation bothDirectoryInformation
                            = new NamespaceFscc.FileBothDirectoryInformation();

                        bothDirectoryInformation = fsccBothDirectoryPacket.Payload;
                        if (bothDirectoryInformation.FileNameLength == uint.MinValue)
                        {
                            isFileIDEqualZero = true;
                        }

                        if (this.smbClientStack.Capability.IsSupportsExtendedSecurity == true)
                        {
                            VerifyMessageSyntaxSmbFindFileBothDirectoryInfo(bothDirectoryInformation);
                        }
                        this.isfinIdBothDirectoryInfo = true;
                    }
                }
                else
                {
                    if (SmbAdapter.fileSystemType == FileSystemType.Fat)
                    {
                        isFileIDEqualZero = true;
                    }
                    else
                    {
                        isFileIDEqualZero = false;
                    }

                    if (this.sutOsVersion == Platform.Win2K3)
                    {
                        isReturnEnumPreviousVersion = false;
                    }
                    else
                    {
                        isReturnEnumPreviousVersion = true;
                    }
                }

                if (!this.sId.ContainsValue(trans2FindFirst2ResponseHeader.SID))
                {
                    this.sId.Add((uint)(gmtTokenIndex), (uint)trans2FindFirst2ResponseHeader.SID);
                }

                VerifyMessageSyntaxTrans2FindFirst2Request(
                    informationLevel,
                    smbTrans2FindFirst2Packet,
                    this.isfindIdFullDirectoryInfo,
                    this.isfinIdBothDirectoryInfo);

                this.isfindIdFullDirectoryInfo = false;
                this.isfinIdBothDirectoryInfo = false;

                this.Trans2FindFirst2Response(
                    smbTrans2FindFirst2ResponseHeader.Mid + this.addMidMark,
                    this.QueryUidTable(smbPacketResponse),
                    this.QueryTidTable(smbPacketResponse),
                    smbPacketResponse.IsSignRequired,
                    isFileIDEqualZero,
                    gmtTokenIndex,
                    isReturnEnumPreviousVersion,
                    (MessageStatus)smbTrans2FindFirst2ResponseHeader.Status,
                    true,
                    true);
            }

            #endregion
        }
        /// <summary>
        /// find the transaction2 packet.
        /// </summary>
        /// <param name="command">the command of transaction2 packet.</param>
        /// <returns>the target transaction2 packet</returns>
        private static SmbPacket FindTheTrans2Packet(Trans2SubCommand command)
        {
            SmbPacket smbPacket = null;
            switch ((Trans2SubCommand)command)
            {
                case Trans2SubCommand.TRANS2_FIND_FIRST2:
                    smbPacket = new SmbTrans2FindFirst2RequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_FIND_NEXT2:
                    smbPacket = new SmbTrans2FindNext2RequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_QUERY_FS_INFORMATION:
                    smbPacket = new SmbTrans2QueryFsInformationRequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_SET_FS_INFORMATION:
                    smbPacket = new SmbTrans2SetFsInformationRequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_QUERY_PATH_INFORMATION:
                    smbPacket = new SmbTrans2QueryPathInformationRequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_SET_PATH_INFORMATION:
                    smbPacket = new SmbTrans2SetPathInformationRequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_QUERY_FILE_INFORMATION:
                    smbPacket = new SmbTrans2QueryFileInformationRequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_SET_FILE_INFORMATION:
                    smbPacket = new SmbTrans2SetFileInformationRequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_GET_DFS_REFERRAL:
                    smbPacket = new SmbTrans2GetDfsReferralRequestPacket();
                    break;

                default:
                    break;
            }
            return smbPacket;
        }
        public void Trans2FindFirst2Request(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            bool isReparse,
            [Domain("InfoLevelFind")] InformationLevel informationLevel,
            int gmtTokenIndex,
            bool isFlagsKnowsLongNameSet,
            bool isGmtPatten)
        {
            #region Create Packet

            SmbTrans2FindFirst2RequestPacket smbPacket = new SmbTrans2FindFirst2RequestPacket();

            ushort uid = (ushort)this.uId[(uint)sessionId];
            ushort tid = (ushort)this.tId[(uint)treeId];
            NamespaceCifs.Trans2SmbParametersFlags transactOptions = NamespaceCifs.Trans2SmbParametersFlags.NONE;
            string fileName = string.Empty;
            if (gmtTokenIndex < uint.MinValue)
            {
                fileName = Site.Properties["SmbTestCaseBadGmt"].ToString();
            }
            else
            {
                if (this.gmtTokens.ContainsKey(gmtTokenIndex))
                {
                    fileName = this.gmtTokens[gmtTokenIndex];
                }
                else
                {
                    fileName = this.gmtTokens[ValidgmtTokenIndex];
                }
            }

            ushort searchCount = ushort.Parse(Site.Properties["SmbTransportSearchCount"]);
            NamespaceCifs.Trans2FindFlags findFlags
                = (NamespaceCifs.Trans2FindFlags)(ushort.Parse(Site.Properties["SmbTransportFindFlags"]));

            NamespaceCifs.SmbFileAttributes searchAttributes
                = (NamespaceCifs.SmbFileAttributes)(ushort.Parse(Site.Properties["SmbTransportSearchFileAttributes"]));

            NamespaceCifs.Trans2FindFirst2SearchStorageType searchStorageType =
                (NamespaceCifs.Trans2FindFirst2SearchStorageType)
                (ushort.Parse(Site.Properties["SmbTransportSearchStorageType"]));

            smbPacket = this.smbClientStack.CreateTrans2FindFirst2Request(
                tid,
                fileName,
                transactOptions,
                searchCount,
                findFlags,
                searchAttributes,
                searchStorageType,
                isReparse,
                isFlagsKnowsLongNameSet,
                (FindInformationLevel)this.informationLevelBytes[(ushort)informationLevel]);

            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;

                if (smbErrorHeader.Status == (uint)MessageStatus.StatusInvalidInfoClass)
                {
                    smbErrorHeader.Status = (uint)MessageStatus.NotSupported;
                }

                //Workaround temp code (How to trigger SUCCESS for TRANS2_FIND_FIRST2 Request)
                if (smbErrorHeader.Status == (uint)MessageStatus.ObjectNameNotFound &&
                    !bool.Parse(Site.Properties["IsTDQ33049Fixed"]))
                {
                    smbErrorHeader.Status = (uint)MessageStatus.InvalidParameter;
                }

                this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status);
            }
            else
            {
                NamespaceCifs.TRANS2_FIND_FIRST2_Request_Trans2_Parameters trans2FindFirst2RequestHeader
                    = smbPacket.Trans2Parameters;

                SmbTrans2FindFirst2ResponsePacket smbTrans2FindFirst2Packet
                    = response as SmbTrans2FindFirst2ResponsePacket;
                NamespaceCifs.SmbHeader smbTrans2FindFirst2ResponseHeader = smbTrans2FindFirst2Packet.SmbHeader;
                NamespaceCifs.TRANS2_FIND_FIRST2_Response_Trans2_Parameters trans2FindFirst2ResponseHeader
                    = smbTrans2FindFirst2Packet.Trans2Parameters;

                bool isFileIDEqualZero = false;
                bool isReturnEnumPreviousVersion = false;
                ushort inforLevel = (ushort)trans2FindFirst2RequestHeader.InformationLevel;
                if (inforLevel ==
                    this.informationLevelBytes[(ushort)InformationLevel.SmbFindFileIdFullDirectoryInfo])
                {
                    if (smbTrans2FindFirst2Packet.SmbData.Trans2_Data.Length != uint.MinValue)
                    {
                        NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket fsccFullDirectoryPacket
                            = new NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket();

                        fsccFullDirectoryPacket.FromBytes(smbTrans2FindFirst2Packet.SmbData.Trans2_Data);

                        NamespaceFscc.FileFullDirectoryInformation fullDirectoryInformation
                            = new NamespaceFscc.FileFullDirectoryInformation();

                        fullDirectoryInformation = fsccFullDirectoryPacket.Payload;
                        if (fullDirectoryInformation.FileNameLength == uint.MinValue)
                        {
                            isFileIDEqualZero = true;
                        }

                        VerifyMessageSyntaxSmbFindFileIdFullDirectoryInfo(fullDirectoryInformation);

                        this.isfindIdFullDirectoryInfo = true;
                    }
                }
                else if (inforLevel ==
                    this.informationLevelBytes[(ushort)InformationLevel.SmbFindFileIdBothDirectoryInfo])
                {
                    if (smbTrans2FindFirst2Packet.SmbData.Trans2_Data.Length != uint.MinValue)
                    {
                        NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket fsccBothDirectoryPacket
                            = new NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket();

                        fsccBothDirectoryPacket.FromBytes(smbTrans2FindFirst2Packet.SmbData.Trans2_Data);

                        NamespaceFscc.FileBothDirectoryInformation bothDirectoryInformation
                            = new NamespaceFscc.FileBothDirectoryInformation();

                        bothDirectoryInformation = fsccBothDirectoryPacket.Payload;

                        long allocationSize = long.Parse(Site.Properties["AllocationSizeForFSCC"]);
                        VerifyFileBothDirectoryInformationOfFSCC(
                            bothDirectoryInformation,
                            allocationSize
                            );
                        bool isNoOtherEntriesFollow = Boolean.Parse(Site.Properties["BsNoOtherEntriesFollowForFSCC"]);
                        VerifyDataTypeFileBothDirectoryInformationOfFSCC(bothDirectoryInformation, isNoOtherEntriesFollow);
                        VerifyMessageSyntaxSmbFindFileBothDirectoryInfo(bothDirectoryInformation);
                        isfinIdBothDirectoryInfo = true;

                        if (bothDirectoryInformation.FileNameLength == uint.MinValue)
                        {
                            isFileIDEqualZero = true;
                        }

                        if (this.smbClientStack.Capability.IsSupportsExtendedSecurity == true)
                        {
                            VerifyMessageSyntaxSmbFindFileBothDirectoryInfo(bothDirectoryInformation);
                        }
                        this.isfinIdBothDirectoryInfo = true;
                    }
                }
                else
                {
                    if (SmbAdapter.fileSystemType == FileSystemType.Fat)
                    {
                        isFileIDEqualZero = true;
                    }
                    else
                    {
                        isFileIDEqualZero = false;
                    }

                    if (this.sutOsVersion == Platform.Win2K3)
                    {
                        isReturnEnumPreviousVersion = false;
                    }
                    else
                    {
                        isReturnEnumPreviousVersion = true;
                    }
                }

                if (!this.sId.ContainsValue(trans2FindFirst2ResponseHeader.SID))
                {
                    this.sId.Add((uint)(gmtTokenIndex), (uint)trans2FindFirst2ResponseHeader.SID);
                }

                VerifyMessageSyntaxTrans2FindFirst2Request(
                    informationLevel,
                    smbTrans2FindFirst2Packet,
                    this.isfindIdFullDirectoryInfo,
                    this.isfinIdBothDirectoryInfo);

                this.isfindIdFullDirectoryInfo = false;
                this.isfinIdBothDirectoryInfo = false;

                this.Trans2FindFirst2Response(
                    smbTrans2FindFirst2ResponseHeader.Mid + this.addMidMark,
                    this.QueryUidTable(smbPacketResponse),
                    this.QueryTidTable(smbPacketResponse),
                    (smbPacketResponse).IsSignRequired,
                    isFileIDEqualZero,
                    gmtTokenIndex,
                    isReturnEnumPreviousVersion,
                    (MessageStatus)smbTrans2FindFirst2ResponseHeader.Status,
                    true,
                    true);
            }

            #endregion
        }
        public void TraditionalTestCase_IgnoreFields_FIND_FIRST2_02_Case()
        {
            #region Connect to the specified server

            smbClientStack.Connect(serverName, serverPort, ipVersion, bufferSize);

            #endregion

            #region Send the Negotiate request

            // Create a SMB_COM_NEGOTIATE request.
            SmbNegotiateRequestPacket negotiateRequest =
                smbClientStack.CreateNegotiateRequest(
                    StackSmb.SignState.NONE,
                    new string[] {
                DialectNameString.PCNET1,
                DialectNameString.LANMAN10,
                DialectNameString.WFW10,
                DialectNameString.LANMAN12,
                DialectNameString.LANMAN21,
                DialectNameString.NTLANMAN
            });

            // Send the SMB_COM_NEGOTIATE request and expect the response in timeout milliseconds.
            smbClientStack.SendPacket(negotiateRequest);
            StackPacket response = smbClientStack.ExpectPacket(timeout);

            // Check whether server return a response.
            Site.Assert.IsNotNull(
                response,
                "SMB_COM_NEGOTIATE response should not be null.");

            // Check whether server returns a SMB_COM_NEGOTIATE response.
            Site.Assert.IsInstanceOfType(
                response,
                typeof(SmbNegotiateResponsePacket),
                "SMB_COM_NEGOTIATE response should be received.");

            // Check the response validity by verifying the Status field in the SMB Header packet.
            SmbNegotiateResponsePacket negotiateResponse = (SmbNegotiateResponsePacket)response;
            Site.Assert.AreEqual <uint>(
                (uint)SmbStatus.STATUS_SUCCESS,
                negotiateRequest.SmbHeader.Status,
                "SMB_COM_NEGOTIATE response status should be SUCCESS.");

            #endregion

            #region Send the first SMB_COM_SESSION_SETUP_ANDX  Request

            SmbSecurityPackage smbSecurityPackage = (SmbSecurityPackage)Enum.Parse(
                typeof(SmbSecurityPackage),
                Site.Properties["SmbSecurityPackageType"] as string,
                true);

            // Create the first SMB_COM_SESSION_SETUP_ANDX request.
            SmbSessionSetupAndxRequestPacket sessionSetupAndxRequest =
                smbClientStack.CreateFirstSessionSetupRequest(
                    smbSecurityPackage,
                    serverName,
                    domainName,
                    userName,
                    password);

            // Send the first SMB_COM_SESSION_SETUP_ANDX request and expect the response in timeout milliseconds.
            smbClientStack.SendPacket(sessionSetupAndxRequest);
            response = smbClientStack.ExpectPacket(timeout);

            // Check whether server return a response.
            Site.Assert.IsNotNull(
                response,
                "SMB_COM_SESSION_SETUP_ANDX response should not be null.");

            // Check whether server returns a the SMB_COM_SESSION_SETUP_ANDX response.
            Site.Assert.IsInstanceOfType(
                response,
                typeof(SmbSessionSetupAndxResponsePacket),
                "SMB_COM_SESSION_SETUP_ANDX response should be received.");

            // Check the response validity by verifying the Status field in the SMB Header packet.
            // If SMB SecurityPackage type is NTLM, the expected SUCCESS response status is STATUS_MORE_PROCESSING_REQUIRED,
            // else if SMB SecurityPackage type is Kerberos, the expected SUCCESS response status is STATUS_SUCCESS.
            SmbSessionSetupAndxResponsePacket sessionSetupResponse = (SmbSessionSetupAndxResponsePacket)response;
            Site.Assert.IsTrue(
                (int)sessionSetupResponse.SmbHeader.Status == (int)SmbStatus.STATUS_MORE_PROCESSING_REQUIRED ||
                (int)sessionSetupResponse.SmbHeader.Status == (int)SmbStatus.STATUS_SUCCESS,
                "SMB_COM_SESSION_SETUP_ANDX response status should be SUCCESS.");

            #endregion

            #region Send the second SMB_COM_SESSION_SETUP_ANDX  request

            // Create the second SMB_COM_SESSION_SETUP_ANDX request.
            ushort sessionUid = sessionSetupResponse.SmbHeader.Uid;

            if ((int)sessionSetupResponse.SmbHeader.Status == (int)SmbStatus.STATUS_MORE_PROCESSING_REQUIRED)
            {
                SmbSessionSetupAndxRequestPacket secondSessionSetupRequest =
                    smbClientStack.CreateSecondSessionSetupRequest(sessionUid, smbSecurityPackage);

                // Send the second SMB_COM_SESSION_SETUP_ANDX request and expect the response in timeout milliseconds.
                smbClientStack.SendPacket(secondSessionSetupRequest);
                response = smbClientStack.ExpectPacket(timeout);

                // Check whether server return a response.
                Site.Assert.IsNotNull(
                    response,
                    "SMB_COM_SESSION_SETUP_ANDX response should not be null.");

                // Check whether server returns a the SMB_COM_SESSION_SETUP_ANDX response.
                Site.Assert.IsInstanceOfType(
                    response,
                    typeof(SmbSessionSetupAndxResponsePacket),
                    "SMB_COM_SESSION_SETUP_ANDX response should be received.");

                // Check the response validity by verifying the Status field in the SMB Header packet.
                sessionSetupResponse = (SmbSessionSetupAndxResponsePacket)response;
                Site.Assert.AreEqual <uint>(
                    (uint)SmbStatus.STATUS_SUCCESS,
                    sessionSetupResponse.SmbHeader.Status,
                    "SMB_COM_SESSION_SETUP_ANDX response status should be SUCCESS.");
            }

            #endregion

            #region Send the SMB_COM_TREE_CONNECT_ANDX request

            // TreeConnect
            string path = Site.Properties["SutNtfsShare1FullName"];

            SmbTreeConnectAndxRequestPacket treeconnectRequest =
                smbClientStack.CreateTreeConnectRequest(
                    sessionUid,
                    path);

            smbClientStack.SendPacket(treeconnectRequest);

            response = smbClientStack.ExpectPacket(timeout);

            // Check whether server return a response.
            Site.Assert.IsNotNull(
                response,
                "SMB_COM_TREE_CONNECT_ANDX response should not be null.");

            Site.Assert.IsInstanceOfType(
                response,
                typeof(SmbTreeConnectAndxResponsePacket),
                "SMB_COM_TREE_CONNECT_ANDX response should be received.");

            // Check the response validity by verifying the Status field in the SMB Header packet.
            SmbTreeConnectAndxResponsePacket treeConnectResponse = (SmbTreeConnectAndxResponsePacket)response;
            Site.Assert.AreEqual <uint>(
                (uint)SmbStatus.STATUS_SUCCESS,
                treeConnectResponse.SmbHeader.Status,
                "SMB_COM_TREE_CONNECT_ANDX response status should be SUCCESS.");
            #endregion

            #region Send the SMB_COM_NT_CREATE_ANDX request

            ushort treeId = treeConnectResponse.SmbHeader.Tid;

            // The file name can be any string.
            string fileName = "Dir1";

            SmbNtCreateAndxRequestPacket createRequest =
                smbClientStack.CreateCreateRequest(
                    treeId,
                    fileName,
                    StackCifs.NtTransactDesiredAccess.GENERIC_ALL,
                    StackCifs.SMB_EXT_FILE_ATTR.NONE,
                    StackCifs.NtTransactShareAccess.FILE_SHARE_DELETE
                    | StackCifs.NtTransactShareAccess.FILE_SHARE_READ
                    | StackCifs.NtTransactShareAccess.FILE_SHARE_WRITE,
                    StackCifs.NtTransactCreateDisposition.FILE_OPEN_IF,
                    NtTransactCreateOptions.FILE_DIRECTORY_FILE,
                    StackCifs.NtTransactImpersonationLevel.SEC_ANONYMOUS,
                    CreateFlags.NT_CREATE_REQUEST_OPLOCK);

            smbClientStack.SendPacket(createRequest);

            response = smbClientStack.ExpectPacket(timeout);

            // Check whether server return a response.
            Site.Assert.IsNotNull(
                response,
                "SMB_COM_NT_CREATE_ANDX response should not be null.");

            Site.Assert.IsInstanceOfType(
                response,
                typeof(SmbNtCreateAndxResponsePacket),
                "SMB_COM_NT_CREATE_ANDX response should be received.");

            // Check the response validity by verifying the Status field in the SMB Header packet.
            SmbNtCreateAndxResponsePacket createResponse = (SmbNtCreateAndxResponsePacket)response;
            Site.Assert.AreEqual <uint>(
                (uint)SmbStatus.STATUS_SUCCESS,
                createResponse.SmbHeader.Status,
                "SMB_COM_NT_CREATE_ANDX response status should be SUCCESS.");
            #endregion

            #region Send the TRANS2_FIND_FIRST2 request
            ushort searchCount = ushort.Parse(Site.Properties["SmbTransportSearchCount"]);
            ushort fileId      = createResponse.SmbParameters.FID;
            byte   length      = createResponse.SmbParameters.WordCount;
            SmbTrans2FindFirst2RequestPacket Trans2FindFirst2Request =
                smbClientStack.CreateTrans2FindFirst2Request(
                    treeId,
                    fileName,
                    StackCifs.Trans2SmbParametersFlags.NONE,
                    searchCount,
                    StackCifs.Trans2FindFlags.SMB_FIND_CONTINUE_FROM_LAST,
                    (StackCifs.SmbFileAttributes) 0x10,
                    StackCifs.Trans2FindFirst2SearchStorageType.FILE_DIRECTORY_FILE,
                    true,
                    true,
                    FindInformationLevel.SMB_INFO_STANDARD);

            smbClientStack.SendPacket(Trans2FindFirst2Request);

            response = smbClientStack.ExpectPacket(timeout);

            // Check whether server return a response.
            Site.Assert.IsNotNull(
                response,
                "TRANS2_FIND_FIRST2 response should not be null.");

            Site.Assert.IsInstanceOfType(
                response,
                typeof(SmbTrans2FindFirst2ResponsePacket),
                "TRANS2_FIND_FIRST2 response should be received.");

            // Check the response validity by verifying the Status field in the SMB Header packet.
            SmbTrans2FindFirst2ResponsePacket trans2FindFirst2Response = (SmbTrans2FindFirst2ResponsePacket)response;
            Site.Assert.AreEqual <uint>(
                (uint)SmbStatus.STATUS_SUCCESS,
                trans2FindFirst2Response.SmbHeader.Status,
                "TRANS2_FIND_FIRST2 response status should be SUCCESS.");

            #endregion

            #region Send the TRANS2_FIND_NEXT2 request

            ushort searchId = trans2FindFirst2Response.Trans2Parameters.SID;

            // Trans2FindNext2
            uint resumeKey = 0;

            SmbTrans2FindNext2RequestPacket trans2FindNext2Request =
                smbClientStack.CreateTrans2FindNext2Request(
                    treeId,
                    fileName,
                    StackCifs.Trans2SmbParametersFlags.NONE,
                    searchCount,
                    searchId,
                    resumeKey,
                    StackCifs.Trans2FindFlags.SMB_FIND_CONTINUE_FROM_LAST,
                    false,
                    true,
                    FindInformationLevel.SMB_INFO_STANDARD);

            smbClientStack.SendPacket(trans2FindNext2Request);

            response = smbClientStack.ExpectPacket(timeout);

            // Check whether server return a response.
            Site.Assert.IsNotNull(
                response,
                "TRANS2_FIND_NEXT2 response should not be null.");

            Site.Assert.IsInstanceOfType(
                response,
                typeof(SmbTrans2FindNext2ResponsePacket),
                "TRANS2_FIND_NEXT2 response should be received.");

            // Check the response validity by verifying the Status field in the SMB Header packet.
            SmbTrans2FindNext2ResponsePacket smbTrans2FindNext2ResponsePacket1 =
                (SmbTrans2FindNext2ResponsePacket)response;
            Site.Assert.AreEqual <uint>(
                (uint)SmbStatus.STATUS_SUCCESS,
                smbTrans2FindNext2ResponsePacket1.SmbHeader.Status,
                "TRANS2_FIND_NEXT2 response status should be SUCCESS.");

            #endregion

            #region Send the TRANS2_FIND_FIRST2

            SmbTrans2FindFirst2RequestPacket Trans2FindFirst2Request2 =
                smbClientStack.CreateTrans2FindFirst2Request(
                    treeId,
                    fileName,
                    StackCifs.Trans2SmbParametersFlags.NONE,
                    searchCount,
                    StackCifs.Trans2FindFlags.SMB_FIND_CONTINUE_FROM_LAST,
                    (StackCifs.SmbFileAttributes) 0x7F,
                    StackCifs.Trans2FindFirst2SearchStorageType.FILE_DIRECTORY_FILE,
                    true,
                    true,
                    FindInformationLevel.SMB_INFO_STANDARD);

            smbClientStack.SendPacket(Trans2FindFirst2Request2);

            StackPacket response2 = smbClientStack.ExpectPacket(timeout);

            // Check whether server return a response.
            Site.Assert.IsNotNull(
                response2,
                "TRANS2_FIND_FIRST2 response should not be null.");

            Site.Assert.IsInstanceOfType(
                response2,
                typeof(SmbTrans2FindFirst2ResponsePacket),
                "TRANS2_FIND_FIRST2 response should be received.");

            // Check the response validity by verifying the Status field in the SMB Header packet.
            SmbTrans2FindFirst2ResponsePacket trans2FindFirst2Response2 = (SmbTrans2FindFirst2ResponsePacket)response2;
            Site.Assert.AreEqual <uint>(
                (uint)SmbStatus.STATUS_SUCCESS,
                trans2FindFirst2Response2.SmbHeader.Status,
                "TRANS2_FIND_FIRST2 response status should be SUCCESS.");

            ushort searchId2 = trans2FindFirst2Response2.Trans2Parameters.SID;

            SmbTrans2FindNext2RequestPacket trans2FindNext2Request2 =
                smbClientStack.CreateTrans2FindNext2Request(
                    treeId,
                    fileName,
                    StackCifs.Trans2SmbParametersFlags.NONE,
                    searchCount,
                    searchId2,
                    resumeKey,
                    StackCifs.Trans2FindFlags.SMB_FIND_CONTINUE_FROM_LAST,
                    false,
                    true,
                    FindInformationLevel.SMB_INFO_STANDARD);

            smbClientStack.SendPacket(trans2FindNext2Request2);

            response2 = smbClientStack.ExpectPacket(timeout);

            // Check whether server return a response.
            Site.Assert.IsNotNull(
                response2,
                "TRANS2_FIND_NEXT2 response should not be null.");

            Site.Assert.IsInstanceOfType(
                response2,
                typeof(SmbTrans2FindNext2ResponsePacket),
                "TRANS2_FIND_NEXT2 response should be received.");

            // Check the response validity by verifying the Status field in the SMB Header packet.
            SmbTrans2FindNext2ResponsePacket smbTrans2FindNext2ResponsePacket2 =
                (SmbTrans2FindNext2ResponsePacket)response2;
            Site.Assert.AreEqual <uint>(
                (uint)SmbStatus.STATUS_SUCCESS,
                smbTrans2FindNext2ResponsePacket2.SmbHeader.Status,
                "TRANS2_FIND_NEXT2 response status should be SUCCESS.");

            #endregion

            #region Capture requirements r109033, r109056

            // if they are the same, verify R109033(R9033) and R109056(R9056).

            //
            // Add the debug information
            //
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SMB_R109033");

            //
            // Verify MS-SMB requirement: MS-SMB_R109033
            //
            bool isVerifyR109033 =
                VerifySmbTrans2FindNext2ResponsePacket(
                    smbTrans2FindNext2ResponsePacket1,
                    smbTrans2FindNext2ResponsePacket2);

            Site.CaptureRequirementIfIsTrue(
                isVerifyR109033,
                109033,
                @"[In File System Attribute Extensions]
                Whatever the value of it[any bit that is not listed in this section] is, 
                the receiver's reply is the same.");

            //
            // Add the debug information
            //
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SMB_R109056");

            //
            // Verify MS-SMB requirement: MS-SMB_R109056
            //
            bool isVerifyR109056 =
                VerifySmbTrans2FindNext2ResponsePacket(
                    smbTrans2FindNext2ResponsePacket1,
                    smbTrans2FindNext2ResponsePacket2);

            Site.CaptureRequirementIfIsTrue(
                isVerifyR109056,
                109056,
                @"[In File System Attribute Extensions] whatever the values of Reserved 0xFE007E00: 
               replies are the same no matter what value is used when the message is received.");

            #endregion

            #region Send the SMB_CLOSE request


            // Close
            SmbCloseRequestPacket CloseRequest = smbClientStack.CreateCloseRequest(fileId);

            smbClientStack.SendPacket(CloseRequest);

            response = smbClientStack.ExpectPacket(timeout);

            // Check whether server return a response.
            Site.Assert.IsNotNull(
                response,
                "SMB_CLOSE response should not be null.");

            Site.Assert.IsInstanceOfType(
                response,
                typeof(SmbCloseResponsePacket),
                "SMB_CLOSE response should be received.");

            // Check the response validity by verifying the Status field in the SMB Header packet.
            SmbCloseResponsePacket closeResponse = (SmbCloseResponsePacket)response;
            Site.Assert.AreEqual <uint>(
                (uint)SmbStatus.STATUS_SUCCESS,
                closeResponse.SmbHeader.Status,
                "SMB_CLOSE response status should be SUCCESS.");

            // TreeDisconnect
            SmbTreeDisconnectRequestPacket treeDisconnectRequest = smbClientStack.CreateTreeDisconnectRequest(treeId);

            smbClientStack.SendPacket(treeDisconnectRequest);

            response = smbClientStack.ExpectPacket(timeout);

            // Check whether server return a response.
            Site.Assert.IsNotNull(
                response,
                "SMB_COM_TREE_DISCONNECT response should not be null.");

            Site.Assert.IsInstanceOfType(
                response,
                typeof(SmbTreeDisconnectResponsePacket),
                "SMB_COM_TREE_DISCONNECT response should be received.");

            // Check the response validity by verifying the Status field in the SMB Header packet.
            SmbTreeDisconnectResponsePacket treeDisconnectResponse = (SmbTreeDisconnectResponsePacket)response;
            Site.Assert.AreEqual <uint>(
                (uint)SmbStatus.STATUS_SUCCESS,
                treeDisconnectResponse.SmbHeader.Status,
                "SMB_COM_TREE_DISCONNECT response status should be SUCCESS.");

            #endregion

            #region Send the SMB_COM_LOGOFF_ANDX request

            // LogOff
            SmbLogoffAndxRequestPacket logoffRequest = smbClientStack.CreateLogoffRequest(sessionUid);

            smbClientStack.SendPacket(logoffRequest);

            response = smbClientStack.ExpectPacket(timeout);

            // Check whether server return a response.
            Site.Assert.IsNotNull(
                response,
                "SMB_COM_LOGOFF_ANDX response should not be null.");

            Site.Assert.IsInstanceOfType(
                response,
                typeof(SmbLogoffAndxResponsePacket),
                "SMB_COM_LOGOFF_ANDX response should be received.");

            // Check the response validity by verifying the Status field in the SMB Header packet.
            SmbLogoffAndxResponsePacket logoffResponse = (SmbLogoffAndxResponsePacket)response;
            Site.Assert.AreEqual <uint>(
                (uint)SmbStatus.STATUS_SUCCESS,
                logoffResponse.SmbHeader.Status,
                "SMB_COM_LOGOFF_ANDX response status should be SUCCESS.");

            #endregion

            #region Disconnect

            // Disconnect
            smbClientStack.Disconnect();

            Site.Assert.IsFalse(
                smbClientStack.IsDataAvailable,
                "SmbClient should not receive any packet after Disconnect method is called.");

            #endregion
        }