9 #include <tcpdump-stdinc.h>
11 #include "interface.h"
14 typedef struct ppi_header
{
26 ppi_header_print(netdissect_options
*ndo
, const u_char
*bp
, u_int length
)
28 const ppi_header_t
*hdr
;
32 hdr
= (const ppi_header_t
*)bp
;
34 len
= EXTRACT_LE_16BITS(&hdr
->ppi_len
);
35 dlt
= EXTRACT_LE_32BITS(&hdr
->ppi_dlt
);
37 if (!ndo
->ndo_qflag
) {
38 ND_PRINT((ndo
, "V.%d DLT %s (%d) len %d", hdr
->ppi_ver
,
39 pcap_datalink_val_to_name(dlt
), dlt
,
42 ND_PRINT((ndo
, "%s", pcap_datalink_val_to_name(dlt
)));
45 ND_PRINT((ndo
, ", length %u: ", length
));
49 ppi_print(netdissect_options
*ndo
,
50 const struct pcap_pkthdr
*h
, const u_char
*p
)
53 const ppi_header_t
*hdr
;
54 u_int caplen
= h
->caplen
;
55 u_int length
= h
->len
;
60 if (caplen
< sizeof(ppi_header_t
)) {
61 ND_PRINT((ndo
, "[|ppi]"));
65 hdr
= (const ppi_header_t
*)p
;
66 len
= EXTRACT_LE_16BITS(&hdr
->ppi_len
);
69 * If we don't have the entire PPI header, don't
72 ND_PRINT((ndo
, "[|ppi]"));
75 if (len
< sizeof(ppi_header_t
)) {
76 ND_PRINT((ndo
, "[|ppi]"));
79 dlt
= EXTRACT_LE_32BITS(&hdr
->ppi_dlt
);
82 ppi_header_print(ndo
, p
, length
);
88 if ((printer
= lookup_printer(dlt
)) != NULL
) {
89 hdrlen
= printer(ndo
, h
, p
);
92 ppi_header_print(ndo
, (const u_char
*)hdr
, length
+ len
);
94 if (!ndo
->ndo_suppress_default_print
)
95 ND_DEFAULTPRINT(p
, caplen
);
98 return (len
+ hdrlen
);
102 * This is the top level routine of the printer. 'p' points
103 * to the ether header of the packet, 'h->ts' is the timestamp,
104 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
105 * is the number of bytes actually captured.
108 ppi_if_print(netdissect_options
*ndo
,
109 const struct pcap_pkthdr
*h
, const u_char
*p
)
111 return (ppi_print(ndo
, h
, p
));
116 * c-style: whitesmith