public static void TreeConnectResponse(ModelSmb2Status status, ShareType_Values shareType, TreeMgmtServerConfig config)
        {
            Condition.IsTrue(Config.Platform == config.Platform);
            Condition.IsTrue(State == ModelState.Connected);

            ModelTreeMgmtTreeConnectRequest treeConnectRequest = ModelHelper.RetrieveOutstandingRequest <ModelTreeMgmtTreeConnectRequest>(ref Request);

            if (treeConnectRequest.sharePath == ModelSharePath.InvalidSharePath)
            {
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.5.7: Otherwise, the server MUST provide the tuple <hostname, sharename> parsed from the request message to invoke the event specified in [MS-SRVS] section 3.1.6.8," +
                    " to normalize the hostname by resolving server aliases and evaluating share scope. The server MUST use <normalized hostname, sharename> to look up the Share in ShareList." +
                    " If no share with a matching share name and server name is found, the server MUST fail the request with STATUS_BAD_NETWORK_NAME");
                ModelHelper.Log(
                    LogType.TestInfo,
                    "Share path is an invalid share path");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
                Condition.IsTrue(status == ModelSmb2Status.STATUS_BAD_NETWORK_NAME);
                return;
            }

            // Only cover Windows behavior (SHOULD behavior) in one condition when the share is "IPC$" or has STYPE_SPECIAL bit set
            // Other cases for 3.3.5.7 statement below are not covered
            // Assume NonWindows will have same behvior regarding to 3.3.4.13 statement
            if (Session_SecurityContext == ModelSessionSecurityContext.NonAdmin &&
                treeConnectRequest.sharePath == ModelSharePath.SpecialSharePath)
            {
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.5.7: The server MUST determine whether the user represented by Session.SecurityContext should be granted access based on the authorization policy specified in Share.ConnectSecurity." +
                    " If the server determines that access should not be granted, the server MUST fail the request with STATUS_ACCESS_DENIED.");
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.4.13: If Share.Name is equal to \"IPC$\" or Share.Type does not have the STYPE_SPECIAL bit set," +
                    " then Share.ConnectSecurity SHOULD be set to a security descriptor allowing all users." +
                    " Otherwise, Share.ConnectSecurity SHOULD be set to a security descriptor allowing only administrators.");
                ModelHelper.Log(
                    LogType.TestInfo,
                    "User authenticated the session is a NonAdmin, and share in the TreeConnect request has STYPE_SPECIAL bit set");
                ModelHelper.Log(LogType.TestTag, TestTag.Compatibility);
                Condition.IsTrue(status == ModelSmb2Status.STATUS_ACCESS_DENIED);
                return;
            }

            Condition.IsTrue(status == ModelSmb2Status.STATUS_SUCCESS);

            if (treeConnectRequest.sharePath != ModelSharePath.SpecialSharePath)
            {
                // only check on Basic Share, Share with Special Bit can be any Type of Share
                // currently, only DISK ShareType in FileSharing Family test suite
                // it's not TD requirement but assumption
                Condition.IsTrue(shareType == ShareType_Values.SHARE_TYPE_DISK);
            }

            Session_TreeConnectExist = true;
        }
        public static void TreeConnectResponse(ModelSmb2Status status, ShareType_Values shareType, TreeMgmtServerConfig config)
        {
            Condition.IsTrue(Config.Platform == config.Platform);
            Condition.IsTrue(State == ModelState.Connected);

            ModelTreeMgmtTreeConnectRequest treeConnectRequest = ModelHelper.RetrieveOutstandingRequest<ModelTreeMgmtTreeConnectRequest>(ref Request);

            if (treeConnectRequest.sharePath == ModelSharePath.InvalidSharePath )
            {
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.5.7: Otherwise, the server MUST provide the tuple <hostname, sharename> parsed from the request message to invoke the event specified in [MS-SRVS] section 3.1.6.8," +
                    " to normalize the hostname by resolving server aliases and evaluating share scope. The server MUST use <normalized hostname, sharename> to look up the Share in ShareList." +
                    " If no share with a matching share name and server name is found, the server MUST fail the request with STATUS_BAD_NETWORK_NAME");
                ModelHelper.Log(
                    LogType.TestInfo,
                    "Share path is an invalid share path");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
                Condition.IsTrue(status == ModelSmb2Status.STATUS_BAD_NETWORK_NAME);
                return;
            }

            // Only cover Windows behavior (SHOULD behavior) in one condition when the share is "IPC$" or has STYPE_SPECIAL bit set
            // Other cases for 3.3.5.7 statement below are not covered
            // Assume NonWindows will have same behvior regarding to 3.3.4.13 statement
            if (Session_SecurityContext == ModelSessionSecurityContext.NonAdmin
                && treeConnectRequest.sharePath == ModelSharePath.SpecialSharePath)
            {
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.5.7: The server MUST determine whether the user represented by Session.SecurityContext should be granted access based on the authorization policy specified in Share.ConnectSecurity." +
                    " If the server determines that access should not be granted, the server MUST fail the request with STATUS_ACCESS_DENIED.");
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.4.13: If Share.Name is equal to \"IPC$\" or Share.Type does not have the STYPE_SPECIAL bit set," +
                    " then Share.ConnectSecurity SHOULD be set to a security descriptor allowing all users." +
                    " Otherwise, Share.ConnectSecurity SHOULD be set to a security descriptor allowing only administrators.");
                ModelHelper.Log(
                    LogType.TestInfo,
                    "User authenticated the session is a NonAdmin, and share in the TreeConnect request has STYPE_SPECIAL bit set");
                ModelHelper.Log(LogType.TestTag, TestTag.Compatibility);
                Condition.IsTrue(status == ModelSmb2Status.STATUS_ACCESS_DENIED);
                return;
            }

            Condition.IsTrue(status == ModelSmb2Status.STATUS_SUCCESS);

            if (treeConnectRequest.sharePath != ModelSharePath.SpecialSharePath)
            {
                // only check on Basic Share, Share with Special Bit can be any Type of Share
                // currently, only DISK ShareType in FileSharing Family test suite
                // it's not TD requirement but assumption
                Condition.IsTrue(shareType == ShareType_Values.SHARE_TYPE_DISK);
            }

            Session_TreeConnectExist = true;
        }
        public Smb2TreeConnectResponsePacket CreateTreeConnectResponse(
            Smb2Endpoint endpoint,
            ulong messageId,
            uint treeId,
            ShareType_Values shareType,
            ShareFlags_Values shareFlags,
            Capabilities_Values capabilities,
            _ACCESS_MASK maximalAccess
            )
        {
            Smb2TreeConnectResponsePacket packet = new Smb2TreeConnectResponsePacket();

            SetHeader(packet, endpoint, messageId);

            packet.Header.TreeId = treeId;
            packet.PayLoad.Capabilities = capabilities;
            packet.PayLoad.MaximalAccess = maximalAccess;
            packet.PayLoad.Reserved = Reserved_Values.V1;
            packet.PayLoad.ShareFlags = shareFlags;
            packet.PayLoad.ShareType = shareType;
            packet.PayLoad.StructureSize = StructureSize_Values.V1;

            packet.Sign();

            return packet;
        }