class IPAddress::IPv6::Unspecified

Overview

The address with all zero bits is called the unspecified address (corresponding to 0.0.0.0 in IPv4). It should be something like this:

0000:0000:0000:0000:0000:0000:0000:0000

but, with the use of compression, it is usually written as just two colons:

::

or, specifying the netmask:

::/128

With IPAddress, create a new unspecified IPv6 address using its own subclass:

ip6 = IPAddress::IPv6::Unspecified.new
ip6.to_s # => => "::/128"

You can easily check if an IPv6 object is an unspecified address by using the IPv6#unspecified? method

ip6.unspecified? # => true

An unspecified IPv6 address can also be created with the wrapper method, like we've seen before

ip6 = IPAddress.new "::"
ip6.unspecified? # => true

This address must never be assigned to an interface and is to be used only in software before the application has learned its host's source address appropriate for a pending connection. Routers must not forward packets with the unspecified address.

Defined in:

ipaddress/ipv6_unspecified.cr

Constructors

Instance methods inherited from class IPAddress::IPv6

<=>(other : IPv6) <=>, ==(other : self) ==, [](index : Int32) : Int32 [], []=(index : Int32, value : Int32) : Nil []=, address : String address, bits : String bits, broadcast_u128 : BigInt broadcast_u128, compressed : String compressed, data : Bytes data, each(&) : Nil each, groups : Array(Int32) groups, hash(hasher) hash, hexs : Array(String) hexs, includes?(others : Array(IPv6))
includes?(other)
includes?(*others : IPv6)
includes?
, link_local? link_local?, literal : String literal, loopback? loopback?, mapped? mapped?, network : IPv6 network, network? network?, network_u128 : BigInt network_u128, pred : IPv6 pred, prefix : Prefix128 prefix, prefix=(prefix : Int32) : Prefix128 prefix=, reverse : String reverse, size : BigInt size, succ : IPv6 succ, to_big_i : BigInt to_big_i, to_hex : String to_hex, to_s(io : IO) to_s, to_string : String to_string, to_string_uncompressed : String to_string_uncompressed, unique_local? unique_local?, unspecified? unspecified?

Constructor methods inherited from class IPAddress::IPv6

new(addr : String, netmask = nil) new, parse_data(data : Bytes, prefix = 128) : IPv6 parse_data, parse_hex(hex : String, prefix = 128) : IPv6 parse_hex, parse_u128(u128 : BigInt, prefix = 128) : IPv6 parse_u128

Class methods inherited from class IPAddress::IPv6

compress(addr : String) : String compress, expand(addr : String) : String expand, groups(addr : String) : Array(Int32) groups, valid?(addr : String) valid?

Instance methods inherited from module IPAddress

ipv4? ipv4?, ipv6? ipv6?

Constructor methods inherited from module IPAddress

new(addr : String | Int) : IPAddress new, parse(addr : String | Int) : IPAddress parse

Class methods inherited from module IPAddress

aton(addr : String) : UInt32 aton, ntoa(uint : UInt32) : String
ntoa(int : Int) : String
ntoa
, valid?(addr : String) valid?, valid_ipv4?(addr : String) valid_ipv4?, valid_ipv4_netmask?(addr : String) valid_ipv4_netmask?, valid_ipv6?(addr : String) valid_ipv6?

Constructor Detail

def self.new #

Creates a new IPv6 unspecified address.

ip6 = IPAddress::IPv6::Unspecified.new
ip6.to_string # => "::/128"

[View source]