SNMP Subagent Programmer's Guide

Writing Subagent Logic
SNMP Subagent Programmer’s Guide119728 4-23
Management Functions
mgmt_trap()
The mgmt_trap() function generates a trap.
When executing this function, the run-time library calls the Get access function
associated with each MIB object for which a value is included in the trap. The library
acts as described earlier, under “mgmt_poll(),” for a Get operation, using either access
functions generated by GDMOC or access functions you provide in your subagent.
rc
is an indication of the success of the function call. A value of 0 indicates the trap
was sent successfully. A nonzero value indicates the trap could not be sent.
mgmt-env
is the void pointer returned from an earlier call to mgmt_init_env().
trap-type
is a pointer to the notification structure generated by GDMOC when the MIB
definition for the trap was compiled. The name of the data structure is generated by
adding the prefix TRAP_ to the trap name in the MIB definition.
Entry Conditions
The value of mgmt-env must be valid. The objects referenced in the trap definition must
have been instantiated by using mgmt_new_instance(). If indexed variables are included
in the trap, locator functions for these variables are invoked automatically when the
subagent does not perform individual entry registration.
Errors
One of the following values, defined in errnoh, is returned if mgmt_trap() fails:
#include "mgmtpubh"
#include "errnoh"
rc = mgmt_trap(mgmt-env, trap-type);
int
mgmt_trap (mgmt-env, trap-type);
void *mgmt-env;
struct notification *trap-type;
-1 Connection with the NonStop agent could not be made.
EFAULT One or more of the argument pointers is NULL.
ENOMEM Not enough memory could be allocated to process the function.
E2BIG The trap PDU exceeds the maximum allowable value of 2048
bytes.