Module Cf_ip6_addr


module Cf_ip6_addr: sig .. end
IPv6 addresses with attribute parameters for type safety.

This module implements IPv6 addresses in an abstract type suitable for use with the Cf_nameinfo module, the Cf_socket module and its cognates for IPv6 transports. Internally, the IPv6 address is represented as a boxed 16-byte custom block. Externally, the IPv6 address abstract type is parameterized with a shadow attribute that constrains how it may be used depending on its address format.


type -'a t 
The type of IPv4 addresses, parameterized by address format attribute.
type opaque = [ `AF_INET6 ] 
The shadow attribute type of IPv6 addresses of unknown format.

type format =
| Unspecified (*::0*)
| Unicast (*::1 to EFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF*)
| Multicast (*FF00::0 to FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF*)
The type of IPv6 address formats.
type unspecified = [ `AF_INET6 | `X ] 
The shadow attribute of the IPv6 unspecified address.
type unicast = [ `AF_INET6 | `U ] 
The shadow attribute of unicast IPv6 addresses.
type multicast = [ `AF_INET6 | `M ] 
The shadow attribute of multicast IPv6 addresses.
val format : opaque t -> format
Use format a to obtain the address format of the IPv6 address a.
val is_unicast : [> opaque ] t -> unicast t
Use is_unicast a to validate that the IPv6 address a is a unicast address. Raises Failure unless the address is a unicast address.
val is_multicast : [> opaque ] t -> multicast t
Use is_multicast a to validate that the IPv6 address a is a multicast address. Raises Failure unless the address is a multicast address.

type unicast_format =
| U_unassigned (*No format assigned.*)
| U_reserved (*Format is reserved for future assignment.*)
| U_loopback (*Loopback addresses.*)
| U_v4compat (*Compatible with tunnels to IPv4 destinations.*)
| U_v4mapped (*IPv4 addresses mapped into IPv6 addresses.*)
| U_link (*Link-local scope*)
| U_site (*Site-local scope (deprecated?)*)
| U_global (*Global scope*)
The type of unicast address formats.
val unicast_format : [> unicast ] t -> unicast_format
Use unicast_format a to obtain the unicast format of the unicast IPv6 address a.
type v4compat = [ `AF_INET6 | `U | `V4C ] 
The shadow attribute of "v4-compat" unicast addresses
val is_v4compat : [> unicast ] t -> Cf_ip4_addr.opaque Cf_ip4_addr.t
Use is_v4compat a to obtain the opaque IPv4 address corresponding to the v4-compat IPv6 address. Raises Failure if the address is not a v4-compat format address.
val to_v4compat : [> Cf_ip4_addr.unicast ] Cf_ip4_addr.t -> v4compat t
Use to_v4compat a to convert the unicast IPv4 address a to its v4-compat IPv6 address.
type v4mapped = [ `AF_INET6 | `U | `V4M ] 
The shadow attribute of "v4-mapped" unicast addresses
val is_v4mapped : [> unicast ] t -> Cf_ip4_addr.opaque Cf_ip4_addr.t
Use is_v4mapped a to obtain the opaque IPv4 address corresponding to the v4-mapped IPv6 address. Raises Failure if the address is not a v4-mapped format address.
val to_v4mapped : [> Cf_ip4_addr.unicast ] Cf_ip4_addr.t -> v4mapped t
Use to_v4mapped a to convert the unicast IPv4 address a to its v4-mapped IPv6 address.

type multicast_flag =
| M_F_transient (*Address is transiently allocated.*)
| M_F_unassigned of int (*Flag is reserved for future assignment.*)
The type of IPv6 multicast address format flags.

type multicast_scope =
| M_S_node (*Node-only scope.*)
| M_S_link (*Link-local scope.*)
| M_S_site (*Site-local scope.*)
| M_S_org (*Organization-local scope.*)
| M_S_global (*Global scope.*)
| M_S_unassigned of int (*Scope reserved for future assignment.*)
The type of IPv6 multicast address scopes.
type multicast_group_id = [ `AF_INET6 | `G ] 
The shadow attribute of multicast group identifiers.
val to_multicast_components : [> multicast ] t ->
multicast_scope * multicast_flag list *
multicast_group_id t
Use to_multicast_components a to obtain the scope, flags and group id of the IPv6 multicast address a.
val of_multicast_components : multicast_scope ->
multicast_flag list ->
multicast_group_id t ->
multicast t
Use of_multicast_components scope flags gid to compose an IPv6 multicast address from the scope, flags and gid components.
val unspecified : unspecified t
The unspecified IPv6 address, i.e. ::0
val loopback : unicast t
The default loopback IPv6 unicast address, i.e. ::1
val node_local_all_nodes : multicast t
The node-local all-nodes multicast address, i.e. ff01::1
val link_local_all_nodes : multicast t
The link-local all-nodes multicast address, i.e. ff02::1
val link_local_all_routers : multicast t
The link-local all-routers multicast address, i.e. ff02::2
val equal : ([> opaque ] as 'a) t -> 'a t -> bool
Use equal a1 a2 to compare two IPv6 addresses for equality.
val compare : ([> opaque ] as 'a) t -> 'a t -> int
Use compare a1 a2 to compare the ordinality of two IPv6 addresses.
val pton : string -> opaque t option
Use pton s to convert the string s containing an IPv6 address in numeric format to its equivalent opaque IPv6 address. Returns None if the string is not in canonical numeric format.
val ntop : [> opaque ] t -> string
Use ntop a to obtain a string representation of the IPv6 address a in canonical numeric format.