]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-pktap.c
Add printing support for vsockmon devices.
[tcpdump] / print-pktap.c
index 93bfda9bdce4bcf0729c6eaec682577211bce33d..af3b3973aa7296b648ea2825c1875a2b766d95ca 100644 (file)
 /* \summary: Apple's DLT_PKTAP printer */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
 
 #include "netdissect.h"
 #include "extract.h"
@@ -67,7 +67,7 @@ typedef struct pktap_header {
 #define PKT_REC_NONE   0       /* nothing follows the header */
 #define PKT_REC_PACKET 1       /* a packet follows the header */
 
-static inline void
+static void
 pktap_header_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
        const pktap_header_t *hdr;
@@ -76,8 +76,8 @@ pktap_header_print(netdissect_options *ndo, const u_char *bp, u_int length)
 
        hdr = (const pktap_header_t *)bp;
 
-       dlt = EXTRACT_LE_U_4(hdr->pkt_dlt);
-       hdrlen = EXTRACT_LE_U_4(hdr->pkt_len);
+       dlt = GET_LE_U_4(hdr->pkt_dlt);
+       hdrlen = GET_LE_U_4(hdr->pkt_len);
        dltname = pcap_datalink_val_to_name(dlt);
        if (!ndo->ndo_qflag) {
                ND_PRINT("DLT %s (%u) len %u",
@@ -106,13 +106,14 @@ pktap_if_print(netdissect_options *ndo,
        const pktap_header_t *hdr;
        struct pcap_pkthdr nhdr;
 
-       if (caplen < sizeof(pktap_header_t) || length < sizeof(pktap_header_t)) {
-               ND_PRINT("[|pktap]");
-               return (0);
+       ndo->ndo_protocol = "pktap_if";
+       if (caplen < sizeof(pktap_header_t)) {
+               nd_print_trunc(ndo);
+               return (caplen);
        }
        hdr = (const pktap_header_t *)p;
-       dlt = EXTRACT_LE_U_4(hdr->pkt_dlt);
-       hdrlen = EXTRACT_LE_U_4(hdr->pkt_len);
+       dlt = GET_LE_U_4(hdr->pkt_dlt);
+       hdrlen = GET_LE_U_4(hdr->pkt_len);
        if (hdrlen < sizeof(pktap_header_t)) {
                /*
                 * Claimed header length < structure length.
@@ -121,12 +122,12 @@ pktap_if_print(netdissect_options *ndo,
                 * is the length supplied so that the header can
                 * be expanded in the future)?
                 */
-               ND_PRINT("[|pktap]");
-               return (0);
+               nd_print_trunc(ndo);
+               return (caplen);
        }
-       if (caplen < hdrlen || length < hdrlen) {
-               ND_PRINT("[|pktap]");
-               return (hdrlen);
+       if (caplen < hdrlen) {
+               nd_print_trunc(ndo);
+               return (caplen);
        }
 
        if (ndo->ndo_eflag)
@@ -136,7 +137,7 @@ pktap_if_print(netdissect_options *ndo,
        caplen -= hdrlen;
        p += hdrlen;
 
-       rectype = EXTRACT_LE_U_4(hdr->pkt_rectype);
+       rectype = GET_LE_U_4(hdr->pkt_rectype);
        switch (rectype) {
 
        case PKT_REC_NONE:
@@ -162,12 +163,4 @@ pktap_if_print(netdissect_options *ndo,
 
        return (hdrlen);
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
-
 #endif /* DLT_PKTAP */