def format(as_id_int):
    """
    Format an AS-identifier given as a (48-bit) integer as a string
    of the form [0-ffff]:[0-ffff]:[0-ffff]
    :param str as_id_int: AS-identifier to format
    :returns: AS-identifier as string
    :raises: ValueError if `as_id_int` not in the valid range for an AS-identifier
    """
    if as_id_int < 0 or as_id_int >= 2**48:
        raise ValueError('Invalid AS-ID')
    low = as_id_int & 0xffff
    mid = (as_id_int >> 16) & 0xffff
    hig = (as_id_int >> 32) & 0xffff
    return "%x:%x:%x" % (hig, mid, low)