Anonymous user
Module:IP: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
m
comment and variable tweaks
(some more style changes (it's still broken but I'll fix it later; also, sorry for the edit conflict)) |
m (comment and variable tweaks) |
||
Line 108:
return nil
end
-- Methods▼
function RawIP:getAdjacent(previous)
-- Return a RawIP object for an adjacent IP address. If previous is true
Line 133 ⟶ 134:
end
▲ -- Methods
-- Return a RawIP object for the prefix of the current IP Address with a
▲ function RawIP:getPrefix(length)
-- bit length of bitLength.
local result = Collection()
result.n = self.n
for i = 1, self.n do
if
if
result[i] = self[i]
else
result[i] = bit32.band(self[i],
bit32.arshift(0xffff8000,
end
else
Line 155 ⟶ 156:
end
function RawIP:
-- Return a
-- bitLength. In other words, the network (the most-significant bits)
-- (host bits) set to 1.▼
-- is the same as the current IP's, but the host bits (the
local bits = self.n * 16
local width
if
width = bits
elseif
width = 0
else
width = bits -
end
local result = Collection()
|