[#193] DBI Exception for Cisco ACE MacAddr format
Also standardise on IEEE MAC format now that NetAddr::MAC has that corrected.
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
* Delete all job queue entries (regardless of status) when deleting device
|
* Delete all job queue entries (regardless of status) when deleting device
|
||||||
* [#15] Undiscovered Neighbor report JOIN fixed, and updated to include
|
* [#15] Undiscovered Neighbor report JOIN fixed, and updated to include
|
||||||
the ports where Macsuck saw the MAC address of a known Device
|
the ports where Macsuck saw the MAC address of a known Device
|
||||||
|
* [#193] DBI Exception for Cisco ACE MacAddr format
|
||||||
|
|
||||||
2.029014 - 2014-11-19
|
2.029014 - 2014-11-19
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App::Netdisco::Util::Node 'check_mac';
|
|||||||
use App::Netdisco::Util::DNS ':all';
|
use App::Netdisco::Util::DNS ':all';
|
||||||
use NetAddr::IP::Lite ':lower';
|
use NetAddr::IP::Lite ':lower';
|
||||||
use Time::HiRes 'gettimeofday';
|
use Time::HiRes 'gettimeofday';
|
||||||
|
use NetAddr::MAC ();
|
||||||
|
|
||||||
use base 'Exporter';
|
use base 'Exporter';
|
||||||
our @EXPORT = ();
|
our @EXPORT = ();
|
||||||
@@ -119,9 +120,11 @@ sub store_arp {
|
|||||||
my ($hash_ref, $now) = @_;
|
my ($hash_ref, $now) = @_;
|
||||||
$now ||= 'now()';
|
$now ||= 'now()';
|
||||||
my $ip = $hash_ref->{'ip'};
|
my $ip = $hash_ref->{'ip'};
|
||||||
my $mac = $hash_ref->{'node'};
|
my $mac = NetAddr::MAC->new($hash_ref->{'node'});
|
||||||
my $name = $hash_ref->{'dns'};
|
my $name = $hash_ref->{'dns'};
|
||||||
|
|
||||||
|
return if !defined $mac or $mac->errstr;
|
||||||
|
|
||||||
schema('netdisco')->txn_do(sub {
|
schema('netdisco')->txn_do(sub {
|
||||||
my $current = schema('netdisco')->resultset('NodeIp')
|
my $current = schema('netdisco')->resultset('NodeIp')
|
||||||
->search(
|
->search(
|
||||||
@@ -131,7 +134,7 @@ sub store_arp {
|
|||||||
schema('netdisco')->resultset('NodeIp')
|
schema('netdisco')->resultset('NodeIp')
|
||||||
->update_or_create(
|
->update_or_create(
|
||||||
{
|
{
|
||||||
mac => $mac,
|
mac => $mac->as_ieee,
|
||||||
ip => $ip,
|
ip => $ip,
|
||||||
dns => $name,
|
dns => $name,
|
||||||
active => \'true',
|
active => \'true',
|
||||||
|
|||||||
@@ -756,7 +756,7 @@ sub store_neighbors {
|
|||||||
if (!defined $neigh) {
|
if (!defined $neigh) {
|
||||||
my $mac = NetAddr::MAC->new(mac => $remote_id);
|
my $mac = NetAddr::MAC->new(mac => $remote_id);
|
||||||
if ($mac and not $mac->errstr) {
|
if ($mac and not $mac->errstr) {
|
||||||
$neigh = $devices->single({mac => $mac->as_microsoft()});
|
$neigh = $devices->single({mac => $mac->as_ieee});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,8 +770,8 @@ sub store_neighbors {
|
|||||||
if ($mac and not $mac->errstr) {
|
if ($mac and not $mac->errstr) {
|
||||||
info sprintf
|
info sprintf
|
||||||
'[%s] neigh - found neighbor %s by MAC %s',
|
'[%s] neigh - found neighbor %s by MAC %s',
|
||||||
$device->ip, $remote_id, $mac->as_microsoft();
|
$device->ip, $remote_id, $mac->as_ieee;
|
||||||
$neigh = $devices->single({mac => $mac->as_microsoft()});
|
$neigh = $devices->single({mac => $mac->as_ieee});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ sub check_mac {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# lower case, hex, colon delimited, 8-bit groups
|
# lower case, hex, colon delimited, 8-bit groups
|
||||||
$node = lc $mac->as_microsoft;
|
$node = lc $mac->as_ieee;
|
||||||
}
|
}
|
||||||
|
|
||||||
# broadcast MAC addresses
|
# broadcast MAC addresses
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ ajax '/ajax/content/search/node' => require_login sub {
|
|||||||
|
|
||||||
my @where_mac =
|
my @where_mac =
|
||||||
($using_wildcards ? \['me.mac::text ILIKE ?', $likeval]
|
($using_wildcards ? \['me.mac::text ILIKE ?', $likeval]
|
||||||
: ((!defined $mac or $mac->errstr) ? \'0=1' : ('me.mac' => $mac->as_microsoft)) );
|
: ((!defined $mac or $mac->errstr) ? \'0=1' : ('me.mac' => $mac->as_ieee)) );
|
||||||
|
|
||||||
my $sightings = schema('netdisco')->resultset('Node')
|
my $sightings = schema('netdisco')->resultset('Node')
|
||||||
->search({-and => [@where_mac, @active, @times]}, {
|
->search({-and => [@where_mac, @active, @times]}, {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use Dancer::Plugin::DBIC;
|
|||||||
use Dancer::Plugin::Auth::Extensible;
|
use Dancer::Plugin::Auth::Extensible;
|
||||||
|
|
||||||
use App::Netdisco::Util::Web 'sql_match';
|
use App::Netdisco::Util::Web 'sql_match';
|
||||||
|
use NetAddr::MAC ();
|
||||||
|
|
||||||
hook 'before' => sub {
|
hook 'before' => sub {
|
||||||
# view settings for node options
|
# view settings for node options
|
||||||
@@ -78,6 +79,7 @@ get '/search' => require_login sub {
|
|||||||
else {
|
else {
|
||||||
my $nd = $s->resultset('Device')->search_fuzzy($q);
|
my $nd = $s->resultset('Device')->search_fuzzy($q);
|
||||||
my ($likeval, $likeclause) = sql_match($q);
|
my ($likeval, $likeclause) = sql_match($q);
|
||||||
|
my $mac = NetAddr::MAC->new($q);
|
||||||
|
|
||||||
if ($nd and $nd->count) {
|
if ($nd and $nd->count) {
|
||||||
if ($nd->count == 1) {
|
if ($nd->count == 1) {
|
||||||
@@ -96,8 +98,9 @@ get '/search' => require_login sub {
|
|||||||
->search({
|
->search({
|
||||||
-or => [
|
-or => [
|
||||||
{name => $likeclause},
|
{name => $likeclause},
|
||||||
(length $q == 17 ? {mac => $q}
|
((!defined $mac or $mac->errstr)
|
||||||
: \['mac::text ILIKE ?', $likeval]),
|
? \['mac::text ILIKE ?', $likeval]
|
||||||
|
: {mac => $mac->as_ieee}),
|
||||||
],
|
],
|
||||||
})->count) {
|
})->count) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user