I am trying to have a dissector for my proprietary protocol. I have to decode Flags byte in my protocol as bit-string and I have done it with below code:
And Wireshark decodes with above code:
But I want to set the Name String for the bit field ‘Protocol Type’ based the value. If Protocol Type bit is set to ‘0’ then I want to show it as “MYPROTO1” and if bit is set to ‘1’ then show it as “MYPROTO2”. i.e: After wireshark decode I want to see it as
Any help is greatly appreciated. asked 17 Aug ‘12, 05:37 Aruna Sirigere edited 17 Aug ‘12, 06:23 multipleinte… |
2 Answers:
What you need is called a value string. I couldn't find any particularly good examples very quickly, but it should look something like this:
...and then when you declare your protofield, provide this table as the
That should do what you want. The equivalent in C would be this:
Note that in C, you could also use a answered 17 Aug ‘12, 06:24 multipleinte… |
In
answered 17 Aug '12, 06:30 Jaap ♦ edited 17 Aug '12, 06:31 |
As a little further explanation, the value “0x10” in the fine examples above is a mask to isolate the bit(s) required for the value string.
Thanks Multipleinterfaces and jaap. It worked.. :)
I’ve converted your “answer” to a comment as that’s how this site works. You can accept the best answer to your question by clicking the “check mark” icon next to the answer which helps other users to see what solved your problem.