JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Oracle |
| 3 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 4 | |
| 5 | /* \summary: Oracle DLT_PPI printer */ |
| 6 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 7 | #ifdef HAVE_CONFIG_H |
| 8 | #include "config.h" |
| 9 | #endif |
| 10 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 11 | #include <netdissect-stdinc.h> |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 12 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 13 | #include "netdissect.h" |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 14 | #include "extract.h" |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 15 | |
| 16 | typedef struct ppi_header { |
| 17 | uint8_t ppi_ver; |
| 18 | uint8_t ppi_flags; |
| 19 | uint16_t ppi_len; |
| 20 | uint32_t ppi_dlt; |
| 21 | } ppi_header_t; |
| 22 | |
| 23 | #define PPI_HDRLEN 8 |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 24 | |
| 25 | #ifdef DLT_PPI |
| 26 | |
| 27 | static inline void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 28 | ppi_header_print(netdissect_options *ndo, const u_char *bp, u_int length) |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 29 | { |
| 30 | const ppi_header_t *hdr; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 31 | uint16_t len; |
| 32 | uint32_t dlt; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 33 | const char *dltname; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 34 | |
| 35 | hdr = (const ppi_header_t *)bp; |
| 36 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 37 | len = EXTRACT_LE_16BITS(&hdr->ppi_len); |
| 38 | dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 39 | dltname = pcap_datalink_val_to_name(dlt); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 40 | |
| 41 | if (!ndo->ndo_qflag) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 42 | ND_PRINT((ndo, "V.%d DLT %s (%d) len %d", hdr->ppi_ver, |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 43 | (dltname != NULL ? dltname : "UNKNOWN"), dlt, |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 44 | len)); |
| 45 | } else { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 46 | ND_PRINT((ndo, "%s", (dltname != NULL ? dltname : "UNKNOWN"))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | ND_PRINT((ndo, ", length %u: ", length)); |
| 50 | } |
| 51 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 52 | static u_int |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 53 | ppi_print(netdissect_options *ndo, |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 54 | const struct pcap_pkthdr *h, const u_char *p) |
| 55 | { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 56 | if_printer printer; |
| 57 | const ppi_header_t *hdr; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 58 | u_int caplen = h->caplen; |
| 59 | u_int length = h->len; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 60 | uint16_t len; |
| 61 | uint32_t dlt; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 62 | uint32_t hdrlen; |
| 63 | struct pcap_pkthdr nhdr; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 64 | |
| 65 | if (caplen < sizeof(ppi_header_t)) { |
| 66 | ND_PRINT((ndo, "[|ppi]")); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 67 | return (caplen); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 68 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 69 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 70 | hdr = (const ppi_header_t *)p; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 71 | len = EXTRACT_LE_16BITS(&hdr->ppi_len); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 72 | if (caplen < len) { |
| 73 | /* |
| 74 | * If we don't have the entire PPI header, don't |
| 75 | * bother. |
| 76 | */ |
| 77 | ND_PRINT((ndo, "[|ppi]")); |
| 78 | return (caplen); |
| 79 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 80 | if (len < sizeof(ppi_header_t)) { |
| 81 | ND_PRINT((ndo, "[|ppi]")); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 82 | return (len); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 83 | } |
| 84 | dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 85 | |
| 86 | if (ndo->ndo_eflag) |
| 87 | ppi_header_print(ndo, p, length); |
| 88 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 89 | length -= len; |
| 90 | caplen -= len; |
| 91 | p += len; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 92 | |
| 93 | if ((printer = lookup_printer(dlt)) != NULL) { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 94 | nhdr = *h; |
| 95 | nhdr.caplen = caplen; |
| 96 | nhdr.len = length; |
| 97 | hdrlen = printer(ndo, &nhdr, p); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 98 | } else { |
| 99 | if (!ndo->ndo_eflag) |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 100 | ppi_header_print(ndo, (const u_char *)hdr, length + len); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 101 | |
| 102 | if (!ndo->ndo_suppress_default_print) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 103 | ND_DEFAULTPRINT(p, caplen); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 104 | hdrlen = 0; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 105 | } |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 106 | return (len + hdrlen); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | /* |
| 110 | * This is the top level routine of the printer. 'p' points |
| 111 | * to the ether header of the packet, 'h->ts' is the timestamp, |
| 112 | * 'h->len' is the length of the packet off the wire, and 'h->caplen' |
| 113 | * is the number of bytes actually captured. |
| 114 | */ |
| 115 | u_int |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 116 | ppi_if_print(netdissect_options *ndo, |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 117 | const struct pcap_pkthdr *h, const u_char *p) |
| 118 | { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 119 | return (ppi_print(ndo, h, p)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | /* |
| 123 | * Local Variables: |
| 124 | * c-style: whitesmith |
| 125 | * c-basic-offset: 8 |
| 126 | * End: |
| 127 | */ |
| 128 | |
| 129 | #endif /* DLT_PPI */ |