ActionTaken.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. namespace SMBLibrary.SMB1
  9. {
  10. public enum LockStatus : byte
  11. {
  12. NoOpLockWasRequestedOrGranted = 0x00,
  13. OpLockWasRequestedAndGranted = 0x01,
  14. }
  15. public struct ActionTaken
  16. {
  17. public OpenResult OpenResult;
  18. public LockStatus LockStatus;
  19. public ActionTaken(byte[] buffer, int offset)
  20. {
  21. OpenResult = (OpenResult)(buffer[offset + 0] & 0x03);
  22. LockStatus = (LockStatus)(buffer[offset + 1] >> 7);
  23. }
  24. public void WriteBytes(byte[] buffer, int offset)
  25. {
  26. buffer[offset + 0] = (byte)((byte)OpenResult & 0x03);
  27. buffer[offset + 1] = (byte)((byte)LockStatus << 7);
  28. }
  29. }
  30. }