struct

IP::Address::IPv6

Inherits IP::Address < Comparable < Comparable < Struct < Value < Object

Constants

ADDRESS_MAX = ~0_u128
ADDRESS_WIDTH = 128_u8

Constructors

new(value : Value)

Creates a new IP::Address::IPv6 from a {{ Value.id }} value.

Source
new(string : String) : self

Constructs a new IP::Address::IPv6 from the contents of a String. Expects an address in the standard presentation form XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX or in the compressed from similar to XXXX:XXXX::XXXX:XXXX:XXXX.

Raises: MalformedError when the input is malformed.

Source
new(hextets : Hextets)

Constructs a new IP::Address::IPv6 from a Tuple of 8 UInt16.

Source
new(sockaddr : Pointer(LibC::SockaddrIn6)) : self

Constructs a new IP::Address::IPv6 from a SockaddrIn6*.

TODO: Significant testing nessissary.

Source
new(value : Int) : self

Constructs a new IP::Address::IPv6 from an Int.

Source

Class methods

new?(string : String) : self | Nil

Constructs a new IP::Address::IPv6 from the contents of a String. Expects an address in the standard presentation form XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX or in the compressed from similar to XXXX:XXXX::XXXX:XXXX:XXXX.

Returns nil when the input is malformed.

Source

Instance methods

[](index : Int) : Hextet

Returns the requested group from the address.

Raises OutOfBoundsError if the requested group is not [0..7].

Source
hextets

Returns a Tuple of 8 UInt16 which represent the addresses octets.

Source
loopback?

Informs if the address is in the loopback address space or not.

Source
max_value

The maximum address of this type.

Source
to_s(upcase : Bool, minify : Bool, io : IO) : Nil

Appends the presentation representation of the address to the given IO.

Source
to_s(upcase : Bool = false, minify : Bool = true) : String

Returns the presentation representation of the address as a String.

Source
to_sockaddr(port : UInt16 = 0_u16) : Pointer(LibC::Sockaddr)

Produces the c sockaddr_in6 struct required by bind, connect, sendto, and sendmsg.

Note: Unix Network Programming: Volume 1, 3rd Edition, p.71-72

  • sin6_len: default size of this struct is 28 bytes.
  • sin_zero: is unused.

TODO: Set correct scope id

Source
value

The internally stored value of the address.

Source
value_network

The internally stored value of the address in network byte order.

Source
width

The width of the address type.

Source

Nested types