public int ParseBinaryImage(byte[] buffer, int startIndex, int length)
{
if ((object)buffer == null)
throw new ArgumentNullException(nameof(buffer));
int imageLength = BinaryLength;
if (length >= imageLength)
{
// Binary image has sufficient data.
UInt16 size;
m_type = (PacketType)(buffer[startIndex]);
m_identifier = buffer[startIndex + 1];
size = EndianOrder.ToUInt16(buffer, startIndex + 2);
Buffer.BlockCopy(buffer, startIndex + 4, m_authenticator, 0, m_authenticator.Length);
// Parse all attributes in the packet.
int cursor = 20;
while (cursor < size)
{
RadiusPacketAttribute attribute = new RadiusPacketAttribute(buffer, startIndex + cursor, length);
m_attributes.Add(attribute);
cursor += attribute.BinaryLength;
}
return imageLength;
}
// Binary image does not have sufficient data.
return 0;
}