I am trying to decode a websocket frame, but I\'m not successful when it comes to decoding the extended payload. Here what I did achieve so far:
char *in = data;
If packet_length is 126, the following 2 bytes give the length of data to be read.
If packet_length is 127, the following 8 bytes give the length of data to be read.
The mask is contained in the following 4 bytes (after the length).
The message to be decoded follows this.
The data framing section of the spec has a useful illustration of this.
If you re-order your code to something like
then things should work.