Fix asn2wrs.py: always add BASE_VAL64_STRING
authorChristophe GUERBER <christophe.guerber@gmail.com>
Tue, 1 Jan 2019 13:53:41 +0000 (14:53 +0100)
committerMichael Mann <mmann78@netscape.net>
Tue, 1 Jan 2019 14:59:28 +0000 (14:59 +0000)
In some cases (e.g. when a field has a user defined dissection function)
the type reported for this field is a 'virtual' one and the latter is not
contained in selt.type. Consequently, BASE_VAL64_STRING is not set.

Function eth_get_type_attr should return all the attributes of a type and
it seems resonable to expect it to return the BASE_VAL64_STRING. This
will solve the above mentioned error and may solve any possible issue in
other parts that call this function.

Change-Id: Iaee9ce5bd30f2a768cfcecf628df23bf1ed54e55
Reviewed-on: https://code.wireshark.org/review/31287
Reviewed-by: Michael Mann <mmann78@netscape.net>
tools/asn2wrs.py

index ca81a8786d6c8fa7b4cc989283062677c3101556..b7f529e6272338bd80d7d9d2b70c474d8ab81691 100755 (executable)
@@ -707,6 +707,8 @@ class EthCtx:
             else:
                 attr.update(self.type[t]['attr'])
                 attr.update(self.eth_type[self.type[t]['ethname']]['attr'])
+        if attr['STRINGS'].startswith('VALS64('):
+            attr['DISPLAY'] += '|BASE_VAL64_STRING'
         #print " ", attr
         return attr
 
@@ -1320,12 +1322,6 @@ class EthCtx:
             use_vals_ext = self.eth_type[ethtype].get('vals_ext')
             if (use_vals_ext):
                 attr['DISPLAY'] += '|BASE_EXT_STRING'
-            if ethtype in self.type \
-               and self.type[ethtype]['attr'].get('STRINGS') == '$$' \
-               and self.eth_type[ethtype]['val'].type == 'IntegerType' \
-               and self.eth_type[ethtype]['val'].HasConstraint() \
-               and self.eth_type[ethtype]['val'].constr.Needs64b(self):
-                attr['DISPLAY'] += '|BASE_VAL64_STRING'
             self.eth_hf[nm] = {'fullname' : fullname, 'pdu' : self.field[f]['pdu'],
                                'ethtype' : ethtype, 'modified' : self.field[f]['modified'],
                                'attr' : attr.copy(),