FlushRequest.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 FLUSH Request
  14. /// </summary>
  15. public class FlushRequest : SMB2Command
  16. {
  17. public const int DeclaredSize = 24;
  18. private ushort StructureSize;
  19. public ushort Reserved1;
  20. public uint Reserved2;
  21. public FileID FileId;
  22. public FlushRequest() : base(SMB2CommandName.Flush)
  23. {
  24. StructureSize = DeclaredSize;
  25. }
  26. public FlushRequest(byte[] buffer, int offset) : base(buffer, offset)
  27. {
  28. StructureSize = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 0);
  29. Reserved1 = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 2);
  30. Reserved2 = 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, Reserved1);
  37. LittleEndianWriter.WriteUInt32(buffer, offset + 4, Reserved2);
  38. FileId.WriteBytes(buffer, offset + 8);
  39. }
  40. public override int CommandLength
  41. {
  42. get
  43. {
  44. return DeclaredSize;
  45. }
  46. }
  47. }
  48. }