SNMP Subagent Programmer's Guide

Writing and Compiling MIBs
SNMP Subagent Programmer’s Guide119728 3-9
Encoding MIBs
C_ACCESS_FUNC access-function-name
specifies that the subagent supplies its own code for Get, Set, and Test
operations on the object. Although you can often rely on the access
functions GDMOC generates, in some cases your subagent needs more
control over the processing associated with Get, Set, and Test operations.
Refer to Section 4, “Writing Subagent Logic,” for more information about
how and when to encode access functions.
The name you encode as access-function-name is actually the suffix to the
function names you use in your subagent:
GET_access-function-name() returns the value of the MIB object.
SET_access-function-name() modifies the value of the MIB object.
TEST_access-function-name() determines whether a pending
modification of the variable is allowed. Test functions examine such
criteria as user access privileges or input value validity.
Set and Test functions are needed only for MIB objects that have the read-
write access attribute.
MIB variables associated with access functions do not have to be global
variables.
C_STRUCT struct-name, FIELD field-name
specifies that the MIB object value is maintained in the field identified
by field-name of a C global data structure identified by struct-name.
This form is frequently used when modelling an object in a table entry.
C_TYPE struct-name, FIELD field-name
specifies that the MIB object value is maintained in an element of a C global
data structure defined using a typedef construct. Otherwise, this form is the
same as the C_STRUCT form.
C_LOCATOR_FUNC locator-function-name
identifies a subagent function, identified by locator-function-name, known as a
“locator function.” The run-time library calls this function whenever the
associated MIB object is about to be accessed. Notifying the subagent before
any information is accessed is a particularly valuable behavior when you need to
use caching, database access, or remote access to obtain the information. You
can also encode a locator function for the run-time library to use in conjunction
with table handling, as described later in this section, under “Table Definitions.
The C_LOCATOR_FUNC clause must follow one of the C-access-method
clauses described earlier.
Refer to Section 4, “Writing Subagent Logic,” for information about how and
when to encode locator functions.