Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Jun 2008 17:12:47 +0200
From:      Marc =?iso-8859-1?q?L=F6rner?= <marc.loerner@hob.de>
To:        freebsd-net@freebsd.org
Subject:   Probable Bug in tcp.h
Message-ID:  <200806051712.47048.marc.loerner@hob.de>

next in thread | raw e-mail | index | archive | help
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!



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806051712.47048.marc.loerner>