Browse Source

SMB2: LockElement: Added SharedLock / ExclusiveLock / Unlock / FailImmediately properties

Tal Aloni 7 years ago
parent
commit
488165b8b9
1 changed files with 76 additions and 0 deletions
  1. 76 0
      SMBLibrary/SMB2/Structures/LockElement.cs

+ 76 - 0
SMBLibrary/SMB2/Structures/LockElement.cs

@@ -35,6 +35,82 @@ namespace SMBLibrary.SMB2
             LittleEndianWriter.WriteUInt64(buffer, offset + 20, Reserved);
         }
 
+        public bool SharedLock
+        {
+            get
+            {
+                return (Flags & LockFlags.SharedLock) > 0;
+            }
+            set
+            {
+                if (value)
+                {
+                    Flags |= LockFlags.SharedLock;
+                }
+                else
+                {
+                    Flags &= ~LockFlags.SharedLock;
+                }
+            }
+        }
+
+        public bool ExclusiveLock
+        {
+            get
+            {
+                return (Flags & LockFlags.ExclusiveLock) > 0;
+            }
+            set
+            {
+                if (value)
+                {
+                    Flags |= LockFlags.ExclusiveLock;
+                }
+                else
+                {
+                    Flags &= ~LockFlags.ExclusiveLock;
+                }
+            }
+        }
+
+        public bool Unlock
+        {
+            get
+            {
+                return (Flags & LockFlags.Unlock) > 0;
+            }
+            set
+            {
+                if (value)
+                {
+                    Flags |= LockFlags.Unlock;
+                }
+                else
+                {
+                    Flags &= ~LockFlags.Unlock;
+                }
+            }
+        }
+
+        public bool FailImmediately
+        {
+            get
+            {
+                return (Flags & LockFlags.FailImmediately) > 0;
+            }
+            set
+            {
+                if (value)
+                {
+                    Flags |= LockFlags.FailImmediately;
+                }
+                else
+                {
+                    Flags &= ~LockFlags.FailImmediately;
+                }
+            }
+        }
+
         public static List<LockElement> ReadLockList(byte[] buffer, int offset, int lockCount)
         {
             List<LockElement> result = new List<LockElement>();