And here's a prototype, written in Lua:
function dump(o)
if type(o) == 'table' then
local s = '{ '.. string.char(10)
for k, v in pairs(o) do
if type(k) ~= 'number' then
k = '"' .. k .. '"'
end
s = s .. '[' .. k .. '] = ' .. dump(v) .. string.char(10)
end
return s .. '} '.. string.char(10)
else
return tostring(o)
end
end
HostData = {}
function HostData.new(macAddr, ipAddr, hostname, description)
return { MacAddress = macAddr, IP = ipAddr, HostName = hostname,
Description = description }
end
Dictionary = {}
hostdata = HostData.new("12:34:56:78", "192.168.1.1", "MyLaptop1", "My first Powerful Laptop")
Dictionary[1] = hostdata
hostdata = HostData.new("78:34:56:12", "192.168.1.2", "MyLaptop2", "My SuperDuper laptop")
Dictionary[2] = hostdata
print("dictionary: ", dump(Dictionary))
and when you run it, here's what it shows:
dictionary: {
[1] = {
["Description"] = My first Powerful Laptop
["HostName"] = MyLaptop1
["IP"] = 192.168.1.1
["MacAddress"] = 12:34:56:78
}
[2] = {
["Description"] = My SuperDuper laptop
["HostName"] = MyLaptop2
["IP"] = 192.168.1.2
["MacAddress"] = 78:34:56:12
}
}
When I wrote the original post, I didn't know Lua.
And therefore, with the prototype code, I've shown it's possible to associate MAC addresses with hostnames, add descriptive names to MAC, IP addresses or hostnames, or do whatever funky stuff you want.
So, what really remains to be done is to flesh out the idea further, and some kind of editor to edit the data (if it's needed, or just get the data somewhere) then incorporate it into Luci and OpenWRT and submit a PR.