oui-offline 1.0.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +59 -13
- data/bin/oui +34 -6
- data/db/oui.sqlite3 +0 -0
- data/ext/mkrf_conf.rb +22 -0
- data/lib/oui.rb +25 -5
- data/oui-offline.gemspec +6 -3
- metadata +27 -23
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 670a47021f9dc5fa1acbe9ee700d34c47a177294
|
4
|
+
data.tar.gz: 3dab82300ccadb0429e3905300cea80ab0639cb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 539dc57d88c7b810a9b3d94dc746c1973003a888ba1428587f041e2a210033345affec1721f34af80891383903cf53a080783fee0d166bf3dab3751bbb01de75
|
7
|
+
data.tar.gz: 41a7b222ef78de1f7023761f5d6f84d72c6ab7ee875b8b1bfd2c54e0411bbf59528df5130e6fde0a20ec5062c24f793e76319c01befc0df0801414a381c079d9
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -1,17 +1,37 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/steakknife/oui.svg)](https://travis-ci.org/steakknife/oui)
|
1
2
|
# OUI (Organizationally Unique Identifiers)
|
3
|
+
|
4
|
+
The 24-bit prefix of MAC / EUI-\* addresses.
|
5
|
+
|
6
|
+
This is a Ruby library and CLI tool `oui`
|
7
|
+
|
2
8
|
## Usage
|
3
9
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
```ruby
|
11
|
+
> OUI.find 'AA-BB-CC'
|
12
|
+
=> nil
|
13
|
+
> OUI.find '00:0c:85'
|
14
|
+
=> {
|
15
|
+
:id => 3205,
|
16
|
+
:organization => "CISCO SYSTEMS, INC.",
|
17
|
+
:address1 => "170 W. TASMAN DRIVE",
|
18
|
+
:address2 => "M/S SJA-2",
|
19
|
+
:address3 => "SAN JOSE CA 95134-1706",
|
20
|
+
:country => "UNITED STATES"
|
21
|
+
}
|
22
|
+
```
|
23
|
+
|
24
|
+
## CLI usage
|
25
|
+
|
26
|
+
```text
|
27
|
+
Usage: oui lookup [options...] oui+ # get corp name, oui in 24-bit oui in hex format
|
28
|
+
|
29
|
+
-j JSON verbose output
|
30
|
+
-r Ruby verbose output
|
31
|
+
-y YAML verbose output
|
32
|
+
|
33
|
+
oui update # update oui internal db from ieee.org
|
34
|
+
```
|
15
35
|
|
16
36
|
## Installation
|
17
37
|
### Gem (insecure installation)
|
@@ -31,7 +51,7 @@ See also: [waxseal](https://github.com/steakknife/waxseal)
|
|
31
51
|
### Bundler Installation
|
32
52
|
|
33
53
|
```ruby
|
34
|
-
gem 'oui-offline'
|
54
|
+
gem 'oui-offline'
|
35
55
|
```
|
36
56
|
|
37
57
|
### Manual Installation
|
@@ -47,9 +67,35 @@ gem 'oui-offline', git: 'https://github.com/steakknife/oui.git'
|
|
47
67
|
|
48
68
|
`oui lookup ABCDEF`
|
49
69
|
|
50
|
-
## Data
|
70
|
+
## Data source
|
51
71
|
|
52
72
|
Database sourced from the public IEEE list, but it can be rebuilt anytime by running `oui update` or `OUI.update_db`
|
73
|
+
The few duplicates that are of multiple entities per OUI instead choose the first registration.
|
74
|
+
|
75
|
+
## Unregistered OUIs
|
76
|
+
|
77
|
+
Place custom/unregistered OUIs in `data/oui-manual.json` and re-run `oui update` or `OUI.update_db`. Feel free to submit a PR to update these permanently.
|
78
|
+
|
79
|
+
## Return format
|
80
|
+
|
81
|
+
The `id` column is a stable, reversible conversion of the OUI as follows: the hexadecimal value of the OUI) to unsigned integer in network order (id).
|
82
|
+
|
83
|
+
- Use `OUI.oui_to_i('aa-bb-cc')` to obtain an `id` from an OUI
|
84
|
+
- Use `OUI.to_s(12345)` to do the inverse, obtain an OUI from an `id`
|
85
|
+
|
86
|
+
## Supported Ruby Engines
|
87
|
+
|
88
|
+
- JRuby
|
89
|
+
- Ruby 1.9.3+ (until February 2015), 2.*
|
90
|
+
|
91
|
+
## Tested Ruby Engines
|
92
|
+
|
93
|
+
- JRuby 1.7.*
|
94
|
+
- Ruby (MRI) 2.2.*
|
95
|
+
|
96
|
+
## Thanks
|
97
|
+
|
98
|
+
[Your name here]
|
53
99
|
|
54
100
|
## License
|
55
101
|
|
data/bin/oui
CHANGED
@@ -2,23 +2,51 @@
|
|
2
2
|
lib_dir = File.expand_path('../../lib', __FILE__)
|
3
3
|
$:.unshift lib_dir unless $:.include? lib_dir
|
4
4
|
require 'oui'
|
5
|
+
autoload :JSON, 'json'
|
6
|
+
autoload :YAML, 'yaml'
|
7
|
+
|
8
|
+
# TODO: OptParse || thor
|
9
|
+
RUBY_OUTPUT = ARGV.delete '-v'
|
10
|
+
JSON_OUTPUT = ARGV.delete '-j'
|
11
|
+
YAML_OUTPUT = ARGV.delete '-y'
|
12
|
+
|
13
|
+
def output(r)
|
14
|
+
put(if YAML_OUTPUT
|
15
|
+
YAML.dump r
|
16
|
+
elsif JSON_OUTPUT
|
17
|
+
JSON.dump r
|
18
|
+
elsif RUBY_OUTPUT
|
19
|
+
r
|
20
|
+
else
|
21
|
+
r[:organization]
|
22
|
+
end)
|
23
|
+
end
|
5
24
|
|
6
|
-
VERBOSE = ARGV.delete '-v'
|
7
25
|
case ARGV.shift
|
8
26
|
when 'lookup'
|
27
|
+
success = nil
|
28
|
+
formats = [RUBY_OUTPUT, JSON_OUTPUT, YAML_OUTPUT].count { |x| x };
|
29
|
+
fail 'Only one format flag is allowed' if formats > 1
|
9
30
|
ARGV.map do |mac|
|
10
|
-
|
11
|
-
|
12
|
-
|
31
|
+
r = OUI.find(mac)
|
32
|
+
success &= !!r
|
33
|
+
output(r || {})
|
13
34
|
end
|
35
|
+
exit 1 unless success
|
14
36
|
|
15
37
|
when 'update'
|
16
38
|
OUI.update_db
|
17
39
|
|
18
40
|
else
|
19
41
|
$stderr.puts <<-EOS
|
20
|
-
Usage: oui lookup oui+ # get corp name, oui in 24-bit oui in hex format
|
21
|
-
|
42
|
+
Usage: oui lookup [options...] oui+ # get corp name, oui in 24-bit oui in hex format
|
43
|
+
|
44
|
+
-j JSON verbose output
|
45
|
+
-r Ruby verbose output
|
46
|
+
-y YAML verbose output
|
47
|
+
|
48
|
+
oui update # update oui internal db from ieee.org
|
49
|
+
|
22
50
|
EOS
|
23
51
|
exit 1
|
24
52
|
end
|
data/db/oui.sqlite3
CHANGED
Binary file
|
data/ext/mkrf_conf.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/command'
|
3
|
+
require 'rubygems/dependency_installer'
|
4
|
+
|
5
|
+
begin
|
6
|
+
Gem::Command.build_args = ARGV
|
7
|
+
$stderr.puts "ARGV=#{ARGV}"
|
8
|
+
rescue NoMethodError
|
9
|
+
end
|
10
|
+
|
11
|
+
inst = Gem::DependencyInstaller.new
|
12
|
+
if RUBY_PLATFORM == 'java'
|
13
|
+
inst.install 'jdbc-sqlite3'
|
14
|
+
else
|
15
|
+
inst.install 'sqlite3', '~> 1'
|
16
|
+
end
|
17
|
+
|
18
|
+
# create dummy rakefile to indicate success
|
19
|
+
File.open(File.join(File.dirname(__FILE__), 'Rakefile'), 'w') do |f|
|
20
|
+
f.puts('task :default')
|
21
|
+
end
|
22
|
+
$stderr.puts 'Finished installing oui driver for sequel'
|
data/lib/oui.rb
CHANGED
@@ -31,20 +31,31 @@ module OUI
|
|
31
31
|
# @return [Hash,nil]
|
32
32
|
def find(oui)
|
33
33
|
update_db unless table? && table.count > 0
|
34
|
-
table.where(id:
|
34
|
+
table.where(id: OUI.to_i(oui)).first
|
35
35
|
end
|
36
36
|
|
37
37
|
# Converts an OUI string to an integer of equal value
|
38
38
|
# @param oui [String,Integer] MAC OUI in hexadecimal formats
|
39
39
|
# hhhh.hh, hh:hh:hh, hh-hh-hh or hhhhhh
|
40
40
|
# @return [Integer] numeric representation of oui
|
41
|
-
def
|
41
|
+
def to_i(oui)
|
42
42
|
return oui if oui.is_a? Integer
|
43
43
|
oui = oui.strip.gsub(/[:\- .]/, '')
|
44
44
|
return unless oui =~ /[[:xdigit:]]{6}/
|
45
45
|
oui.to_i(16)
|
46
46
|
end
|
47
47
|
|
48
|
+
# Convert an id to OUI
|
49
|
+
# @param oui [String,nil] string to place between pairs of hex digits, nil for none
|
50
|
+
# @return [String] hexadecimal format of id
|
51
|
+
def to_s(id, sep = '-')
|
52
|
+
return id if id.is_a? String
|
53
|
+
unless id >= 0x000000 && id <= 0xFFFFFF
|
54
|
+
raise ArgumentError, "#{id} is not a valid 24-bit OUI"
|
55
|
+
end
|
56
|
+
format('%06x', id).scan(/../).join(sep)
|
57
|
+
end
|
58
|
+
|
48
59
|
# Release backend resources
|
49
60
|
def close_db
|
50
61
|
@db = nil
|
@@ -54,6 +65,7 @@ module OUI
|
|
54
65
|
# @return [Integer] number of unique records loaded
|
55
66
|
def update_db
|
56
67
|
## Sequel
|
68
|
+
close_db
|
57
69
|
drop_table
|
58
70
|
create_table
|
59
71
|
db.transaction do
|
@@ -78,12 +90,20 @@ module OUI
|
|
78
90
|
|
79
91
|
def connect_file_db(f)
|
80
92
|
FileUtils.mkdir_p(File.dirname(f))
|
81
|
-
|
93
|
+
if RUBY_PLATFORM == 'java'
|
94
|
+
Sequel.connect('jdbc:sqlite:'+f)
|
95
|
+
else
|
96
|
+
Sequel.sqlite(f)
|
97
|
+
end
|
82
98
|
end
|
83
99
|
|
84
100
|
def connect_db
|
85
101
|
if IN_MEMORY_ONLY
|
86
|
-
|
102
|
+
if RUBY_PLATFORM == 'java'
|
103
|
+
Sequel.connect('jdbc:sqlite::memory:')
|
104
|
+
else
|
105
|
+
Sequel.sqlite # in-memory sqlite database
|
106
|
+
end
|
87
107
|
else
|
88
108
|
debug "Connecting to db file #{LOCAL_DB}"
|
89
109
|
connect_file_db LOCAL_DB
|
@@ -198,7 +218,7 @@ module OUI
|
|
198
218
|
g = g.map { |k, v| [k.to_sym, v] }
|
199
219
|
g = Hash[g]
|
200
220
|
# convert OUI octets to integers
|
201
|
-
g[:id] =
|
221
|
+
g[:id] = OUI.to_i(g[:id])
|
202
222
|
create_unless_present(g)
|
203
223
|
end
|
204
224
|
rescue Errno::ENOENT
|
data/oui-offline.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification::new do |s|
|
2
2
|
s.name = 'oui-offline'
|
3
|
-
s.version = '1.
|
3
|
+
s.version = '1.2.3'
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.summary = 'Organizationally Unique Idenitfiers (OUI)'
|
6
6
|
s.description = 'Organizationally Unique Idenitfiers (OUI) offline database'
|
@@ -12,6 +12,7 @@ Gem::Specification::new do |s|
|
|
12
12
|
'bin/oui',
|
13
13
|
'data/oui-manual.json',
|
14
14
|
'db/oui.sqlite3',
|
15
|
+
'ext/mkrf_conf.rb',
|
15
16
|
'lib/oui.rb',
|
16
17
|
'oui-offline.gemspec',
|
17
18
|
]
|
@@ -25,7 +26,9 @@ Gem::Specification::new do |s|
|
|
25
26
|
s.homepage = 'https://github.com/steakknife/oui'
|
26
27
|
s.post_install_message = 'Oui!'
|
27
28
|
|
28
|
-
s.add_dependency '
|
29
|
-
s.
|
29
|
+
s.add_dependency 'sequel', '~> 4'
|
30
|
+
s.extensions << 'ext/mkrf_conf.rb'
|
31
|
+
s.add_development_dependency 'rake', '~> 10'
|
32
|
+
s.add_development_dependency 'minitest', '~> 5'
|
30
33
|
end
|
31
34
|
.tap {|gem| pk = File.expand_path(File.join('~/.keys', 'gem-private_key.pem')); gem.signing_key = pk if File.exist? pk; gem.cert_chain = ['gem-public_cert.pem']} # pressed firmly by waxseal
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oui-offline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Barry Allard
|
@@ -41,53 +41,56 @@ cert_chain:
|
|
41
41
|
TE/ChTQStrIVMKgW+FbU3E6AmrM6HcwTi7mwsDM8S36y2NZ5DVaZPCpvkiTDgPSW
|
42
42
|
t/HWh1yhriCUe/y8+De8M87btOs=
|
43
43
|
-----END CERTIFICATE-----
|
44
|
-
date: 2015-01-
|
44
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
45
45
|
dependencies:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: sequel
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
|
-
- - "
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '1.3'
|
53
|
-
- - "<"
|
50
|
+
- - "~>"
|
54
51
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
52
|
+
version: '4'
|
56
53
|
type: :runtime
|
57
54
|
prerelease: false
|
58
55
|
version_requirements: !ruby/object:Gem::Requirement
|
59
56
|
requirements:
|
60
|
-
- - "
|
57
|
+
- - "~>"
|
61
58
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
63
|
-
- - "<"
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: '2'
|
59
|
+
version: '4'
|
66
60
|
- !ruby/object:Gem::Dependency
|
67
|
-
name:
|
61
|
+
name: rake
|
68
62
|
requirement: !ruby/object:Gem::Requirement
|
69
63
|
requirements:
|
70
|
-
- - "
|
64
|
+
- - "~>"
|
71
65
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
73
|
-
|
66
|
+
version: '10'
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '10'
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: minitest
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
74
79
|
- !ruby/object:Gem::Version
|
75
80
|
version: '5'
|
76
|
-
type: :
|
81
|
+
type: :development
|
77
82
|
prerelease: false
|
78
83
|
version_requirements: !ruby/object:Gem::Requirement
|
79
84
|
requirements:
|
80
|
-
- - "
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '4'
|
83
|
-
- - "<"
|
85
|
+
- - "~>"
|
84
86
|
- !ruby/object:Gem::Version
|
85
87
|
version: '5'
|
86
88
|
description: Organizationally Unique Idenitfiers (OUI) offline database
|
87
89
|
email: barry.allard@gmail.com
|
88
90
|
executables:
|
89
91
|
- oui
|
90
|
-
extensions:
|
92
|
+
extensions:
|
93
|
+
- ext/mkrf_conf.rb
|
91
94
|
extra_rdoc_files: []
|
92
95
|
files:
|
93
96
|
- Gemfile
|
@@ -95,6 +98,7 @@ files:
|
|
95
98
|
- bin/oui
|
96
99
|
- data/oui-manual.json
|
97
100
|
- db/oui.sqlite3
|
101
|
+
- ext/mkrf_conf.rb
|
98
102
|
- lib/oui.rb
|
99
103
|
- oui-offline.gemspec
|
100
104
|
homepage: https://github.com/steakknife/oui
|
metadata.gz.sig
CHANGED
Binary file
|