@staticmethod
def ipv4_filter(value, bogon=None, **_):
    """
        IPv4 address filter:
        - check if string length is >7 (e.g. not just 4 digits and 3 dots)
        - check if not in list of bogon IP addresses
        return True if OK, False otherwise.
        """
    ip = value
    if ip.startswith(b'0'):
        return False
    for x in ip.split(b'.'):
        if int(x) > 255:
            return False
    if ip.endswith(b'.0') or ip.endswith(b'.255'):
        return False
    if bogon is not None:
        ip_bytes = ip.split(b'.')
        byte1 = int(ip_bytes[0])
        byte2 = int(ip_bytes[1])
        if ip.startswith(b'10.'):
            return False
        if ip.startswith(b'100.') and byte2 & 192 == 64:
            return False
        if ip.startswith(b'127.'):
            return False
        if ip.startswith(b'169.254.'):
            return False
        if ip.startswith(b'172.') and byte2 & 240 == 16:
            return False
        if ip.startswith(b'192.0.0.'):
            return False
        if ip.startswith(b'192.0.2.'):
            return False
        if ip.startswith(b'192.168.'):
            return False
        if ip.startswith(b'198.') and byte2 & 254 == 18:
            return False
        if ip.startswith(b'198.51.100.'):
            return False
        if ip.startswith(b'203.0.113.'):
            return False
        if byte1 & 240 == 224:
            return False
        if byte1 & 240 == 240:
            return False
    return True
