mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
host_details.lua: add MAC-based host classification
This commit adds to host details the classification of a host based on its MAC address. The classification is performed according to https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf. This partially addresses issue #43.
This commit is contained in:
parent
0161be04b2
commit
0d2eeeb4d8
3 changed files with 26695 additions and 1 deletions
|
|
@ -1505,6 +1505,10 @@ function split(s, delimiter)
|
|||
return result;
|
||||
end
|
||||
|
||||
function startswith(s, char)
|
||||
return string.sub(s, 1, string.len(s)) == char
|
||||
end
|
||||
|
||||
function strsplit(inputstr, sep)
|
||||
if (inputstr == nil or inputstr == "") then return {} end
|
||||
if sep == nil then
|
||||
|
|
@ -1576,3 +1580,22 @@ function makeTopStatsScriptsArray()
|
|||
end
|
||||
return(topArray)
|
||||
end
|
||||
|
||||
function get_mac_classification(mac_address)
|
||||
local file_mac = io.open(fixPath(dirs.installdir.."/third-party/well-known-MAC.txt"))
|
||||
if (file_mac == nil) then return "" end
|
||||
local mac_line = file_mac:read("*l")
|
||||
while (mac_line ~= nil) do
|
||||
if (not startswith(mac_line, "#") and mac_line ~= "") then
|
||||
t = split(mac_line, "\t")
|
||||
if (string.match(mac_address, t[1]..".*") ~= nil) then
|
||||
file_mac.close()
|
||||
return split(t[2], " ")[1]
|
||||
end
|
||||
end
|
||||
mac_line = file_mac:read("*l")
|
||||
end
|
||||
file_mac.close()
|
||||
return ""
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue