louis 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/louis.rb +6 -1
- data/lib/louis/version.rb +1 -1
- data/spec/louis_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adaad7bd50934cb9c07640c6337cd7ee05d3482f
|
4
|
+
data.tar.gz: 28014330bbdde67d3aae4fabd5eff3580ee21d6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 941bd810af19878ceb73521ba89592f4089b11832675a48aeac97cbd95f3c3aa0350ad8c8022754eb8856c71a39ccef114d596d66fb9a4b8f2c56822a8dacfe4
|
7
|
+
data.tar.gz: de5e80da9bea9b268ead29368866ca43fbcba49b4df353d146629f1538068d14b35eb3fe581755217d88ae21799f5a0af70c64202ba878f75881bfd5b77510f9
|
data/lib/louis.rb
CHANGED
@@ -7,6 +7,11 @@ require 'louis/version'
|
|
7
7
|
module Louis
|
8
8
|
extend Helpers
|
9
9
|
|
10
|
+
# This masks out both the 'universal/local' bit as well as the
|
11
|
+
# 'unicast/multicast' bit which is the first and second least significant bit
|
12
|
+
# of the first byte in a vendor prefix.
|
13
|
+
IGNORED_BITS_MASK = 0xfcffffffffff
|
14
|
+
|
10
15
|
# Loads the lookup table, parsing out the uncommented non-blank lines into
|
11
16
|
# objects we can compare MACs against to find their vendor.
|
12
17
|
def self.lookup_table
|
@@ -30,7 +35,7 @@ module Louis
|
|
30
35
|
match = nil
|
31
36
|
|
32
37
|
mask_keys.each do |mask|
|
33
|
-
prefix = mac_to_num(mac) & calculate_mask(nil, mask)
|
38
|
+
prefix = mac_to_num(mac) & IGNORED_BITS_MASK & calculate_mask(nil, mask)
|
34
39
|
match = lookup_table[mask.to_s][prefix.to_s]
|
35
40
|
|
36
41
|
break if match
|
data/lib/louis/version.rb
CHANGED
data/spec/louis_spec.rb
CHANGED
@@ -31,6 +31,8 @@ RSpec.describe Louis do
|
|
31
31
|
let(:base_mac) { '00:12:34:00:00:00' }
|
32
32
|
let(:partial_mac) { '3c:97:0e' }
|
33
33
|
let(:unknown_mac) { 'c5:00:00:00:00:00' }
|
34
|
+
let(:local_mac) { '3e:97:0e' }
|
35
|
+
let(:multicast_mac) { '3d:97:0e' }
|
34
36
|
|
35
37
|
it 'should return a hash' do
|
36
38
|
expect(Louis.lookup(base_mac)).to be_a(Hash)
|
@@ -56,6 +58,14 @@ RSpec.describe Louis do
|
|
56
58
|
expect(Louis.lookup(partial_mac)['long_vendor']).to eq('Wistron InfoComm(Kunshan)Co.,Ltd.')
|
57
59
|
end
|
58
60
|
|
61
|
+
it 'should drop the local bit when performing a lookup' do
|
62
|
+
expect(Louis.lookup(local_mac)['short_vendor']).to eq('WistronI')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should drop the multicast bit when performing a lookup' do
|
66
|
+
expect(Louis.lookup(multicast_mac)['short_vendor']).to eq('WistronI')
|
67
|
+
end
|
68
|
+
|
59
69
|
it 'should return "Unknown" as the short vendor string for unknown MAC prefixes' do
|
60
70
|
expect(Louis.lookup(unknown_mac)['short_vendor']).to eq('Unknown')
|
61
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: louis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stelfox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|