def matches_prefix(ip, prefix):
    """
    Returns True if the given IP address is part of the given
    network, returns False otherwise.

    :type  ip: string
    :param ip: An IP address.
    :type  prefix: string
    :param prefix: An IP prefix.
    :rtype:  bool
    :return: True if the IP is in the prefix, False otherwise.
    """
    ip_int = ip2int(ip)
    network, pfxlen = parse_prefix(prefix)
    network_int = ip2int(network)
    mask_int = pfxlen2mask_int(pfxlen)
    return ip_int&mask_int == network_int&mask_int