struct IP::Address::IPv6

Defined in:

ip/address/ipv6.cr

Constant Summary

ADDRESS_MAX = ~0_u128
ADDRESS_WIDTH = 128_u8

0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_u128

Constructors

Instance Method Summary

Instance methods inherited from struct IP::Address

+(other : Int) : self +, -(other : Int) : self -, <=>(other : IP::Address) : Int
<=>(other : IP::Block) : Int
<=>
, [](index : Int) [], adjacent?(other : IP::Block)
adjacent?(other : IP::Address)
adjacent?
, family : Socket::Family family, hash(hasher) hash, inspect(io : IO) : Nil inspect, ipv4? : Bool ipv4?, ipv6? : Bool ipv6?, loopback? : Bool loopback?, max_value max_value, to_sockaddr to_sockaddr, value value, value_network value_network, width width

Constructor methods inherited from struct IP::Address

[](string : String) : self [], []?(string : String) : self? []?, new(string : String) : self
new(sockaddr : ::Pointer(LibC::Sockaddr)) : self
new
, new?(string : String) : self? new?

Class methods inherited from struct IP::Address

ipv4(string : String) ipv4, ipv4?(string : String) ipv4?, ipv6(string : String) ipv6, ipv6?(string : String) ipv6?

Constructor Detail

def self.new(value : Value) #

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


[View source]
def self.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.


[View source]
def self.new(hextets : Hextets) #

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


[View source]
def self.new(sockaddr : ::Pointer(LibC::SockaddrIn6)) : self #

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

TODO Significant testing nessissary.


[View source]
def self.new(value : Int) : self #

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


[View source]
def self.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.

Returns nil when the input is malformed.


[View source]

Instance Method Detail

def [](index : Int) : Hextet #

Returns the requested group from the address.

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


[View source]
def hextets : Hextets #

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


[View source]
def loopback? : Bool #

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


[View source]
def max_value : Value #

The maximum address of this type.


[View source]
def to_s(upcase : Bool, minify : Bool, io : IO) : Nil #

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


[View source]
def to_s(upcase : Bool = false, minify : Bool = true) : String #

Returns the presentation representation of the address as a String.


[View source]
def 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


[View source]
def value : Value #

The internally stored value of the address.


[View source]
def value_network : StaticArray(LibC::UInt16T, 8) #

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


[View source]
def width : UInt8 #

The width of the address type.


[View source]