louis 2.2.6 → 2.3.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/louis.rb +16 -3
  3. data/lib/louis/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27e838a561868bb08e6cb122a38cd013f1d19cc1c0885abad4a4b702dce0fc40
4
- data.tar.gz: 531a76d566067c09bcf30cffe152f730ad117c9209713cd6def625507f1d6fcb
3
+ metadata.gz: 7a23145355005de6f4a9fd4ac295ef38f805119a2c517d4c1802c85a963ad165
4
+ data.tar.gz: 2efad33702a8a7534da9005cc8144d38160a2dd315540aeed2d7be7dd62e9ca3
5
5
  SHA512:
6
- metadata.gz: babe19acc931feca5368dd8372172a3466ead255f9562c6f738ec643568350f651db3396dc8fde8062ea378326e6a81f07a78c3db5ed172f63454161e7816ef4
7
- data.tar.gz: 64892d2b3941ed426649b79c67aed95bdca4a972ae9c63b1b0067acaff7c858582fe691866a33422f7dd1c90b056e4d5268134539ba6726e282277248844ac4d
6
+ metadata.gz: 60d1852ff3545e169ae355c85d94fab6249b2dedf48d4b7ea5a1702d17db7673b6d639e827f997c33292a7c8589adaa2e97998b37d866303bd0b539965c39330
7
+ data.tar.gz: cc88ffe8f66007fad9a08aa7f319d688c481878df0ef2b209b912f4de8cd1fd96ab2782a2278f50441369f4b6511b42b20d17acc60d3bfd392d0963d87ece3a5
@@ -10,10 +10,17 @@ module Louis
10
10
  # of the first byte in a vendor prefix.
11
11
  IGNORED_BITS_MASK = 0xfcffffffffff
12
12
 
13
+ # Flag to indicate that this address is generated versus one assigned by a
14
+ # manufacturer.
15
+ LOCALLY_ADMINISTERED_BIT = 0x020000000000
16
+
13
17
  # Loads the lookup table, parsing out the uncommented non-blank lines into
14
18
  # objects we can compare MACs against to find their vendor.
15
19
  LOOKUP_TABLE = JSON.parse(File.read(Louis::PARSED_DATA_FILE))
16
20
 
21
+ # Bit flag indicating that the address is directed at more than one recipient.
22
+ MULTICAST_BIT = 0x010000000000
23
+
17
24
  # Collect the recorded mask and order it appropriately from most specific to
18
25
  # least.
19
26
  #
@@ -31,10 +38,15 @@ module Louis
31
38
  numeric_mac = Louis::Helpers.mac_to_num(mac)
32
39
  masked_mac = numeric_mac & IGNORED_BITS_MASK
33
40
 
41
+ address_flags = []
42
+ address_flags << (numeric_mac & MULTICAST_BIT > 0 ? :multicast : :unicast)
43
+ address_flags << (numeric_mac & LOCALLY_ADMINISTERED_BIT > 0 ? :locally_generated : :manufacturer_generated)
44
+
34
45
  if (vendor = search_table(masked_mac))
35
46
  return {
47
+ 'flags' => address_flags,
36
48
  'long_vendor' => vendor['l'],
37
- 'short_vendor' => vendor['s']
49
+ 'short_vendor' => vendor['s'],
38
50
  }.compact
39
51
  end
40
52
 
@@ -42,12 +54,13 @@ module Louis
42
54
  # Google... with your 'da' prefix...)
43
55
  if (vendor = search_table(numeric_mac))
44
56
  return {
57
+ 'flags' => address_flags,
45
58
  'long_vendor' => vendor['l'],
46
- 'short_vendor' => vendor['s']
59
+ 'short_vendor' => vendor['s'],
47
60
  }.compact
48
61
  end
49
62
 
50
- {'long_vendor' => 'Unknown', 'short_vendor' => 'Unknown'}
63
+ {'flags' => address_flags, 'long_vendor' => 'Unknown', 'short_vendor' => 'Unknown'}
51
64
  end
52
65
 
53
66
  def self.search_table(encoded_mac)
@@ -1,3 +1,3 @@
1
1
  module Louis
2
- VERSION = '2.2.6'
2
+ VERSION = '2.3.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: louis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.6
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stelfox