summaryrefslogtreecommitdiff
path: root/6/firewall.pl
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2023-11-14 16:18:17 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2023-11-14 16:18:17 +0100
commit0cace145fed5c0e64f9fbf4295be5264582517e8 (patch)
tree74957b9879f9640c8c8d4197304fc6702f2b8e39 /6/firewall.pl
parent03d5aada1f8064af6b3d278b51a801cac0f3a85a (diff)
downloadprolog-firewall-0cace145fed5c0e64f9fbf4295be5264582517e8.tar.gz
prolog-firewall-0cace145fed5c0e64f9fbf4295be5264582517e8.tar.bz2
prolog-firewall-0cace145fed5c0e64f9fbf4295be5264582517e8.tar.xz
prolog-firewall-0cace145fed5c0e64f9fbf4295be5264582517e8.zip
wip
Diffstat (limited to '6/firewall.pl')
-rw-r--r--6/firewall.pl24
1 files changed, 24 insertions, 0 deletions
diff --git a/6/firewall.pl b/6/firewall.pl
new file mode 100644
index 0000000..d76e2d1
--- /dev/null
+++ b/6/firewall.pl
@@ -0,0 +1,24 @@
+% vim set ft=prolog
+
+% rule(src, dst, proto, port, source(..)).
+
+:- module(firewall, [
+ fw_rule/2,
+ retract_all_from/1]).
+
+:- use_module(hosts, [
+ router_link/3]).
+
+:- dynamic fw_rule/2.
+
+rule_is_from(fw_rule(_, Attr), From) :- Attr.from=From.
+
+rules_from(From, Rules) :-
+ findall(fw_rule(Host, Attr), (fw_rule(Host, Attr), Attr.from=From), Rules).
+
+retract_all_from(From) :-
+ rules_from(From, Rules),
+ retract_rules(Rules).
+
+retract_rules([R|Rules]) :- retract(R), retract_rules(Rules).
+retract_rules([]).