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 if (caplen
< sizeof(ppi_header_t
)) {
68 ND_PRINT(" %s", tstr
);
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
80 ND_PRINT(" %s", tstr
);
83 if (len
< sizeof(ppi_header_t
)) {
84 ND_PRINT(" %s", tstr
);
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 return (ppi_print(ndo
, h
, p
));
130 * c-style: whitesmith