From c3f00c5757162a2f8457be1b159318e086e9ab9f Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Sat, 25 Jan 2020 20:59:33 +0200 Subject: [PATCH] NetBios: NodeStatusResponse: Added read constructor --- .../NameServicePackets/NodeStatusResponse.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/SMBLibrary/NetBios/NameServicePackets/NodeStatusResponse.cs b/SMBLibrary/NetBios/NameServicePackets/NodeStatusResponse.cs index 6761a75..1f9b9d6 100644 --- a/SMBLibrary/NetBios/NameServicePackets/NodeStatusResponse.cs +++ b/SMBLibrary/NetBios/NameServicePackets/NodeStatusResponse.cs @@ -19,6 +19,7 @@ namespace SMBLibrary.NetBios { public NameServicePacketHeader Header; public ResourceRecord Resource; + // Resource Data: // byte NumberOfNames; public KeyValuePairList Names = new KeyValuePairList(); public NodeStatistics Statistics; @@ -33,6 +34,22 @@ namespace SMBLibrary.NetBios Statistics = new NodeStatistics(); } + public NodeStatusResponse(byte[] buffer, int offset) + { + Header = new NameServicePacketHeader(buffer, ref offset); + Resource = new ResourceRecord(buffer, ref offset); + + int position = 0; + byte numberOfNames = ByteReader.ReadByte(Resource.Data, ref position); + for (int index = 0; index < numberOfNames; index++) + { + string name = ByteReader.ReadAnsiString(Resource.Data, ref position, 16); + NameFlags nameFlags = (NameFlags)BigEndianReader.ReadUInt16(Resource.Data, ref position); + Names.Add(name, nameFlags); + } + Statistics = new NodeStatistics(Resource.Data, ref position); + } + public byte[] GetBytes() { Resource.Data = GetData();