SnmpExtensionTrap

The extensible agent calls the SnmpExtensionTrap function in the extension agent DLL to retrieve traps generated by the extension agent.

BOOL SnmpExtensionTrap(

AsnObjectIdentifier *enterprise, // Generating enterprise
AsnInteger *genericTrap, // Generating trap type
AsnInteger *specificTrap, // Enterprise specific type
AsnTimeticks *timeStamp, // Time stamp
RFC1157VarBindList *variableBindings // Variable bindings
);  

Parameters

enterprise

[out] Points to an object identifier that indicates the originating object generating the trap. The extensible agent does not free the memory for this variable.

genericTrap

[out] Points to an indication of the generic trap. This parameter can be one of the following values:

Value Meaning
SNMP_GENERICTRAP_COLDSTART The agent is initializing protocol entities on the managed mode. It may alter objects in its view.
SNMP_GENERICTRAP_WARMSTART The agent is re-initializing itself but will not alter objects within its view.
SNMP_GENERICTRAP_LINKDOWN An attached interface has changed from the up state to the down state. The first variable identifies the interface.
SNMP_GENERICTRAP_LINKUP An attached interface has changed from the down state to the up state. The first variable identifies the interface.
SNMP_GENERICTRAP_AUTHFAILURE An SNMP entity has sent an SNMP message, but has falsely claimed to belong to a known community.
SNMP_GENERICTRAP_EGPNEIGHLOSS An EGP peer has changed to the down state. The first variable identifies the IP address of the EGP peer.
SNMP_GENERICTRAP_ENTERSPECIFIC Signals an extraordinary event that is identified in the specific-trap parameter.

specificTrap

[out] Points to an indication of the specific trap generated.

timeStamp

[out] Points to a variable to receive the time stamp.

variableBindings

[out] Points to the variable bindings list. The memory for the list will be allocated by the extension agent. The extensible agent will free the memory with a call to the SnmpUtilVarBindListFree function.

Return Values

If the SnmpExtensionTrap function returns a trap in its parameters, the return value is TRUE. Otherwise, the extensible agent repeatedly calls the function until it returns a value of FALSE.

Remarks

The extensible agent repeatedly calls the SnmpExtensionTrap function once the hPollForTrapEvent event handle of the SnmpExtensionInit function has been set to the signaled state. Each successful call returns data from a single trap. It returns FALSE to indicate that its parameters do not represent valid trap data and to stop the extensible agent's repeated calls.

The extension agent must not free the memory for the variableBindings parameter. The extensible agent automatically performs this action. Use the SnmpUtilMemAlloc function to allocate memory for each RFC1157VarBind structure.

It is important to note that earlier documentation stated that the extension agent should dynamically allocate memory for the enterprise object identifier because the extensible agent would attempt to release the memory after sending a trap. The extensible agent will not release the memory associated with the enterprise object identifier. The recommendation is that you return a pointer to a static AsnObjectIdentifier structure instead.

See Also

SetEvent, SnmpUtilMemAlloc, SnmpUtilVarBindListFree, RFC1157VarBindList, SnmpExtensionInit