Question about source code.

R.Z. Pan rzpan at sitechasia.com
Fri Sep 29 01:01:42 UTC 2000


----- Original Message -----
From: <Mark.Andrews at nominum.com>
To: R.Z. Pan <rzpan at sitechasia.com>
Cc: Bind Mailing List <bind-users at isc.org>
Sent: Thursday, September 28, 2000 8:06 PM
Subject: Re: Question about source code.


>
> > Hi,please check these code below:(I've added some comments with red
color.)
> >
> > u_char *
> > ns_find_tsig(u_char *msg, u_char *eom) {                   /*msg is the
point
> > er of a DNS
> >            datagram,eom is msg§˜; */
> >  HEADER *hp = (HEADER *)msg;
> >  int n, type;
> >  u_char *cp = msg, *start;
> >
> >  if (msg == NULL || eom == NULL || msg > eom)
> >   return (NULL);
> >
> >  if (cp  HFIXEDSZ >= eom)
> >   return (NULL);
> >
> >  if (hp->arcount == 0)
> >   return (NULL);
> >
> >  cp = HFIXEDSZ;          /* HFIXEDSZ is 12,so,cp pointed to the question
zon
> > e*/
> >
> >  n = ns_skiprr(cp, eom, ns_s_qd, ntohs(hp->qdcount));/*I've looked up
this fu
> > nc,it means skip
> >             the question zone.Of course,a
> >                                      question zone include a request
> >                                                           name,a request
type
> >  and a request type. */
> >  if (n < 0)
> >   return (NULL);
> >  cp = n;                <------ Now,the cp pointed to the tail of
question z
> > one.
> >
> >  n = ns_skiprr(cp, eom, ns_s_an, ntohs(hp->ancount));
> >  if (n < 0)
> >   return (NULL);
> >  cp = n;
> >
> >  n = ns_skiprr(cp, eom, ns_s_ns, ntohs(hp->nscount));
> >  if (n < 0)
> >   return (NULL);
> >  cp = n;
> >
> >  n = ns_skiprr(cp, eom, ns_s_ar, ntohs(hp->arcount) - 1);
> >  if (n < 0)
> >   return (NULL);
> >  cp = n;
>
> This is the start of last RR.
> We have only skipped "hp->arcount - 1" records so far in the
> additional section, so there is one to go.

Yes!I missed the "-1" here.

>
> >
> >  start = cp;
> >  n = dn_skipname(cp, eom);     <<---- Skip a domain name again.This is
my que
> > stion.cp is pointed
> >                                 the tail of the datagram,Why we need to
skip
> > domain again?
>
> Because this is the owner name of what may be the TSIG record.

Great appreciation to  you!






More information about the bind-users mailing list