This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Creating Table in subtree

0

I have been trying to update a plugin(from 1.6 to 2.2). In the previous plugin, the following code was used to create a table data.

for (row = 0; row < 10; row++) {
                proto_tree_add_text(command_tree, tvb, FIRSTELEMENT_START + 2*row, ELEMENT_LENGTH,    "PA%u\t%s\t%s\t%s %s %u",
                        row + 1,
                        try_val_to_str(pa_array[row][0], discrete_status_var),
                        try_val_to_str(pa_array[row][1], discrete_status_var),
                        try_val_to_str(pa_array[row][2], source_deck_var),
                        try_val_to_str(pa_array[row][3], source_type_var),
                        pa_array[row][4]
                );
            }

I have been trying to replace the proto_tree_add_text by proto_tree_add_item to achieve the same result, but without any success. Can someone please help me? Thanks a lot.

asked 23 Feb '17, 07:10

xaheen's gravatar image

xaheen
71141519
accept rate: 50%

edited 23 Feb '17, 08:10

grahamb's gravatar image

grahamb ♦
19.8k330206


One Answer:

1

You can use proto_tree_add_XXX_format() functions but combining several values on the same line defeats the possibility to filter individual items, so it is not encouraged.

answered 24 Feb '17, 01:59

Pascal%20Quantin's gravatar image

Pascal Quantin
5.5k1060
accept rate: 30%

1

What they could do is create a top-level item with multiple values and then put each of the individual values as named fields underneath that top-level item.

(24 Feb '17, 13:46) Guy Harris ♦♦

Could you please tell me where I can find some example use of proto_tree_add_XXX_format()? Thanks @Pascal Quantin @Guy Harris

(27 Feb '17, 02:07) xaheen

Proto_tree_add_string_format works perfectly! :D

(09 Mar '17, 00:41) xaheen