SNMP Subagent Programmer's Guide

Writing Subagent Logic
SNMP Subagent Programmer’s Guide119728 4-25
Callback Functions
Callback Functions
You can write functions for the run-time library to use when performing SNMP
operations. Known as “callback functions,” they are encoded in your subagent and
referred to by name in your MIB definition. The run-time library invokes callback
functions when the associated MIB object is the target of an SNMP operation.
The callback functions are summarized in Table 4-3 and described individually in more
detail later in this section; encode function names and the types of their arguments using
the uppercase and lowercase conventions used in the syntax boxes.
When to Use Callback Functions
Table 4-4 summarizes the conditions under which callback functions are useful.
Table 4-3. Callback Functions
Function Type Function Name Use
Access functions GET_access-function-
name()
SET_access-function-
name()
TEST_access-
function-
name()
These functions perform Get, Set, and
Test operations on a MIB object. If the
MIB object has an access type of read-
only, you only need to supply a
function that performs a Get operation.
If the object has read-write access, you
supply three functions: one to Get a
new value, one to Test the value, and
one to Set the value. Access functions
accept the value for a MIB object and
return an indication of success or
failure.
Locator functions locator-function-
name
These functions let your subagent
perform some operation before
responding to an SNMP request. They
accept arguments that identify a MIB
object, and return a pointer to its
associated context. Locator functions
are often used to locate the table entry
that is the target of Get, GetNext, or Set
operations.
Next functions next-function-name These functions keep track of the
location of the lexically next table
entry. They accept index values from
SNMP requests and return the index for
the next table entry. During GetNext
operations, a next function is called
before a locator function.