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

Hello, community. In the ASN.1 definition I work with there is a value defined as an UTF8String. ~/epan/dissectors/packet-per.c does not contain any function dissecting it. Thus, I suppose I have to write my own one and to add it to packet-per.c

How can I do that? I looked to other string dissectors. In many of them function "dissect_per_restricted_character_string_sorted" is used with differences in the last three parameters. Is it about supplying correct parameters to that function only?

Thank you in advance


asked 15 Jan '13, 00:17

Ewgenijkkg's gravatar image

accept rate: 60%

What does asn2wrs generate now?

(15 Jan '13, 01:02) Anders ♦

Hello, it creates a call to "dissect_per_UTF8String(tvb, offset, actx, tree, hf_index, NO_BOUND, NO_BOUND, FALSE)". But as I mentioned the function is absent in packet-per.c

(15 Jan '13, 01:26) Ewgenijkkg

Its not clear to me if it should be 27 Encoding the restricted character string types : Or 28 Encoding the unrestricted character string type : If it's the later I presume its actually an OCTET STRING filled with the UTF-8 characters?

(15 Jan '13, 01:46) Anders ♦

Hmm, the only thing I know is that it's the UTF8String data type of ASN.1 That's the value type in my ASN.1 definition. How could I find out the rest?

(15 Jan '13, 01:55) Ewgenijkkg

Hi, I would start by defining dissect_per_UTF8String() in packet-per.[ch] then in that function call dissect_per_octet_string() then see if the length and content comes out right.

(15 Jan '13, 03:46) Anders ♦

Hmm I would try mimicing dissect_per_IA5String() and do required changes as I go, I'm guessing the alphbet_lenght is 2^32-1. If you have a trace to work with and know what the encoded string is it should be possible to work it out. In dissect_per_restricted_character_string_sorted() the for loop fetching bit by bit can probably be replacet by tvb_get_bits...

(15 Jan '13, 04:36) Anders ♦

OK, it worked out! However, I set the last parameter of "call dissect_per_octet_string" - "tvbuff_t **value_tvb" to NULL. What is that parameter for, when would I need it?



P.S. I mean your first suggestion with dissect_per_octet_string() worked out :)

(15 Jan '13, 04:39) Ewgenijkkg

That parameter is used when you want to have the OCTET STRING returned in a new tvb for further dissection.

(15 Jan '13, 08:17) Anders ♦
showing 5 of 8 show 3 more comments

So, I wrote my UTF8String dissection function in packet-per.c and packet-per.h according to the comments above:

dissect_per_UTF8String(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, gboolean has_extension)
    offset=dissect_per_octet_string(tvb, offset, actx, tree, hf_index, min_len, max_len, has_extension, NULL);
    return offset;

That worked out then.

Great thanks for your help, Anders!

permanent link

answered 15 Jan '13, 07:08

Ewgenijkkg's gravatar image

accept rate: 60%

edited 15 Jan '13, 07:13

If the code is correct, then maybe it would be worth to add it to the Wireshark distribution?

(15 Jan '13, 07:56) Ewgenijkkg

Please open a bug report (enhancement)and include a patch/diff. It would be great if it would be possible to try it with a trace as well, if you are not willing to submit/share your dissector perhaps it's possible to design a dummy dissector and a dummy frame to test with?

(15 Jan '13, 08:14) Anders ♦

OK, I submitted the enhancement request with my patch.

(16 Jan '13, 02:11) Ewgenijkkg

The feature request was implemented in the current code version, however not with dissect_per_octet_string but with dissect_per_restricted_character_string_sorted.

(24 Jan '13, 01:58) Ewgenijkkg
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: 15 Jan '13, 00:17

question was seen: 2,596 times

last updated: 24 Jan '13, 01:58

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