Device::MAC - Handle hardware MAC Addresses (EUI-48 and EUI-64)
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"; }
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
Creates and returns a new Device::MAC object. The MAC value is required.
Return the MAC that this object was created with.
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.
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.
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.
Given a MAC in any common format, normalizes it into a lower-case, zero padded, hexadecimal format with colon separators.
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.
cmp
<=>
Decodes a MAC into a list of 8 integers. This is primarily used internally, but may be useful in some circumstances.
These are internal methods that you generally won't have to worry about.
The BUILDARGS method overloads Moose::Object to allow you to pass a single string argument containing the MAC when calling "new".
A utility method that calls mac_cmp with the appropriate arguments. Used by overload.
Internal method for overload to call when attempting to stringify the object.
This utility method clears the values of any attributes that depend on the MAC. It is called when the MAC attribute it set.
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.
http://www.jasonkohles.com/software/device-mac
http://en.wikipedia.org/wiki/MAC_Address
Device::OUI
Jason Kohles <email@jasonkohles.com>
<email@jasonkohles.com>
http://www.jasonkohles.com
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.
To install Device::MAC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Device::MAC
CPAN shell
perl -MCPAN -e shell install Device::MAC
For more information on module installation, please visit the detailed CPAN module installation guide.