Wireshark-dev: Re: [Wireshark-dev] dissect_per_constrained_integer() with
From: "Pavel Strnad" <strnadp@xxxxxxxxxx>
Date: Thu, 22 Dec 2016 17:20:01 +0100
Hi Pascal, Thank You for fast response and clear comments. Would it make sense to implement extra dissect_per_semi_constrained_integer? I can try to implement dissect_per_semi_constrained_integer (tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, guint32 min, guint32 max, guint32 *value, gboolean has_extension, gboolean lb_infinite). Extra parameter will allow us to distinguish both cases where either min(lb_infinite=TRUE) or max(lb_infinite=FALSE) is set to NO_BOUND? I can do the same for 64b version. Afterwards I will need to update asn2wrs accordingly to have this issue fixed. This will not sort out the case of direct callers to dissect_per_constrained_integer. What do You think? Best Regards, Pavel ----------------------------------------------------------------------- Date: Wed, 21 Dec 2016 16:07:02 +0100 From: Pascal Quantin <pascal.quantin@xxxxxxxxx> To: Developer support list for Wireshark <wireshark-dev@xxxxxxxxxxxxx> Subject: Re: [Wireshark-dev] dissect_per_constrained_integer() with no_bound (MAX in ASN.1) Message-ID: <CAGka-82MWxYv2aj0WJRL_p9ooEmBRpo7_sAH7KTpHc6C0vCFYA@xxxxxxxxxxxxxx> Content-Type: text/plain; charset="utf-8" Hi Pavel, 2016-12-21 15:37 GMT+01:00 Pavel Strnad <strnadp@xxxxxxxxxx>: > Hello, > > I am trying to understand the difference in usage of NO_BOUND or > UINT_MAX in the place of max parameter in > dissect_per_constrained_integer() function. In my case aligned PER variant. > > > > From packet-per.h: > > #define NO_BOUND -1 > > guint32 dissect_per_constrained_integer(tvbuff_t *tvb, guint32 offset, > asn1_ctx_t *actx, proto_tree *tree, int hf_index, guint32 min, guint32 > max, > guint32 *value, gboolean has_extension); > > > > Based on that it looks like that there is no different dissection of > following two asn.1 definitions? > Correct, semi-constrained integer does not seem to be managed properly. This matches the comment found in line 1283. > 1) seconds INTEGER (0..4294967295) > > 2) seconds INTEGER (0..MAX) where MAX translates to > NO_BOUND=4294967295 using asn2wrs > > > > Reading X.691 (aligned PER) wireshark seems to dissect well the 1st > case that is using size constraint but not the 2nd case > > where semi-constraint size is used and the length determinant should > include padding bits in the case of aligned PER. > > > > I would like to try to fix it myself but will need some hint how to > differentiate these two cases and keep API unchanged? > IMHO you can't without changing the API. Maybe we would need to extra booleans indicating whether the min and / or max values are bounded or not, and adapt asn2wrs generator accordingly. This way we could drop the NO_BOUND define Note that this sounds like a non trivial project because: - as indicated in the comments, dissect_per_constrained_integer only handle 32 bits integers and dissect_per_constrained_integer_64b only handles 64 bits integers, so both needs to be adapted - MIN or MAX parameters do not seem properly handled in other types also, and any change done in dissect_per_constrained_integer(_64b) needs to be reflected in the caller functions and any other making use of NO_BOUND Regards, Pascal.
- Follow-Ups:
- Re: [Wireshark-dev] dissect_per_constrained_integer() with
- From: Pascal Quantin
- Re: [Wireshark-dev] dissect_per_constrained_integer() with
- Prev by Date: Re: [Wireshark-dev] Field Registration Error
- Next by Date: Re: [Wireshark-dev] dissect_per_constrained_integer() with
- Previous by thread: Re: [Wireshark-dev] Field Registration Error
- Next by thread: Re: [Wireshark-dev] dissect_per_constrained_integer() with
- Index(es):