mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-27 12:03:44 +08:00
Insert references to type definition RFCs.
Use EXTRACT_16BITS to get type, class, length instead of manual byte extraction. Print multiple <character-string>s if present in TXT records. Don't print arbitrary junk from the packet when parsing an [illegal] 0-length TXT record.
This commit is contained in:
parent
b09ea5197b
commit
3972747931
118
print-domain.c
118
print-domain.c
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.83 2003-04-04 00:18:54 fenner Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.84 2003-04-04 03:49:25 fenner Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -240,56 +240,57 @@ ns_cprint(register const u_char *cp)
|
||||
return (cp + i);
|
||||
}
|
||||
|
||||
/* http://www.iana.org/assignments/dns-parameters */
|
||||
struct tok ns_type2str[] = {
|
||||
{ T_A, "A" },
|
||||
{ T_NS, "NS" },
|
||||
{ T_MD, "MD" },
|
||||
{ T_MF, "MF" },
|
||||
{ T_CNAME, "CNAME" },
|
||||
{ T_SOA, "SOA" },
|
||||
{ T_MB, "MB" },
|
||||
{ T_MG, "MG" },
|
||||
{ T_MR, "MR" },
|
||||
{ T_NULL, "NULL" },
|
||||
{ T_WKS, "WKS" },
|
||||
{ T_PTR, "PTR" },
|
||||
{ T_HINFO, "HINFO" },
|
||||
{ T_MINFO, "MINFO" },
|
||||
{ T_MX, "MX" },
|
||||
{ T_TXT, "TXT" },
|
||||
{ T_RP, "RP" },
|
||||
{ T_AFSDB, "AFSDB" },
|
||||
{ T_X25, "X25" },
|
||||
{ T_ISDN, "ISDN" },
|
||||
{ T_RT, "RT" },
|
||||
{ T_NSAP, "NSAP" },
|
||||
{ T_A, "A" }, /* RFC 1035 */
|
||||
{ T_NS, "NS" }, /* RFC 1035 */
|
||||
{ T_MD, "MD" }, /* RFC 1035 */
|
||||
{ T_MF, "MF" }, /* RFC 1035 */
|
||||
{ T_CNAME, "CNAME" }, /* RFC 1035 */
|
||||
{ T_SOA, "SOA" }, /* RFC 1035 */
|
||||
{ T_MB, "MB" }, /* RFC 1035 */
|
||||
{ T_MG, "MG" }, /* RFC 1035 */
|
||||
{ T_MR, "MR" }, /* RFC 1035 */
|
||||
{ T_NULL, "NULL" }, /* RFC 1035 */
|
||||
{ T_WKS, "WKS" }, /* RFC 1035 */
|
||||
{ T_PTR, "PTR" }, /* RFC 1035 */
|
||||
{ T_HINFO, "HINFO" }, /* RFC 1035 */
|
||||
{ T_MINFO, "MINFO" }, /* RFC 1035 */
|
||||
{ T_MX, "MX" }, /* RFC 1035 */
|
||||
{ T_TXT, "TXT" }, /* RFC 1035 */
|
||||
{ T_RP, "RP" }, /* RFC 1183 */
|
||||
{ T_AFSDB, "AFSDB" }, /* RFC 1183 */
|
||||
{ T_X25, "X25" }, /* RFC 1183 */
|
||||
{ T_ISDN, "ISDN" }, /* RFC 1183 */
|
||||
{ T_RT, "RT" }, /* RFC 1183 */
|
||||
{ T_NSAP, "NSAP" }, /* RFC 1706 */
|
||||
{ T_NSAP_PTR, "NSAP_PTR" },
|
||||
{ T_SIG, "SIG" },
|
||||
{ T_KEY, "KEY" },
|
||||
{ T_PX, "PX" },
|
||||
{ T_GPOS, "GPOS" },
|
||||
{ T_AAAA, "AAAA" },
|
||||
{ T_LOC, "LOC" },
|
||||
{ T_NXT, "NXT" },
|
||||
{ T_EID, "EID" },
|
||||
{ T_NIMLOC, "NIMLOC" },
|
||||
{ T_SRV, "SRV" },
|
||||
{ T_ATMA, "ATMA" },
|
||||
{ T_NAPTR, "NAPTR" },
|
||||
{ T_A6, "A6" },
|
||||
{ T_DNAME, "DNAME" },
|
||||
{ T_OPT, "OPT" },
|
||||
{ T_SIG, "SIG" }, /* RFC 2535 */
|
||||
{ T_KEY, "KEY" }, /* RFC 2535 */
|
||||
{ T_PX, "PX" }, /* RFC 2163 */
|
||||
{ T_GPOS, "GPOS" }, /* RFC 1712 */
|
||||
{ T_AAAA, "AAAA" }, /* RFC 1886 */
|
||||
{ T_LOC, "LOC" }, /* RFC 1876 */
|
||||
{ T_NXT, "NXT" }, /* RFC 2535 */
|
||||
{ T_EID, "EID" }, /* Nimrod */
|
||||
{ T_NIMLOC, "NIMLOC" }, /* Nimrod */
|
||||
{ T_SRV, "SRV" }, /* RFC 2782 */
|
||||
{ T_ATMA, "ATMA" }, /* ATM Forum */
|
||||
{ T_NAPTR, "NAPTR" }, /* RFC 2168, RFC 2915 */
|
||||
{ T_A6, "A6" }, /* RFC 2874 */
|
||||
{ T_DNAME, "DNAME" }, /* RFC 2672 */
|
||||
{ T_OPT, "OPT" }, /* RFC 2671 */
|
||||
{ T_UINFO, "UINFO" },
|
||||
{ T_UID, "UID" },
|
||||
{ T_GID, "GID" },
|
||||
{ T_UNSPEC, "UNSPEC" },
|
||||
{ T_UNSPECA, "UNSPECA" },
|
||||
{ T_TKEY, "TKEY" },
|
||||
{ T_TSIG, "TSIG" },
|
||||
{ T_IXFR, "IXFR" },
|
||||
{ T_AXFR, "AXFR" },
|
||||
{ T_MAILB, "MAILB" },
|
||||
{ T_MAILA, "MAILA" },
|
||||
{ T_TKEY, "TKEY" }, /* RFC 2930 */
|
||||
{ T_TSIG, "TSIG" }, /* RFC 2845 */
|
||||
{ T_IXFR, "IXFR" }, /* RFC 1995 */
|
||||
{ T_AXFR, "AXFR" }, /* RFC 1035 */
|
||||
{ T_MAILB, "MAILB" }, /* RFC 1035 */
|
||||
{ T_MAILA, "MAILA" }, /* RFC 1035 */
|
||||
{ T_ANY, "ANY" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
@ -315,11 +316,11 @@ ns_qprint(register const u_char *cp, register const u_char *bp)
|
||||
return(NULL);
|
||||
|
||||
/* print the qtype and qclass (if it's not IN) */
|
||||
i = *cp++ << 8;
|
||||
i |= *cp++;
|
||||
i = EXTRACT_16BITS(cp);
|
||||
cp += 2;
|
||||
printf(" %s", tok2str(ns_type2str, "Type%d", i));
|
||||
i = *cp++ << 8;
|
||||
i |= *cp++;
|
||||
i = EXTRACT_16BITS(cp);
|
||||
cp += 2;
|
||||
if (i != C_IN)
|
||||
printf(" %s", tok2str(ns_class2str, "(Class %d)", i));
|
||||
|
||||
@ -347,18 +348,18 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
|
||||
return (snapend);
|
||||
|
||||
/* print the type/qtype and class (if it's not IN) */
|
||||
typ = *cp++ << 8;
|
||||
typ |= *cp++;
|
||||
class = *cp++ << 8;
|
||||
class |= *cp++;
|
||||
typ = EXTRACT_16BITS(cp);
|
||||
cp += 2;
|
||||
class = EXTRACT_16BITS(cp);
|
||||
cp += 2;
|
||||
if (class != C_IN && typ != T_OPT)
|
||||
printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
|
||||
|
||||
/* ignore ttl */
|
||||
cp += 4;
|
||||
|
||||
len = *cp++ << 8;
|
||||
len |= *cp++;
|
||||
len = EXTRACT_16BITS(cp);
|
||||
cp += 2;
|
||||
|
||||
rp = cp + len;
|
||||
|
||||
@ -416,8 +417,13 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
|
||||
break;
|
||||
|
||||
case T_TXT:
|
||||
putchar(' ');
|
||||
(void)ns_cprint(cp);
|
||||
while (cp < rp) {
|
||||
printf(" \"");
|
||||
cp = ns_cprint(cp);
|
||||
if (cp == NULL)
|
||||
return(NULL);
|
||||
putchar('"');
|
||||
}
|
||||
break;
|
||||
|
||||
case T_SRV:
|
||||
|
Loading…
Reference in New Issue
Block a user