__init__.py 文件源码

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

项目:vpc-router 作者: romana 项目源码 文件源码
def is_cidr_in_cidr(small_cidr, big_cidr):
    """
    Return True if the small CIDR is contained in the big CIDR.

    """
    # The default route (0.0.0.0/0) is handled differently, since every route
    # would always be contained in there. Instead, only a small CIDR of
    # "0.0.0.0/0" can match against it. Other small CIDRs will always result in
    # 'False' (not contained).
    if small_cidr == "0.0.0.0/0":
        return big_cidr == "0.0.0.0/0"
    else:
        if big_cidr == "0.0.0.0/0":
            return False

    s = ipaddress.IPv4Network(unicode(small_cidr))
    b = ipaddress.IPv4Network(unicode(big_cidr))
    return s.subnet_of(b)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号