NAME
Device::MAC - Handle hardware MAC Addresses (EUI-48 and EUI-64)
SYNOPSIS
use Device::MAC;
my $mac = Device::MAC->new( '00:19:e3:01:0e:72' );
print $mac->normalized."\n";
if ( $mac->is_unicast ) {
print "\tIs Unicast\n";
} elsif ( $mac->is_multicast ) {
print "\tIs Multicast\n";
}
if ( $mac->is_local ) {
print "\tIs Locally Administered\n";
} elsif ( $mac->is_universal ) {
print "\tIs Universally Administered\n";
print "\tVendor: ".$mac->oui->organization."\n";
}
DESCRIPTION
This module provides an interface to deal with Media Access Control (or MAC) addresses. These are the addresses that uniquely identify a device on a network. Although the common case is hardware addresses on network cards, there are a variety of devices that use this system. This module supports both EUI-48 and EUI-64 addresses.
Some devices that use EUI-48 (or MAC-48) addresses include:
Ethernet
802.11 wireless networks
Bluetooth
IEEE 802.5 token ring
FDDI
ATM
Some devices that use EUI-64 addresses include:
Firewire
IPv6
ZigBee / 802.15.4 wireless personal-area networks
METHODS
Device::MAC->new( $mac )
Creates and returns a new Device::MAC object. The MAC value is required.
$mac->mac
Return the MAC that this object was created with.
$mac->oui
Returns a Device::OUI object representing the OUI (Organizationally Unique Identifier) for the MAC. This object can give you information about the vendor of the device represented by this MAC.
$mac->normalized
Return a 'normalized' MAC value for this object. The normalized value is in lower-case hex, with colon separators (such as '00:19:e3:01:0e:72').
Device::MAC objects have stringification overloaded to return this value.
FUNCTIONS / EXPORTS
Although this module is entirely object oriented, there are a handful of utility functions that you can import from this module if you find a need for them. Nothing is exported by default, so if you want to import any of them you need to say so explicitly:
use Device::MAC qw( ... );
You can get all of them by importing the ':all' tag:
use Device::MAC ':all';
The exporting is handled by Sub::Exporter.
normalize_mac( $mac )
Given a MAC in any common format, normalizes it into a lower-case, zero padded, hexadecimal format with colon separators.
mac_cmp( $mac1, $mac2 )
This is a convenience method, given two Device::MAC objects, or two MACs (in any format acceptable to "normalize_mac") will return -1, 0, or 1, depending on whether the first MAC is less than, equal to, or greater than the second one.
Device::MAC objects have cmp
and <=>
overloaded so that simply comparing them will work as expected.
mac_to_integers( $mac )
Decodes a MAC into a list of 8 integers. This is primarily used internally, but may be useful in some circumstances.
INTERNAL METHODS
These are internal methods that you generally won't have to worry about.
BUILDARGS
The BUILDARGS method overloads Moose::Object to allow you to pass a single string argument containing the MAC when calling "new".
overload_cmp
A utility method that calls mac_cmp with the appropriate arguments. Used by overload.
overload_stringify
Internal method for overload to call when attempting to stringify the object.
clear_mac_dependent
This utility method clears the values of any attributes that depend on the MAC. It is called when the MAC attribute it set.
MODULE HOME PAGE
The home page of this module is http://www.jasonkohles.com/software/device-mac. This is where you can always find the latest version, development versions, and bug reports. You will also find a link there to report bugs.
SEE ALSO
http://www.jasonkohles.com/software/device-mac
http://en.wikipedia.org/wiki/MAC_Address
AUTHOR
Jason Kohles <email@jasonkohles.com>
COPYRIGHT AND LICENSE
Copyright 2008, 2009 Jason Kohles
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.