Deleted Added
full compact
print-domain.c (36899) print-domain.c (39300)
1/*
1/*
2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 */
21
22#ifndef lint
23static const char rcsid[] =
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 */
21
22#ifndef lint
23static const char rcsid[] =
24 "@(#) $Header: print-domain.c,v 1.37 96/12/10 23:21:06 leres Exp $ (LBL)";
24 "@(#) $Header: print-domain.c,v 1.39 97/06/13 12:56:28 leres Exp $ (LBL)";
25#endif
26
27#include <sys/param.h>
28#include <sys/time.h>
29#include <sys/socket.h>
30
31#if __STDC__
32struct mbuf;
33struct rtentry;
34#endif
35#include <net/if.h>
36
37#include <netinet/in.h>
38#include <net/ethernet.h>
39#include <netinet/in_systm.h>
40#include <netinet/ip.h>
41#include <netinet/ip_var.h>
42#include <netinet/udp.h>
43#include <netinet/udp_var.h>
44#include <netinet/tcp.h>
45#include <netinet/tcpip.h>
46
25#endif
26
27#include <sys/param.h>
28#include <sys/time.h>
29#include <sys/socket.h>
30
31#if __STDC__
32struct mbuf;
33struct rtentry;
34#endif
35#include <net/if.h>
36
37#include <netinet/in.h>
38#include <net/ethernet.h>
39#include <netinet/in_systm.h>
40#include <netinet/ip.h>
41#include <netinet/ip_var.h>
42#include <netinet/udp.h>
43#include <netinet/udp_var.h>
44#include <netinet/tcp.h>
45#include <netinet/tcpip.h>
46
47#ifdef NOERROR
47#undef NOERROR /* Solaris sucks */
48#undef NOERROR /* Solaris sucks */
49#endif
50#ifdef NOERROR
48#undef T_UNSPEC /* SINIX does too */
51#undef T_UNSPEC /* SINIX does too */
52#endif
49#include <arpa/nameser.h>
50
51#include <stdio.h>
52
53#include "interface.h"
54#include "addrtoname.h"
55#include "extract.h" /* must come after interface.h */
56
57/* Compatibility */
58#ifndef T_TXT
59#define T_TXT 16 /* text strings */
60#endif
61#ifndef T_RP
62#define T_RP 17 /* responsible person */
63#endif
64#ifndef T_AFSDB
65#define T_AFSDB 18 /* AFS cell database */
66#endif
67#ifndef T_X25
68#define T_X25 19 /* X_25 calling address */
69#endif
70#ifndef T_ISDN
71#define T_ISDN 20 /* ISDN calling address */
72#endif
73#ifndef T_RT
74#define T_RT 21 /* router */
75#endif
76#ifndef T_NSAP
77#define T_NSAP 22 /* NSAP address */
78#endif
79#ifndef T_NSAP_PTR
80#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
81#endif
82#ifndef T_SIG
83#define T_SIG 24 /* security signature */
84#endif
85#ifndef T_KEY
86#define T_KEY 25 /* security key */
87#endif
88#ifndef T_PX
89#define T_PX 26 /* X.400 mail mapping */
90#endif
91#ifndef T_GPOS
92#define T_GPOS 27 /* geographical position (withdrawn) */
93#endif
94#ifndef T_AAAA
95#define T_AAAA 28 /* IP6 Address */
96#endif
97#ifndef T_LOC
98#define T_LOC 29 /* Location Information */
99#endif
100
101#ifndef T_UNSPEC
102#define T_UNSPEC 103 /* Unspecified format (binary data) */
103#endif
104#ifndef T_UNSPECA
105#define T_UNSPECA 104 /* "unspecified ascii". Ugly MIT hack */
106#endif
107
108#ifndef C_CHAOS
109#define C_CHAOS 3 /* for chaos net (MIT) */
110#endif
111#ifndef C_HS
112#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
113#endif
114
115static char *ns_ops[] = {
116 "", " inv_q", " stat", " op3", " notify", " op5", " op6", " op7",
117 " op8", " updataA", " updateD", " updateDA",
118 " updateM", " updateMA", " zoneInit", " zoneRef",
119};
120
121static char *ns_resp[] = {
122 "", " FormErr", " ServFail", " NXDomain",
123 " NotImp", " Refused", " Resp6", " Resp7",
124 " Resp8", " Resp9", " Resp10", " Resp11",
125 " Resp12", " Resp13", " Resp14", " NoChange",
126};
127
128/* skip over a domain name */
129static const u_char *
130ns_nskip(register const u_char *cp, register const u_char *bp)
131{
132 register u_char i;
133
134 if (((i = *cp++) & INDIR_MASK) == INDIR_MASK)
135 return (cp + 1);
136 while (i && cp < snapend) {
137 cp += i;
138 i = *cp++;
139 }
140 return (cp);
141}
142
143/* print a <domain-name> */
144static const u_char *
145ns_nprint(register const u_char *cp, register const u_char *bp)
146{
147 register u_int i;
148 register const u_char *rp;
149 register int compress;
150
151 i = *cp++;
152 rp = cp + i;
153 if ((i & INDIR_MASK) == INDIR_MASK) {
154 rp = cp + 1;
155 compress = 1;
156 } else
157 compress = 0;
158 if (i != 0)
159 while (i && cp < snapend) {
160 if ((i & INDIR_MASK) == INDIR_MASK) {
161 cp = bp + (((i << 8) | *cp) & 0x3fff);
162 i = *cp++;
163 continue;
164 }
165 if (fn_printn(cp, i, snapend))
166 break;
167 cp += i;
168 putchar('.');
169 i = *cp++;
170 if (!compress)
171 rp += i + 1;
172 }
173 else
174 putchar('.');
175 return (rp);
176}
177
178/* print a <character-string> */
179static const u_char *
180ns_cprint(register const u_char *cp, register const u_char *bp)
181{
182 register u_int i;
183
184 i = *cp++;
185 (void)fn_printn(cp, i, snapend);
186 return (cp + i);
187}
188
189static struct tok type2str[] = {
190 { T_A, "A" },
191 { T_NS, "NS" },
192 { T_MD, "MD" },
193 { T_MF, "MF" },
194 { T_CNAME, "CNAME" },
195 { T_SOA, "SOA" },
196 { T_MB, "MB" },
197 { T_MG, "MG" },
198 { T_MR, "MR" },
199 { T_NULL, "NULL" },
200 { T_WKS, "WKS" },
201 { T_PTR, "PTR" },
202 { T_HINFO, "HINFO" },
203 { T_MINFO, "MINFO" },
204 { T_MX, "MX" },
205 { T_TXT, "TXT" },
206 { T_RP, "RP" },
207 { T_AFSDB, "AFSDB" },
208 { T_X25, "X25" },
209 { T_ISDN, "ISDN" },
210 { T_RT, "RT" },
211 { T_NSAP, "NSAP" },
212 { T_NSAP_PTR, "NSAP_PTR" },
213 { T_SIG, "SIG" },
214 { T_KEY, "KEY" },
215 { T_PX, "PX" },
216 { T_GPOS, "GPOS" },
217 { T_AAAA, "AAAA" },
218 { T_LOC , "LOC " },
53#include <arpa/nameser.h>
54
55#include <stdio.h>
56
57#include "interface.h"
58#include "addrtoname.h"
59#include "extract.h" /* must come after interface.h */
60
61/* Compatibility */
62#ifndef T_TXT
63#define T_TXT 16 /* text strings */
64#endif
65#ifndef T_RP
66#define T_RP 17 /* responsible person */
67#endif
68#ifndef T_AFSDB
69#define T_AFSDB 18 /* AFS cell database */
70#endif
71#ifndef T_X25
72#define T_X25 19 /* X_25 calling address */
73#endif
74#ifndef T_ISDN
75#define T_ISDN 20 /* ISDN calling address */
76#endif
77#ifndef T_RT
78#define T_RT 21 /* router */
79#endif
80#ifndef T_NSAP
81#define T_NSAP 22 /* NSAP address */
82#endif
83#ifndef T_NSAP_PTR
84#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
85#endif
86#ifndef T_SIG
87#define T_SIG 24 /* security signature */
88#endif
89#ifndef T_KEY
90#define T_KEY 25 /* security key */
91#endif
92#ifndef T_PX
93#define T_PX 26 /* X.400 mail mapping */
94#endif
95#ifndef T_GPOS
96#define T_GPOS 27 /* geographical position (withdrawn) */
97#endif
98#ifndef T_AAAA
99#define T_AAAA 28 /* IP6 Address */
100#endif
101#ifndef T_LOC
102#define T_LOC 29 /* Location Information */
103#endif
104
105#ifndef T_UNSPEC
106#define T_UNSPEC 103 /* Unspecified format (binary data) */
107#endif
108#ifndef T_UNSPECA
109#define T_UNSPECA 104 /* "unspecified ascii". Ugly MIT hack */
110#endif
111
112#ifndef C_CHAOS
113#define C_CHAOS 3 /* for chaos net (MIT) */
114#endif
115#ifndef C_HS
116#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
117#endif
118
119static char *ns_ops[] = {
120 "", " inv_q", " stat", " op3", " notify", " op5", " op6", " op7",
121 " op8", " updataA", " updateD", " updateDA",
122 " updateM", " updateMA", " zoneInit", " zoneRef",
123};
124
125static char *ns_resp[] = {
126 "", " FormErr", " ServFail", " NXDomain",
127 " NotImp", " Refused", " Resp6", " Resp7",
128 " Resp8", " Resp9", " Resp10", " Resp11",
129 " Resp12", " Resp13", " Resp14", " NoChange",
130};
131
132/* skip over a domain name */
133static const u_char *
134ns_nskip(register const u_char *cp, register const u_char *bp)
135{
136 register u_char i;
137
138 if (((i = *cp++) & INDIR_MASK) == INDIR_MASK)
139 return (cp + 1);
140 while (i && cp < snapend) {
141 cp += i;
142 i = *cp++;
143 }
144 return (cp);
145}
146
147/* print a <domain-name> */
148static const u_char *
149ns_nprint(register const u_char *cp, register const u_char *bp)
150{
151 register u_int i;
152 register const u_char *rp;
153 register int compress;
154
155 i = *cp++;
156 rp = cp + i;
157 if ((i & INDIR_MASK) == INDIR_MASK) {
158 rp = cp + 1;
159 compress = 1;
160 } else
161 compress = 0;
162 if (i != 0)
163 while (i && cp < snapend) {
164 if ((i & INDIR_MASK) == INDIR_MASK) {
165 cp = bp + (((i << 8) | *cp) & 0x3fff);
166 i = *cp++;
167 continue;
168 }
169 if (fn_printn(cp, i, snapend))
170 break;
171 cp += i;
172 putchar('.');
173 i = *cp++;
174 if (!compress)
175 rp += i + 1;
176 }
177 else
178 putchar('.');
179 return (rp);
180}
181
182/* print a <character-string> */
183static const u_char *
184ns_cprint(register const u_char *cp, register const u_char *bp)
185{
186 register u_int i;
187
188 i = *cp++;
189 (void)fn_printn(cp, i, snapend);
190 return (cp + i);
191}
192
193static struct tok type2str[] = {
194 { T_A, "A" },
195 { T_NS, "NS" },
196 { T_MD, "MD" },
197 { T_MF, "MF" },
198 { T_CNAME, "CNAME" },
199 { T_SOA, "SOA" },
200 { T_MB, "MB" },
201 { T_MG, "MG" },
202 { T_MR, "MR" },
203 { T_NULL, "NULL" },
204 { T_WKS, "WKS" },
205 { T_PTR, "PTR" },
206 { T_HINFO, "HINFO" },
207 { T_MINFO, "MINFO" },
208 { T_MX, "MX" },
209 { T_TXT, "TXT" },
210 { T_RP, "RP" },
211 { T_AFSDB, "AFSDB" },
212 { T_X25, "X25" },
213 { T_ISDN, "ISDN" },
214 { T_RT, "RT" },
215 { T_NSAP, "NSAP" },
216 { T_NSAP_PTR, "NSAP_PTR" },
217 { T_SIG, "SIG" },
218 { T_KEY, "KEY" },
219 { T_PX, "PX" },
220 { T_GPOS, "GPOS" },
221 { T_AAAA, "AAAA" },
222 { T_LOC , "LOC " },
223#ifndef T_UINFO
224#define T_UINFO 100
225#endif
226 { T_UINFO, "UINFO" },
227#ifndef T_UID
228#define T_UID 101
229#endif
230 { T_UID, "UID" },
231#ifndef T_GID
232#define T_GID 102
233#endif
234 { T_GID, "GID" },
219 { T_UNSPEC, "UNSPEC" },
220 { T_UNSPECA, "UNSPECA" },
221 { T_AXFR, "AXFR" },
222 { T_MAILB, "MAILB" },
223 { T_MAILA, "MAILA" },
224 { T_ANY, "ANY" },
225 { 0, NULL }
226};
227
228static struct tok class2str[] = {
229 { C_IN, "IN" }, /* Not used */
230 { C_CHAOS, "CHAOS)" },
231 { C_HS, "HS" },
232 { C_ANY, "ANY" },
233 { 0, NULL }
234};
235
236/* print a query */
237static void
238ns_qprint(register const u_char *cp, register const u_char *bp)
239{
240 register const u_char *np = cp;
241 register u_int i;
242
243 cp = ns_nskip(cp, bp);
244
245 if (cp + 4 > snapend)
246 return;
247
248 /* print the qtype and qclass (if it's not IN) */
249 i = *cp++ << 8;
250 i |= *cp++;
251 printf(" %s", tok2str(type2str, "Type%d", i));
252 i = *cp++ << 8;
253 i |= *cp++;
254 if (i != C_IN)
255 printf(" %s", tok2str(class2str, "(Class %d)", i));
256
257 fputs("? ", stdout);
258 ns_nprint(np, bp);
259}
260
261/* print a reply */
262static const u_char *
263ns_rprint(register const u_char *cp, register const u_char *bp)
264{
265 register u_int i;
266 register u_short typ, len;
267 register const u_char *rp;
268
269 if (vflag) {
270 putchar(' ');
271 cp = ns_nprint(cp, bp);
272 } else
273 cp = ns_nskip(cp, bp);
274
275 if (cp + 10 > snapend)
276 return (snapend);
277
278 /* print the type/qtype and class (if it's not IN) */
279 typ = *cp++ << 8;
280 typ |= *cp++;
281 i = *cp++ << 8;
282 i |= *cp++;
283 if (i != C_IN)
284 printf(" %s", tok2str(class2str, "(Class %d)", i));
285
286 /* ignore ttl */
287 cp += 4;
288
289 len = *cp++ << 8;
290 len |= *cp++;
291
292 rp = cp + len;
293
294 printf(" %s", tok2str(type2str, "Type%d", typ));
295 switch (typ) {
296
297 case T_A:
298 printf(" %s", ipaddr_string(cp));
299 break;
300
301 case T_NS:
302 case T_CNAME:
303 case T_PTR:
304 putchar(' ');
305 (void)ns_nprint(cp, bp);
306 break;
307
308 case T_MX:
309 putchar(' ');
310 (void)ns_nprint(cp + 2, bp);
311 printf(" %d", EXTRACT_16BITS(cp));
312 break;
313
314 case T_TXT:
315 putchar(' ');
316 (void)ns_cprint(cp, bp);
317 break;
318
319 case T_UNSPECA: /* One long string */
320 printf(" %.*s", len, cp);
321 break;
322 }
323 return (rp); /* XXX This isn't always right */
324}
325
326void
327ns_print(register const u_char *bp, u_int length)
328{
329 register const HEADER *np;
330 register int qdcount, ancount, nscount, arcount;
331 register const u_char *cp;
332
333 np = (const HEADER *)bp;
334 /* get the byte-order right */
335 qdcount = ntohs(np->qdcount);
336 ancount = ntohs(np->ancount);
337 nscount = ntohs(np->nscount);
338 arcount = ntohs(np->arcount);
339
340 if (np->qr) {
341 /* this is a response */
342 printf(" %d%s%s%s%s%s",
343 ntohs(np->id),
344 ns_ops[np->opcode],
345 ns_resp[np->rcode],
346 np->aa? "*" : "",
347 np->ra? "" : "-",
348 np->tc? "|" : "");
349 if (qdcount != 1)
350 printf(" [%dq]", qdcount);
351 /* Print QUESTION section on -vv */
352 if (vflag > 1) {
353 fputs(" q: ", stdout);
354 cp = ns_nprint((const u_char *)(np + 1), bp);
355 } else
356 cp = ns_nskip((const u_char *)(np + 1), bp);
357 printf(" %d/%d/%d", ancount, nscount, arcount);
358 if (ancount--) {
359 cp = ns_rprint(cp + 4, bp);
360 while (ancount-- && cp < snapend) {
361 putchar(',');
362 cp = ns_rprint(cp, bp);
363 }
364 }
365 }
366 else {
367 /* this is a request */
368 printf(" %d%s%s",
369 ntohs(np->id),
370 ns_ops[np->opcode],
371 np->rd? "+" : "");
372
373 /* any weirdness? */
374 if (*(((u_short *)np)+1) & htons(0x6ff))
375 printf(" [b2&3=0x%x]", ntohs(*(((u_short *)np)+1)));
376
377 if (np->opcode == IQUERY) {
378 if (qdcount)
379 printf(" [%dq]", qdcount);
380 if (ancount != 1)
381 printf(" [%da]", ancount);
382 }
383 else {
384 if (ancount)
385 printf(" [%da]", ancount);
386 if (qdcount != 1)
387 printf(" [%dq]", qdcount);
388 }
389 if (nscount)
390 printf(" [%dn]", nscount);
391 if (arcount)
392 printf(" [%dau]", arcount);
393
394 ns_qprint((const u_char *)(np + 1), (const u_char *)np);
395 }
396 printf(" (%d)", length);
397}
235 { T_UNSPEC, "UNSPEC" },
236 { T_UNSPECA, "UNSPECA" },
237 { T_AXFR, "AXFR" },
238 { T_MAILB, "MAILB" },
239 { T_MAILA, "MAILA" },
240 { T_ANY, "ANY" },
241 { 0, NULL }
242};
243
244static struct tok class2str[] = {
245 { C_IN, "IN" }, /* Not used */
246 { C_CHAOS, "CHAOS)" },
247 { C_HS, "HS" },
248 { C_ANY, "ANY" },
249 { 0, NULL }
250};
251
252/* print a query */
253static void
254ns_qprint(register const u_char *cp, register const u_char *bp)
255{
256 register const u_char *np = cp;
257 register u_int i;
258
259 cp = ns_nskip(cp, bp);
260
261 if (cp + 4 > snapend)
262 return;
263
264 /* print the qtype and qclass (if it's not IN) */
265 i = *cp++ << 8;
266 i |= *cp++;
267 printf(" %s", tok2str(type2str, "Type%d", i));
268 i = *cp++ << 8;
269 i |= *cp++;
270 if (i != C_IN)
271 printf(" %s", tok2str(class2str, "(Class %d)", i));
272
273 fputs("? ", stdout);
274 ns_nprint(np, bp);
275}
276
277/* print a reply */
278static const u_char *
279ns_rprint(register const u_char *cp, register const u_char *bp)
280{
281 register u_int i;
282 register u_short typ, len;
283 register const u_char *rp;
284
285 if (vflag) {
286 putchar(' ');
287 cp = ns_nprint(cp, bp);
288 } else
289 cp = ns_nskip(cp, bp);
290
291 if (cp + 10 > snapend)
292 return (snapend);
293
294 /* print the type/qtype and class (if it's not IN) */
295 typ = *cp++ << 8;
296 typ |= *cp++;
297 i = *cp++ << 8;
298 i |= *cp++;
299 if (i != C_IN)
300 printf(" %s", tok2str(class2str, "(Class %d)", i));
301
302 /* ignore ttl */
303 cp += 4;
304
305 len = *cp++ << 8;
306 len |= *cp++;
307
308 rp = cp + len;
309
310 printf(" %s", tok2str(type2str, "Type%d", typ));
311 switch (typ) {
312
313 case T_A:
314 printf(" %s", ipaddr_string(cp));
315 break;
316
317 case T_NS:
318 case T_CNAME:
319 case T_PTR:
320 putchar(' ');
321 (void)ns_nprint(cp, bp);
322 break;
323
324 case T_MX:
325 putchar(' ');
326 (void)ns_nprint(cp + 2, bp);
327 printf(" %d", EXTRACT_16BITS(cp));
328 break;
329
330 case T_TXT:
331 putchar(' ');
332 (void)ns_cprint(cp, bp);
333 break;
334
335 case T_UNSPECA: /* One long string */
336 printf(" %.*s", len, cp);
337 break;
338 }
339 return (rp); /* XXX This isn't always right */
340}
341
342void
343ns_print(register const u_char *bp, u_int length)
344{
345 register const HEADER *np;
346 register int qdcount, ancount, nscount, arcount;
347 register const u_char *cp;
348
349 np = (const HEADER *)bp;
350 /* get the byte-order right */
351 qdcount = ntohs(np->qdcount);
352 ancount = ntohs(np->ancount);
353 nscount = ntohs(np->nscount);
354 arcount = ntohs(np->arcount);
355
356 if (np->qr) {
357 /* this is a response */
358 printf(" %d%s%s%s%s%s",
359 ntohs(np->id),
360 ns_ops[np->opcode],
361 ns_resp[np->rcode],
362 np->aa? "*" : "",
363 np->ra? "" : "-",
364 np->tc? "|" : "");
365 if (qdcount != 1)
366 printf(" [%dq]", qdcount);
367 /* Print QUESTION section on -vv */
368 if (vflag > 1) {
369 fputs(" q: ", stdout);
370 cp = ns_nprint((const u_char *)(np + 1), bp);
371 } else
372 cp = ns_nskip((const u_char *)(np + 1), bp);
373 printf(" %d/%d/%d", ancount, nscount, arcount);
374 if (ancount--) {
375 cp = ns_rprint(cp + 4, bp);
376 while (ancount-- && cp < snapend) {
377 putchar(',');
378 cp = ns_rprint(cp, bp);
379 }
380 }
381 }
382 else {
383 /* this is a request */
384 printf(" %d%s%s",
385 ntohs(np->id),
386 ns_ops[np->opcode],
387 np->rd? "+" : "");
388
389 /* any weirdness? */
390 if (*(((u_short *)np)+1) & htons(0x6ff))
391 printf(" [b2&3=0x%x]", ntohs(*(((u_short *)np)+1)));
392
393 if (np->opcode == IQUERY) {
394 if (qdcount)
395 printf(" [%dq]", qdcount);
396 if (ancount != 1)
397 printf(" [%da]", ancount);
398 }
399 else {
400 if (ancount)
401 printf(" [%da]", ancount);
402 if (qdcount != 1)
403 printf(" [%dq]", qdcount);
404 }
405 if (nscount)
406 printf(" [%dn]", nscount);
407 if (arcount)
408 printf(" [%dau]", arcount);
409
410 ns_qprint((const u_char *)(np + 1), (const u_char *)np);
411 }
412 printf(" (%d)", length);
413}