Conditions are evaluated when parsing if and elsif statements. These conditions allow the server to make complex decisions based on one of a number of possible criteria.

Syntax
if ( condition ) { ...

elsif ( condition ) { ...

Conditions are expressed using the following syntax:

Syntax Description

&Attribute-Name

Check for attribute existence.

module-code

Check return code of a previous module.

data

Check value of data.

lhs OP rhs

Compare two kinds of data.

( condition )

Check sub-condition

( ! condition )

Negate a conditional check

( condition ) && …

Check a condition AND the next one

( condition ) || …

Check a condition OR the next one

Examples
if ( &User-Name == "bob" ) {
    ...
}

if ( &Framed-IP-Address == 127.0.0.1 ) {
    ...
}

if ( &Calling-Station-Id == "%{sql:SELECT ...}" ) {
    ...
}

Load-time Syntax Checks

The server performs a number of checks when it loads the configuration files. Unlike version 2, all of the conditions are syntax checked when the server loads. This checking greatly aids in creating configurations which are correct. Where the configuration is incorrect, a descriptive error is produced.

This error contains the filename and line number of the syntax error. In addition, it will print out a portion of the line which caused the error, and point to the exact character where the error was seen. These descriptive messages means that most errors are easy to find and fix.

Load-time Optimizations

The server performs a number of optimizations when it loads the configuration files. Conditions which have static values are evaluated, and replaced with the result of the conditional comparison.

Example
if ( 0 == 1 ) {
    ...
}

The condition 0 == 1 is static, and will evaluate to false. Since it evaluates to false, the configuration inside of the if statement is ignored. Any modules referenced inside of the if statement will not be loaded.

This optimization is most useful for creating configurations which selectively load (or not) certain policies. If the condition above was used in version 2, the configurastion inside of the if statement would be loaded, even though it would never be used.