Wireshark mailing list archives
Re: How to retrieve text displayed for a proto_item ?
From: Jaap Keuter <jaap.keuter () xs4all nl>
Date: Thu, 22 Dec 2011 16:24:06 +0100
On 2011-12-22 15:25, Teto wrote:
Hi everybody,Easy question despite I couldn't find the answer. Here is an example -not a real one - of what I would like to do: proto_item* pi = proto_tree_add_text(tree, tvb, offset, 4, "Sub-tlvs number" ); col_add_fstr(cinfo, COL_INFO, "test: %s" , get_displayed_text_of_proto_item(pi) ); It woud ideally display "Sub-tlvs number" in COL_INFO part. So what's the equivalent for "get_displayed_text_of_proto_item(pi)". I tried with PITEM_FINFO(subtree)->hfinfo->name but seems like the wrong part (displayed nthg). Regards Matt
Hi, This is considered bad style, not recommended, subject to change, etc. So what you should do is setup your string, like so: const char labelstring[] = "Sub-tlvs number"; and use it, like so: proto_tree_add_text(tree, tvb, offset, 4, labelstring); col_add_fstr(cinfo, COL_INFO, "test: %s", labelstring); So work out your string in a pointer and use that. If the actual stringdepends on a certain variable, Wirehshark provides several kinds of nice translation functions. val_to_str(), using valuestrings. It can be used in
header fields too! But if you must, and there is no guarantee it works in every case (like display filters yes/no, coloring yes/no, or in tshark), you should lookinto finfo, not hfinfo. Note this won't pass the inspection by reviewers.
Thanks, Jaap ___________________________________________________________________________ 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:
- How to retrieve text displayed for a proto_item ? Teto (Dec 22)
- Re: How to retrieve text displayed for a proto_item ? Jaap Keuter (Dec 22)
- Re: How to retrieve text displayed for a proto_item ? Teto (Dec 23)
- Re: How to retrieve text displayed for a proto_item ? Stephen Fisher (Dec 29)
- Re: How to retrieve text displayed for a proto_item ? Teto (Dec 23)
- Re: How to retrieve text displayed for a proto_item ? Jaap Keuter (Dec 22)