SNMP Subagent Programmer's Guide

Writing Subagent Logic
SNMP Subagent Programmer’s Guide119728 4-27
Callback Functions
Define the locator function following the C_VARIABLE, C_ACCESS_FUNC,
C_STRUCT, or C_TYPE extension.
Next Functions
Next functions are identified in the INDEX clause associated with a table entry. In the
following example, from the Indexed Trap Generator MIB, the next function is named
next_entry. The run-time library calls next_entry to process GetNext operations. This
next function returns a pointer to the index of the lexically next entry in the table. The
index in this example consists of two values: a card number and a port number.
tblTrapTableEntry OBJECT-TYPE
SYNTAX TableEntry
ACCESS not-accessible
STATUS mandatory
DESCRIPTION
"Each tblTrapEntry holds the statistics for one port
on some card. These entries are indexed by card and
port number."
INDEX { cardNumber, portNumber }
C_NEXT_FUNC next_entry
::= { tblTrapTable 1 }
You must provide a next function if you do not register a table entry-by-entry. Do not
provide a next function if you register every entry.
Access Functions
Access functions are identified in the ACCESS clause for a MIB object. The following
example, illustrating an object from the System Time Manager MIB, shows how to let
the run-time library know the subagent provides access functions for the read-write
object named systemTimeString:
systemTimeString OBJECT-TYPE
SYNTAX DisplayString (SIZE (19))
ACCESS read-write
C_ACCESS_FUNC systemTimeString
STATUS mandatory
DESCRIPTION
"The system’s local system time. GET means get current
system time; SET means set system time. GET
will always work, but subagent process must
run as SUPER group member for SET to work.
Format of time string is: ''YYYY/MM/DD HH:MM:SS''.
SET time must be in the range 1975 Jan 01
00:00:00 to 4000 Dec 31 23:59:59.999999."
::= { systime 1 }
The name in the extension, systemTimeString, becomes the suffix to actual function
names provided by the subagent:
GET_systemTimeString
TEST_systemTimeString
SET_systemTimeString