CloseRequest.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Copyright (C) 2017 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. using System.Collections.Generic;
  9. using Utilities;
  10. namespace SMBLibrary.SMB2
  11. {
  12. /// <summary>
  13. /// SMB2 CLOSE Request
  14. /// </summary>
  15. public class CloseRequest : SMB2Command
  16. {
  17. public const int DeclaredSize = 24;
  18. private ushort StructureSize;
  19. public CloseFlags Flags;
  20. public uint Reserved;
  21. public FileID FileId;
  22. public CloseRequest() : base(SMB2CommandName.Close)
  23. {
  24. StructureSize = DeclaredSize;
  25. }
  26. public CloseRequest(byte[] buffer, int offset) : base(buffer, offset)
  27. {
  28. StructureSize = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 0);
  29. Flags = (CloseFlags)LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 2);
  30. Reserved = LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 4);
  31. FileId = new FileID(buffer, offset + SMB2Header.Length + 8);
  32. }
  33. public override void WriteCommandBytes(byte[] buffer, int offset)
  34. {
  35. LittleEndianWriter.WriteUInt16(buffer, offset + 0, StructureSize);
  36. LittleEndianWriter.WriteUInt16(buffer, offset + 2, (ushort)Flags);
  37. LittleEndianWriter.WriteUInt32(buffer, offset + 4, Reserved);
  38. FileId.WriteBytes(buffer, offset + 8);
  39. }
  40. public bool PostQueryAttributes
  41. {
  42. get
  43. {
  44. return ((this.Flags & CloseFlags.PostQueryAttributes) > 0);
  45. }
  46. }
  47. public override int CommandLength
  48. {
  49. get
  50. {
  51. return DeclaredSize;
  52. }
  53. }
  54. }
  55. }