Commit ba2204ae authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

Maskable: constant table for address lengths

parent 11f3b029
......@@ -34,6 +34,9 @@ local sortedkeys = util.sortedkeys
local startswith = require('stringy').startswith
local ADDRLEN = {inet=32, inet6=128}
M.ConfigObject = M.class()
function M.ConfigObject:init(context, location)
......@@ -710,7 +713,7 @@ function M.Maskable:init(...)
setdefault(self.mask, family, copy(self.mask))
for _, attr in ipairs{'src', 'dest'} do
self[attr..'-mask'][family] = self.mask[family][attr] or
({src=({inet=32, inet6=128})[family], dest=0})[attr]
({src=ADDRLEN[family], dest=0})[attr]
end
end
end
......@@ -730,9 +733,7 @@ function M.Maskable:initmask()
for _, family in ipairs{'inet', 'inet6'} do
local value = self[mask][family]
if not value then self[mask][family] = 0
elseif value == true then
self[mask][family] = ({inet=32, inet6=128})[family]
end
elseif value == true then self[mask][family] = ADDRLEN[family] end
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment