Example #1
0
        public void RequestOplockAndOperateFileRequest(
            RequestedOplockLevel_Values requestedOplockLevel,
            OplockFileOperation fileOperation,
            out OplockLevel_Values grantedOplockLevel,
            out OplockConfig c)
        {
            Smb2CreateContextResponse[] serverCreateContexts;
            string fileName = GetTestFileName(uncSharePath);

            OplockLevel_Values grantedTmp = OplockLevel_Values.OPLOCK_LEVEL_NONE;

            testClient.Create(
                treeId,
                fileName,
                CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                out fileId,
                out serverCreateContexts,
                requestedOplockLevel_Values: requestedOplockLevel,
                checker: (header, response) =>
            {
                grantedTmp = response.OplockLevel;
            });

            Site.Log.Add(LogEntryKind.Debug, "OplockLevel granted by server: {0}", grantedTmp);
            grantedOplockLevel = grantedTmp;
            c = oplockConfig;

            oplockLevelOnOpen = grantedTmp;

            fileOperationInvoker = new FileOperationDelegate(FileOperation);
            var task = Task.Run(() => fileOperationInvoker.Invoke(fileOperation, fileName));

            task.Wait(500);// Assume that notification will arrive in .5 sec if there's any
        }
Example #2
0
        private void FileOperation(OplockFileOperation fileOperation, string fileName)
        {
            Site.Log.Add(LogEntryKind.Debug, "File operation on same file from another client");

            Smb2FunctionalClient clientForAnotherOpen = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site);

            clientForAnotherOpen.ConnectToServer(testConfig.UnderlyingTransport, testConfig.SutComputerName, testConfig.SutIPAddress, testConfig.ClientNic1IPAddress);

            clientForAnotherOpen.Negotiate(new DialectRevision[] { negotiatedDialect }, testConfig.IsSMB1NegotiateEnabled);

            clientForAnotherOpen.SessionSetup(
                testConfig.DefaultSecurityPackage,
                server,
                testConfig.AccountCredential,
                testConfig.UseServerGssToken);

            uint treeIdForAnotherOpen;

            clientForAnotherOpen.TreeConnect(
                uncSharePath,
                out treeIdForAnotherOpen);

            FILEID fileIdForAnotherOpen;

            Smb2CreateContextResponse[] serverCreateContexts;

            clientForAnotherOpen.Create(
                treeIdForAnotherOpen,
                fileName,
                CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                out fileIdForAnotherOpen,
                out serverCreateContexts);

            if (fileOperation == OplockFileOperation.WriteFromAnotherOpen)
            {
                string writeContent = Smb2Utility.CreateRandomString(1);

                clientForAnotherOpen.Write(treeIdForAnotherOpen, fileIdForAnotherOpen, writeContent);
            }

            usedTestClients.Push(clientForAnotherOpen);
        }
        public void RequestOplockAndOperateFileRequest(
            RequestedOplockLevel_Values requestedOplockLevel,
            OplockFileOperation fileOperation,
            out OplockLevel_Values grantedOplockLevel,
            out OplockConfig c)
        {
            Smb2CreateContextResponse[] serverCreateContexts;
            string fileName = "OplockMBT_" + Guid.NewGuid().ToString();

            OplockLevel_Values grantedTmp = OplockLevel_Values.OPLOCK_LEVEL_NONE;

            testClient.Create(
                treeId,
                fileName,
                CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                out fileId,
                out serverCreateContexts,
                requestedOplockLevel_Values: requestedOplockLevel,
                checker: (header, response) =>
            {
                grantedTmp = response.OplockLevel;
            });

            Site.Log.Add(LogEntryKind.Debug, "OplockLevel granted by server: {0}", grantedTmp);
            grantedOplockLevel = grantedTmp;
            c = oplockConfig;

            oplockLevelOnOpen = grantedTmp;

            fileOperationInvoker = new FileOperationDelegate(FileOperation);
            fileOperationInvoker.BeginInvoke(fileOperation, fileName, null, null);

            // Assume that notification will arrive in .5 sec if there's any
            // Without such sleep, OplockBreakNotification would not be expected by SE
            Thread.Sleep(500);
        }
Example #4
0
        public static void RequestOplockAndOperateFileCall(RequestedOplockLevel_Values requestedOplockLevel, OplockFileOperation fileOperation)
        {
            Condition.IsTrue(State == ModelState.Connected);
            Condition.IsNull(Request);

            // <46> Section 2.2.14: Windows-based clients never use exclusive oplocks. Because there are no situations where it would
            // require an exclusive oplock where it would not also require an SMB2_OPLOCK_LEVEL_BATCH, it always requests an SMB2_OPLOCK_LEVEL_BATCH.
            Condition.IsTrue(requestedOplockLevel != RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE &&
                             requestedOplockLevel != RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE &&
                             requestedOplockLevel != RequestedOplockLevel_Values.OPLOCK_LEVEL_EXCLUSIVE);

            Request = new ModelRequestOplockAndTriggerBreakRequest(requestedOplockLevel);
        }
        public void RequestOplockAndOperateFileRequest(
            RequestedOplockLevel_Values requestedOplockLevel,
            OplockFileOperation fileOperation,
            out OplockLevel_Values grantedOplockLevel,
            out OplockConfig c)
        {
            Smb2CreateContextResponse[] serverCreateContexts;
            string fileName = "OplockMBT_"+ Guid.NewGuid().ToString();

            OplockLevel_Values grantedTmp = OplockLevel_Values.OPLOCK_LEVEL_NONE;
            testClient.Create(
                    treeId,
                    fileName,
                    CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                    out fileId,
                    out serverCreateContexts,
                    requestedOplockLevel_Values: requestedOplockLevel,
                    checker: (header, response) =>
                    {
                        grantedTmp = response.OplockLevel;
                    });

            Site.Log.Add(LogEntryKind.Debug, "OplockLevel granted by server: {0}", grantedTmp);
            grantedOplockLevel = grantedTmp;
            c = oplockConfig;

            oplockLevelOnOpen = grantedTmp;

            fileOperationInvoker = new FileOperationDelegate(FileOperation);
            fileOperationInvoker.BeginInvoke(fileOperation, fileName, null, null);

            // Assume that notification will arrive in .5 sec if there's any
            // Without such sleep, OplockBreakNotification would not be expected by SE
            Thread.Sleep(500);
        }
        private void FileOperation(OplockFileOperation fileOperation, string fileName)
        {
            Site.Log.Add(LogEntryKind.Debug, "File operation on same file from another client");

            Smb2FunctionalClient clientForAnotherOpen = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site);
            clientForAnotherOpen.ConnectToServer(testConfig.UnderlyingTransport, testConfig.SutComputerName, testConfig.SutIPAddress, testConfig.ClientNic1IPAddress);

            clientForAnotherOpen.Negotiate(new DialectRevision[]{negotiatedDialect}, testConfig.IsSMB1NegotiateEnabled);

            clientForAnotherOpen.SessionSetup(
                testConfig.DefaultSecurityPackage,
                server,
                testConfig.AccountCredential,
                testConfig.UseServerGssToken);

            uint treeIdForAnotherOpen;
            clientForAnotherOpen.TreeConnect(
                uncSharePath,
                out treeIdForAnotherOpen);

            FILEID fileIdForAnotherOpen;
            Smb2CreateContextResponse[] serverCreateContexts;

            clientForAnotherOpen.Create(
                treeIdForAnotherOpen,
                fileName,
                CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                out fileIdForAnotherOpen,
                out serverCreateContexts);

            if (fileOperation == OplockFileOperation.WriteFromAnotherOpen)
            {
                string writeContent = Smb2Utility.CreateRandomString(1);

                clientForAnotherOpen.Write(treeIdForAnotherOpen, fileIdForAnotherOpen, writeContent);
            }
        }
        public static void RequestOplockAndOperateFileCall(RequestedOplockLevel_Values requestedOplockLevel, OplockFileOperation fileOperation)
        {
            Condition.IsTrue(State == ModelState.Connected);
            Condition.IsNull(Request);

            // <46> Section 2.2.14: Windows-based clients never use exclusive oplocks. Because there are no situations where it would
            // require an exclusive oplock where it would not also require an SMB2_OPLOCK_LEVEL_BATCH, it always requests an SMB2_OPLOCK_LEVEL_BATCH.
            Condition.IsTrue(requestedOplockLevel != RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE
                && requestedOplockLevel != RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE
                && requestedOplockLevel != RequestedOplockLevel_Values.OPLOCK_LEVEL_EXCLUSIVE);

            Request = new ModelRequestOplockAndTriggerBreakRequest(requestedOplockLevel);
        }