Hello, I have the following problem. My dissector needs to rebuild a new tvb. A better description would be, I need to cut out some data and send it to the next dissector. As Example....
the first to lines are some other protocol data (my protocol) 11, 22 and 33 are the ethernet header 44 the ip header what I now need to do is to cut out line I and II, reasamble it an send it to the next dissector (ethernet). I found the solution in building a composite buffer. The real code looks a little bit different but for the data above it would like this.
The handle_eth is set with
No the problem…. With Ethernet everything is fine. Then the Ethernet dissector sends it to IP dies because of wrong data. When I look at the data IP gets I see that IP do not get the right data. It should be
but it is
That shows me that the composite buffer is not working the right way. I found some old mailing lists entries (the newest was 2011) with composite buffer problems. Do I miss something or they still problems with the composite buffer? Is there another way to do this that I missed? Thanks Gatherer EDIT1: fixed the code example after the first reply EDIT2: I got it running today. But it’s a little bit weared. I post the real code so I can discribe it better. First the code.
asked 28 Jan ‘14, 07:45 Gatherer edited 30 Jan ‘14, 13:16 |
One Answer:
(Possibly your example doesn't match your actual code). That being said, you can obviously just create a new tvb and then copy portions of the existing tvb to the new tvb. ISTR tvb_composite goes through some gyrations (and may actually create a tvb with the components) so it may be no worse to just copy the sections into a new tvb. answered 28 Jan '14, 08:16 Bill Meier ♦♦ with the length you are right ... should be 16 byte per line with the offset you are right too .. thats the problem with writing simple example code .. ;) what do you mean with copy the code into a new tvb . just with memcpy? Do you have a small example? (28 Jan '14, 08:25) Gatherer I use wireshark 1.10.3 ... i can switch to the latest stable if needed (28 Jan '14, 08:34) Gatherer 1 I take that back :) not quite so "obviously".
See epan/tvbuff.h for details (especially for tvb_new_child_real_data) (The above was done quickly so it may not be quite correct). (28 Jan ‘14, 08:59) Bill Meier ♦♦ 1 P.S: I just re-ran the tvbtest diagnostic and it shows no problems with composite buffers; I don’t think there’s a need to update 1.10.3 (28 Jan ‘14, 09:02) Bill Meier ♦♦ I updated my comment (30 Jan ‘14, 13:16) Gatherer |
Just two quick notes: (I hadn’t noticed your update).
Update: Highlighting of the packet bytes based upon a composite buffer doesn’t work (as you noted)in GTK Wireshark. Feel free to file a bug at bugs.wireshark.org. I should note that it’s very unlikely that it will be fixed in GTK Wireshark since the dev Wireshark is now using QT as the GUI library. However, the bug report can serve as a reminder to check if the same problem exists in QT Wireshark.