Class NetAddr::EUI
In: lib/eui.rb
Parent: Object

EUI - Extended Unique Identifier

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.

Methods

address   create   ei   link_local   new   oui   to_i   to_ipv6   to_s  

Public Class methods

Synopsis

Create a new EUI48 or EUI64 object.

 Example:
 addr = NetAddr::EUI.create('aa-bb-cc-dd-ee-ff')
 addr = NetAddr::EUI.create('aa:bb:cc:dd:ee:ff')
 addr = NetAddr::EUI.create('aabb.ccdd.eeff')
 addr = NetAddr::EUI.create('aa-bb-cc-dd-ee-ff-00-01')

Arguments

  • eui = EUI as a String

Returns

Synopsis

 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')

Arguments:

  • EUI as a String or Integer. Strings should contain no formatting characters.

Public Instance methods

Synopsis

 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"

Arguments:

  • options = Hash with the following fields:
      :Delimiter -- delimitation character. valid values are (- : .)
    

Returns:

  • String

Synopsis

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"

Arguments:

  • options = Hash with the following fields:
      :Delimiter -- delimitation character. valid values are (-, and :)
    

Returns:

  • String

Synopsis

 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"

Arguments:

  • options = Hash with the following fields:
      :Short -- if true, return IPv6 addresses in short-hand notation
      :Objectify -- if true, return CIDR objects
    

Returns:

Synopsis

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"

Arguments:

  • options = Hash with the following fields:
      :Delimiter -- delimitation character. valid values are (-, and :)
    

Returns:

  • String

Synopsis

Returns the EUI as an Integer.

 Example:
 addr = NetAddr::EUI.create('aabb.ccdd.eeff')
 addr.to_i => 187723572702975

Arguments:

  • none

Returns:

  • Integer

Synopsis

 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"

Arguments:

  • options = Hash with the following fields:
      :Short -- if true, return IPv6 addresses in short-hand notation
      :Objectify -- if true, return CIDR objects
    

Returns:

Synopsis

Returns the EUI as an unformatted String.

 Example:
 addr = NetAddr::EUI.create('aabb.ccdd.eeff')
 addr.to_s => "aabbccddeeff"

Arguments:

  • none

Returns:

  • String

[Validate]