Wireshark mailing list archives
Re: hfinfo.string const initializer / change VALS by preference ?
From: Jakub Zawadzki <darkjames () darkjames ath cx>
Date: Fri, 18 Jun 2010 10:48:07 +0200
Hi, On Fri, Jun 18, 2010 at 09:35:02AM +0200, Harald Welte wrote:
As part of the OpenBSC project, I've been working on a dissector for the GSM A-bis OML protocol. One of the problems with this protocol is that it only specifies a set of common functions which are then extended by each vendor/implementor. This starts with the message type. There are some message types that are according to the GSM TS 12.21, and then there are vendor-specific message types. The ranges of the vendor-specific message types overlap. so let's say the spec has defined 0x01, 0x02, 0x03 and vendor A uses 0x05, 0x06, whereas vendor B uses 0x05 and 0x06 for something completely else. Thus, it is impossible to make one 'value_string' array that encompasses all the message types and their names. Luckily, I can have a preference that allows the user to select which vendor his trace uses. My idea was to use the proto_handoff() function to check the preference and then dynamically allocate (and populate) a value_string[] array that contains the combination of the standard message types as well as the specific message types for the preferences-selected vendor. However, this fails since the hinfo.strings value needs toe have a constant initializer. And as hfinfo is registered in the proto_register() function, there is probably no way for me to change this from within proto_handoff()
I think the best is to have two hfinfo entries, with different value_string..
But if you don't want to:
1/ You can use value_string_ext (and or hfinfo.display with BASE_EXT_STRING)
static const value_string vs_vendor0[] = { ... }; /* pref_vendor == 0 */
static const value_string vs_vendor1[] = { ... }; /* pref_vendor == 1 */
static int pref_vendor = 0;
static value_string_ext vse_vendor0 = VALUE_STRING_EXT_INIT(vs_vendor0);
static value_string_ext vse_vendor1 = VALUE_STRING_EXT_INIT(vs_vendor1);
static value_string_ext vs_vendor = VALUE_STRING_EXT_INIT(vs_vendor0); /*needed?*
/* And when preference is changed (apply_cb in prefs_register_protocol), something like:
(or in proto_handoff() (?)
*/
switch (pref_vendor) {
case 0: vs_vendor = vs_vendor0; break;
case 1: vs_vendor = vs_vendor1; break;
default: g_assert_not_reached();
}
2/ Simillar idea like before, but use value_string instead of value_string_ext.
And memcpy() arrays. (If you have small arrays it won't hurt much)
Hth.
Btw. OpenBSC is great project!
___________________________________________________________________________
Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives: http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- hfinfo.string const initializer / change VALS by preference ? Harald Welte (Jun 18)
- Re: hfinfo.string const initializer / change VALS by preference ? Jakub Zawadzki (Jun 18)
- Re: hfinfo.string const initializer / change VALS by preference ? Harald Welte (Jun 19)
- Re: hfinfo.string const initializer / change VALS by preference ? Jakub Zawadzki (Jun 18)
