Classification scripts are organized into rules. Each rule has a target and one or more match conditions. For example:
subscriber-classifier {
.
.
.
rule rule-2 {
target <-unauthenticatedUserDn->;
condition {
"loginType == \"ADDR\"";
"loginType == \"AUTHADDR\"";
}
}
}
dhcp-classifier {
.
.
.
rule rule-2 {
target cn=default,<-dhcpProfileDN->;
condition {
1;
}
}
}
interface-classifier {
.
.
.
rule rule-5 {
target /sample/junose/DHCP;
condition {
"interfaceName=\"fastEthernet*\"";
"interfaceName=\"atm*/*.*\"";
}
}
}
A target is the result of the classification script that gets returned to the SAE. There are two special types of targets:
Because script targets use * (asterisks), you cannot use * in other types of targets.
A target can contain expressions. These expressions can refer to an object in the SAE’s memory or configuration, to specific matching conditions, or to another function or script.
Suppose the classification object in a subscriber classifier contains a field called userName. The classifier target uniqueId=<- userName -> is expanded to contain the actual content of the userName field before it is returned to the SAE; for example, for userName=juser, uniqueId=juser is returned.
Target expressions are enclosed in angle brackets and hyphens; for example, <-retailerDn->. The classifier expands expressions before it returns the target to the SAE. The expression is interpreted by an embedded Python interpreter and can contain variables and Python operations. In the simplest case an expression can be a single variable that is replaced with its current contents. Available variable names are all fields of the object passed to the classifier and names created with regular expression matching.
Because a scripting interpreter interprets expressions, more complex operations are possible. Examples are:
You can configure multiple classification conditions for a rule. For example:
- rule rule-2 {
- target /ent/EntDefault;
-
- condition {
- "pppLoginName=\"\"";
- "&interfaceName!=\"fastEthernet0*\"";
- "&interfaceName!=\"null*\"";
- "&interfaceName!=\"loopback*\"";
- }
- }
If you prefix a condition with an & (ampersand) character, the condition is examined only if the previous condition matches.
If you prefix a condition with a | (pipe) character, the condition is examined only if the previous conditions have not produced a positive match.
You can use glob or regular expression matching to configure each target’s conditions.
Glob matches are of the form:
where match is a pattern similar to UNIX filename matching. Glob matches are case insensitive. “ field != match” is true, if field=match is not true.
The available field names are described for the specific classifiers. Examples are:
Regular expression matches are of the form:
where field !~ re is true if field =~ re is not true. The regular expression is re. For a complete description of the syntax, see:http://www.python.org/doc/2.0/lib/re-syntax.html
You can group regular expressions with pairs of parentheses. If such an expression matches, the contents of the groups are made available for target expressions. Group number n is available as G[n], where n is the number of the opening parenthesis of the group. You can also name groups by using the special notation (?P<name>…).
Examples:
- ifAlias =~ "SSP(.*)"
- # match a string starting with "SSP". The remainder is
stored
- # in the variable "G[1]"
- ifAlias =~ (?P<dn>name=(?P<name>[^,]*).*)
- # match a string starting with “ name=“ . The
whole match is
- # stored in the variable “ dn” . A submatch
which does not
- # contain any “ ,” -characters and starts after
“ name=“
- # is stored in variable “ name”