?? print-domain.c
字號:
i = EXTRACT_16BITS(cp); cp += 2; if (is_mdns) class = (i & ~C_CACHE_FLUSH); else class = i; if (class != C_IN && typ != T_OPT) printf(" %s", tok2str(ns_class2str, "(Class %d)", class)); if (is_mdns) { if (i & C_CACHE_FLUSH) printf(" (Cache flush)"); } if (typ == T_OPT) { /* get opt flags */ cp += 2; opt_flags = EXTRACT_16BITS(cp); /* ignore rest of ttl field */ cp += 2; } else if (vflag > 2) { /* print ttl */ printf(" ["); relts_print(EXTRACT_32BITS(cp)); printf("]"); cp += 4; } else { /* ignore ttl */ cp += 4; } len = EXTRACT_16BITS(cp); cp += 2; rp = cp + len; printf(" %s", tok2str(ns_type2str, "Type%d", typ)); if (rp > snapend) return(NULL); switch (typ) { case T_A: if (!TTEST2(*cp, sizeof(struct in_addr))) return(NULL); printf(" %s", intoa(htonl(EXTRACT_32BITS(cp)))); break; case T_NS: case T_CNAME: case T_PTR:#ifdef T_DNAME case T_DNAME:#endif putchar(' '); if (ns_nprint(cp, bp) == NULL) return(NULL); break; case T_SOA: if (!vflag) break; putchar(' '); if ((cp = ns_nprint(cp, bp)) == NULL) return(NULL); putchar(' '); if ((cp = ns_nprint(cp, bp)) == NULL) return(NULL); if (!TTEST2(*cp, 5 * 4)) return(NULL); printf(" %u", EXTRACT_32BITS(cp)); cp += 4; printf(" %u", EXTRACT_32BITS(cp)); cp += 4; printf(" %u", EXTRACT_32BITS(cp)); cp += 4; printf(" %u", EXTRACT_32BITS(cp)); cp += 4; printf(" %u", EXTRACT_32BITS(cp)); cp += 4; break; case T_MX: putchar(' '); if (!TTEST2(*cp, 2)) return(NULL); if (ns_nprint(cp + 2, bp) == NULL) return(NULL); printf(" %d", EXTRACT_16BITS(cp)); break; case T_TXT: while (cp < rp) { printf(" \""); cp = ns_cprint(cp); if (cp == NULL) return(NULL); putchar('"'); } break; case T_SRV: putchar(' '); if (!TTEST2(*cp, 6)) return(NULL); if (ns_nprint(cp + 6, bp) == NULL) return(NULL); printf(":%d %d %d", EXTRACT_16BITS(cp + 4), EXTRACT_16BITS(cp), EXTRACT_16BITS(cp + 2)); break;#ifdef INET6 case T_AAAA: { struct in6_addr addr; char ntop_buf[INET6_ADDRSTRLEN]; if (!TTEST2(*cp, sizeof(struct in6_addr))) return(NULL); memcpy(&addr, cp, sizeof(struct in6_addr)); printf(" %s", inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf))); break; } case T_A6: { struct in6_addr a; int pbit, pbyte; char ntop_buf[INET6_ADDRSTRLEN]; if (!TTEST2(*cp, 1)) return(NULL); pbit = *cp; pbyte = (pbit & ~7) / 8; if (pbit > 128) { printf(" %u(bad plen)", pbit); break; } else if (pbit < 128) { if (!TTEST2(*(cp + 1), sizeof(a) - pbyte)) return(NULL); memset(&a, 0, sizeof(a)); memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte); printf(" %u %s", pbit, inet_ntop(AF_INET6, &a, ntop_buf, sizeof(ntop_buf))); } if (pbit > 0) { putchar(' '); if (ns_nprint(cp + 1 + sizeof(a) - pbyte, bp) == NULL) return(NULL); } break; }#endif /*INET6*/ case T_OPT: printf(" UDPsize=%u", class); if (opt_flags & 0x8000) printf(" OK"); break; case T_UNSPECA: /* One long string */ if (!TTEST2(*cp, len)) return(NULL); if (fn_printn(cp, len, snapend)) return(NULL); break; case T_TSIG: { if (cp + len > snapend) return(NULL); if (!vflag) break; putchar(' '); if ((cp = ns_nprint(cp, bp)) == NULL) return(NULL); cp += 6; if (!TTEST2(*cp, 2)) return(NULL); printf(" fudge=%u", EXTRACT_16BITS(cp)); cp += 2; if (!TTEST2(*cp, 2)) return(NULL); printf(" maclen=%u", EXTRACT_16BITS(cp)); cp += 2 + EXTRACT_16BITS(cp); if (!TTEST2(*cp, 2)) return(NULL); printf(" origid=%u", EXTRACT_16BITS(cp)); cp += 2; if (!TTEST2(*cp, 2)) return(NULL); printf(" error=%u", EXTRACT_16BITS(cp)); cp += 2; if (!TTEST2(*cp, 2)) return(NULL); printf(" otherlen=%u", EXTRACT_16BITS(cp)); cp += 2; } } return (rp); /* XXX This isn't always right */}voidns_print(register const u_char *bp, u_int length, int is_mdns){ register const HEADER *np; register int qdcount, ancount, nscount, arcount; register const u_char *cp; u_int16_t b2; np = (const HEADER *)bp; TCHECK(*np); /* get the byte-order right */ qdcount = EXTRACT_16BITS(&np->qdcount); ancount = EXTRACT_16BITS(&np->ancount); nscount = EXTRACT_16BITS(&np->nscount); arcount = EXTRACT_16BITS(&np->arcount); if (DNS_QR(np)) { /* this is a response */ printf("%d%s%s%s%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)], ns_resp[DNS_RCODE(np)], DNS_AA(np)? "*" : "", DNS_RA(np)? "" : "-", DNS_TC(np)? "|" : "", DNS_AD(np)? "$" : ""); if (qdcount != 1) printf(" [%dq]", qdcount); /* Print QUESTION section on -vv */ cp = (const u_char *)(np + 1); while (qdcount--) { if (qdcount < EXTRACT_16BITS(&np->qdcount) - 1) putchar(','); if (vflag > 1) { fputs(" q:", stdout); if ((cp = ns_qprint(cp, bp, is_mdns)) == NULL) goto trunc; } else { if ((cp = ns_nskip(cp)) == NULL) goto trunc; cp += 4; /* skip QTYPE and QCLASS */ } } printf(" %d/%d/%d", ancount, nscount, arcount); if (ancount--) { if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; while (cp < snapend && ancount--) { putchar(','); if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; } } if (ancount > 0) goto trunc; /* Print NS and AR sections on -vv */ if (vflag > 1) { if (cp < snapend && nscount--) { fputs(" ns:", stdout); if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; while (cp < snapend && nscount--) { putchar(','); if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; } } if (nscount > 0) goto trunc; if (cp < snapend && arcount--) { fputs(" ar:", stdout); if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; while (cp < snapend && arcount--) { putchar(','); if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; } } if (arcount > 0) goto trunc; } } else { /* this is a request */ printf("%d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)], DNS_RD(np) ? "+" : "", DNS_CD(np) ? "%" : ""); /* any weirdness? */ b2 = EXTRACT_16BITS(((u_short *)np)+1); if (b2 & 0x6cf) printf(" [b2&3=0x%x]", b2); if (DNS_OPCODE(np) == IQUERY) { if (qdcount) printf(" [%dq]", qdcount); if (ancount != 1) printf(" [%da]", ancount); } else { if (ancount) printf(" [%da]", ancount); if (qdcount != 1) printf(" [%dq]", qdcount); } if (nscount) printf(" [%dn]", nscount); if (arcount) printf(" [%dau]", arcount); cp = (const u_char *)(np + 1); if (qdcount--) { 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, is_mdns); if (!cp) goto trunc; } } if (qdcount > 0) goto trunc; /* Print remaining sections on -vv */ if (vflag > 1) { if (ancount--) { if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; while (cp < snapend && ancount--) { putchar(','); if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; } } if (ancount > 0) goto trunc; if (cp < snapend && nscount--) { fputs(" ns:", stdout); if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; while (nscount-- && cp < snapend) { putchar(','); if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; } } if (nscount > 0) goto trunc; if (cp < snapend && arcount--) { fputs(" ar:", stdout); if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; while (cp < snapend && arcount--) { putchar(','); if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) goto trunc; } } if (arcount > 0) goto trunc; } } printf(" (%d)", length); return; trunc: printf("[|domain]"); return;}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -