I have got a working dissector up and running using Lua, and it is working well. It does everything I need it to do and I am getting the information I need - no problems. However, I would like to make a rather large improvement. Currently, our packets are sent with a 24-bit mask in each header, informing the client which fields in the packet are valid. If the field is not valid, it is normally just padded with nulls (0x00). Currently, I am adding all fields to my tree, without checking the mask, so I get a lot of useless tree items, and I have to manually check the flags to see which fields with 0s are valid or invalid... My question is: How do I only add items to the tree if the mask in the header e.g. currently: then in my dissector: Do I have to wrap an if statement around each and every asked 22 Mar '15, 20:54 Fidelius edited 22 Mar '15, 20:56 |
2 Answers:
Nope, you do not have to wrap each and every Really, a statement like So what you can do is create a proxy function that will decide whether to actually call
Note that the above is just an example - I haven’t tried it or even verified it was well-formed code. But it should give you the general idea. answered 27 Jun ‘15, 21:36 Hadriel |
If you want to document each dissected byte, even if it is not used, then you can use the Alternatively, do not add the field at all since it is unlikely of interest to the user. Yes, you need to check this yourself, but some structured code should help here. answered 03 May '15, 16:05 Lekensteyn |