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
        }
        public void Trans2FindNext2Request(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            bool isReparse,
            [Domain("InfoLevelFind")] InformationLevel informationLevel,
            int sid,
            int gmtTokenIndex,
            bool isFlagsKnowsLongNameSet)
        {
            #region Create Packet

            SmbTrans2FindNext2RequestPacket smbPacket = new SmbTrans2FindNext2RequestPacket();

            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 < (int)uint.MinValue)
            {
                fileName = Site.Properties["SmbTestCaseBadGmt"].ToString();
            }
            else
            {
                if (this.gmtTokens.ContainsKey(gmtTokenIndex))
                {
                    fileName = this.gmtTokens[gmtTokenIndex];
                }
                else
                {
                    fileName = this.gmtTokens[ValidgmtTokenIndex];
                }
            }

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

            ushort searchCount = ushort.Parse(Site.Properties["SmbTransportSearchCount"]);

            smbPacket = this.smbClientStack.CreateTrans2FindNext2Request(
                tid,
                fileName,
                transactOptions,
                searchCount,
                (ushort)this.sId[(uint)sid],
                uint.MinValue,
                findFlags,
                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;
                }
                this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status);
            }
            else
            {
                SmbTrans2FindNext2ResponsePacket smbTrans2FindNext2Packet = response
                    as SmbTrans2FindNext2ResponsePacket;

                NamespaceCifs.SmbHeader smtTrans2FindNext2ResponseHeader = smbTrans2FindNext2Packet.SmbHeader;

                SmbTrans2FindNext2RequestPacket lastPacketFindNext = smbPacket as SmbTrans2FindNext2RequestPacket;

                NamespaceCifs.TRANS2_FIND_NEXT2_Request_Trans2_Parameters trans2FindNext2RequestHeader
                    = lastPacketFindNext.Trans2Parameters;

                bool isFileIDEqualZero = true;
                switch (trans2FindNext2RequestHeader.InformationLevel)
                {
                    case NamespaceCifs.FindInformationLevel.SMB_FIND_FILE_FULL_DIRECTORY_INFO:
                        {
                            if (smbTrans2FindNext2Packet.SmbData.Trans2_Data.Length != uint.MinValue)
                            {
                                NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket
                                    findNextFsccFullDirectoryPacket =
                                    new NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket();

                                findNextFsccFullDirectoryPacket.FromBytes(smbTrans2FindNext2Packet.SmbData.Trans2_Data);

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

                                findNextFullDirectoryInformation = findNextFsccFullDirectoryPacket.Payload;
                                if (findNextFullDirectoryInformation.FileNameLength == uint.MinValue)
                                {
                                    isFileIDEqualZero = true;
                                }

                                VerifyMessageSyntaxSmbFindFileIdFullDirectoryInfo(findNextFullDirectoryInformation);
                            }

                            break;
                        }

                    case NamespaceCifs.FindInformationLevel.SMB_FIND_FILE_BOTH_DIRECTORY_INFO:
                        {
                            if (smbTrans2FindNext2Packet.SmbData.Trans2_Data.Length != uint.MinValue)
                            {
                                NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket
                                    findNextFsccBothDirectoryPacket =
                                    new NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket();

                                findNextFsccBothDirectoryPacket.FromBytes(smbTrans2FindNext2Packet.SmbData.Trans2_Data);

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

                                findNextBothDirectoryInformation = findNextFsccBothDirectoryPacket.Payload;
                                if (findNextBothDirectoryInformation.FileNameLength == uint.MinValue)
                                {
                                    isFileIDEqualZero = true;
                                }

                                if (this.smbClientStack.Capability.IsSupportsExtendedSecurity == true)
                                {
                                    VerifyMessageSyntaxSmbFindFileBothDirectoryInfo(findNextBothDirectoryInformation);
                                }
                            }

                            break;
                        }

                    case NamespaceCifs.FindInformationLevel.SMB_FIND_FILE_DIRECTORY_INFO:
                        {
                            if (SmbAdapter.fileSystemType == FileSystemType.Fat)
                            {
                                isFileIDEqualZero = true;
                            }
                            else
                            {
                                isFileIDEqualZero = false;
                            }

                            break;
                        }
                }

                this.Trans2FindNext2Response(
                    smtTrans2FindNext2ResponseHeader.Mid + this.addMidMark,
                    this.QueryUidTable(smbPacketResponse),
                    this.QueryTidTable(smbPacketResponse),
                    (smbPacketResponse).IsSignRequired,
                    isFileIDEqualZero,
                    (MessageStatus)smtTrans2FindNext2ResponseHeader.Status);
            }

            #endregion
        }
        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
        }