[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Probable Bug in tcp.h



Hello,
I probably found a bug in declaration of "struct tcphdr"!

struct tcphdr {
	u_short	th_sport;		/* source port */
	u_short	th_dport;		/* destination port */
	tcp_seq	th_seq;			/* sequence number */
	tcp_seq	th_ack;			/* acknowledgement number */
#if BYTE_ORDER == LITTLE_ENDIAN
	u_int	th_x2:4,		/* (unused) */						<---here
		th_off:4;		/* data offset */						<---
#endif
#if BYTE_ORDER == BIG_ENDIAN
	u_int	th_off:4,		/* data offset */
		th_x2:4;		/* (unused) */
#endif
	u_char	th_flags;

First of all I have the problam of misalignment of th_off. Because in this way 
always 4 bytes are read and the the bits of th_off are replaced. Then the 4 
bytes are written back. 

But should (th_x and th_off) not only be 1 byte in whole -> only read and 
write 1 byte?

I think if this was changed, my misalignment problems would go away!

I'll appreciate any thoughts on this!

Regards,
Marc

P.S.: Please cc me because I'm not on the list!
_______________________________________________
freebsd-net_(_at_)_freebsd_(_dot_)_org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscribe_(_at_)_freebsd_(_dot_)_org"