* Copyright (c) 1985 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)skip.c 5.5 (Berkeley) 6/18/88";
*******************************************************************************
* Routines to skip over portions of a query buffer.
* Note: this file has been submitted for inclusion in
* BIND resolver library. When this has been done, this file
* is no longer necessary (assuming there haven't been any
* Adapted from 4.3BSD BIND res_debug.c
*******************************************************************************
#include <arpa/nameser.h>
*******************************************************************************
* Skip the contents of a query.
* Interpretation of numFieldsToSkip argument:
* res_skip returns pointer to:
* 1 -> start of question records.
* 2 -> start of authoritative answer records.
* 3 -> start of additional records.
* 4 -> first byte after end of additional records.
* (address) - success operation.
* NULL - a resource record had an incorrect format.
*******************************************************************************
res_skip(msg
, numFieldsToSkip
, eom
)
* Skip the header fields.
cp
= msg
+ sizeof(HEADER
);
if (n
= ntohs(hp
->qdcount
) ) {
tmp
= dn_skipname(cp
, eom
);
if (tmp
== -1) return(NULL
);
cp
+= sizeof(u_short
); /* type */
cp
+= sizeof(u_short
); /* class */
if (--numFieldsToSkip
<= 0) return(cp
);
* skip authoritative answer records
if (n
= ntohs(hp
->ancount
)) {
cp
= res_skip_rr(cp
, eom
);
if (cp
== NULL
) return(NULL
);
if (--numFieldsToSkip
== 0) return(cp
);
* skip name server records
if (n
= ntohs(hp
->nscount
)) {
cp
= res_skip_rr(cp
, eom
);
if (cp
== NULL
) return(NULL
);
if (--numFieldsToSkip
== 0) return(cp
);
* skip additional records
if (n
= ntohs(hp
->arcount
)) {
cp
= res_skip_rr(cp
, eom
);
if (cp
== NULL
) return(NULL
);
*******************************************************************************
* Skip over resource record fields.
* (address) - success operation.
* NULL - a resource record had an incorrect format.
*******************************************************************************
if ((tmp
= dn_skipname(cp
, eom
)) == -1)
return (NULL
); /* compression error */
cp
+= sizeof(u_short
); /* type */
cp
+= sizeof(u_short
); /* class */
cp
+= sizeof(u_long
); /* ttl */
cp
+= sizeof(u_short
); /* dlen */