summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorguy <guy>2003-11-05 06:02:58 +0000
committerguy <guy>2003-11-05 06:02:58 +0000
commitf4d64fe38b9b7213a486eac4a18c3c434e1cccc8 (patch)
treeb9ffe2374cdf60558f40f448c21bea950d9f98f4
parent8f34a01034446e63b7ceec8267f6a1e04b167cbf (diff)
downloadtcpdump-f4d64fe38b9b7213a486eac4a18c3c434e1cccc8.tar.gz
In mDNS, report IN-class records with the "cache flush" bit set as such,
rather than as "Class 32769".
-rw-r--r--interface.h4
-rw-r--r--nameser.h3
-rw-r--r--print-domain.c47
-rw-r--r--print-tcp.c4
-rw-r--r--print-udp.c8
5 files changed, 37 insertions, 29 deletions
diff --git a/interface.h b/interface.h
index 744b89dd..2c282126 100644
--- a/interface.h
+++ b/interface.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.216 2003-10-27 10:13:45 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.217 2003-11-05 06:02:58 guy Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@@ -249,7 +249,7 @@ extern u_int ltalk_if_print(const struct pcap_pkthdr *, const u_char *);
extern void msdp_print(const unsigned char *, u_int);
extern void nfsreply_print(const u_char *, u_int, const u_char *);
extern void nfsreq_print(const u_char *, u_int, const u_char *);
-extern void ns_print(const u_char *, u_int);
+extern void ns_print(const u_char *, u_int, int);
extern void ntp_print(const u_char *, u_int);
extern u_int null_if_print(const struct pcap_pkthdr *, const u_char *);
extern void ospf_print(const u_char *, u_int, const u_char *);
diff --git a/nameser.h b/nameser.h
index a1d504a8..7a9e6113 100644
--- a/nameser.h
+++ b/nameser.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.13 2002-12-11 07:13:55 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.14 2003-11-05 06:02:59 guy Exp $ (LBL) */
/*
* Copyright (c) 1983, 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -190,6 +190,7 @@
#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
/* Query class values which do not appear in resource records */
#define C_ANY 255 /* wildcard match */
+#define C_CACHE_FLUSH 0x8000 /* mDNS cache flush flag */
/*
* Status return codes for T_UNSPEC conversion routines
diff --git a/print-domain.c b/print-domain.c
index 6173521d..788be7f1 100644
--- a/print-domain.c
+++ b/print-domain.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.85 2003-09-25 22:30:22 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.86 2003-11-05 06:03:00 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;
@@ -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;
}
}
@@ -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;
}
}
diff --git a/print-tcp.c b/print-tcp.c
index 2b7c610c..c69dbcd0 100644
--- a/print-tcp.c
+++ b/print-tcp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.106 2003-10-28 03:16:36 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.107 2003-11-05 06:03:01 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -622,7 +622,7 @@ tcp_print(register const u_char *bp, register u_int length,
* TCP DNS query has 2byte length at the head.
* XXX packet could be unaligned, it can go strange
*/
- ns_print(bp + 2, length - 2);
+ ns_print(bp + 2, length - 2, 0);
} else if (sport == MSDP_PORT || dport == MSDP_PORT) {
msdp_print(bp, length);
}
diff --git a/print-udp.c b/print-udp.c
index 2bf77d4b..2888a6d7 100644
--- a/print-udp.c
+++ b/print-udp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.123 2003-10-27 22:44:37 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.124 2003-11-05 06:03:01 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -599,8 +599,10 @@ udp_print(register const u_char *bp, u_int length,
if (!qflag) {
#define ISPORT(p) (dport == (p) || sport == (p))
- if (ISPORT(NAMESERVER_PORT) || ISPORT(MULTICASTDNS_PORT))
- ns_print((const u_char *)(up + 1), length);
+ if (ISPORT(NAMESERVER_PORT))
+ ns_print((const u_char *)(up + 1), length, 0);
+ else if (ISPORT(MULTICASTDNS_PORT))
+ ns_print((const u_char *)(up + 1), length, 1);
else if (ISPORT(TIMED_PORT))
timed_print((const u_char *)(up + 1));
else if (ISPORT(TFTP_PORT))