But, glibc and the rest of user-space is working off those standard headers, so those are the ones you want to be using.
The <linux/*> ones are typically straight out of the kernel source, and often aren't appropriate for user-space.
-- referenced here.
So <netinet/tcp.h> <netinet/udp.h> <netinet/icmp.h> are what we want.
If on x86 or x86_64, little-endian will set to macro __BIT_ORDER in <endian.h>.
In <netinet/tcp.h>:
# else /* !__FAVOR_BSD */
struct tcphdr
{
u_int16_t source;
u_int16_t dest;
u_int32_t seq;
u_int32_t ack_seq;
# if __BYTE_ORDER == __LITTLE_ENDIAN
u_int16_t res1:4;
u_int16_t doff:4;
u_int16_t fin:1;
u_int16_t syn:1;
u_int16_t rst:1;
u_int16_t psh:1;
u_int16_t ack:1;
u_int16_t urg:1;
u_int16_t res2:2;
# elif __BYTE_ORDER == __BIG_ENDIAN
u_int16_t doff:4;
u_int16_t res1:4;
u_int16_t res2:2;
u_int16_t urg:1;
u_int16_t ack:1;
u_int16_t psh:1;
u_int16_t rst:1;
u_int16_t syn:1;
u_int16_t fin:1;
# else
# error "Adjust your defines"
# endif
u_int16_t window;
u_int16_t check;
u_int16_t urg_ptr;
};
# endif /* __FAVOR_BSD */
I've tested and checked that __BYTE_ORDER == __LITTLE_ENDIAN.
No comments:
Post a Comment