Revert "[#23] Move to NetAddr::MAC for better handling of MACs"

This reverts commit 562b3d26db.

Discovered a few unpolished bits of NetAddr::MAC, unfortunately. For example
$NetAddr::MAC::errstr is not reset when new instances are created.
This commit is contained in:
Oliver Gorwits
2014-05-28 23:23:08 +01:00
parent 97f68aaeb6
commit ba38f9e93d
12 changed files with 32 additions and 51 deletions

View File

@@ -3,7 +3,7 @@ package App::Netdisco::Util::Node;
use Dancer qw/:syntax :script/;
use Dancer::Plugin::DBIC 'schema';
use NetAddr::MAC;
use Net::MAC;
use App::Netdisco::Util::Permission 'check_acl';
use base 'Exporter';
@@ -66,18 +66,18 @@ MAC address does not belong to an interface on any known Device
sub check_mac {
my ($device, $node, $port_macs) = @_;
my $mac = NetAddr::MAC->new(mac => $node);
my $mac = Net::MAC->new(mac => $node, 'die' => 0, verbose => 0);
$port_macs ||= {};
# incomplete MAC addresses (BayRS frame relay DLCI, etc)
if ($mac->errstr) {
if ($mac->get_error) {
debug sprintf ' [%s] check_mac - mac [%s] malformed - skipping',
$device->ip, $node;
return 0;
}
else {
# lower case, hex, colon delimited, 8-bit groups
$node = lc $mac->as_microsoft;
$node = lc $mac->as_IEEE;
}
# broadcast MAC addresses