Platform SDK: Network Management |
The Microsoft SNMP service calls the SnmpExtensionTrap function to retrieve information the service needs to generate traps for the SNMP extension agent. The service calls this function only after the extension agent sets the trap event handle to the signaled state during a call to the SnmpExtensionInit function. The SnmpExtensionTrap function is an element of the SNMP Extension Agent API.
BOOL SnmpExtensionTrap( AsnObjectIdentifier *pEnterpriseOid, // generating enterprise AsnInteger32 *pGenericTrapId, // generating trap type AsnInteger32 *pSpecificTrapId, // enterprise-specific type AsnTimeticks *pTimeStamp, // time stamp SnmpVarBindList *pVarBindList // variable bindings );
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 pSpecificTrapId parameter. |
If the SnmpExtensionTrap function returns a trap, the return value is TRUE. The SNMP service repeatedly calls the function until it returns a value of FALSE. For additional information, see the following Remarks section.
The SNMP service repeatedly calls the SnmpExtensionTrap function when the phSubagentTrapEvent event handle is set to the signaled state. This handle is passed back during the call to the SnmpExtensionInit entry point function. The SnmpExtensionTrap function must return TRUE to indicate that the parameters contain valid data for a single trap. The function must return FALSE to indicate that the parameters do not represent valid trap data, and to stop the service's repeated calls.
Note that after the SNMP service sends a trap, it frees the memory associated with the variable binding list.
It is important to note that earlier documentation stated that the extension agent should dynamically allocate memory for the enterprise object identifier because the SNMP service would attempt to release the memory after sending a trap. The service will not release the memory associated with the enterprise object identifier. It is recommended that you return a pointer to a static AsnObjectIdentifier structure instead.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Snmp.h.
Simple Network Management Protocol (SNMP) Overview, SNMP Functions, SetEvent, SnmpUtilMemAlloc, SnmpUtilVarBindListFree, SnmpVarBindList, SnmpSvcGetUptime, SnmpExtensionInit