*/
#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)";
+static const char rcsid[] _U_ =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.90 2005-04-20 20:59:30 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
blabel_print(const u_char *cp)
{
int bitlen, slen, b;
- int truncated = 0;
const u_char *bitp, *lim;
char tc;
if ((bitlen = *cp) == 0)
bitlen = 256;
slen = (bitlen + 3) / 4;
- if ((lim = cp + 1 + slen) > snapend) {
- truncated = 1;
- lim = snapend;
- }
+ lim = cp + 1 + slen;
/* print the bit string as a hex string */
printf("\\[x");
- for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++)
+ for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++) {
+ TCHECK(*bitp);
printf("%02x", *bitp);
- if (bitp == lim)
- printf("...");
- else if (b > 4) {
+ }
+ if (b > 4) {
+ TCHECK(*bitp);
tc = *bitp++;
printf("%02x", tc & (0xff << (8 - b)));
} else if (b > 0) {
+ TCHECK(*bitp);
tc = *bitp++;
printf("%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b)));
}
printf("/%d]", bitlen);
-
- return(truncated ? NULL : lim);
+ return lim;
+trunc:
+ printf(".../%d]", bitlen);
+ return NULL;
}
static int
i = *cp;
if ((i & INDIR_MASK) == EDNS0_MASK) {
int bitlen, elt;
-
- if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL)
+ if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) {
+ printf("<ELT %d>", elt);
return(-1);
+ }
if (!TTEST2(*(cp + 1), 1))
return(-1);
if ((bitlen = *(cp + 1)) == 0)
/* 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;
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);
/* 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;
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 */
}
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;
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)
}
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;
}
}
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;
}
}
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;
}
}
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;
}
/* 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;
}
}
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;
}
}
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;
}
}