protected override void Decode(IChannelHandlerContext context, DatagramPacket message, List <object> output) { IByteBuffer buffer = message.Content; IDnsQuery query = NewQuery(message, buffer); bool success = false; try { int questionCount = buffer.ReadUnsignedShort(); int answerCount = buffer.ReadUnsignedShort(); int authorityRecordCount = buffer.ReadUnsignedShort(); int additionalRecordCount = buffer.ReadUnsignedShort(); DecodeQuestions(query, buffer, questionCount); DecodeRecords(query, DnsSection.ANSWER, buffer, answerCount); DecodeRecords(query, DnsSection.AUTHORITY, buffer, authorityRecordCount); DecodeRecords(query, DnsSection.ADDITIONAL, buffer, additionalRecordCount); output.Add(query); success = true; } finally { if (!success) { query.Release(); } } }