diff options
Diffstat (limited to '4.pl')
-rw-r--r-- | 4.pl | 70 |
1 files changed, 37 insertions, 33 deletions
@@ -12,26 +12,26 @@ host(lhn2ix). % public_key(hash, "pk hash"). % (router, router_ip, remote) -router_link(knot, "1::1", hash). -router_link(knot, "1::8", lhn2ix). -router_link(knot, "1::7", kv24ix). -router_link(hash, "1::2", knot). -router_link(hash, "1::10", kv24ix). -router_link(hash, "1::3", lhn2ix). -router_link(kv24ix, "1::6", knot). -router_link(kv24ix, "1::5", hash). -router_link(lhn2ix, "1::9", hash). -router_link(lhn2ix, "1::4", knot). +router_link(knot, "1::1", hash). +router_link(knot, "1::8", lhn2ix). +router_link(knot, "1::7", kv24ix). +router_link(hash, "1::2", knot). +router_link(hash, "1::10", kv24ix). +router_link(hash, "1::3", lhn2ix). +router_link(kv24ix, "1::6", knot). +router_link(kv24ix, "1::5", hash). +router_link(lhn2ix, "1::9", hash). +router_link(lhn2ix, "1::4", knot). router_link(conflatorio, "1::11", lhn2ix). -router_link(lhn2ix, "1::12", conflatorio). +router_link(lhn2ix, "1::12", conflatorio). % network(R, address, range) -network(conflatorio, ipv6_net("1:78e1::", 64)). -network(hash, ipv6_net("1:e5b0::", 64)). -network(knot, ipv6_net("1:f11b::", 64)). -network(lhn2ix, ipv6_net("1:dbe1::", 64)). -network(lhn2ix, ipv6_net("1:dbe2::", 64)). -network(kv42ix, ipv6_net("1:cd02::", 64)). +attached_network(conflatorio, ipv6_net("1:78e1::", 64)). +attached_network(hash, ipv6_net("1:e5b0::", 64)). +attached_network(knot, ipv6_net("1:f11b::", 64)). +attached_network(lhn2ix, ipv6_net("1:dbe1::", 64)). +attached_network(lhn2ix, ipv6_net("1:ab69::", 64)). +attached_network(kv42ix, ipv6_net("1:cd02::", 64)). %host(H) :- router_link(H, _, _). %host(H) :- router_link(_, H, _). @@ -53,7 +53,7 @@ bgp_connection(H, R) :- % wg_if(H, R, PK) :- bgp_connection(H, R), public_key(R, PK). % % wg_if(H, R, PK)? % wg_if_allowed_ips(H, Ip, 128) :- bgp_connection(H, R), router_link(H, R, Ip). -% wg_if_allowed_ips(H, Ip, Range) :- bgp_connection(H, R), network(R, Ip, Range). +% wg_if_allowed_ips(H, Ip, Range) :- bgp_connection(H, R), attached_network(R, Ip, Range). % % wg_if_allowed_ips(H, Ip, Range)? bgp_connections(H, Cs) :- findall(Name, bgp_connection(H, Name), Cs). @@ -66,23 +66,27 @@ bird_protocol_bgp(Router, Neighbor, Address, AllowedNetworks) :- router_link(Neighbor, Address, Router), AllowedNetworks = []. -edge(a, b). edge(b, c). edge(c, d). edge(d, a). -path(X, Y) :- edge(X, Y). -path(X, Y) :- edge(X, Z), path(Z, Y). +% edge(a, b). edge(b, c). edge(c, d). edge(d, a). +% path(X, Y) :- edge(X, Y). +% path(X, Y) :- edge(X, Z), path(Z, Y). -direct_network(Router, N) :- - router_link(Router, _, Remote), - network(Remote, N). +attached_networks(Router, Ns) :- + findall(N, attached_network(Router, N), Ns). -direct_networks(Router, Ns) :- - findall(N, direct_network(Router, N), Ns). +remote_network(Router, N) :- + router_link(Router, _, Remote), + attached_network(Remote, N). -indirect_network(Router, Ns) :- +remote_networks(Router, Ns) :- router_link(Router, _, Remote), - direct_network(Remote, Ns). + attached_networks(Remote, Ns). + +% doesn't recurse +% available_networks(R, Ns) :- +% attached_networks(R, Attached), +% setof(N, remote_network(R, N), Remote), +% union(Attached, Remote, Xs), -incoming_networks(R, Ns) :- - %findall(N, direct_network(R, N), Direct), - Direct = [], - setof(N, indirect_network(R, N), Indirect), - union(Direct, Indirect, Ns). +router_path(X, Y) :- router_path(X, Y, []). +router_path(X, Y, _) :- router_link(X, _, Y). +router_path(X, Y, V) :- \+ member(X, V), router_link(X, _, Z), router_path(Z, Y, [X|V]). |