From 14fb889f021c50763d21c77ff0f25e8bdbabd3a9 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 27 Oct 2023 11:07:12 +0200 Subject: wip --- 2.dl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 2.dl diff --git a/2.dl b/2.dl new file mode 100644 index 0000000..ab1c998 --- /dev/null +++ b/2.dl @@ -0,0 +1,40 @@ +#lang datalog + +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). + +public-key(conflatorio, "pk conflatorio"). +public-key(lhn2ix, "pk lhn2ix"). +public-key(knot, "pk knot"). + +router-link(knot,lhn2ix, "1:1::1"). +router-link(knot,kv24ix, "1:1::2"). +router-link(lhn2ix, knot, "1:2::1"). +router-link(lhn2ix, conflatorio, "1:2::2"). +router-link(conflatorio, lhn2ix, "1:3::1"). + +% network(R, address, range) +network(lhn2ix, "1:dbea::", 64). +network(conflatorio, "1:e5b0::", 64). +network(knot, "1:f11b::", 64). + +host(H) :- router-link(H, B, Ip). +host(H) :- router-link(A, H, Ip). +host(H)? + +bgp-connection(H, R) :- + host(H), host(R), + router-link(H, R, IpH), + router-link(R, H, IpR). + +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-config(H) :- bgp-connection(H, Name). +bgp-config(H)? -- cgit v1.2.3