<%-
  @bogons_v4 = [
    '0.0.0.0/8',       # RFC1122
    '10.0.0.0/8',      # RFC1918
    '100.64.0.0/10',   # RFC6598
    '127.0.0.0/8',     # RFC1122
    '169.254.0.0/16',  # RFC3927
    '172.16.0.0/12',   # RFC1918
    '192.0.0.0/24',    # RFC5736
    '192.0.2.0/24',    # RFC5737
    '192.88.99.0/24',  # RFC3068
    '192.168.0.0/16',  # RFC1918
    '198.18.0.0/15',   # RFC2544
    '198.51.100.0/24', # RFC5737
    '203.0.113.0/24',  # RFC5737
    '224.0.0.0/3'      # RFC5771/RFC6034/RFC2365)
  ]
  @bogons_v6 = [
    '3ffe::/16',         # RFC2546
    '2001:db8::/32',     # RFC3849
    '2001::/32',         # Teredo
    '2002::/16',         # 6to4
    '0000::/8',          # RFC4291
    '0200::/7',          # RFC4048
    '0400::/6',          # RFC4291
    '0800::/5',          # RFC4291
    '1000::/4',          # RFC4291
    '2000::/3',          # RFC4291
    '4000::/3',          # RFC4291
    '6000::/3',          # RFC4291
    '8000::/3',          # RFC4291
    'a000::/3',          # RFC4291
    'c000::/3',          # RFC4291
    'e000::/4',          # RFC4291
    'f000::/5',          # RFC4291
    'f800::/6',          # RFC4291
    'fc00::/7',          # RFC4193
    'fe00::/9',          # RFC4291
    'fe80::/10',         # RFC4291
    'fec0::/10',         # RFC3879
    'ff00::/8'           # RFC4291
  ]
-%>
!
ip prefix-list default-route seq 1 permit 0.0.0.0/0
!
ip prefix-list deny seq 1 deny any
!
ip prefix-list deny-default-route seq 1 deny 0.0.0.0/0
<%- if @reject_bogons_v4 -%>
  <%- @bogons_v4.each_with_index do |reject, index| -%>
    <%- if reject.include?('/') and reject.split('/')[-1].to_i < 24 then confine = ' le 24' else confine = '' end -%>
ip prefix-list deny-default-route seq <%= index + 2 %> deny <%= reject %><%= confine %>
  <%- end -%>
  <%- @seq_mod = @bogons_v4.length -%>
<%- else @seq_mod = 0 end -%>
<%- @rejected_v4.each_with_index do |reject, index| -%>
  <%- if reject.include?('/') and reject.split('/')[-1].to_i < 24 then confine = ' le 24' else confine = '' end -%>
ip prefix-list deny-default-route seq <%= index + 2 + @seq_mod %> deny <%= reject %><%= confine %>
<%- end -%>
ip prefix-list deny-default-route seq <%= @rejected_v4.length + 2 + @seq_mod %> permit 0.0.0.0/0 le 24
!
<% if ! @enable_advertisements or ! @enable_advertisements_v4 then -%>
ip prefix-list prefix-v4 seq 1 deny any
<%- end -%>
<%- @prefix_v4_index = 1 -%>
<%- if ! @failover_server then -%>
  <%- @networks4.each do |network| -%>
    <%- @prefix_v4_index += 1 -%>
ip prefix-list prefix-v4 seq <%= @prefix_v4_index %> permit <%= network %>
  <%- end -%>
<%- end -%>
<%- @failsafe_networks4.each do |network| -%>
  <%- @prefix_v4_index += 1 -%>
ip prefix-list prefix-v4 seq <%= @prefix_v4_index %> permit <%= network %>
<%- end -%>
!
<%- @networks4.each_with_index do |network, index| -%>
ip prefix-list specific-v4 seq <%= index + 1 %> permit <%= network %>
<%- end -%>
!
ipv6 prefix-list default-route seq 1 permit ::/0
!
ipv6 prefix-list deny seq 1 deny any
!
ipv6 prefix-list deny-default-route seq 1 deny ::/0
<%- if @reject_bogons_v6 -%>
  <%- @bogons_v6.each_with_index do |reject, index| -%>
    <%- if reject.include?('/') and reject.split('/')[-1].to_i < 48 then confine = ' le 48' else confine = '' end -%>
ipv6 prefix-list deny-default-route seq <%= index + 2 %> deny <%= reject %><%= confine %>
  <%- end -%>
  <%- @seq_mod = @bogons_v6.length -%>
<%- else @seq_mod = 0 end -%>
<%- @rejected_v6.each_with_index do |reject, index| -%>
  <%- if reject.include?('/') and reject.split('/')[-1].to_i < 48 then confine = ' le 48' else confine = '' end -%>
ipv6 prefix-list deny-default-route seq <%= index + 2 + @seq_mod %> deny <%= reject %><%= confine %>
<%- end -%>
ipv6 prefix-list deny-default-route seq <%= @rejected_v6.length + 2 + @seq_mod %> permit ::/0 le 48
!
<% if ! @enable_advertisements or ! @enable_advertisements_v6 then -%>
ipv6 prefix-list prefix-v6 seq 1 deny any
<%- end -%>
<%- @prefix_v6_index = 1 -%>
<%- if ! @failover_server then -%>
  <%- @networks6.each do |network| -%>
    <%- @prefix_v6_index += 1 -%>
ipv6 prefix-list prefix-v6 seq <%= @prefix_v6_index %> permit <%= network %>
  <%- end -%>
<%- end -%>
<%- @failsafe_networks6.each do |network| -%>
  <%- @prefix_v6_index += 1 -%>
ipv6 prefix-list prefix-v6 seq <%= @prefix_v6_index %> permit <%= network %>
<%- end -%>
!
<%- @networks6.each_with_index do |network, index| -%>
ipv6 prefix-list specific-v6 seq <%= index + 1 %> permit <%= network %>
<%- end -%>
!
