def rules_ports(
        firewall_rules, only_restricted=False, redirect=False, *_, **__):
    """
    Return restricted ports (<1024) from firewall rules.

    Args:
        firewall_rules (list of dict): Firewall rules.
        only_restricted (bool): If True, list only ports < 1024.
        redirect (bool): If True, provides a redirect for ports < 1024 in the
            unrestricted port range.

    Returns:
        list of dict: port, redirected port, protocol
    """
    filtered = []
    for rule in firewall_rules:
        start = int(rule['start_port'])
        end = int(rule['end_port'])
        if not only_restricted or start < 1024:
            protocol = rule['protocol']
            filtered += [{
                'port': str(port),
                'redirect': str(port + (
                    60000 if port < 1024 and redirect else 0)),
                'protocol': protocol} for port in range(start, end + 1)]
    return filtered