ws_type override the type (BOOLEAN -> FT_BOOLEAN). ws_base override the base (DEC -> BASE_HEX). ws_desc override the description. ws allow to specify description and name for wireshark. Name is important as allows filters. Having a single attribute with 2 values allows to quickly specify the main attributes. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- python_modules/dissector.py | 46 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/python_modules/dissector.py b/python_modules/dissector.py index 23bb96a..5b14b92 100644 --- a/python_modules/dissector.py +++ b/python_modules/dissector.py @@ -199,12 +199,30 @@ def get_primitive_ft_type(t): assert size in (1, 2, 4, 8) return "FT_%sINT%d" % (unsigned, size * 8) +# fix some attributes +# ws attribute contains description and optionally a name +def fix_attributes(t): + if t and t.has_attr('ws'): + ws = t.attributes['ws'] + if not t.has_attr('ws_name'): + t.attributes['ws_name'] = [ws[1]] + if not t.has_attr('ws_desc'): + t.attributes['ws_desc'] = [ws[0]] + # write a field def write_wireshark_field(writer, container, member, t, tree, size, encoding='ENC_LITTLE_ENDIAN', prefix=''): assert(member and container) - hf_name = member_hf_name(container, member) + def get_member_t_attr(attr, default=None): + if t.has_attr(attr): + default = t.attributes[attr][0] + if member and member.has_attr(attr): + default = member.attributes[attr][0] + return default + + fix_attributes(member) + fix_attributes(t) # compute proper type f_type = 'FT_NONE' @@ -224,8 +242,30 @@ def write_wireshark_field(writer, container, member, t, tree, size, encoding='EN assert(t.has_name()) vals = 'VALS(%s_vs)' % codegen.prefix_underscore_lower(t.name) - desc = member.name - ws_name = 'auto.' + hf_name[3:] + # override type + ws_type = get_member_t_attr('ws_type') + if ws_type: + f_type = 'FT_%s' % ws_type + if f_type == 'FT_BOOLEAN': + vals = 'TFS(&tfs_set_notset)' + base = 'BASE_NONE' + vals = 'NULL' + + # override base + ws_base = get_member_t_attr('ws_base') + if ws_base: + base = 'BASE_%s' % ws_base + + # read description + desc = get_member_t_attr('ws_desc', member.name) + + # read name + ws_name = get_member_t_attr('ws_name') + if not ws_name: + hf_name = member_hf_name(container, member) + ws_name = 'auto.' + hf_name[3:] + else: + hf_name = 'hf_%s' % ws_name.replace('.', '_') writer.statement("%sproto_tree_add_item(%s, %s, glb->tvb, offset, %s, %s)" % (prefix, tree, hf_name, size, encoding)) -- 2.1.0 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel