[PATCH v3 39/51] Allows to have two type with different size to point to same field name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 c88118f..554f59c 100644
--- a/python_modules/dissector.py
+++ b/python_modules/dissector.py
@@ -45,17 +45,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()
 
@@ -297,6 +294,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'
@@ -305,6 +304,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'
@@ -342,7 +342,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.1.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]