def __as_number(asn, fail=True):
    """ Autonomous System Number validation. """
    if str(asn).isdigit() and 0 <= int(asn) < 2 ** 32:
        return asn
    if fail:
        raise ValueError('Bad AS number')
