of packets they receive. The syntax for specifying this conditional
behaviour is documented here.
.SH REFERENCE: CONDITIONAL BEHAVIOUR
-Conditional behaviour is specified using the if statement and the else
-or elsif statements. A conditional statement can appear anywhere
+Conditional behaviour may be specified using the if statement and the else
+or elsif statements or the switch and case statements.
+A conditional statement can appear anywhere
that a regular statement (e.g., an option statement) can appear, and
-can enclose one or more such statements. A typical conditional
-statement in a server might be:
+can enclose one or more such statements.
+.PP
+.B CONDITIONAL BEHAVIOUR: IF
+.PP
+A typical conditional if statement in a server might be:
.PP
.nf
if option dhcp-user-class = "accounting" {
.B else
are evaluated. Boolean expressions that evaluate to null are
treated as false in conditionals.
+.PP
+.B CONDITIONAL BEHAVIOUR: SWITCH
+.PP
+The above example can be rewritten using a switch construct as well.
+.PP
+.nf
+switch (option dhcp-user-class) {
+ case "accounting":
+ max-lease-time 17600;
+ option domain-name "accounting.example.org";
+ option domain-name-servers ns1.accounting.example.org,
+ ns2.accounting.example.org;
+ case "sales":
+ max-lease-time 17600;
+ option domain-name "sales.example.org";
+ option domain-name-servers ns1.sales.example.org,
+ ns2.sales.example.org;
+ break;
+ case "engineering":
+ max-lease-time 17600;
+ option domain-name "engineering.example.org";
+ option domain-name-servers ns1.engineering.example.org,
+ ns2.engineering.example.org;
+ break;
+ default:
+ max-lease-time 600;
+ option domain-name "misc.example.org";
+ option domain-name-servers ns1.misc.example.org,
+ ns2.misc.example.org;
+ break;
+}
+.fi
+.PP
+The
+.B switch
+statement and the
+.B case
+statements can both be data expressions or numeric expressions. Within
+a switch statement they all must be the same type. The server
+evaluates the expression from the switch statement and then it evaluates
+the expressions from the case statements until it finds a match.
+.PP
+If it finds a match it starts executing statements from that case
+until the next break statement. If it doesn't find a match it
+starts from the default statement and again proceeds to the next
+break statement. If there is no match and no default it does nothing.
+.PP
.SH BOOLEAN EXPRESSIONS
The following is the current list of boolean expressions that are
supported by the DHCP distribution.
be representable in fewer than 32 bits, but the precision of such
integers may be more than 32 bits.
.PP
+In addition to the following operators several standard math functions
+are available. They are:
+.nf
+operation symbol
+add \fB+\fR
+subtract \fB-\fR
+divide \fB/\fR
+multiply \fB*\fR
+modulus \fB%\fR
+bitwise and \fB&\fR
+bitwise or \fB|\fR
+bitwise xor \fB^\fR
+.fi
+.PP
.B extract-int (\fIdata-expr\fB, \fIwidth\fB)\fR
.PP
.RS 0.25i