X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/b38f324af9dd953a661b9f35910f8c6d8eb2cc06..0ce779d1756e2bc1f5a845df5acf86f0dc698a14:/print-ppi.c diff --git a/print-ppi.c b/print-ppi.c index cb8f3b95..ad5eb27f 100644 --- a/print-ppi.c +++ b/print-ppi.c @@ -30,21 +30,23 @@ ppi_header_print(netdissect_options *ndo, const u_char *bp, u_int length) const ppi_header_t *hdr; uint16_t len; uint32_t dlt; + const char *dltname; hdr = (const ppi_header_t *)bp; - len = EXTRACT_LE_16BITS(&hdr->ppi_len); - dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt); + len = EXTRACT_LE_U_2(&hdr->ppi_len); + dlt = EXTRACT_LE_U_4(&hdr->ppi_dlt); + dltname = pcap_datalink_val_to_name(dlt); if (!ndo->ndo_qflag) { - ND_PRINT((ndo, "V.%d DLT %s (%d) len %d", hdr->ppi_ver, - pcap_datalink_val_to_name(dlt), dlt, - len)); + ND_PRINT("V.%d DLT %s (%d) len %d", hdr->ppi_ver, + (dltname != NULL ? dltname : "UNKNOWN"), dlt, + len); } else { - ND_PRINT((ndo, "%s", pcap_datalink_val_to_name(dlt))); + ND_PRINT("%s", (dltname != NULL ? dltname : "UNKNOWN")); } - ND_PRINT((ndo, ", length %u: ", length)); + ND_PRINT(", length %u: ", length); } static u_int @@ -61,25 +63,25 @@ ppi_print(netdissect_options *ndo, struct pcap_pkthdr nhdr; if (caplen < sizeof(ppi_header_t)) { - ND_PRINT((ndo, "[|ppi]")); + ND_PRINT("[|ppi]"); return (caplen); } hdr = (const ppi_header_t *)p; - len = EXTRACT_LE_16BITS(&hdr->ppi_len); + len = EXTRACT_LE_U_2(&hdr->ppi_len); if (caplen < len) { /* * If we don't have the entire PPI header, don't * bother. */ - ND_PRINT((ndo, "[|ppi]")); + ND_PRINT("[|ppi]"); return (caplen); } if (len < sizeof(ppi_header_t)) { - ND_PRINT((ndo, "[|ppi]")); + ND_PRINT("[|ppi]"); return (len); } - dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt); + dlt = EXTRACT_LE_U_4(&hdr->ppi_dlt); if (ndo->ndo_eflag) ppi_header_print(ndo, p, length);