Reputation: 11
Can anyone explain the concept of network byte order and host byte order for ipv6 addresses .
Upvotes: 0
Views: 620
Reputation: 10000
In IPv6, there's effectively no difference.
The following assumes C on Linux and Windows:
In IPv4, an address is stored as an unsigned 32-bit integer, so it is affected by the endianness of the system. It must therefore be converted to network byte order before it can be sent on the wire.
But an IPv6 address is stored in a sockaddr_in6
struct, in a field in6_addr
which is also a struct containing an array of 16 unsigned 8-bit characters.
Therefore, because the IPv6 address is always effectively in network byte order, it is not necessary to do any byte order conversion when working with IPv6 addresses, e.g. those returned from getaddrinfo()
. You may simply treat the in6_addr
struct as opaque data.
Upvotes: 1