Class: IPAddress::IPv6::Unspecified

Inherits:
IPAddress::IPv6 show all
Defined in:
lib/ipaddress_2/ipv6.rb

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:

ip = IPAddress::IPv6::Unspecified.new

ip.to_s
  #=> => "::/128"

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

ip.unspecified?
  #=> true

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

ip = IPAddress "::"

ip.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.

Constant Summary

Constants inherited from IPAddress::IPv6

IN6FORMAT

Constants included from IPAddress

AUTHORS, GEM, NAME, VERSION

Instance Method Summary collapse

Methods inherited from IPAddress::IPv6

#+, #<=>, #[], #[]=, #add, #address, #advance_network, #allocate, #as_json, #bits, #broadcast, #broadcast_u128, compress, #compressed, #data, #each, expand, #find_adjacent_subnet, #first, groups, #groups, #hexs, #hostpart, #hostpart_u128, #include?, #include_all?, #last, #link_local?, #literal, #loopback?, #mapped?, #network, #network?, #network_u128, #next_network, parse_data, parse_hex, parse_u128, #pred, #prefix, #prefix=, #previous_network, #regress_network, #reverse, #size, #split, #subnet, #subtract, #succ, summarize, #supernet, #to_hex, #to_i, #to_s, #to_string, #to_string_uncompressed, #unique_local?, #unspecified?

Methods included from IPAddress

demongoize, deprecate, evolve, #ipv4?, #ipv6?, mongoize, #mongoize, ntoa, parse, valid?, valid_ip?, valid_ipv4?, valid_ipv4_netmask?, valid_ipv4_subnet?, valid_ipv6?, valid_ipv6_subnet?

Constructor Details

#initializeUnspecified

Creates a new IPv6 unspecified address

ip = IPAddress::IPv6::Unspecified.new

ip.to_s
   #=> => "::/128"

1271
1272
1273
1274
1275
1276
# File 'lib/ipaddress_2/ipv6.rb', line 1271

def initialize
  @address = ("0000:"*8).chop
  @groups = Array.new(8,0)
  @prefix = Prefix128.new(128)
  @compressed = compress_address
end