I've asked this before, but didn't get any answers. This might be impossible to do. For my dissector, some tree items have the corresponding value stored in two, not continuous parts. For example, I have this chunk of a buffer: 1a2b3c4d. The first and last byte combined is the value I need, so 1a4d. I can calculate this value and add a tree item to represent it. But I don't know how to get only the bytes 1a and 4d highlighted, and leaving the middle two bytes alone, when clicking on this tree item. Any ideas? asked 28 Mar '14, 12:41 YXI edited 28 Mar '14, 16:00 Hadriel |
4 Answers:
You should be able to use Then, in your dissect_myproto ...
answered 28 Mar '14, 13:53 multipleinte... showing 5 of 6 show 1 more comments |
You could try "cheating": create your current 64-bit ProtoField without a mask, and also create two 32-bit ProtoField for each 32-bit portion of the 64-bit with the appropriate mask for each portion. When you add the 64-bit one to the tree use the answered 28 Mar '14, 16:44 Hadriel "When you add the 64-bit one to the tree use the TvbRange of the whole 64-bits"... I think this opens a new tab in the bytes pane, because it is not a TvbRange that actually exists in the stream. I don't want to have to have so many new tabs open(they don't auto close when you are done looking at them). Also, ideally, the users can see where the disjoint bytes are located in relation to each other with just open click. Oh, am I picky? (28 Mar '14, 19:28) YXI I'm not sure we're using the same words. A "tab" usually means a new window pane, and no adding a tree item does not create a new window. It does create a new branch in the tree, and if you add elements under that branch (i.e., under that child node) then the user will see an expansion icon (an arrow in GTK, or a plus in windows I think) next to that tree item, which they can click to expand to view what's under it if they want to. But it doesn't usually show in expanded form automatically so it shouldn't bother them. These things are already done all over the place and most people don't notice it. For example, if you have a capture with TCP/IPv4 traffic, you'll see the Frame, Ethernet (or wifi), IP, and TCP in the details pane. If you expand the IP one, you'll see a DSCP field, which itself can be expanded, as well as the flags field, etc. Those aren't really one field each - they're multiple fields each: a parent one that you see without expanding it, and then the child ones under it when you expand them. (28 Mar '14, 19:41) Hadriel Sorry I have to use "Your answer" instead of comment, as I have two images. You will see what I mean by "tab" by looking at the images. Toward the very bottom, there are two tabs, one for frame (79 bytes) and another for myTvb (4 bytes). myTvb is created from disjoint bytes in the payload. Wireshark automatically created the myTvb tab to show this new buffer that does not exist in the original payload. The code that corresponds to this is as follows: subtree:add(buffer(0,2),"The first value: " .. buffer(0,2):uint())
Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
|
Is this a C function? I have to use Lua. Also, my value is a 64 bit int.
Yes, it is part of the C interface. I don't think this functionality is exposed through the Lua interface right now, but I'm not as familiar with the Lua API.
According to the docs, the mask option (0xFF0000FF in the example) should be available (optional parameter)
64 bit is a second story. (usable) Lua 64 bit support was only added recently. What is your Wireshark version?
Using masks for ProtoFields is supported, and is shown in the
dissector.lua
example script found here. Using a 64-bit mask isn't though, both because Lua itself would lose precision in such a big number, but also because the current code gets it as a 32-bit integer. I'd argue the latter is a bug, but the former requires accepting aUInt64
mask type anyway to actually work right. So I think you should submit a bug.Apparently the internal C-code for fields only supports a 32-bit mask to begin with. I grep'ed the code, and sure enough not a single 64-bit field uses a mask. The one I found that should have, cheated and pretended it was a 32-bit field because only the lower 32-bits were being used. That will make this tricky to support. :(