asio-tr2 icon indicating copy to clipboard operation
asio-tr2 copied to clipboard

Consider scope_id on address_v6

Open chriskohlhoff opened this issue 10 years ago • 2 comments

chriskohlhoff avatar Feb 27 '15 10:02 chriskohlhoff

Pre-Lenexa Summary

[internet.address.v6]

The question is whether it is appropriate that address_v6 has a scope id, or whether it should be separate.

I'm not in favour of any change here.

Asio's design uses a top-down decomposition. A socket has-a remote endpoint and it has-a local endpoint. An endpoint (which is usually used in its IP version independent form) is composed of an address and a port. An IPv4 address has a 32 bit representation. An IPv6 address has a 128 bit representation plus a scope_id that may be meaningful for certain types of addresses (such as link-local addresses).

The address_v6::bytes_type type may be used when it is important that addresses be stored in their raw 128 bit form.

chriskohlhoff avatar May 05 '15 12:05 chriskohlhoff

The main motivation for wanting to separate the scope_id from the 128 bit IPv6 representation is that it makes the address larger than 128 bits - so should you want to pull a sequence of IPv6 values without scope_ids from a file or a byte stream (or indeed store them) you cannot map that directly to an IPv6 address.

However the bytes_type of the IPv6 address is specifically there to facilitate this purpose. This allows you to create a byte level mapping and expose a valid and generally useful IPv6 address with scope_id as required. Separating the scope_id from the 128 bit representation would not offer any improvement here but would instead fragment the interface.

ja11sop avatar May 05 '15 12:05 ja11sop