NameQueryRequest.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright (C) 2014-2020 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.IO;
  10. using System.Text;
  11. using Utilities;
  12. namespace SMBLibrary.NetBios
  13. {
  14. /// <summary>
  15. /// [RFC 1002] 4.2.12. NAME QUERY REQUEST
  16. /// </summary>
  17. public class NameQueryRequest
  18. {
  19. public NameServicePacketHeader Header;
  20. public QuestionSection Question;
  21. public NameQueryRequest()
  22. {
  23. Header = new NameServicePacketHeader();
  24. Header.OpCode = NameServiceOperation.QueryRequest;
  25. Header.Flags = OperationFlags.RecursionDesired;
  26. Question = new QuestionSection();
  27. Question.Type = NameRecordType.NB;
  28. }
  29. public NameQueryRequest(byte[] buffer, int offset)
  30. {
  31. Header = new NameServicePacketHeader(buffer, ref offset);
  32. Question = new QuestionSection(buffer, ref offset);
  33. }
  34. public byte[] GetBytes()
  35. {
  36. MemoryStream stream = new MemoryStream();
  37. Header.WriteBytes(stream);
  38. Question.WriteBytes(stream);
  39. return stream.ToArray();
  40. }
  41. }
  42. }