protected override int ParseBodyImage(byte[] buffer, int startIndex, int length)
{
if (DraftRevision == DraftRevision.Draft6)
{
// Handle single label the standard way (parsing out null value)
return base.ParseBodyImage(buffer, startIndex, length);
}
else
{
int parseLength = MaximumLabelLength;
byte[] labelBuffer = new byte[16];
string[] labels = new string[16];
for (int i = 0; i < 16; i++)
{
// Get next label buffer
Buffer.BlockCopy(buffer, startIndex + i * 16, labelBuffer, 0, 16);
bool foundNull = false;
// Replace null characters with spaces; since characters after null
// are usually invalid garbage, blank these out with spaces as well
for (int j = 0; j < 16; j++)
{
if (foundNull || labelBuffer[j] == 0)
{
foundNull = true;
labelBuffer[j] = 32;
}
}
// Interpret bytes as an ASCII string
labels[i] = Encoding.ASCII.GetString(labelBuffer, 0, 16);
}
// Concatenate all labels together into one large string
Label = string.Concat(labels);
return parseLength;
}
}