1package Netdot::Model::OUI;
2
3use base 'Netdot::Model';
4use warnings;
5use strict;
6
7my $logger = Netdot->log->get_logger('Netdot::Model::Device');
8
9=head1 NAME
10
11Netdot::Model::OUI - Organizational Unique Identifier (OUI) Class
12
13=head1 CLASS METHODS
14=cut
15
16############################################################################
17
18=head2 retrieve_all_hashref - Build a hash with key=OUI, value=vendor
19
20  Arguments:
21    None
22  Returns:
23    Hash reference
24  Examples:
25    my $uois = OUI->retrieve_all_hashref();
26
27
28=cut
29
30sub retrieve_all_hashref {
31    my ($class) = @_;
32    $class->isa_class_method('retrieve_all_hashref');
33
34    # Build the search-all-macs SQL query
35    my ($aref, %oui, $sth);
36
37    my $dbh = $class->db_Main;
38    eval {
39	$sth = $dbh->prepare_cached("SELECT oui,vendor FROM oui");
40	$sth->execute();
41	$aref = $sth->fetchall_arrayref;
42    };
43    if ( my $e = $@ ){
44	$class->throw_fatal($e);
45    }
46    # Build a hash
47    foreach my $row ( @$aref ){
48	my ($oui, $vendor) = @$row;
49	$oui{$oui} = $vendor;
50    }
51    return \%oui;
52}
53
54=head1 AUTHOR
55
56Carlos Vicente, C<< <cvicente at ns.uoregon.edu> >>
57
58=head1 COPYRIGHT & LICENSE
59
60Copyright 2012 University of Oregon, all rights reserved.
61
62This program is free software; you can redistribute it and/or modify
63it under the terms of the GNU General Public License as published by
64the Free Software Foundation; either version 2 of the License, or
65(at your option) any later version.
66
67This program is distributed in the hope that it will be useful, but
68WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
69or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
70License for more details.
71
72You should have received a copy of the GNU General Public License
73along with this program; if not, write to the Free Software Foundation,
74Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
75
76=cut
77
78#Be sure to return 1
791;
80