VersionsSupported.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 System.Text;
  10. using Utilities;
  11. namespace SMBLibrary.RPC
  12. {
  13. /// <summary>
  14. /// p_rt_versions_supported_t
  15. /// </summary>
  16. public class VersionsSupported
  17. {
  18. public List<Version> Entries = new List<Version>(); // p_protocols
  19. public VersionsSupported()
  20. {
  21. }
  22. public VersionsSupported(byte[] buffer, int offset)
  23. {
  24. byte protocols = ByteReader.ReadByte(buffer, offset + 0);
  25. Entries = new List<Version>();
  26. for (int index = 0; index < protocols; index++)
  27. {
  28. Version version = new Version(buffer, offset + 1 + index * Version.Length);
  29. Entries.Add(version);
  30. }
  31. }
  32. public void WriteBytes(byte[] buffer, int offset)
  33. {
  34. ByteWriter.WriteByte(buffer, offset + 0, (byte)this.Count);
  35. for (int index = 0; index < Entries.Count; index++)
  36. {
  37. Entries[index].WriteBytes(buffer, offset + 1 + index * Version.Length);
  38. }
  39. }
  40. public int Count
  41. {
  42. get
  43. {
  44. return Entries.Count;
  45. }
  46. }
  47. public int Length
  48. {
  49. get
  50. {
  51. return 1 + Count * Version.Length;
  52. }
  53. }
  54. }
  55. }