def lhcidrs(lip, hip):
"""Convert a range from lowip to highip to a set of address/mask values."""
r = []
while lip <= hip:
# algorithm:
# try successively smaller length blocks starting at lip
# until we find one that fits within lip,hip. add it to
# the list, set lip to one plus its end, keep going.
# we must insure that the chosen mask has lip as its proper
# lower end, and doesn't go lower.
lb = ffs(lip)
if lb == -1:
lb = 32
while lb >= 0:
(lt, ht) = cidrrange((lip, (32-lb)))
if lt == lip and ht <= hip:
break
lb = lb - 1
if lb < 0:
raise ArithmeticError, "something horribly wrong"
r.append((lip, (32-lb)))
lip = ht+1
return r
# This class handles network blocks.
评论列表
文章目录