netblock.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:pentestly 作者: praetorian-inc 项目源码 文件源码
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.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号