NetBios: PositiveNameQueryResponse: Added read constructor

This commit is contained in:
Tal Aloni 2020-01-25 21:01:30 +02:00
parent c3f00c5757
commit 254e78a969

View file

@ -21,6 +21,7 @@ namespace SMBLibrary.NetBios
public NameServicePacketHeader Header;
public ResourceRecord Resource;
// Resource Data:
public KeyValuePairList<byte[], NameFlags> Addresses = new KeyValuePairList<byte[], NameFlags>();
public PositiveNameQueryResponse()
@ -32,6 +33,19 @@ namespace SMBLibrary.NetBios
Resource = new ResourceRecord(NameRecordType.NB);
}
public PositiveNameQueryResponse(byte[] buffer, int offset)
{
Header = new NameServicePacketHeader(buffer, ref offset);
Resource = new ResourceRecord(buffer, ref offset);
int position = 0;
while (position < Resource.Data.Length)
{
NameFlags nameFlags = (NameFlags)BigEndianReader.ReadUInt16(Resource.Data, ref position);
byte[] address = ByteReader.ReadBytes(Resource.Data, ref position, 4);
Addresses.Add(address, nameFlags);
}
}
public byte[] GetBytes()
{
Resource.Data = GetData();