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
= EXTRACT_LE_U_2(hdr
->ppi_len
);
39 dlt
= EXTRACT_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", EXTRACT_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
= EXTRACT_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
= EXTRACT_LE_U_4(hdr
->ppi_dlt
);
91 ppi_header_print(ndo
, p
, length
);
97 if ((printer
= lookup_printer(dlt
)) != NULL
) {
101 hdrlen
= printer(ndo
, &nhdr
, p
);
104 ppi_header_print(ndo
, (const u_char
*)hdr
, length
+ len
);
106 if (!ndo
->ndo_suppress_default_print
)
107 ND_DEFAULTPRINT(p
, caplen
);
110 return (len
+ hdrlen
);
116 * This is the top level routine of the printer. 'p' points
117 * to the ether header of the packet, 'h->ts' is the timestamp,
118 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
119 * is the number of bytes actually captured.
122 ppi_if_print(netdissect_options
*ndo
,
123 const struct pcap_pkthdr
*h
, const u_char
*p
)
125 ndo
->ndo_protocol
= "ppi_if";
126 return (ppi_print(ndo
, h
, p
));