OSQA is unmaintained. Help us figure out where to go from here.

I am new to wireshark and I am trying to upgrade a plugin that was build for 1.x to 2.x. One of those steps is replacing proto_tree_add_text() with proto_tree_add_item()

if the old code is

proto_tree_add_text(foo_tree, tvb, 0, -1, "header ver. %s", header_array[index]);

I know I would have to start with

static hf_register_info hf[] = {
    { &foo_header,
        { "header ver. ", "foo.header",
        FT_NONE, BASE_NONE,
        NULL, 0x0,
        NULL, HFILL }
    }
};
proto_tree_add_item(foo_tree, foo_header, tvb, 0, -1, ENC_NA);

But how would I add the array into the string to display? Where is a good source to learn about using hf_register_info?

asked 21 Jul, 15:19

allantse's gravatar image

allantse
114
accept rate: 100%


proto_tree_add_none_format(foo_tree, foo_header, tvb, 0, -1, "header ver. %s", header_array[index]);
permanent link

answered 21 Jul, 21:53

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.3k335194
accept rate: 19%

thank you!

(04 Aug, 09:32) allantse

From the little information you have given I would consider rewriting the code and add the header information elements with proto_tree_add_item() with Hf_header_version and the appropriate length of the field.

(04 Aug, 09:46) Anders ♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×173
×16
×10

question asked: 21 Jul, 15:19

question was seen: 181 times

last updated: 04 Aug, 09:46

p​o​w​e​r​e​d by O​S​Q​A