#630 display full oui vendor

This commit is contained in:
Oliver Gorwits
2019-08-18 10:49:57 +01:00
parent c73c3e7569
commit 26dbb714df
4 changed files with 22 additions and 17 deletions

View File

@@ -257,7 +257,7 @@ sub deploy_oui {
print color 'reset';
}
# This subroutine is from Wireshark's make-manuf
# This subroutine is baed on Wireshark's make-manuf
# http://anonsvn.wireshark.org/wireshark/trunk/tools/make-manuf
sub shorten {
my $manuf = shift;
@@ -271,22 +271,27 @@ sub shorten {
# & isn't needed when Standalone
$manuf =~ s/ \& / /g;
# remove junk whitespace
$manuf =~ s/\s+/ /g;
# Remove any "the", "inc", "plc" ...
$manuf
=~ s/\s(the|inc|incorporated|plc|systems|corp|corporation|s\/a|a\/s|ab|ag|kg|gmbh|co|company|limited|ltd|holding|spa)(?= )//gi;
=~ s/\s(?:the|inc|incorporated|plc|systems|corp|corporation|s\/a|a\/s|ab|ag|kg|gmbh|co|company|limited|ltd|holding|spa)(?= )//gi;
# Convert to consistent case
$manuf =~ s/(\w+)/\u\L$1/g;
# Remove all spaces
$manuf =~ s/\s+//g;
# Deviating from make-manuf for HP
$manuf =~ s/Hewlett[-]?Packard/Hp/;
# Truncate all names to a reasonable length, say, 8 characters.
# If the string contains UTF-8, this may be substantially more than 8 bytes.
$manuf = substr( $manuf, 0, 8 );
# Truncate all names to first two words max 20 chars
if (length($manuf) > 21) {
my @twowords = grep {defined} (split ' ', $manuf)[0 .. 1];
$manuf = join ' ', @twowords;
}
# Remove all spaces
$manuf =~ s/\s+//g;
return encode( "utf8", $manuf );
}

View File

@@ -47,7 +47,7 @@ get '/ajax/content/report/nodevendor/data' => require_login sub {
my $match = $vendor eq 'blank' ? undef : $vendor;
$rs = $rs->search( { 'oui.abbrev' => $match },
{ '+columns' => [qw/ device.dns device.name oui.abbrev /],
{ '+columns' => [qw/ device.dns device.name oui.abbrev oui.company /],
join => [qw/ oui device /],
collapse => 1,
});
@@ -86,7 +86,7 @@ get '/ajax/content/report/nodevendor' => require_login sub {
my $match = $vendor eq 'blank' ? undef : $vendor;
$rs = $rs->search( { 'oui.abbrev' => $match },
{ '+columns' => [qw/ device.dns device.name oui.abbrev /],
{ '+columns' => [qw/ device.dns device.name oui.abbrev oui.company /],
join => [qw/ oui device /],
collapse => 1,
});
@@ -102,9 +102,9 @@ get '/ajax/content/report/nodevendor' => require_login sub {
$rs = $rs->search(
{ },
{ join => 'oui',
select => [ 'oui.abbrev', { count => {distinct => 'me.mac'}} ],
as => [qw/ vendor count /],
group_by => [qw/ oui.abbrev /]
select => [ 'oui.abbrev', 'oui.company', { count => {distinct => 'me.mac'}} ],
as => [qw/ abbrev vendor count /],
group_by => [qw/ oui.abbrev oui.company /]
}
)->order_by( { -desc => 'count' } );

View File

@@ -43,7 +43,7 @@ $(document).ready(function() {
}, {
"data": 'oui.abbrev',
"render": function(data, type, row, meta) {
return '<a href="[% uri_for('/report/nodevendor') %]?vendor=' + encodeURIComponent(data || 'blank') + '">' + he.encode(data ||'(Unknown Vendor)') + '</a>';
return '<a href="[% uri_for('/report/nodevendor') %]?vendor=' + encodeURIComponent(row.oui.abbrev || 'blank') + '">' + he.encode(row.oui.company ||'(Unknown Vendor)') + '</a>';
}
}, {
"data": 'port',
@@ -71,7 +71,7 @@ $(document).ready(function() {
{
"data": 'vendor',
"render": function(data, type, row, meta) {
return '<a href="[% uri_for('/report/nodevendor') %]?vendor=' + encodeURIComponent(data || 'blank') + '">' + he.encode(data ||'(Unknown Vendor)') + '</a>';
return '<a href="[% uri_for('/report/nodevendor') %]?vendor=' + encodeURIComponent(row.abbrev || 'blank') + '">' + he.encode(row.vendor ||'(Unknown Vendor)') + '</a>';
}
}, {
"data": 'count',

View File

@@ -1,11 +1,11 @@
[% USE CSV -%]
[% IF opt %]
[% CSV.dump(['MAC' 'Vendor' 'Company' 'Device' 'Port']) %]
[% CSV.dump(['MAC' 'Company' 'Device' 'Port']) %]
[% FOREACH row IN results %]
[% mylist = [] %]
[% device = row.device.dns || row.device.name || row.switch %]
[% FOREACH col IN [ row.mac.upper row.oui.abbrev row.oui.company device row.port ] %]
[% FOREACH col IN [ row.mac.upper row.oui.company device row.port ] %]
[% mylist.push(col) %]
[% END %]
[% CSV.dump(mylist) %]