Module:IP: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
a subnet has getPrefix and so does not need its own copy of parts
(save progress on new implentation plan - an internal RawIP object used for bit operations on IP parts)
(a subnet has getPrefix and so does not need its own copy of parts)
Line 382:
 
local function makeSubnet(data, cidrStr)
-- If cidrStr is a valid IPv4 or IPv6 CIDR specification, store its parts
-- information in data and return trueits version. Otherwise, return falsenil.
local lhs, rhs = cidrStr:match('^%s*(.-)/(%d+)%s*$')
if lhs then
Line 392:
local prefix = base:getPrefix(n)
if base == prefix then
data.parts = base:getIPParts()
data.bitLength = n
data.prefix = prefix
data.highestIP = base:getHighestIP(n)
return truebits == 32 and V4 or V6
end
end
end
return falsenil
end
 
Line 469 ⟶ 468:
-- Set initial values
checkType('Subnet.new', 1, cidr, 'string')
ifdata.version not= makeSubnet(data, cidr) then
if not data.version then
error('invalid CIDR', 2)
end
data.version = data.parts.n == 2 and V4 or V6
 
return obj
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu