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.
- checksums.yaml +4 -4
- data/lib/louis.rb +16 -3
- data/lib/louis/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a23145355005de6f4a9fd4ac295ef38f805119a2c517d4c1802c85a963ad165
|
4
|
+
data.tar.gz: 2efad33702a8a7534da9005cc8144d38160a2dd315540aeed2d7be7dd62e9ca3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60d1852ff3545e169ae355c85d94fab6249b2dedf48d4b7ea5a1702d17db7673b6d639e827f997c33292a7c8589adaa2e97998b37d866303bd0b539965c39330
|
7
|
+
data.tar.gz: cc88ffe8f66007fad9a08aa7f319d688c481878df0ef2b209b912f4de8cd1fd96ab2782a2278f50441369f4b6511b42b20d17acc60d3bfd392d0963d87ece3a5
|
data/lib/louis.rb
CHANGED
@@ -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)
|
data/lib/louis/version.rb
CHANGED