ResultElement.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace SMBLibrary.RPC
  12. {
  13. /// <summary>
  14. /// p_result_t
  15. /// </summary>
  16. public struct ResultElement
  17. {
  18. public const int Length = 24;
  19. public NegotiationResult Result;
  20. public RejectionReason Reason;
  21. public SyntaxID TransferSyntax;
  22. public ResultElement(byte[] buffer, int offset)
  23. {
  24. Result = (NegotiationResult)LittleEndianConverter.ToUInt16(buffer, offset + 0);
  25. Reason = (RejectionReason)LittleEndianConverter.ToUInt16(buffer, offset + 2);
  26. TransferSyntax = new SyntaxID(buffer, offset + 4);
  27. }
  28. public void WriteBytes(byte[] buffer, int offset)
  29. {
  30. LittleEndianWriter.WriteUInt16(buffer, offset + 0, (ushort)Result);
  31. LittleEndianWriter.WriteUInt16(buffer, offset + 2, (ushort)Reason);
  32. TransferSyntax.WriteBytes(buffer, offset + 4);
  33. }
  34. }
  35. }