NodeStatistics.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.NetBios
  12. {
  13. public class NodeStatistics
  14. {
  15. public const int Length = 46;
  16. public byte[] UnitID; // MAC address, 6 bytes;
  17. public byte Jumpers;
  18. public byte TestResult;
  19. public ushort VersionNumber;
  20. public ushort PeriodOfStatistics;
  21. public ushort NumberOfCRCs;
  22. public ushort NumberOfAlignmentErrors;
  23. public ushort NumberOfCollisions;
  24. public ushort NumberOfSendAborts;
  25. public uint NumberOfGoodSends;
  26. public uint NumberOfGoodReceives;
  27. public ushort NumberOfRetransmits;
  28. public ushort NumberOfNoResourceConditions;
  29. public ushort NumberOfFreeCommandBlocks;
  30. public ushort TotalNumberOfCommandBlocks;
  31. public ushort MaxTotalNumberOfCommandBlocks;
  32. public ushort NumberOfPendingSessions;
  33. public ushort MaxNumberOfPendingSessions;
  34. public ushort MaxTotalsSessionsPossible;
  35. public ushort SessionDataPacketSize;
  36. public NodeStatistics()
  37. {
  38. UnitID = new byte[6];
  39. }
  40. public void WriteBytes(byte[] buffer, int offset)
  41. {
  42. ByteWriter.WriteBytes(buffer, ref offset, UnitID, 6);
  43. ByteWriter.WriteByte(buffer, ref offset, Jumpers);
  44. ByteWriter.WriteByte(buffer, ref offset, TestResult);
  45. BigEndianWriter.WriteUInt16(buffer, ref offset, VersionNumber);
  46. BigEndianWriter.WriteUInt16(buffer, ref offset, PeriodOfStatistics);
  47. BigEndianWriter.WriteUInt16(buffer, ref offset, NumberOfCRCs);
  48. BigEndianWriter.WriteUInt16(buffer, ref offset, NumberOfAlignmentErrors);
  49. BigEndianWriter.WriteUInt16(buffer, ref offset, NumberOfCollisions);
  50. BigEndianWriter.WriteUInt16(buffer, ref offset, NumberOfSendAborts);
  51. BigEndianWriter.WriteUInt32(buffer, ref offset, NumberOfGoodSends);
  52. BigEndianWriter.WriteUInt32(buffer, ref offset, NumberOfGoodReceives);
  53. BigEndianWriter.WriteUInt16(buffer, ref offset, NumberOfRetransmits);
  54. BigEndianWriter.WriteUInt16(buffer, ref offset, NumberOfNoResourceConditions);
  55. BigEndianWriter.WriteUInt16(buffer, ref offset, NumberOfFreeCommandBlocks);
  56. BigEndianWriter.WriteUInt16(buffer, ref offset, TotalNumberOfCommandBlocks);
  57. BigEndianWriter.WriteUInt16(buffer, ref offset, MaxTotalNumberOfCommandBlocks);
  58. BigEndianWriter.WriteUInt16(buffer, ref offset, NumberOfPendingSessions);
  59. BigEndianWriter.WriteUInt16(buffer, ref offset, MaxNumberOfPendingSessions);
  60. BigEndianWriter.WriteUInt16(buffer, ref offset, MaxTotalsSessionsPossible);
  61. BigEndianWriter.WriteUInt16(buffer, ref offset, SessionDataPacketSize);
  62. }
  63. public byte[] GetBytes()
  64. {
  65. byte[] buffer = new byte[Length];
  66. WriteBytes(buffer, 0);
  67. return buffer;
  68. }
  69. }
  70. }