SNMP Subagent Programmer's Guide

Writing Subagent Logic
SNMP Subagent Programmer’s Guide—119728 4-33
Callback Functions
0 (LOCATE_SET)
1 (LOCATE_GET)
2 (LOCATE_NEXT)
3 (LOCATE_TEST)
4 (LOCATE_TRAP)
To support the creation of new table entries, a subagent should create and initialize
the new entry, then return the context pointer of the row when op is set to
LOCATE_SET. The run-time library updates the entry with the values contained in
the SNMP Set request.
Example
The following example is taken from the Dynamic Directory sample program. This
program contains a locator function named locate_file, which the run-time library calls
when it needs to find an entry in the table named dirFiles:
dirFiles OBJECT-TYPE
SYNTAX SEQUENCE OF FileEntry
...
FileEntry ::=
SEQUENCE {
fileName
DisplayString
}
fileName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
C_STRUCT file_entry, FIELD file_name
C_LOCATOR_FUNC locate_file
STATUS mandatory
DESCRIPTION
"The name of one of the files in the directory."
::= { fileEntry 1 }
The table in this MIB is dynamic because its entries are file names associated with a
particular subvolume at any time. Because the table is dynamic, the subagent needs to
rebuild it each time an SNMP request for an entry arrives. The subagent registers the
entire table rather than each entry in the table, so it must provide both a locator function
and a next function.