Return a tuple corresponding to the string representation of an IPv4
    address.

    An IPv4 address is canonically represented in dot-decimal notation,
    which consists of four decimal numbers, each ranging from 0 to 255,
    separated by dots, e.g., ``172.16.254.1``.


    @param value: a dotted-decimal notation of an IPv4 address, consisting
        of four decimal numbers, each ranging from ``0`` to ``255``,
        separated by dots.

    @param strict: indicate whether the ``None`` value is accepted.


    @return: a tuple of four decimal numbers ``(byte1, byte2, byte3, byte4)``,
        each ranging from ``0`` to ``255``.

def string_to_ipv4(value, strict=False):
    """
    Return a tuple corresponding to the string representation of an IPv4
    address.

    An IPv4 address is canonically represented in dot-decimal notation,
    which consists of four decimal numbers, each ranging from 0 to 255,
    separated by dots, e.g., ``172.16.254.1``.


    @param value: a dotted-decimal notation of an IPv4 address, consisting
        of four decimal numbers, each ranging from ``0`` to ``255``,
        separated by dots.

    @param strict: indicate whether the ``None`` value is accepted.


    @return: a tuple of four decimal numbers ``(byte1, byte2, byte3, byte4)``,
        each ranging from ``0`` to ``255``.
    """
    if is_undefined(value):
        if strict:
            raise ValueError('The value cannot be null')
        return None

    if not REGEX_IPV4.match(value):
        raise ValueError('The specified string "%s" does not represent a IPv4' % value)

    ipv4 = [ int(byte) for byte in value.split('.') if int(byte) < 256]

    if len(ipv4) != 4:
        raise ValueError('The IPv4 "%s" has invalid byte(s)' % value)

    return ipv4