summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2023-11-02 08:36:02 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2023-11-02 08:36:02 +0100
commit76c50495523b781a34db82bd4adf2330d395d726 (patch)
treef1a0800a36e81576442d25be112127004a69cdff
parentf9e4736863371770bbbd03cf1762d8d44153b7a7 (diff)
downloadprolog-firewall-76c50495523b781a34db82bd4adf2330d395d726.tar.gz
prolog-firewall-76c50495523b781a34db82bd4adf2330d395d726.tar.bz2
prolog-firewall-76c50495523b781a34db82bd4adf2330d395d726.tar.xz
prolog-firewall-76c50495523b781a34db82bd4adf2330d395d726.zip
wip
-rw-r--r--4.pl88
1 files changed, 88 insertions, 0 deletions
diff --git a/4.pl b/4.pl
new file mode 100644
index 0000000..81b7120
--- /dev/null
+++ b/4.pl
@@ -0,0 +1,88 @@
+% 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)
+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)).
+
+%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).
+
+% warnings(Msg) :-
+% host(H), host(R),
+% router_link(H, R, _),
+% not router_link(R, H, _),
+% Msg = "missing router link!".
+
+% bgp_connection(H, Remote)?
+
+% 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_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).
+
+direct_network(Router, N) :-
+ router_link(Router, _, Remote),
+ network(Remote, N).
+
+direct_networks(Router, Ns) :-
+ findall(N, direct_network(Router, N), Ns).
+
+indirect_network(Router, Ns) :-
+ router_link(Router, _, Remote),
+ direct_network(Remote, Ns).
+
+incoming_networks(R, Ns) :-
+ %findall(N, direct_network(R, N), Direct),
+ Direct = [],
+ setof(N, indirect_network(R, N), Indirect),
+ union(Direct, Indirect, Ns).