Ethereal-dev: Re: [Ethereal-dev] Need help with desegmenting VNC traffic over TCP.

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Mon, 6 Oct 2003 14:16:36 -0700

On Oct 6, 2003, at 5:15 AM, Brad Hards wrote:

OK, I'm confused again.
How do I desegment a message like the attached one?

You'd dissect it with what I suspect won't be code that's as simple as you'd like, because RFB doesn't have a nice message size field at the beginning of all messages. :-)

If number-of-rectangles is non-zero, you know that you need at least 12 bytes more in the packet, for the fixed-length portion of the first rectangle. So, at that point, if you don't have those 12 bytes, you tell the desegmentation code you need it, and return.

Once you have those 12 bytes, you compute how many bytes of rectangle data you need, based on the width, height, and, presumably, encoding and, if you don't have all of them, you ask for them.

Unfortunately, that only works for the first rectangle - you are correct, you'll need state attached to the conversation to handle the rest, to keep track of which rectangle you're reassembling.

The state I'd attach would be the number of rectangles. Once you've fully desegmented a rectangle, decrement that number by 1 and, if it's non-zero, keep desegmenting, otherwise dissect the packet.