SessionRetargetResponsePacket.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Copyright (C) 2014-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.NetBios
  11. {
  12. /// <summary>
  13. /// [RFC 1002] 4.3.5. SESSION RETARGET RESPONSE PACKET
  14. /// </summary>
  15. public class SessionRetargetResponsePacket : SessionPacket
  16. {
  17. uint IPAddress;
  18. ushort Port;
  19. public SessionRetargetResponsePacket() : base()
  20. {
  21. this.Type = SessionPacketTypeName.RetargetSessionResponse;
  22. }
  23. public SessionRetargetResponsePacket(byte[] buffer, int offset) : base(buffer, offset)
  24. {
  25. IPAddress = BigEndianConverter.ToUInt32(this.Trailer, offset + 0);
  26. Port = BigEndianConverter.ToUInt16(this.Trailer, offset + 4);
  27. }
  28. public override byte[] GetBytes()
  29. {
  30. this.Trailer = new byte[6];
  31. BigEndianWriter.WriteUInt32(this.Trailer, 0, IPAddress);
  32. BigEndianWriter.WriteUInt16(this.Trailer, 4, Port);
  33. return base.GetBytes();
  34. }
  35. public override int Length
  36. {
  37. get
  38. {
  39. return HeaderLength + 6;
  40. }
  41. }
  42. }
  43. }