This is our old Q&A Site. Please post any new questions and answers at

I'm in the process of migrating a custom Wireshark from 1.2.6 to 2.0.3. Yes, I know a huge leap.

I'm trying to figure out use 3 format strings in proto_tree_append_text(), however when compiling wireshark doesn't like it.

The old code is:

attr_str = decoder (tvb, offset + 4, len); /* Refers back to the customer decoder function I have */
proto_tree_add_text(tree, tvb, offset, pack_len, "%s %u %s", str, type, attr_str);

This code addresses a value in the transform attributes. attr_str is listed in the function variables as const char *attr_str. When this information was decoded in wireshark 1.2.6, it showed the attribute and a 6 digit number for the value (i.e., Decoder ID: 123456).

Currently, the new code is located in the dissect_transform_..._attributes. I've put the const gchar *attr_str into the function variables again. So then the new code I have as:

proto_tree_add_item(sub_transform_attr_type_tree, hf_isakmp_ike_attr_decoder_id, tvb. offset, optlen, ENC_NA);
attr_str = decoder_id(tvb, offset + 4, len);
proto_tree_append_text(transform_attr_type_item, "%s %u %s", val_to_str(tvb_get_ntohs(tvb, offset), str, type, attr_str, "Unknown %d"));

I have tried the proto_tree_add_string(), but that didn't help any. I'm looking for some ideas. PS, I am far from being an expert in programming, so if I'm way out of line, it's OK to let me know.


asked 27 May '16, 08:01

ladyslinger's gravatar image

accept rate: 0%

edited 27 May '16, 08:29

grahamb's gravatar image

grahamb ♦

And what error did you get?

(27 May '16, 08:29) grahamb ♦

The error I get is "too many arguments in function 'val_to_str'"

(27 May '16, 10:19) ladyslinger

The prototype for val_to_str() is:

val_to_str(const guint32 val, const value_string *vs, const char *fmt)

But in your code you have:

val_to_str(tvb_get_ntohs(tvb, offset), str, type, attr_str, "Unknown %d")

i.e. 5 parameters instead of the expected 3. It's not entirely clear from the minimal context you've provided exactly what you're trying to do, so you'll have to work out exactly what you should be passing to val_to_str().

permanent link

answered 28 May '16, 04:06

grahamb's gravatar image

grahamb ♦
accept rate: 22%

Your answer
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 27 May '16, 08:01

question was seen: 1,071 times

last updated: 28 May '16, 04:06

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