Created
May 31, 2012 07:44
-
-
Save pachacamac/2841710 to your computer and use it in GitHub Desktop.
Mac address OUI lookup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db, oui, company, address = {}, nil, nil, '' | |
lines = File.readlines('oui.txt') #http://standards.ieee.org/develop/regauth/oui/oui.txt | |
lines.each do |line| | |
#line.encode!('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode!('UTF-8', 'UTF-16').rstrip! | |
line = line.unpack("C*").pack("U*").rstrip | |
if m = line.match(/^(\d\d-\d\d-\d\d)\s+\(hex\)\s+(.*?)$/) | |
oui, company = m[1], m[2] | |
elsif oui && company && m = line.match(/^\s+(.*?)$/) | |
address << m[1] << "\n" | |
elsif oui && company && line == '' | |
db[oui] = [company, address] | |
oui, company, address = nil, nil, '' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment