% vim set ft=prolog host(conflatorio). host(hash). host(knot). host(kv24ix). host(lhn2ix). % public_key(conflatorio, "pk conflatorio"). % public_key(lhn2ix, "pk lhn2ix"). % public_key(knot, "pk knot"). % 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(conflatorio, "1::11", lhn2ix). router_link(lhn2ix, "1::12", conflatorio). % network(R, address, range) 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, _). % host(H). bgp_connection(H, R) :- host(H), host(R), router_link(H, _, R), router_link(R, _, H). warning(Msg) :- host(H), host(R), router_link(H, _, R), \+ router_link(R, _, H), format(string(Msg), "Missing router_link from ~w to ~w", [R, H]). bgp_connections(H, Cs) :- findall(Name, bgp_connection(H, Name), Cs). bgp_config(H, Connections) :- bgp_connections(H, Connections). % bgp_config(H)? bird_protocol_bgp(Router, Neighbor, Address, AllowedNetworks) :- router_link(Router, _, Neighbor), 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). attached_networks(Router, Ns) :- findall(N, attached_network(Router, N), Ns). remote_network(Router, N) :- router_link(Router, _, Remote), attached_network(Remote, N). remote_networks(Router, Ns) :- router_link(Router, _, Remote), 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), 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]).