Wireshark-users: Re: [Wireshark-users] A question about using tvb_get_string_enc() function

Date Prev · Date Next · Thread Prev · Thread Next
From: Nan Xiao <xiaonan830818@xxxxxxxxx>
Date: Tue, 16 Aug 2022 09:46:09 +0800
Hi Guy,

Got it, thanks very much for your quick reply and detailed explanation!
Best Regards
Nan Xiao


On Tue, Aug 16, 2022 at 9:44 AM Guy Harris <gharris@xxxxxxxxx> wrote:
On Aug 15, 2022, at 6:26 PM, Nan Xiao <xiaonan830818@xxxxxxxxx> wrote:

> I am checking packet-gsm_sms.c and come across following code (https://gitlab.com/wireshark/wireshark/-/blob/master/epan/dissectors/packet-gsm_sms.c#L651):
>
>     ......
>     addrstr = tvb_get_string_enc(pinfo->pool, tvb, offset, numdigocts, ENC_KEYPAD_ABC_TBCD|ENC_NA);
>     ......
>  The value of ENC_NA is 0x00000000, and the value of ENC_KEYPAD_ABC_TBCD is 0x00000046, so it seems the value of ENC_KEYPAD_ABC_TBCD|ENC_NA is still ENC_KEYPAD_ABC_TBCD, and ENC_NA is lost. I also checked tvb_get_string_enc (https://gitlab.com/wireshark/wireshark/-/blob/master/epan/tvbuff.c#L3060), and couldn't find any special process of ENC_NA. Could someone advise why ENC_NA is needed here? Or I misunderstood something? Thanks very much in advance!

ENC_NA is for fields for which there's no endianness, so the code doesn't check the endianness.

It's not there for the benefit of the software, as there's no need to tell tvb_get_string_enc() for that string encoding; it's there for the benefit of people reading the code.  Therefore, it doesn't matter that it's zero.
___________________________________________________________________________
Sent via:    Wireshark-users mailing list <wireshark-users@xxxxxxxxxxxxx>
Archives:    https://www.wireshark.org/lists/wireshark-users
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-users
             mailto:wireshark-users-request@xxxxxxxxxxxxx?subject=unsubscribe