This is used sometimes to make possible to specify a wireshark filter. Let say for instance that an initial size of a specific id is 16 bit. Then on a later version new messages are added were the id to the same type is added as 32 bit. Allowing different sizes on the same field name (for instance a "image_id") allows to specify a simpler wireshark filter (could be something like "spice.image_id == 76"). Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- python_modules/dissector.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python_modules/dissector.py b/python_modules/dissector.py index 65bb57d..3be7e70 100644 --- a/python_modules/dissector.py +++ b/python_modules/dissector.py @@ -48,17 +48,14 @@ class HF: hf_writer.variable_def("static int", "%s = -1" % self.hf_name) def create(self): - other = self.fields.get(self.ws_name) + other = self.fields.get(self.hf_name) if other: - for f in 'hf_name desc ws_name base vals mask'.split(): + for f in 'hf_name desc ws_name f_type base vals mask'.split(): if other.__dict__[f] != self.__dict__[f]: raise Exception('HF Field different from previous for\n\t%s\n\t%s' % (other, self)) - if other.f_type != self.f_type: - if other.f_type[:7] != 'FT_UINT' or self.f_type[:7] != 'FT_UINT': - raise Exception('HF Field different from previous for\n\t%s\n\t%s' % (other, self)) return - self.fields[self.ws_name] = self + self.fields[self.hf_name] = self self.add_wireshark_field() @@ -298,6 +295,8 @@ def write_wireshark_field(writer, container, member, t, ws, tree, size, encoding assert(member and container) + size_name = '' + # compute proper type f_type = 'FT_NONE' base = 'BASE_NONE' @@ -306,6 +305,7 @@ def write_wireshark_field(writer, container, member, t, ws, tree, size, encoding assert(t.is_primitive()) base = 'BASE_DEC' f_type = get_primitive_ft_type(t) + size_name = str(t.get_fixed_nw_size() * 8) if isinstance(t, ptypes.FlagsType): # show flag as hexadecimal for now base = 'BASE_HEX' @@ -343,7 +343,7 @@ def write_wireshark_field(writer, container, member, t, ws, tree, size, encoding hf_name = member_hf_name(container, member) ws_name = 'auto.' + hf_name[3:] else: - hf_name = 'hf_%s' % ws_name.replace('.', '_') + hf_name = 'hf_%s%s' % (ws_name.replace('.', '_'), size_name) writer.statement("%sproto_tree_add_item(%s, %s, glb->tvb, offset, %s, %s)" % (prefix, tree, hf_name, size, encoding)) -- 2.4.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel