The switch Statement

Syntax
switch  {
    case  {
        [ statements-1 ]
    }
    case  {
        [ statements-2 ]
    }
    case {
        [ statements-3 ]
    }
}

A switch statement causes the server to evaluate expansion, which can be an &Attribute-Name or data. The result is compared against match-1 and match-2 to find a match. If no string matches, then the server looks for the default case statement, which has no associated match.

The matching is done via equality. The switch statement is mostly syntactic sugar and is used to simplify the visual form of the configuration. It is mostly equivalent to the following use of if statements:

Nearly equivalent syntax
if ( == ) {
    [ statements-1 ]
}
elsif ( == ) {
    [ statements-2 ]
}
else {
    [ statements-3 ]
}

The only difference between the two forms is that for a switch statement, the expansion is evaluated only once. For the equivalent if statement, the expansion is evaluated again for every if.

If a matching case is found, the statements within that case are evaluated. If no matching case is found, the "default" case is evaluated. This default is the case with no match text. If there is no default case, then the switch statement does nothing.

The match text for the case statement can be an &Attribute-Name or data.

No statement other than case can appear in a switch statement, and the case statement cannot appear outside of a switch statement.