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

how to replace ‘proto_tree_add_text’ for wireshark 2.2

0

Hello wireshark gurus, I have a simple problem(but quite devastating for me). I am trying to update this dissector from wireshark 1.6 to 2.2 for windows. I have successfully removed all the errors due to change in API, except for one --> proto_tree_add_text. I know it should be replaced by proto_tree_add_xxx. But I couldn't find any way of understanding how to implement the change.I have read the readme files. but I'm unable to attain any success after trying a lot. New functions require some parameter named 'id' eg. proto_tree_add_string(tree, id, tvb, start, length, value_ptr); What is this ID? Could anyone please guide me solving this issue. I'm posting some of the code snippets. Thanks

proto_item *header_item = proto_tree_add_text(cidsifecmd_tree, tvb, CIDSIFE_HEADER_FIRST_BYTE_START, CIDSIFE_HEADER_LENGTH,
        "Header > Protocol Revision: %u, Airframe Manufacturer: %u, Data Length: %u",
        ife_protocol_revision, ife_airframe_manufactor, ife_data_length
);

proto_tree_add_text(command_tree, tvb, 7, 1, "Direct PA:\t\t%s", try_val_to_str(getbits(tvb_get_guint8(tvb, 7), 1, 2), discrete_status_var));

proto_tree_add_text(command_tree, tvb, 7, 1, "Video In Use:\t%s", try_val_to_str(getbits(tvb_get_guint8(tvb, 7), 3, 2), discrete_status_var) ); proto_tree_add_text(command_tree, tvb, 5, 10, "Item\tVPA\tNMPA\tAudioType"); for (row = 0; row < 10; row++) { proto_tree_add_text(command_tree, tvb, 5, 10, "VPA%u\t%s\t%s\t%s", 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], vpa_audio_type_var) ); }

proto_tree_add_text(sub_tree, tvb, CIDSIFE_CMD42_FIRSTELEMENT_START + tmp_row * CIDSIFE_CMD42_ELEMENT_LENGTH, CIDSIFE_CMD42_ELEMENT_LENGTH, str);


It also appears once in the header file

#define PROTO_TREE_ADD_HEADER( ife_tree, ife_command, element_start, element_length )                      
proto_item *sub_item = proto_tree_add_text(
(ife_tree) , tvb, (element_start),
ife_numberOfElements * (element_length),
"%s (%u entries)",
try_val_to_str( (ife_command) , command_name_var),
ife_numberOfElements
);
proto_tree *sub_tree = proto_item_add_subtree(sub_item, ett_cidsifecmd_tree)

asked 02 Dec ‘16, 09:20

xaheen's gravatar image

xaheen
71141519
accept rate: 50%

edited 02 Dec ‘16, 10:05

grahamb's gravatar image

grahamb ♦
19.8k330206


One Answer:

1

The is a Perl helper script in tools\convert_proto_tree_add_text.pl that does a fair bit of the donkey work for you, but may need manual assistance to complete the conversion.

The script might not work correctly on your macro in the header file, but after you see what the script has done to the other functions you should be able to work out what is needed in the macro. I suspect the macro may need additional parameter(s).

answered 02 Dec '16, 10:15

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

Thanks a lot @grahamb Sadly now I am lost with this convert_proto_tree_add_text.pl file :p trying to figure out what to do with it as I have no Idea about Perl.

(05 Dec '16, 13:58) xaheen