Parsing package

Howdy folks,

I’m currently writing something and i got stuck.

I’m suppose to parse a package and get the length of it and then retrieve the rest of the data.

Except i somehow can’t get the package to be parsed correctly.

The full client bitstream (except the filling zero’s behind)

01-91-17-62-38-CF-FB-00-F0-3E-F9-B2-47-17-CE-BF-1B-63-B9-41-22-F6-EF-8E-33-E3-29-DB-48-47-F5-A0-4E-DA-95-5C-86-17-65-F7-6D-F0-4C-73-52-8B-34-76-3B-A0-51-29-A9-D4-A3-44-23-39-EE-0B-67-E4-BA-E4-58-CF-21-A0-0C-7E-90-21-BD-00-04-08-31-32-33-34-35-36-37-38

I need to parse the last package (08 … 38)

I created a struct at the top of the page

typedef struct AUTH_LOGON_AUTHENTICATE_C
{
uint8 length;
uint32 data;
} sAuthLogonAuthenticate_C;
After this inside the void i want to get the length

sAuthLogonAuthenticate_C lp;

if (!socket().recv((char *)&lp, sizeof(sAuthLogonAuthenticate_C)))
    return false;

std::vector<uint8> buf;
buf.resize(2);

socket().recv((char *)&buf[0], 2);

#if TRINITY_ENDIAN == TRINITY_BIGENDIAN
EndianConvert(((uint16)(buf[0])));
#endif

sLog->outDebug(LOG_FILTER_AUTHSERVER, “Length: %#04x”, buf[0]);

I want to retrieve the length (08) and then the following bits after that according the length (31-32-33-34-35-36-37-38)

What am i doing wrong ?

Was thinking a bit to stupid here, at the line

if (!socket().recv((char *)&lp, sizeof(sAuthLogonAuthenticate_C)))
return false;

It’s loaded into lp, so i can get the length just by doing lp.length /emoticons/default_smile.png

But it’s still unclear to get the data (31-32-33-34-35-36-37-38) since lp.data is NULL.

Hope somebody can help me out here.

Read it by parts, first read the uint8 and then read [length] bytes.