In the previous section describing the if statement, all of the examples use simple Boolean conditions that evaluate to either true or false. RPL also provides a way
to build compound conditions from simple conditions by means of Boolean operators.
Three Boolean operators exist: negation (not), conjunction (and), and disjunction (or). In the policy language, negation has the highest precedence, followed by conjunction, and then by disjunction. Parentheses
may be used to group compound conditions to override precedence or to improve readability.
The following simple condition:
med eq 42
is true only if the value of the MED in the route is 42, otherwise it is false.
A simple condition may also be negated using the not operator:
not next-hop in (10.0.2.2)
Any Boolean condition enclosed in parentheses is itself a Boolean condition:
(destination in prefix-list-1)
A compound condition takes either of two forms. It can be a simple expression followed by the and operator, itself followed by a simple condition:
med eq 42 and next-hop in (10.0.2.2)
A compound condition may also be a simpler expression followed by the or operator and then another simple condition:
origin is igp or origin is incomplete
An entire compound condition may be enclosed in parentheses:
(med eq 42 and next-hop in (10.0.2.2))
The parentheses may serve to make the grouping of subconditions more readable, or they may force the evaluation of a subcondition
as a unit.
In the following example, the highest-precedence not operator applies only to the destination test, the and operator combines the result of the not expression with the community test, and the or operator combines that result with the MED test.
med eq 10 or not destination in (10.1.3.0/24) and community matches-any ([12..34]:[56..78])
With a set of parentheses to express the precedence, the result is the following:
med eq 10 or ((not destination in (10.1.3.0/24)) and community matches-any ([12..34]:[56..78])
The following is another example of a complex expression:
(origin is igp or origin is incomplete or not med eq 42) and next-hop in (10.0.2.2)
The left conjunction is a compound condition enclosed in parentheses. The first simple condition of the inner compound condition
tests the value of the origin attribute; if it is Interior Gateway Protocol (IGP), then the inner compound condition is true.
Otherwise, the evaluation moves on to test the value of the origin attribute again, and if it is incomplete, then the inner
compound condition is true. Otherwise, the evaluation moves to check the next component condition, which is a negation of
a simple condition.