(ip, prefixlen, version)
Check the validity of a prefix

    Checks if the variant part of a prefix only has 0s, and the length is
    correct.

    >>> _checkPrefix(0x7f000000L, 24, 4)
    1
    >>> _checkPrefix(0x7f000001L, 24, 4)
    0
    >>> repr(_checkPrefix(0x7f000001L, -1, 4))
    'None'
    >>> repr(_checkPrefix(0x7f000001L, 33, 4))
    'None'
Check the validity of a prefix
Check the validity of a prefix
def _checkPrefix(ip, prefixlen, version):
    """Check the validity of a prefix

    Checks if the variant part of a prefix only has 0s, and the length is
    correct.

    >>> _checkPrefix(0x7f000000L, 24, 4)
    1
    >>> _checkPrefix(0x7f000001L, 24, 4)
    0
    >>> repr(_checkPrefix(0x7f000001L, -1, 4))
    'None'
    >>> repr(_checkPrefix(0x7f000001L, 33, 4))
    'None'
    """

    # TODO: unify this v4/v6/invalid code in a function
    bits = _ipVersionToLen(version)

    if prefixlen < 0 or prefixlen > bits:
        return None

    if ip == 0:
        zbits = bits + 1
    else:
        zbits = _count0Bits(ip)
    if zbits < bits - prefixlen:
        return 0
    else:
        return 1
def _checkPrefix ( ip , prefixlen , version ) : # TODO: unify this v4/v6/invalid code in a function bits = _ipVersionToLen ( version ) if prefixlen < 0 or prefixlen > bits : return None if ip == 0 : zbits = bits + 1 else : zbits = _count0Bits ( ip ) if zbits < bits - prefixlen : return 0 else : return 1