def Message.decode(m)
o = Message.new()
begin
MessageDecoder.new(m) {|msg|
o.header = Header.new(msg)
o.header.qdcount.times {
question = msg.get_question
o.question << question
}
o.header.ancount.times {
rr = msg.get_rr
o.answer << rr
}
o.header.nscount.times {
rr = msg.get_rr
o.authority << rr
}
o.header.arcount.times { |count|
start = msg.index
rr = msg.get_rr
if (rr.type == Types::TSIG)
if (count!=o.header.arcount-1)
Dnsruby.log.Error("Incoming message has TSIG record before last record")
raise DecodeError.new("TSIG record present before last record")
end
o.tsigstart = start
end
o.additional << rr
}
}
rescue DecodeError => e
e.partial_message = o
raise e
end
return o
end