Wireshark mailing list archives

How to print out string encoded data that contains nul characters?


From: "John Dill" <John.Dill () greenfieldeng com>
Date: Wed, 9 Apr 2014 17:06:50 -0400


I have several character data fields that happen to contain sections of non-ascii binary data including nul characters. 
 I'd like to get a string display that shows all of the characters according to the length of the field, i.e.

20 20 20 20 20 20 01 00 01 00 48 31 20 20 20 20 

produces

"      \001\000\001\000H1    "

In proto.c, I see that all of the format_text calls use strlen(bytes) as the length.

case FT_STRING:
case FT_STRINGZ:
case FT_UINT_STRING:
        bytes = (guint8 *)fvalue_get(&fi->value);
        label_fill(label_str, hfinfo, format_text(bytes, strlen(bytes)));

What is the recommended way of creating a text string that uses the octal encoding '\xxx' for non-ASCII data including 
nul characters that uses the 'length' field of 'proto_tree_add_item'?  I'm currently using FT_STRING, but obviously the 
string label ends at the first nul character.  I do not want FT_BYTES because the characters themselves are the 
important data in the field.

Thanks,
John Dill
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

Current thread: