in6.h: declare in6_addr with a union and extra fields
According to https://tools.ietf.org/html/rfc3493: 3.2 IPv6 Address Structure "The structure in6_addr above is usually implemented with an embedded union with extra fields that force the desired alignment level in a manner similar to BSD implementations of "struct in_addr"." Change-Id: Ibe0ee685366398c143cdf9573dcb77566a12888b Reviewed-on: https://review.haiku-os.org/c/haiku/+/3348 Reviewed-by: Rene Gollent <rene@gollent.com>
This commit is contained in:
parent
fb4fd84f4d
commit
7335fb0d5c
@ -11,8 +11,17 @@
|
||||
|
||||
|
||||
struct in6_addr {
|
||||
uint8_t s6_addr[16];
|
||||
};
|
||||
union {
|
||||
uint8_t u6_addr8[16];
|
||||
uint16_t u6_addr16[8];
|
||||
uint32_t u6_addr32[4];
|
||||
} in6_u;
|
||||
#define s6_addr in6_u.u6_addr8
|
||||
#define s6_addr16 in6_u.u6_addr16
|
||||
#define s6_addr32 in6_u.u6_addr32
|
||||
} _PACKED;
|
||||
|
||||
|
||||
|
||||
/* IP Version 6 socket address. */
|
||||
struct sockaddr_in6 {
|
||||
@ -25,21 +34,21 @@ struct sockaddr_in6 {
|
||||
};
|
||||
|
||||
|
||||
#define IN6ADDR_ANY_INIT {{ \
|
||||
#define IN6ADDR_ANY_INIT {{{ \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
|
||||
#define IN6ADDR_LOOPBACK_INIT {{ \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
|
||||
#define IN6ADDR_LOOPBACK_INIT {{{ \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
|
||||
#define IN6ADDR_NODELOCAL_ALLNODES_INIT {{ \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
|
||||
#define IN6ADDR_NODELOCAL_ALLNODES_INIT {{{ \
|
||||
0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
|
||||
#define IN6ADDR_LINKLOCAL_ALLNODES_INIT {{ \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
|
||||
#define IN6ADDR_LINKLOCAL_ALLNODES_INIT {{{ \
|
||||
0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
|
||||
#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT {{ \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
|
||||
#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT {{{ \
|
||||
0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
|
||||
|
||||
extern const struct in6_addr in6addr_any;
|
||||
extern const struct in6_addr in6addr_loopback;
|
||||
|
Loading…
Reference in New Issue
Block a user