{% from 'macros.j2' import write_prefix_list %}
# ---------------------------------------------------------
# RPKI

{% if cfg.filtering.rpki.enabled or (
		cfg.filtering.irrdb.use_rpki_roas_as_route_objects.enabled and
		cfg.filtering.irrdb.use_rpki_roas_as_route_objects.source == "rtrlib"
	) %}
roa table RPKI {
{% if roas %}
{%	for roa in roas if roa.prefix.prefix is current_ipver %}
	roa {{ roa.prefix.prefix }}/{{ roa.prefix.length -}}
{%		if roa.prefix.le %}
 max {{ roa.prefix.le -}}
{%		else %}
 max {{ roa.prefix.length -}}
{%		endif %}
 as {{ roa.asn }};
{%	endfor %}
{% endif %}
};
{% else %}
# RPKI not used.
{% endif %}

{% if cfg.filtering.irrdb.use_rpki_roas_as_route_objects.enabled and
	cfg.filtering.irrdb.use_rpki_roas_as_route_objects.source == "ripe-rpki-validator-cache" %}
# RPKI ROAs used as route objects
{%	for origin_asn in rpki_roas_as_route_objects|sort %}
define RPKI_ROAs_as_route_objects_{{ origin_asn }} = [
{{ write_prefix_list(rpki_roas_as_route_objects[origin_asn].roas, True) }}
];
{%	endfor %}
{% endif %}
