X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/59690cf6b7ffce3cc86936cbe658909c6ec3a687..237acb8f896a20821c6f06b6d422d5034b981fcd:/print-bootp.c diff --git a/print-bootp.c b/print-bootp.c index 85b56301..4da4f952 100644 --- a/print-bootp.c +++ b/print-bootp.c @@ -71,7 +71,7 @@ bootp_print(netdissect_options *ndo, if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) { ND_TCHECK2(bp->bp_chaddr[0], 6); - ND_PRINT((ndo, " from %s", etheraddr_string(bp->bp_chaddr))); + ND_PRINT((ndo, " from %s", etheraddr_string(ndo, bp->bp_chaddr))); } ND_PRINT((ndo, ", length %u", length)); @@ -105,60 +105,60 @@ bootp_print(netdissect_options *ndo, /* Client's ip address */ ND_TCHECK(bp->bp_ciaddr); if (EXTRACT_32BITS(&bp->bp_ciaddr.s_addr)) - ND_PRINT((ndo, "\n\t Client-IP %s", ipaddr_string(&bp->bp_ciaddr))); + ND_PRINT((ndo, "\n\t Client-IP %s", ipaddr_string(ndo, &bp->bp_ciaddr))); /* 'your' ip address (bootp client) */ ND_TCHECK(bp->bp_yiaddr); if (EXTRACT_32BITS(&bp->bp_yiaddr.s_addr)) - ND_PRINT((ndo, "\n\t Your-IP %s", ipaddr_string(&bp->bp_yiaddr))); + ND_PRINT((ndo, "\n\t Your-IP %s", ipaddr_string(ndo, &bp->bp_yiaddr))); /* Server's ip address */ ND_TCHECK(bp->bp_siaddr); if (EXTRACT_32BITS(&bp->bp_siaddr.s_addr)) - ND_PRINT((ndo, "\n\t Server-IP %s", ipaddr_string(&bp->bp_siaddr))); + ND_PRINT((ndo, "\n\t Server-IP %s", ipaddr_string(ndo, &bp->bp_siaddr))); /* Gateway's ip address */ ND_TCHECK(bp->bp_giaddr); if (EXTRACT_32BITS(&bp->bp_giaddr.s_addr)) - ND_PRINT((ndo, "\n\t Gateway-IP %s", ipaddr_string(&bp->bp_giaddr))); + ND_PRINT((ndo, "\n\t Gateway-IP %s", ipaddr_string(ndo, &bp->bp_giaddr))); /* Client's Ethernet address */ if (bp->bp_htype == 1 && bp->bp_hlen == 6) { ND_TCHECK2(bp->bp_chaddr[0], 6); - ND_PRINT((ndo, "\n\t Client-Ethernet-Address %s", etheraddr_string(bp->bp_chaddr))); + ND_PRINT((ndo, "\n\t Client-Ethernet-Address %s", etheraddr_string(ndo, bp->bp_chaddr))); } ND_TCHECK2(bp->bp_sname[0], 1); /* check first char only */ if (*bp->bp_sname) { ND_PRINT((ndo, "\n\t sname \"")); - if (fn_print(bp->bp_sname, ndo->ndo_snapend)) { - putchar('"'); - fputs(tstr + 1, stdout); + if (fn_print(ndo, bp->bp_sname, ndo->ndo_snapend)) { + ND_PRINT((ndo, "\"")); + ND_PRINT((ndo, "%s", tstr + 1)); return; } - putchar('"'); + ND_PRINT((ndo, "\"")); } ND_TCHECK2(bp->bp_file[0], 1); /* check first char only */ if (*bp->bp_file) { ND_PRINT((ndo, "\n\t file \"")); - if (fn_print(bp->bp_file, ndo->ndo_snapend)) { - putchar('"'); - fputs(tstr + 1, stdout); + if (fn_print(ndo, bp->bp_file, ndo->ndo_snapend)) { + ND_PRINT((ndo, "\"")); + ND_PRINT((ndo, "%s", tstr + 1)); return; } - putchar('"'); + ND_PRINT((ndo, "\"")); } /* Decode the vendor buffer */ ND_TCHECK(bp->bp_vend[0]); if (memcmp((const char *)bp->bp_vend, vm_rfc1048, - sizeof(u_int32_t)) == 0) + sizeof(uint32_t)) == 0) rfc1048_print(ndo, bp->bp_vend); else if (memcmp((const char *)bp->bp_vend, vm_cmu, - sizeof(u_int32_t)) == 0) + sizeof(uint32_t)) == 0) cmu_print(ndo, bp->bp_vend); else { - u_int32_t ul; + uint32_t ul; ul = EXTRACT_32BITS(&bp->bp_vend); if (ul != 0) @@ -167,7 +167,7 @@ bootp_print(netdissect_options *ndo, return; trunc: - fputs(tstr, stdout); + ND_PRINT((ndo, "%s", tstr)); } /* @@ -363,14 +363,14 @@ static void rfc1048_print(netdissect_options *ndo, register const u_char *bp) { - register u_int16_t tag; + register uint16_t tag; register u_int len; register const char *cp; register char c; int first, idx; - u_int32_t ul; - u_int16_t us; - u_int8_t uc, subopt, suboptlen; + uint32_t ul; + uint16_t us; + uint8_t uc, subopt, suboptlen; ND_PRINT((ndo, "\n\t Vendor-rfc1048 Extensions")); @@ -452,7 +452,7 @@ rfc1048_print(netdissect_options *ndo, bp += 2; cp = tok2str(xtag2str, "?xT%u", us); if (!first) - putchar('+'); + ND_PRINT((ndo, "+")); ND_PRINT((ndo, "%s", cp + 1)); first = 0; } @@ -474,12 +474,12 @@ rfc1048_print(netdissect_options *ndo, case 'a': /* ascii strings */ - putchar('"'); - if (fn_printn(bp, len, ndo->ndo_snapend)) { - putchar('"'); + ND_PRINT((ndo, "\"")); + if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) { + ND_PRINT((ndo, "\"")); goto trunc; } - putchar('"'); + ND_PRINT((ndo, "\"")); bp += len; len = 0; break; @@ -490,11 +490,11 @@ rfc1048_print(netdissect_options *ndo, /* ip addresses/32-bit words */ while (len >= sizeof(ul)) { if (!first) - putchar(','); + ND_PRINT((ndo, ",")); ul = EXTRACT_32BITS(bp); if (c == 'i') { ul = htonl(ul); - ND_PRINT((ndo, "%s", ipaddr_string(&ul))); + ND_PRINT((ndo, "%s", ipaddr_string(ndo, &ul))); } else if (c == 'L') ND_PRINT((ndo, "%d", ul)); else @@ -509,12 +509,12 @@ rfc1048_print(netdissect_options *ndo, /* IP address pairs */ while (len >= 2*sizeof(ul)) { if (!first) - putchar(','); + ND_PRINT((ndo, ",")); memcpy((char *)&ul, (const char *)bp, sizeof(ul)); - ND_PRINT((ndo, "(%s:", ipaddr_string(&ul))); + ND_PRINT((ndo, "(%s:", ipaddr_string(ndo, &ul))); bp += sizeof(ul); memcpy((char *)&ul, (const char *)bp, sizeof(ul)); - ND_PRINT((ndo, "%s)", ipaddr_string(&ul))); + ND_PRINT((ndo, "%s)", ipaddr_string(ndo, &ul))); bp += sizeof(ul); len -= 2*sizeof(ul); first = 0; @@ -525,7 +525,7 @@ rfc1048_print(netdissect_options *ndo, /* shorts */ while (len >= sizeof(us)) { if (!first) - putchar(','); + ND_PRINT((ndo, ",")); us = EXTRACT_16BITS(bp); ND_PRINT((ndo, "%u", us)); bp += sizeof(us); @@ -538,13 +538,13 @@ rfc1048_print(netdissect_options *ndo, /* boolean */ while (len > 0) { if (!first) - putchar(','); + ND_PRINT((ndo, ",")); switch (*bp) { case 0: - putchar('N'); + ND_PRINT((ndo, "N")); break; case 1: - putchar('Y'); + ND_PRINT((ndo, "Y")); break; default: ND_PRINT((ndo, "%u?", *bp)); @@ -562,7 +562,7 @@ rfc1048_print(netdissect_options *ndo, /* Bytes */ while (len > 0) { if (!first) - putchar(c == 'x' ? ':' : '.'); + ND_PRINT((ndo, c == 'x' ? ":" : ".")); if (c == 'x') ND_PRINT((ndo, "%02x", *bp)); else @@ -586,7 +586,7 @@ rfc1048_print(netdissect_options *ndo, } tag = *bp++; --len; - fputs(tok2str(nbo2str, NULL, tag), stdout); + ND_PRINT((ndo, "%s", tok2str(nbo2str, NULL, tag))); break; case TAG_OPT_OVERLOAD: @@ -598,7 +598,7 @@ rfc1048_print(netdissect_options *ndo, } tag = *bp++; --len; - fputs(tok2str(oo2str, NULL, tag), stdout); + ND_PRINT((ndo, "%s", tok2str(oo2str, NULL, tag))); break; case TAG_CLIENT_FQDN: @@ -616,12 +616,12 @@ rfc1048_print(netdissect_options *ndo, if (*bp || *(bp+1)) ND_PRINT((ndo, "%u/%u ", *bp, *(bp+1))); bp += 2; - putchar('"'); - if (fn_printn(bp, len - 3, ndo->ndo_snapend)) { - putchar('"'); + ND_PRINT((ndo, "\"")); + if (fn_printn(ndo, bp, len - 3, ndo->ndo_snapend)) { + ND_PRINT((ndo, "\"")); goto trunc; } - putchar('"'); + ND_PRINT((ndo, "\"")); bp += len - 3; len = 0; break; @@ -638,12 +638,12 @@ rfc1048_print(netdissect_options *ndo, type = *bp++; len--; if (type == 0) { - putchar('"'); - if (fn_printn(bp, len, ndo->ndo_snapend)) { - putchar('"'); + ND_PRINT((ndo, "\"")); + if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) { + ND_PRINT((ndo, "\"")); goto trunc; } - putchar('"'); + ND_PRINT((ndo, "\"")); bp += len; len = 0; break; @@ -651,7 +651,7 @@ rfc1048_print(netdissect_options *ndo, ND_PRINT((ndo, "%s ", tok2str(arp2str, "hardware-type %u,", type))); while (len > 0) { if (!first) - putchar(':'); + ND_PRINT((ndo, ":")); ND_PRINT((ndo, "%02x", *bp)); ++bp; --len; @@ -684,7 +684,7 @@ rfc1048_print(netdissect_options *ndo, case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */ case AGENT_SUBOPTION_REMOTE_ID: case AGENT_SUBOPTION_SUBSCRIBER_ID: - fn_printn(bp, suboptlen, NULL); + fn_printn(ndo, bp, suboptlen, NULL); break; default: @@ -711,7 +711,7 @@ rfc1048_print(netdissect_options *ndo, } while (len > 0) { if (!first) - putchar(','); + ND_PRINT((ndo, ",")); mask_width = *bp++; len--; /* mask_width <= 32 */ @@ -729,13 +729,13 @@ rfc1048_print(netdissect_options *ndo, len = 0; break; } - putchar('('); + ND_PRINT((ndo, "(")); if (mask_width == 0) ND_PRINT((ndo, "default")); else { for (i = 0; i < significant_octets ; i++) { if (i > 0) - putchar('.'); + ND_PRINT((ndo, ".")); ND_PRINT((ndo, "%d", *bp++)); } for (i = significant_octets ; i < 4 ; i++) @@ -743,7 +743,7 @@ rfc1048_print(netdissect_options *ndo, ND_PRINT((ndo, "/%d", mask_width)); } memcpy((char *)&ul, (const char *)bp, sizeof(ul)); - ND_PRINT((ndo, ":%s)", ipaddr_string(&ul))); + ND_PRINT((ndo, ":%s)", ipaddr_string(ndo, &ul))); bp += sizeof(ul); len -= (significant_octets + 4); first = 0; @@ -779,7 +779,7 @@ cmu_print(netdissect_options *ndo, #define PRINTCMUADDR(m, s) { ND_TCHECK(cmu->m); \ if (cmu->m.s_addr != 0) \ - ND_PRINT((ndo, " %s:%s", s, ipaddr_string(&cmu->m.s_addr))); } + ND_PRINT((ndo, " %s:%s", s, ipaddr_string(ndo, &cmu->m.s_addr))); } ND_PRINT((ndo, " vend-cmu")); cmu = (const struct cmu_vend *)bp; @@ -799,7 +799,7 @@ cmu_print(netdissect_options *ndo, return; trunc: - fputs(tstr, stdout); + ND_PRINT((ndo, "%s", tstr)); #undef PRINTCMUADDR }