5 /* \summary: Oracle DLT_PPI printer */
11 #include <netdissect-stdinc.h>
13 #include "netdissect.h"
16 typedef struct ppi_header
{
28 ppi_header_print(netdissect_options
*ndo
, const u_char
*bp
, u_int length
)
30 const ppi_header_t
*hdr
;
35 hdr
= (const ppi_header_t
*)bp
;
37 len
= EXTRACT_LE_16BITS(&hdr
->ppi_len
);
38 dlt
= EXTRACT_LE_32BITS(&hdr
->ppi_dlt
);
39 dltname
= pcap_datalink_val_to_name(dlt
);
41 if (!ndo
->ndo_qflag
) {
42 ND_PRINT((ndo
, "V.%d DLT %s (%d) len %d", hdr
->ppi_ver
,
43 (dltname
!= NULL
? dltname
: "UNKNOWN"), dlt
,
46 ND_PRINT((ndo
, "%s", (dltname
!= NULL
? dltname
: "UNKNOWN")));
49 ND_PRINT((ndo
, ", length %u: ", length
));
53 ppi_print(netdissect_options
*ndo
,
54 const struct pcap_pkthdr
*h
, const u_char
*p
)
57 const ppi_header_t
*hdr
;
58 u_int caplen
= h
->caplen
;
59 u_int length
= h
->len
;
63 struct pcap_pkthdr nhdr
;
65 if (caplen
< sizeof(ppi_header_t
)) {
66 ND_PRINT((ndo
, "[|ppi]"));
70 hdr
= (const ppi_header_t
*)p
;
71 ND_TCHECK_16BITS(&hdr
->ppi_len
);
72 len
= EXTRACT_LE_16BITS(&hdr
->ppi_len
);
75 * If we don't have the entire PPI header, don't
78 ND_PRINT((ndo
, "[|ppi]"));
81 if (len
< sizeof(ppi_header_t
)) {
82 ND_PRINT((ndo
, "[|ppi]"));
85 ND_TCHECK_32BITS(&hdr
->ppi_dlt
);
86 dlt
= EXTRACT_LE_32BITS(&hdr
->ppi_dlt
);
89 ppi_header_print(ndo
, p
, length
);
95 if ((printer
= lookup_printer(dlt
)) != NULL
) {
99 hdrlen
= printer(ndo
, &nhdr
, p
);
102 ppi_header_print(ndo
, (const u_char
*)hdr
, length
+ len
);
104 if (!ndo
->ndo_suppress_default_print
)
105 ND_DEFAULTPRINT(p
, caplen
);
108 return (len
+ hdrlen
);
114 * This is the top level routine of the printer. 'p' points
115 * to the ether header of the packet, 'h->ts' is the timestamp,
116 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
117 * is the number of bytes actually captured.
120 ppi_if_print(netdissect_options
*ndo
,
121 const struct pcap_pkthdr
*h
, const u_char
*p
)
123 return (ppi_print(ndo
, h
, p
));
128 * c-style: whitesmith