|
From: Periya.Data <per...@gm...> - 2011-09-01 22:36:37
|
Right. I did a print of dns_hdr.toString(). All the 4 sections are 0. Hence,
getQuestion, as you pointed out, returns null.
byte[] dns_msg_buf= new byte[2048];
bb.get(dns_msg_buf, 71, caplen);
Message dns_msg = new Message(dns_msg_buf);
System.out.println("Message size: " + dns_msg.numBytes());
Header dns_hdr = dns_msg.getHeader();
System.out.println("DNS Header: " + dns_hdr.toString());
DNS Header: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 0
;; flags: ; qd: 0 an: 0 au: 0 ad: 0
On Thu, Sep 1, 2011 at 3:26 PM, Brian Wellington <bwe...@xb...> wrote:
>
> On Sep 1, 2011, at 3:23 PM, Periya.Data wrote:
>
> Also, I get a null pointer exception error when I try to getName.
>
> // DNS Questions
> Name qname;
> int qtype;
> int qclass;
>
> Record question = dns_msg.getQuestion();
> qname = question.getName(); ===> error at this line.
>
> I am not what that means. A valid record is not found? Is there a nice way
> to check if a valid record has been returned? Maybe I am screwing up with
> the starting of a valid DNS message from the bytebuffer.
>
>
> As I said before, there's a problem with your data. If you're parsing a
> message, and the DNS header indicates that there are 0 records in all of the
> sections, the message parser won't try to parse any records, so
> Message.getQuestion() would return null.
>
> Brian
>
|