5 /* \summary: Oracle DLT_PPI printer */
11 #include "netdissect-stdinc.h"
13 #include "netdissect.h"
16 static const char tstr
[] = "[|ppi]";
18 typedef struct ppi_header
{
30 ppi_header_print(netdissect_options
*ndo
, const u_char
*bp
, u_int length
)
32 const ppi_header_t
*hdr
;
37 hdr
= (const ppi_header_t
*)bp
;
39 len
= EXTRACT_LE_U_2(hdr
->ppi_len
);
40 dlt
= EXTRACT_LE_U_4(hdr
->ppi_dlt
);
41 dltname
= pcap_datalink_val_to_name(dlt
);
43 if (!ndo
->ndo_qflag
) {
44 ND_PRINT("V.%u DLT %s (%u) len %u", EXTRACT_U_1(hdr
->ppi_ver
),
45 (dltname
!= NULL
? dltname
: "UNKNOWN"), dlt
,
48 ND_PRINT("%s", (dltname
!= NULL
? dltname
: "UNKNOWN"));
51 ND_PRINT(", length %u: ", length
);
55 ppi_print(netdissect_options
*ndo
,
56 const struct pcap_pkthdr
*h
, const u_char
*p
)
59 const ppi_header_t
*hdr
;
60 u_int caplen
= h
->caplen
;
61 u_int length
= h
->len
;
65 struct pcap_pkthdr nhdr
;
67 ndo
->ndo_protocol
= "ppi";
68 if (caplen
< sizeof(ppi_header_t
)) {
69 ND_PRINT(" %s", tstr
);
73 hdr
= (const ppi_header_t
*)p
;
74 ND_TCHECK_2(hdr
->ppi_len
);
75 len
= EXTRACT_LE_U_2(hdr
->ppi_len
);
78 * If we don't have the entire PPI header, don't
81 ND_PRINT(" %s", tstr
);
84 if (len
< sizeof(ppi_header_t
)) {
85 ND_PRINT(" %s", tstr
);
88 ND_TCHECK_4(hdr
->ppi_dlt
);
89 dlt
= EXTRACT_LE_U_4(hdr
->ppi_dlt
);
92 ppi_header_print(ndo
, p
, length
);
98 if ((printer
= lookup_printer(dlt
)) != NULL
) {
100 nhdr
.caplen
= caplen
;
102 hdrlen
= printer(ndo
, &nhdr
, p
);
105 ppi_header_print(ndo
, (const u_char
*)hdr
, length
+ len
);
107 if (!ndo
->ndo_suppress_default_print
)
108 ND_DEFAULTPRINT(p
, caplen
);
111 return (len
+ hdrlen
);
117 * This is the top level routine of the printer. 'p' points
118 * to the ether header of the packet, 'h->ts' is the timestamp,
119 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
120 * is the number of bytes actually captured.
123 ppi_if_print(netdissect_options
*ndo
,
124 const struct pcap_pkthdr
*h
, const u_char
*p
)
126 ndo
->ndo_protocol
= "ppi_if";
127 return (ppi_print(ndo
, h
, p
));