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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aacc08eac58a7b6385e494c825c2847291da3caf
4
- data.tar.gz: 47ec0bb01af5cae3df4d15afc4614de90bb65a4a
3
+ metadata.gz: adaad7bd50934cb9c07640c6337cd7ee05d3482f
4
+ data.tar.gz: 28014330bbdde67d3aae4fabd5eff3580ee21d6b
5
5
  SHA512:
6
- metadata.gz: 185d504d9cbbed532324d90cfa1ba15e0ecb2369a13619ecef8cc4750e725f0136ad958a34fe25cd87f593c604de4092a4dcb520f78f4ea3e8326ee491b67f5b
7
- data.tar.gz: 8c86da0357ec378fa5ca246a2a2ee7731041b10543787455ef383079179a40da3bc892f20adfbe6608e82d6fbda8139423bbe7e3bd48c28c74a575f2931d129e
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
@@ -1,3 +1,3 @@
1
1
  module Louis
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
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.1
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: 2015-12-17 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler