Wireshark-dev: Re: [Wireshark-dev] new dissector - dynamic value string table?

Date: Thu, 28 Feb 2013 12:29:05 +0200
Hi Max,

> On the first question of detecting the camera type, it looks like the
> information I need is captured by packet-usb.c (emem_tree_t
> *device_to_product_table) -- however it's not exported.   I will need to
> add a way of getting access to this tree from the new dissector.

I guess you do not want to export it. Instead, you can extent private_info in packet.usb.c for exporting vendor_id/product_id (etc.)  to higher protocol (see packet-hci_usb.c).

As I understand correctly you also need to do something like that:
static const value_string vendor_xxx_specific_vals[] = {
    {0x0001, "A"},
    {0x0401, "B"},
    {0x0402, "C"},
    {0, NULL}
};

static const value_string generic_vals[] = {
    {0x0001, "A"},
    {0x0401, "X"},
    {0x0555, "O"},
    {0, NULL}
};

/*...*/

gchar *unknown_key = "Unknown";
gchar *value;

for (i=0;i <vendors; i+= 1) {
    value = val_to_str_const(vendor_key, vendor_xxx_specific_vals, unknown_key);
    if (value == unknown_key) {
        value = val_to_str_const(vendor_key, generic_vals, unknown_key);
        hf = hf_generic;
    } else {
    hf = hf_vendor_xxx
    }
}

proto

/*...*/

{ &hf_vendor_xxx_type,
    { "Something", "usb.xxx.something",
    FT_UINT16, BASE_HEX, VALS(vendor_xxx_specific_vals), 0x00,
    NULL, HFILL }
},
{ &hf_generic_type,
    { "Something", "usb.xxx.something",
    FT_UINT16, BASE_HEX, VALS(generic_vals), 0x00,
    NULL, HFILL }
},

See also "hf_usb_idProduct". It use table created by merge vendor id and product id in one key.


Pozdrawiam / Best regards
-------------------------------------------------------------------------------------------------------------
Michał Łabędzki, Software Engineer
Tieto Corporation
Product Engineering Services
http://www.tieto.com / http://www.tieto.pl
---
ASCII: Michal Labedzki
e-mail: michal.labedzki@xxxxxxxxx
location: Swobodna 1 Street, 50-088 Wrocław, Poland
desk: 5.021
---
Please note: The information contained in this message may be legally privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, you are hereby notified that any unauthorised use, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank You.
---
Please consider the environment before printing this e-mail.
---
Tieto Poland spółka z ograniczoną odpowiedzialnością z siedzibą w Szczecinie, ul. Malczewskiego 26. Zarejestrowana w Sądzie Rejonowym Szczecin-Centrum w Szczecinie, XIII Wydział Gospodarczy Krajowego Rejestru Sądowego pod numerem 0000124858. NIP: 8542085557. REGON: 812023656. Kapitał zakładowy: 4 271500 PLN