Hi all I have a requirement like, - Calculate the subtree length dynamically. Would like to how this can be achieved. I am using Wireshark 1.10.8 version. One more question: Can i create a subtree with length given as "0" and then can i update the same tree with the actual length after parsing the data and displaying on Wireshark GUI ? Thanks in advance. Regards Kiran Kumar G asked 15 Dec '14, 12:07 Kiran Kumar G |
One Answer:
You can have a look at proto_item_set_len() function so as to set afterwards the size of a given item. Not sure that you can create a subtree with a length of 0 (it might trigger an assertion) so create it with a size of 1 ;) answered 15 Dec '14, 13:06 Pascal Quantin showing 5 of 7 show 2 more comments |
Thanks Pascal for the answer, it worked to set the length of the tree after the dissection is completed.
One more information i would like to know is how to highlight the bytes of the length set using proto_item_set_len() in the hex window pane.
Thank you.
Not sure to understand your question. The bytes of the subtree will be automatically highlighted when you select it.
I would like to re-iterate the question.
1 - I have created an item using proto_tree_add_none_format(), here i am passing length = 0, it worked. If i pass -1 or 1 it showed as malformed packet.
2 - Then, i calculated the length of the tree during the dissection.
3 - Now, used proto_item_set_len() function to set the length calculated in point 2. Length is getting reflected when i select the subtree but not highlighting the corresponding bytes in the hex window pane.
Thanks a lot Pascal, your solution worked fine for our requirement. Now, we are able to dynamically calculate the length of the tree and set it after the dissection. We are also able to see the highlighting of the subtree for the length bytes set.
Thank you very much for your help and suggestion :)
As far as I know this is working fine (you can find an example of its usage in file-gif.c). If ou get an assertion when setting a size of 1, then it means that there is something wrong with your code. Are you at the end of the TVB?
@Kiran Kumar G,
If an answer has solved your issue, please accept the answer for the benefit of other users by clicking the checkmark icon next to the answer. Please read the FAQ for more information.
Thanks Grahamb, i have accepted the solution provided by Pascal as the correct answer. Thank you.