X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/0cced4fcdcad0c011cb123371d557067da7c6bbe..a8c33a5850cd9d2f39e56c06b645c283225d78c4:/print-lwres.c diff --git a/print-lwres.c b/print-lwres.c index 70b1c6f4..6f7d9aaa 100644 --- a/print-lwres.c +++ b/print-lwres.c @@ -205,12 +205,12 @@ lwres_printname(netdissect_options *ndo, ND_PRINT(" "); for (i = 0; i < l; i++) { - fn_print_char(ndo, EXTRACT_U_1(p)); + fn_print_char(ndo, GET_U_1(p)); p++; } p++; /* skip terminating \0 */ - return p - p0; + return ND_BYTES_BETWEEN(p, p0); trunc: return -1; @@ -225,7 +225,7 @@ lwres_printnamelen(netdissect_options *ndo, if (p + 2 > ndo->ndo_snapend) goto trunc; - l = EXTRACT_BE_U_2(p); + l = GET_BE_U_2(p); advance = lwres_printname(ndo, l, p + 2); if (advance < 0) goto trunc; @@ -246,15 +246,15 @@ lwres_printbinlen(netdissect_options *ndo, p = p0; if (p + 2 > ndo->ndo_snapend) goto trunc; - l = EXTRACT_BE_U_2(p); + l = GET_BE_U_2(p); if (p + 2 + l > ndo->ndo_snapend) goto trunc; p += 2; for (i = 0; i < l; i++) { - ND_PRINT("%02x", EXTRACT_U_1(p)); + ND_PRINT("%02x", GET_U_1(p)); p++; } - return p - p0; + return ND_BYTES_BETWEEN(p, p0); trunc: return -1; @@ -272,11 +272,11 @@ lwres_printaddr(netdissect_options *ndo, p = p0; ap = (const lwres_addr_t *)p; ND_TCHECK_2(ap->length); - l = EXTRACT_BE_U_2(ap->length); + l = GET_BE_U_2(ap->length); p += LWRES_ADDR_LEN; ND_TCHECK_LEN(p, l); - switch (EXTRACT_BE_U_4(ap->family)) { + switch (GET_BE_U_4(ap->family)) { case 1: /* IPv4 */ if (l < 4) return -1; @@ -290,14 +290,14 @@ lwres_printaddr(netdissect_options *ndo, p += sizeof(nd_ipv6); break; default: - ND_PRINT(" %u/", EXTRACT_BE_U_4(ap->family)); + ND_PRINT(" %u/", GET_BE_U_4(ap->family)); for (i = 0; i < l; i++) { - ND_PRINT("%02x", EXTRACT_U_1(p)); + ND_PRINT("%02x", GET_U_1(p)); p++; } } - return p - p0; + return ND_BYTES_BETWEEN(p, p0); trunc: return -1; @@ -320,34 +320,34 @@ lwres_print(netdissect_options *ndo, ND_TCHECK_2(np->authlength); ND_PRINT(" lwres"); - v = EXTRACT_BE_U_2(np->version); + v = GET_BE_U_2(np->version); if (ndo->ndo_vflag || v != LWRES_LWPACKETVERSION_0) ND_PRINT(" v%u", v); if (v != LWRES_LWPACKETVERSION_0) { - s = bp + EXTRACT_BE_U_4(np->length); + s = bp + GET_BE_U_4(np->length); goto tail; } - response = EXTRACT_BE_U_2(np->pktflags) & LWRES_LWPACKETFLAG_RESPONSE; + response = GET_BE_U_2(np->pktflags) & LWRES_LWPACKETFLAG_RESPONSE; /* opcode and pktflags */ - v = EXTRACT_BE_U_4(np->opcode); + v = GET_BE_U_4(np->opcode); ND_PRINT(" %s%s", tok2str(opcode, "#0x%x", v), response ? "" : "?"); /* pktflags */ - v = EXTRACT_BE_U_2(np->pktflags); + v = GET_BE_U_2(np->pktflags); if (v & ~LWRES_LWPACKETFLAG_RESPONSE) ND_PRINT("[0x%x]", v); if (ndo->ndo_vflag > 1) { ND_PRINT(" ("); /*)*/ - ND_PRINT("serial:0x%x", EXTRACT_BE_U_4(np->serial)); - ND_PRINT(" result:0x%x", EXTRACT_BE_U_4(np->result)); - ND_PRINT(" recvlen:%u", EXTRACT_BE_U_4(np->recvlength)); + ND_PRINT("serial:0x%x", GET_BE_U_4(np->serial)); + ND_PRINT(" result:0x%x", GET_BE_U_4(np->result)); + ND_PRINT(" recvlen:%u", GET_BE_U_4(np->recvlength)); /* BIND910: not used */ if (ndo->ndo_vflag > 2) { - ND_PRINT(" authtype:0x%x", EXTRACT_BE_U_2(np->authtype)); - ND_PRINT(" authlen:%u", EXTRACT_BE_U_2(np->authlength)); + ND_PRINT(" authtype:0x%x", GET_BE_U_2(np->authtype)); + ND_PRINT(" authlen:%u", GET_BE_U_2(np->authlength)); } /*(*/ ND_PRINT(")"); @@ -368,7 +368,7 @@ lwres_print(netdissect_options *ndo, grbn = NULL; p = (const u_char *)(np + 1); - switch (EXTRACT_BE_U_4(np->opcode)) { + switch (GET_BE_U_4(np->opcode)) { case LWRES_OPCODE_NOOP: s = p; break; @@ -379,10 +379,10 @@ lwres_print(netdissect_options *ndo, /* BIND910: not used */ if (ndo->ndo_vflag > 2) { ND_PRINT(" flags:0x%x", - EXTRACT_BE_U_4(gabn->flags)); + GET_BE_U_4(gabn->flags)); } - v = EXTRACT_BE_U_4(gabn->addrtypes); + v = GET_BE_U_4(gabn->addrtypes); switch (v & (LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6)) { case LWRES_ADDRTYPE_V4: ND_PRINT(" IPv4"); @@ -398,7 +398,7 @@ lwres_print(netdissect_options *ndo, ND_PRINT("[0x%x]", v); s = p + LWRES_GABNREQUEST_LEN; - l = EXTRACT_BE_U_2(gabn->namelen); + l = GET_BE_U_2(gabn->namelen); advance = lwres_printname(ndo, l, s); if (advance < 0) goto trunc; @@ -411,7 +411,7 @@ lwres_print(netdissect_options *ndo, /* BIND910: not used */ if (ndo->ndo_vflag > 2) { ND_PRINT(" flags:0x%x", - EXTRACT_BE_U_4(gnba->flags)); + GET_BE_U_4(gnba->flags)); } s = p + LWRES_GNBAREQUEST_LEN; @@ -428,18 +428,18 @@ lwres_print(netdissect_options *ndo, /* BIND910: not used */ if (ndo->ndo_vflag > 2) { ND_PRINT(" flags:0x%x", - EXTRACT_BE_U_4(grbn->flags)); + GET_BE_U_4(grbn->flags)); } ND_PRINT(" %s", tok2str(ns_type2str, "Type%u", - EXTRACT_BE_U_2(grbn->rdtype))); - if (EXTRACT_BE_U_2(grbn->rdclass) != C_IN) { + GET_BE_U_2(grbn->rdtype))); + if (GET_BE_U_2(grbn->rdclass) != C_IN) { ND_PRINT(" %s", tok2str(ns_class2str, "Class%u", - EXTRACT_BE_U_2(grbn->rdclass))); + GET_BE_U_2(grbn->rdclass))); } s = p + LWRES_GRBNREQUEST_LEN; - l = EXTRACT_BE_U_2(grbn->namelen); + l = GET_BE_U_2(grbn->namelen); advance = lwres_printname(ndo, l, s); if (advance < 0) goto trunc; @@ -465,7 +465,7 @@ lwres_print(netdissect_options *ndo, grbn = NULL; p = (const u_char *)(np + 1); - switch (EXTRACT_BE_U_4(np->opcode)) { + switch (GET_BE_U_4(np->opcode)) { case LWRES_OPCODE_NOOP: s = p; break; @@ -476,21 +476,21 @@ lwres_print(netdissect_options *ndo, /* BIND910: not used */ if (ndo->ndo_vflag > 2) { ND_PRINT(" flags:0x%x", - EXTRACT_BE_U_4(gabn->flags)); + GET_BE_U_4(gabn->flags)); } - ND_PRINT(" %u/%u", EXTRACT_BE_U_2(gabn->naliases), - EXTRACT_BE_U_2(gabn->naddrs)); + ND_PRINT(" %u/%u", GET_BE_U_2(gabn->naliases), + GET_BE_U_2(gabn->naddrs)); s = p + LWRES_GABNRESPONSE_LEN; - l = EXTRACT_BE_U_2(gabn->realnamelen); + l = GET_BE_U_2(gabn->realnamelen); advance = lwres_printname(ndo, l, s); if (advance < 0) goto trunc; s += advance; /* aliases */ - na = EXTRACT_BE_U_2(gabn->naliases); + na = GET_BE_U_2(gabn->naliases); for (i = 0; i < na; i++) { advance = lwres_printnamelen(ndo, s); if (advance < 0) @@ -499,7 +499,7 @@ lwres_print(netdissect_options *ndo, } /* addrs */ - na = EXTRACT_BE_U_2(gabn->naddrs); + na = GET_BE_U_2(gabn->naddrs); for (i = 0; i < na; i++) { advance = lwres_printaddr(ndo, s); if (advance < 0) @@ -514,20 +514,20 @@ lwres_print(netdissect_options *ndo, /* BIND910: not used */ if (ndo->ndo_vflag > 2) { ND_PRINT(" flags:0x%x", - EXTRACT_BE_U_4(gnba->flags)); + GET_BE_U_4(gnba->flags)); } - ND_PRINT(" %u", EXTRACT_BE_U_2(gnba->naliases)); + ND_PRINT(" %u", GET_BE_U_2(gnba->naliases)); s = p + LWRES_GNBARESPONSE_LEN; - l = EXTRACT_BE_U_2(gnba->realnamelen); + l = GET_BE_U_2(gnba->realnamelen); advance = lwres_printname(ndo, l, s); if (advance < 0) goto trunc; s += advance; /* aliases */ - na = EXTRACT_BE_U_2(gnba->naliases); + na = GET_BE_U_2(gnba->naliases); for (i = 0; i < na; i++) { advance = lwres_printnamelen(ndo, s); if (advance < 0) @@ -543,20 +543,20 @@ lwres_print(netdissect_options *ndo, /* BIND910: not used */ if (ndo->ndo_vflag > 2) { ND_PRINT(" flags:0x%x", - EXTRACT_BE_U_4(grbn->flags)); + GET_BE_U_4(grbn->flags)); } ND_PRINT(" %s", tok2str(ns_type2str, "Type%u", - EXTRACT_BE_U_2(grbn->rdtype))); - if (EXTRACT_BE_U_2(grbn->rdclass) != C_IN) { + GET_BE_U_2(grbn->rdtype))); + if (GET_BE_U_2(grbn->rdclass) != C_IN) { ND_PRINT(" %s", tok2str(ns_class2str, "Class%u", - EXTRACT_BE_U_2(grbn->rdclass))); + GET_BE_U_2(grbn->rdclass))); } ND_PRINT(" TTL "); unsigned_relts_print(ndo, - EXTRACT_BE_U_4(grbn->ttl)); - ND_PRINT(" %u/%u", EXTRACT_BE_U_2(grbn->nrdatas), - EXTRACT_BE_U_2(grbn->nsigs)); + GET_BE_U_4(grbn->ttl)); + ND_PRINT(" %u/%u", GET_BE_U_2(grbn->nrdatas), + GET_BE_U_2(grbn->nsigs)); s = p + LWRES_GRBNRESPONSE_LEN; advance = lwres_printnamelen(ndo, s); @@ -565,7 +565,7 @@ lwres_print(netdissect_options *ndo, s += advance; /* rdatas */ - na = EXTRACT_BE_U_2(grbn->nrdatas); + na = GET_BE_U_2(grbn->nrdatas); for (i = 0; i < na; i++) { /* XXX should decode resource data */ advance = lwres_printbinlen(ndo, s); @@ -575,7 +575,7 @@ lwres_print(netdissect_options *ndo, } /* sigs */ - na = EXTRACT_BE_U_2(grbn->nsigs); + na = GET_BE_U_2(grbn->nsigs); for (i = 0; i < na; i++) { /* XXX how should we print it? */ advance = lwres_printbinlen(ndo, s); @@ -593,14 +593,14 @@ lwres_print(netdissect_options *ndo, tail: /* length mismatch */ - if (EXTRACT_BE_U_4(np->length) != length) { - ND_PRINT(" [len: %u != %u]", EXTRACT_BE_U_4(np->length), + if (GET_BE_U_4(np->length) != length) { + ND_PRINT(" [len: %u != %u]", GET_BE_U_4(np->length), length); } - if (!unsupported && s < bp + EXTRACT_BE_U_4(np->length)) + if (!unsupported && s < bp + GET_BE_U_4(np->length)) ND_PRINT("[extra]"); return; trunc: - ND_PRINT("[|lwres]"); + nd_print_trunc(ndo); }