> (that is, bits 6-7 in byte 2, and bits 0-2 in byte 1, if you
> consider the 16 bits in bytes 1 and 2 to be a single unit (like an
> endian-independent uint16), and to count bits from the right)
No, read the bits in the order that they appear.
Example
03 80 00 00 00 00 02 FF FF
Suppose the protocol defined for the example is defined as:
Type: 6 bits
Subtype: 3 bits
Padding character: 7 bits
Padding length: 8 bits
Data length: 32 bits
Data: Data length bytes
Padding: Padding length bytes
What I was thinking about was to retrieve those values like this:
int type = tvbuff_get_bits( tvbf, 6 );
int subtype = tvbuff_get_bits( tvbf, 3 );
char pad_char = tvbuff_get_bits( tvbf, 7 );
int plength = tv_buff_get_byte( tvbf );
int dlen = tv_buff_get_bits( tvbf, 32 );
char* pdata = tv_buff_get_bytes( tvbf, pdata, dlen );
In short, let the tv_buff and it's accessors count the bits and bytes.
I know that the pseudocode above has it's problems ( the 32 bit length, is it big or little endian?)
but that is an implementation issue.
RFC1889 is a very nice (for low values of nice) example of this style of protocol
--
Andreas Sikkema