Wireshark-dev: Re: [Wireshark-dev] asn2wrs: autodetection for 64 bits X constrained integers
From: Pascal Quantin <pascal.quantin@xxxxxxxxx>
Date: Wed, 25 Oct 2017 12:29:38 +0200
Hi Pavel,

2017-10-25 8:34 GMT+02:00 Pavel Strnad <strnadp@xxxxxxxxxx>:
Hi list,
can we improve auto detection for 64b variant of constrained integers?
In the master branch we handle the cases of integers over/under +/- 2^32 but
what about MIX.. and ..MAX constants?
There are such dissectors in our current source tree: h245, t125, x509,..
that should use 64b instead of current 32b.

Can we use patch like bellow to improve it?

diff --git a/tools/asn2wrs.py b/tools/asn2wrs.py index
76cd10c674..6788bf09cd 100755
--- a/tools/asn2wrs.py
+++ b/tools/asn2wrs.py
@@ -3618,8 +3618,9 @@ class Constraint (Node):

     def Needs64b(self, ectx):
         (minv, maxv, ext) = self.GetValue(ectx)
-        if (str(minv).isdigit() or ((str(minv)[0] == "-") and
str(minv)[1:].isdigit())) \
-        and str(maxv).isdigit() and (abs(int(maxv) - int(minv)) >= 2**32):
+        if ((str(minv).isdigit() or ((str(minv)[0] == "-") and
str(minv)[1:].isdigit())) \
+        and str(maxv).isdigit() and (abs(int(maxv) - int(minv)) >= 2**32))
\
+        or (maxv == 'MAX') or (minv == 'MIN'):
             return True
         return False

This sounds reasonable. See https://code.wireshark.org/review/24049

Best regards,
Pascal.