NameQueryRequest.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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.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.ARCount = 1;
  26. Question = new QuestionSection();
  27. }
  28. public NameQueryRequest(byte[] buffer, int offset)
  29. {
  30. Header = new NameServicePacketHeader(buffer, ref offset);
  31. Question = new QuestionSection(buffer, ref offset);
  32. }
  33. public byte[] GetBytes()
  34. {
  35. MemoryStream stream = new MemoryStream();
  36. Header.WriteBytes(stream);
  37. Question.WriteBytes(stream);
  38. return stream.ToArray();
  39. }
  40. }
  41. }