| Class | NetAddr::EUI |
| In: |
lib/eui.rb
|
| Parent: | Object |
A class & series of methods for creating and manipulating Extended Unique Identifier (EUI) addresses. Two types of address formats are supported EUI-48 and EUI-64. The most common use for this class will be to manipulate MAC addresses (which are essentially a type of EUI-48 address).
EUI addresses are separated into two parts, the Organizationally Unique Identifier (OUI) and the Extended Identifier (EI). The OUI is assigned by the IEEE and is used to identify a particular hardware manufacturer. The EI is assigned by the hardware manufacturer as a per device unique address.
Probably the most useful feature of this class, and thus the reason it was created, is to help automate certain address assignments within IP. For example, IPv6 Link Local addresses use MAC addresses for IP auto-assignment and multicast MAC addresses are determined based on the multicast IP address.
This method performs absolutely no error checking, and is meant to be used only by
other internal methods for the sake of the speedier creation of EUI objects.
Please consider using #create unless you know what you are doing with 100% certainty.
Example:
NetAddr::EUI48.new('aabbccddeeff')
Returns EUI address. The default address format is xxxx.xxxx.xxxx
Example:
addr = NetAddr::EUI.create('aabb.ccdd.eeff')
addr.address(:Delimiter => '-') => "aa-bb-cc-dd-ee-ff"
addr.address(:Delimiter => ':') => "aa:bb:cc:dd:ee:ff"
:Delimiter -- delimitation character. valid values are (- : .)
Returns Extended Identifier portion of an EUI address (the vendor assigned ID). The default address format is xx-xx-xx
Example:
addr = NetAddr::EUI.create('aabb.ccdd.eeff')
addr.ei(:Delimiter => '-') => "dd-ee-ff"
:Delimiter -- delimitation character. valid values are (-, and :)
Provide an IPv6 Link Local address based on the current EUI address.
Example:
addr = NetAddr::EUI.create('aabb.ccdd.eeff')
addr.link_local() => "fe80:0000:0000:0000:aabb:ccff:fedd:eeff"
:Short -- if true, return IPv6 addresses in short-hand notation :Objectify -- if true, return CIDR objects
Returns Organizationally Unique Identifier portion of an EUI address (the vendor ID). The default address format is xx-xx-xx.
Example:
addr = NetAddr::EUI.create('aabb.ccdd.eeff')
addr.oui(:Delimiter => '-') => "aa-bb-cc"
:Delimiter -- delimitation character. valid values are (-, and :)
Returns the EUI as an Integer.
Example:
addr = NetAddr::EUI.create('aabb.ccdd.eeff')
addr.to_i => 187723572702975
Given a valid IPv6 subnet, return an IPv6 address based on the current EUI.
Example:
addr = NetAddr::EUI.create('aabb.ccdd.eeff')
addr.to_ipv6('3ffe::/64') => "3ffe:0000:0000:0000:a8bb:ccff:fedd:eeff"
:Short -- if true, return IPv6 addresses in short-hand notation :Objectify -- if true, return CIDR objects