% vim set ft=prolog % rule(src, dst, proto, port, source(..)). :- module(firewall, [ fw_rule/2, warning/1, retract_all_from/1]). :- use_module(hosts, [ router_link/3]). :- dynamic fw_rule/2. warning(Msg) :- fw_rule(Host, Attr), \+ (_{from:_} :< Attr), format(string(Msg), "Missing 'from' on fw_rule for host '~w', ~w", [Host, Attr]). 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([]).