.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::MAC::Vendor 3pm" .TH Net::MAC::Vendor 3pm "2019-12-26" "perl v5.30.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::MAC::Vendor \- Look up the vendor for a MAC .SH "VERSION" .IX Header "VERSION" version 1.265 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Net::MAC::Vendor; \& \& my $mac = "00:0d:93:29:f6:c2"; \& \& my $array = Net::MAC::Vendor::lookup( $mac ); .Ve .PP You can also run this as a script with as many arguments as you like. The module realizes it is a script, looks up the information for each \s-1MAC,\s0 and outputs it. .PP .Vb 1 \& perl Net/MAC/Vendor.pm 00:0d:93:29:f6:c2 00:0d:93:29:f6:c5 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Institute of Electrical and Electronics Engineers (\s-1IEEE\s0) assigns an Organizational Unique Identifier (\s-1OUI\s0) to manufacturers of network interfaces. Each interface has a Media Access Control (\s-1MAC\s0) address of six bytes. The first three bytes are the \s-1OUI.\s0 .PP This module allows you to take a \s-1MAC\s0 address and turn it into the \s-1OUI\s0 and vendor information. You can, for instance, scan a network, collect \s-1MAC\s0 addresses, and turn those addresses into vendors. With vendor information, you can often guess at what what you are looking at (\fIe.g.\fR an Apple product). .PP You can use this as a module as its individual functions, or call it as a script with a list of \s-1MAC\s0 addresses as arguments. The module can figure it out. .PP The \s-1IEEE\s0 moves the location of its \s-1OUI\s0 file. If they do that again, you can set the \f(CW\*(C`NET_MAC_VENDOR_OUI_URL\*(C'\fR environment variable to get the new \&\s-1URL\s0 without updating the code. .PP Here are some of the old URLs, which also flip-flop schemes: .PP .Vb 4 \& http://standards.ieee.org/regauth/oui/oui.txt \& https://standards.ieee.org/regauth/oui/oui.txt \& http://standards\-oui.ieee.org/oui.txt \& http://standards\-oui.ieee.org/oui/oui.txt .Ve .PP There are older copies of the \s-1OUI\s0 file in the GitHub repository. .PP These files are large (about 4MB), so you might want to cache a copy. .PP A different source of information is linuxnet.ca that publishes sanitized and compressed versions of the list, such as: .PP .Vb 1 \& http://linuxnet.ca/ieee/oui.txt.bz2 .Ve .PP The module can read and decompress compressed versions (as long as the url reflects the compression type in the filename as the linuxnet.ca links do). .SS "Functions" .IX Subsection "Functions" .ie n .IP "run( @macs )" 4 .el .IP "run( \f(CW@macs\fR )" 4 .IX Item "run( @macs )" If I call this module as a script, this class method automatically runs. It takes the \s-1MAC\s0 addresses and prints the registered vendor information for each address. I can pass it a list of \s-1MAC\s0 addresses and \fBrun()\fR processes each one of them. It prints out what it discovers. .Sp This method does try to use a cache of \s-1OUI\s0 to cut down on the times it has to access the network. If the cache is fully loaded (perhaps using \f(CW\*(C`load_cache\*(C'\fR), it may not even use the network at all. .IP "ua" 4 .IX Item "ua" Return the Mojo::UserAgent object used to fetch resources. .IP "lookup( \s-1MAC\s0 )" 4 .IX Item "lookup( MAC )" Given the \s-1MAC\s0 address, return an anonymous array with the vendor information. The first element is the vendor name, and the remaining elements are the address lines. Different records may have different numbers of lines, although the first two should be consistent. .Sp This makes a direct request to the \s-1IEEE\s0 website for that \s-1OUI\s0 to return the information for that vendor. .Sp The \f(CW\*(C`normalize_mac()\*(C'\fR function explains the possible formats for \s-1MAC.\s0 .IP "normalize_mac( \s-1MAC\s0 )" 4 .IX Item "normalize_mac( MAC )" Takes a \s-1MAC\s0 address and turns it into the form I need to send to the \s-1IEEE\s0 lookup, which is the first six bytes in hex separated by hyphens. For instance, 00:0d:93:29:f6:c2 turns into 00\-0D\-93. .Sp The input string can be a separated by colons or hyphens. They can omit leading 0's (which might make things look odd). We only need the first three bytes .Sp .Vb 1 \& 00:0d:93:29:f6:c2 # usual form \& \& 00\-0d\-93\-29\-f6\-c2 # with hyphens \& \& 00:0d:93 # first three bytes \& \& 0:d:93 # missing leading zero \& \& :d:93 # missing all leading zeros .Ve .Sp The input string can also be a blessed NetAddr::MAC object. .IP "fetch_oui( \s-1MAC\s0 )" 4 .IX Item "fetch_oui( MAC )" Looks up the \s-1OUI\s0 information on the \s-1IEEE\s0 website, or uses a cached version of it. Pass it the result of \f(CW\*(C`normalize_mac()\*(C'\fR and you should be fine. .Sp The \f(CW\*(C`normalize_mac()\*(C'\fR function explains the possible formats for \&\s-1MAC.\s0 .Sp To avoid multiple calls on the network, use \f(CW\*(C`load_cache\*(C'\fR to preload the entire \s-1OUI\s0 space into an in-memory cache. This can take a long time over a slow network, though; the file is about 60,000 lines. .Sp Also, the \s-1IEEE\s0 website has been flaky lately, so loading the cache is better. This distribution comes with several versions of the complete \&\s-1OUI\s0 data file. .IP "fetch_oui_from_custom( \s-1MAC,\s0 [ \s-1URL\s0 ] )" 4 .IX Item "fetch_oui_from_custom( MAC, [ URL ] )" Looks up the \s-1OUI\s0 information from the specified \s-1URL\s0 or the \s-1URL\s0 set in the \f(CW\*(C`NET_MAC_VENDOR_OUI_SOURCE\*(C'\fR environment variable. .Sp The \f(CW\*(C`normalize_mac()\*(C'\fR function explains the possible formats for \&\s-1MAC.\s0 .IP "fetch_oui_from_ieee( \s-1MAC\s0 )" 4 .IX Item "fetch_oui_from_ieee( MAC )" Looks up the \s-1OUI\s0 information on the \s-1IEEE\s0 website. Pass it the result of \f(CW\*(C`normalize_mac()\*(C'\fR and you should be fine. .Sp The \f(CW\*(C`normalize_mac()\*(C'\fR function explains the possible formats for \&\s-1MAC.\s0 .IP "fetch_oui_from_cache( \s-1MAC\s0 )" 4 .IX Item "fetch_oui_from_cache( MAC )" Looks up the \s-1OUI\s0 information in the cached \s-1OUI\s0 information (see \&\f(CW\*(C`load_cache\*(C'\fR). .Sp The \f(CW\*(C`normalize_mac()\*(C'\fR function explains the possible formats for \&\s-1MAC.\s0 .Sp To avoid multiple calls on the network, use \f(CW\*(C`load_cache\*(C'\fR to preload the entire \s-1OUI\s0 space into an in-memory cache. .Sp If it doesn't find the \s-1MAC\s0 in the cache, it returns nothing. .IP "extract_oui_from_html( \s-1HTML, OUI\s0 )" 4 .IX Item "extract_oui_from_html( HTML, OUI )" Gets rid of the \s-1HTML\s0 around the \s-1OUI\s0 information. It may still be ugly. The \s-1HTML\s0 is the search results page of the \s-1IEEE\s0 ouisearch lookup. .Sp Returns false if it could not extract the information. This could mean unexpected input or a change in format. .IP "parse_oui( \s-1STRING\s0 )" 4 .IX Item "parse_oui( STRING )" Takes a string that looks like this: .Sp .Vb 5 \& 00\-03\-93 (hex) Apple Computer, Inc. \& 000393 (base 16) Apple Computer, Inc. \& 20650 Valley Green Dr. \& Cupertino CA 95014 \& UNITED STATES .Ve .Sp and turns it into an array of lines. It discards the first line, strips the leading information from the second line, and strips the leading whitespace from all of the lines. .Sp With no arguments, it returns an empty anonymous array. .IP "oui_url" 4 .IX Item "oui_url" .PD 0 .IP "oui_urls" 4 .IX Item "oui_urls" .PD Returns the URLs of the oui.txt resource. The \s-1IEEE\s0 likes to move this around. These are the default \s-1URL\s0 that \f(CW\*(C`load_cache\*(C'\fR will use, but you can also supply your own with the \f(CW\*(C`NET_MAC_VENDOR_OUI_URL\*(C'\fR environment variable. .IP "load_cache( [ SOURCE[, \s-1DEST\s0 ] ] )" 4 .IX Item "load_cache( [ SOURCE[, DEST ] ] )" Downloads the current list of all OUIs in \s-1SOURCE,\s0 parses it with \&\f(CW\*(C`parse_oui()\*(C'\fR, and stores it in the cache. The \f(CW\*(C`fetch_oui()\*(C'\fR will use this cache if it exists. .Sp By default, this uses the \s-1URL\s0 from \f(CW\*(C`oui_url\*(C'\fR, but given an argument, it tries to use that. .Sp If the url indicates that the data is compressed, the response content is decompressed before being stored. .Sp If \f(CW\*(C`load_cache\*(C'\fR cannot load the data, it issues a warning and returns nothing. .Sp This previously used DBM::Deep if it was installed, but that was much too slow. Instead, if you want persistence, you can play with \&\f(CW$Net::MAC::Vendor::Cached\fR yourself. .Sp If you want to store the data fetched for later use, add a destination filename to the request. To fetch from the default location and store, specify \f(CW\*(C`undef\*(C'\fR as source. .SH "Caching" .IX Header "Caching" Eventually I want people to write their own caching classes so I've created some class methods for this. .IP "add_to_cache( \s-1OUI, PARSED_DATA\s0 )" 4 .IX Item "add_to_cache( OUI, PARSED_DATA )" Add to the cache. This is mostly in place for a future expansion to full objects so you can override this in a subclass. .IP "get_from_cache( \s-1OUI\s0 )" 4 .IX Item "get_from_cache( OUI )" Get from the cache. This is mostly in place for a future expansion to full objects so you can override this in a subclass. .IP "\fBget_cache_hash()\fR" 4 .IX Item "get_cache_hash()" Get the hash the built-in cache uses. You should only use this if you were using the old \f(CW$Cached\fR package variable. .PP 1; _\|_END_\|_ .SH "SEE ALSO" .IX Header "SEE ALSO" Net::MacMap .SH "SUPPORT" .IX Header "SUPPORT" Bugs may be submitted through the \s-1RT\s0 bug tracker (or bug\-Net\-MAC\-Vendor@rt.cpan.org ). .PP I am also usually active on irc, as 'ether' at \f(CW\*(C`irc.perl.org\*(C'\fR. .SH "AUTHOR" .IX Header "AUTHOR" brian d foy .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" .IP "\(bu" 4 brian d foy .IP "\(bu" 4 Karen Etheridge .IP "\(bu" 4 Frank Maas .IP "\(bu" 4 openstrike .IP "\(bu" 4 Dean Hamstead .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is Copyright (c) 2004 by brian d foy. .PP This is free software, licensed under: .PP .Vb 1 \& The Artistic License 2.0 (GPL Compatible) .Ve