# File lib/Dnsruby/message.rb, line 587
    def Message.decode(m)
      o = Message.new()
      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 # needed for TSIG verification
          end
          o.additional << rr
        }
      }
      return o
    end