public static void OplockBreakNotification(OPLOCK_BREAK_Notification_Packet_OplockLevel_Values acceptableAckOplockLevel)
        {
            Condition.IsTrue(State == ModelState.Connected);

            ModelHelper.Log(LogType.Requirement, "3.3.4.6: The new oplock level MUST be either SMB2_OPLOCK_LEVEL_NONE or SMB2_OPLOCK_LEVEL_II.");
            Condition.IsTrue(acceptableAckOplockLevel == OPLOCK_BREAK_Notification_Packet_OplockLevel_Values.OPLOCK_LEVEL_II
                || acceptableAckOplockLevel == OPLOCK_BREAK_Notification_Packet_OplockLevel_Values.OPLOCK_LEVEL_NONE);

            ModelHelper.Log(LogType.Requirement,
                "The server MUST locate the open by walking the GlobalOpenTable to find an entry whose Open.LocalOpen matches the one provided in the oplock break. ");
            ModelHelper.Log(LogType.Requirement,
                "If no entry is found, the break indication MUST be ignored and the server MUST complete the oplock break call with SMB2_OPLOCK_LEVEL_NONE as the new oplock level.");
            ModelHelper.Log(LogType.TestInfo, "Open should not be NULL.");
            Condition.IsNotNull(Open);

            ModelHelper.Log(LogType.TestInfo, "Open.OplockState is set to Breaking.");
            Open.OplockState = OplockState.Breaking;
        }
Example #2
0
        public static void OplockBreakNotification(OPLOCK_BREAK_Notification_Packet_OplockLevel_Values acceptableAckOplockLevel)
        {
            Condition.IsTrue(State == ModelState.Connected);

            ModelHelper.Log(LogType.Requirement, "3.3.4.6: The new oplock level MUST be either SMB2_OPLOCK_LEVEL_NONE or SMB2_OPLOCK_LEVEL_II.");
            Condition.IsTrue(acceptableAckOplockLevel == OPLOCK_BREAK_Notification_Packet_OplockLevel_Values.OPLOCK_LEVEL_II ||
                             acceptableAckOplockLevel == OPLOCK_BREAK_Notification_Packet_OplockLevel_Values.OPLOCK_LEVEL_NONE);

            ModelHelper.Log(LogType.Requirement,
                            "The server MUST locate the open by walking the GlobalOpenTable to find an entry whose Open.LocalOpen matches the one provided in the oplock break. ");
            ModelHelper.Log(LogType.Requirement,
                            "If no entry is found, the break indication MUST be ignored and the server MUST complete the oplock break call with SMB2_OPLOCK_LEVEL_NONE as the new oplock level.");
            ModelHelper.Log(LogType.TestInfo, "Open should not be NULL.");
            Condition.IsNotNull(Open);

            ModelHelper.Log(LogType.TestInfo, "Open.OplockState is set to Breaking.");
            Open.OplockState = OplockState.Breaking;
        }
        /// <summary>
        /// Create Smb2OpLockBreakNotificationPacket
        /// </summary>
        /// <param name="endpoint">represents where this packet will be sent</param>
        /// <param name="oplockLevel">The server MUST set this to the maximum value of the OplockLevel 
        /// that the server will accept for an acknowledgment from the client</param>
        /// <param name="fileId">An SMB2_FILEID, as specified in section 2.2.14.1</param>
        /// <returns>A Smb2OpLockBreakNotificationPacket</returns>
        public Smb2OpLockBreakNotificationPacket CreateOpLockBreakNotificationResponse(
            Smb2Endpoint endpoint,
            OPLOCK_BREAK_Notification_Packet_OplockLevel_Values oplockLevel,
            FILEID fileId
            )
        {
            Smb2OpLockBreakNotificationPacket packet = new Smb2OpLockBreakNotificationPacket();

            packet.Header.Flags = Packet_Header_Flags_Values.FLAGS_SERVER_TO_REDIR;
            packet.Header.Command = Smb2Command.OPLOCK_BREAK;
            packet.Header.MessageId = ulong.MaxValue;
            packet.Header.ProtocolId = Smb2Consts.Smb2ProtocolId;
            packet.Header.Signature = new byte[Smb2Consts.SignatureSize];
            packet.Header.StructureSize = Packet_Header_StructureSize_Values.V1;

            packet.Endpoint = endpoint;
            packet.PayLoad.FileId = fileId;
            packet.PayLoad.OplockLevel = oplockLevel;
            packet.PayLoad.Reserved = OPLOCK_BREAK_Notification_Packet_Reserved_Values.V1;
            packet.PayLoad.Reserved2 = OPLOCK_BREAK_Notification_Packet_Reserved2_Values.V1;
            packet.PayLoad.StructureSize = OPLOCK_BREAK_Notification_Packet_StructureSize_Values.V1;

            packet.Sign();

            return packet;
        }