Hello. I'm working on a proxy server for X11, that will also do some slight data manipulation(color depth, watermarking and some more) on certain data. I've got the connection up and running, and I'm manipulating the server ip in the connection on 177/UDP so the client connects correctly through the proxy instead of calling the server instead. In other words, I've got a fully functional proxy that proxies the data through port 6000 from the client to the server.
What I'm attempting to do now is to parse the data stream and locate the beginning and type of every message to weed out the data I'll just pass on from the data I need to manipulate. However, I hit a snag really early in this.
The data that I get from the client is a single byte with the byteorder('B' in my case, but I'm making it support both), followed by 2 bytes for the major version(3) and 2 bytes for the minor version(11). Both of these are designated CARD16 in the protocol specification(http://tools.ietf.org/html/rfc1013). Following this is an AuthorizationName, meaning the type of authorization to use, of type STRING8. STRING8 is designated in docs as LISTOFCARD8, meaning a list of 8-bit unsigned integers.
Here's where the problem is: I haven't the slightest how long the LISTOFCARD8 is. Snip from specification : "the size of the length field may vary (it is not necessarily the same size as a FOO), in some cases may be implicit, and is not fully specified in this document.".
The actual data I've got, from byte 5 and onward in the datastream, is 0 0 12 0 10 0 0 and then the actual data stream(ASCII string "MIT-MAGIC-COOKIE-1"). I can't make out a valid string length from th bytes preceding it, and the string itself does not appear to be null terminated.
So, to my question, if it hasn't already come across: How can I determine the length of a ListOfFOO, or more specifically a ListOfCARD8, as set down in RFC 1013?
Thank you! // Eric Johansson