Wireshark-dev: [Wireshark-dev] Fields with symbolic values defined in another file

From: Javier Godoy <mail@xxxxxxxxxxxxxx>
Date: Tue, 23 Jul 2013 06:44:06 -0300
In the SCSI dissector, I would like to add support for the OSD attribute identification sense data descriptor.
The descriptor is a list of attribute page and attribute number fields.

The code would be added to dissect_scsi_descriptor_snsinfo in packet-scsi.c because the SCSI dissector does not forward sense data to the sub-dissector. My issue is that symbolic names for attribute pages and attribute numbers are defined in packet-scsi-osd.c (page names are just a string_value array, and attribute number names are given by function osd_lookup_attribute).

What approach do you recommend for including the attribute names in the fields of the sense data descriptor?

For reference, in packet-scsi-osd.c the fields that represent page/number values are defined as
{ &hf_scsi_osd_attributes_page,
  {"Attributes Page", "scsi_osd.attributes.page", FT_UINT32, BASE_HEX,
     VALS(attributes_page_vals), 0, NULL, HFILL}},
{ &hf_scsi_osd_attribute_number,
  {"Attribute Number", "scsi_osd.attribute.number", FT_UINT32, BASE_HEX, 
    NULL, 0, NULL, HFILL}},
 
And they are dissected as:
  const attribute_page_numbers_t *apn;
  proto_item *item;
  item=proto_tree_add_item(tt, hf_scsi_osd_attribute_number, tvb, offset, 4, ENC_BIG_ENDIAN);
  apn= osd_lookup_attribute(page,number);
  if (!apn) {
  expert_add_info(pinfo, item, &ei_osd_attr_unknown);
  proto_item_append_text(item, " (Unknown)");
  } else {
  proto_item_append_text(item, " (%s)", apn->name);
  }


Best Regards

Javier