Hello André,
On 08/01/14 12:23, André Roth wrote:
...
+ union {
+ uint16_t bitfield;
+ struct {
+ uint16_t pid:13;
+ uint16_t one:3;
+ } __attribute__((packed));
+ } __attribute__((packed));
+ uint8_t type_version:5;
+ uint8_t one2:3;
+ uint32_t size;
Are you sure that this code handles the endianess correctly? Looking at
netinet/in.h I'm under the impression that the order of the bitfield
entries have to be swapped, too:
struct ip
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int ip_hl:4; /* header length */
unsigned int ip_v:4; /* version */
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned int ip_v:4; /* version */
unsigned int ip_hl:4; /* header length */
#endif
I also remember that you can also easily get the byte swapping wrongif
entries cross byte borders (like a :13 one).
Maybe you could write some unit tests for your functions. The Debian
build farm then will catch any errors.
Cheers,
Gregor
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html