ServerInfo.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 SMBLibrary.RPC;
  11. using Utilities;
  12. namespace SMBLibrary.Services
  13. {
  14. /// <summary>
  15. /// [MS-SRVS] SERVER_INFO Union
  16. /// </summary>
  17. public class ServerInfo : INDRStructure
  18. {
  19. public uint Level;
  20. public ServerInfoLevel Info;
  21. public ServerInfo()
  22. {
  23. }
  24. public ServerInfo(ServerInfoLevel info)
  25. {
  26. Level = info.Level;
  27. Info = info;
  28. }
  29. public ServerInfo(NDRParser parser)
  30. {
  31. Read(parser);
  32. }
  33. public void Read(NDRParser parser)
  34. {
  35. parser.BeginStructure(); // SERVER_INFO Union
  36. Level = parser.ReadUInt32();
  37. switch (Level)
  38. {
  39. case 100:
  40. ServerInfo100 info100 = null;
  41. parser.ReadEmbeddedStructureFullPointer<ServerInfo100>(ref info100);
  42. Info = info100;
  43. break;
  44. case 101:
  45. ServerInfo101 info101 = null;
  46. parser.ReadEmbeddedStructureFullPointer<ServerInfo101>(ref info101);
  47. Info = info101;
  48. break;
  49. default:
  50. throw new NotImplementedException();
  51. }
  52. ;
  53. parser.EndStructure(); // SERVER_INFO Union
  54. }
  55. public void Write(NDRWriter writer)
  56. {
  57. writer.BeginStructure(); // SERVER_INFO Union
  58. writer.WriteUInt32(Level);
  59. writer.WriteEmbeddedStructureFullPointer(Info);
  60. writer.EndStructure(); // SERVER_INFO Union
  61. }
  62. }
  63. }