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