import re


def format_ipv4(value, mask=None):
    """ Format an integer as a IPv4 string """
    value_ipv4 = ".".join([str(int(x, 16)) for x in re.findall('..', "{:08x}".format(value))])
    if mask is None:
        return value_ipv4
    value_mask = ".".join([str(int(x, 16)) for x in re.findall('..', "{:08x}".format(mask))])
    return "{}/{}".format(value_ipv4, value_mask)