import struct
import socket


def ip2int(ip):
    """
    Converts the given IP address to a 4 byte integer value.

    :type  ip: string
    :param ip: An IP address.
    :rtype:  long
    :return: The IP, converted to a number.
    """
    if ip == '255.255.255.255':
        return 0xFFFFFFFF
    return struct.unpack('!L', socket.inet_aton(ip))[0]