def AaNet.proto_ok

bend-osdev-apparmor@0.1.0.0 · rule_network.bend:115

import bend-osdev-apparmor@0.1.0.0/rule_network.bend as RuleNetwork
import Base
import bend-osdev-apparmor@0.1.0.0/text.bend as X

115# a protocol needs the inet or inet6 domain, or none, and icmp is not inet6's
116# (apparmor_parser 4.0.1: "Invalid network entry" otherwise)
117def AaNet.proto_ok(d: Maybe<&2, List<&2, U32>>, pr: Maybe<&2, List<&2, U32>>) -> Bool:
118  match d:
119    case None{}:
120      True{}
121    case Some{+x}:
122      match pr:
123        case None{}:
124          True{}
125        case Some{+y}:
126          Bool.or(X.AaText.is(x, "inet"), Bool.and(X.AaText.is(x, "inet6"), Bool.not(X.AaText.is(y, "icmp"))))

Uses (8)

Used by (1)