8 #include <tcpdump-stdinc.h>
13 #include "netdissect.h"
14 #include "interface.h"
17 typedef struct ppi_header
{
29 ppi_header_print(struct netdissect_options
*ndo
, const u_char
*bp
, u_int length
)
31 const ppi_header_t
*hdr
;
35 hdr
= (const ppi_header_t
*)bp
;
37 len
= EXTRACT_16BITS(&hdr
->ppi_len
);
38 dlt
= EXTRACT_32BITS(&hdr
->ppi_dlt
);
40 if (!ndo
->ndo_qflag
) {
41 ND_PRINT((ndo
,", V.%d DLT %s (%d) len %d", hdr
->ppi_ver
,
42 pcap_datalink_val_to_name(dlt
), dlt
,
45 ND_PRINT((ndo
,", %s", pcap_datalink_val_to_name(dlt
)));
48 ND_PRINT((ndo
, ", length %u: ", length
));
52 ppi_print(struct netdissect_options
*ndo
,
53 const struct pcap_pkthdr
*h
, const u_char
*p
)
55 if_ndo_printer ndo_printer
;
58 u_int caplen
= h
->caplen
;
59 u_int length
= h
->len
;
62 if (caplen
< sizeof(ppi_header_t
)) {
63 ND_PRINT((ndo
, "[|ppi]"));
66 hdr
= (ppi_header_t
*)p
;
67 dlt
= EXTRACT_32BITS(&hdr
->ppi_dlt
);
70 ppi_header_print(ndo
, p
, length
);
72 length
-= sizeof(ppi_header_t
);
73 caplen
-= sizeof(ppi_header_t
);
74 p
+= sizeof(ppi_header_t
);
76 if ((printer
= lookup_printer(dlt
)) != NULL
) {
78 } else if ((ndo_printer
= lookup_ndo_printer(dlt
)) != NULL
) {
79 ndo_printer(ndo
, h
, p
);
82 ppi_header_print(ndo
, (u_char
*)hdr
,
83 length
+ sizeof(ppi_header_t
));
85 if (!ndo
->ndo_suppress_default_print
)
86 ndo
->ndo_default_print(ndo
, p
, caplen
);
91 * This is the top level routine of the printer. 'p' points
92 * to the ether header of the packet, 'h->ts' is the timestamp,
93 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
94 * is the number of bytes actually captured.
97 ppi_if_print(struct netdissect_options
*ndo
,
98 const struct pcap_pkthdr
*h
, const u_char
*p
)
100 ppi_print(ndo
, h
, p
);
102 return (sizeof(ppi_header_t
));
107 * c-style: whitesmith