X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/39727479314a287fae9a03c63d8a98f9725d6051..fe0fcd92e3ae841f7ccf84b250df1ec4afdaecbc:/print-domain.c diff --git a/print-domain.c b/print-domain.c index 0ffa872d..5a67d214 100644 --- a/print-domain.c +++ b/print-domain.c @@ -20,8 +20,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.84 2003-04-04 03:49:25 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.88 2003-11-16 09:36:18 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -305,7 +305,7 @@ struct tok ns_class2str[] = { /* print a query */ static const u_char * -ns_qprint(register const u_char *cp, register const u_char *bp) +ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns) { register const u_char *np = cp; register u_int i; @@ -321,7 +321,9 @@ ns_qprint(register const u_char *cp, register const u_char *bp) printf(" %s", tok2str(ns_type2str, "Type%d", i)); i = EXTRACT_16BITS(cp); cp += 2; - if (i != C_IN) + if (is_mdns && i == (C_IN|C_CACHE_FLUSH)) + printf(" (Cache flush)"); + else if (i != C_IN) printf(" %s", tok2str(ns_class2str, "(Class %d)", i)); fputs("? ", stdout); @@ -331,7 +333,7 @@ ns_qprint(register const u_char *cp, register const u_char *bp) /* print a reply */ static const u_char * -ns_rprint(register const u_char *cp, register const u_char *bp) +ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns) { register u_int class; register u_short typ, len; @@ -352,7 +354,9 @@ ns_rprint(register const u_char *cp, register const u_char *bp) cp += 2; class = EXTRACT_16BITS(cp); cp += 2; - if (class != C_IN && typ != T_OPT) + if (is_mdns && class == (C_IN|C_CACHE_FLUSH)) + printf(" (Cache flush)"); + else if (class != C_IN && typ != T_OPT) printf(" %s", tok2str(ns_class2str, "(Class %d)", class)); /* ignore ttl */ @@ -518,7 +522,7 @@ ns_rprint(register const u_char *cp, register const u_char *bp) } void -ns_print(register const u_char *bp, u_int length) +ns_print(register const u_char *bp, u_int length, int is_mdns) { register const HEADER *np; register int qdcount, ancount, nscount, arcount; @@ -542,7 +546,7 @@ ns_print(register const u_char *bp, u_int length) DNS_AA(np)? "*" : "", DNS_RA(np)? "" : "-", DNS_TC(np)? "|" : "", - DNS_CD(np)? "%" : ""); + DNS_AD(np)? "$" : ""); if (qdcount != 1) printf(" [%dq]", qdcount); @@ -553,7 +557,7 @@ ns_print(register const u_char *bp, u_int length) putchar(','); if (vflag > 1) { fputs(" q:", stdout); - if ((cp = ns_qprint(cp, bp)) == NULL) + if ((cp = ns_qprint(cp, bp, is_mdns)) == NULL) goto trunc; } else { if ((cp = ns_nskip(cp)) == NULL) @@ -563,11 +567,11 @@ ns_print(register const u_char *bp, u_int length) } printf(" %d/%d/%d", ancount, nscount, arcount); if (ancount--) { - if ((cp = ns_rprint(cp, bp)) == NULL) + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; while (cp < snapend && ancount--) { putchar(','); - if ((cp = ns_rprint(cp, bp)) == NULL) + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; } } @@ -577,11 +581,11 @@ ns_print(register const u_char *bp, u_int length) if (vflag > 1) { if (cp < snapend && nscount--) { fputs(" ns:", stdout); - if ((cp = ns_rprint(cp, bp)) == NULL) + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; while (cp < snapend && nscount--) { putchar(','); - if ((cp = ns_rprint(cp, bp)) == NULL) + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; } } @@ -589,11 +593,11 @@ ns_print(register const u_char *bp, u_int length) goto trunc; if (cp < snapend && arcount--) { fputs(" ar:", stdout); - if ((cp = ns_rprint(cp, bp)) == NULL) + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; while (cp < snapend && arcount--) { putchar(','); - if ((cp = ns_rprint(cp, bp)) == NULL) + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; } } @@ -605,7 +609,7 @@ ns_print(register const u_char *bp, u_int length) /* this is a request */ printf(" %d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)], DNS_RD(np) ? "+" : "", - DNS_AD(np) ? "$" : ""); + DNS_CD(np) ? "%" : ""); /* any weirdness? */ b2 = EXTRACT_16BITS(((u_short *)np)+1); @@ -631,12 +635,13 @@ ns_print(register const u_char *bp, u_int length) cp = (const u_char *)(np + 1); if (qdcount--) { - cp = ns_qprint(cp, (const u_char *)np); + cp = ns_qprint(cp, (const u_char *)np, is_mdns); if (!cp) goto trunc; while (cp < snapend && qdcount--) { cp = ns_qprint((const u_char *)cp, - (const u_char *)np); + (const u_char *)np, + is_mdns); if (!cp) goto trunc; } @@ -647,11 +652,11 @@ ns_print(register const u_char *bp, u_int length) /* Print remaining sections on -vv */ if (vflag > 1) { if (ancount--) { - if ((cp = ns_rprint(cp, bp)) == NULL) + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; while (cp < snapend && ancount--) { putchar(','); - if ((cp = ns_rprint(cp, bp)) == NULL) + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; } } @@ -659,11 +664,11 @@ ns_print(register const u_char *bp, u_int length) goto trunc; if (cp < snapend && nscount--) { fputs(" ns:", stdout); - if ((cp = ns_rprint(cp, bp)) == NULL) + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; while (nscount-- && cp < snapend) { putchar(','); - if ((cp = ns_rprint(cp, bp)) == NULL) + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; } } @@ -671,11 +676,11 @@ ns_print(register const u_char *bp, u_int length) goto trunc; if (cp < snapend && arcount--) { fputs(" ar:", stdout); - if ((cp = ns_rprint(cp, bp)) == NULL) + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; while (cp < snapend && arcount--) { putchar(','); - if ((cp = ns_rprint(cp, bp)) == NULL) + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; } }