diff options
author | Guy Harris <guy@alum.mit.edu> | 2019-03-23 00:35:23 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2019-03-23 20:30:00 +0000 |
commit | ed23cfba226b6e21f3e97147f19e617bddc0c5e9 (patch) | |
tree | e0ffd7fd6e62029fff4da51209f2a9e9b6334b46 /wiretap | |
parent | 80d96e91d248af40b50969702a0e5aafb7132376 (diff) |
Clean up IPMB/I2C link-layer header types.
209 is LINKTYPE_IPMB_LINUX; add _LINUX/_linux to the WTAP_ENCAP_ name
and function/structure names, to clarify that it's not I2C in general,
it's I2C with a particular pseudo-header.
199 is now LINKTYPE_IPMB_KONTRON, not LINKTYPE_IPMB, as it doesn't have
raw I2C packets, it has I2C packets with a pseudo-header. Change the
WTAP_ENCAP_ name, and add a dissector for it.
Change-Id: Ie097f4317b03d2b2adfd9b81a4b11caf6268399e
Reviewed-on: https://code.wireshark.org/review/32539
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/pcap-common.c | 59 | ||||
-rw-r--r-- | wiretap/wtap.c | 8 | ||||
-rw-r--r-- | wiretap/wtap.h | 4 |
3 files changed, 36 insertions, 35 deletions
diff --git a/wiretap/pcap-common.c b/wiretap/pcap-common.c index a758e5cef0..48ea4e00d9 100644 --- a/wiretap/pcap-common.c +++ b/wiretap/pcap-common.c @@ -347,8 +347,8 @@ static const struct { { 196, WTAP_ENCAP_SITA }, /* Endace Record File Encapsulation */ { 197, WTAP_ENCAP_ERF }, - /* IPMB */ - { 199, WTAP_ENCAP_IPMB }, + /* IPMB/I2C with Kontron pseudo-header */ + { 199, WTAP_ENCAP_IPMB_KONTRON }, /* Juniper-private data link type, used for capturing data on a secure tunnel interface. */ { 200, WTAP_ENCAP_JUNIPER_ST }, /* Bluetooth HCI UART transport (part H:4) frames, like hcidump */ @@ -359,8 +359,8 @@ static const struct { { 203, WTAP_ENCAP_LAPD }, /* PPP with pseudoheader */ { 204, WTAP_ENCAP_PPP_WITH_PHDR }, - /* IPMB/I2C */ - { 209, WTAP_ENCAP_I2C }, + /* IPMB/I2C with a Linux-specific header (defined by Pigeon Point Systems) */ + { 209, WTAP_ENCAP_I2C_LINUX }, /* FlexRay frame */ { 210, WTAP_ENCAP_FLEXRAY }, /* MOST frame */ @@ -1629,20 +1629,21 @@ pcap_write_erf_pseudoheader(wtap_dumper *wdh, } /* - * I2C link-layer on-disk format + * I2C-with=Linux-pseudoheader link-layer on-disk format, as defined by + * Pigeon Point Systems. */ -struct i2c_file_hdr { +struct i2c_linux_file_hdr { guint8 bus; guint8 flags[4]; }; static int -pcap_read_i2c_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, +pcap_read_i2c_linux_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, guint packet_size, int *err, gchar **err_info) { - struct i2c_file_hdr i2c_hdr; + struct i2c_linux_file_hdr i2c_linux_hdr; - if (packet_size < sizeof (struct i2c_file_hdr)) { + if (packet_size < sizeof (struct i2c_linux_file_hdr)) { /* * Uh-oh, the packet isn't big enough to even * have a pseudo-header. @@ -1652,32 +1653,32 @@ pcap_read_i2c_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, packet_size); return -1; } - if (!wtap_read_bytes(fh, &i2c_hdr, sizeof (i2c_hdr), err, err_info)) + if (!wtap_read_bytes(fh, &i2c_linux_hdr, sizeof (i2c_linux_hdr), err, err_info)) return -1; - pseudo_header->i2c.is_event = i2c_hdr.bus & 0x80 ? 1 : 0; - pseudo_header->i2c.bus = i2c_hdr.bus & 0x7f; - pseudo_header->i2c.flags = pntoh32(&i2c_hdr.flags); + pseudo_header->i2c.is_event = i2c_linux_hdr.bus & 0x80 ? 1 : 0; + pseudo_header->i2c.bus = i2c_linux_hdr.bus & 0x7f; + pseudo_header->i2c.flags = pntoh32(&i2c_linux_hdr.flags); - return (int)sizeof (struct i2c_file_hdr); + return (int)sizeof (struct i2c_linux_file_hdr); } static gboolean -pcap_write_i2c_pseudoheader(wtap_dumper *wdh, +pcap_write_i2c_linux_pseudoheader(wtap_dumper *wdh, const union wtap_pseudo_header *pseudo_header, int *err) { - struct i2c_file_hdr i2c_hdr; + struct i2c_linux_file_hdr i2c_linux_hdr; /* - * Write the I2C header. + * Write the I2C Linux-specific pseudo-header. */ - memset(&i2c_hdr, 0, sizeof(i2c_hdr)); - i2c_hdr.bus = pseudo_header->i2c.bus | + memset(&i2c_linux_hdr, 0, sizeof(i2c_linux_hdr)); + i2c_linux_hdr.bus = pseudo_header->i2c.bus | (pseudo_header->i2c.is_event ? 0x80 : 0x00); - phtonl((guint8 *)&i2c_hdr.flags, pseudo_header->i2c.flags); - if (!wtap_dump_file_write(wdh, &i2c_hdr, sizeof(i2c_hdr), err)) + phtonl((guint8 *)&i2c_linux_hdr.flags, pseudo_header->i2c.flags); + if (!wtap_dump_file_write(wdh, &i2c_linux_hdr, sizeof(i2c_linux_hdr), err)) return FALSE; - wdh->bytes_dumped += sizeof(i2c_hdr); + wdh->bytes_dumped += sizeof(i2c_linux_hdr); return TRUE; } @@ -2233,8 +2234,8 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, return -1; /* Read error */ break; - case WTAP_ENCAP_I2C: - phdr_len = pcap_read_i2c_pseudoheader(fh, + case WTAP_ENCAP_I2C_LINUX: + phdr_len = pcap_read_i2c_linux_pseudoheader(fh, &rec->rec_header.packet_header.pseudo_header, packet_size, err, err_info); if (phdr_len == -1) @@ -2336,7 +2337,7 @@ wtap_encap_requires_phdr(int wtap_encap) case WTAP_ENCAP_NFC_LLCP: case WTAP_ENCAP_PPP_WITH_PHDR: case WTAP_ENCAP_ERF: - case WTAP_ENCAP_I2C: + case WTAP_ENCAP_I2C_LINUX: return TRUE; } return FALSE; @@ -2436,8 +2437,8 @@ pcap_get_phdr_size(int encap, const union wtap_pseudo_header *pseudo_header) } break; - case WTAP_ENCAP_I2C: - hdrsize = (int)sizeof (struct i2c_file_hdr); + case WTAP_ENCAP_I2C_LINUX: + hdrsize = (int)sizeof (struct i2c_linux_file_hdr); break; default: @@ -2504,8 +2505,8 @@ pcap_write_phdr(wtap_dumper *wdh, int encap, const union wtap_pseudo_header *pse return FALSE; break; - case WTAP_ENCAP_I2C: - if (!pcap_write_i2c_pseudoheader(wdh, pseudo_header, err)) + case WTAP_ENCAP_I2C_LINUX: + if (!pcap_write_i2c_linux_pseudoheader(wdh, pseudo_header, err)) return FALSE; break; } diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 36866a23cd..26bea65313 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -660,8 +660,8 @@ static struct encap_type_info encap_table_base[] = { /* WTAP_ENCAP_BLUETOOTH_HCI */ { "bluetooth-hci", "Bluetooth without transport layer" }, - /* WTAP_ENCAP_IPMB */ - { "ipmb", "Intelligent Platform Management Bus" }, + /* WTAP_ENCAP_IPMB_KONTRON */ + { "ipmb-kontron", "Intelligent Platform Management Bus with Kontron pseudo-header" }, /* WTAP_ENCAP_IEEE802_15_4 */ { "wpan", "IEEE 802.15.4 Wireless PAN" }, @@ -687,8 +687,8 @@ static struct encap_type_info encap_table_base[] = { /* WTAP_ENCAP_X2E_SERIAL */ { "x2e-serial", "X2E serial line capture" }, - /* WTAP_ENCAP_I2C */ - { "i2c", "I2C" }, + /* WTAP_ENCAP_I2C_LINUX */ + { "i2c-linux", "I2C with Linux-specific pseudo-header" }, /* WTAP_ENCAP_IEEE802_15_4_NONASK_PHY */ { "wpan-nonask-phy", "IEEE 802.15.4 Wireless PAN non-ASK PHY" }, diff --git a/wiretap/wtap.h b/wiretap/wtap.h index fbb7168f17..39eb7cae19 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -183,7 +183,7 @@ extern "C" { #define WTAP_ENCAP_SITA 100 #define WTAP_ENCAP_SCCP 101 #define WTAP_ENCAP_BLUETOOTH_HCI 102 /*raw packets without a transport layer header e.g. H4*/ -#define WTAP_ENCAP_IPMB 103 +#define WTAP_ENCAP_IPMB_KONTRON 103 #define WTAP_ENCAP_IEEE802_15_4 104 #define WTAP_ENCAP_X2E_XORAYA 105 #define WTAP_ENCAP_FLEXRAY 106 @@ -192,7 +192,7 @@ extern "C" { #define WTAP_ENCAP_CAN20B 109 #define WTAP_ENCAP_LAYER1_EVENT 110 #define WTAP_ENCAP_X2E_SERIAL 111 -#define WTAP_ENCAP_I2C 112 +#define WTAP_ENCAP_I2C_LINUX 112 #define WTAP_ENCAP_IEEE802_15_4_NONASK_PHY 113 #define WTAP_ENCAP_TNEF 114 #define WTAP_ENCAP_USB_LINUX_MMAPPED 115 |