ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] asn2wrs: autodetection for 64 bits X constrained integers

From: "Pavel Strnad" <strnadp@xxxxxxxxxx>
Date: Thu, 26 Oct 2017 01:02:30 +0200

Hi Pascal,

thank You for fast response and proposal review.

Best Regards,

Pavel

 

From: Wireshark-dev [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of Pascal Quantin
Sent: Wednesday, October 25, 2017 12:30 PM
To: Developer support list for Wireshark
Subject: Re: [Wireshark-dev] asn2wrs: autodetection for 64 bits X constrained integers

 

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.