| File: | builds/wireshark/wireshark/epan/dissectors/packet-i2c.c |
| Warning: | line 322, column 3 Value stored to 'ti' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* packet-i2c.c |
| 2 | * Routines for I2C captures (using libpcap extensions) |
| 3 | * |
| 4 | * Pigeon Point Systems <www.pigeonpoint.com> |
| 5 | * |
| 6 | * Wireshark - Network traffic analyzer |
| 7 | * By Gerald Combs <gerald@wireshark.org> |
| 8 | * Copyright 1998 Gerald Combs |
| 9 | * |
| 10 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 11 | */ |
| 12 | |
| 13 | #include "config.h" |
| 14 | |
| 15 | #include <epan/packet.h> |
| 16 | #include <epan/capture_dissectors.h> |
| 17 | #include <epan/expert.h> |
| 18 | #include <epan/prefs.h> |
| 19 | #include <epan/decode_as.h> |
| 20 | #include <epan/tfs.h> |
| 21 | #include <epan/proto_data.h> |
| 22 | #include "packet-i2c.h" |
| 23 | |
| 24 | void proto_register_i2c(void); |
| 25 | void proto_reg_handoff_i2c(void); |
| 26 | |
| 27 | static dissector_handle_t i2c_linux_handle; |
| 28 | static capture_dissector_handle_t i2c_linux_cap_handle; |
| 29 | static dissector_handle_t i2c_kontron_handle; |
| 30 | |
| 31 | static int proto_i2c; |
| 32 | static int proto_i2c_event; |
| 33 | static int proto_i2c_data; |
| 34 | |
| 35 | |
| 36 | static int hf_i2c_bus; |
| 37 | static int hf_i2c_event; |
| 38 | static int hf_i2c_flags; |
| 39 | static int hf_i2c_flags_rd; |
| 40 | static int hf_i2c_addr; |
| 41 | |
| 42 | static int ett_i2c; |
| 43 | static int ett_i2c_flags; |
| 44 | |
| 45 | static expert_field ei_i2c_record_too_short; |
| 46 | |
| 47 | static dissector_table_t subdissector_table; |
| 48 | static heur_dissector_list_t i2c_heur_subdissector_list; |
| 49 | |
| 50 | static dissector_handle_t ipmb_handle; |
| 51 | |
| 52 | #define I2C_PROTO_DATA_MESSAGE0 0 |
| 53 | |
| 54 | const i2c_message_data * |
| 55 | i2c_message_data_get(packet_info *pinfo) |
| 56 | { |
| 57 | return (const i2c_message_data *)p_get_proto_data(pinfo->pool, pinfo, |
| 58 | proto_i2c, I2C_PROTO_DATA_MESSAGE0); |
| 59 | } |
| 60 | |
| 61 | #define I2C_FLAG_RD0x00000001 0x00000001 |
| 62 | |
| 63 | /* I2C events. */ |
| 64 | #define I2C_EVENT_PROM_ON(1 << 0) (1 << 0) /* Promiscuous mode: on */ |
| 65 | #define I2C_EVENT_PROM_OFF(1 << 1) (1 << 1) /* Promiscuous mode: off */ |
| 66 | #define I2C_EVENT_ONLINE_ON(1 << 2) (1 << 2) /* Online state: on */ |
| 67 | #define I2C_EVENT_ONLINE_OFF(1 << 3) (1 << 3) /* Online state: off */ |
| 68 | #define I2C_EVENT_ATTACHED_ON(1 << 4) (1 << 4) /* Attached state: on */ |
| 69 | #define I2C_EVENT_ATTACHED_OFF(1 << 5) (1 << 5) /* Attached state: off */ |
| 70 | #define I2C_EVENT_PROM_OVFL_ON(1 << 6) (1 << 6) /* Prom. queue overflow: on */ |
| 71 | #define I2C_EVENT_PROM_OVFL_OFF(1 << 7) (1 << 7) /* Prom. queue overflow: off */ |
| 72 | #define I2C_EVENT_OVFL_ON(1 << 8) (1 << 8) /* Queue overflow: on */ |
| 73 | #define I2C_EVENT_OVFL_OFF(1 << 9) (1 << 9) /* Queue overflow: off */ |
| 74 | |
| 75 | /* I2C errors. */ |
| 76 | #define I2C_EVENT_ERR_DATA_LO(1 << 16) (1 << 16) /* Unable to drive data LO */ |
| 77 | #define I2C_EVENT_ERR_DATA_HI(1 << 17) (1 << 17) /* Unable to drive data HI */ |
| 78 | #define I2C_EVENT_ERR_CLOCK_LO(1 << 18) (1 << 18) /* Unable to drive clock LO */ |
| 79 | #define I2C_EVENT_ERR_CLOCK_HI(1 << 19) (1 << 19) /* Unable to drive clock HI */ |
| 80 | #define I2C_EVENT_ERR_CLOCK_TO(1 << 20) (1 << 20) /* Clock low timeout */ |
| 81 | #define I2C_EVENT_ERR_PHYS(1 << 21) (1 << 21) /* The I2C bus controller |
| 82 | has been physically |
| 83 | disconnected from the bus */ |
| 84 | #define I2C_EVENT_ERR_FAIL(1 << 22) (1 << 22) /* Undiagnosed failure */ |
| 85 | |
| 86 | static void i2c_prompt(packet_info *pinfo _U___attribute__((unused)), char* result) |
| 87 | { |
| 88 | snprintf(result, MAX_DECODE_AS_PROMPT_LEN200, "Interpret I2C messages as"); |
| 89 | } |
| 90 | |
| 91 | static bool_Bool |
| 92 | capture_i2c_linux(const unsigned char *pd _U___attribute__((unused)), int offset _U___attribute__((unused)), int len _U___attribute__((unused)), capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header) |
| 93 | { |
| 94 | if (pseudo_header->i2c.is_event) { |
| 95 | capture_dissector_increment_count(cpinfo, proto_i2c_event); |
| 96 | } else { |
| 97 | capture_dissector_increment_count(cpinfo, proto_i2c_data); |
| 98 | } |
| 99 | |
| 100 | return true1; |
| 101 | } |
| 102 | |
| 103 | static const char * |
| 104 | i2c_linux_get_event_desc(uint32_t event) |
| 105 | { |
| 106 | const char *desc; |
| 107 | |
| 108 | switch (event & 0x0000ffff) { |
| 109 | case I2C_EVENT_PROM_ON(1 << 0): |
| 110 | desc = "Promiscuous mode is enabled"; |
| 111 | break; |
| 112 | case I2C_EVENT_PROM_OFF(1 << 1): |
| 113 | desc = "Promiscuous mode is disabled"; |
| 114 | break; |
| 115 | case I2C_EVENT_ONLINE_ON(1 << 2): |
| 116 | desc = "The I2C controller is operational"; |
| 117 | break; |
| 118 | case I2C_EVENT_ONLINE_OFF(1 << 3): |
| 119 | desc = "The I2C controller is non-operational"; |
| 120 | /* The upper-order error bits belong to the offline event. */ |
| 121 | if (event & I2C_EVENT_ERR_DATA_LO(1 << 16)) { |
| 122 | desc = "The I2C controller is non-operational: " |
| 123 | "unable to drive data LO"; |
| 124 | } else if (event & I2C_EVENT_ERR_DATA_HI(1 << 17)) { |
| 125 | desc = "The I2C controller is non-operational: " |
| 126 | "unable to drive data HI"; |
| 127 | } else if (event & I2C_EVENT_ERR_CLOCK_LO(1 << 18)) { |
| 128 | desc = "The I2C controller is non-operational: " |
| 129 | "unable to drive clock LO"; |
| 130 | } else if (event & I2C_EVENT_ERR_CLOCK_HI(1 << 19)) { |
| 131 | desc = "The I2C controller is non-operational: " |
| 132 | "unable to drive clock HI"; |
| 133 | } else if (event & I2C_EVENT_ERR_CLOCK_TO(1 << 20)) { |
| 134 | desc = "The I2C controller is non-operational: " |
| 135 | "clock low timeout"; |
| 136 | } else if (event & I2C_EVENT_ERR_PHYS(1 << 21)) { |
| 137 | desc = "The I2C controller is non-operational: " |
| 138 | "the I2C bus controller has been " |
| 139 | "physically disconnected from the bus"; |
| 140 | } else if (event & I2C_EVENT_ERR_FAIL(1 << 22)) { |
| 141 | desc = "The I2C controller is non-operational: " |
| 142 | "undiagnosed failure"; |
| 143 | } |
| 144 | break; |
| 145 | case I2C_EVENT_ATTACHED_ON(1 << 4): |
| 146 | desc = "The I2C controller is attached to an I2C bus"; |
| 147 | break; |
| 148 | case I2C_EVENT_ATTACHED_OFF(1 << 5): |
| 149 | desc = "The I2C controller is detached from an I2C bus"; |
| 150 | break; |
| 151 | case I2C_EVENT_PROM_OVFL_ON(1 << 6): |
| 152 | desc = "The incoming promiscuous data buffer has been overrun; " |
| 153 | "some data is lost"; |
| 154 | break; |
| 155 | case I2C_EVENT_PROM_OVFL_OFF(1 << 7): |
| 156 | desc = "The incoming promiscuous data buffer is available"; |
| 157 | break; |
| 158 | case I2C_EVENT_OVFL_ON(1 << 8): |
| 159 | desc = "The incoming I2C data buffer has been overrun; " |
| 160 | "some data is lost"; |
| 161 | break; |
| 162 | case I2C_EVENT_OVFL_OFF(1 << 9): |
| 163 | desc = "The incoming I2C data buffer is available"; |
| 164 | break; |
| 165 | default: |
| 166 | desc = "<unknown state event>"; |
| 167 | break; |
| 168 | } |
| 169 | |
| 170 | return desc; |
| 171 | } |
| 172 | |
| 173 | /* Address 00h: the General Call when writing, the START byte when reading. */ |
| 174 | static const char * |
| 175 | i2c_addr_zero_suffix(uint8_t addr, bool_Bool read) |
| 176 | { |
| 177 | if (addr != 0) |
| 178 | return ""; |
| 179 | return read ? " (START byte)" : " (General Call)"; |
| 180 | } |
| 181 | |
| 182 | static int |
| 183 | dissect_i2c_linux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U___attribute__((unused))) |
| 184 | { |
| 185 | proto_item *ti, *flags_ti; |
| 186 | proto_tree *i2c_tree, *flags_tree; |
| 187 | heur_dtbl_entry_t *hdtbl_entry; |
| 188 | uint8_t is_event; |
| 189 | uint8_t bus, addr; |
| 190 | uint32_t flags; |
| 191 | bool_Bool addr_reported; |
| 192 | bool_Bool addr_captured; |
| 193 | |
| 194 | flags = pinfo->pseudo_header->i2c.flags; |
| 195 | |
| 196 | bus = pinfo->pseudo_header->i2c.bus; |
| 197 | col_add_fstr(pinfo->cinfo, COL_DEF_SRC, "I2C-%d", bus); |
| 198 | |
| 199 | is_event = pinfo->pseudo_header->i2c.is_event; |
| 200 | addr_reported = is_event || tvb_reported_length(tvb) >= 1; |
| 201 | addr_captured = is_event || tvb_captured_length(tvb) >= 1; |
| 202 | |
| 203 | if (is_event) { |
| 204 | addr = 0; |
| 205 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "I2C Event"); |
| 206 | col_set_str(pinfo->cinfo, COL_DEF_DST, "----"); |
| 207 | col_add_str(pinfo->cinfo, COL_INFO, |
| 208 | i2c_linux_get_event_desc(flags)); |
| 209 | } else if (!addr_reported) { |
| 210 | addr = 0; |
| 211 | col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "I2C %s", |
| 212 | (flags & I2C_FLAG_RD0x00000001) ? "Read" : "Write"); |
| 213 | col_set_str(pinfo->cinfo, COL_DEF_DST, "----"); |
| 214 | col_set_str(pinfo->cinfo, COL_INFO, |
| 215 | "Record too short to contain a hardware address"); |
| 216 | } else if (!addr_captured) { |
| 217 | addr = 0; |
| 218 | col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "I2C %s", |
| 219 | (flags & I2C_FLAG_RD0x00000001) ? "Read" : "Write"); |
| 220 | col_set_str(pinfo->cinfo, COL_DEF_DST, "----"); |
| 221 | col_add_fstr(pinfo->cinfo, COL_INFO, "I2C %s, %d bytes", |
| 222 | (flags & I2C_FLAG_RD0x00000001) ? "Read" : "Write", |
| 223 | tvb_captured_length(tvb)); |
| 224 | } else { |
| 225 | /* Report 7-bit hardware address */ |
| 226 | addr = tvb_get_uint8(tvb, 0) >> 1; |
| 227 | col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "I2C %s", |
| 228 | (flags & I2C_FLAG_RD0x00000001) ? "Read" : "Write"); |
| 229 | col_add_fstr(pinfo->cinfo, COL_DEF_DST, "0x%02x", addr); |
| 230 | col_add_fstr(pinfo->cinfo, COL_INFO, "I2C %s, %d bytes", |
| 231 | (flags & I2C_FLAG_RD0x00000001) ? "Read" : "Write", tvb_captured_length(tvb)); |
| 232 | } |
| 233 | |
| 234 | pinfo->ptype = PT_I2C; |
| 235 | |
| 236 | ti = proto_tree_add_protocol_format(tree, proto_i2c, tvb, 0, -1, |
| 237 | "Inter-Integrated Circuit (%s)", |
| 238 | is_event ? "Event" : "Data"); |
| 239 | |
| 240 | i2c_tree = proto_item_add_subtree(ti, ett_i2c); |
| 241 | proto_tree_add_uint_format(i2c_tree, hf_i2c_bus, tvb, 0, 0, bus, |
| 242 | "Bus: I2C-%d", bus); |
| 243 | |
| 244 | if (is_event) { |
| 245 | proto_tree_add_uint_format_value(i2c_tree, hf_i2c_event, tvb, 0, 0, |
| 246 | flags, "%s (0x%08x)", |
| 247 | i2c_linux_get_event_desc(flags), flags); |
| 248 | } else { |
| 249 | if (addr_captured) { |
| 250 | proto_tree_add_uint_format_value(i2c_tree, hf_i2c_addr, tvb, 0, 1, |
| 251 | addr, "0x%02x%s", addr, |
| 252 | i2c_addr_zero_suffix(addr, |
| 253 | (flags & I2C_FLAG_RD0x00000001) != 0)); |
| 254 | } |
| 255 | flags_ti = proto_tree_add_uint(i2c_tree, hf_i2c_flags, tvb, 0, 0, flags); |
| 256 | flags_tree = proto_item_add_subtree(flags_ti, ett_i2c_flags); |
| 257 | proto_tree_add_boolean(flags_tree, hf_i2c_flags_rd, tvb, 0, 0, |
| 258 | flags & I2C_FLAG_RD0x00000001); |
| 259 | |
| 260 | if (!addr_reported) { |
| 261 | proto_tree_add_expert(i2c_tree, pinfo, |
| 262 | &ei_i2c_record_too_short, tvb, 0, 0); |
| 263 | return tvb_captured_length(tvb); |
| 264 | } |
| 265 | if (!addr_captured) { |
| 266 | tvb_ensure_bytes_exist(tvb, 0, 1); |
| 267 | return tvb_captured_length(tvb); |
| 268 | } |
| 269 | |
| 270 | i2c_message_data *message_data = wmem_new(pinfo->pool, i2c_message_data)((i2c_message_data*)wmem_alloc((pinfo->pool), sizeof(i2c_message_data ))); |
| 271 | message_data->bus = bus; |
| 272 | p_set_proto_data(pinfo->pool, pinfo, proto_i2c, |
| 273 | I2C_PROTO_DATA_MESSAGE0, message_data); |
| 274 | |
| 275 | if (!dissector_try_payload_with_data(subdissector_table, tvb, pinfo, tree, true1, NULL((void*)0)) && |
| 276 | !dissector_try_heuristic(i2c_heur_subdissector_list, tvb, pinfo, tree, &hdtbl_entry, NULL((void*)0))) |
| 277 | { |
| 278 | call_data_dissector(tvb, pinfo, tree); |
| 279 | } |
| 280 | } |
| 281 | return tvb_captured_length(tvb); |
| 282 | } |
| 283 | |
| 284 | /* DLT199 capture header (data length, port) plus the address octet. */ |
| 285 | #define I2C_KONTRON_MIN_LEN3 3 |
| 286 | |
| 287 | /* The shortest IPMB frame packet-ipmi.c decodes with a responder address. */ |
| 288 | #define I2C_KONTRON_MIN_IPMB_LEN7 7 |
| 289 | |
| 290 | /* IPMB-over-I2C, with Kontron pseudo-header */ |
| 291 | static int |
| 292 | dissect_i2c_kontron(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U___attribute__((unused))) |
| 293 | { |
| 294 | proto_item *ti; |
| 295 | proto_tree *i2c_tree; |
| 296 | int offset = 0; |
| 297 | unsigned reported; |
| 298 | unsigned captured; |
| 299 | uint8_t addr_octet; |
| 300 | uint8_t addr; |
| 301 | bool_Bool read; |
| 302 | tvbuff_t *new_tvb; |
| 303 | |
| 304 | col_set_str(pinfo->cinfo, COL_DEF_SRC, "I2C"); |
| 305 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "I2C"); |
| 306 | |
| 307 | reported = tvb_reported_length(tvb); |
| 308 | captured = tvb_captured_length(tvb); |
| 309 | |
| 310 | if (reported < I2C_KONTRON_MIN_LEN3) { |
| 311 | col_add_fstr(pinfo->cinfo, COL_INFO, |
| 312 | "Bogus length %u, minimum %u", reported, |
| 313 | (unsigned)I2C_KONTRON_MIN_LEN3); |
| 314 | ti = proto_tree_add_protocol_format(tree, proto_i2c, tvb, 0, -1, |
| 315 | "Inter-Integrated Circuit"); |
| 316 | i2c_tree = proto_item_add_subtree(ti, ett_i2c); |
| 317 | proto_tree_add_expert(i2c_tree, pinfo, &ei_i2c_record_too_short, |
| 318 | tvb, 0, -1); |
| 319 | return tvb_captured_length(tvb); |
| 320 | } |
| 321 | if (captured < I2C_KONTRON_MIN_LEN3) { |
| 322 | ti = proto_tree_add_protocol_format(tree, proto_i2c, tvb, 0, -1, |
Value stored to 'ti' is never read | |
| 323 | "Inter-Integrated Circuit"); |
| 324 | tvb_ensure_bytes_exist(tvb, 0, I2C_KONTRON_MIN_LEN3); |
| 325 | return tvb_captured_length(tvb); |
| 326 | } |
| 327 | |
| 328 | /* Data length field */ |
| 329 | offset++; |
| 330 | |
| 331 | /* Port number on which the message was received */ |
| 332 | offset++; |
| 333 | |
| 334 | /* DLT199: length, port, then the IPMB frame; its address octet has R/W#. */ |
| 335 | addr_octet = tvb_get_uint8(tvb, offset); |
| 336 | addr = addr_octet >> 1; |
| 337 | read = (addr_octet & 0x01) != 0; |
| 338 | col_append_fstr(pinfo->cinfo, COL_PROTOCOL, " %s", |
| 339 | read ? "Read" : "Write"); |
| 340 | col_add_fstr(pinfo->cinfo, COL_DEF_DST, "0x%02x", addr); |
| 341 | col_add_fstr(pinfo->cinfo, COL_INFO, "I2C %s, %d bytes", |
| 342 | read ? "Read" : "Write", tvb_captured_length(tvb)); |
| 343 | |
| 344 | pinfo->ptype = PT_I2C; |
| 345 | |
| 346 | ti = proto_tree_add_protocol_format(tree, proto_i2c, tvb, 0, -1, |
| 347 | "Inter-Integrated Circuit (%s)", read ? "Read" : "Write"); |
| 348 | i2c_tree = proto_item_add_subtree(ti, ett_i2c); |
| 349 | |
| 350 | proto_tree_add_uint_format_value(i2c_tree, hf_i2c_addr, tvb, offset, 1, |
| 351 | addr, "0x%02x%s", addr, |
| 352 | i2c_addr_zero_suffix(addr, read)); |
| 353 | |
| 354 | if (reported - (unsigned)offset < I2C_KONTRON_MIN_IPMB_LEN7) { |
| 355 | proto_tree_add_expert(i2c_tree, pinfo, &ei_i2c_record_too_short, |
| 356 | tvb, offset, -1); |
| 357 | return tvb_captured_length(tvb); |
| 358 | } |
| 359 | if (captured - (unsigned)offset < I2C_KONTRON_MIN_IPMB_LEN7) { |
| 360 | tvb_ensure_bytes_exist(tvb, offset, I2C_KONTRON_MIN_IPMB_LEN7); |
| 361 | return tvb_captured_length(tvb); |
| 362 | } |
| 363 | |
| 364 | new_tvb = tvb_new_subset_remaining(tvb, offset); |
| 365 | call_dissector(ipmb_handle, new_tvb, pinfo, tree); |
| 366 | return tvb_captured_length(tvb); |
| 367 | } |
| 368 | |
| 369 | void |
| 370 | proto_register_i2c(void) |
| 371 | { |
| 372 | static hf_register_info hf[] = { |
| 373 | { &hf_i2c_bus, { "Bus ID", "i2c.bus", FT_UINT8, BASE_DEC, NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 374 | { &hf_i2c_addr, { "Target address", "i2c.addr", FT_UINT8, BASE_HEX, NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 375 | { &hf_i2c_event, { "Event", "i2c.event", FT_UINT32, BASE_HEX, NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 376 | { &hf_i2c_flags, { "Flags", "i2c.flags", FT_UINT32, BASE_HEX, NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 377 | { &hf_i2c_flags_rd, { "Read", "i2c.flags.rd", FT_BOOLEAN, 32, |
| 378 | TFS(&tfs_set_notset)((0 ? (const struct true_false_string*)0 : ((&tfs_set_notset )))), I2C_FLAG_RD0x00000001, |
| 379 | "The one flag bit LINKTYPE_I2C_LINUX defines for a regular packet:" |
| 380 | " if set, the packet is a read", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 381 | }; |
| 382 | static int *ett[] = { |
| 383 | &ett_i2c, |
| 384 | &ett_i2c_flags |
| 385 | }; |
| 386 | static ei_register_info ei[] = { |
| 387 | { &ei_i2c_record_too_short, |
| 388 | { "i2c.record_too_short", PI_MALFORMED0x07000000, PI_ERROR0x00800000, |
| 389 | "Record is shorter than the fields its link type defines," |
| 390 | " so it cannot be dissected further", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE , BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0)}} }}, |
| 391 | }; |
| 392 | expert_module_t *expert_i2c; |
| 393 | module_t *m; |
| 394 | |
| 395 | proto_i2c = proto_register_protocol("Inter-Integrated Circuit", "I2C", "i2c"); |
| 396 | proto_register_field_array(proto_i2c, hf, array_length(hf)(sizeof (hf) / sizeof (hf)[0])); |
| 397 | proto_register_subtree_array(ett, array_length(ett)(sizeof (ett) / sizeof (ett)[0])); |
| 398 | |
| 399 | expert_i2c = expert_register_protocol(proto_i2c); |
| 400 | expert_register_field_array(expert_i2c, ei, array_length(ei)(sizeof (ei) / sizeof (ei)[0])); |
| 401 | |
| 402 | /* Placeholders for capture statistics */ |
| 403 | proto_i2c_event = proto_register_protocol_in_name_only("I2C Events", "I2C Events", "i2c_event", proto_i2c, FT_PROTOCOL); |
| 404 | proto_i2c_data = proto_register_protocol_in_name_only("I2C Data", "I2C Data", "i2c_data", proto_i2c, FT_PROTOCOL); |
| 405 | |
| 406 | m = prefs_register_protocol_obsolete(proto_i2c); |
| 407 | prefs_register_obsolete_preference(m, "type"); |
| 408 | |
| 409 | subdissector_table = register_decode_as_next_proto(proto_i2c, "i2c.message", "I2C messages dissector", i2c_prompt); |
| 410 | i2c_heur_subdissector_list = register_heur_dissector_list_with_description("i2c.message", "I2C message", proto_i2c); |
| 411 | |
| 412 | i2c_linux_handle = register_dissector("i2c_linux", dissect_i2c_linux, proto_i2c); |
| 413 | i2c_linux_cap_handle = register_capture_dissector("i2c_linux", capture_i2c_linux, proto_i2c); |
| 414 | i2c_kontron_handle = register_dissector("i2c_kontron", dissect_i2c_kontron, proto_i2c); |
| 415 | } |
| 416 | |
| 417 | void |
| 418 | proto_reg_handoff_i2c(void) |
| 419 | { |
| 420 | dissector_add_uint("wtap_encap", WTAP_ENCAP_I2C_LINUX112, i2c_linux_handle); |
| 421 | capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_I2C_LINUX112, i2c_linux_cap_handle); |
| 422 | |
| 423 | dissector_add_uint("wtap_encap", WTAP_ENCAP_IPMB_KONTRON103, i2c_kontron_handle); |
| 424 | |
| 425 | ipmb_handle = find_dissector("ipmb"); |
| 426 | } |
| 427 | |
| 428 | /* |
| 429 | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
| 430 | * |
| 431 | * Local variables: |
| 432 | * c-basic-offset: 8 |
| 433 | * tab-width: 8 |
| 434 | * indent-tabs-mode: t |
| 435 | * End: |
| 436 | * |
| 437 | * vi: set shiftwidth=8 tabstop=8 noexpandtab: |
| 438 | * :indentSize=8:tabSize=8:noTabs=false: |
| 439 | */ |