The SMB2 OPLOCK_BREAK Notification Packet is sent by the server when the underlying object store indicates that an opportunistic lock (oplock) is being broken, representing a change in the oplock level. This response is composed of an SMB2 header, as specified in section , followed by this notification structure:
 private void OnLeaseBreakNotificationReceived(Packet_Header header, OPLOCK_BREAK_Notification_Packet notification)
 {
     breakType = ModelBreakType.OplockBreak;
     oplockClient.OplockAcknowledgement(treeIdOplock, notification.FileId, (OPLOCK_BREAK_Acknowledgment_OplockLevel_Values)notification.OplockLevel);
 }
        private void OnOpLockBreakNotificationReceived(Packet_Header respHeader, OPLOCK_BREAK_Notification_Packet OpLockBreakNotify)
        {
            BaseTestSite.Log.Add(
                LogEntryKind.Comment,
                "OpLockBreakNotification was received from server");
            OpLockBreakNotifyReceived = OpLockBreakNotify;

            ///The FileId field of the response structure MUST be set to the values from the Open structure,
            ///with the volatile part set to Open.FileId and the persistent part set to Open.DurableFileId.
            BaseTestSite.Assert.AreEqual(fileId, OpLockBreakNotify.FileId, "FileId should be identical");

            BaseTestSite.Assert.IsTrue(
                OpLockBreakNotify.OplockLevel == OPLOCK_BREAK_Notification_Packet_OplockLevel_Values.OPLOCK_LEVEL_II ||
                OpLockBreakNotify.OplockLevel == OPLOCK_BREAK_Notification_Packet_OplockLevel_Values.OPLOCK_LEVEL_NONE,
                "The new oplock level MUST be either SMB2_OPLOCK_LEVEL_NONE or SMB2_OPLOCK_LEVEL_II.");
            OpLockNotificationReceived.Set();
        }
        private void OnOplockBreakNotificationReceived(Packet_Header header, OPLOCK_BREAK_Notification_Packet packet)
        {
            Site.Log.Add(LogEntryKind.Debug, "OplockBreakNotification was received from server");

            Site.Assert.AreEqual(
                Smb2Command.OPLOCK_BREAK,
                header.Command,
                "The server MUST set the Command in the SMB2 header to SMB2 OPLOCK_BREAK");

            Site.Assert.AreEqual(
                0xFFFFFFFFFFFFFFFF,
                header.MessageId,
                "The server MUST set the MessageId to 0xFFFFFFFFFFFFFFFF");

            Site.Assert.AreEqual(
                (ulong)0,
                header.SessionId,
                "The server MUST set the SessionId to 0");

            Site.Assert.AreEqual(
                (uint)0,
                header.TreeId,
                "The server MUST set the TreeId to 0");

            Site.Assert.AreEqual(
                fileId,
                packet.FileId,
                "The FileId field of the response structure MUST be set to the values from the Open structure, with the volatile part set to Open.FileId and the persistent part set to Open.DurableFileId");

            // Verify signature is set to 0 if it's not signed
            Site.Assert.AreEqual(
                true,
                BitConverter.ToUInt64(header.Signature, 0) == 0 && BitConverter.ToUInt64(header.Signature, 8) == 0,
                "The SMB2 Oplock Break Notification is sent to the client. The message MUST NOT be signed, as specified in section 3.3.4.1.1");

            OplockBreakNotification(packet.OplockLevel);
        }
        /// <summary>
        /// Handle the oplock break notification.
        /// </summary>
        /// <param name="respHeader">The SMB2 header included in the notification.</param>
        /// <param name="oplockBreakNotify">Oplock break notification payload in the notification.</param>
        private void OnOplockBreakNotificationReceived(Packet_Header respHeader, OPLOCK_BREAK_Notification_Packet oplockBreakNotify)
        {
            Smb2FunctionalClient client = null;
            if (smb2ClientMainChannel != null)
            {
                client = smb2ClientMainChannel;
            }
            else if (smb2ClientAlternativeChannel != null)
            {
                client = smb2ClientAlternativeChannel;
            }

            if (client != null)
            {
                Site.Log.Add(LogEntryKind.Debug, "Receive an oplock break notification and will send oplock break acknowledgment.");
                client.OplockAcknowledgement(
                    treeIdMainChannel,
                    fileIdMainChannel,
                    (OPLOCK_BREAK_Acknowledgment_OplockLevel_Values)oplockBreakNotify.OplockLevel,
                    checker: (responseHeader, response) => { }
                    );
            }
        }