The expression to be evaluated. This object is the same
as a DisplayString (RFC 1903) except for its maximum length.
Except for the variable names the expression is in ANSI C
syntax. Only the subset of ANSI C operators and functions
listed here is allowed.
Variables are expressed as a dollar sign ('$') and an
integer that corresponds to an expObjectIndex. An
example of a valid expression is:
($1-$5)*100
Expressions may not be recursive, that is although an
expression may use the results of another expression, it
may not contain any variable that is directly or
indirectly a result of its own evaluation.
The only allowed operators are:
( )
- (unary)
+ - * / %
& | ^ << >> ~
! && || == != > >= < <=
Note the parentheses are included for parenthesizing the
expression, not for casting data types.
The only constant types defined are:
int (32-bit signed)
long (64-bit signed)
unsigned int
unsigned long
hexadecimal
character
string
oid
The default type for a positive integer is int unless it
is too large in which case it is long.
All but oid are as defined for ANSI C. Note that a
hexadecimal constant may end up as a scalar or an array of
8-bit integers. A string constant is enclosed in double
quotes and may contain back-slashed individual characters
as in ANSI C.
An oid constant comprises 32-bit, unsigned integers and at
least one period, for example:
0.
.0
1.3.6.1
Integer-typed objects are treated as 32- or 64-bit, signed
or unsigned integers, as appropriate. The results of
mixing them are as for ANSI C, including the type of the
result. Note that a 32-bit value is thus promoted to 64
bits only in an operation with a 64-bit value. There is
no provision for larger values to handle overflow.
Relative to SNMP data types, a resulting value becomes
unsigned when calculating it uses any unsigned value,
including a counter. To force the final value to be of
data type counter the expression must explicitly use the
counter32() or counter64() function (defined below).
OCTET STRINGS and OBJECT IDENTIFIERs are treated as 1-based
arrays of unsigned 8-bit integers and unsigned 32-bit
integers, respectively.
IpAddresses are treated as 32-bit, unsigned integers in
network byte order, that is, the hex version of 255.0.0.0 is
0xff000000.
Conditional expressions result in a 32-bit, unsigned integer
of value 0 for false or 1 for true. When an arbitrary value
is used as a boolean 0 is false and non-zero is true.
Rules for the resulting data type from an operation, based
on the operator:
For << and >> the result is the same as the left hand
operand.
For &&, ||, ==, !=, <, <=, >, and >= the result is always
Unsigned32.
For unary - the result is always Integer32.
For +, -, *, /, %, &, |, and ^ the result is promoted
according to the following rules, in order from most to
least preferred:
If left hand and right hand operands are the same
type, use that.
If either side is Counter64, use that.
If either side is IpAddress, use that.
If either side is TimeTicks, use that.
If either side is Counter32, use that.
Otherwise use Unsigned32.
The following rules say what operators apply with what
data types. Any combination not explicitly defined does
not work.
For all operators any of the following can be the left
hand or right hand operand: Integer32, Counter32,
Unsigned32, Counter64.
The operators +, -, *, /, %, <, <=, >, and >= also work with
TimeTicks.
The operators &, |, and ^ also work with IpAddress.
The operators << and >> also work with IpAddress but only
as the left hand operand.
The + operator performs a concatenation of two OCTET STRINGs
or two OBJECT IDENTIFIERs.
The operators &, | perform bitwise operations on
OCTET STRINGs. If the OCTET STRING happens to be a
DisplayString the results may be meaningless, but the agent
system does not check this as some such systems do not
have this information.
The operators << and >> perform bitwise operations on
OCTET STRINGs appearing as the left hand operand.
The only functions defined are:
counter32
counter64
arraySection
stringBegins
stringEnds
stringContains
oidBegins
oidEnds
oidContains
sum
exists
The following function definitions indicate their by naming
the data type of the parameter in the parameter's position
in the parameter list. The parameter must be of the type
indicated and generally may be a constant, a MIB object, a
function, or an expression.
counter32(integer) - wrapped around an integer value
counter32 forces Counter32 as a data type.
counter64(integer) - similar to counter32 except that the
resulting data type is 'counter64'.
arraySection(array, integer, integer) - selects a piece of
an array (i.e. part of an OCTET STRING or
OBJECT IDENTIFIER). The integer arguments are in the
range 0 to 4,294,967,295. The first is an initial array
index (1-based) and the second is an ending array index.
A value of 0 indicates first or last element, respectively.
If the first element is larger than the array length the
result is 0 length. If the second integer is less than or
equal to the first, the result is 0 length. If the second
is larger than the array length it indicates last element.
stringBegins/Ends/Contains(octetString, octetString) -
looks for the second string (which can be a string constant)
in the first and returns the 1-based index where the match
began. A return value of 0 indicates no match (i.e.
boolean false).
oidBegins/Ends/Contains(oid, oid) - looks for the second OID
(which can be an OID constant) in the first and returns the
the 1-based index where the match began. A return value
of 0 indicates no match (i.e. boolean false).
sum(integerObject*) - sums all availiable values of the
wildcarded integer object, resulting in an integer scalar.
Must be used with caution as it wraps on overflow with no
notification.
exists(anyTypeObject) - verifies the object instance
exists. A return value of 0 indicates NoSuchInstance
(i.e. boolean false). |