Wireshark-dev: Re: [Wireshark-dev] Problem with ENC_BCD_DIGITS_0_9 odd/even

From: Jaap Keuter <jaap.keuter@xxxxxxxxx>
Date: Wed, 9 Dec 2020 18:49:02 +0100
Hi,

Indeed a nasty one. You need sub-octet length indication here, which doesn’t exist. But since it’s limited to nibbles, a single flag is all that’s really needed.
Anything above the ENC_CHARENCODING_MASK would be fine. 

This would be the minimalist implementation of this:
proto_tree_add_item(subtree, hf_bcd_thing, tvb, offset, -1, ENC_KEYPAD_BC_TBCD | (odd ? ENC_BCD_ODD : 0));

Jaap

On 9 Dec 2020, at 16:43, Anders Broman via Wireshark-dev <wireshark-dev@xxxxxxxxxxxxx> wrote:

Hi,
There is a problem with the BCD encoded numbers as they may be padded and unfortunately with Zero.
 
“Encoding scheme: BCD. Note: Filler H’0 (last digit) is used in case of the odd number of digits.” 
 
In order to present this properly
It would be good to be able to pass an odd/even indicator, what would be the preferred bits to use?
#define ENC_BCD_ODD               0x10000000
#define ENC_BCD_EVEN              0x20000000
 
If(odd){
   proto_tree_add_item(subtree, hf_cs1plus_gen_digits, parameter_tvb, poffset, -1, ENC_KEYPAD_BC_TBCD| ENC_BCD_ODD );
else
   proto_tree_add_item(subtree, hf_cs1plus_gen_digits, parameter_tvb, poffset, -1, ENC_KEYPAD_BC_TBCD| ENC_BCD_EVEN);
 
Or some other solution?
 
Best regards
Anders
 
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
            mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe