SNMP Subagent Programmer's Guide

Writing Subagent Logic
SNMP Subagent Programmer’s Guide—119728 4-29
Callback Functions
Access Functions
Access functions are used to provide logic for the run-time library to use for a MIB
object when a manager wants to perform Get or Set operations on it. When the run-time
library calls an access function, it passes it the value for a MIB object; the function
returns an indication of success or failure. Write your own access functions when the
access functions generated by GDMOC are not able to handle the request processing
required.
static int
is an indication of the success of the function call. The subagent returns one of the
following values, defined in the header file named snmperrh:
0 (SNMP_ERR_NO_ERROR)
1 (SNMP_ERR_TOO_BIG)
2 (SNMP_ERR_NO_SUCH_NAME)
3 (SNMP_ERR_BAD_VALUE)
4 (SNMP_ERR_READ_ONLY)
5 (SNMP_ERR_GEN_ERR)
The NonStop agent passes the error information to the manager. In the case of
SNMP_ERR_READ_ONLY, the agent passes SNMP_ERR_NO_SUCH_NAME. In
the case of the other errors, the agent passes the string associated with the error.
When a Test operation fails, the Set function is never called.
GET_access-function-name
identifies a function responsible for returning the value of a MIB object.
SET_access-function-name
identifies a function responsible for modifying the value of a MIB object to match
the value indicated by the value argument.
TEST_access-function-name
identifies a function responsible for determining whether a Set operation should be
allowed.
#include "smitypeh"
#include "snmperrh"
static int
{ GET_ | SET_ | TEST_ }access-function-name
(context, index-list, value);
void *context;
void **index-list;
void *value;