ip.h bitfields and CLICK_BYTE_ORDER?
Markku Savela <[email protected]>
| Newsgroups | gmane.network.routing.click |
|---|---|
| Message-ID | <[email protected]> |
I see following in ip.h (and similar stuff in ip6.h):
struct click_ip {
#if CLICK_BYTE_ORDER == CLICK_BIG_ENDIAN
unsigned ip_v : 4; /* 0 version == 4 */
unsigned ip_hl : 4; /* header length */
#elif CLICK_BYTE_ORDER == CLICK_LITTLE_ENDIAN
unsigned ip_hl : 4; /* 0 header length */
unsigned ip_v : 4; /* version == 4 */
#else
# error "unknown byte order"
#endif
How can these ever work reliably? I mean, what has bitfield
placement within a byte (or int) to do with the byte order?
The C standard gives the compiler a total freedom of
placing the consecutive bit fields within a struct.