5 /* \summary: Oracle DLT_PPI printer */
11 #include "netdissect-stdinc.h"
13 #include "netdissect.h"
17 typedef struct ppi_header
{
29 ppi_header_print(netdissect_options
*ndo
, const u_char
*bp
, u_int length
)
31 const ppi_header_t
*hdr
;
36 hdr
= (const ppi_header_t
*)bp
;
38 len
= GET_LE_U_2(hdr
->ppi_len
);
39 dlt
= GET_LE_U_4(hdr
->ppi_dlt
);
40 dltname
= pcap_datalink_val_to_name(dlt
);
42 if (!ndo
->ndo_qflag
) {
43 ND_PRINT("V.%u DLT %s (%u) len %u", GET_U_1(hdr
->ppi_ver
),
44 (dltname
!= NULL
? dltname
: "UNKNOWN"), dlt
,
47 ND_PRINT("%s", (dltname
!= NULL
? dltname
: "UNKNOWN"));
50 ND_PRINT(", length %u: ", length
);
54 ppi_print(netdissect_options
*ndo
,
55 const struct pcap_pkthdr
*h
, const u_char
*p
)
58 const ppi_header_t
*hdr
;
59 u_int caplen
= h
->caplen
;
60 u_int length
= h
->len
;
64 struct pcap_pkthdr nhdr
;
66 ndo
->ndo_protocol
= "ppi";
67 if (caplen
< sizeof(ppi_header_t
)) {
72 hdr
= (const ppi_header_t
*)p
;
73 ND_TCHECK_2(hdr
->ppi_len
);
74 len
= GET_LE_U_2(hdr
->ppi_len
);
77 * If we don't have the entire PPI header, don't
83 if (len
< sizeof(ppi_header_t
)) {
87 ND_TCHECK_4(hdr
->ppi_dlt
);
88 dlt
= GET_LE_U_4(hdr
->ppi_dlt
);
91 ppi_header_print(ndo
, p
, length
);
97 printer
= lookup_printer(ndo
, dlt
);
98 if (printer
.printer
!= NULL
) {
100 nhdr
.caplen
= caplen
;
102 if (ndo
->ndo_void_printer
== TRUE
) {
103 printer
.void_printer(ndo
, &nhdr
, p
);
104 hdrlen
= ndo
->ndo_ll_header_length
;
106 hdrlen
= printer
.uint_printer(ndo
, &nhdr
, p
);
109 ppi_header_print(ndo
, (const u_char
*)hdr
, length
+ len
);
111 if (!ndo
->ndo_suppress_default_print
)
112 ND_DEFAULTPRINT(p
, caplen
);
115 return (len
+ hdrlen
);
121 * This is the top level routine of the printer. 'p' points
122 * to the ether header of the packet, 'h->ts' is the timestamp,
123 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
124 * is the number of bytes actually captured.
127 ppi_if_print(netdissect_options
*ndo
,
128 const struct pcap_pkthdr
*h
, const u_char
*p
)
130 ndo
->ndo_protocol
= "ppi_if";
131 return (ppi_print(ndo
, h
, p
));